-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
chunk sparse arrays #3202
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
Merged
Merged
chunk sparse arrays #3202
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0d03c3f
chunk sparse arrays
crusaderky e495fd6
Deprecated API
crusaderky 8868cc9
Merge remote-tracking branch 'upstream/master' into sparse_dask
crusaderky 7aa4222
Don't wrap plain numpy arrays with ImplicitToExplicitIndexingAdapter
crusaderky 6ddec67
typo
crusaderky 5a1ffae
What's New
crusaderky 38efffc
Version bump and annotations What's New polish
crusaderky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,14 @@ | ||
from collections import OrderedDict | ||
from contextlib import suppress | ||
from distutils.version import LooseVersion | ||
from textwrap import dedent | ||
import pickle | ||
import numpy as np | ||
import pandas as pd | ||
|
||
from xarray import DataArray, Dataset, Variable | ||
from xarray.tests import mock | ||
from xarray import DataArray, Variable | ||
from xarray.core.npcompat import IS_NEP18_ACTIVE | ||
import xarray as xr | ||
import xarray.ufuncs as xu | ||
|
||
from . import ( | ||
assert_allclose, | ||
assert_array_equal, | ||
assert_equal, | ||
assert_frame_equal, | ||
assert_identical, | ||
raises_regex, | ||
) | ||
from . import assert_equal, assert_identical | ||
|
||
import pytest | ||
|
||
|
@@ -148,7 +137,6 @@ def test_variable_property(prop): | |
True, | ||
marks=xfail(reason="'COO' object has no attribute 'argsort'"), | ||
), | ||
param(do("chunk", chunks=(5, 5)), True, marks=xfail), | ||
param( | ||
do( | ||
"concat", | ||
|
@@ -422,9 +410,6 @@ def test_dataarray_property(prop): | |
False, | ||
marks=xfail(reason="Missing implementation for np.flip"), | ||
), | ||
param( | ||
do("chunk", chunks=(5, 5)), False, marks=xfail(reason="Coercion to dense") | ||
), | ||
param( | ||
do("combine_first", make_xrarray({"x": 10, "y": 5})), | ||
True, | ||
|
@@ -879,3 +864,17 @@ def test_sparse_coords(self): | |
dims=["x"], | ||
coords={"x": COO.from_numpy([1, 2, 3, 4])}, | ||
) | ||
|
||
|
||
def test_chunk(): | ||
s = sparse.COO.from_numpy(np.array([0, 0, 1, 2])) | ||
a = DataArray(s) | ||
ac = a.chunk(2) | ||
assert ac.chunks == ((2, 2),) | ||
assert isinstance(ac.data._meta, sparse.COO) | ||
assert_identical(ac, a) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm guessing this is due to dask/dask#5259 |
||
|
||
ds = a.to_dataset(name="a") | ||
dsc = ds.chunk(2) | ||
assert dsc.chunks == {"dim_0": (2, 2)} | ||
assert_identical(dsc, ds) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.