Skip to content

Commit

Permalink
PEP 8
Browse files Browse the repository at this point in the history
  • Loading branch information
zwsmith200 committed Nov 1, 2023
1 parent 3d81e39 commit 38a2d4b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
11 changes: 5 additions & 6 deletions package/MDAnalysis/topology/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ def squash_by(child_parent_ids, *attributes):

def squash_by_attributes(squash_attributes, *other_attributes):
"""Squash a child-parent relationship using combinations of attributes
parents will retain their order of appearance
parents will retain their order of appearance
Arguments
---------
squash_attributes - list of attribute arrays (attributes used to
squash_attributes - list of attribute arrays (attributes used to
identify the parent)
*other_attributes - other arrays that need to follow the sorting of ids
Expand All @@ -164,18 +164,17 @@ def squash_by_attributes(squash_attributes, *other_attributes):
unique_combos, sort_mask, atom_idx = np.unique(
squash_array, return_index=True, return_inverse=True, axis=0)


appearance_order = np.argsort(sort_mask)
new_index = np.arange(0,len(appearance_order))
new_index = np.arange(0, len(appearance_order))
resort_pairs = np.column_stack((appearance_order, new_index))
atom_idx_mapping = dict(resort_pairs)

sorted_atom_idx = np.vectorize(atom_idx_mapping.get)(atom_idx).astype(int)
sorted_mask = np.sort(sort_mask)

squashed_attrs = [attr[sorted_mask] for attr in squash_attributes]
other_attrs = [attr[sorted_mask] for attr in other_attributes]

return sorted_atom_idx, squashed_attrs, other_attrs


Expand Down
1 change: 1 addition & 0 deletions testsuite/MDAnalysisTests/topology/test_mol2.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ def test_unformat():
match='Some atoms in the mol2 file'):
u = mda.Universe(StringIO(mol2_resname_unformat), format='MOL2')


def test_repeat_resid():
u = mda.Universe(StringIO(mol2_repeat_resid), format='MOL2')

Expand Down
7 changes: 4 additions & 3 deletions testsuite/MDAnalysisTests/topology/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,12 @@ def test_nobonds_error():

pdb_repeat_resid = """\
ATOM 1 CA LYS A 1 65.978 40.866 -0.183 1.00 0.00 C
ATOM 2 CA SER A 2 64.324 40.006 3.164 1.00 0.00 C
ATOM 3 CA LEU A 1 64.000 39.236 8.648 1.00 0.00 C
ATOM 4 N LYS A 1 66.135 42.099 -1.007 1.00 0.00 N1+
ATOM 2 CA SER A 2 64.324 40.006 3.164 1.00 0.00 C
ATOM 3 CA LEU A 1 64.000 39.236 8.648 1.00 0.00 C
ATOM 4 N LYS A 1 66.135 42.099 -1.007 1.00 0.00 N
"""


def test_repeat_resid():
u = mda.Universe(StringIO(pdb_repeat_resid), format='PDB')

Expand Down

0 comments on commit 38a2d4b

Please sign in to comment.