Skip to content

Commit

Permalink
merge changes from upstream.
Browse files Browse the repository at this point in the history
  • Loading branch information
marjanalbooyeh committed Nov 23, 2024
2 parents b5c24f2 + 5ae979a commit d7e3f2d
Show file tree
Hide file tree
Showing 27 changed files with 468 additions and 143 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: pytest

on:
push:
# Action will run when any changes to these paths are pushed or pr'ed to master
branches: [ main ]
paths:
- flowermd/**
Expand All @@ -26,6 +25,7 @@ on:

jobs:
pytest:
if: github.event.pull_request.draft == false
strategy:
fail-fast: false
matrix:
Expand All @@ -36,10 +36,10 @@ jobs:

steps:
- name: Check out repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Build environment
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
environment-file: environment-dev.yml
python-version: ${{ matrix.python-version }}
Expand All @@ -56,7 +56,7 @@ jobs:
run: python -m pytest -rs -v --cov=./ --cov-report=xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
Expand Down
34 changes: 9 additions & 25 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,48 +1,32 @@
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
autofix_prs: true
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: weekly
skip: [ ]
submodules: false

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.4 # Ruff version
hooks:
- id: ruff
args: [--fix, --extend-ignore=E203]
- id: ruff-format
args: [ --line-length=80 ]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
exclude: 'flowermd/tests/assets/.* | flowermd/assets/.*'
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
args: [ --line-length=80 ]
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
args:
[ --profile=black, --line-length=80 ]
exclude: 'flowermd/tests/assets/.* | */__init__.py'

- repo: https://github.com/pycqa/flake8
rev: 7.0.0
hooks:
- id: flake8
args:
- --max-line-length=80
- --extend-ignore=E203
exclude: '__init__.py'

- repo: https://github.com/pycqa/pydocstyle
rev: '6.3.0'
hooks:
- id: pydocstyle
exclude: ^(flowermd/tests/|flowermd/internal/|flowermd/utils|setup.py|flowermd/__version__.py|docs/)
args: [ --convention=numpy ]
exclude: 'flowermd/tests/assets/.* '
12 changes: 6 additions & 6 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ channels:
dependencies:
- foyer >=0.12.0
- fresnel
- freud >=2.13.1
- gmso >=0.11.2
- freud >=3.0
- gmso >=0.12.0
- gsd >=3.0
- grits=0.4.1
- hoomd=4.3
- grits >=0.5.0
- hoomd >=4.5
- mbuild >=0.17.0
- numpy
- numpy <2.0
- openbabel >=3
- pip
- pre-commit
Expand All @@ -20,4 +20,4 @@ dependencies:
- nbmake
- python >=3.10, <3.12
- fresnel >=0.13.5
- cmeutils >=1.1.1
- cmeutils >=1.3
12 changes: 6 additions & 6 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ channels:
dependencies:
- foyer >=0.12.0
- fresnel
- freud >=2.13.1
- gmso >=0.11.2
- freud >=3.0
- gmso >=0.12.0
- gsd >=3.0
- hoomd=4.3
- grits >=0.5.0
- hoomd >=4.5
- mbuild >=0.17.0
- numpy
- numpy <2.0
- openbabel >=3
- pip
- py3Dmol
- python >=3.10, <3.12
- fresnel >=0.13.5
- cmeutils >=1.1.1
- grits =0.4.1
- cmeutils >=1.3
1 change: 1 addition & 0 deletions flowermd/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa: F401
"""flowerMD package."""

from .internal.units import Units
Expand Down
2 changes: 1 addition & 1 deletion flowermd/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION = (1, 3, 0)
VERSION = (1, 3, 1)

__version__ = ".".join(map(str, VERSION))
1 change: 1 addition & 0 deletions flowermd/assets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa: F401
"""Paths to the assets used by flowerMD."""

from .forcefields import FF_DIR
Expand Down
1 change: 1 addition & 0 deletions flowermd/base/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruff: noqa: F401
"""Base classes for flowerMD."""

