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
I've encountered a strange invalid slice error with a beam list. I'm not sure I can reproduce a MWE, but I'm reporting this because I'm sure we'll eventually find a cause.
>>>np.nanmedian(spec)
---------------------------------------------------------------------------ValueErrorTraceback (mostrecentcalllast)
/scratch/local/42000842/ipykernel_40160/2236068460.pyin<module>---->1np.nanmedian(spec)
<__array_function__internals>innanmedian(*args, **kwargs)
/blue/adamginsburg/adamginsburg/repos/astropy/astropy/units/quantity.pyin__array_function__(self, function, types, args, kwargs)
1673# implementation.1674iffunctioninSUBCLASS_SAFE_FUNCTIONS:
->1675returnsuper().__array_function__(function, types, args, kwargs)
16761677eliffunctioninFUNCTION_HELPERS:
~/.local/lib/python3.9/site-packages/numpy/lib/nanfunctions.pyinnanmedian(a, axis, out, overwrite_input, keepdims)
1117returnnp.nanmean(a, axis, out=out, keepdims=keepdims)
1118->1119r, k=function_base._ureduce(a, func=_nanmedian, axis=axis, out=out,
1120overwrite_input=overwrite_input)
1121ifkeepdimsandkeepdimsisnotnp._NoValue:
~/.local/lib/python3.9/site-packages/numpy/lib/function_base.pyin_ureduce(a, func, **kwargs)
3562keepdim= (1,) *a.ndim3563->3564r=func(a, **kwargs)
3565returnr, keepdim3566~/.local/lib/python3.9/site-packages/numpy/lib/nanfunctions.pyin_nanmedian(a, axis, out, overwrite_input)
985part=a.ravel()
986ifoutisNone:
-->987return_nanmedian1d(part, overwrite_input)
988else:
989out[...] =_nanmedian1d(part, overwrite_input)
~/.local/lib/python3.9/site-packages/numpy/lib/nanfunctions.pyin_nanmedian1d(arr1d, overwrite_input)
972returnarr1d[-1]
973-->974returnnp.median(arr1d_parsed, overwrite_input=overwrite_input)
975976<__array_function__internals>inmedian(*args, **kwargs)
/blue/adamginsburg/adamginsburg/repos/astropy/astropy/units/quantity.pyin__array_function__(self, function, types, args, kwargs)
1673# implementation.1674iffunctioninSUBCLASS_SAFE_FUNCTIONS:
->1675returnsuper().__array_function__(function, types, args, kwargs)
16761677eliffunctioninFUNCTION_HELPERS:
~/.local/lib/python3.9/site-packages/numpy/lib/function_base.pyinmedian(a, axis, out, overwrite_input, keepdims)
36533654 """
-> 3655 r, k = _ureduce(a, func=_median, axis=axis, out=out,
3656 overwrite_input=overwrite_input)
3657 if keepdims:
~/.local/lib/python3.9/site-packages/numpy/lib/function_base.py in _ureduce(a, func, **kwargs)
3562 keepdim = (1,) * a.ndim
3563
-> 3564 r = func(a, **kwargs)
3565 return r, keepdim
3566
~/.local/lib/python3.9/site-packages/numpy/lib/function_base.py in _median(a, axis, out, overwrite_input)
3708 if np.issubdtype(a.dtype, np.inexact) and sz > 0:
3709 # warn and return nans like mean would
-> 3710 rout = mean(part[indexer], axis=axis, out=out)
3711 return np.lib.utils._median_nancheck(part, rout, axis, out)
3712 else:
/blue/adamginsburg/adamginsburg/repos/spectral-cube/spectral_cube/lower_dimensional_structures.py in __getitem__(self, key)
1116
1117 def __getitem__(self, key):
-> 1118 new_qty = super(VaryingResolutionOneDSpectrum, self).__getitem__(key)
1119
1120 # use the goodbeams_mask setter here because it checks size
/blue/adamginsburg/adamginsburg/repos/spectral-cube/spectral_cube/lower_dimensional_structures.py in __getitem__(self, key, **kwargs)
751 # keeping it here.
752 try:
--> 753 kwargs['beams'] = self.beams[key]
754 except (AttributeError, TypeError):
755 pass
/blue/adamginsburg/adamginsburg/repos/radio-beam/radio_beam/multiple_beams.py in __getitem__(self, view)
147 meta=[x for ii,x in zip(view, self.meta) if ii])
148 else:
--> 149 raise ValueError("Invalid slice")
150151def__array_finalize__(self, obj):
ValueError: Invalidslice
I've encountered a strange invalid slice error with a beam list. I'm not sure I can reproduce a MWE, but I'm reporting this because I'm sure we'll eventually find a cause.
Debug work:
so the problem is that we're passing a list of slices instead of a single slice here.
A workaround is to do something like:
in the
lower_dimensional_structures
call, but this is fundamentally abeams
issue because we're usingisinstance
here: https://github.com/radio-astro-tools/radio-beam/blob/master/radio_beam/multiple_beams.py#L129-L149The text was updated successfully, but these errors were encountered: