Skip to content

Commit

Permalink
Merge pull request #2851 from activeloopai/min_max_calculation
Browse files Browse the repository at this point in the history
Min max calculation
  • Loading branch information
activesoull committed May 10, 2024
2 parents 2f22e5f + 072dc21 commit 7114eb9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions deeplake/core/dataset/dataset.py
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

0 comments on commit 7114eb9

Please sign in to comment.