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