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
{{ message }}
This repository has been archived by the owner on Feb 17, 2023. It is now read-only.
>>> import biggus
>>> import numpy as np
>>> a = np.arange(5)
>>> b = biggus.NumpyArrayAdapter(a)
>>> c = b[((1,),)]
>>> c.ndarray()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../biggus/_init.py", line 1455, in ndarray
array = self._apply_keys()
File ".../biggus/_init.py", line 1525, in _apply_keys
array = self.concrete.__getitem__(keys)
IndexError: unsupported iterator index
This is the root of a hard-to-track-down bug in Iris, so it would be useful if an error was returned when the array was first indexed.
The text was updated successfully, but these errors were encountered:
Interestingly, for a numpy array, the following access is fine:
a[[[1]]]
but not for a biggus NumpyArrayAdapter:
>>> b[[[1]]]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../biggus/_init.py", line 516, in __getitem__
indexed_array = self._getitem_full_keys(keys)
File ".../biggus/_init.py", line 1444, in _getitem_full_keys
result_key = self._cleanup_new_key(new_key, size, axis)
File ".../biggus/_init.py", line 1358, in _cleanup_new_key
raise IndexError(msg)
IndexError: index [1] is out of bounds for axis 0 with size 5
And the following is fine for numpy:
a[[1]]
and biggus only fails at the call to b.ndarray:
>>> b[[1]]
<NumpyArrayAdapter shape=(1) dtype=dtype('int64')>
>>> b[[1]].ndarray()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File ".../biggus/_init.py", line 1455, in ndarray
array = self._apply_keys()
File ".../biggus/_init.py", line 1525, in _apply_keys
array = self.concrete.__getitem__(keys)
IndexError: unsupported iterator index
The initial issue is due to a numpy bug which is fixed in the latest version. Of the other two cases, the second (a[[1]]) is due to the same bug, while the first (a[[[1]]]) appears to be due to the fact that biggus expects arguments to __getitem__ to only be nested at most twice (e.g. 1, (1,) and ((1,),) are fine but (((1,),),) isn't), whereas numpy allows indefinite nesting
This is the root of a hard-to-track-down bug in Iris, so it would be useful if an error was returned when the array was first indexed.
The text was updated successfully, but these errors were encountered: