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
tscrim
left a comment
There was a problem hiding this comment.
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.
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.
| 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.
| while (dimension_one < dim + 1): | |
| while dimension_one < dim + 1: |
| 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.
| 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.
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
CombinatorialPolyhedroncurrently 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