@@ -1491,6 +1491,55 @@ cdef class Array(object):
1491
1491
"""Retrieve data cells with multi-range, domain-inclusive indexing by label.
1492
1492
Returns the cross-product of the ranges.
1493
1493
1494
+ Accepts a scalar, ``slice``, or list of scalars per-label for querying on the
1495
+ corresponding dimensions. For multidimensional arrays querying by labels only on
1496
+ a subset of dimensions, ``:`` should be passed in-place for any labels preceeding
1497
+ custom ranges.
1498
+
1499
+ ** Example **
1500
+
1501
+ >>> import tiledb, numpy as np
1502
+ >>>
1503
+ >>> dim1 = tiledb.Dim("d1", domain=(1, 4))
1504
+ >>> dim2 = tiledb.Dim("d2", domain=(1, 3))
1505
+ >>> dom = tiledb.Domain(dim1, dim2)
1506
+ >>> att = tiledb.Attr("a1", dtype=np.int64)
1507
+ >>> dim_labels = {
1508
+ ... 0: {"l1": dim1.create_label_schema("decreasing", np.int64)},
1509
+ ... 1: {
1510
+ ... "l2": dim2.create_label_schema("increasing", np.int64),
1511
+ ... "l3": dim2.create_label_schema("increasing", np.float64),
1512
+ ... },
1513
+ ... }
1514
+ >>> 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]
1531
+ OrderedDict([('l1', array([4, 3])), ('a1', array([[1, 2, 3],
1532
+ [4, 5, 6]]))])
1533
+ OrderedDict([('l3', array([0.5, 1. ])), ('l1', array([2])), ('a1', array([[8, 9]]))])
1534
+ OrderedDict([('l2', array([-1, 0])), ('a1', array([[ 1, 2],
1535
+ [ 4, 5],
1536
+ [ 7, 8],
1537
+ [10, 11]]))])
1538
+ OrderedDict([('l3', array([0.5, 1. ])), ('a1', array([[ 2, 3],
1539
+ [ 5, 6],
1540
+ [ 8, 9],
1541
+ [11, 12]]))])
1542
+
1494
1543
:param labels: List of labels to use when querying. Can only use at most one
1495
1544
label per dimension.
1496
1545
:param list selection: Per dimension, a scalar, ``slice``, or list of scalars.
0 commit comments