Skip to content
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

Return ragged arrays in Environment Matching Code #1064

Merged
merged 19 commits into from Mar 16, 2023

Conversation

tommy-waltmann
Copy link
Collaborator

Description

This PR makes the point_environments property of the EnvironmentCluster and EnvironmentMotifMatch, as well as the cluster_environments property of EnvironmentCluster, return a list if numpy arrays of different sizes.

Motivation and Context

This is a more intuitive way to return the data to the user, and the padded zero vectors in the previous implementation were confusing.

Resolves: #981

How Has This Been Tested?

Tests have been added to ensure raggedness of the properties which have had their behavior changed.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds or improves functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation improvement (updates to user guides, docstrings, or developer docs)

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • I have updated the documentation (if relevant).
  • I have added tests that cover my changes (if relevant).
  • All new and existing tests passed.
  • I have updated the credits.
  • I have updated the Changelog.

@tommy-waltmann tommy-waltmann requested a review from a team as a code owner January 27, 2023 16:07
@tommy-waltmann tommy-waltmann requested review from bdice and removed request for a team January 27, 2023 16:07
@tommy-waltmann tommy-waltmann added this to the v3.0.0 milestone Jan 27, 2023
@tommy-waltmann
Copy link
Collaborator Author

In addition to the changes here, I think the restriction that the disjoint set data structure (EnvDisjointSet) have a max number of neighbors in any given environment can be lifted now. I didn't write that code though, so I'm not quite sure, @vyasr any thoughts?

@vyasr
Copy link
Collaborator

vyasr commented Jan 28, 2023

Hmm yeah I think that sounds right. The only reason that was needed was to properly size the output arrays and to control iteration bounds, but with a ragged array you can iterate properly over each subarray (environment) so it should be safe to stop tracking that. Let me know if you run into any issues with removing it, but I think it should be fine.

Copy link
Member

@b-butler b-butler left a comment

Choose a reason for hiding this comment

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

I am not overly familiar with the environment matching code, but the changes look good.

cpp/environment/MatchEnv.cc Outdated Show resolved Hide resolved
Co-authored-by: Brandon Butler <butlerbr@umich.edu>
Copy link
Member

@bdice bdice left a comment

Choose a reason for hiding this comment

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

A few small suggestions.

cpp/environment/MatchEnv.cc Outdated Show resolved Hide resolved
cpp/environment/MatchEnv.cc Outdated Show resolved Hide resolved
cpp/environment/MatchEnv.cc Outdated Show resolved Hide resolved
doc/source/reference/credits.rst Outdated Show resolved Hide resolved
tests/test_environment_MatchEnv.py Outdated Show resolved Hide resolved
tests/test_environment_MatchEnv.py Outdated Show resolved Hide resolved
ChangeLog.md Outdated Show resolved Hide resolved
@tommy-waltmann tommy-waltmann merged commit 3954c5d into next Mar 16, 2023
22 checks passed
@tommy-waltmann tommy-waltmann deleted the ragged-env-properties branch March 16, 2023 18:29
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.

None yet

4 participants