-
Notifications
You must be signed in to change notification settings - Fork 110
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
Add some more __str__ function to geometry classes for pretty print #1289
Conversation
The truth value of an array with more than one element is ambiguous.
…d Polyhedron classes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a few comments but generally looking good!
points = box.points | ||
x, y, z = zip(*points) | ||
xmin, xmax = min(x), max(x) | ||
ymin, ymax = min(y), max(y) | ||
zmin, zmax = min(z), max(z) | ||
xmin, xmax = box.xmin, box.xmax | ||
ymin, ymax = box.ymin, box.ymax | ||
zmin, zmax = box.zmin, box.zmax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is not related to the str stuff, is it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change is there because I couldn't actually run tests without fixing the broken functions.
src/compas/geometry/polygon.py
Outdated
@@ -103,6 +103,9 @@ def __init__(self, points, name=None): | |||
def __repr__(self): | |||
return "{0}(points={1!r})".format(type(self).__name__, self.points) | |||
|
|||
def __str__(self): | |||
return "{0}(points={1})".format(type(self).__name__, [point.__str__() for point in self.points]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switch to str()
as above
@yck011522 please keep the PR focused on the implementation of |
@tomvanmele The associated changes are there only because those functions were broken to the point that prevented me to test out the new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, this slipped through the cracks... it lgtm!
@yck011522 could you fix the conflict so that we can merge? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides the changelog fix it lgtm
CHANGELOG.md
Outdated
@@ -268,6 +268,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
* Changed `compas.scene.VolMesh`'s `show_vertices`, `show_edges`, `show_faces`, `show_cells` to optionally accept a sequence of keys. | |||
* Fixed missing implementation of `Sphere.base`. | |||
* Fixed bug in `intersection_sphere_sphere`. | |||
* Changed the `__str__` of `compas.geometry.Frame`, `compas.geometry.Plane`, `compas.geometry.Polygon`, `compas.geometry.Polyhedron`, `compas.geometry.Quaternion` to use a limited number of decimals (determined by `Tolerance.PRECISION`). Note: `__repr__` will instead maintain full precision. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you update this? Because after the merge it's way down in the file, changing an already released version
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1289 +/- ##
==========================================
+ Coverage 60.11% 60.19% +0.07%
==========================================
Files 207 207
Lines 22234 22248 +14
==========================================
+ Hits 13366 13392 +26
+ Misses 8868 8856 -12 ☔ View full report in Codecov by Sentry. |
@tomvanmele @gonzalocasas |
Because newer float format behavior is different in different python versions
there seems to be a problem with TOL.format_numbers not passing test
I was trying to add some more tests to cover the str and repr functions. However I realized that the underlying mechanism of formatting the numbers in Point is based on So I have decided to open another PR to investigate the problem and this PR will not have those tests included. |
Having coverage metrics is good, but we don't intend to be obsessive about it |
@yck011522 the test is just feedback about coverage. it will not block the PR from being merged... |
Partially Fixes #1287
What type of change is this?
Checklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.CHANGELOG.md
file in theUnreleased
section under the most fitting heading (e.g.Added
,Changed
,Removed
).invoke test
).invoke lint
).compas.datastructures.Mesh
.