Skip to content

Commit

Permalink
Merge pull request #55 from zwicker-group/py3.12
Browse files Browse the repository at this point in the history
Enable python 3.12 for package
  • Loading branch information
david-zwicker authored Jan 2, 2024
2 parents 131ba47 + ccf29eb commit e7c29f1
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 42 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,27 @@ jobs:
strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]
python-version: ['3.8', '3.11']
python-version: ['3.8', '3.12']

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r tests/requirements.txt
- name: Install optional dependencies
continue-on-error: true
run: |
pip install py-pde
- name: Test with pytest
env:
NUMBA_WARNINGS: 1
Expand Down
2 changes: 1 addition & 1 deletion docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ You can thus install it using
conda install -c conda-forge py-modelrunner
This installation includes all required dependencies to have all features of `py-pde`.
This installation includes all required dependencies to have all features of `py-modelrunner`.


Installing from source
Expand Down
2 changes: 1 addition & 1 deletion modelrunner/py.typed
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# This file indicates that the py-pde package supports typing compliant with PEP 561
# This file indicates that the package supports typing compliant with PEP 561
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = [
]
license = {text = "MIT"}
readme = "README.md"
requires-python = ">=3.8,<3.12"
requires-python = ">=3.8,<3.13"
dynamic = ["version"]

classifiers = [
Expand All @@ -21,6 +21,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]

# Requirements for setuptools
Expand Down
30 changes: 1 addition & 29 deletions tests/helpers/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
"""

import importlib
from typing import Any, Callable, List, Optional, Sequence, TypeVar, Union
from typing import Any, Callable, List, Optional, TypeVar

import numpy as np
import pytest

TFunc = TypeVar("TFunc", bound=Callable[..., Any])

Expand All @@ -31,33 +30,6 @@ def module_available(module_name: str) -> bool:
return True


def skipUnlessModule(
module_names: Union[Sequence[str], str]
) -> Callable[[TFunc], TFunc]:
"""decorator that skips a test when a module is not available
Args:
module_names (str):
The name of the required module(s)
Returns:
A function, so this can be used as a decorator
"""
if isinstance(module_names, str):
module_names = [module_names]

for module_name in module_names:
if not module_available(module_name):
# return decorator skipping test
return pytest.skip(f"requires {module_name}")

# return no-op decorator if all modules are available
def wrapper(f: TFunc) -> TFunc:
return f

return wrapper


def storage_extensions(
incl_folder: bool = True, dot: bool = False, *, exclude: Optional[List] = None
):
Expand Down
1 change: 0 additions & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ isort>=5.1
pytest>=5.4
pytest-cov>=2.8
pytest-xdist>=1.30
py-pde>=0.33
mypy>=0.770
9 changes: 4 additions & 5 deletions tests/storage/test_storage_special.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

import numpy as np
import pytest
from pde.tools.misc import skipUnlessModule

from helpers import STORAGE_OBJECTS, assert_data_equals
from helpers import STORAGE_OBJECTS, assert_data_equals, module_available
from modelrunner.storage import MemoryStorage, open_storage


Expand All @@ -24,7 +23,7 @@ def test_memory_storage(obj):
np.testing.assert_array_equal(storage.read_array("dyn", index=0), np.ones(2))


@skipUnlessModule("h5py")
@pytest.mark.skipif(not module_available("h5py"), reason="requires `h5py` module")
def test_hdf_storage(tmp_path):
"""test HDFStorage"""
import h5py
Expand All @@ -40,7 +39,7 @@ def test_hdf_storage(tmp_path):
assert root.attrs["test"] == 5


@skipUnlessModule("zarr")
@pytest.mark.skipif(not module_available("zarr"), reason="requires `zarr` module")
def test_zarr_storage(tmp_path):
"""test ZarrStorage"""
import zarr
Expand All @@ -66,7 +65,7 @@ def test_json_storage(tmp_path):
assert json.load(fp) == json.loads(json_txt)


@skipUnlessModule("yaml")
@pytest.mark.skipif(not module_available("yaml"), reason="requires `yaml` module")
def test_yaml_storage(tmp_path):
"""test YAMLStorage"""
import yaml
Expand Down
6 changes: 3 additions & 3 deletions tests/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np
import pytest

from helpers import assert_data_equals, skipUnlessModule, storage_extensions
from helpers import assert_data_equals, module_available, storage_extensions
from modelrunner.results import Result, ResultCollection

STORAGE_EXT = storage_extensions(incl_folder=True, dot=True)
Expand Down Expand Up @@ -34,7 +34,7 @@ def test_result_serialization(ext, tmp_path):
np.testing.assert_equal(read.data, result.data)


@skipUnlessModule("pde")
@pytest.mark.skipif(not module_available("pde"), reason="requires `pde` module")
@pytest.mark.parametrize("ext", STORAGE_EXT)
def test_pde_field_storage(ext, tmp_path):
"""test writing pde fields"""
Expand All @@ -59,7 +59,7 @@ def test_pde_field_storage(ext, tmp_path):
np.testing.assert_equal(read.data, result.data)


@skipUnlessModule("pde")
@pytest.mark.skipif(not module_available("pde"), reason="requires `pde` module")
@pytest.mark.parametrize("ext", STORAGE_EXT)
def test_pde_trajectory_storage(ext, tmp_path):
"""test writing pde trajectories"""
Expand Down

0 comments on commit e7c29f1

Please sign in to comment.