Skip to content

Commit

Permalink
Parametrize arrayschema repr test
Browse files Browse the repository at this point in the history
  • Loading branch information
ihnorton committed Jun 24, 2021
1 parent 93e6e99 commit 0a150c0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
30 changes: 15 additions & 15 deletions tiledb/libtiledb.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3293,8 +3293,8 @@ cdef class ArraySchema(object):
cdef tiledb_layout_t cell_layout = TILEDB_ROW_MAJOR
cdef tiledb_layout_t tile_layout = TILEDB_ROW_MAJOR
try:
cell_layout = _tiledb_layout(cell_order)
tile_layout = _tiledb_layout(tile_order)
cell_layout = _tiledb_layout(cell_order if cell_order else 'row-major')
tile_layout = _tiledb_layout(tile_order if tile_order else 'row-major')
check_error(ctx, tiledb_array_schema_set_cell_order(ctx.ptr, schema_ptr, cell_layout))
check_error(ctx, tiledb_array_schema_set_tile_order(ctx.ptr, schema_ptr, tile_layout))
except:
Expand Down Expand Up @@ -3513,11 +3513,11 @@ cdef class ArraySchema(object):
"""
cdef tiledb_layout_t order = TILEDB_UNORDERED
self._tile_order(&order)

layout_string = _tiledb_layout_string(order)
if self.cell_order == "hilbert":
layout_string = None

return layout_string

@property
Expand Down Expand Up @@ -3721,7 +3721,7 @@ cdef class ArraySchema(object):
output.write(" ],\n")
output.write(
f" cell_order='{self.cell_order}',\n"
f" tile_order='{self.tile_order}',\n"
f" tile_order={repr(self.tile_order)},\n"
)
output.write(f" capacity={self.capacity},\n")
output.write(f" sparse={self.sparse},\n")
Expand Down Expand Up @@ -4313,13 +4313,13 @@ cdef class Array(object):
:param tiledb.Config config: The TileDB Config with consolidation parameters set
:param key: (default None) encryption key to decrypt an encrypted array
:type key: str or bytes
:param timestamp: (default None) If not None, vacuum the array using the
:param timestamp: (default None) If not None, vacuum the array using the
given tuple(int, int) UNIX seconds range (inclusive)
:type timestamp: tuple (int, int)
:type timestamp: tuple (int, int)
:raises: :py:exc:`tiledb.TileDBError`
Rather than passing the timestamp into this function, it may be set with
the config parameters `"sm.vacuum.timestamp_start"`and
the config parameters `"sm.vacuum.timestamp_start"`and
`"sm.vacuum.timestamp_end"` which takes in a time in UNIX seconds. If both
are set then this function's `timestamp` argument will be used.
Expand Down Expand Up @@ -5558,15 +5558,15 @@ def consolidate(uri, key=None, Config config=None, Ctx ctx=None, timestamp=None)
:param str key: (default None) Key to decrypt array if the array is encrypted
:param tiledb.Config config: The TileDB Config with consolidation parameters set
:param tiledb.Ctx ctx: (default None) The TileDB Context
:param timestamp: (default None) If not None, vacuum the array using the given
:param timestamp: (default None) If not None, vacuum the array using the given
tuple(int, int) UNIX seconds range (inclusive)
:rtype: str or bytes
:return: path (URI) to the consolidated TileDB Array
:raises TypeError: cannot convert path to unicode string
:raises: :py:exc:`tiledb.TileDBError`
Rather than passing the timestamp into this function, it may be set with
the config parameters `"sm.vacuum.timestamp_start"`and
the config parameters `"sm.vacuum.timestamp_start"`and
`"sm.vacuum.timestamp_end"` which takes in a time in UNIX seconds. If both
are set then this function's `timestamp` argument will be used.
Expand All @@ -5582,7 +5582,7 @@ def consolidate(uri, key=None, Config config=None, Ctx ctx=None, timestamp=None)

if not isinstance(timestamp, tuple) and len(timestamp) != 2:
raise TypeError("'timestamp' argument expects tuple(start: int, end: int)")

if timestamp[0] is not None:
config["sm.consolidation.timestamp_start"] = timestamp[0]
if timestamp[1] is not None:
Expand All @@ -5609,7 +5609,7 @@ def consolidate(uri, key=None, Config config=None, Ctx ctx=None, timestamp=None)
key_ptr = <void *> PyBytes_AS_STRING(bkey)
#TODO: unsafe cast here ssize_t -> uint64_t
key_len = <unsigned int> PyBytes_GET_SIZE(bkey)

cdef int rc = TILEDB_OK
with nogil:
rc = tiledb_array_consolidate_with_key(ctx_ptr, uri_ptr, key_type, key_ptr, key_len, config_ptr)
Expand Down Expand Up @@ -6598,15 +6598,15 @@ def vacuum(uri, Config config=None, Ctx ctx=None, timestamp=None):
Defaults to None, inheriting the context parameters.
:param (ctx: tiledb.Ctx, optional): Context. Defaults to
`tiledb.default_ctx()`.
:param (int, int) timestamp: (default None) If not None, vacuum the array
:param (int, int) timestamp: (default None) If not None, vacuum the array
using the given range (inclusive)
:raises TypeError: cannot convert `uri` to unicode string
:raises: :py:exc:`tiledb.TileDBError`
This operation of this function is controlled by
the `"sm.vacuum.mode"` parameter, which accepts the values ``fragments``,
``fragment_meta``, and ``array_meta``. Rather than passing the timestamp
into this function, it may be set by using `"sm.vacuum.timestamp_start"`and
into this function, it may be set by using `"sm.vacuum.timestamp_start"`and
`"sm.vacuum.timestamp_end"` which takes in a time in UNIX seconds. If both
are set then this function's `timestamp` argument will be used.
Expand Down Expand Up @@ -6643,7 +6643,7 @@ def vacuum(uri, Config config=None, Ctx ctx=None, timestamp=None):

if not isinstance(timestamp, tuple) and len(timestamp) != 2:
raise TypeError("'timestamp' argument expects tuple(start: int, end: int)")

if timestamp[0] is not None:
config["sm.vacuum.timestamp_start"] = timestamp[0]
if timestamp[1] is not None:
Expand Down
14 changes: 7 additions & 7 deletions tiledb/tests/test_libtiledb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3582,10 +3582,7 @@ def write_fragments(target_path, dshape, num_writes):
assert frags.to_vacuum_num == 0

conf = tiledb.Config(
{
"sm.consolidation.timestamp_start": 5,
"sm.consolidation.timestamp_end": 9,
}
{"sm.consolidation.timestamp_start": 5, "sm.consolidation.timestamp_end": 9}
)
tiledb.consolidate(path, config=conf)
tiledb.vacuum(path)
Expand Down Expand Up @@ -3788,7 +3785,7 @@ def test_init_config(self):
self.assertEqual(3, init_test_wrapper({"sm.io_concurrency_level": 3}))


class ReprTest(unittest.TestCase):
class ReprTest(DiskTestCase):
def test_attr_repr(self):
attr = tiledb.Attr(name="itsanattr", dtype=np.float64)
self.assertTrue(
Expand All @@ -3802,14 +3799,17 @@ def test_attr_repr(self):
exec("from tiledb import Attr; from numpy import float64", g)
self.assertEqual(eval(repr(attr), g), attr)

def test_arrayschema_repr(self):
def test_arrayschema_repr(self, sparse_cell_order):
filters = tiledb.FilterList([tiledb.ZstdFilter(-1)])
for sparse in [False, True]:
cell_order = sparse_cell_order if sparse else None
domain = tiledb.Domain(
tiledb.Dim(domain=(1, 8), tile=2), tiledb.Dim(domain=(1, 8), tile=2)
)
a1 = tiledb.Attr("val", dtype="f8", filters=filters)
orig_schema = tiledb.ArraySchema(domain=domain, attrs=(a1,), sparse=sparse)
orig_schema = tiledb.ArraySchema(
domain=domain, attrs=(a1,), sparse=sparse, cell_order=cell_order
)

schema_repr = repr(orig_schema)
g = dict()
Expand Down

0 comments on commit 0a150c0

Please sign in to comment.