Skip to content

Commit 3af516f

Browse files
authored
gh-198: enforce python>3.8 & numpy>1.21 (#326)
Closes #198. For Array API support (#67), we need minimum versions of: 1. `Python 3.9` as specified here https://data-apis.org/array-api-compat/changelog.html#id9 2. `NumPy 1.22` as specified here https://numpy.org/doc/stable/reference/array_api.html#array-api-standard-compatibility In this PR I have enforced both of these. The code changes have come from `ruff` linting, utilising the benefits from [3.9](https://docs.python.org/3/whatsnew/3.9.html). I also removed some of the overzealous comments on imports. They weren't adding anything and meant the imports took up more room.
1 parent 8a7dbec commit 3af516f

File tree

7 files changed

+21
-24
lines changed

7 files changed

+21
-24
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ jobs:
3232
strategy:
3333
matrix:
3434
python-version:
35-
- "3.8"
3635
- "3.9"
3736
- "3.10"
3837
- "3.11"
@@ -67,7 +66,7 @@ jobs:
6766
uses: coverallsapp/github-action@v2
6867
with:
6968
parallel-finished: true
70-
carryforward: run-3.8,run-3.9,run-3.10,run-3.11,run-3.12
69+
carryforward: run-3.9,run-3.10,run-3.11,run-3.12
7170

7271
build:
7372
name: Build

glass/fields.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,17 @@
2727
from __future__ import annotations
2828

2929
import warnings
30-
31-
# typing
32-
from typing import Any, Callable, Generator, Iterable, Optional, Sequence, Tuple, Union
30+
from collections.abc import Generator, Iterable, Sequence
31+
from typing import Any, Callable, Optional, Union
3332

3433
import healpy as hp
3534
import numpy as np
3635
import numpy.typing as npt
3736
from gaussiancl import gaussiancl
3837

3938
# types
40-
Size = Optional[Union[int, Tuple[int, ...]]]
41-
Iternorm = Tuple[Optional[int], npt.NDArray, npt.NDArray]
39+
Size = Optional[Union[int, tuple[int, ...]]]
40+
Iternorm = tuple[Optional[int], npt.NDArray, npt.NDArray]
4241
ClTransform = Union[str, Callable[[npt.NDArray], npt.NDArray]]
4342
Cls = Sequence[Union[npt.NDArray, Sequence[float]]]
4443
Alms = npt.NDArray

glass/lensing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131

3232
from __future__ import annotations
3333

34-
# typing support
35-
from typing import TYPE_CHECKING, Sequence
34+
from typing import TYPE_CHECKING
3635

3736
import healpy as hp
3837
import numpy as np
3938

4039
if TYPE_CHECKING:
41-
# to prevent circular dependencies, only import these for type checking
40+
from collections.abc import Sequence
41+
4242
import numpy.typing as npt
4343

4444
from cosmology import Cosmology

glass/shells.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@
4545
from __future__ import annotations
4646

4747
import warnings
48-
49-
# type checking
50-
from typing import TYPE_CHECKING, Callable, NamedTuple, Sequence, Union
48+
from collections.abc import Sequence
49+
from typing import TYPE_CHECKING, Callable, NamedTuple, Union
5150

5251
import numpy as np
5352
import numpy.typing as npt
@@ -57,7 +56,6 @@
5756
if TYPE_CHECKING:
5857
from cosmology import Cosmology
5958

60-
6159
# types
6260
ArrayLike1D = Union[Sequence[float], npt.NDArray]
6361
WeightFunc = Callable[[ArrayLike1D], npt.NDArray]

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
nox.options.reuse_existing_virtualenvs = True
1212
nox.options.sessions = ["lint", "tests"]
1313

14-
ALL_PYTHON = ["3.8", "3.9", "3.10", "3.11", "3.12"]
14+
ALL_PYTHON = ["3.9", "3.10", "3.11", "3.12"]
1515

1616

1717
@nox.session

pyproject.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ classifiers = [
1111
"Operating System :: OS Independent",
1212
"Programming Language :: Python :: 3",
1313
"Programming Language :: Python :: 3 :: Only",
14-
"Programming Language :: Python :: 3.8",
1514
"Programming Language :: Python :: 3.9",
1615
"Programming Language :: Python :: 3.10",
1716
"Programming Language :: Python :: 3.11",
@@ -24,7 +23,7 @@ dependencies = [
2423
"gaussiancl>=2022.10.21",
2524
"healpix>=2022.11.1",
2625
"healpy>=1.15.0",
27-
"numpy>=1.20.0",
26+
"numpy>=1.22.0",
2827
]
2928
description = "Generator for Large Scale Structure"
3029
dynamic = [
@@ -35,7 +34,7 @@ maintainers = [
3534
]
3635
name = "glass"
3736
readme = "README.md"
38-
requires-python = ">=3.8"
37+
requires-python = ">=3.9"
3938
license.file = "LICENSE"
4039

4140
[project.optional-dependencies]

tests/test_fits.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ def test_basic_write(tmp_path):
3232
filename_gfits = "gfits.fits" # what GLASS creates
3333
filename_tfits = "tfits.fits" # file created on the fly to test against
3434

35-
with user.write_catalog(
36-
tmp_path / filename_gfits, ext="CATALOG"
37-
) as out, fitsio.FITS(tmp_path / filename_tfits, "rw", clobber=True) as my_fits:
35+
with (
36+
user.write_catalog(tmp_path / filename_gfits, ext="CATALOG") as out,
37+
fitsio.FITS(tmp_path / filename_tfits, "rw", clobber=True) as my_fits,
38+
):
3839
for i in range(my_max):
3940
array = np.arange(i, i + 1, delta) # array of size 1/delta
4041
array2 = np.arange(i + 1, i + 2, delta) # array of size 1/delta
@@ -43,9 +44,10 @@ def test_basic_write(tmp_path):
4344
names = ["RA", "RB"]
4445
_test_append(my_fits, arrays, names)
4546

46-
with fitsio.FITS(tmp_path / filename_gfits) as g_fits, fitsio.FITS(
47-
tmp_path / filename_tfits
48-
) as t_fits:
47+
with (
48+
fitsio.FITS(tmp_path / filename_gfits) as g_fits,
49+
fitsio.FITS(tmp_path / filename_tfits) as t_fits,
50+
):
4951
glass_data = g_fits[1].read()
5052
test_data = t_fits[1].read()
5153
assert glass_data["RA"].size == test_data["RA"].size

0 commit comments

Comments
 (0)