1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchFromGitHub,
6
7 # build-system
8 setuptools-scm,
9
10 # dependencies
11 astropy,
12 casa-formats-io,
13 dask,
14 joblib,
15 numpy,
16 packaging,
17 radio-beam,
18 tqdm,
19
20 # tests
21 aplpy,
22 pytest-astropy,
23 pytestCheckHook,
24}:
25
26buildPythonPackage rec {
27 pname = "spectral-cube";
28 version = "0.6.6";
29 pyproject = true;
30
31 src = fetchFromGitHub {
32 owner = "radio-astro-tools";
33 repo = "spectral-cube";
34 tag = "v${version}";
35 hash = "sha256-fBjbovBXqUfX8rG8gEM3BY5p0BLfa4n1PMbPpPJPDgQ=";
36 };
37
38 build-system = [ setuptools-scm ];
39
40 dependencies = [
41 astropy
42 casa-formats-io
43 dask
44 joblib
45 numpy
46 packaging
47 radio-beam
48 tqdm
49 ]
50 ++ dask.optional-dependencies.array;
51
52 nativeCheckInputs = [
53 aplpy
54 pytest-astropy
55 pytestCheckHook
56 ];
57
58 # Tests must be run in the build directory.
59 preCheck = ''
60 cd build/lib
61 '';
62
63 pytestFlags = [
64 # FutureWarning: Can't acquire a memory view of a Dask array. This will raise in the future
65 # https://github.com/radio-astro-tools/spectral-cube/issues/943
66 "-Wignore::FutureWarning"
67 ];
68
69 disabledTests = [
70 # AttributeError: 'DaskSpectralCube' object has no attribute 'dtype'
71 "test_key_access_valid"
72
73 # For some reason, those tests are failing with "FutureWarning: Can't acquire a memory view of a Dask array."
74 # without being caught by the `-W ignore::FutureWarning` flag above.
75 "test_1d_slice_reductions"
76 "test_1d_slice_round"
77 "test_1d_slices"
78 "test_1dcomparison_mask_1d_index"
79 "test_1dmask_indexing"
80 "test_2dcomparison_mask_1d_index"
81 "test_3d_beams_roundtrip"
82 "test_4d_beams_roundtrip"
83 "test_LDO_arithmetic"
84 "test_add"
85 "test_apply_everywhere"
86 "test_apply_everywhere_plusminus"
87 "test_apply_function_parallel_shape"
88 "test_attributes"
89 "test_basic_arrayness"
90 "test_basic_unit_conversion"
91 "test_basic_unit_conversion_beams"
92 "test_beam_jpix_checks_array"
93 "test_beam_jtok"
94 "test_beam_jtok_2D"
95 "test_beam_jtok_array"
96 "test_beam_proj_meta"
97 "test_beams_convolution"
98 "test_beams_convolution_equal"
99 "test_casa_read_basic"
100 "test_convolution"
101 "test_convolve_to_equal"
102 "test_convolve_to_jybeam_multibeams"
103 "test_convolve_to_jybeam_onebeam"
104 "test_convolve_to_with_bad_beams"
105 "test_cube_add"
106 "test_cube_stacking"
107 "test_cube_with_swapped_axes"
108 "test_div"
109 "test_filled"
110 "test_getitem"
111 "test_getitem_vrsc"
112 "test_how_withfluxunit"
113 "test_initialization_from_units"
114 "test_mask_none"
115 "test_mosaic_cube"
116 "test_mul"
117 "test_mul_cubes"
118 "test_multibeams_unit_conversions_general_1D"
119 "test_numpy_ma_tools"
120 "test_oned_slic"
121 "test_oned_slice_beams"
122 "test_padding_direction"
123 "test_pow"
124 "test_preserves_header_meta_values"
125 "test_proj_meta"
126 "test_regression_719"
127 "test_repr_1d"
128 "test_slice_wcs"
129 "test_slicing"
130 "test_spatial_smooth_g2d"
131 "test_spatial_smooth_maxfilter"
132 "test_spatial_smooth_median"
133 "test_spatial_smooth_t2d"
134 "test_spatial_world"
135 "test_spectral_interpolate"
136 "test_spectral_interpolate_reversed"
137 "test_spectral_interpolate_varying_chunksize"
138 "test_spectral_interpolate_with_fillvalue"
139 "test_spectral_interpolate_with_mask"
140 "test_spectral_slice_preserve_units"
141 "test_spectral_smooth"
142 "test_spectral_units"
143 "test_stacking"
144 "test_stacking_badvels"
145 "test_stacking_noisy"
146 "test_stacking_reversed_specaxis"
147 "test_stacking_woffset"
148 "test_stacking_wpadding"
149 "test_subtract"
150 "test_subtract_cubes"
151 "test_unit_conversions_general"
152 "test_unit_conversions_general_1D"
153 "test_unit_conversions_general_2D"
154 "test_varyres_mask"
155 "test_varyres_spectra"
156 "test_varyres_unitconversion_roundtrip"
157 "test_with_flux_unit"
158 "test_with_spectral_unit"
159 ]
160 ++ lib.optionals stdenv.hostPlatform.isDarwin [
161 # Flaky: AssertionError: assert diffvals.max()*u.B <= 1*u.MB
162 "test_reproject_3D_memory"
163 ];
164
165 disabledTestPaths = lib.optionals stdenv.hostPlatform.isDarwin [
166 # On x86_darwin, this test fails with "Fatal Python error: Aborted"
167 # when sandbox = true.
168 "spectral_cube/tests/test_visualization.py"
169 ];
170
171 pythonImportsCheck = [ "spectral_cube" ];
172
173 meta = {
174 description = "Library for reading and analyzing astrophysical spectral data cubes";
175 homepage = "https://spectral-cube.readthedocs.io";
176 changelog = "https://github.com/radio-astro-tools/spectral-cube/releases/tag/v${version}";
177 license = lib.licenses.bsd3;
178 maintainers = with lib.maintainers; [ smaret ];
179 };
180}