def test_get_array_fits_fails(): """Test convert.get_array""" helpers.setup() # make test array tmp = np.zeros((3), dtype=np.float32) out_path = os.path.join(helpers.TEST_PATH, "test.fits") fits.PrimaryHDU(data=tmp).writeto(out_path) with pytest.raises(ValueError) as excinfo: convert.get_array(out_path) helpers.tear_down() assert "FitsMap only supports 2D" in str(excinfo.value)
def test_get_array_png(): """Test convert.get_array""" helpers.setup() # make test array expected_array = camera() out_path = os.path.join(helpers.TEST_PATH, "test.png") Image.fromarray(expected_array).save(out_path) # get test array actual_array = convert.get_array(out_path) helpers.tear_down() np.testing.assert_equal(expected_array, np.flipud(actual_array))
def test_get_array_fits(): """Test convert.get_array""" helpers.setup() # make test array tmp = np.zeros((3, 3), dtype=np.float32) out_path = os.path.join(helpers.TEST_PATH, "test.fits") fits.PrimaryHDU(data=tmp).writeto(out_path) pads = [[0, 1], [0, 1]] expected_array = np.pad(tmp, pads, mode="constant", constant_values=np.nan) # get test array actual_array = convert.get_array(out_path) helpers.tear_down() np.testing.assert_equal(expected_array, actual_array)