Skip to content

Commit

Permalink
Merge pull request #2471 from dhomeier/ci-np2
Browse files Browse the repository at this point in the history
Compatibility and tests against Numpy 2.0.0rc1
  • Loading branch information
dhomeier authored Apr 17, 2024
2 parents b47ae71 + bd331ce commit 924d0ae
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/ci_workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- linux: py39-test
- linux: py310-test-all
- linux: py311-test
- linux: py311-test-all
- linux: py312-test-all
# Documentation build
- linux: py38-docs
Expand All @@ -43,14 +43,21 @@ jobs:
- macos: py39-test
- macos: py310-test-all
- macos: py311-test
- macos: py312-test-all
# Test some configurations on Windows
- windows: py38-test
- windows: py310-test
- windows: py39-test
# Test against latest developer versions of some packages
- linux: py310-test-dev-all
- linux: py311-test-dev
- linux: py312-test-dev-all
- macos: py311-test-dev-all
- macos: py312-test-dev
- windows: py310-test-dev
publish:
needs: tests
Expand Down
2 changes: 2 additions & 0 deletions glue/utils/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,8 @@ class categorical_ndarray(np.ndarray):

def __new__(cls, value, dtype=None, copy=True, order=None, subok=False,
ndmin=0, categories=None):
if not copy and np.lib.NumpyVersion(np.__version__) >= "2.0.0rc1":
copy = None
result = np.array(value, dtype=dtype, copy=copy, order=order,
subok=True, ndmin=ndmin).view(categorical_ndarray)
if categories is not None:
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ install_requires =
pandas>=1.2
echo>=0.6
astropy>=4.0
fast_histogram>=0.12
setuptools>=30.3.0
ipython>=4.0
dill>=0.2
Expand Down
12 changes: 10 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tox]
envlist =
py{38,39,310,311}-{codestyle,test,docs}-all-{dev,legacy}{,-visual}
py{38,39,310,311,312}-{codestyle,test,docs}-all-{dev,legacy}{,-visual}
requires = pip >= 18.0
setuptools >= 30.3.0

Expand All @@ -10,7 +10,7 @@ passenv =
DISPLAY
HOME
setenv =
dev: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/astropy/simple https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
dev: PIP_EXTRA_INDEX_URL = https://pypi.anaconda.org/astropy/simple https://pypi.anaconda.org/liberfa/simple https://pypi.anaconda.org/scientific-python-nightly-wheels/simple
visual: MPLFLAGS = -m "mpl_image_compare" --mpl --mpl-generate-summary=html --mpl-results-path={toxinidir}/results --mpl-hash-library={toxinidir}/glue/tests/visual/{envname}.json --mpl-baseline-path=https://raw.githubusercontent.com/glue-viz/glue-core-visual-tests/images/{envname}/
whitelist_externals =
find
Expand All @@ -22,7 +22,9 @@ changedir =
docs: doc
deps =
dev: numpy>=0.0.dev0
dev: scipy>=0.0.dev0
dev: astropy>=0.0.dev0
# LTS
lts: astropy==5.0.*
lts: matplotlib==3.5.*
# Pin numpy-lts until permanent solution for #2353/#2428
Expand All @@ -46,6 +48,12 @@ extras =
all: all
docs: docs
visual: visualtest
# Need `--pre` for packages like pandas having no released version supporting numpy>=2.0 yet,
# + `--no-deps` for casa-formats-io having no branch for numpy>=2.0 -
# for as long all test deps need to be manually pulled in above as well!
install_command =
!dev: python -I -m pip install
dev: python -I -m pip install -v
commands =
test: pip freeze
test: pytest --pyargs glue --cov glue --cov-config={toxinidir}/setup.cfg {env:MPLFLAGS} {posargs}
Expand Down

0 comments on commit 924d0ae

Please sign in to comment.