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

G3Timestream Slicing #45

Closed
jlashner opened this issue Dec 1, 2020 · 0 comments
Closed

G3Timestream Slicing #45

jlashner opened this issue Dec 1, 2020 · 0 comments

Comments

@jlashner
Copy link
Contributor

jlashner commented Dec 1, 2020

Slicing of G3Timetreams in python differs a bit from np.array slicing.

In python you are allowed to slice lists with stop and step being larger than the size of the array:

>>> import numpy as np
>>> x = np.arange(5.)
>>> x[:10]
array([0., 1., 2., 3., 4.])
>>> x[::10]
array([0.])

However G3Timestreams produce fatal errors when trying the same thing:

>>> from spt3g import core
>>> import numpy as np
>>> x = core.G3Timestream(np.arange(5.))
>>> x[:10]
FATAL (G3Timestream): Stop index 10 out of range (G3Timestream.cxx:822 in G3TimestreamPtr {anonymous}::G3Timestream_getslice(const G3Timestream&, boost::python::slice))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/mnt/so1/shared/software/spt3g_software/200627/build/spt3g/core/timestreamextensions.py", line 13, in G3Timestream_getitem
    it = x._cxxslice(y)
RuntimeError: Stop index 10 out of range (in G3TimestreamPtr {anonymous}::G3Timestream_getslice(const G3Timestream&, boost::python::slice))
>>> x[::10]
FATAL (G3Timestream): Step index 10 out of range (G3Timestream.cxx:824 in G3TimestreamPtr {anonymous}::G3Timestream_getslice(const G3Timestream&, boost::python::slice))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/mnt/so1/shared/software/spt3g_software/200627/build/spt3g/core/timestreamextensions.py", line 13, in G3Timestream_getitem
    it = x._cxxslice(y)
RuntimeError: Step index 10 out of range (in G3TimestreamPtr {anonymous}::G3Timestream_getslice(const G3Timestream&, boost::python::slice))

It would be great if we could change G3Timestream so slicing behavior is consistent with numpy arrays.

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