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

Min max calculation #2851

Merged
merged 2 commits into from
May 10, 2024
Merged
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
12 changes: 10 additions & 2 deletions deeplake/core/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,20 @@ def __len__(self, warn: bool = True):
@property
def max_len(self):
"""Return the maximum length of the tensor."""
return max([len(tensor) for tensor in self.tensors.values()])
return (
max([len(tensor) for tensor in self.tensors.values()])
if self.tensors
else 0
)

@property
def min_len(self):
"""Return the minimum length of the tensor."""
return min([len(tensor) for tensor in self.tensors.values()])
return (
min([len(tensor) for tensor in self.tensors.values()])
if self.tensors
else 0
)

def __getstate__(self) -> Dict[str, Any]:
"""Returns a dict that can be pickled and used to restore this dataset.
Expand Down
Loading