Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix support for NDData objects with dask .data attributes #365

Merged
merged 1 commit into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions reproject/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ def valid_celestial_input(tmp_path, request, wcs):
input_value = (da.from_array(array), wcs)
elif request.param == "nddata":
input_value = NDData(data=array, wcs=wcs)
elif request.param == "nddata_dask":
input_value = NDData(data=da.from_array(array), wcs=wcs)
elif request.param == "wcs":
set_wcs_array_shape(wcs, array.shape)
input_value = wcs
Expand All @@ -158,6 +160,7 @@ def valid_celestial_input(tmp_path, request, wcs):
"data_wcs_tuple",
"dask_wcs_tuple",
"nddata",
"nddata_dask",
]


Expand Down
6 changes: 5 additions & 1 deletion reproject/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ def parse_input_data(input_data, hdu_in=None):
elif isinstance(input_data, BaseLowLevelWCS) and input_data.array_shape is not None:
return input_data.array_shape, HighLevelWCSWrapper(input_data)
elif isinstance(input_data, astropy.nddata.NDDataBase):
return input_data.data, input_data.wcs
if isinstance(input_data.data, da.core.Array):
data = _dask_to_numpy_memmap(input_data.data)
else:
data = input_data.data
return data, input_data.wcs
else:
raise TypeError(
"input_data should either be an HDU object or a tuple "
Expand Down