diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c619985..27ff873 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,8 +42,8 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.12"] - runs-on: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.10", "3.13"] + runs-on: [ubuntu-latest] #, macos-latest, windows-latest] include: - python-version: pypy-3.10 @@ -68,6 +68,6 @@ jobs: --durations=20 - name: Upload coverage report - uses: codecov/codecov-action@v4.3.0 + uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c7760e..92689b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,9 +3,3 @@ cmake_minimum_required(VERSION 3.15...3.26) set(SKBUILD_PROJECT_NAME pscpy) project(${SKBUILD_PROJECT_NAME} LANGUAGES CXX) - -set(PYBIND11_FINDPYTHON ON) -find_package(pybind11 CONFIG REQUIRED) - -pybind11_add_module(_core MODULE src/main.cpp) -install(TARGETS _core DESTINATION ${SKBUILD_PROJECT_NAME}) diff --git a/src/main.cpp b/src/main.cpp deleted file mode 100644 index d570cd0..0000000 --- a/src/main.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include - -int add(int i, int j) { return i + j; } - -namespace py = pybind11; - -PYBIND11_MODULE(_core, m) { - m.doc() = R"pbdoc( - Pybind11 example plugin - ----------------------- - .. currentmodule:: python_example - .. autosummary:: - :toctree: _generate - add - subtract - )pbdoc"; - - m.def("add", &add, R"pbdoc( - Add two numbers - Some other explanation about the add function. - )pbdoc"); - - m.def("subtract", [](int i, int j) { return i - j; }, R"pbdoc( - Subtract two numbers - Some other explanation about the subtract function. - )pbdoc"); -} diff --git a/src/pscpy/adios2py/__init__.py b/src/pscpy/adios2py/__init__.py index e8dc201..97fef40 100644 --- a/src/pscpy/adios2py/__init__.py +++ b/src/pscpy/adios2py/__init__.py @@ -54,7 +54,7 @@ def _name(self) -> str: def _dtype(self) -> np.dtype[Any]: self._assert_not_closed() - return np.dtype(adios2.type_adios_to_numpy(self._var.type())) + return np.dtype(adios2.type_adios_to_numpy(self._var.type())) # type: ignore[no-any-return] def __getitem__(self, args: SupportsInt | slice | tuple[SupportsInt | slice, ...]) -> NDArray[Any]: self._assert_not_closed() diff --git a/src/pscpy/psc.py b/src/pscpy/psc.py index b6d4f0d..2db072a 100644 --- a/src/pscpy/psc.py +++ b/src/pscpy/psc.py @@ -37,7 +37,7 @@ def __init__(self, file: File, length: ArrayLike | None = None, corner: ArrayLik self.z = self._get_coord(2) def _get_coord(self, coord_idx: int) -> NDArray[np.floating[Any]]: - return np.linspace( # type: ignore[no-any-return] + return np.linspace( start=self.corner[coord_idx], stop=self.corner[coord_idx] + self.length[coord_idx], num=self.gdims[coord_idx], diff --git a/src/pscpy/pscadios2.py b/src/pscpy/pscadios2.py index bcfb5fc..70e599a 100644 --- a/src/pscpy/pscadios2.py +++ b/src/pscpy/pscadios2.py @@ -1,6 +1,5 @@ from __future__ import annotations -import io import os import pathlib from typing import Any, Iterable, Protocol, SupportsInt @@ -25,6 +24,7 @@ ) from xarray.core import indexing from xarray.core.datatree import DataTree +from xarray.core.types import ReadBuffer from xarray.core.utils import Frozen, FrozenDict from .adios2py import File, Variable @@ -149,7 +149,7 @@ def psc_open_dataset( length: ArrayLike | None = None, corner: ArrayLike | None = None, ) -> xarray.Dataset: - filename = _normalize_path(filename_or_obj) # type: ignore[no-untyped-call] + filename = _normalize_path(filename_or_obj) store = PscAdios2Store.open(filename, species_names, length=length, corner=corner) data_vars, attrs = store.load() # type: ignore[no-untyped-call] @@ -167,13 +167,12 @@ class PscAdios2BackendEntrypoint(BackendEntrypoint): @override def open_dataset( self, - filename_or_obj: str | os.PathLike[Any] | io.BufferedIOBase | AbstractDataStore, + filename_or_obj: str | os.PathLike[Any] | ReadBuffer[Any] | AbstractDataStore, *, drop_variables: str | Iterable[str] | None = None, length: ArrayLike | None = None, corner: ArrayLike | None = None, species_names: Iterable[str] | None = None, # e.g. ['e', 'i']; FIXME should be readable from file - **kwargs: Any, ) -> xarray.Dataset: if not isinstance(filename_or_obj, (str, os.PathLike)): raise NotImplementedError() @@ -190,14 +189,14 @@ def open_dataset( ) @override - def guess_can_open(self, filename_or_obj: str | os.PathLike[Any] | io.BufferedIOBase | AbstractDataStore) -> bool: + def guess_can_open(self, filename_or_obj: str | os.PathLike[Any] | ReadBuffer[Any] | AbstractDataStore) -> bool: if isinstance(filename_or_obj, (str, os.PathLike)): ext = pathlib.Path(filename_or_obj).suffix return ext in {".bp"} return False @override - def open_datatree(self, filename_or_obj: str | os.PathLike[Any] | io.BufferedIOBase | AbstractDataStore, **kwargs: Any) -> DataTree[Any]: + def open_datatree(self, filename_or_obj: str | os.PathLike[Any] | ReadBuffer[Any] | AbstractDataStore, **kwargs: Any) -> DataTree: raise NotImplementedError() diff --git a/tests/test_compiled.py b/tests/test_compiled.py deleted file mode 100644 index 845d50a..0000000 --- a/tests/test_compiled.py +++ /dev/null @@ -1,11 +0,0 @@ -from __future__ import annotations - -import pscpy._core as m - - -def test_add(): - assert m.add(2, 3) == 5 - - -def test_subtract(): - assert m.subtract(7, 5) == 2