Skip to content

Commit

Permalink
improve exceptions and remove wip code to test the excpetion
Browse files Browse the repository at this point in the history
  • Loading branch information
boeddeker committed Dec 3, 2024
1 parent 073f4c1 commit 1c99a4b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lazy_dataset/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ def from_dataset(
>>> from_dataset(ds)
ListDataset(len=4)
MapDataset(_pickle.loads)
>>> list(ds.items())
"""
try:
Expand Down Expand Up @@ -434,7 +433,10 @@ def copy(self, freeze: bool = False) -> 'Dataset':
Returns:
A copy of this dataset
"""
raise NotImplementedError
raise NotImplementedError(
f'copy is not implemented for {self.__class__}.\n'
f'self: \n{repr(self)}'
)

def __iter__(self, with_key=False):
if with_key:
Expand Down Expand Up @@ -2706,8 +2708,8 @@ def __iter__(self, with_key=False):
if with_key:
try:
self.keys()
except AssertionError:
raise _ItemsNotDefined(self.__class__.__name__) from None
except AssertionError as e:
raise _ItemsNotDefined(self.__class__.__name__) from e

for input_dataset in self.input_datasets:
if with_key:
Expand Down Expand Up @@ -2996,6 +2998,7 @@ def __init__(self, *input_datasets):
]
raise AssertionError(
f'Expect that all input_datasets have the same keys. '
f'Missing: {lengths} of {len(keys)}\n'
f'Missing keys: '
f'{missing_keys}\n{self.input_datasets}'
)
Expand Down

0 comments on commit 1c99a4b

Please sign in to comment.