streaming icon indicating copy to clipboard operation
streaming copied to clipboard

Use IndexError instead of ValueError in __getitem__

Open keaganlong opened this issue 9 months ago • 1 comments

https://github.com/mosaicml/streaming/blob/0b055ffcbce130ea7c5a99cd35fe2ec7702af4ac/streaming/base/spanner.py#L52

Hello, curious if it might be more customary to use python's IndexError instead of your custom ValueError when an index is out of bounds in __getitem__. One consequence of using the current setup is that you will get a ValueError exception when you use Spanner/LocalDataset/etc as an iterator. Python allows objects with a __getitem__ to be used as an iterator but it expects to catch and stop on IndexError.

keaganlong avatar May 17 '24 22:05 keaganlong