Skip to content

Commit

Permalink
Raise error when sparse=True is passed to tiledb.from_numpy (#2080)
Browse files Browse the repository at this point in the history
  • Loading branch information
kounelisagis authored Oct 1, 2024
1 parent d70fd75 commit a1b6335
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tiledb/highlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ def from_numpy(uri, array, config=None, ctx=None, **kwargs):
ctx = _get_ctx(ctx, config)
mode = kwargs.pop("mode", "ingest")
timestamp = kwargs.pop("timestamp", None)
sparse = kwargs.pop("sparse", False)

if sparse:
raise tiledb.TileDBError("from_numpy only supports dense arrays")

if mode not in ("ingest", "schema_only", "append"):
raise tiledb.TileDBError(f"Invalid mode specified ('{mode}')")
Expand Down
8 changes: 8 additions & 0 deletions tiledb/tests/test_fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,14 @@ def test_sc43221(self):
a = tiledb.Group("mem://tmp1")
repr(a.meta)

def test_sc56611(self):
# test from_numpy with sparse argument set to True
uri = self.path("test_sc56611")
data = np.random.rand(10, 10)
with pytest.raises(tiledb.cc.TileDBError) as exc_info:
tiledb.from_numpy(uri, data, sparse=True)
assert str(exc_info.value) == "from_numpy only supports dense arrays"


class SOMA919Test(DiskTestCase):
"""
Expand Down

0 comments on commit a1b6335

Please sign in to comment.