From 793a283b06079854dbef705f0732bcb1a1df41a3 Mon Sep 17 00:00:00 2001 From: chrisjonesbsu Date: Mon, 26 Jun 2023 12:28:31 -0600 Subject: [PATCH 1/3] pin gsd>=2.9; update gsd.hoomd.Snapshot to gsd.hoomd.Frame --- environment-dev-win.yml | 2 +- environment-dev.yml | 2 +- mbuild/formats/gsdwriter.py | 4 ++-- mbuild/formats/hoomd_snapshot.py | 4 ++-- mbuild/tests/test_gsd.py | 18 +++++++++--------- mbuild/tests/test_hoomd.py | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/environment-dev-win.yml b/environment-dev-win.yml index a50c45686..75a94cbe3 100644 --- a/environment-dev-win.yml +++ b/environment-dev-win.yml @@ -9,7 +9,7 @@ dependencies: - gmso>=0.9.0 - foyer>=0.11.0 - garnett>=0.7.1 - - gsd>=1.2 + - gsd>=2.9 - intermol - mdtraj - networkx diff --git a/environment-dev.yml b/environment-dev.yml index f3cc47950..aafa85ce1 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -9,7 +9,7 @@ dependencies: - foyer>=0.11.0 - freud>=2.0.0 - garnett>=0.7.1 - - gsd>=2 + - gsd>=2.9 - hoomd>=3 - intermol - mdtraj diff --git a/mbuild/formats/gsdwriter.py b/mbuild/formats/gsdwriter.py index 8a2ba9c1a..3ab4b5c03 100644 --- a/mbuild/formats/gsdwriter.py +++ b/mbuild/formats/gsdwriter.py @@ -60,7 +60,7 @@ def write_gsd( if shift_coords: xyz = coord_shift(xyz, structure.box[:3]) - gsd_snapshot = gsd.hoomd.Snapshot() + gsd_snapshot = gsd.hoomd.Frame() gsd_snapshot.configuration.step = 0 gsd_snapshot.configuration.dimensions = 3 @@ -101,7 +101,7 @@ def write_gsd( if structure.rb_torsions: _write_dihedral_information(gsd_snapshot, structure) - with gsd.hoomd.open(filename, mode="wb") as gsd_file: + with gsd.hoomd.open(filename, mode="w") as gsd_file: gsd_file.append(gsd_snapshot) diff --git a/mbuild/formats/hoomd_snapshot.py b/mbuild/formats/hoomd_snapshot.py index 76e3d7b4a..673e0415b 100644 --- a/mbuild/formats/hoomd_snapshot.py +++ b/mbuild/formats/hoomd_snapshot.py @@ -27,11 +27,11 @@ def _get_hoomd_version(): def from_snapshot(snapshot, scale=1.0): """Convert a Snapshot to a Compound. - Snapshot can be a hoomd.Snapshot or a gsd.hoomd.Snapshot. + Snapshot can be a hoomd.Snapshot or a gsd.hoomd.Frame. Parameters ---------- - snapshot : hoomd.Snapshot or gsd.hoomd.Snapshot + snapshot : hoomd.Snapshot or gsd.hoomd.Frame Snapshot from which to build the mbuild Compound. scale : float, optional, default 1.0 Value by which to scale the length values diff --git a/mbuild/tests/test_gsd.py b/mbuild/tests/test_gsd.py index c322d9f56..704a934a1 100644 --- a/mbuild/tests/test_gsd.py +++ b/mbuild/tests/test_gsd.py @@ -43,7 +43,7 @@ def test_particles(self, ethane): from mbuild.utils.sorting import natural_sort ethane.save(filename="ethane.gsd", forcefield_name="oplsaa") - with gsd.hoomd.open("ethane.gsd", mode="rb") as f: + with gsd.hoomd.open("ethane.gsd", mode="r") as f: frame = f[0] assert frame.configuration.step == 0 @@ -88,7 +88,7 @@ def test_box(self, ethane): ethane.box = Box(lengths=[2.0, 3.0, 4.0]) ethane.save(filename="ethane.gsd", forcefield_name="oplsaa") - with gsd.hoomd.open("ethane.gsd", mode="rb") as f: + with gsd.hoomd.open("ethane.gsd", mode="r") as f: frame = f[0] box_from_gsd = frame.configuration.box.astype(float) @@ -101,7 +101,7 @@ def test_box(self, ethane): ethane.periodicity = (True, True, True) ethane.save(filename="ethane-periodicity.gsd", forcefield_name="oplsaa") - with gsd.hoomd.open("ethane-periodicity.gsd", mode="rb") as f: + with gsd.hoomd.open("ethane-periodicity.gsd", mode="r") as f: frame = f[0] box_from_gsd_periodic = frame.configuration.box.astype(float) assert np.array_equal(box_from_gsd, box_from_gsd_periodic) @@ -111,7 +111,7 @@ def test_box(self, ethane): ethane.save( filename="triclinic-box.gsd", forcefield_name="oplsaa", box=box ) - with gsd.hoomd.open("triclinic-box.gsd", mode="rb") as f: + with gsd.hoomd.open("triclinic-box.gsd", mode="r") as f: frame = f[0] lx, ly, lz, xy, xz, yz = frame.configuration.box @@ -131,7 +131,7 @@ def test_rigid(self, benzene): benzene.label_rigid_bodies(rigid_particles="C") benzene.save(filename="benzene.gsd", forcefield_name="oplsaa") - with gsd.hoomd.open("benzene.gsd", mode="rb") as f: + with gsd.hoomd.open("benzene.gsd", mode="r") as f: frame = f[0] rigid_bodies = frame.particles.body @@ -150,7 +150,7 @@ def test_bonded(self, ethane): from foyer import Forcefield ethane.save(filename="ethane.gsd", forcefield_name="oplsaa") - with gsd.hoomd.open("ethane.gsd", mode="rb") as f: + with gsd.hoomd.open("ethane.gsd", mode="r") as f: frame = f[0] structure = ethane.to_parmed() @@ -244,7 +244,7 @@ def test_pairs(self, benzene): from foyer import Forcefield benzene.save(filename="benzene.gsd", forcefield_name="oplsaa") - with gsd.hoomd.open("benzene.gsd", mode="rb") as f: + with gsd.hoomd.open("benzene.gsd", mode="r") as f: frame = f[0] structure = benzene.to_parmed() @@ -273,7 +273,7 @@ def test_units(self, ethane): ref_mass=ref_mass, box=box, ) - with gsd.hoomd.open("ethane.gsd", mode="rb") as f: + with gsd.hoomd.open("ethane.gsd", mode="r") as f: frame = f[0] box_from_gsd = frame.configuration.box.astype(float) @@ -312,7 +312,7 @@ def test_box_dimensions(self, benzene): benzene, n_compounds=n_benzenes, box=[0, 0, 0, 4, 4, 4] ) filled.save(filename="benzene.gsd") - with gsd.hoomd.open("benzene.gsd", mode="rb") as f: + with gsd.hoomd.open("benzene.gsd", mode="r") as f: frame = f[0] positions = frame.particles.position.astype(float) for coords in positions: diff --git a/mbuild/tests/test_hoomd.py b/mbuild/tests/test_hoomd.py index eedbe0fbc..5dc243fc9 100644 --- a/mbuild/tests/test_hoomd.py +++ b/mbuild/tests/test_hoomd.py @@ -74,7 +74,7 @@ def test_compound_from_gsdsnapshot(self, ethane): snap, _ = to_hoomdsnapshot(filled) # copy attributes from the snapshot to a gsd snapshot - gsd_snap = gsd.hoomd.Snapshot() + gsd_snap = gsd.hoomd.Frame() gsd_snap.particles.N = snap.particles.N gsd_snap.particles.types = snap.particles.types gsd_snap.particles.typeid = snap.particles.typeid From 0581098051f111aeeb48476b8dc2f42fe001399f Mon Sep 17 00:00:00 2001 From: chrisjonesBSU Date: Mon, 26 Jun 2023 13:11:06 -0600 Subject: [PATCH 2/3] remove outdated unit test --- mbuild/tests/test_compound.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/mbuild/tests/test_compound.py b/mbuild/tests/test_compound.py index 9ab12a226..b6d7b33d2 100644 --- a/mbuild/tests/test_compound.py +++ b/mbuild/tests/test_compound.py @@ -2360,15 +2360,6 @@ def test_from_rdkit_smiles(self, test_smiles): np.diff(np.vstack(pos).reshape(len(pos), -1), axis=0) == 0 ).all() - @pytest.mark.parametrize("bad_smiles", ["F[P-](F)(F)(F)(F)F"]) - @pytest.mark.skipif(not has_rdkit, reason="RDKit is not installed") - def test_incorrect_rdkit_smiles(self, bad_smiles): - with pytest.raises( - MBuildError, - match=r"RDKit was unable to generate " r"3D coordinates", - ): - mb.load(bad_smiles, smiles=True, backend="rdkit", seed=29) - @pytest.mark.skipif(not has_openbabel, reason="Pybel is not installed") def test_get_smiles(self): test_strings = ["CCO", "CCCCCCCC", "c1ccccc1", "CC(=O)Oc1ccccc1C(=O)O"] From 18dfa2e96336dcd81c6cb653227dc778e312c5f3 Mon Sep 17 00:00:00 2001 From: CalCraven Date: Mon, 26 Jun 2023 17:02:07 -0500 Subject: [PATCH 3/3] fix numpy to 1.24.2 to fix unyt comparison bug --- environment-dev-win.yml | 2 +- environment-dev.yml | 2 +- environment.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/environment-dev-win.yml b/environment-dev-win.yml index 75a94cbe3..5280d4338 100644 --- a/environment-dev-win.yml +++ b/environment-dev-win.yml @@ -14,7 +14,7 @@ dependencies: - mdtraj - networkx - nglview>=2.7 - - numpy + - numpy=1.24.2 - openbabel>=3.0.0 - packmol=1!18.013 - parmed>=3.4.3 diff --git a/environment-dev.yml b/environment-dev.yml index aafa85ce1..6905ac637 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -15,7 +15,7 @@ dependencies: - mdtraj - networkx - nglview>=3 - - numpy + - numpy=1.24.2 - openbabel>=3 - packmol>=20 - parmed>=3.4.3 diff --git a/environment.yml b/environment.yml index c6424ea2a..05be62ac2 100644 --- a/environment.yml +++ b/environment.yml @@ -3,7 +3,7 @@ channels: - conda-forge dependencies: - ele - - numpy + - numpy=1.24.2 - packmol>=18 - gmso>=0.9.0 - parmed>=3.4.3