Skip to content

Commit 0a150c0

Browse files
committed
Parametrize arrayschema repr test
1 parent 93e6e99 commit 0a150c0

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

tiledb/libtiledb.pyx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3293,8 +3293,8 @@ cdef class ArraySchema(object):
32933293
cdef tiledb_layout_t cell_layout = TILEDB_ROW_MAJOR
32943294
cdef tiledb_layout_t tile_layout = TILEDB_ROW_MAJOR
32953295
try:
3296-
cell_layout = _tiledb_layout(cell_order)
3297-
tile_layout = _tiledb_layout(tile_order)
3296+
cell_layout = _tiledb_layout(cell_order if cell_order else 'row-major')
3297+
tile_layout = _tiledb_layout(tile_order if tile_order else 'row-major')
32983298
check_error(ctx, tiledb_array_schema_set_cell_order(ctx.ptr, schema_ptr, cell_layout))
32993299
check_error(ctx, tiledb_array_schema_set_tile_order(ctx.ptr, schema_ptr, tile_layout))
33003300
except:
@@ -3513,11 +3513,11 @@ cdef class ArraySchema(object):
35133513
"""
35143514
cdef tiledb_layout_t order = TILEDB_UNORDERED
35153515
self._tile_order(&order)
3516-
3516+
35173517
layout_string = _tiledb_layout_string(order)
35183518
if self.cell_order == "hilbert":
35193519
layout_string = None
3520-
3520+
35213521
return layout_string
35223522

35233523
@property
@@ -3721,7 +3721,7 @@ cdef class ArraySchema(object):
37213721
output.write(" ],\n")
37223722
output.write(
37233723
f" cell_order='{self.cell_order}',\n"
3724-
f" tile_order='{self.tile_order}',\n"
3724+
f" tile_order={repr(self.tile_order)},\n"
37253725
)
37263726
output.write(f" capacity={self.capacity},\n")
37273727
output.write(f" sparse={self.sparse},\n")
@@ -4313,13 +4313,13 @@ cdef class Array(object):
43134313
:param tiledb.Config config: The TileDB Config with consolidation parameters set
43144314
:param key: (default None) encryption key to decrypt an encrypted array
43154315
:type key: str or bytes
4316-
:param timestamp: (default None) If not None, vacuum the array using the
4316+
:param timestamp: (default None) If not None, vacuum the array using the
43174317
given tuple(int, int) UNIX seconds range (inclusive)
4318-
:type timestamp: tuple (int, int)
4318+
:type timestamp: tuple (int, int)
43194319
:raises: :py:exc:`tiledb.TileDBError`
43204320
43214321
Rather than passing the timestamp into this function, it may be set with
4322-
the config parameters `"sm.vacuum.timestamp_start"`and
4322+
the config parameters `"sm.vacuum.timestamp_start"`and
43234323
`"sm.vacuum.timestamp_end"` which takes in a time in UNIX seconds. If both
43244324
are set then this function's `timestamp` argument will be used.
43254325
@@ -5558,15 +5558,15 @@ def consolidate(uri, key=None, Config config=None, Ctx ctx=None, timestamp=None)
55585558
:param str key: (default None) Key to decrypt array if the array is encrypted
55595559
:param tiledb.Config config: The TileDB Config with consolidation parameters set
55605560
:param tiledb.Ctx ctx: (default None) The TileDB Context
5561-
:param timestamp: (default None) If not None, vacuum the array using the given
5561+
:param timestamp: (default None) If not None, vacuum the array using the given
55625562
tuple(int, int) UNIX seconds range (inclusive)
55635563
:rtype: str or bytes
55645564
:return: path (URI) to the consolidated TileDB Array
55655565
:raises TypeError: cannot convert path to unicode string
55665566
:raises: :py:exc:`tiledb.TileDBError`
55675567
55685568
Rather than passing the timestamp into this function, it may be set with
5569-
the config parameters `"sm.vacuum.timestamp_start"`and
5569+
the config parameters `"sm.vacuum.timestamp_start"`and
55705570
`"sm.vacuum.timestamp_end"` which takes in a time in UNIX seconds. If both
55715571
are set then this function's `timestamp` argument will be used.
55725572
@@ -5582,7 +5582,7 @@ def consolidate(uri, key=None, Config config=None, Ctx ctx=None, timestamp=None)
55825582

55835583
if not isinstance(timestamp, tuple) and len(timestamp) != 2:
55845584
raise TypeError("'timestamp' argument expects tuple(start: int, end: int)")
5585-
5585+
55865586
if timestamp[0] is not None:
55875587
config["sm.consolidation.timestamp_start"] = timestamp[0]
55885588
if timestamp[1] is not None:
@@ -5609,7 +5609,7 @@ def consolidate(uri, key=None, Config config=None, Ctx ctx=None, timestamp=None)
56095609
key_ptr = <void *> PyBytes_AS_STRING(bkey)
56105610
#TODO: unsafe cast here ssize_t -> uint64_t
56115611
key_len = <unsigned int> PyBytes_GET_SIZE(bkey)
5612-
5612+
56135613
cdef int rc = TILEDB_OK
56145614
with nogil:
56155615
rc = tiledb_array_consolidate_with_key(ctx_ptr, uri_ptr, key_type, key_ptr, key_len, config_ptr)
@@ -6598,15 +6598,15 @@ def vacuum(uri, Config config=None, Ctx ctx=None, timestamp=None):
65986598
Defaults to None, inheriting the context parameters.
65996599
:param (ctx: tiledb.Ctx, optional): Context. Defaults to
66006600
`tiledb.default_ctx()`.
6601-
:param (int, int) timestamp: (default None) If not None, vacuum the array
6601+
:param (int, int) timestamp: (default None) If not None, vacuum the array
66026602
using the given range (inclusive)
66036603
:raises TypeError: cannot convert `uri` to unicode string
66046604
:raises: :py:exc:`tiledb.TileDBError`
66056605
66066606
This operation of this function is controlled by
66076607
the `"sm.vacuum.mode"` parameter, which accepts the values ``fragments``,
66086608
``fragment_meta``, and ``array_meta``. Rather than passing the timestamp
6609-
into this function, it may be set by using `"sm.vacuum.timestamp_start"`and
6609+
into this function, it may be set by using `"sm.vacuum.timestamp_start"`and
66106610
`"sm.vacuum.timestamp_end"` which takes in a time in UNIX seconds. If both
66116611
are set then this function's `timestamp` argument will be used.
66126612
@@ -6643,7 +6643,7 @@ def vacuum(uri, Config config=None, Ctx ctx=None, timestamp=None):
66436643

66446644
if not isinstance(timestamp, tuple) and len(timestamp) != 2:
66456645
raise TypeError("'timestamp' argument expects tuple(start: int, end: int)")
6646-
6646+
66476647
if timestamp[0] is not None:
66486648
config["sm.vacuum.timestamp_start"] = timestamp[0]
66496649
if timestamp[1] is not None:

tiledb/tests/test_libtiledb.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3582,10 +3582,7 @@ def write_fragments(target_path, dshape, num_writes):
35823582
assert frags.to_vacuum_num == 0
35833583

35843584
conf = tiledb.Config(
3585-
{
3586-
"sm.consolidation.timestamp_start": 5,
3587-
"sm.consolidation.timestamp_end": 9,
3588-
}
3585+
{"sm.consolidation.timestamp_start": 5, "sm.consolidation.timestamp_end": 9}
35893586
)
35903587
tiledb.consolidate(path, config=conf)
35913588
tiledb.vacuum(path)
@@ -3788,7 +3785,7 @@ def test_init_config(self):
37883785
self.assertEqual(3, init_test_wrapper({"sm.io_concurrency_level": 3}))
37893786

37903787

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

3805-
def test_arrayschema_repr(self):
3802+
def test_arrayschema_repr(self, sparse_cell_order):
38063803
filters = tiledb.FilterList([tiledb.ZstdFilter(-1)])
38073804
for sparse in [False, True]:
3805+
cell_order = sparse_cell_order if sparse else None
38083806
domain = tiledb.Domain(
38093807
tiledb.Dim(domain=(1, 8), tile=2), tiledb.Dim(domain=(1, 8), tile=2)
38103808
)
38113809
a1 = tiledb.Attr("val", dtype="f8", filters=filters)
3812-
orig_schema = tiledb.ArraySchema(domain=domain, attrs=(a1,), sparse=sparse)
3810+
orig_schema = tiledb.ArraySchema(
3811+
domain=domain, attrs=(a1,), sparse=sparse, cell_order=cell_order
3812+
)
38133813

38143814
schema_repr = repr(orig_schema)
38153815
g = dict()

0 commit comments

Comments
 (0)