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

map_blocks error with dask==2021.4 #288

Closed
aaronspring opened this issue Apr 20, 2021 · 5 comments · Fixed by #293
Closed

map_blocks error with dask==2021.4 #288

aaronspring opened this issue Apr 20, 2021 · 5 comments · Fixed by #293

Comments

@aaronspring
Copy link
Collaborator

aaronspring commented Apr 20, 2021

Problem description

Tests fail:

FAILED xskillscore/tests/test_contingency.py::test_Contingency_table[category_edges0-dim0-chunked_da]
FAILED xskillscore/tests/test_contingency.py::test_Contingency_table[category_edges0-dim0-chunked_ds]
FAILED xskillscore/tests/test_contingency.py::test_Contingency_table[category_edges0-dim1-chunked_da]
FAILED xskillscore/tests/test_contingency.py::test_Contingency_table[category_edges0-dim1-chunked_ds]
FAILED xskillscore/tests/test_contingency.py::test_Contingency_table[category_edges0-dim2-chunked_da]
FAILED xskillscore/tests/test_contingency.py::test_Contingency_table[category_edges0-dim2-chunked_ds]
FAILED xskillscore/tests/test_contingency.py::test_Contingency_table[category_edges0-time-chunked_da]
FAILED xskillscore/tests/test_contingency.py::test_Contingency_table[category_edges0-time-chunked_ds]
FAILED xskillscore/tests/test_contingency.py::test_Contingency_table[category_edges0-dim4-chunked_da]
FAILED xskillscore/tests/test_contingency.py::test_Contingency_table[category_edges0-dim4-chunked_ds]
FAILED xskillscore/tests/test_contingency.py::test_Contingency_table[category_edges1-dim0-chunked_da]
FAILED xskillscore/tests/test_contingency.py::test_Contingency_table[category_edges1-dim0-chunked_ds]
FAILED xskillscore/tests/test_contingency.py::test_Contingency_table[category_edges1-dim1-chunked_da]
FAILED xskillscore/tests/test_contingency.py::test_Contingency_table[category_edges1-dim1-chunked_ds]
FAILED xskillscore/tests/test_contingency.py::test_Contingency_table[category_edges1-dim2-chunked_da]
FAILED xskillscore/tests/test_contingency.py::test_Contingency_table[category_edges1-dim2-chunked_ds]
FAILED xskillscore/tests/test_contingency.py::test_Contingency_table[category_edges1-time-chunked_da]
FAILED xskillscore/tests/test_contingency.py::test_Contingency_table[category_edges1-time-chunked_ds]
FAILED xskillscore/tests/test_contingency.py::test_Contingency_table[category_edges1-dim4-chunked_da]
FAILED xskillscore/tests/test_contingency.py::test_Contingency_table[category_edges1-dim4-chunked_ds]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_tuple-Dataset-True-True-time-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_rps_category_edges_None[True]
FAILED xskillscore/tests/test_probabilistic.py::test_rps_category_edges_None[False]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_tuple-Dataset-True-True-time-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_tuple-Dataset-True-True-None-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[area-Dataset-True-False-time-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[area-Dataset-True-False-None-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_tuple-Dataset-True-True-None-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_tuple-Dataset-True-False-time-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[area-Dataset-True-False-None-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_tuple-DataArray-True-True-time-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_tuple-Dataset-True-False-time-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_tuple-DataArray-True-True-time-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_tuple-Dataset-True-False-None-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_tuple-DataArray-True-True-None-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_tuple-Dataset-True-False-None-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_tuple-DataArray-True-True-None-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_tuple-DataArray-True-False-time-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[area-DataArray-True-True-time-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_tuple-DataArray-True-False-time-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_tuple-DataArray-True-False-None-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[area-DataArray-True-True-time-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_tuple-DataArray-True-False-None-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[area-DataArray-True-True-None-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_metric_dim-Dataset-True-True-None-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[area-DataArray-True-True-None-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_metric_dim-Dataset-True-False-time-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[area-DataArray-True-False-time-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[area-Dataset-True-True-time-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_metric_dim-Dataset-True-False-time-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[area-DataArray-True-False-time-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[area-Dataset-True-True-time-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_metric_dim-Dataset-True-False-None-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[area-DataArray-True-False-None-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[area-Dataset-True-True-None-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_metric_dim-Dataset-True-False-None-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[area-Dataset-True-True-None-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[area-DataArray-True-False-None-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[area-Dataset-True-False-time-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_metric_dim-DataArray-True-True-None-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_metric_dim-DataArray-True-False-time-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_metric_dim-DataArray-True-False-time-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_metric_dim-Dataset-True-True-time-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_metric_dim-DataArray-True-True-time-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_metric_dim-DataArray-True-False-None-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_metric_dim-DataArray-True-False-None-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_metric_dim-Dataset-True-True-time-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_metric_dim-DataArray-True-True-time-observation_3d-forecast_3d]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_metric_dim-Dataset-True-True-None-observation_1d_long-forecast_1d_long]
FAILED xskillscore/tests/test_probabilistic.py::test_roc_returns[all_as_metric_dim-DataArray-True-True-None-observation_1d_long-forecast_1d_long]

Errors look like:

skillscore/tests/test_probabilistic.py:831: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
xskillscore/core/probabilistic.py:1209: in roc
    dim=dim,
xskillscore/core/contingency.py:122: in __init__
    self._table = self._get_contingency_table(dim)
xskillscore/core/contingency.py:167: in _get_contingency_table
    bin_dim_suffix="_bin",
xskillscore/core/utils.py:166: in histogram
    return xhist(*args, bins=bins, **kwargs)
/usr/share/miniconda/envs/xskillscore-minimum-tests/lib/python3.7/site-packages/xhistogram/xarray.py:146: in histogram
    block_size=block_size
/usr/share/miniconda/envs/xskillscore-minimum-tests/lib/python3.7/site-packages/xhistogram/core.py:271: in histogram
    block_size=block_size,
/usr/share/miniconda/envs/xskillscore-minimum-tests/lib/python3.7/site-packages/xhistogram/core.py:131: in _histogram_2d_vectorized
    bin_indices = ravel_multi_index(each_bin_indices, hist_shapes)
/usr/share/miniconda/envs/xskillscore-minimum-tests/lib/python3.7/site-packages/xhistogram/duck_array_ops.py:24: in f
    return getattr(module, name)(*args, **kwargs)
<__array_function__ internals>:6: in ravel_multi_index
    ???
/usr/share/miniconda/envs/xskillscore-minimum-tests/lib/python3.7/site-packages/dask/array/core.py:1525: in __array_function__
    return da_func(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

multi_index = [dask.array<digitize, shape=(1, 200), dtype=int64, chunksize=(1, 200), chunktype=numpy.ndarray>, dask.array<digitize, shape=(1, 200), dtype=int64, chunksize=(1, 200), chunktype=numpy.ndarray>]
dims = [4, 4], mode = 'raise', order = 'C'

    @wraps(np.ravel_multi_index)
    def ravel_multi_index(multi_index, dims, mode="raise", order="C"):
>       return multi_index.map_blocks(
            _ravel_multi_index_kernel,
            dtype=np.intp,
            chunks=(multi_index.shape[-1],),
            drop_axis=0,
            func_kwargs=dict(dims=dims, mode=mode, order=order),
        )
E       AttributeError: 'list' object has no attribute 'map_blocks'

Where

I didnt change anything in contingency, only RPS.

https://github.com/xarray-contrib/xskillscore/pull/287/checks?check_run_id=2388515699

versions:
dask 2021.4.0 pyhd8ed1ab_0 conda-forge
dask-core 2021.4.0 pyhd8ed1ab_0 conda-forge
xarray 0.17.0 pyhd8ed1ab_0 conda-forge
xhistogram 0.1.3 pyhd8ed1ab_0 conda-forge
xskillscore 0.0.post1 dev_0

Likely an upstream xhist issue.

@raybellwaves
Copy link
Member

@aaronspring @dougiesquire want to continue the convo here from xgcm/xhistogram#27 (comment) (the xhist wrapper for datasets).

I forget is there a way to use pytest and remove the parametrize of do you have have to change it in the code base? The 50 ways it fails doesn't help.

Looks as thought the tests failings are

@raybellwaves
Copy link
Member

May have been my PR https://github.com/xgcm/xhistogram/pull/31/files where I moved ravel_multi_index to the dask version. I wonder if there was something in there previously that worked with https://github.com/xarray-contrib/xskillscore/blob/master/xskillscore/core/utils.py#L133

@dougiesquire
Copy link
Collaborator

May have been my PR https://github.com/xgcm/xhistogram/pull/31/files where I moved ravel_multi_index to the dask version. I wonder if there was something in there previously that worked with https://github.com/xarray-contrib/xskillscore/blob/master/xskillscore/core/utils.py#L133

Trying to check this now. It is failing within ravel_multi_index, but still trying to work out why exactly...

@dougiesquire
Copy link
Collaborator

I don't think this is an issue with anything in xskillscore. I can reproduce the error with dask=2021.04.0 and xhistogram=0.1.3 using the following:

from xhistogram.xarray import histogram as xhist

data = np.random.randint(0, 10, size=10)
a = xr.DataArray(data, coords=[range(len(data))], dims=["x"]).chunk().rename('a')
b = a.rename('b')

xhist(a, b, 
      bins=[np.array([-np.inf,  0.5,  np.inf]), np.array([-np.inf,  0.5,  np.inf])],
      **{'dim': ['x'], 'bin_dim_suffix': '_bin'})

I'm wondering if the issue with dask=2021.03 has not yet been fully resolved. Still investigating...

@dougiesquire
Copy link
Collaborator

I think I've found the issue - see xgcm/xhistogram#27 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants