-
Notifications
You must be signed in to change notification settings - Fork 258
Make Regression Tests Pass by Default #2983
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
base: main
Are you sure you want to change the base?
Changes from all commits
9156e75
8405c3f
8b52c36
96cc1eb
52237f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1066,9 +1066,10 @@ def descend_tree(self, structure, atoms, root=None, strict=False): | |
| else: | ||
| return root | ||
| else: | ||
| # logging.warning('For {0}, a node {1} with overlapping children {2} was encountered ' | ||
| # 'in tree with top level nodes {3}. Assuming the first match is the ' | ||
| # 'better one.'.format(structure, root, next, self.top)) | ||
| # Multiple children match - pick the first in tree order. | ||
| # The tree is constructed deterministically, so this is deterministic. | ||
| # (Sorting by label can pick the wrong node when siblings overlap, | ||
| # e.g. Nitrites sorts before Nitro but Nitro is the intended match.) | ||
|
Comment on lines
-1069
to
+1072
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logging line was commented out 12 year ago e8c7f1d, so is probably fine to remove. What does the "sorting by label" part of the new comment refer to? |
||
| return self.descend_tree(structure, atoms, next_node[0], strict) | ||
|
|
||
| def are_siblings(self, node, node_other): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -324,7 +324,7 @@ def combine_cycles(cycle1, cycle2): | |
| """ | ||
| set1 = set(cycle1) | ||
| set2 = set(cycle2) | ||
| return list(set1.union(set2)) | ||
| return sorted(set1.union(set2)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where in the code is |
||
|
|
||
|
|
||
| def is_aromatic_ring(submol): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -469,7 +469,10 @@ cdef class Graph(object): | |
| cpdef sort_vertices(self, bint save_order=False): | ||
| """ | ||
| Sort the vertices in the graph. This can make certain operations, e.g. | ||
| the isomorphism functions, much more efficient. | ||
| the isomorphism functions, much more efficient. Vertices that have a | ||
| ``sorting_key`` attribute (e.g. :class:`Atom`) will use it as a chemical | ||
| tiebreaker for vertices with identical connectivity values, ensuring | ||
| deterministic ordering. | ||
| """ | ||
| cdef Vertex vertex | ||
| cdef int index | ||
|
|
@@ -485,7 +488,21 @@ cdef class Graph(object): | |
| # If we need to sort then let's also update the connecitivities so | ||
| # we're sure they are right, since the sorting labels depend on them | ||
| self.update_connectivity_values() | ||
| self.vertices.sort(key=get_vertex_connectivity_value) | ||
|
|
||
| # Build sort keys with optional chemical tiebreaker (sorting_key attribute) | ||
| # to ensure deterministic ordering when connectivity values are identical. | ||
| # Index is included as a final tiebreaker to avoid comparing vertex | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you need a final tiebreaker? I thought python's list.sort() was stable, meaning if there is a tie, the order remains the same, which is also the effect of your sorting by index. |
||
| # objects directly (GroupAtom has no __lt__). | ||
| # Sort (key, index) pairs, then use the resulting index order to reorder. | ||
| paired = [] | ||
| for index, vertex in enumerate(self.vertices): | ||
| conn = get_vertex_connectivity_value(vertex) | ||
| sort_key = getattr(vertex, 'sorting_key', None) | ||
| paired.append(((conn, sort_key if sort_key is not None else ()), index)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this not |
||
|
|
||
| paired.sort() | ||
| ordered = [self.vertices[idx] for _, idx in paired] | ||
| self.vertices = ordered | ||
| for index, vertex in enumerate(self.vertices): | ||
| vertex.sorting_label = index | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -615,7 +615,12 @@ def is_isomorphic(self, other, either_direction=True, check_identical=False, che | |
| save_order=save_order) | ||
|
|
||
| # Compare specific_collider to specific_collider | ||
| collider_match = (self.specific_collider == other.specific_collider) | ||
| if self.specific_collider is None: | ||
| collider_match = other.specific_collider is None | ||
| elif other.specific_collider is None: | ||
| collider_match = False | ||
| else: | ||
| collider_match = self.specific_collider.is_isomorphic(other.specific_collider) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The commit comment says this is to fix: |
||
|
|
||
| # Return now, if we can | ||
| if forward_reactants_match and forward_products_match and collider_match: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,12 +53,12 @@ | |
| toleranceMoveToCore=0.01, | ||
| toleranceKeepInEdge=0.001, | ||
| toleranceInterruptSimulation=1e8, | ||
| maximumEdgeSpecies=10000, | ||
| maximumEdgeSpecies=300, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are the changes to this file still required after your other changes, or could this be reverted? Changing from 10000 to 300 seems a little drastic to me. Can you comment on this change? (and the similar change to |
||
| minCoreSizeForPrune=10, | ||
| minSpeciesExistIterationsForPrune=2, | ||
| maxNumObjsPerIter=3, | ||
| filterReactions=True, | ||
| maxNumSpecies=35, | ||
| maxNumSpecies=15, | ||
| ) | ||
|
|
||
| options( | ||
|
|
||
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'm assuming this comment is correct, that tree construction is deterministic.