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

Minor bug in grain.python.RangeDataSource.__getitem__() #400

Open
albanie opened this issue Apr 25, 2024 · 0 comments
Open

Minor bug in grain.python.RangeDataSource.__getitem__() #400

albanie opened this issue Apr 25, 2024 · 0 comments

Comments

@albanie
Copy link

albanie commented Apr 25, 2024

There may be a bug in grain.python.RangeDataSource.__getitem__().

Minimal code to reproduce:

import grain.python as pygrain 
x = pygrain.RangeDataSource(start=1,stop=10,step=2)
print(list(x))

Outputs:

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
[<ipython-input-5-88dd2177f112>](https://localhost:8080/#) in <cell line: 3>()
      1 import grain.python as pygrain
      2 x = pygrain.RangeDataSource(start=1,stop=10,step=2)
----> 3 print(list(x))

[/usr/local/lib/python3.10/dist-packages/grain/_src/python/data_sources.py](https://localhost:8080/#) in __getitem__(self, record_key)
     92   def __getitem__(self, record_key: SupportsIndex) -> int:
     93     record_key = record_key.__index__()
---> 94     assert record_key >= 0 and record_key < self._len
     95     return self._start + record_key * self._step
     96 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant