mirror of
https://github.com/gumyr/build123d.git
synced 2026-03-09 00:02:04 -07:00
Main issue, which concerns Vector, Location, and ShapeList: Comparison with an object of a different type should not cause an exception - they are simply not equal. Raising an exception in __eq__ can (and will*) break unrelated code that expects __eq__ to be well-behaved. (* I noticed this bug when cq-editor choked on it while trying to find a name for an object in a dictionary of local variables) There's a second more minor issue, which concerns the rest of the classes: When the other type in __eq__ is not supported, one should technically return NotImplemented instead of False, to allow the other type to take part in the comparison, in case they know about our type. (__ne__ should also not generally be implemented as just the negation of __eq__ because of this, but that's also a moot point because the __ne__ can just be removed - Python will automatically do the right thing based on __eq__ here) Technically, the __eq__ for Vector and Plane is also broken in another way: It's not transitive. >>> a, b, c = Vector(0), Vector(9e-6), Vector(18e-6) >>> a == b == c True >>> a == c False They should really eg. have a separate is_close() for approximate comparison, but this isn't fixed here, since I have no idea how many places it'd break, for one. |
||
|---|---|---|
| .. | ||
| cyl_w_rect_hole.stl | ||
| svg_import_test.svg | ||
| test_algebra.py | ||
| test_build_common.py | ||
| test_build_enums.py | ||
| test_build_generic.py | ||
| test_build_line.py | ||
| test_build_part.py | ||
| test_build_sketch.py | ||
| test_direct_api.py | ||
| test_drafting.py | ||
| test_exporters.py | ||
| test_exporters3d.py | ||
| test_importers.py | ||
| test_joints.py | ||
| test_mesher.py | ||
| test_pack.py | ||
| test_persistence.py | ||
| test_topo_explore.py | ||