Skip to content

Commit

Permalink
Fixing formatting errors to conform with ruff.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Chico committed Apr 26, 2024
2 parents 6611b2a + 91c3d75 commit 182a0eb
Show file tree
Hide file tree
Showing 58 changed files with 1,258 additions and 785 deletions.
32 changes: 18 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4.1.1
- name: Set up Python 3.8
uses: actions/setup-python@v5
with:
python-version: "3.8"
- uses: pre-commit/action@v3.0.0
- uses: actions/checkout@v3.3.0
- name: Set up Python
uses: actions/setup-python@v4.5.0
with:
python-version: "3.9"
- name: Make sure virtualevn>20 is installed, which will yield newer pip and possibility to pin pip version.
run: pip install "virtualenv>20"
- name: Install Tox
run: pip install tox
- name: Run pre-commit in Tox
run: tox -e pre-commit


tests:

Expand All @@ -31,16 +37,14 @@ jobs:
fail-fast: false
matrix:
include:
- python-version: "3.8"
lammps-version: "2020.03.03"
- python-version: "3.8"
lammps-version: "2020.12.24"
- python-version: "3.9"
lammps-version: "2020.12.24"
- python-version: "3.9"
lammps-version: "2020.03.03"
lammps-version: "2022.06.23"
- python-version: "3.10"
lammps-version: "2021.09.29"
lammps-version: "2022.06.23"
- python-version: "3.11"
lammps-version: "2022.06.23"

runs-on: ubuntu-latest

Expand Down Expand Up @@ -87,10 +91,10 @@ jobs:

