Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Mar 14, 2024
1 parent a50e506 commit 3e6019b
Showing 1 changed file with 40 additions and 11 deletions.
51 changes: 40 additions & 11 deletions cmeutils/gsd_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,13 +408,25 @@ def trim_snapshot_molecules(parent_snapshot, mol_indices):
new_snap.particles.N = sum(len(i) for i in mol_indices)

Check warning on line 408 in cmeutils/gsd_utils.py

View check run for this annotation

Codecov / codecov/patch

cmeutils/gsd_utils.py#L406-L408

Added lines #L406 - L408 were not covered by tests

# Write out particle info
for attr in ["position", "mass", "velocity", "orientation", "image", "diameter", "angmom", "typeid"]:
for attr in [

Check warning on line 411 in cmeutils/gsd_utils.py

View check run for this annotation

Codecov / codecov/patch

cmeutils/gsd_utils.py#L411

Added line #L411 was not covered by tests
"position",
"mass",
"velocity",
"orientation",
"image",
"diameter",
"angmom",
"typeid",
]:
setattr(

Check warning on line 421 in cmeutils/gsd_utils.py

View check run for this annotation

Codecov / codecov/patch

cmeutils/gsd_utils.py#L421

Added line #L421 was not covered by tests
new_snap.particles,
attr,
np.concatenate(
list(getattr(parent_snapshot.particles, attr)[i] for i in mol_indices)
)
list(
getattr(parent_snapshot.particles, attr)[i]
for i in mol_indices
)
),
)
new_snap.particles.types = parent_snapshot.particles.types

Check warning on line 431 in cmeutils/gsd_utils.py

View check run for this annotation

Codecov / codecov/patch

cmeutils/gsd_utils.py#L431

Added line #L431 was not covered by tests

Expand All @@ -429,9 +441,13 @@ def trim_snapshot_molecules(parent_snapshot, mol_indices):
mol_bond_groups = []
mol_bond_ids = []
for count, indices in enumerate(mol_indices):
mask = np.any(np.isin(parent_snapshot.bonds.group, indices.flatten()), axis=1)
mask = np.any(

Check warning on line 444 in cmeutils/gsd_utils.py

View check run for this annotation

Codecov / codecov/patch

cmeutils/gsd_utils.py#L441-L444

Added lines #L441 - L444 were not covered by tests
np.isin(parent_snapshot.bonds.group, indices.flatten()), axis=1
)
parent_mol_bonds = parent_snapshot.bonds.group[np.where(mask)[0]]
parent_mol_bond_typeids = parent_snapshot.bonds.typeid[np.where(mask)[0]]
parent_mol_bond_typeids = parent_snapshot.bonds.typeid[

Check warning on line 448 in cmeutils/gsd_utils.py

View check run for this annotation

Codecov / codecov/patch

cmeutils/gsd_utils.py#L447-L448

Added lines #L447 - L448 were not covered by tests
np.where(mask)[0]
]
new_mol_bonds = np.vectorize(particle_index_map.get)(parent_mol_bonds)
mol_bond_groups.append(new_mol_bonds)
mol_bond_ids.append(parent_mol_bond_typeids)

Check warning on line 453 in cmeutils/gsd_utils.py

View check run for this annotation

Codecov / codecov/patch

cmeutils/gsd_utils.py#L451-L453

