sunraster
sunraster copied to clipboard
Unit tests fail for [email protected]
Describe the bug
Hi,
While preparing this project for Guix index I've faced with some tests failed to pass:
________________ test_read_spice_l2_fits_single_file_dumbbells _________________
spice_rasdb_filename = '/tmp/guix-build-python-sunraster-0.5.1.drv-0/pytest-of-nixbld/pytest-0/test_read_spice_l2_fits_single2/spice/solo_L2_spice-n-ras-db_20200602T081733_V01_12583760-000.fits'
def test_read_spice_l2_fits_single_file_dumbbells(spice_rasdb_filename):
filename = spice_rasdb_filename
> result = read_spice_l2_fits(filename, read_dumbbells=True)
sunraster/instr/tests/test_spice.py:290:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
sunraster/instr/spice.py:108: in read_spice_l2_fits
aligned_axes = tuple(range(len(first_sequence.dimensions)))
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/ndcube.py:471: in dimensions
warn_deprecated("Replaced by ndcube.NDCube.shape")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
msg = 'Replaced by ndcube.NDCube.shape', stacklevel = 1
def warn_deprecated(msg, stacklevel=1):
"""
Raise a `NDCubeDeprecationWarning`.
Parameters
----------
msg : str
Warning message.
stacklevel : int
This is interpreted relative to the call to this function,
e.g. ``stacklevel=1`` (the default) sets the stack level in the
code that calls this function.
"""
> warnings.warn(msg, NDCubeDeprecationWarning , stacklevel + 1)
E ndcube.utils.exceptions.NDCubeDeprecationWarning: Replaced by ndcube.NDCube.shape
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/utils/exceptions.py:61: NDCubeDeprecationWarning
__________ test_read_spice_l2_fits_multiple_rasters_multiple_windows ___________
spice_rasdb_filename = '/tmp/guix-build-python-sunraster-0.5.1.drv-0/pytest-of-nixbld/pytest-0/test_read_spice_l2_fits_multip0/spice/solo_L2_spice-n-ras-db_20200602T081733_V01_12583760-000.fits'
def test_read_spice_l2_fits_multiple_rasters_multiple_windows(spice_rasdb_filename):
filenames = [spice_rasdb_filename] * 2
result = read_spice_l2_fits(filenames)
assert isinstance(result, READ_SPICE_L2_FITS_RETURN_TYPE)
assert set(result.aligned_axes.values()) == {(0, 2, 3)}
assert len(result) == 2
> assert all(window.dimensions[0].value == len(filenames) for window in result.values())
sunraster/instr/tests/test_spice.py:303:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
sunraster/instr/tests/test_spice.py:303: in <genexpr>
assert all(window.dimensions[0].value == len(filenames) for window in result.values())
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/ndcube_sequence.py:50: in dimensions
warn_deprecated("Replaced by ndcube.NDCubeSequence.shape")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
msg = 'Replaced by ndcube.NDCubeSequence.shape', stacklevel = 1
def warn_deprecated(msg, stacklevel=1):
"""
Raise a `NDCubeDeprecationWarning`.
Parameters
----------
msg : str
Warning message.
stacklevel : int
This is interpreted relative to the call to this function,
e.g. ``stacklevel=1`` (the default) sets the stack level in the
code that calls this function.
"""
> warnings.warn(msg, NDCubeDeprecationWarning , stacklevel + 1)
E ndcube.utils.exceptions.NDCubeDeprecationWarning: Replaced by ndcube.NDCubeSequence.shape
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/utils/exceptions.py:61: NDCubeDeprecationWarning
____________ test_read_spice_l2_fits_multiple_rasters_single_window ____________
spice_rasdb_filename = '/tmp/guix-build-python-sunraster-0.5.1.drv-0/pytest-of-nixbld/pytest-0/test_read_spice_l2_fits_multip1/spice/solo_L2_spice-n-ras-db_20200602T081733_V01_12583760-000.fits'
def test_read_spice_l2_fits_multiple_rasters_single_window(spice_rasdb_filename):
filenames = [spice_rasdb_filename] * 2
result = read_spice_l2_fits(filenames, windows=["WINDOW0_70.51"])
assert isinstance(result, READ_SPICE_L2_FITS_RETURN_TYPE)
assert result.aligned_axes is None
assert len(result) == 1
> assert all(window.dimensions[0].value == len(filenames) for window in result.values())
sunraster/instr/tests/test_spice.py:313:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
sunraster/instr/tests/test_spice.py:313: in <genexpr>
assert all(window.dimensions[0].value == len(filenames) for window in result.values())
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/ndcube_sequence.py:50: in dimensions
warn_deprecated("Replaced by ndcube.NDCubeSequence.shape")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
msg = 'Replaced by ndcube.NDCubeSequence.shape', stacklevel = 1
def warn_deprecated(msg, stacklevel=1):
"""
Raise a `NDCubeDeprecationWarning`.
Parameters
----------
msg : str
Warning message.
stacklevel : int
This is interpreted relative to the call to this function,
e.g. ``stacklevel=1`` (the default) sets the stack level in the
code that calls this function.
"""
> warnings.warn(msg, NDCubeDeprecationWarning , stacklevel + 1)
E ndcube.utils.exceptions.NDCubeDeprecationWarning: Replaced by ndcube.NDCubeSequence.shape
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/utils/exceptions.py:61: NDCubeDeprecationWarning
____________ test_read_spice_l2_fits_multiple_sns_multiple_windows _____________
spice_sns_filename = '/tmp/guix-build-python-sunraster-0.5.1.drv-0/pytest-of-nixbld/pytest-0/test_read_spice_l2_fits_multip2/spice/solo_L2_spice-n-sit_20200620T235901_V01_16777431-000.fits'
def test_read_spice_l2_fits_multiple_sns_multiple_windows(spice_sns_filename):
filenames = [spice_sns_filename] * 2
result = read_spice_l2_fits(filenames)
assert isinstance(result, READ_SPICE_L2_FITS_RETURN_TYPE)
assert set(result.aligned_axes.values()) == {(0, 2, 3)}
assert len(result) == 2
> assert all(window.dimensions[0].value == len(filenames) for window in result.values())
sunraster/instr/tests/test_spice.py:323:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
sunraster/instr/tests/test_spice.py:323: in <genexpr>
assert all(window.dimensions[0].value == len(filenames) for window in result.values())
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/ndcube_sequence.py:50: in dimensions
warn_deprecated("Replaced by ndcube.NDCubeSequence.shape")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
msg = 'Replaced by ndcube.NDCubeSequence.shape', stacklevel = 1
def warn_deprecated(msg, stacklevel=1):
"""
Raise a `NDCubeDeprecationWarning`.
Parameters
----------
msg : str
Warning message.
stacklevel : int
This is interpreted relative to the call to this function,
e.g. ``stacklevel=1`` (the default) sets the stack level in the
code that calls this function.
"""
> warnings.warn(msg, NDCubeDeprecationWarning , stacklevel + 1)
E ndcube.utils.exceptions.NDCubeDeprecationWarning: Replaced by ndcube.NDCubeSequence.shape
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/utils/exceptions.py:61: NDCubeDeprecationWarning
_______________ test_read_spice_l2_fits_multiple_files_dumbbells _______________
spice_rasdb_filename = '/tmp/guix-build-python-sunraster-0.5.1.drv-0/pytest-of-nixbld/pytest-0/test_read_spice_l2_fits_multip3/spice/solo_L2_spice-n-ras-db_20200602T081733_V01_12583760-000.fits'
def test_read_spice_l2_fits_multiple_files_dumbbells(spice_rasdb_filename):
filenames = [spice_rasdb_filename] * 2
> result = read_spice_l2_fits(filenames, read_dumbbells=True)
sunraster/instr/tests/test_spice.py:329:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
sunraster/instr/spice.py:108: in read_spice_l2_fits
aligned_axes = tuple(range(len(first_sequence.dimensions)))
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/ndcube_sequence.py:50: in dimensions
warn_deprecated("Replaced by ndcube.NDCubeSequence.shape")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
msg = 'Replaced by ndcube.NDCubeSequence.shape', stacklevel = 1
def warn_deprecated(msg, stacklevel=1):
"""
Raise a `NDCubeDeprecationWarning`.
Parameters
----------
msg : str
Warning message.
stacklevel : int
This is interpreted relative to the call to this function,
e.g. ``stacklevel=1`` (the default) sets the stack level in the
code that calls this function.
"""
> warnings.warn(msg, NDCubeDeprecationWarning , stacklevel + 1)
E ndcube.utils.exceptions.NDCubeDeprecationWarning: Replaced by ndcube.NDCubeSequence.shape
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/utils/exceptions.py:61: NDCubeDeprecationWarning
_ test_apply_exposure_time_correction[input_cube0-False-False-expected_cube0] __
input_cube = <[NDCubeDeprecationWarning('Replaced by ndcube.NDCube.shape') raised in repr()] SpectrogramCube object at 0x7fff5e93f910>
undo = False, force = False
expected_cube = <[NDCubeDeprecationWarning('Replaced by ndcube.NDCube.shape') raised in repr()] SpectrogramCube object at 0x7fff5e93f790>
@pytest.mark.parametrize(
"input_cube, undo, force, expected_cube",
[
(spectrogram_DN0, False, False, spectrogram_DN_per_s0),
(spectrogram_DN_per_s0, True, False, spectrogram_DN0),
(spectrogram_DN_per_s0, False, True, spectrogram_DN_per_s_per_s0),
(spectrogram_DN0, True, True, spectrogram_DN_s0),
],
)
def test_apply_exposure_time_correction(input_cube, undo, force, expected_cube):
output_cube = input_cube.apply_exposure_time_correction(undo=undo, force=force)
> assert_cubes_equal(output_cube, expected_cube)
sunraster/tests/test_spectrogram.py:187:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/tests/helpers.py:134: in assert_cubes_equal
assert_metas_equal(test_input.meta, expected_cube.meta)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_input = {'exposure time': <Quantity [2., 2.] s>}
expected_output = {'exposure time': <Quantity [2., 2.] s>}
def assert_metas_equal(test_input, expected_output):
if type(test_input) is not type(expected_output):
raise AssertionError(
"input and expected are of different type. "
f"input: {type(test_input)}; expected: {type(expected_output)}")
multi_element_msg = "more than one element is ambiguous"
if isinstance(test_input, NDMeta) and isinstance(expected_output, NDMeta):
assert test_input.keys() == expected_output.keys()
if test_input.data_shape is None or expected_output.data_shape is None:
assert test_input.data_shape == expected_output.data_shape
else:
assert np.allclose(test_input.data_shape, expected_output.data_shape)
for test_value, expected_value in zip(test_input.values(), expected_output.values()):
try:
assert test_value == expected_value
except ValueError as err: # noqa: PERF203
if multi_element_msg in err.args[0]:
assert np.allclose(test_value, expected_value)
for key in test_input.axes.keys():
assert all(test_input.axes[key] == expected_output.axes[key])
else:
if not (test_input is None and expected_output is None):
assert test_input.keys() == expected_output.keys()
for key in list(test_input.keys()):
> assert test_input[key] == expected_output[key]
E ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/tests/helpers.py:122: ValueError
__ test_apply_exposure_time_correction[input_cube1-True-False-expected_cube1] __
input_cube = <[NDCubeDeprecationWarning('Replaced by ndcube.NDCube.shape') raised in repr()] SpectrogramCube object at 0x7fff5e93f790>
undo = True, force = False
expected_cube = <[NDCubeDeprecationWarning('Replaced by ndcube.NDCube.shape') raised in repr()] SpectrogramCube object at 0x7fff5e93f910>
@pytest.mark.parametrize(
"input_cube, undo, force, expected_cube",
[
(spectrogram_DN0, False, False, spectrogram_DN_per_s0),
(spectrogram_DN_per_s0, True, False, spectrogram_DN0),
(spectrogram_DN_per_s0, False, True, spectrogram_DN_per_s_per_s0),
(spectrogram_DN0, True, True, spectrogram_DN_s0),
],
)
def test_apply_exposure_time_correction(input_cube, undo, force, expected_cube):
output_cube = input_cube.apply_exposure_time_correction(undo=undo, force=force)
> assert_cubes_equal(output_cube, expected_cube)
sunraster/tests/test_spectrogram.py:187:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/tests/helpers.py:134: in assert_cubes_equal
assert_metas_equal(test_input.meta, expected_cube.meta)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_input = {'exposure time': <Quantity [2., 2.] s>}
expected_output = {'exposure time': <Quantity [2., 2.] s>}
def assert_metas_equal(test_input, expected_output):
if type(test_input) is not type(expected_output):
raise AssertionError(
"input and expected are of different type. "
f"input: {type(test_input)}; expected: {type(expected_output)}")
multi_element_msg = "more than one element is ambiguous"
if isinstance(test_input, NDMeta) and isinstance(expected_output, NDMeta):
assert test_input.keys() == expected_output.keys()
if test_input.data_shape is None or expected_output.data_shape is None:
assert test_input.data_shape == expected_output.data_shape
else:
assert np.allclose(test_input.data_shape, expected_output.data_shape)
for test_value, expected_value in zip(test_input.values(), expected_output.values()):
try:
assert test_value == expected_value
except ValueError as err: # noqa: PERF203
if multi_element_msg in err.args[0]:
assert np.allclose(test_value, expected_value)
for key in test_input.axes.keys():
assert all(test_input.axes[key] == expected_output.axes[key])
else:
if not (test_input is None and expected_output is None):
assert test_input.keys() == expected_output.keys()
for key in list(test_input.keys()):
> assert test_input[key] == expected_output[key]
E ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/tests/helpers.py:122: ValueError
__ test_apply_exposure_time_correction[input_cube2-False-True-expected_cube2] __
input_cube = <[NDCubeDeprecationWarning('Replaced by ndcube.NDCube.shape') raised in repr()] SpectrogramCube object at 0x7fff5e93f790>
undo = False, force = True
expected_cube = <[NDCubeDeprecationWarning('Replaced by ndcube.NDCube.shape') raised in repr()] SpectrogramCube object at 0x7fff5e93f4c0>
@pytest.mark.parametrize(
"input_cube, undo, force, expected_cube",
[
(spectrogram_DN0, False, False, spectrogram_DN_per_s0),
(spectrogram_DN_per_s0, True, False, spectrogram_DN0),
(spectrogram_DN_per_s0, False, True, spectrogram_DN_per_s_per_s0),
(spectrogram_DN0, True, True, spectrogram_DN_s0),
],
)
def test_apply_exposure_time_correction(input_cube, undo, force, expected_cube):
output_cube = input_cube.apply_exposure_time_correction(undo=undo, force=force)
> assert_cubes_equal(output_cube, expected_cube)
sunraster/tests/test_spectrogram.py:187:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/tests/helpers.py:134: in assert_cubes_equal
assert_metas_equal(test_input.meta, expected_cube.meta)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_input = {'exposure time': <Quantity [2., 2.] s>}
expected_output = {'exposure time': <Quantity [2., 2.] s>}
def assert_metas_equal(test_input, expected_output):
if type(test_input) is not type(expected_output):
raise AssertionError(
"input and expected are of different type. "
f"input: {type(test_input)}; expected: {type(expected_output)}")
multi_element_msg = "more than one element is ambiguous"
if isinstance(test_input, NDMeta) and isinstance(expected_output, NDMeta):
assert test_input.keys() == expected_output.keys()
if test_input.data_shape is None or expected_output.data_shape is None:
assert test_input.data_shape == expected_output.data_shape
else:
assert np.allclose(test_input.data_shape, expected_output.data_shape)
for test_value, expected_value in zip(test_input.values(), expected_output.values()):
try:
assert test_value == expected_value
except ValueError as err: # noqa: PERF203
if multi_element_msg in err.args[0]:
assert np.allclose(test_value, expected_value)
for key in test_input.axes.keys():
assert all(test_input.axes[key] == expected_output.axes[key])
else:
if not (test_input is None and expected_output is None):
assert test_input.keys() == expected_output.keys()
for key in list(test_input.keys()):
> assert test_input[key] == expected_output[key]
E ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/tests/helpers.py:122: ValueError
__ test_apply_exposure_time_correction[input_cube3-True-True-expected_cube3] ___
input_cube = <[NDCubeDeprecationWarning('Replaced by ndcube.NDCube.shape') raised in repr()] SpectrogramCube object at 0x7fff5e93f910>
undo = True, force = True
expected_cube = <[NDCubeDeprecationWarning('Replaced by ndcube.NDCube.shape') raised in repr()] SpectrogramCube object at 0x7fff5e93fc40>
@pytest.mark.parametrize(
"input_cube, undo, force, expected_cube",
[
(spectrogram_DN0, False, False, spectrogram_DN_per_s0),
(spectrogram_DN_per_s0, True, False, spectrogram_DN0),
(spectrogram_DN_per_s0, False, True, spectrogram_DN_per_s_per_s0),
(spectrogram_DN0, True, True, spectrogram_DN_s0),
],
)
def test_apply_exposure_time_correction(input_cube, undo, force, expected_cube):
output_cube = input_cube.apply_exposure_time_correction(undo=undo, force=force)
> assert_cubes_equal(output_cube, expected_cube)
sunraster/tests/test_spectrogram.py:187:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/tests/helpers.py:134: in assert_cubes_equal
assert_metas_equal(test_input.meta, expected_cube.meta)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_input = {'exposure time': <Quantity [2., 2.] s>}
expected_output = {'exposure time': <Quantity [2., 2.] s>}
def assert_metas_equal(test_input, expected_output):
if type(test_input) is not type(expected_output):
raise AssertionError(
"input and expected are of different type. "
f"input: {type(test_input)}; expected: {type(expected_output)}")
multi_element_msg = "more than one element is ambiguous"
if isinstance(test_input, NDMeta) and isinstance(expected_output, NDMeta):
assert test_input.keys() == expected_output.keys()
if test_input.data_shape is None or expected_output.data_shape is None:
assert test_input.data_shape == expected_output.data_shape
else:
assert np.allclose(test_input.data_shape, expected_output.data_shape)
for test_value, expected_value in zip(test_input.values(), expected_output.values()):
try:
assert test_value == expected_value
except ValueError as err: # noqa: PERF203
if multi_element_msg in err.args[0]:
assert np.allclose(test_value, expected_value)
for key in test_input.axes.keys():
assert all(test_input.axes[key] == expected_output.axes[key])
else:
if not (test_input is None and expected_output is None):
assert test_input.keys() == expected_output.keys()
for key in list(test_input.keys()):
> assert test_input[key] == expected_output[key]
E ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/tests/helpers.py:122: ValueError
_____________________ test_ndcube_components_after_slicing _____________________
def test_ndcube_components_after_slicing():
"""
Tests all cube components are correctly propagated by slicing.
"""
item = tuple([slice(0, 1)] * 3)
sliced_cube = spectrogram_instrument_axes[item]
data = spectrogram_instrument_axes.data[item]
uncertainty = spectrogram_instrument_axes.uncertainty[item]
mask = spectrogram_instrument_axes.mask[item]
extra_coords = list(EXTRA_COORDS0)
ec_axis = 0
ec0 = list(extra_coords[0])
ec0[-1] = ec0[-1][item[ec_axis]]
wcs = spectrogram_instrument_axes.wcs[item]
expected_cube = SpectrogramCube(
data=data,
wcs=wcs,
uncertainty=uncertainty,
mask=mask,
meta=spectrogram_instrument_axes.meta,
unit=spectrogram_instrument_axes.unit,
instrument_axes=spectrogram_instrument_axes.instrument_axes,
)
expected_cube.extra_coords.add(*ec0)
> assert str(sliced_cube)
sunraster/tests/test_spectrogram.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
sunraster/spectrogram.py:302: in __str__
Pixel dimensions: {self.dimensions.astype(int)}
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/ndcube.py:471: in dimensions
warn_deprecated("Replaced by ndcube.NDCube.shape")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
msg = 'Replaced by ndcube.NDCube.shape', stacklevel = 1
def warn_deprecated(msg, stacklevel=1):
"""
Raise a `NDCubeDeprecationWarning`.
Parameters
----------
msg : str
Warning message.
stacklevel : int
This is interpreted relative to the call to this function,
e.g. ``stacklevel=1`` (the default) sets the stack level in the
code that calls this function.
"""
> warnings.warn(msg, NDCubeDeprecationWarning , stacklevel + 1)
E ndcube.utils.exceptions.NDCubeDeprecationWarning: Replaced by ndcube.NDCube.shape
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/utils/exceptions.py:61: NDCubeDeprecationWarning
_ test_apply_exposure_time_correction[input_sequence0-False-False-expected_sequence0] _
input_sequence = <[NDCubeDeprecationWarning('Replaced by ndcube.NDCubeSequence.shape') raised in repr()] RasterSequence object at 0x7fff5ecdcd90>
undo = False, force = False
expected_sequence = <[NDCubeDeprecationWarning('Replaced by ndcube.NDCubeSequence.shape') raised in repr()] RasterSequence object at 0x7fff5ecde980>
@pytest.mark.parametrize(
"input_sequence, undo, force, expected_sequence",
[
(sequence_DN, False, False, sequence_DN_per_s),
(sequence_DN_per_s, True, False, sequence_DN),
(sequence_DN_per_s, False, True, sequence_DN_per_s_per_s),
(sequence_DN, True, True, sequence_DN_s),
],
)
def test_apply_exposure_time_correction(input_sequence, undo, force, expected_sequence):
output_sequence = input_sequence.apply_exposure_time_correction(undo, copy=True, force=force)
> assert_cubesequences_equal(output_sequence, expected_sequence)
sunraster/tests/test_spectrogramsequence.py:255:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/tests/helpers.py:147: in assert_cubesequences_equal
assert_cubes_equal(cube, expected_sequence.data[i], check_data=check_data)
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/tests/helpers.py:134: in assert_cubes_equal
assert_metas_equal(test_input.meta, expected_cube.meta)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_input = {'exposure time': <Quantity [2., 2.] s>}
expected_output = {'exposure time': <Quantity [2., 2.] s>}
def assert_metas_equal(test_input, expected_output):
if type(test_input) is not type(expected_output):
raise AssertionError(
"input and expected are of different type. "
f"input: {type(test_input)}; expected: {type(expected_output)}")
multi_element_msg = "more than one element is ambiguous"
if isinstance(test_input, NDMeta) and isinstance(expected_output, NDMeta):
assert test_input.keys() == expected_output.keys()
if test_input.data_shape is None or expected_output.data_shape is None:
assert test_input.data_shape == expected_output.data_shape
else:
assert np.allclose(test_input.data_shape, expected_output.data_shape)
for test_value, expected_value in zip(test_input.values(), expected_output.values()):
try:
assert test_value == expected_value
except ValueError as err: # noqa: PERF203
if multi_element_msg in err.args[0]:
assert np.allclose(test_value, expected_value)
for key in test_input.axes.keys():
assert all(test_input.axes[key] == expected_output.axes[key])
else:
if not (test_input is None and expected_output is None):
assert test_input.keys() == expected_output.keys()
for key in list(test_input.keys()):
> assert test_input[key] == expected_output[key]
E ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/tests/helpers.py:122: ValueError
_ test_apply_exposure_time_correction[input_sequence1-True-False-expected_sequence1] _
input_sequence = <[NDCubeDeprecationWarning('Replaced by ndcube.NDCubeSequence.shape') raised in repr()] RasterSequence object at 0x7fff5ecde980>
undo = True, force = False
expected_sequence = <[NDCubeDeprecationWarning('Replaced by ndcube.NDCubeSequence.shape') raised in repr()] RasterSequence object at 0x7fff5ecdcd90>
@pytest.mark.parametrize(
"input_sequence, undo, force, expected_sequence",
[
(sequence_DN, False, False, sequence_DN_per_s),
(sequence_DN_per_s, True, False, sequence_DN),
(sequence_DN_per_s, False, True, sequence_DN_per_s_per_s),
(sequence_DN, True, True, sequence_DN_s),
],
)
def test_apply_exposure_time_correction(input_sequence, undo, force, expected_sequence):
output_sequence = input_sequence.apply_exposure_time_correction(undo, copy=True, force=force)
> assert_cubesequences_equal(output_sequence, expected_sequence)
sunraster/tests/test_spectrogramsequence.py:255:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/tests/helpers.py:147: in assert_cubesequences_equal
assert_cubes_equal(cube, expected_sequence.data[i], check_data=check_data)
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/tests/helpers.py:134: in assert_cubes_equal
assert_metas_equal(test_input.meta, expected_cube.meta)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_input = {'exposure time': <Quantity [2., 2.] s>}
expected_output = {'exposure time': <Quantity [2., 2.] s>}
def assert_metas_equal(test_input, expected_output):
if type(test_input) is not type(expected_output):
raise AssertionError(
"input and expected are of different type. "
f"input: {type(test_input)}; expected: {type(expected_output)}")
multi_element_msg = "more than one element is ambiguous"
if isinstance(test_input, NDMeta) and isinstance(expected_output, NDMeta):
assert test_input.keys() == expected_output.keys()
if test_input.data_shape is None or expected_output.data_shape is None:
assert test_input.data_shape == expected_output.data_shape
else:
assert np.allclose(test_input.data_shape, expected_output.data_shape)
for test_value, expected_value in zip(test_input.values(), expected_output.values()):
try:
assert test_value == expected_value
except ValueError as err: # noqa: PERF203
if multi_element_msg in err.args[0]:
assert np.allclose(test_value, expected_value)
for key in test_input.axes.keys():
assert all(test_input.axes[key] == expected_output.axes[key])
else:
if not (test_input is None and expected_output is None):
assert test_input.keys() == expected_output.keys()
for key in list(test_input.keys()):
> assert test_input[key] == expected_output[key]
E ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/tests/helpers.py:122: ValueError
_ test_apply_exposure_time_correction[input_sequence2-False-True-expected_sequence2] _
input_sequence = <[NDCubeDeprecationWarning('Replaced by ndcube.NDCubeSequence.shape') raised in repr()] RasterSequence object at 0x7fff5ecde980>
undo = False, force = True
expected_sequence = <[NDCubeDeprecationWarning('Replaced by ndcube.NDCubeSequence.shape') raised in repr()] RasterSequence object at 0x7fff5eb16710>
@pytest.mark.parametrize(
"input_sequence, undo, force, expected_sequence",
[
(sequence_DN, False, False, sequence_DN_per_s),
(sequence_DN_per_s, True, False, sequence_DN),
(sequence_DN_per_s, False, True, sequence_DN_per_s_per_s),
(sequence_DN, True, True, sequence_DN_s),
],
)
def test_apply_exposure_time_correction(input_sequence, undo, force, expected_sequence):
output_sequence = input_sequence.apply_exposure_time_correction(undo, copy=True, force=force)
> assert_cubesequences_equal(output_sequence, expected_sequence)
sunraster/tests/test_spectrogramsequence.py:255:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/tests/helpers.py:147: in assert_cubesequences_equal
assert_cubes_equal(cube, expected_sequence.data[i], check_data=check_data)
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/tests/helpers.py:134: in assert_cubes_equal
assert_metas_equal(test_input.meta, expected_cube.meta)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_input = {'exposure time': <Quantity [2., 2.] s>}
expected_output = {'exposure time': <Quantity [2., 2.] s>}
def assert_metas_equal(test_input, expected_output):
if type(test_input) is not type(expected_output):
raise AssertionError(
"input and expected are of different type. "
f"input: {type(test_input)}; expected: {type(expected_output)}")
multi_element_msg = "more than one element is ambiguous"
if isinstance(test_input, NDMeta) and isinstance(expected_output, NDMeta):
assert test_input.keys() == expected_output.keys()
if test_input.data_shape is None or expected_output.data_shape is None:
assert test_input.data_shape == expected_output.data_shape
else:
assert np.allclose(test_input.data_shape, expected_output.data_shape)
for test_value, expected_value in zip(test_input.values(), expected_output.values()):
try:
assert test_value == expected_value
except ValueError as err: # noqa: PERF203
if multi_element_msg in err.args[0]:
assert np.allclose(test_value, expected_value)
for key in test_input.axes.keys():
assert all(test_input.axes[key] == expected_output.axes[key])
else:
if not (test_input is None and expected_output is None):
assert test_input.keys() == expected_output.keys()
for key in list(test_input.keys()):
> assert test_input[key] == expected_output[key]
E ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/tests/helpers.py:122: ValueError
_ test_apply_exposure_time_correction[input_sequence3-True-True-expected_sequence3] _
input_sequence = <[NDCubeDeprecationWarning('Replaced by ndcube.NDCubeSequence.shape') raised in repr()] RasterSequence object at 0x7fff5ecdcd90>
undo = True, force = True
expected_sequence = <[NDCubeDeprecationWarning('Replaced by ndcube.NDCubeSequence.shape') raised in repr()] RasterSequence object at 0x7fff5eb14790>
@pytest.mark.parametrize(
"input_sequence, undo, force, expected_sequence",
[
(sequence_DN, False, False, sequence_DN_per_s),
(sequence_DN_per_s, True, False, sequence_DN),
(sequence_DN_per_s, False, True, sequence_DN_per_s_per_s),
(sequence_DN, True, True, sequence_DN_s),
],
)
def test_apply_exposure_time_correction(input_sequence, undo, force, expected_sequence):
output_sequence = input_sequence.apply_exposure_time_correction(undo, copy=True, force=force)
> assert_cubesequences_equal(output_sequence, expected_sequence)
sunraster/tests/test_spectrogramsequence.py:255:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/tests/helpers.py:147: in assert_cubesequences_equal
assert_cubes_equal(cube, expected_sequence.data[i], check_data=check_data)
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/tests/helpers.py:134: in assert_cubes_equal
assert_metas_equal(test_input.meta, expected_cube.meta)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_input = {'exposure time': <Quantity [2., 2.] s>}
expected_output = {'exposure time': <Quantity [2., 2.] s>}
def assert_metas_equal(test_input, expected_output):
if type(test_input) is not type(expected_output):
raise AssertionError(
"input and expected are of different type. "
f"input: {type(test_input)}; expected: {type(expected_output)}")
multi_element_msg = "more than one element is ambiguous"
if isinstance(test_input, NDMeta) and isinstance(expected_output, NDMeta):
assert test_input.keys() == expected_output.keys()
if test_input.data_shape is None or expected_output.data_shape is None:
assert test_input.data_shape == expected_output.data_shape
else:
assert np.allclose(test_input.data_shape, expected_output.data_shape)
for test_value, expected_value in zip(test_input.values(), expected_output.values()):
try:
assert test_value == expected_value
except ValueError as err: # noqa: PERF203
if multi_element_msg in err.args[0]:
assert np.allclose(test_value, expected_value)
for key in test_input.axes.keys():
assert all(test_input.axes[key] == expected_output.axes[key])
else:
if not (test_input is None and expected_output is None):
assert test_input.keys() == expected_output.keys()
for key in list(test_input.keys()):
> assert test_input[key] == expected_output[key]
E ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/tests/helpers.py:122: ValueError
_____________________________ [doctest] raster.rst _____________________________
109 [('custom:pos.helioprojective.lat', 'custom:pos.helioprojective.lon', 'time'), ('custom:pos.helioprojective.lat', 'custom:pos.helioprojective.lon'), ('em.wl',)]
110
111 In the raster case, ``'meta.obs.sequence'`` represents the raster scan number axis.
112 For those familiar with `~ndcube.NDCubeSequence`, these are simply aliases for the `~ndcube.NDCubeSequence.array_axis_physical_axis_types` and `~ndcube.NDCubeSequence.cube_like_world_axis_physical_axis_types`, respectively.
113
114 The length of each axis can also be displayed in either the raster or sns representation.
115
116 .. code-block:: python
117
118 >>> my_rasters.raster_dimensions
UNEXPECTED EXCEPTION: NDCubeDeprecationWarning('Replaced by ndcube.NDCubeSequence.shape')
Traceback (most recent call last):
File "/gnu/store/50047r6f9chb6dwd01f9hai90y9arwb4-python-3.10.7/lib/python3.10/doctest.py", line 1350, in __run
exec(compile(example.source, filename, "single",
File "<doctest raster.rst[35]>", line 1, in <module>
File "/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/ndcube_sequence.py", line 50, in dimensions
warn_deprecated("Replaced by ndcube.NDCubeSequence.shape")
File "/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/utils/exceptions.py", line 61, in warn_deprecated
warnings.warn(msg, NDCubeDeprecationWarning , stacklevel + 1)
ndcube.utils.exceptions.NDCubeDeprecationWarning: Replaced by ndcube.NDCubeSequence.shape
/tmp/guix-build-python-sunraster-0.5.1.drv-0/sunraster-0.5.1/docs/data_types/raster.rst:118: UnexpectedException
__________________________ [doctest] spectrogram.rst ___________________________
104 The supported exposure time coordinate names can be found under ``sunraster.spectrogram.SUPPORTED_EXPOSURE_NAMES``.
105
106 Dimensions
107 ^^^^^^^^^^
108
109 The `~sunraster.SpectrogramCube.dimensions` and `~sunraster.SpectrogramCube.array_axis_physical_types` methods enable users to inspect the shape and WCS axis types of the `~sunraster.SpectrogramCube` instance.
110
111 .. code-block:: python
112
113 >>> my_spectrograms.dimensions
UNEXPECTED EXCEPTION: NDCubeDeprecationWarning('Replaced by ndcube.NDCube.shape')
Traceback (most recent call last):
File "/gnu/store/50047r6f9chb6dwd01f9hai90y9arwb4-python-3.10.7/lib/python3.10/doctest.py", line 1350, in __run
exec(compile(example.source, filename, "single",
File "<doctest spectrogram.rst[12]>", line 1, in <module>
File "/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/ndcube.py", line 471, in dimensions
warn_deprecated("Replaced by ndcube.NDCube.shape")
File "/gnu/store/a18b5bx2vmnggdldsc6mjpwvw6qw1n6k-python-ndcube-2.3.1/lib/python3.10/site-packages/ndcube/utils/exceptions.py", line 61, in warn_deprecated
warnings.warn(msg, NDCubeDeprecationWarning , stacklevel + 1)
ndcube.utils.exceptions.NDCubeDeprecationWarning: Replaced by ndcube.NDCube.shape
/tmp/guix-build-python-sunraster-0.5.1.drv-0/sunraster-0.5.1/docs/data_types/spectrogram.rst:113: UnexpectedException
=========================== short test summary info ============================
FAILED sunraster/instr/tests/test_spice.py::test_read_spice_l2_fits_single_file_dumbbells - ndcube.utils.exceptions.NDCubeDeprecationWarning: Replaced by ndcube.NDCube.shape
FAILED sunraster/instr/tests/test_spice.py::test_read_spice_l2_fits_multiple_rasters_multiple_windows - ndcube.utils.exceptions.NDCubeDeprecationWarning: Replaced by ndcube.NDCubeSequence.shape
FAILED sunraster/instr/tests/test_spice.py::test_read_spice_l2_fits_multiple_rasters_single_window - ndcube.utils.exceptions.NDCubeDeprecationWarning: Replaced by ndcube.NDCubeSequence.shape
FAILED sunraster/instr/tests/test_spice.py::test_read_spice_l2_fits_multiple_sns_multiple_windows - ndcube.utils.exceptions.NDCubeDeprecationWarning: Replaced by ndcube.NDCubeSequence.shape
FAILED sunraster/instr/tests/test_spice.py::test_read_spice_l2_fits_multiple_files_dumbbells - ndcube.utils.exceptions.NDCubeDeprecationWarning: Replaced by ndcube.NDCubeSequence.shape
FAILED sunraster/tests/test_spectrogram.py::test_apply_exposure_time_correction[input_cube0-False-False-expected_cube0] - ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
FAILED sunraster/tests/test_spectrogram.py::test_apply_exposure_time_correction[input_cube1-True-False-expected_cube1] - ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
FAILED sunraster/tests/test_spectrogram.py::test_apply_exposure_time_correction[input_cube2-False-True-expected_cube2] - ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
FAILED sunraster/tests/test_spectrogram.py::test_apply_exposure_time_correction[input_cube3-True-True-expected_cube3] - ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
FAILED sunraster/tests/test_spectrogram.py::test_ndcube_components_after_slicing - ndcube.utils.exceptions.NDCubeDeprecationWarning: Replaced by ndcube.NDCube.shape
FAILED sunraster/tests/test_spectrogramsequence.py::test_apply_exposure_time_correction[input_sequence0-False-False-expected_sequence0] - ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
FAILED sunraster/tests/test_spectrogramsequence.py::test_apply_exposure_time_correction[input_sequence1-True-False-expected_sequence1] - ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
FAILED sunraster/tests/test_spectrogramsequence.py::test_apply_exposure_time_correction[input_sequence2-False-True-expected_sequence2] - ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
FAILED sunraster/tests/test_spectrogramsequence.py::test_apply_exposure_time_correction[input_sequence3-True-True-expected_sequence3] - ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
FAILED docs/data_types/raster.rst::raster.rst
FAILED docs/data_types/spectrogram.rst::spectrogram.rst
======================== 16 failed, 66 passed in 5.22s =========================
Inputs: