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

Standardize file type handling in gsd_utils #6

Merged
merged 12 commits into from
Apr 15, 2021

Conversation

chrisjonesBSU
Copy link
Member

@chrisjonesBSU chrisjonesBSU commented Apr 13, 2021

This PR does the following:

  • Allows all of the functions in gsd_utils.py to handle either a gsd file and frame number, or work directly with a gsd.hoomd.snapshot

I added a _validate_inputs() function which both checks for what is being passed in (file or snap) and does some quick validation. The function returns a snapshot regardless of what's passed in. It gets called at the beginning of each of the util functions, which then work with snapshots.

  • Re-names a couple functions

frame_get_type_positions renamed to get_type_positions so that it's shorter.
snap_molecule_indices renamed to snap_molecule_cluster so that it more closely matches the naming of freud.cluster.Cluster() which this function is basically a quick wrapper for.

  • Adds a new function that returns all of the particle types in a gsd file/snapshot
    Nothing fancy, just a quick helper/utility function.

@codecov
Copy link

codecov bot commented Apr 13, 2021

Codecov Report

Merging #6 (11a625b) into master (d7535cf) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master        #6   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines           10        38   +28     
=========================================
+ Hits            10        38   +28     
Impacted Files Coverage Δ
cmeutils/gsd_utils.py 100.00% <100.00%> (ø)

Copy link
Member

@jennyfothergill jennyfothergill 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 nice! Let's add tests for get_all_types and snap_molecule_cluster and maybe a test that _validate_inputs raises the error when all three args are provided.

@jennyfothergill jennyfothergill merged commit c731a24 into cmelab:master Apr 15, 2021
@chrisjonesBSU chrisjonesBSU deleted the add/gsdutils branch November 15, 2023 19:27
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.

gsd util functions should be able to work with gsd file or a snapshot
2 participants