Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Numpy 2 testing #427

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
version: [py39, py310, py311]
version: [py39, py310, py311, py312]
include:
- os: ubuntu-latest
platform: linux
Expand Down
6 changes: 3 additions & 3 deletions cf_units/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1759,9 +1759,9 @@ def convert(self, value, other, ctype=FLOAT64, inplace=False):
result = cftime.date2num(
result_datetimes, other.cftime_unit, other.calendar
)
convert_type = isinstance(
value, np.ndarray
) and np.issubsctype(value.dtype, np.floating)
convert_type = isinstance(value, np.ndarray) and np.issubdtype(
value.dtype, np.floating
)
if convert_type:
result = result.astype(value.dtype)
else:
Expand Down
3 changes: 3 additions & 0 deletions cf_units/tests/integration/parse/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#
# This file is part of cf-units and is released under the BSD license.
# See LICENSE in the root of the repository for full licensing details.
import pytest

antlr4 = pytest.importorskip("antlr4")

import cf_units._udunits2_parser.graph as g
from cf_units._udunits2_parser import parse
Expand Down
3 changes: 3 additions & 0 deletions cf_units/tests/integration/parse/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#
# This file is part of cf-units and is released under the BSD license.
# See LICENSE in the root of the repository for full licensing details.
import pytest

antlr4 = pytest.importorskip("antlr4")

import re

Expand Down
3 changes: 3 additions & 0 deletions cf_units/tests/test_tex.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#
# This file is part of cf-units and is released under the BSD license.
# See LICENSE in the root of the repository for full licensing details.
import pytest

antlr4 = pytest.importorskip("antlr4")

from cf_units.tex import tex

Expand Down
3 changes: 2 additions & 1 deletion cf_units/tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,8 @@ def test_foreign_endian(self):
f = Unit("deg_f")

# Manufacture a non-native byte-order array to be converted.
orig = np.arange(4, dtype=np.float32).newbyteorder().byteswap()
arr = np.arange(4, dtype=np.float32)
orig = arr.view(arr.dtype.newbyteorder("S"))

emsg = (
"Unable to convert non-native byte ordered array in-place. "
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ requires = [
"setuptools>=45",
"setuptools_scm[toml]>=7.0",
"wheel",
"oldest-supported-numpy",
"oldest-supported-numpy ; python_version < '3.9'",
"numpy>=2.0.0rc1 ; python_version >= '3.9'",
"Cython"
]
# Defined by PEP 517
Expand Down
3 changes: 2 additions & 1 deletion requirements/cf-units.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ dependencies:
- numpy

# core dependencies
- antlr-python-runtime 4.11.1.* # To update this, see cf_units/_udunits2_parser/README.md
- cftime>=1.2
- numpy>=1.23
- udunits2
Expand All @@ -28,3 +27,5 @@ dependencies:

# docs dependencies
- sphinx
# latex
- antlr-python-runtime 4.11.1.* # To update this, see cf_units/_udunits2_parser/README.md
177 changes: 177 additions & 0 deletions requirements/locks/py312-lock-linux-64.txt

Large diffs are not rendered by default.

173 changes: 173 additions & 0 deletions requirements/locks/py312-lock-osx-64.txt

Large diffs are not rendered by default.

176 changes: 176 additions & 0 deletions requirements/locks/py312-lock-win-64.txt

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ version = attr: cf_units.__version__
[options]
include_package_data = True
install_requires =
antlr4-python3-runtime ==4.11.1 # To update this, see cf_units/_udunits2_parser/README.md
cftime >=1.2
jinja2
numpy >=1.23
Expand All @@ -47,6 +46,8 @@ python_requires =
zip_safe = False

[options.extras_require]
latex =
antlr4-python3-runtime ==4.11.1 # To update this, see cf_units/_udunits2_parser/README.md
docs =
sphinx
test =
Expand All @@ -58,6 +59,7 @@ test =
pytest-cov
all =
pre-commit
%(latex)s
%(docs)s
%(test)s

Expand Down
7 changes: 5 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ requires =
tox-run-command


[testenv:py{39,310,311}-lock]
[testenv:py{39,310,311,312}-lock]
allowlist_externals =
cp
changedir =
Expand Down Expand Up @@ -32,17 +32,20 @@ commands =
conda-lock --channel conda-forge --kind explicit --file {env:TMPFILE} --platform linux-64 --filename-template "{envname}-\{platform\}.txt" {posargs}


[testenv:py{39,310,311}-{linux,osx,win}-test]
[testenv:py{39,310,311,312}-{linux,osx,win}-test]
conda_spec =
py39-linux: {toxinidir}{/}requirements{/}locks{/}py39-lock-linux-64.txt
py310-linux: {toxinidir}{/}requirements{/}locks{/}py310-lock-linux-64.txt
py311-linux: {toxinidir}{/}requirements{/}locks{/}py311-lock-linux-64.txt
py312-linux: {toxinidir}{/}requirements{/}locks{/}py312-lock-linux-64.txt
py39-osx: {toxinidir}{/}requirements{/}locks{/}py39-lock-osx-64.txt
py310-osx: {toxinidir}{/}requirements{/}locks{/}py310-lock-osx-64.txt
py311-osx: {toxinidir}{/}requirements{/}locks{/}py311-lock-osx-64.txt
py312-osx: {toxinidir}{/}requirements{/}locks{/}py312-lock-osx-64.txt
py39-win: {toxinidir}{/}requirements{/}locks{/}py39-lock-win-64.txt
py310-win: {toxinidir}{/}requirements{/}locks{/}py310-lock-win-64.txt
py311-win: {toxinidir}{/}requirements{/}locks{/}py311-lock-win-64.txt
py312-win: {toxinidir}{/}requirements{/}locks{/}py312-lock-win-64.txt
description =
Perform cf-units unit/integration tests.
passenv =
Expand Down
Loading