-
-
Notifications
You must be signed in to change notification settings - Fork 654
refactor(34773): combinatorial polyhedron: move list of pairs to dedicated class #35073
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
refactor(34773): combinatorial polyhedron: move list of pairs to dedicated class #35073
Conversation
Codecov ReportBase: 88.59% // Head: 88.58% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## develop #35073 +/- ##
===========================================
- Coverage 88.59% 88.58% -0.02%
===========================================
Files 2140 2140
Lines 396998 396961 -37
===========================================
- Hits 351740 351632 -108
- Misses 45258 45329 +71
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
…_list_of_pairs_to_dedicated_class' into refactor/34773/move_list_of_pairs_to_dedicated_class
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.
While the changes here are unlikely to have any major net change on the timings, nevertheless it would be good to check on an example or two.
cdef size_t j | ||
if add_equations and names: | ||
# Also getting the equations for each facet. | ||
return tuple( | ||
(((facet_one(i),) + self.equations()), | ||
((facet_two(i),) + self.equations())) | ||
for i in range(n_ridges)) | ||
def get_ridge(size_t i): | ||
ridge = self._ridges.get(i)[0] | ||
return ((f(ridge.first),) + self.equations(), | ||
(f(ridge.second),) + self.equations()) | ||
|
||
else: | ||
return tuple((facet_one(i), facet_two(i)) | ||
for i in range(n_ridges)) | ||
def get_ridge(size_t i): | ||
ridge = self._ridges.get(i)[0] | ||
return (f(ridge.first), f(ridge.second)) | ||
|
||
cdef size_t j | ||
return tuple(get_ridge(j) for j in range(n_ridges)) |
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 am not sure about these changes. They seem to slow it down (extra Python function calls) and is at best a net zero improvement to readability (I would actually argue it makes it more complicated). Although I guess you are halving the number of function calls, but I think it would be better to just have the two cases do a return
.
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.
Improved in 2367bc9.
while (dimension_one < dim + 1): | ||
already_seen = sum(f_vector[j] for j in range(dimension_two + 1)) | ||
already_seen_next = already_seen + f_vector[dimension_two + 1] | ||
while (dimension_one < dim + 1): |
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.
while (dimension_one < dim + 1): | |
while dimension_one < dim + 1: |
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.
Done in 2367bc9.
self._lists[n_lists] = <pair_s*> check_allocarray(length_per_list, sizeof(pair_s)) | ||
self.length += 1 | ||
|
||
cdef inline pair_s* get(self, size_t index) except NULL: |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
Done in 2367bc9.
cdef size_t first, second | ||
(first, second) = value | ||
|
||
if (index == self.length): |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
Done in 2367bc9.
I did, but of course it valuable to share this Before:
After:
|
Thank you. LGTM. |
Thank you. |
Documentation preview for this PR is ready! 🎉 |
📚 Description
CombinatorialPolyhedron
currently contains a lot of code related to (possibly long) lists of pairs. This code can and should be moved elsewhere. This is a step towards better readability and allowing future changes to the code.This is a first step of #34773.
Along the way I update my outdated email address.
📝 Checklist
⌛ Dependencies