Skip to content
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

Dim.shape Should Error Out If Not int or datetime #1055

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# In-Progress

## Bug Fixes
* `Dim.shape` correctly errors out if type is not integer or datetime [#1055](https://github.com/TileDB-Inc/TileDB-Py/pull/1055)

# TileDB-Py 0.14.2 Release Notes

## TileDB Embedded updates:
Expand Down
13 changes: 10 additions & 3 deletions tiledb/libtiledb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2025,9 +2025,16 @@ cdef class Dim(object):

cdef _integer_domain(self):
cdef tiledb_datatype_t typ = self._get_type()
if typ == TILEDB_FLOAT32 or typ == TILEDB_FLOAT64:
return False
return True
return typ in (
TILEDB_UINT8,
TILEDB_INT8,
TILEDB_UINT16,
TILEDB_INT16,
TILEDB_UINT32,
TILEDB_INT32,
TILEDB_UINT64,
TILEDB_INT64,
)

cdef _datetime_domain(self):
cdef tiledb_datatype_t typ = self._get_type()
Expand Down
8 changes: 8 additions & 0 deletions tiledb/tests/test_libtiledb.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ def test_datetime_dimension(self):
name="d1", domain=(-10, 10), tile=2, dtype=np.datetime64("", "D")
)

def test_shape(self):
dim = tiledb.Dim(name="", dtype="|S0", var=True)
with self.assertRaisesRegex(
TypeError,
"shape only valid for integer and datetime dimension domains",
):
dim.shape


class DomainTest(DiskTestCase):
def test_domain(self, capfd):
Expand Down