- name: Run pytest
run: |
tox -e ${{ matrix.python-version }}-aiida_lammps -- tests/ --cov=./aiida_lammps --cov-append --cov-report=xml --cov-report=term-missing
tox -e ${{ matrix.python-version }}-aiida_lammps -- tests/ --cov=aiida_lammps --cov-append --cov-report=xml --cov-report=term-missing
- name: Upload to Codecov
if: matrix.python-version == 3.8
if: matrix.python-version == 3.10
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
62 changes: 57 additions & 5 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
initialise a test database and profile
"""

# pylint: disable=redefined-outer-name
from __future__ import annotations

Expand All @@ -14,18 +15,18 @@

from aiida import orm
from aiida.common import AttributeDict, CalcInfo, LinkType, exceptions
from aiida.engine import CalcJob
from aiida.engine import Process
from aiida.engine.utils import instantiate_process
from aiida.manage.manager import get_manager
from aiida.plugins import WorkflowFactory
from aiida.plugins.entry_point import format_entry_point_string
from aiida_lammps.calculations.base import LammpsBaseCalculation
from aiida_lammps.data.potential import LammpsPotentialData
from aiida_lammps.data.trajectory import LammpsTrajectory
import numpy as np
import pytest
import yaml

from aiida_lammps.calculations.base import LammpsBaseCalculation
from aiida_lammps.data.potential import LammpsPotentialData
from aiida_lammps.data.trajectory import LammpsTrajectory
from tests.utils import TEST_DIR, AiidaTestApp

pytest_plugins = ["aiida.manage.tests.pytest_fixtures"]
Expand Down Expand Up @@ -68,6 +69,12 @@ def pytest_report_header(config):
]


@pytest.fixture
def structure_parameters() -> AttributeDict:
parameteters = AttributeDict({"dimension": 2, "boundary": ["p", "p", "f"]})
return parameteters


@pytest.fixture
def filepath_tests() -> pathlib.Path:
"""Return the path to the tests folder."""
Expand Down Expand Up @@ -119,6 +126,15 @@ def parameters_minimize() -> AttributeDict:
"ke/atom": [{"type": [{"keyword": " ", "value": " "}], "group": "all"}],
"stress/atom": [{"type": ["NULL"], "group": "all"}],
"pressure": [{"type": ["thermo_temp"], "group": "all"}],
"property/atom": [
{
"type": [
{"keyword": " ", "value": "fx"},
{"keyword": " ", "value": "fy"},
],
"group": "all",
}
],
}

parameters.minimize = {
Expand Down Expand Up @@ -171,6 +187,15 @@ def parameters_minimize_groups() -> AttributeDict:
"stress/atom": [{"type": ["NULL"], "group": "all"}],
"pressure": [{"type": ["thermo_temp"], "group": "all"}],
"ke": [{"type": [{"keyword": " ", "value": " "}], "group": "test"}],
"property/atom": [
{
"type": [
{"keyword": " ", "value": "fx"},
{"keyword": " ", "value": "fy"},
],
"group": "all",
}
],
}

parameters.minimize = {
Expand Down Expand Up @@ -218,6 +243,15 @@ def parameters_md_nve() -> AttributeDict:
"ke/atom": [{"type": [{"keyword": " ", "value": " "}], "group": "all"}],
"stress/atom": [{"type": ["NULL"], "group": "all"}],
"pressure": [{"type": ["thermo_temp"], "group": "all"}],
"property/atom": [
{
"type": [
{"keyword": " ", "value": "fx"},
{"keyword": " ", "value": "fy"},
],
"group": "all",
}
],
}
parameters.md = {
"integration": {
Expand Down Expand Up @@ -262,6 +296,15 @@ def parameters_md_nvt() -> AttributeDict:
"ke/atom": [{"type": [{"keyword": " ", "value": " "}], "group": "all"}],
"stress/atom": [{"type": ["NULL"], "group": "all"}],
"pressure": [{"type": ["thermo_temp"], "group": "all"}],
"property/atom": [
{
"type": [
{"keyword": " ", "value": "fx"},
{"keyword": " ", "value": "fy"},
],
"group": "all",
}
],
}
parameters.md = {
"integration": {
Expand Down Expand Up @@ -309,6 +352,15 @@ def parameters_md_npt() -> AttributeDict:
"ke/atom": [{"type": [{"keyword": " ", "value": " "}], "group": "all"}],
"stress/atom": [{"type": ["NULL"], "group": "all"}],
"pressure": [{"type": ["thermo_temp"], "group": "all"}],
"property/atom": [
{
"type": [
{"keyword": " ", "value": "fx"},
{"keyword": " ", "value": "fy"},
],
"group": "all",
}
],
}
parameters.md = {
"integration": {
Expand Down Expand Up @@ -565,7 +617,7 @@ def factory(
entry_point_name: str,
inputs: dict[str, Any] | None = None,
return_process: bool = False,
) -> tuple[pathlib.Path, CalcInfo] | CalcJob:
) -> tuple[pathlib.Path, CalcInfo] | Process:
"""Create a :class:`aiida.engine.CalcJob` instance with the given inputs.
:param entry_point_name: The entry point name of the calculation job plugin to run.
Expand Down
8 changes: 4 additions & 4 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
`tox -e docs-clean` and `tox -e docs-update`,
or directly: `sphinx-build -n -W --keep-going docs/source docs/_build`
"""

import pathlib
import time

from aiida.manage.configuration import load_documentation_profile

from aiida.manage.configuration import Profile, load_profile
from aiida_lammps import __version__

# -- AiiDA-related setup --------------------------------------------------

# Load the dummy profile even if we are running locally, this way the
# documentation will succeed even if the current
# default profile of the AiiDA installation does not use a Django backend.
load_documentation_profile()
load_profile(Profile("docs", {"process_control": {}, "storage": {}}))

project = "AiiDA LAMMPS"
copyright = f"2021-{time.localtime().tm_year}, AiiDA Team. All rights reserved"
Expand Down Expand Up @@ -45,7 +45,7 @@

# Settings for the `autoapi.extenstion` automatically generating API docs
filepath_docs = pathlib.Path(__file__).parent.parent
filepath_src = filepath_docs.parent / "aiida_lammps"
filepath_src = filepath_docs.parent / "src/aiida_lammps"
autoapi_type = "python"
autoapi_dirs = [filepath_src]
autoapi_ignore = [filepath_src / "*cli*"]
Expand Down
4 changes: 2 additions & 2 deletions docs/source/developers/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The test suite can be run in an isolated, virtual environment using `tox` (see `

```console
pip install tox
tox -e 3.8-aiida_lammps
tox -e 3.9-aiida_lammps
```

or directly:
Expand All @@ -57,7 +57,7 @@ conda install lammps==2019.06.05
You can specify a different executable name for LAMMPS with:

```console
tox -e 3.8-aiida_lammps -- --lammps-exec lmp_exec
tox -e 3.9-aiida_lammps -- --lammps-exec lmp_exec
```

To output the results of calcjob executions to a specific directory:
Expand Down
2 changes: 2 additions & 0 deletions docs/source/topics/data/parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ The dictionary is separated into several nested dictionaries that control differ
* ``box_tilt``: determines how [skewed the cell](https://docs.lammps.org/box.html) is, of great importance for triclinic systems (default: ``small``).
* ``groups``: list with the names of the groups to be added. The names of the possible groups are generated by the list of possible kind names generated by the structure (default: skip parameter).
* ``atom_style``: how the [atoms](https://docs.lammps.org/atom_style.html) are treated by the ``LAMMPS`` simulation.
* ``boundary``: allows to override the [boundary](https://docs.lammps.org/boundary.html) conditions as set by the AiiDA structure as they can be incompatible with what ``LAMMPS`` expects.
* ``dimension``: allows to override the [dimension](https://docs.lammps.org/dimension.html) as determined by the AiiDA structure as it is determined by the boundary conditions and this is not what ``LAMMPS`` expects.
- ``potential``: parameters related to the potential describing the system:
* ``potential_style_options``: extra parameters related to each of the possible pair styles (default: skip parameter).
* ``neighbor``: sets the parameters affecting the construction of the [neighbor list](https://docs.lammps.org/neighbor.html) (default: skip parameter).
Expand Down
3 changes: 1 addition & 2 deletions docs/source/tutorials/include/scripts/run_md_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

from aiida.engine import run
from aiida.orm import Dict, StructureData, load_code
from aiida_lammps.data.potential import LammpsPotentialData
from ase.build import bulk
import requests

from aiida_lammps.data.potential import LammpsPotentialData

# Load the code configured for ``lmp``. Make sure to replace
# this string with the label used in the code setup.
code = load_code("lammps@localhost")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

from aiida.engine import run
from aiida.orm import Dict, StructureData, load_code
from aiida_lammps.data.potential import LammpsPotentialData
from ase.build import bulk
import requests

from aiida_lammps.data.potential import LammpsPotentialData

# Load the code configured for ``lmp``. Make sure to replace
# this string with the label used in the code setup.
code = load_code("lammps@localhost")
Expand Down
3 changes: 1 addition & 2 deletions examples/calculations/launch_lammps_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
from aiida.common.extendeddicts import AttributeDict
from aiida.engine import run_get_node
from aiida.plugins import CalculationFactory
import numpy as np

from aiida_lammps.data.potential import LammpsPotentialData
import numpy as np


def generate_structure() -> orm.StructureData:
Expand Down
3 changes: 1 addition & 2 deletions examples/calculations/launch_lammps_minimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
from aiida.common.extendeddicts import AttributeDict
from aiida.engine import run_get_node
from aiida.plugins import CalculationFactory
import numpy as np

from aiida_lammps.data.potential import LammpsPotentialData
import numpy as np


def generate_structure() -> orm.StructureData:
Expand Down
3 changes: 1 addition & 2 deletions examples/launch_lammps_base_restart_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
from aiida.common.extendeddicts import AttributeDict
from aiida.engine import run_get_node
from aiida.plugins import CalculationFactory
import numpy as np

from aiida_lammps.data.potential import LammpsPotentialData
import numpy as np


def generate_structure() -> orm.StructureData:
Expand Down
3 changes: 1 addition & 2 deletions examples/launch_lammps_base_restart_folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
from aiida.common.extendeddicts import AttributeDict
from aiida.engine import run_get_node
from aiida.plugins import CalculationFactory
import numpy as np

from aiida_lammps.data.potential import LammpsPotentialData
import numpy as np


def generate_structure() -> orm.StructureData:
Expand Down
Loading

0 comments on commit 182a0eb

Please sign in to comment.