diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 825b299..ee647d0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,9 +20,7 @@ jobs: with: python-version: ${{ matrix.python-version }} - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd - - name: Install pytest - run: pip install pytest - - name: Install PyVMCON - run: pip install . + - name: Install PyVMCON with testing dependencies (pytest) + run: pip install '.[test]' - name: Run pytest run: pytest tests/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c161d48..5e8c029 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,12 +1,12 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v2.3.0 + rev: v6.0.0 hooks: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.15.4 + rev: v0.15.13 hooks: - id: ruff-check args: [--fix] diff --git a/README.md b/README.md index 449b563..6fc9625 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ pip install . Documentation for the VMCON algorithm and PyVMCON API/use can be found on our [**GitHub pages**](https://ukaea.github.io/PyVMCON/). The documentation includes references to the VMCON paper and other helpful resources. ## Testing -Tests can be run using `pytest tests/`. The tests check the paper examples are replicated. +Tests can be run by installing the optional test dependencies `pip install 'PyVMCON[test]'` and then running `pytest tests/`. The tests check the examples from the original VMCON paper are replicated. ## License PyVMCON is provided under the MIT license, please see the LICENSE file for full details. diff --git a/pyproject.toml b/pyproject.toml index f3cb275..c4e512d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,6 +23,7 @@ Documentation = "https://ukaea.github.io/PyVMCON/" Source = "https://github.com/ukaea/PyVMCON" [project.optional-dependencies] +test = ["pytest"] docs = [ "Sphinx>=6.1", "sphinxcontrib-mermaid>=0.9", @@ -56,3 +57,6 @@ ignore = [ [tool.ruff.lint.per-file-ignores] "*.ipynb" = ["T201", "S311", "ANN", "D103"] "tests/*" = ["INP001", "ANN", "D103", "S101", "SLF001", "PLR0915", "PLR2004"] + +[tool.ruff.format] +preview = true diff --git a/tests/test_vmcon.py b/tests/test_vmcon.py index aaaf13f..3557502 100644 --- a/tests/test_vmcon.py +++ b/tests/test_vmcon.py @@ -25,28 +25,22 @@ class BRevisionAsset: B=np.identity(2), ksi=np.array([-0.66666666666666663, -0.83333333333333348]), eta=np.array([-1.3425925925925923, -1.7129629629629632]), - expected_return=np.array( - [ - [1.3858727457706470, 0.50241291449459347], - [0.50241291449459347, 1.6536252239598812], - ] - ), + expected_return=np.array([ + [1.3858727457706470, 0.50241291449459347], + [0.50241291449459347, 1.6536252239598812], + ]), ), BRevisionAsset( - B=np.array( - [ - [2.1875467668036239, 1.4714414127452644], - [1.4714414127452644, 2.7501870672148332], - ] - ), + B=np.array([ + [2.1875467668036239, 1.4714414127452644], + [1.4714414127452644, 2.7501870672148332], + ]), ksi=np.array([-1.2385140125071988e-6, -6.1925700625482853e-7]), eta=np.array([-3.6205427119684330e-6, -3.5255433852299234e-6]), - expected_return=np.array( - [ - [2.1875592084316073, 1.4714730232083293], - [1.4714730232083293, 2.7502368318126678], - ] - ), + expected_return=np.array([ + [2.1875592084316073, 1.4714730232083293], + [1.4714730232083293, 2.7502368318126678], + ]), ), ], ) @@ -75,17 +69,16 @@ def test_revise_B(test_asset): expected_return=np.array([-1.3425925925925923, -1.7129629629629632]), ), BRevisionAsset( - B=np.array( - [ - [2.1875467668036239, 1.4714414127452644], - [1.4714414127452644, 2.7501870672148332], - ] - ), + B=np.array([ + [2.1875467668036239, 1.4714414127452644], + [1.4714414127452644, 2.7501870672148332], + ]), ksi=np.array([-1.2385140125071988e-6, -6.1925700625482853e-7]), eta=np.array([-3.6205427119684330e-6, -3.5255433852299234e-6]), - expected_return=np.array( - [-3.6205427119684330e-006, -3.5255433852299234e-006] - ), + expected_return=np.array([ + -3.6205427119684330e-006, + -3.5255433852299234e-006, + ]), ), ], )