diff --git a/python/chemiscope/structures/__init__.py b/python/chemiscope/structures/__init__.py index 48cf1c696..107512e54 100644 --- a/python/chemiscope/structures/__init__.py +++ b/python/chemiscope/structures/__init__.py @@ -18,7 +18,7 @@ ase_tensors_to_ellipsoids, ase_vectors_to_arrows, ) -from ._mda import ( +from ._mda import ( # noqa: F401 _mda_to_json, _mda_valid_structures, _mda_list_atom_properties, @@ -47,7 +47,7 @@ def _guess_adapter(frames): stk_frames, use_stk = _stk_valid_structures(frames) if use_stk: return stk_frames, "stk" - + mda_frames, use_mda = _mda_valid_structures(frames) if use_mda: return mda_frames, "mda" @@ -133,10 +133,11 @@ def extract_properties(frames, only=None, environments=None): raise RuntimeError( "stk molecules do not contain properties, you must manually provide them" ) - + elif adapter == "mda": raise RuntimeError( - "MDAnalysis molecules do not contain properties, you must manually provide them" + "MDAnalysis molecules do not contain properties, you" + "must manually provide them" ) else: diff --git a/python/chemiscope/structures/_mda.py b/python/chemiscope/structures/_mda.py index 42323409d..028db74ff 100644 --- a/python/chemiscope/structures/_mda.py +++ b/python/chemiscope/structures/_mda.py @@ -8,7 +8,7 @@ HAVE_MDA = False -def _mda_valid_structures(frames: mda.Universe): +def _mda_valid_structures(frames): if HAVE_MDA and isinstance(frames, mda.Universe): return frames, True else: @@ -25,7 +25,8 @@ def _mda_to_json(ag): if ag.dimensions is not None: data["cell"] = list( np.concatenate( - mda.lib.mdamath.triclinic_vectors(ag.dimensions), dtype=np.float64 + mda.lib.mdamath.triclinic_vectors(ag.dimensions), + dtype=np.float64, # should be np.float64 otherwise not serializable ) ) diff --git a/python/tests/mda_structures.py b/python/tests/mda_structures.py index a4fee8bb3..dde98d1cc 100644 --- a/python/tests/mda_structures.py +++ b/python/tests/mda_structures.py @@ -10,7 +10,6 @@ BASE_FRAME.atoms.positions = np.array([[0, 0, 0], [1, 1, 1], [2, 2, 5]]) - class TestStructures(unittest.TestCase): """Conversion of structure data to chemiscope JSON""" diff --git a/tox.ini b/tox.ini index a3099cbfb..01855859d 100644 --- a/tox.ini +++ b/tox.ini @@ -29,6 +29,7 @@ deps = ase==3.22.1 rdkit==2024.3.4 stk + MDAnalysis commands = pip install chemiscope[explore]