Skip to content

Commit 5824126

Browse files
authored
Use Temporary Directory in Docs Example For Dim Labels (#1815)
* When running tests locally, the example array gets created but does not get deleted. This results in subsequent test runs erroring out because it tries to create the array again, but it already exists.
1 parent 047470f commit 5824126

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

tiledb/libtiledb.pyx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,22 +1512,22 @@ cdef class Array(object):
15121512
... },
15131513
... }
15141514
>>> schema = tiledb.ArraySchema(domain=dom, attrs=(att,), dim_labels=dim_labels)
1515-
>>> uri = "label_index_example"
1516-
>>> tiledb.Array.create(uri, schema)
1517-
>>>
1518-
>>> a1_data = np.reshape(np.arange(1, 13), (4, 3))
1519-
>>> l1_data = np.arange(4, 0, -1)
1520-
>>> l2_data = np.arange(-1, 2)
1521-
>>> l3_data = np.linspace(0, 1.0, 3)
1522-
>>>
1523-
>>> with tiledb.open(uri, "w") as A:
1524-
... A[:] = {"a1": a1_data, "l1": l1_data, "l2": l2_data, "l3": l3_data}
1525-
>>>
1526-
>>> with tiledb.open(uri, "r") as A:
1527-
... A.label_index(["l1"])[3:4]
1528-
... A.label_index(["l1", "l3"])[2, 0.5:1.0]
1529-
... A.label_index(["l2"])[:, -1:0]
1530-
... A.label_index(["l3"])[:, 0.5:1.0]
1515+
>>> with tempfile.TemporaryDirectory() as tmp:
1516+
... tiledb.Array.create(tmp, schema)
1517+
...
1518+
... a1_data = np.reshape(np.arange(1, 13), (4, 3))
1519+
... l1_data = np.arange(4, 0, -1)
1520+
... l2_data = np.arange(-1, 2)
1521+
... l3_data = np.linspace(0, 1.0, 3)
1522+
...
1523+
... with tiledb.open(tmp, "w") as A:
1524+
... A[:] = {"a1": a1_data, "l1": l1_data, "l2": l2_data, "l3": l3_data}
1525+
...
1526+
... with tiledb.open(tmp, "r") as A:
1527+
... A.label_index(["l1"])[3:4]
1528+
... A.label_index(["l1", "l3"])[2, 0.5:1.0]
1529+
... A.label_index(["l2"])[:, -1:0]
1530+
... A.label_index(["l3"])[:, 0.5:1.0]
15311531
OrderedDict([('l1', array([4, 3])), ('a1', array([[1, 2, 3],
15321532
[4, 5, 6]]))])
15331533
OrderedDict([('l3', array([0.5, 1. ])), ('l1', array([2])), ('a1', array([[8, 9]]))])

0 commit comments

Comments
 (0)