From a6a2a9ea0b76c9c16b0f361f28cb875310417404 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 18 Dec 2024 22:44:48 -0500 Subject: [PATCH 1/5] devops: fix some mypy complaints presumably mostly related to changes in upstream packages --- src/pscpy/adios2py/__init__.py | 2 +- src/pscpy/psc.py | 2 +- src/pscpy/pscadios2.py | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-) 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..fffdc0e 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,7 +167,7 @@ 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, @@ -190,14 +190,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() From cea38312d872634d9bd6d9c8e5f5f4193d157ed6 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 18 Dec 2024 22:58:54 -0500 Subject: [PATCH 2/5] devops: remove unused C++ example code --- CMakeLists.txt | 6 ------ src/main.cpp | 27 --------------------------- tests/test_compiled.py | 11 ----------- 3 files changed, 44 deletions(-) delete mode 100644 src/main.cpp delete mode 100644 tests/test_compiled.py 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/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 From 274d90fa96918725f206a49ce24f8a9faaf50ea2 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 18 Dec 2024 23:13:03 -0500 Subject: [PATCH 3/5] devops: fix pylint complaint: **kwargs unused --- src/pscpy/pscadios2.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pscpy/pscadios2.py b/src/pscpy/pscadios2.py index fffdc0e..70e599a 100644 --- a/src/pscpy/pscadios2.py +++ b/src/pscpy/pscadios2.py @@ -173,7 +173,6 @@ def open_dataset( 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() From 035d0ad072c4721befc93982e4d9024066a569f4 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 18 Dec 2024 23:20:17 -0500 Subject: [PATCH 4/5] devops: run ci with python 3.10 and 3.13 not going to try to support python<3.10 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c619985..6a61737 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.8", "3.12"] + python-version: ["3.10", "3.13"] runs-on: [ubuntu-latest, macos-latest, windows-latest] include: From e5633f749c4358f66d0c12c7bdc5c40c811ff5c4 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 18 Dec 2024 23:45:08 -0500 Subject: [PATCH 5/5] devops: skip macos, windows tests, update codecov-action --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6a61737..27ff873 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: fail-fast: false matrix: python-version: ["3.10", "3.13"] - runs-on: [ubuntu-latest, macos-latest, windows-latest] + 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 }}