Skip to content

Commit f3f3817

Browse files
committed
Allow a minimal test build (no specutils or dask)
1 parent 3795fa9 commit f3f3817

6 files changed

Lines changed: 24 additions & 18 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
coverage: codecov
2929
toxdeps: tox-pypi-filter
3030
envs: |
31-
- linux: py313
31+
- linux: py313-minimal
3232
secrets:
3333
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
3434

ndcube/conftest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"""
55
import logging
66

7-
import dask.array
87
import numpy as np
98
import pytest
109
from gwcs import coordinate_frames as cf
@@ -1041,15 +1040,16 @@ def ndcube_2d_ln_lt_unit_unc_mask(wcs_2d_lt_ln):
10411040

10421041
@pytest.fixture
10431042
def ndcube_2d_dask(wcs_2d_lt_ln):
1043+
da = pytest.importorskip("dask.array")
10441044
shape = (8, 4)
10451045
chunks = 2
10461046
data = data_nd(shape).astype(float)
1047-
da = dask.array.asarray(data, chunks=chunks)
1047+
darr = da.asarray(data, chunks=chunks)
10481048
mask = np.zeros(shape, dtype=bool)
1049-
da_mask = dask.array.asarray(mask, chunks=chunks)
1049+
da_mask = da.asarray(mask, chunks=chunks)
10501050
uncert = data * 0.1
1051-
da_uncert = StdDevUncertainty(dask.array.asarray(uncert, chunks=chunks))
1052-
return NDCube(da, wcs=wcs_2d_lt_ln, uncertainty=da_uncert, mask=da_mask, unit=u.J)
1051+
da_uncert = StdDevUncertainty(da.asarray(uncert, chunks=chunks))
1052+
return NDCube(darr, wcs=wcs_2d_lt_ln, uncertainty=da_uncert, mask=da_mask, unit=u.J)
10531053

10541054

10551055
@pytest.fixture

ndcube/tests/test_ndcube.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from inspect import signature
22

3-
import dask.array
43
import numpy as np
54
import pytest
65

@@ -73,8 +72,9 @@ def test_to(ndcube_1d_l, new_unit):
7372

7473

7574
def test_to_dask(ndcube_2d_dask):
75+
da = pytest.importorskip("dask.array")
7676
output = ndcube_2d_dask.to(u.mJ)
77-
dask_type = dask.array.core.Array
77+
dask_type = da.core.Array
7878
assert isinstance(output.data, dask_type)
7979
assert isinstance(output.uncertainty.array, dask_type)
8080
assert isinstance(output.mask, dask_type)
@@ -103,14 +103,15 @@ def test_ndcube_quantity(ndcube_2d_ln_lt_units):
103103

104104

105105
def test_data_setter(ndcube_4d_ln_l_t_lt):
106+
da = pytest.importorskip("dask.array")
106107
cube = ndcube_4d_ln_l_t_lt
107108
assert isinstance(cube.data, np.ndarray)
108109

109110
new_data = np.zeros_like(cube.data)
110111
cube.data = new_data
111112
assert cube.data is new_data
112113

113-
dask_array = dask.array.zeros_like(cube.data)
114+
dask_array = da.zeros_like(cube.data)
114115
cube.data = dask_array
115116
assert cube.data is dask_array
116117

ndcube/tests/test_ndcube_reproject_and_rebin.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
import re
22
import copy
33

4-
import dask.array
54
import numpy as np
65
import pytest
76

8-
try:
9-
from specutils import Spectrum
10-
except ImportError:
11-
from specutils import Spectrum1D as Spectrum
12-
137
import astropy.units as u
148
import astropy.wcs
159
from astropy.coordinates import SpectralCoord
@@ -167,11 +161,12 @@ def test_rebin(ndcube_3d_l_ln_lt_ectime, bin_shape):
167161

168162

169163
def test_rebin_dask(ndcube_2d_dask):
164+
da = pytest.importorskip("dask.array")
170165
# Execute rebin.
171166
cube = ndcube_2d_dask
172167
bin_shape = (4, 2)
173168
output = cube.rebin(bin_shape, propagate_uncertainties=True)
174-
dask_type = dask.array.core.Array
169+
dask_type = da.core.Array
175170
assert isinstance(output.data, dask_type)
176171
assert isinstance(output.uncertainty.array, dask_type)
177172
assert isinstance(output.mask, dask_type)
@@ -312,7 +307,12 @@ def test_rebin_axis_aware_meta(ndcube_4d_axis_aware_meta):
312307

313308

314309
def test_rebin_specutils():
310+
pytest.importorskip("specutils")
315311
# Tests for https://github.com/sunpy/ndcube/issues/717
312+
try:
313+
from specutils import Spectrum # noqa PLC0415
314+
except ImportError:
315+
from specutils import Spectrum1D as Spectrum # noqa PLC0415
316316
y = np.arange(4000)*u.ct
317317
x = np.arange(200, 4200)*u.nm
318318
spec = Spectrum(flux=y, spectral_axis=x, bin_specification='centers', mask=x > 2000*u.nm)

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ tests-only = [
4040
"pytest",
4141
"pytest-memray; sys_platform != 'win32'",
4242
]
43+
tests-minimal = [
44+
"ndcube[plotting,reproject,tests-only]",
45+
"sunpy>=6.1.0",
46+
]
4347
tests = [
4448
"ndcube[plotting,reproject,tests-only,tests-optional,asdf-tests]",
4549
]

tox.ini

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ requires =
44
tox-pypi-filter>=0.14
55
envlist =
66
py{311,312,313,314}
7+
py313-minimal
78
py314-devdeps
89
py311-oldestdeps
910
codestyle
@@ -63,8 +64,8 @@ deps =
6364
figure-!devdeps: scipy
6465
# The following indicates which extras_require will be installed
6566
extras =
66-
!oldestdeps: tests
67-
oldestdeps: tests-only
67+
minimal: tests-minimal
68+
!minimal: tests
6869
commands_pre =
6970
oldestdeps: minimum_dependencies ndcube --extras plotting reproject asdf tests-optional --filename requirements-min.txt
7071
oldestdeps: pip install -r requirements-min.txt

0 commit comments

Comments
 (0)