Skip to content

Commit a1b6335

Browse files
authored
Raise error when sparse=True is passed to tiledb.from_numpy (#2080)
1 parent d70fd75 commit a1b6335

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

tiledb/highlevel.py

+4
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ def from_numpy(uri, array, config=None, ctx=None, **kwargs):
114114
ctx = _get_ctx(ctx, config)
115115
mode = kwargs.pop("mode", "ingest")
116116
timestamp = kwargs.pop("timestamp", None)
117+
sparse = kwargs.pop("sparse", False)
118+
119+
if sparse:
120+
raise tiledb.TileDBError("from_numpy only supports dense arrays")
117121

118122
if mode not in ("ingest", "schema_only", "append"):
119123
raise tiledb.TileDBError(f"Invalid mode specified ('{mode}')")

tiledb/tests/test_fixes.py

+8
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,14 @@ def test_sc43221(self):
282282
a = tiledb.Group("mem://tmp1")
283283
repr(a.meta)
284284

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

286294
class SOMA919Test(DiskTestCase):
287295
"""

0 commit comments

Comments
 (0)