Skip to content

Conversation

Joschua-Conrad
Copy link

@Joschua-Conrad Joschua-Conrad commented Oct 10, 2025

First of all: I love working with CQ, thank you for maintaining this library!

Plane supports conversion between local/global coordinate systems, and Location supports chaining coordinate-system offsets.
So I from time to time want to convert between them.
However, while there is a Location.__init__ from Plane and a Location.plane property, I did not find an implementation of the opposite conversion.
This PR adds this conversion from Location to Plane.

Some things I ask the reviewers to notice and possibly discuss:

  • I tried using @multimethod on Plane.__init__. But that then disallows passing keyword arguments to the constructor, and that is needed in existing code. Using @multidispatch produces working code, but Sphinx docs do not support it. So I left Plane.__init__ untouched and added a Plane.fromLocation class-method.
  • The Location.plane property I added is analogous to Plane.location.
  • I did not find a test of geom.py, so I added test_geom.py. The new test creates a Plane and then runs through a chain of conversions Plane -> Location -> Plane -> Location. In the end, there are two Planes and two Locations, which have to be equal, respectively. This is asserted, along with origin and rotations of the first created Location.
  • pytest, build_docs.sh, and black all pass, and yield the same warnings as on the master branch.

I'm excited about your feedback!

Otherwise creating of Plane from tuple of int does not work anymore due to introduced @multimethod
Instead of just creating a temporary plane and rotating it
multimethod did not work, as that disallows keyword arguments for construction of Plane, which ruins many tests
multidispatch works with keyword arguments, but looks horrible in docs
Construction from class method just works.
Copy link

codecov bot commented Oct 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.75%. Comparing base (dadf151) to head (198e32e).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1912   +/-   ##
=======================================
  Coverage   95.74%   95.75%           
=======================================
  Files          29       29           
  Lines        7827     7842   +15     
  Branches     1179     1179           
=======================================
+ Hits         7494     7509   +15     
  Misses        192      192           
  Partials      141      141           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Joschua-Conrad Joschua-Conrad marked this pull request as ready for review October 10, 2025 08:54
self.origin = Vector(origin)

@classmethod
def fromLocation(cls, loc: "Location",) -> "Plane":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not an __init__ overload?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see it in the description. I think we'd rather have an __init__ version.

Sphinx fix PRs are highly welcome ;). Probably it will require a custom plugin...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants