-
Notifications
You must be signed in to change notification settings - Fork 108
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
fixed Sphere._vertices used before populated #1407
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1407 +/- ##
==========================================
+ Coverage 60.83% 61.29% +0.45%
==========================================
Files 207 207
Lines 22270 22270
==========================================
+ Hits 13549 13651 +102
+ Misses 8721 8619 -102 ☔ View full report in Codecov by Sentry. |
tests/compas/geometry/test_shpere.py
Outdated
assert len(sphere.edges) == 496 | ||
assert len(sphere.faces) == 256 | ||
assert len(sphere.vertices) == 242 |
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.
would be even better to relate these assertions to numbers derived from the discretisation params (u, v)
this is happening because i (wrongly) imagined/assumed that faces or edges would be accessed after vertices, and i wanted to avoid recomputing the vertices over and over again, if not necessary. intention was good, implementation bad :) would be nice if we can find another way to handle this... |
Well I mean edges and faces are cached so the the compute methods should only be called once.. I assumed the vertices are not cached for the case resolution is changed, but since edges and faces are perhaps we should cache vertices as well? We could maybe use a reset computed kind of decorator to invalidate caches.. |
would be nice but i don't see an easy solution. we could monitor the shape's own properties but modifications can be made at a deeper level and then things become tricky. for example cylinder = Cylinder(radius=1.0, height=1.0)
# all of the following would have to trigger a cache reset
cylinder.radius = ...
cylinder.height = ...
cylinder.resolution_u = ...
cylinder.resolution_v = ...
cylinder.frame = ...
cylinder.frame.point = ...
cylinder.frame.point.x = ...
... not sure how we can elegantly track this. |
anyway perhaps that is not the point of this PR... |
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.
LGTM
I see, indeed tricky. |
Small fix in
Sphere
of issue causingSphere.edges
andSphere.faces
to fail if calls before first call toSphere.vertices
.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
.