-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set object codec for object arrays (#573)
- Loading branch information
Showing
3 changed files
with
39 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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 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 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,10 +1,22 @@ | ||
import pytest | ||
from numpy.testing import assert_array_equal | ||
|
||
import cubed | ||
import cubed.array_api as xp | ||
from cubed.storage.backend import backend_storage_name | ||
|
||
|
||
# This is less strict than the spec, but is supported by implementations like NumPy | ||
def test_prod_sum_bool(): | ||
a = xp.ones((2,), dtype=xp.bool) | ||
assert_array_equal(xp.prod(a).compute(), xp.asarray([1], dtype=xp.int64)) | ||
assert_array_equal(xp.sum(a).compute(), xp.asarray([2], dtype=xp.int64)) | ||
|
||
|
||
@pytest.mark.skipif( | ||
backend_storage_name() != "zarr-python", | ||
reason="object dtype only works on zarr-python", | ||
) | ||
def test_object_dtype(): | ||
a = xp.asarray(["a", "b"], dtype=object, chunks=2) | ||
cubed.to_zarr(a, store=None) |