Skip to content

Commit a1b91e1

Browse files
committed
Correct __getitem__ and subarray methods to respect view_attr for sparse arrays
1 parent eb3ac6d commit a1b91e1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tiledb/sparse_array.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import warnings
12
from collections import OrderedDict
23

34
import numpy as np
@@ -292,6 +293,9 @@ def __getitem__(self, selection):
292293
>>> # A[5.0:579.9]
293294
294295
"""
296+
if self.view_attr:
297+
return self.subarray(selection)
298+
295299
result = self.subarray(selection)
296300
for i in range(self.schema.nattr):
297301
attr = self.schema.attr(i)
@@ -506,7 +510,11 @@ def subarray(self, selection, coords=True, attrs=None, cond=None, order=None):
506510

507511
attr_names = list()
508512

509-
if attrs is None:
513+
if self.view_attr is not None:
514+
if attrs is not None:
515+
warnings.warn("view_attr is set, ignoring attrs parameter", UserWarning)
516+
attr_names.extend(self.view_attr)
517+
elif attrs is None:
510518
attr_names.extend(
511519
self.schema.attr(i)._internal_name for i in range(self.schema.nattr)
512520
)

0 commit comments

Comments
 (0)