From 9fd1fe221f4979612da6c85ccc29462329c39e64 Mon Sep 17 00:00:00 2001 From: Jonathan Foster Date: Tue, 19 Sep 2023 11:32:47 -0400 Subject: [PATCH] Do not use fancy index for subsets over Dask data --- glue/core/fixed_resolution_buffer.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/glue/core/fixed_resolution_buffer.py b/glue/core/fixed_resolution_buffer.py index 1898c5e10..76bc0c067 100644 --- a/glue/core/fixed_resolution_buffer.py +++ b/glue/core/fixed_resolution_buffer.py @@ -246,7 +246,14 @@ def compute_fixed_resolution_buffer(data, bounds, target_data=None, target_cid=N # array. This won't be very efficient when dealing with 3d fixed # resolution buffers, but it will at least work as opposed to not. - if target_cid is not None and isinstance(data, Data) and isinstance(data.get_component(target_cid), DaskComponent): + # Since subset definitions can be pretty arbitrary, we do not rely + # on fancy indexing if the target dataset has any DaskComponents + # when we apply subset_state. + + target_cid_is_dask = target_cid is not None and isinstance(data, Data) and isinstance(data.get_component(target_cid), DaskComponent) + subset_over_dask_data = subset_state is not None and any([isinstance(data.get_component(comp), DaskComponent) for comp in data.main_components]) + + if target_cid_is_dask or subset_over_dask_data: # Extract sub-region of data first, then fetch exact coordinate values subregion = tuple([slice(np.nanmin(coord), np.nanmax(coord) + 1) for coord in translated_coords])