Skip to content

Commit

Permalink
fixed max_view
Browse files Browse the repository at this point in the history
  • Loading branch information
activesoull committed Jan 24, 2025
1 parent 5f51c56 commit d7718c0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
27 changes: 27 additions & 0 deletions deeplake/api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
SampleExtendError,
)
from deeplake.util.path import convert_string_to_pathlib_if_needed, verify_dataset_name
from deeplake.tests.common import requires_libdeeplake, disabale_hidden_tensors_config
from deeplake.util.testing import assert_array_equal
from deeplake.util.pretty_print import summary_tensor, summary_dataset
from deeplake.util.shape_interval import ShapeInterval
Expand Down Expand Up @@ -2544,6 +2545,32 @@ def test_pickle_bug(local_ds):
)


@requires_libdeeplake
def test_max_view_with_query(local_auth_ds):
import random

with local_auth_ds as ds:
ds.create_tensor(
"label1", htype="generic", dtype=np.int32, **disabale_hidden_tensors_config
)
ds.create_tensor(
"label2", htype="generic", dtype=np.int32, **disabale_hidden_tensors_config
)

for _ in range(1000):
ds.label1.append(int(100 * random.uniform(0.0, 1.0)))

for _ in range(100):
ds.label2.append(int(100 * random.uniform(0.0, 1.0)))

view = local_auth_ds.query("select label1, label2 LIMIT 200")
view_max = view.max_view

labels2 = view_max.label2.numpy(aslist=True)
assert labels2[150] == None
print(labels2, labels2[150])


def test_max_view(memory_ds):
with memory_ds as ds:
ds.create_tensor("abc")
Expand Down
5 changes: 5 additions & 0 deletions deeplake/core/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4928,6 +4928,11 @@ def max_view(self):
(20, 20, 3) [1]
(20, 20, 3) [None]
"""
from deeplake.core.dataset.indra_dataset_view import IndraDatasetView

if isinstance(self, IndraDatasetView):
return self

return self.__class__(
storage=self.storage,
index=self.index,
Expand Down
2 changes: 1 addition & 1 deletion deeplake/core/dataset/indra_dataset_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def __getitem__(
)
else:
raise InvalidKeyTypeError(item)
raise AttributeError("Dataset has no attribute - {item}")
raise AttributeError(f"Dataset has no attribute - {item}")

def __getattr__(self, key):
try:
Expand Down

0 comments on commit d7718c0

Please sign in to comment.