Added lines #L451 - L453 were not covered by tests
Expand All @@ -445,9 +461,13 @@ def trim_snapshot_molecules(parent_snapshot, mol_indices):
mol_angle_groups = []
mol_angle_ids = []
for count, indices in enumerate(mol_indices):
mask = np.any(np.isin(parent_snapshot.angles.group, indices.flatten()), axis=1)
mask = np.any(

Check warning on line 464 in cmeutils/gsd_utils.py

View check run for this annotation

Codecov / codecov/patch

cmeutils/gsd_utils.py#L461-L464

Added lines #L461 - L464 were not covered by tests
np.isin(parent_snapshot.angles.group, indices.flatten()), axis=1
)
parent_mol_angles = parent_snapshot.angles.group[np.where(mask)[0]]
parent_mol_angle_typeids = parent_snapshot.angles.typeid[np.where(mask)[0]]
parent_mol_angle_typeids = parent_snapshot.angles.typeid[

Check warning on line 468 in cmeutils/gsd_utils.py

View check run for this annotation

Codecov / codecov/patch

cmeutils/gsd_utils.py#L467-L468

Added lines #L467 - L468 were not covered by tests
np.where(mask)[0]
]
new_mol_angles = np.vectorize(particle_index_map.get)(parent_mol_angles)
mol_angle_groups.append(new_mol_angles)
mol_angle_ids.append(parent_mol_angle_typeids)

Check warning on line 473 in cmeutils/gsd_utils.py

View check run for this annotation

Codecov / codecov/patch

cmeutils/gsd_utils.py#L471-L473

Added lines #L471 - L473 were not covered by tests
Expand All @@ -461,10 +481,18 @@ def trim_snapshot_molecules(parent_snapshot, mol_indices):
mol_dihedral_groups = []
mol_dihedral_ids = []
for count, indices in enumerate(mol_indices):
mask = np.any(np.isin(parent_snapshot.dihedrals.group, indices.flatten()), axis=1)
parent_mol_dihedrals = parent_snapshot.dihedrals.group[np.where(mask)[0]]
parent_mol_dihedral_typeids = parent_snapshot.dihedrals.typeid[np.where(mask)[0]]
new_mol_dihedrals = np.vectorize(particle_index_map.get)(parent_mol_dihedrals)
mask = np.any(

Check warning on line 484 in cmeutils/gsd_utils.py

View check run for this annotation

Codecov / codecov/patch

cmeutils/gsd_utils.py#L481-L484

Added lines #L481 - L484 were not covered by tests
np.isin(parent_snapshot.dihedrals.group, indices.flatten()), axis=1
)
parent_mol_dihedrals = parent_snapshot.dihedrals.group[

Check warning on line 487 in cmeutils/gsd_utils.py

View check run for this annotation

Codecov / codecov/patch

cmeutils/gsd_utils.py#L487

Added line #L487 was not covered by tests
np.where(mask)[0]
]
parent_mol_dihedral_typeids = parent_snapshot.dihedrals.typeid[

Check warning on line 490 in cmeutils/gsd_utils.py

View check run for this annotation

Codecov / codecov/patch

cmeutils/gsd_utils.py#L490

Added line #L490 was not covered by tests
np.where(mask)[0]
]
new_mol_dihedrals = np.vectorize(particle_index_map.get)(

Check warning on line 493 in cmeutils/gsd_utils.py

View check run for this annotation

Codecov / codecov/patch

cmeutils/gsd_utils.py#L493

Added line #L493 was not covered by tests
parent_mol_dihedrals
)
mol_dihedral_groups.append(new_mol_dihedrals)
mol_dihedral_ids.append(parent_mol_dihedral_typeids)

Check warning on line 497 in cmeutils/gsd_utils.py

View check run for this annotation

Codecov / codecov/patch

cmeutils/gsd_utils.py#L496-L497

Added lines #L496 - L497 were not covered by tests

Expand All @@ -476,6 +504,7 @@ def trim_snapshot_molecules(parent_snapshot, mol_indices):
new_snap.validate()
return new_snap

Check warning on line 505 in cmeutils/gsd_utils.py

View check run for this annotation

Codecov / codecov/patch

cmeutils/gsd_utils.py#L504-L505

Added lines #L504 - L505 were not covered by tests


def identify_snapshot_connections(snapshot):
"""Identify angle and dihedral connections in a snapshot from bonds.
Expand Down

0 comments on commit 3e6019b

Please sign in to comment.