Skip to content

Conversation

@jwagenet
Copy link
Contributor

@jwagenet jwagenet commented Dec 6, 2025

Improve and make consistent string representations for Vector, Location, Axis, and Plane.
All classes now follow format:

ax = Axis((1.11, 2.22, 3.33), (4.44, 5.55, 6.66))
str(ax): "Axis: (position=(1.11, 2.22, 3.33), direction=(0.455842, 0.569803, 0.683763))"
repr(ax): "Axis((1.11, 2.22, 3.33), (0.45584230583855184, 0.5698028822981898, 0.6837634587578277))"

Changes

  • Add __format__ for Vector to simplify formatting Vector tuples
  • __repr__ follows format class_name(attribute1, attribute2, ...) where float format is .13g (previously used for Vector). repr() is intended to explicitly reproduce the class if executed
  • __str__ follows format class_name: ("attribute1"=attribute1, "attribute2"=attribute2, ...) where float format is .6g (TOL_DIGITS)
  • Use .6g for Vector formats in show_topology
  • Correct Location kwarg names and make docstrings more concise
    • Explicitly position, direction, angle constructor in branches

Resolves #1104

@jwagenet
Copy link
Contributor Author

jwagenet commented Dec 6, 2025

I'm not married to .6g precision for str and .13g precision for repr. I think both could be smaller, especially repr, since effective precision is generally limited by TOLERANCE

@codecov
Copy link

codecov bot commented Dec 6, 2025

Codecov Report

❌ Patch coverage is 97.72727% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 96.34%. Comparing base (20854b3) to head (17b1bd8).
⚠️ Report is 77 commits behind head on dev.

Files with missing lines Patch % Lines
src/build123d/geometry.py 97.61% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1160      +/-   ##
==========================================
- Coverage   96.59%   96.34%   -0.26%     
==========================================
  Files          34       34              
  Lines       11118    11421     +303     
==========================================
+ Hits        10739    11003     +264     
- Misses        379      418      +39     

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Improve Axis __repr__

1 participant