Skip to content

Additional clean up after initial alpha push - no new functionality#435

Merged
peterrrock2 merged 12 commits intomggg:wip/rustworkx-migrationfrom
chief-dweeb:frm_rustworkx_post_alpha
Jan 15, 2026
Merged

Additional clean up after initial alpha push - no new functionality#435
peterrrock2 merged 12 commits intomggg:wip/rustworkx-migrationfrom
chief-dweeb:frm_rustworkx_post_alpha

Conversation

@chief-dweeb
Copy link
Copy Markdown

Lots of lines that have changed - hopefully not too painful.

There is a block comment at the top of tree.py that you should look at. Tree.py is the file that got serious refactoring done. Most of the rest of the changes were of the clean-up variety.

Looking forward to your feedback..

-Fred

Copy link
Copy Markdown
Collaborator

@peterrrock2 peterrrock2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good so far! Couple of small nitpicks in here and then responses to your comments

Comment on lines +630 to +631
# frm: TODO: Documentation: more detail on contents of JSON file needed above in docstrings

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

Comment on lines +2049 to +2056
# frm: TODO: Refactoring: Encapsulate ALL NX dependencies in this file.

# frm: TODO: Refactoring: Move routines so that the ones that do NOT mirror NetworkX
# come at the end, after a comment to that effect.

# Note: The two laplacian functions: laplacian_matrix() and
# normalized_laplacian_matrix() are part of the Graph class primarily to
# encapsulate all NetworkX dependencies in one place - this module.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all sounds good to me

restarts = 0
attempts = 0

# frm: TODO: Code: When would it make sense for max_attempts to be None? Infinite loop potential...
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the None value is terrible. We should force it to be an int and put a defensive check before this.

Comment on lines +2028 to +2042
# frm: TODO: Refactoring: Remove old_bipartition_tree_random() after PR code review
#
# A while ago I added the routine, bipartition_tree_random_with_num_cuts() because
# the routine, reversible_recom() in tree_proposals.py had used an internal routine
# called _get_possible_edge_cuts_and_populated_graph() because it wanted to know how many possible
# cut solutions existed. I did what was expedient and just added a function inside
# tree.py that did what the code in tree_proposals.py did in order to hide the
# internal routine. I later realized that it was EXACTLY the same as bipartition_tree_random()
# except that it passed back one more value, so I just replaced the definitioin of
# bipartition_tree_random() with a call to bipartition_tree_random_with_num_cuts() and
# then discarded the extra num_cuts returned value.
#
# I am leaving this in the codebase for now, just to make it easier for Peter to see
# what is going on when he does a review. Note that after this change all tests passed
# (January 9, 20206)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Comment on lines +2152 to +2162
# frm: TODO: Refactoring: Would be nice to rename "method" to "bipartition_tree_method"
#
# This is clearly not a high priority, but it would be nice to have a parameter name that
# better stated what it meant. "method" indicates that it is a function, but what does
# the function do? When reading the code where "method" is called, it would have been
# nice to see bipartition_tree_method(...) instead.
#
# However, for legacy code reasons it is probably not worth changing. *sigh*
#
# Peter - please confirm that this is not something that is worth changing, and
# then I will be able to put it behind me ;-).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, go ahead and change this. Changing the method in the epsilon_tree_bipartition is rare, and I am willing to deal with any emails coming from the update.

Comment on lines +2862 to +2868
# frm TODO: Refactoring: recursicve_seed_part() is never called - not in this file and not in any other
# GerryChain file. Is it intended to be used by end-users?
#
# It calculates an initial assignment dictionary - for use in creating a Partition object.
#
# Are there other uses as well? The comment for recursive_tree_part() implied that there
# might be other uses for creating an initial assigment-like dict...
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unsure of what was in the mind of the creator of this function, but I have only ever seen it used for making initial partitions of a graph.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving recursive_seed_part, recursive_seed_part, and epsilon_tree_bipartition makes sense to me. My only organizational note is that I would like the recursive functions placed in something like "partition/initial_paritition_generators.py" rather than in "parition/partition.py" since they have been used for things outside of making a Partition object before, and we have some more algorithms that we might add to the mix later this year (also, I would like to try and move this repository to the "one thought per file" paradigm whenever we get the chance during this refactor). The epsilon_tree_bipartition is fine to go in "proposals/tree_proposals.py", however.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: we will need to make sure to add this to the top of the release notes.

chief-dweeb and others added 5 commits January 15, 2026 15:10
Co-authored-by: Peter <27579114+peterrrock2@users.noreply.github.com>
Co-authored-by: Peter <27579114+peterrrock2@users.noreply.github.com>
Co-authored-by: Peter <27579114+peterrrock2@users.noreply.github.com>
Co-authored-by: Peter <27579114+peterrrock2@users.noreply.github.com>
Co-authored-by: Peter <27579114+peterrrock2@users.noreply.github.com>
@chief-dweeb chief-dweeb reopened this Jan 15, 2026
@chief-dweeb
Copy link
Copy Markdown
Author

Peter,

I closed the PR, thinking that doing so would trigger an auto-merge, but when that did not seem to happen, I re-opened it.

Note that I committed all of your proposed changes.

I assume that it is up to you to do the merge. When you have done so, I will do a pull - just to be sure everything is synched, and then I will go back to making changes.

-Fred

@peterrrock2
Copy link
Copy Markdown
Collaborator

No problem. I'll merge this in now.

@peterrrock2 peterrrock2 merged commit 3c74895 into mggg:wip/rustworkx-migration Jan 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants