-
-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use of <source class>.to_<target class>
methods
#155
Comments
I propose this :
|
Although I haven't pushed it yet, I have have two modules: |
wow, that is awesome progress! |
The restructuring to |
Taking a quick look at the 234 | def to_tuple(self) -> tuple[float, float, float]:
417 | def to_pnt(self) -> gp_Pnt:
421 | def to_dir(self) -> gp_Dir:
584 | def to_plane(self) -> Plane:
845 | def to_align_offset(self, align: Tuple[float, float]) -> Tuple[float, float]:
949 | def to_tuple(self) -> Tuple[float, float, float, float]:
1282 | def to_axis(self) -> Axis:
1286 | def to_tuple(self) -> tuple[tuple[float, float, float], tuple[float, float, float]]:
2088 | def to_gp_ax2(self) -> gp_Ax2:
2136 | def to_local_coords(self, obj: Union[VectorLike, Any, BoundBox]):
2847 | def to_splines(
2880 | def to_vtk_poly_data(
2933 | def to_arcs(self, tolerance: float = 1e-3) -> Face:
4270 | def to_wire(self) -> Wire:
5001 | def to_axis(self) -> Axis:
6554 | def to_tuple(self) -> tuple[float, float, float]:
6682 | def to_wire(self) -> Wire: Lastly Anything I can do to help trim these down / refactor? |
How does this sound:
The sub-classes of Shape don't have init methods and should if the |
FWIW the built-in @dataclass
class A:
x: float
y: float
z: float
def to_tuple(self):
return self.x, self.y, self.z
def __iter__(self):
return iter((self.x, self.y, self.z))
a = A(1, 2, 3)
assert a.to_tuple() == tuple(a)
x,y,z = a
assert tuple(a) == (x,y,z) I won't risk claiming whether this is the way to go or not though |
Both print(tuple(Vertex(1, 2, 3)))
print(tuple(Vector(4, 5, 6))) results in
|
There are many methods that convert from one class to another - for example
Vector.to_vertex()
. These methods don't seem as pythonic as using the target class'__init__
method to do the conversion - e.g.Vertex(v:Vector)
. They also couple the classes together which makes separation into multiple modules impossible (or at least very difficult).I'm proposing converting all of the
to_class
methods over toclass()
. Is there any reason not to do this?The text was updated successfully, but these errors were encountered: