Skip to content

Commit

Permalink
Dim.shape Should Error Out If Not int or datetime (#1055)
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenv authored Apr 28, 2022
1 parent 4d20eaf commit 3defced
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
5 changes: 4 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# In Progress
# In-Progress

## Improvements
* Refactor display of TileDB objects in Jupyter notebooks to be more readable [#1049](https://github.com/TileDB-Inc/TileDB-Py/pull/1049)

## 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 @@ -2022,9 +2022,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 @@ -282,6 +282,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

0 comments on commit 3defced

Please sign in to comment.