Skip to content

Commit

Permalink
Merge pull request #36 from chrisjonesBSU/remove_hoomd
Browse files Browse the repository at this point in the history
remove hoomd 2 from environment file
  • Loading branch information
chrisjonesBSU authored Mar 28, 2022
2 parents a7695c6 + 0f420d5 commit 08c1605
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ jobs:
shell: bash -l {0}
run: python -m pytest -v -rs --cov=./ --cov-report=xml

- name: Test hoomd2 functions
shell: bash -l {0}
run: |
mamba install -c conda-forge hoomd=2
python -m pytest -v -rs -k test_xml_to_gsd --cov=./ --cov-report=xml --cov-append
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
Expand Down
10 changes: 8 additions & 2 deletions cmeutils/gsd_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import freud
import gsd.hoomd
import hoomd
import hoomd.deprecated
import numpy as np


Expand Down Expand Up @@ -202,6 +200,14 @@ def xml_to_gsd(xmlfile, gsdfile):
gsdfile : str
Path to gsd file
"""
try:
import hoomd
import hoomd.deprecated
except ImportError:
raise ImportError(
"You must have hoomd version 2 installed to use xml_to_gsd()"
)

hoomd.util.quiet_status()
hoomd.context.initialize("")
hoomd.deprecated.init.read_xml(xmlfile, restart=xmlfile)
Expand Down
15 changes: 15 additions & 0 deletions cmeutils/tests/test_gsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,24 @@

import gsd.hoomd
import numpy as np
import packaging.version

from base_test import BaseTest
from cmeutils.gsd_utils import (
get_type_position, get_molecule_cluster, get_all_types, _validate_inputs,
snap_delete_types, xml_to_gsd
)

try:
import hoomd
if "version" in dir(hoomd):
hoomd_version = packaging.version.parse(hoomd.version.version)
else:
hoomd_version = packaging.version.parse(hoomd.__version__)
has_hoomd = True
except ImportError:
has_hoomd = False


class TestGSD(BaseTest):
def test_get_type_position(self, gsdfile):
Expand Down Expand Up @@ -57,6 +68,10 @@ def test_snap_delete_types_bonded(self, snap_bond):
new_snap = snap_delete_types(snap_bond, "A")
assert "A" not in new_snap.particles.types

@pytest.mark.skipif(
not has_hoomd or hoomd_version.major != 2,
reason="HOOMD is not installed or is wrong version"
)
def test_xml_to_gsd(self, tmp_path, p3ht_gsd, p3ht_xml):
new_gsd = tmp_path / "new.gsd"
xml_to_gsd(p3ht_xml, new_gsd)
Expand Down
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ channels:
dependencies:
- freud
- gsd
- hoomd<3
- numpy
- pip
- python=3.7
Expand Down

0 comments on commit 08c1605

Please sign in to comment.