Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AL-2350] Indra returns polygons differently than python #2509

Merged
merged 2 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion deeplake/core/dataset/deeplake_query_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
self, aslist=False, *args, **kwargs
) -> Union[np.ndarray, List[np.ndarray]]:
r = self.indra_tensor.numpy(aslist=aslist)
if aslist or isinstance(r, np.ndarray):
if aslist or isinstance(r, (np.ndarray, list)):

Check warning on line 71 in deeplake/core/dataset/deeplake_query_tensor.py

View check run for this annotation

Codecov / codecov/patch

deeplake/core/dataset/deeplake_query_tensor.py#L71

Added line #L71 was not covered by tests
return r
else:
try:
Expand Down
40 changes: 40 additions & 0 deletions deeplake/core/tests/test_deeplake_indra_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from deeplake.cli.auth import logout
from deeplake.core.dataset.deeplake_query_dataset import DeepLakeQueryDataset
import random
import math
import pytest


Expand Down Expand Up @@ -269,6 +270,45 @@
assert deeplake_indra_ds[1].image.numpy()[98].shape == (20, 10, 3)


@requires_libdeeplake
def test_query_tensors_polygon_htype_consistency(local_auth_ds_generator):
ds = local_auth_ds_generator()
with ds:
ds.create_tensor(

Check warning on line 277 in deeplake/core/tests/test_deeplake_indra_dataset.py

View check run for this annotation

Codecov / codecov/patch

deeplake/core/tests/test_deeplake_indra_dataset.py#L275-L277

Added lines #L275 - L277 were not covered by tests
"polygon",
dtype=np.float32,
htype="polygon",
sample_compression=None,
)
ds.create_tensor(

Check warning on line 283 in deeplake/core/tests/test_deeplake_indra_dataset.py

View check run for this annotation

Codecov / codecov/patch

deeplake/core/tests/test_deeplake_indra_dataset.py#L283

Added line #L283 was not covered by tests
"labels",
dtype=np.uint16,
htype="generic",
sample_compression=None,
)
for i in range(10):
polygons = []
for j in range(i):
p = np.ndarray((3 + j, 2))
for k in range(3 + j):
p[k] = [

Check warning on line 294 in deeplake/core/tests/test_deeplake_indra_dataset.py

View check run for this annotation

Codecov / codecov/patch

deeplake/core/tests/test_deeplake_indra_dataset.py#L289-L294

Added lines #L289 - L294 were not covered by tests
200 * (j % 3) + 150 * (math.sin(6.28 * k / (3 + j)) + 1) / 2,
200 * (j / 3) + 150 * (math.cos(6.28 * k / (3 + j)) + 1) / 2,
]
polygons.append(p)
ds.labels.append(i)
ds.polygon.append(polygons)

Check warning on line 300 in deeplake/core/tests/test_deeplake_indra_dataset.py

View check run for this annotation

Codecov / codecov/patch

deeplake/core/tests/test_deeplake_indra_dataset.py#L298-L300

Added lines #L298 - L300 were not covered by tests

view = ds.query("select *, labels+labels as new_tensor")
for i in range(len(ds)):
orig = ds.polygon[i].numpy()
new = view.polygon[i].numpy()

Check warning on line 305 in deeplake/core/tests/test_deeplake_indra_dataset.py

View check run for this annotation

Codecov / codecov/patch

deeplake/core/tests/test_deeplake_indra_dataset.py#L302-L305

Added lines #L302 - L305 were not covered by tests

assert type(orig) == type(new)
for i, j in zip(orig, new):
assert np.all(i == j)

Check warning on line 309 in deeplake/core/tests/test_deeplake_indra_dataset.py

View check run for this annotation

Codecov / codecov/patch

deeplake/core/tests/test_deeplake_indra_dataset.py#L307-L309

Added lines #L307 - L309 were not covered by tests


@requires_libdeeplake
def test_random_split(local_auth_ds_generator):
deeplake_ds = local_auth_ds_generator()
Expand Down
2 changes: 1 addition & 1 deletion deeplake/core/vectorstore/test_deeplake_vectorstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ def assert_updated_vector_store(
("local_auth_ds", None, "vector_store_row_ids", None, None),
("local_auth_ds", None, None, "vector_store_filter_udf", None),
("local_auth_ds", None, None, "vector_store_filters", None),
("local_auth_ds", None, None, None, "vector_store_query"),
("hub_cloud_ds", None, None, None, "vector_store_query"),
],
indirect=True,
)
Expand Down
Loading