Skip to content

Commit

Permalink
Merge pull request #1022 from activeloopai/fix/2.0/tensor_meta_shapes
Browse files Browse the repository at this point in the history
[small] update scalar test
  • Loading branch information
verbose-void committed Jul 8, 2021
2 parents 75f9aff + 6b5ab3f commit f2652f1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion hub/api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from hub.api.dataset import Dataset
from hub.core.tests.common import parametrize_all_dataset_storages
from hub.tests.common import assert_array_lists_equal
from hub.util.exceptions import TensorDtypeMismatchError
from hub.util.exceptions import TensorDtypeMismatchError, TensorInvalidSampleShapeError
from hub.client.client import HubBackendClient
from hub.client.utils import has_hub_testing_creds

Expand Down Expand Up @@ -239,6 +239,16 @@ def test_scalar_samples(ds: Dataset):

assert tensor.numpy(aslist=True) == expected.tolist()

assert tensor.shape == (11,)

# len(shape) for a scalar is `()`. len(shape) for [1] is `(1,)`
with pytest.raises(TensorInvalidSampleShapeError):
tensor.append([1])

# len(shape) for a scalar is `()`. len(shape) for [1, 2] is `(2,)`
with pytest.raises(TensorInvalidSampleShapeError):
tensor.append([1, 2])


@parametrize_all_dataset_storages
def test_sequence_samples(ds: Dataset):
Expand Down

0 comments on commit f2652f1

Please sign in to comment.