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 }}
Repository navigation
numpy TypeError on coordinate transform (TypeError: For this input type lists must contain either int or Ellipsis) #7051
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
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
It's a Numpy 1.14 issue, since it worked with the previous versions (I just upgraded to Numpy 1.14 in my conda py2 env and now I get the error). It should work as before with unicode_literals since the string contains only ascii characters.
The core question is: are we satisfied just saying astropy is "not compatible" with 1.14.0 and requires 1.14.1? It's pretty clear this is a straight-up bug in numpy (c.f. numpy/numpy#10369 / numpy/numpy#10369numpy/numpy#10371), so saying we aren't going to address it is fairly reasonable, IMHO.
The alternative would probably require adjusting the einsum call to do whatever set of transposes/etc are necessary to replicate the einsum. That would have both performance and readability implications that I am not too comfortable with.
So with that in mind I think we should not make a change, and close this issue once 1.14.1 is out (and we are sure it's working). Anyone disagree?
If we do go that route, though, we may want to hold off on the astropy 3.0 release until 1.14.1 is out... @mhvk, do you have any idea whether "end of Jan" is likely to be acheived or if we should have a backup in case not?
Scratch that - I realize the fix is pretty trivial (should have read #7051 (comment) more carefully) - set the optimize keyword explicitly to False only for numpy 1.14.0... See #7105 . So I take back all of #7051 (comment) and instead would say just merging #7105 is the best solution...
@eteq - I'm in favour of having the fix for now, as the numpy milestoning is a little bit confusing as the fix upstream is milestoned to 1.15. We can always remove the workaround if the upstream fix comes out before astropy 3.0
@pythonastroM31 - this is not related to this bug -- are you sure you are using astropy version >= 2.0? (the radial_velocity was only introduced in 2.0). If so, please open a new issue and give more details about versions, etc.
@mhvk -- first of all, thank you so much. Now I have upgraded the astropy-2.0.3; again the same issue raised when I run the same code in the terminal. I am looking for conversion of phase-space coordinates from the galacto-centric frame of reference, and for calculating the values of radial, angular and azimuthal velocity from given ra, dec, d_gc etc. of CSV file data.
Activity
pllim commentedon Jan 8, 2018
FWIW, I don't see any error using Python 3 and Astropy dev. Can you update Python and/or Astropy?
mhvk commentedon Jan 8, 2018
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 numpy/numpy#10343, since I can get rid of it by passing on
optimize=False.I labelled it
upstream-fix requiredsince the underlying problem is numpy, though if need be we probably could have a work-around.pllim commentedon Jan 9, 2018
Huh... Incidentally there is a
numpy-devfailure at https://travis-ci.org/astropy/astropy/jobs/326547832 that also mentioned "einsum". Is that related?mzechmeister commentedon Jan 11, 2018
I have this problem when I try get to run this http://docs.astropy.org/en/stable/time/#barycentric-and-heliocentric-light-travel-time-corrections.
I traced it back to
unicode_literalsused inastropy/coordinates/builtin_frames/utils.py. Becausegives the error. Without
unicode_literalsit runs. I figured out that immediately in the callnp.einsum'...i,...i'is converted tou'...i,...i'. Maybe related to this https://lists.gt.net/python/dev/1292881.saimn commentedon Jan 11, 2018
It's a Numpy 1.14 issue, since it worked with the previous versions (I just upgraded to Numpy 1.14 in my conda py2 env and now I get the error). It should work as before with unicode_literals since the string contains only ascii characters.
EDIT: see numpy/numpy#10369
jobovy commentedon Jan 12, 2018
I'm getting this error using the astropy implementation of (ra,dec) -> (l,b) coordinate transformations
https://travis-ci.org/jobovy/galpy/jobs/328214749
Only my Python2 tests fail, Python3 all pass.
mhvk commentedon Jan 12, 2018
@jobovy - This indeed looks like the same bug, at least if you are also using numpy 1.14.
jobovy commentedon Jan 12, 2018
This is a travis build, using whatever numpy
conda install numpycurrently gives (can't go back and check!), but I assume this is numpy 1.14.6 remaining items
mhvk commentedon Jan 15, 2018
@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...
Temporarily switch to numpy v1.13 because of astropy/astropy#7051; do…
eteq commentedon Jan 21, 2018
The core question is: are we satisfied just saying astropy is "not compatible" with 1.14.0 and requires 1.14.1? It's pretty clear this is a straight-up bug in numpy (c.f. numpy/numpy#10369 / numpy/numpy#10369 numpy/numpy#10371), so saying we aren't going to address it is fairly reasonable, IMHO.
The alternative would probably require adjusting the
einsumcall to do whatever set of transposes/etc are necessary to replicate theeinsum. That would have both performance and readability implications that I am not too comfortable with.So with that in mind I think we should not make a change, and close this issue once 1.14.1 is out (and we are sure it's working). Anyone disagree?
If we do go that route, though, we may want to hold off on the astropy 3.0 release until 1.14.1 is out... @mhvk, do you have any idea whether "end of Jan" is likely to be acheived or if we should have a backup in case not?
eteq commentedon Jan 21, 2018
Scratch that - I realize the fix is pretty trivial (should have read #7051 (comment) more carefully) - set the
optimizekeyword explicitly to False only for numpy 1.14.0... See #7105 . So I take back all of #7051 (comment) and instead would say just merging #7105 is the best solution...bsipocz commentedon Jan 21, 2018
@eteq - I'm in favour of having the fix for now, as the numpy milestoning is a little bit confusing as the fix upstream is milestoned to 1.15. We can always remove the workaround if the upstream fix comes out before astropy 3.0
rkpradhan commentedon Jan 21, 2018
Can you help me? @jobovy
mhvk commentedon Jan 21, 2018
@pythonastroM31 - this is not related to this bug -- are you sure you are using astropy version >= 2.0? (the
radial_velocitywas only introduced in 2.0). If so, please open a new issue and give more details about versions, etc.rkpradhan commentedon Jan 21, 2018
@mhvk -- first of all, thank you so much. Now I have upgraded the astropy-2.0.3; again the same issue raised when I run the same code in the terminal. I am looking for conversion of phase-space coordinates from the galacto-centric frame of reference, and for calculating the values of radial, angular and azimuthal velocity from given ra, dec, d_gc etc. of CSV file data.
adrn commentedon Jan 21, 2018
@pythonastroM31 Your question is not related to this issue. Please raise your question in a new issue, or in the astropy slack channel
rkpradhan commentedon Jan 21, 2018
@adrn Okay, my problem is related to typeError in running the program. I just run in the terminal; code like that...
Can you help me with this problem? How can we resolve this?
mhvk commentedon Jan 21, 2018
@pythonastroM31 - please open a new issue - it is not helpful to us to have comments about unrelated problems in this thread.
Detect einsum bug and turn-off astropy unit conversions in that case …