Skip to content

Commit c9b7381

Browse files
committed
Fix tests
1 parent 7b6ba15 commit c9b7381

File tree

4 files changed

+49
-44
lines changed

4 files changed

+49
-44
lines changed

tiledb/libtiledb.pyx

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,21 +1514,21 @@ cdef class Array(object):
15141514
... A[:] = {"a1": a1_data, "l1": l1_data, "l2": l2_data, "l3": l3_data}
15151515
...
15161516
... with tiledb.open(tmp, "r") as A:
1517-
... A.label_index(["l1"])[3:4]
1518-
... A.label_index(["l1", "l3"])[2, 0.5:1.0]
1519-
... A.label_index(["l2"])[:, -1:0]
1520-
... A.label_index(["l3"])[:, 0.5:1.0]
1521-
OrderedDict([('l1', array([4, 3])), ('a1', array([[1, 2, 3],
1522-
[4, 5, 6]]))])
1523-
OrderedDict([('l3', array([0.5, 1. ])), ('l1', array([2])), ('a1', array([[8, 9]]))])
1524-
OrderedDict([('l2', array([-1, 0])), ('a1', array([[ 1, 2],
1525-
[ 4, 5],
1526-
[ 7, 8],
1527-
[10, 11]]))])
1528-
OrderedDict([('l3', array([0.5, 1. ])), ('a1', array([[ 2, 3],
1529-
[ 5, 6],
1530-
[ 8, 9],
1531-
[11, 12]]))])
1517+
... A.label_index(["l1"])[3:4] # doctest: +ELLIPSIS
1518+
... A.label_index(["l1", "l3"])[2, 0.5:1.0] # doctest: +ELLIPSIS
1519+
... A.label_index(["l2"])[:, -1:0] # doctest: +ELLIPSIS
1520+
... A.label_index(["l3"])[:, 0.5:1.0] # doctest: +ELLIPSIS
1521+
OrderedDict(...'l1'... array([4, 3])..., ...'a1'... array([[1, 2, 3],
1522+
[4, 5, 6]])...)
1523+
OrderedDict(...'l3'... array([0.5, 1. ])..., ...'l1'... array([2])..., ...'a1'... array([[8, 9]])...)
1524+
OrderedDict(...'l2'... array([-1, 0])..., ...'a1'... array([[ 1, 2],
1525+
[ 4, 5],
1526+
[ 7, 8],
1527+
[10, 11]])...)
1528+
OrderedDict(...'l3'... array([0.5, 1. ])..., ...'a1'... array([[ 2, 3],
1529+
[ 5, 6],
1530+
[ 8, 9],
1531+
[11, 12]])...)
15321532
15331533
:param labels: List of labels to use when querying. Can only use at most one
15341534
label per dimension.
@@ -1572,19 +1572,23 @@ cdef class Array(object):
15721572
>>>
15731573
>>> with tempfile.TemporaryDirectory() as tmp:
15741574
... A = tiledb.from_numpy(tmp, np.eye(4) * [1,2,3,4])
1575-
... A.multi_index[1]
1576-
... A.multi_index[1,1]
1575+
... A.multi_index[1] # doctest: +ELLIPSIS
1576+
... A.multi_index[1,1] # doctest: +ELLIPSIS
15771577
... # return row 0 and 2
1578-
... A.multi_index[[0,2]]
1578+
... A.multi_index[[0,2]] # doctest: +ELLIPSIS
15791579
... # return rows 0 and 2 intersecting column 2
1580-
... A.multi_index[[0,2], 2]
1580+
... A.multi_index[[0,2], 2] # doctest: +ELLIPSIS
15811581
... # return rows 0:2 intersecting columns 0:2
1582-
... A.multi_index[slice(0,2), slice(0,2)]
1583-
OrderedDict([('', array([[0., 2., 0., 0.]]))])
1584-
OrderedDict([('', array([[2.]]))])
1585-
OrderedDict([('', array([[1., 0., 0., 0.], [0., 0., 3., 0.]]))])
1586-
OrderedDict([('', array([[0.], [3.]]))])
1587-
OrderedDict([('', array([[1., 0., 0.], [0., 2., 0.], [0., 0., 3.]]))])
1582+
... A.multi_index[slice(0,2), slice(0,2)] # doctest: +ELLIPSIS
1583+
OrderedDict(...''... array([[0., 2., 0., 0.]])...)
1584+
OrderedDict(...''... array([[2.]])...)
1585+
OrderedDict(...''... array([[1., 0., 0., 0.],
1586+
[0., 0., 3., 0.]])...)
1587+
OrderedDict(...''... array([[0.],
1588+
[3.]])...)
1589+
OrderedDict(...''... array([[1., 0., 0.],
1590+
[0., 2., 0.],
1591+
[0., 0., 3.]])...)
15881592
15891593
"""
15901594
# Delayed to avoid circular import
@@ -2161,8 +2165,8 @@ cdef class DenseArrayImpl(Array):
21612165
... A[0:10] = {"a1": np.zeros((10)), "a2": np.ones((10))}
21622166
... with tiledb.DenseArray(tmp + "/array", mode='r') as A:
21632167
... # Access specific attributes individually.
2164-
... A.query(attrs=("a1",))[0:5]
2165-
OrderedDict([('a1', array([0, 0, 0, 0, 0]))])
2168+
... A.query(attrs=("a1",))[0:5] # doctest: +ELLIPSIS
2169+
OrderedDict(...'a1'... array([0, 0, 0, 0, 0])...)
21662170
21672171
"""
21682172
if not self.isopen or self.mode != 'r':
@@ -2216,8 +2220,8 @@ cdef class DenseArrayImpl(Array):
22162220
... A[0:10] = {"a1": np.zeros((10)), "a2": np.ones((10))}
22172221
... with tiledb.DenseArray(tmp + "/array", mode='r') as A:
22182222
... # A[0:5], attribute a1, row-major without coordinates
2219-
... A.subarray((slice(0, 5),), attrs=("a1",), coords=False, order='C')
2220-
OrderedDict([('a1', array([0, 0, 0, 0, 0]))])
2223+
... A.subarray((slice(0, 5),), attrs=("a1",), coords=False, order='C') # doctest: +ELLIPSIS
2224+
OrderedDict(...'a1'... array([0, 0, 0, 0, 0])...)
22212225
22222226
"""
22232227
from .subarray import Subarray
@@ -3154,11 +3158,10 @@ cdef class SparseArrayImpl(Array):
31543158
... "a2": np.array([3, 4])}
31553159
... with tiledb.SparseArray(tmp + "/array", mode='r') as A:
31563160
... # Return an OrderedDict with values and coordinates
3157-
... A[0:3, 0:10]
3161+
... A[0:3, 0:10] # doctest: +ELLIPSIS
31583162
... # Return just the "x" coordinates values
3159-
... A[0:3, 0:10]["x"]
3160-
OrderedDict([('a1', array([1, 2])), ('a2', array([3, 4])), ('y', array([0, 2], dtype=uint64)), ('x', array([0, 3], dtype=uint64))])
3161-
array([0, 3], dtype=uint64)
3163+
... A[0:3, 0:10]["x"] # doctest: +ELLIPSIS
3164+
OrderedDict(...'a1'... array([1, 2])..., ...'a2'... array([3, 4])..., ...'y'... array([0, 2], dtype=uint64)..., ...'x'... array([0, 3], dtype=uint64)...)
31623165
31633166
With a floating-point array domain, index bounds are inclusive, e.g.:
31643167
@@ -3231,8 +3234,8 @@ cdef class SparseArrayImpl(Array):
32313234
... A[I, J] = {"a1": np.array([1, 2]),
32323235
... "a2": np.array([3, 4])}
32333236
... with tiledb.SparseArray(tmp + "/array", mode='r') as A:
3234-
... A.query(attrs=("a1",), coords=False, order='G')[0:3, 0:10]
3235-
OrderedDict([('a1', array([1, 2]))])
3237+
... A.query(attrs=("a1",), coords=False, order='G')[0:3, 0:10] # doctest: +ELLIPSIS
3238+
OrderedDict(...'a1'... array([1, 2])...)
32363239
32373240
"""
32383241
if not self.isopen or self.mode not in ('r', 'd'):
@@ -3341,8 +3344,8 @@ cdef class SparseArrayImpl(Array):
33413344
... "a2": np.array([3, 4])}
33423345
... with tiledb.SparseArray(tmp + "/array", mode='r') as A:
33433346
... # A[0:3, 0:10], attribute a1, row-major without coordinates
3344-
... A.subarray((slice(0, 3), slice(0, 10)), attrs=("a1",), coords=False, order='G')
3345-
OrderedDict([('a1', array([1, 2]))])
3347+
... A.subarray((slice(0, 3), slice(0, 10)), attrs=("a1",), coords=False, order='G') # doctest: +ELLIPSIS
3348+
OrderedDict(...'a1'... array([1, 2])...)
33463349
33473350
"""
33483351
from .subarray import Subarray

tiledb/tests/test_compat.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_compat_tiledb_py_0_5_anon_attr_dense(self):
4646

4747
path = self.path("tiledb_py_0_6_anon_attr")
4848
with tarfile.open(fileobj=io.BytesIO(base64.b64decode(array_tgz))) as tf:
49-
tf.extractall(path)
49+
tf.extractall(path, filter="fully_trusted")
5050

5151
with tiledb.open(path) as A:
5252
self.assertEqual(A.schema.attr(0).name, "")
@@ -85,7 +85,7 @@ def test_compat_py_0_5_anon_attr_sparse(self):
8585

8686
path = self.path("test_tiledb_py_0_5_anon_attr_sparse")
8787
with tarfile.open(fileobj=io.BytesIO(base64.b64decode(test_array))) as tf:
88-
tf.extractall(path)
88+
tf.extractall(path, filter="fully_trusted")
8989
with tiledb.open(path) as A:
9090
assert_array_equal(A[:][""], np.array([1.0, 2.0, 5.0]))
9191

@@ -108,7 +108,7 @@ def test_tiledb_py_0_6_anon_attr(self):
108108

109109
path = self.path("0_6_anon_sparse")
110110
with tarfile.open(fileobj=io.BytesIO(base64.b64decode(tgz_sparse))) as tf:
111-
tf.extractall(path)
111+
tf.extractall(path, filter="fully_trusted")
112112
with tiledb.open(path) as A:
113113
if A.schema.sparse:
114114
assert_array_equal(A[:][""], np.array([1.0, 2.0, 5.0]))
@@ -158,7 +158,7 @@ def test_tiledb_py_0_6_anon_attr(self):
158158

159159
path = self.path("0_6_anon_dense")
160160
with tarfile.open(fileobj=io.BytesIO(base64.b64decode(tgz_dense))) as tf:
161-
tf.extractall(path)
161+
tf.extractall(path, filter="fully_trusted")
162162
with tiledb.open(path) as A:
163163
self.assertEqual(A.schema.attr(0).name, "")
164164
self.assertEqual(A.schema.attr(0)._internal_name, "__attr")

tiledb/tests/test_fork_ctx.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def test_no_warning_fork_without_ctx():
3636
@pytest.mark.skipif(
3737
sys.platform == "win32", reason="fork() is not available on Windows"
3838
)
39+
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
3940
def test_warning_fork_with_ctx():
4041
"""Get a warning if we fork after creating a tiledb context."""
4142
_ = tiledb.Ctx()
@@ -50,6 +51,7 @@ def test_warning_fork_with_ctx():
5051
@pytest.mark.skipif(
5152
sys.platform == "win32", reason="fork() is not available on Windows"
5253
)
54+
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
5355
def test_warning_fork_with_default_ctx():
5456
"""Get a warning if we fork after creating a default context."""
5557
_ = tiledb.default_ctx()
@@ -60,8 +62,6 @@ def test_warning_fork_with_default_ctx():
6062
else:
6163
os.wait()
6264

63-
pass
64-
6565

6666
@pytest.mark.skipif(
6767
sys.platform == "win32", reason="fork() is not available on Windows"
@@ -79,6 +79,7 @@ def test_no_warning_multiprocessing_without_ctx():
7979
@pytest.mark.skipif(
8080
sys.platform == "win32", reason="fork() is not available on Windows"
8181
)
82+
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
8283
def test_warning_multiprocessing_with_ctx():
8384
"""Get a warning if we fork after creating a tiledb context."""
8485
_ = tiledb.Ctx()
@@ -92,6 +93,7 @@ def test_warning_multiprocessing_with_ctx():
9293
@pytest.mark.skipif(
9394
sys.platform == "win32", reason="fork() is not available on Windows"
9495
)
96+
@pytest.mark.filterwarnings("ignore::DeprecationWarning")
9597
def test_warning_multiprocessing_with_default_ctx():
9698
"""Get a warning if we fork after creating a default context."""
9799
_ = tiledb.default_ctx()

tiledb/tests/test_libtiledb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def test_upgrade_version(self):
327327
path = self.path("test_upgrade_version")
328328

329329
with tarfile.open(fileobj=io.BytesIO(base64.b64decode(tgz_sparse))) as tf:
330-
tf.extractall(path)
330+
tf.extractall(path, filter="fully_trusted")
331331

332332
with tiledb.open(path) as A:
333333
assert A.schema.version == 5

0 commit comments

Comments
 (0)