from .forcefield import BaseHOOMDForcefield, BaseXMLForcefield
Expand Down
30 changes: 25 additions & 5 deletions flowermd/base/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def _identify_bond_types(self, gmso_molecule):
or bond.connection_members[1].name
)
bond_connections = [p1_name, p2_name]
if not tuple(bond_connections[::-1]) in self.bond_types:
if tuple(bond_connections[::-1]) not in self.bond_types:
self.bond_types.add(tuple(bond_connections))

def _identify_angle_types(self, gmso_molecule):
Expand All @@ -341,7 +341,7 @@ def _identify_angle_types(self, gmso_molecule):
or angle.connection_members[2].name
)
angle_connections = [p1_name, p2_name, p3_name]
if not tuple(angle_connections[::-1]) in self.angle_types:
if tuple(angle_connections[::-1]) not in self.angle_types:
self.angle_types.add(tuple(angle_connections))

def _identify_dihedral_types(self, gmso_molecule):
Expand Down Expand Up @@ -372,7 +372,7 @@ def _identify_dihedral_types(self, gmso_molecule):
or dihedral.connection_members[3].name
)
dihedral_connections = [p1_name, p2_name, p3_name, p4_name]
if not tuple(dihedral_connections[::-1]) in self.dihedral_types:
if tuple(dihedral_connections[::-1]) not in self.dihedral_types:
self.dihedral_types.add(tuple(dihedral_connections))

def _identify_improper_types(self, gmso_molecule):
Expand Down Expand Up @@ -403,7 +403,7 @@ def _identify_improper_types(self, gmso_molecule):
or improper.connection_members[3].name
)
improper_connections = [p1_name, p2_name, p3_name, p4_name]
if not tuple(improper_connections[::-1]) in self.improper_types:
if tuple(improper_connections[::-1]) not in self.improper_types:
self.improper_types.add(tuple(improper_connections))

def _identify_topology_information(self, gmso_molecule):
Expand Down Expand Up @@ -477,6 +477,11 @@ class Polymer(Molecule):
The bond length between connected atoms (units: nm)
bond_orientation: list, default None
The orientation of the bond between connected atoms.
periodic_bond_axis : str, default None
Axis which to orient the polymer backbone along.
Once the chain is aligned, a periodic bond between
head and tail atoms is formed.
Options are "x", "y", or "z"
"""

Expand All @@ -490,12 +495,14 @@ def __init__(
bond_indices=None,
bond_length=None,
bond_orientation=None,
periodic_bond_axis=None,
**kwargs,
):
self.lengths = check_return_iterable(lengths)
self.bond_indices = bond_indices
self.bond_length = bond_length
self.bond_orientation = bond_orientation
self.periodic_bond_axis = periodic_bond_axis
num_mols = check_return_iterable(num_mols)
if len(num_mols) != len(self.lengths):
raise ValueError("Number of molecules and lengths must be equal.")
Expand All @@ -513,14 +520,27 @@ def monomer(self):
return self._mb_molecule

def _build(self, length):
if self.periodic_bond_axis:
if not isinstance(
self.periodic_bond_axis, str
) or self.periodic_bond_axis.lower() not in ["x", "y", "z"]:
raise ValueError(
"Valid choices for a `periodic_bond_axis` are "
"'x', 'y', 'z'"
)
add_hydrogens = False
else:
add_hydrogens = True
chain = mbPolymer()
chain.add_monomer(
self.monomer,
indices=self.bond_indices,
separation=self.bond_length,
orientation=self.bond_orientation,
)
chain.build(n=length, sequence="A")
chain.build(n=length, sequence="A", add_hydrogens=add_hydrogens)
if self.periodic_bond_axis:
chain.create_periodic_bond(axis=self.periodic_bond_axis)
return chain

def _generate(self):
Expand Down
Loading

0 comments on commit d7e3f2d

Please sign in to comment.