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

Fix ds.summary #2714

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
16 changes: 8 additions & 8 deletions deeplake/api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,24 +204,24 @@ def test_stringify(memory_ds, capsys):
ds.summary()
assert (
capsys.readouterr().out
== "Dataset(path='mem://hub_pytest/test_api/test_stringify', tensors=['image'])\n\n tensor htype shape dtype compression\n ------- ------- ------- ------- ------- \n image generic (4, 4) None None \n"
== "Dataset(path='mem://hub_pytest/test_api/test_stringify', tensors=['image'])\n\n tensor htype shape dtype compression\n ------- ------- ------- ------- ------- \n image generic (4, 4) float64 None \n"
)

ds[1:2].summary()
assert (
capsys.readouterr().out
== "Dataset(path='mem://hub_pytest/test_api/test_stringify', index=Index([slice(1, 2, None)]), tensors=['image'])\n\n tensor htype shape dtype compression\n ------- ------- ------- ------- ------- \n image generic (1, 4) None None \n"
== "Dataset(path='mem://hub_pytest/test_api/test_stringify', index=Index([slice(1, 2, None)]), tensors=['image'])\n\n tensor htype shape dtype compression\n ------- ------- ------- ------- ------- \n image generic (1, 4) float64 None \n"
)

ds.image.summary()
assert (
capsys.readouterr().out
== "Tensor(key='image')\n\n htype shape dtype compression\n ------- ------- ------- ------- \n generic (4, 4) None None \n"
== "Tensor(key='image')\n\n htype shape dtype compression\n ------- ------- ------- ------- \n generic (4, 4) float64 None \n"
)
ds[1:2].image.summary()
assert (
capsys.readouterr().out
== "Tensor(key='image', index=Index([slice(1, 2, None)]))\n\n htype shape dtype compression\n ------- ------- ------- ------- \n generic (1, 4) None None \n"
== "Tensor(key='image', index=Index([slice(1, 2, None)]))\n\n htype shape dtype compression\n ------- ------- ------- ------- \n generic (1, 4) float64 None \n"
)


Expand All @@ -233,11 +233,11 @@ def test_summary(memory_ds):

assert (
summary_dataset(ds)
== "\n tensor htype shape dtype compression\n ------- ------- ------- ------- ------- \n abc generic (4, 4) None None \n images image (0,) int32 jpeg "
== "\n tensor htype shape dtype compression\n ------- ------- ------- ------- ------- \n abc generic (4, 4) float64 None \n images image (0,) int32 jpeg "
)
assert (
summary_tensor(ds.abc)
== "\n htype shape dtype compression\n ------- ------- ------- ------- \n generic (4, 4) None None "
== "\n htype shape dtype compression\n ------- ------- ------- ------- \n generic (4, 4) float64 None "
)
assert (
summary_tensor(ds.images)
Expand All @@ -259,12 +259,12 @@ def test_view_summary(memory_ds, capsys):
captured = capsys.readouterr().out
assert (
captured
== f"{str(ds[2500:])}\n\n tensor htype shape dtype compression\n ------- ------- ------- ------- ------- \n abc generic (10000, 5, 5:10, 3) None None \n"
== f"{str(ds[2500:])}\n\n tensor htype shape dtype compression\n ------- ------- ------- ------- ------- \n abc generic (10000, 5, 5:10, 3) float64 None \n"
)

assert (
summary_dataset(ds[:7500])
== "\n tensor htype shape dtype compression\n ------- ------- ------- ------- ------- \n abc generic (7500, 5:10, 5, 3) None None "
== "\n tensor htype shape dtype compression\n ------- ------- ------- ------- ------- \n abc generic (7500, 5:10, 5, 3) float64 None "
)


Expand Down
4 changes: 2 additions & 2 deletions deeplake/util/pretty_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def summary_tensor(tensor):
if tensor_compression == None:
tensor_compression = "None"

if tensor.dtype == None:
if tensor.dtype is None:
tensor_dtype = "None"
else:
tensor_dtype = tensor.dtype.name
Expand Down Expand Up @@ -93,7 +93,7 @@ def summary_dataset(dataset):
if tensor_compression == None:
tensor_compression = "None"

if tensor_object.dtype == None:
if tensor_object.dtype is None:
tensor_dtype = "None"
else:
tensor_dtype = tensor_object.dtype.name
Expand Down