Skip to content

Commit

Permalink
Throw IndexError When Using Step With Indexer (#911)
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenv authored Feb 3, 2022
1 parent 7f30408 commit a0cf242
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# TileDB-Py 0.12.3 Release Notes

## Bug Fixes
* Error out with `IndexError` when attempting to use a step in the regular indexer [#911](https://github.com/TileDB-Inc/TileDB-Py/pull/911)

# TileDB-Py 0.12.2 Release Notes

## TileDB Embedded updates:
* TileDB-Py 0.12.1 includes TileDB Embedded [TileDB 2.6.2](https://github.com/TileDB-Inc/TileDB/releases/tag/2.6.2)
* TileDB-Py 0.12.2 includes TileDB Embedded [TileDB 2.6.2](https://github.com/TileDB-Inc/TileDB/releases/tag/2.6.2)

## API Changes
* Addition of `ArraySchema.validity_filters` [#898](https://github.com/TileDB-Inc/TileDB-Py/pull/898)
Expand Down
4 changes: 2 additions & 2 deletions tiledb/libtiledb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3406,8 +3406,8 @@ def index_domain_subarray(array: Array, dom: Domain, idx: tuple):
subarray.append((start,stop))
continue

#if step and step < 0:
# raise IndexError("only positive slice steps are supported")
if step and array.schema.sparse:
raise IndexError("steps are not supported for sparse arrays")

# Datetimes will be treated specially
is_datetime = (dim_dtype.kind == 'M')
Expand Down
5 changes: 5 additions & 0 deletions tiledb/tests/test_libtiledb.py
Original file line number Diff line number Diff line change
Expand Up @@ -2413,6 +2413,11 @@ def test_subarray(self, sparse_cell_order):
with tiledb.SparseArray(self.path("foo"), mode="r") as T:
self.assertEqual(((50, 100),), T.nonempty_domain())

# stepped ranges are not supported
with self.assertRaises(IndexError) as idxerr:
T[40:61:5]
assert str(idxerr.value) == "steps are not supported for sparse arrays"

# retrieve just valid coordinates in subarray T[40:60]
assert_array_equal(T[40:61]["x"], [50, 60])

Expand Down

0 comments on commit a0cf242

Please sign in to comment.