def test_transform_image_does_not_change_input(): ccd_data = ccd_data_func() original = ccd_data.copy() with np.errstate(invalid="ignore"): _ = transform_image(ccd_data, np.sqrt) np.testing.assert_array_equal(original.data, ccd_data) assert original.unit == ccd_data.unit
def test_catch_transform_wcs_warning(): ccd_data = ccd_data_func() def tran(arr): return 10 * arr with catch_warnings() as w: tran = transform_image(ccd_data, tran)
def test_transform_image(mask_data, uncertainty): ccd_data = ccd_data_func(data_size=50) if mask_data: ccd_data.mask = np.zeros_like(ccd_data) ccd_data.mask[10, 10] = 1 if uncertainty: err = np.random.normal(size=ccd_data.shape) ccd_data.uncertainty = StdDevUncertainty(err) def tran(arr): return 10 * arr tran = transform_image(ccd_data, tran) assert_array_equal(10 * ccd_data.data, tran.data) if mask_data: assert tran.shape == tran.mask.shape assert_array_equal(ccd_data.mask, tran.mask) if uncertainty: assert tran.shape == tran.uncertainty.array.shape assert_array_equal(10 * ccd_data.uncertainty.array, tran.uncertainty.array)
def test_transform_isfunc(): ccd_data = ccd_data_func() with pytest.raises(TypeError): transform_image(ccd_data, 1)
def test_transform_isccd(): with pytest.raises(TypeError): transform_image(1, 1)
def test_transform_image_does_not_change_input(): ccd_data = ccd_data_func() original = ccd_data.copy() ccd = transform_image(ccd_data, np.sqrt) np.testing.assert_array_equal(original.data, ccd_data) assert original.unit == ccd_data.unit