astropy: numpy TypeError on coordinate transform (TypeError: For this input type lists must contain either int or Ellipsis)
A numpy TypeError is raised when doing a coordinate transformation on an array. This appeared with numpy v 1.14.0. The following code gives the error, copied below. python version is 2.7 astropy version is 2.0.3
import numpy as np
import astropy
from astropy import coordinates, units
print "numpy v", np.__version__
print "astropy v", astropy.__version__
c = coordinates.SkyCoord(ra=[10, 11, 12, 13]*units.degree, dec=[41, -5, 42, 0]*units.degree)
print c.transform_to('galactic')
numpy v 1.14.0
astropy v 2.0.3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/ben/.virtualenvs/test/lib/python2.7/site-packages/astropy/coordinates/sky_coordinate.py", line 482, in transform_to
new_coord = trans(self.frame, generic_frame)
File "/Users/ben/.virtualenvs/test/lib/python2.7/site-packages/astropy/coordinates/transformations.py", line 1314, in __call__
curr_coord = t(curr_coord, curr_toframe)
File "/Users/ben/.virtualenvs/test/lib/python2.7/site-packages/astropy/coordinates/transformations.py", line 1232, in __call__
newrep = self._apply_transform(fromcoord, M, None)
File "/Users/ben/.virtualenvs/test/lib/python2.7/site-packages/astropy/coordinates/transformations.py", line 1005, in _apply_transform
rep = rep.transform(matrix)
File "/Users/ben/.virtualenvs/test/lib/python2.7/site-packages/astropy/coordinates/representation.py", line 1115, in transform
newxyz = np.einsum('...ij,j...->i...', matrix, oldxyz.value)
File "/Users/ben/.virtualenvs/test/lib/python2.7/site-packages/numpy/core/einsumfunc.py", line 1087, in einsum
einsum_call=True)
File "/Users/ben/.virtualenvs/test/lib/python2.7/site-packages/numpy/core/einsumfunc.py", line 688, in einsum_path
input_subscripts, output_subscript, operands = _parse_einsum_input(operands)
File "/Users/ben/.virtualenvs/test/lib/python2.7/site-packages/numpy/core/einsumfunc.py", line 432, in _parse_einsum_input
raise TypeError("For this input type lists must contain "
TypeError: For this input type lists must contain either int or Ellipsis
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 23 (19 by maintainers)
Commits related to this issue
- Fixed bug in rotate_vector_collection due to upstream bug in Numpy v1.14. See https://github.com/astropy/astropy/issues/7051. Calling np.einsum with optimize=False has virtually no impact on performan... — committed to aphearin/halotools by deleted user 6 years ago
- Temporarily switch to numpy v1.13 because of astropy/astropy#7051; don't run conda in quiet mode — committed to jobovy/galpy by jobovy 6 years ago
- Detect einsum bug and turn-off astropy unit conversions in that case (see astropy/astropy#7051) — committed to jobovy/galpy by jobovy 6 years ago
@pythonastroM31 - please open a new issue - it is not helpful to us to have comments about unrelated problems in this thread.
@bsipocz - not quite: on python3, I have a problem with
The fact that we don’t use this internally doesn’t mean it cannot get done…
p.s. The reason we didn’t catch it is that our
numpy-dev
test is done with python3, and there the same path is not taken.I cannot directly reproduce the error on python3 (astropy 2.0.3, numpy-dev), but can reproduce a later part:
Or more directly proving this is an upstream problem:
It is almost certainly related to https://github.com/numpy/numpy/issues/10343, since I can get rid of it by passing on
optimize=False
.I labelled it
upstream-fix required
since the underlying problem is numpy, though if need be we probably could have a work-around.