You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Slicing of G3Timetreams in python differs a bit from np.array slicing.
In python you are allowed to slice lists with
stop
andstep
being larger than the size of the array:However G3Timestreams produce fatal errors when trying the same thing:
It would be great if we could change G3Timestream so slicing behavior is consistent with numpy arrays.
The text was updated successfully, but these errors were encountered: