-
-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Toposlib - creating an ndarray from ragged nested sequences is deprecated #536
Comments
This seems related to #506, I'm not sure if the discussion there is helpful to you or not. |
@JeremyTurpin — An experimental fix for that was made a few weeks ago, and is scheduled to appear in the next version. Could you try installing the most recent development version, and checking whether it fixes the problem?
Thanks! As you'll see from the code, the solution is to make all three (x, y, z) components have the same length, instead of trying to paste together a long x and y array with a single number 0.0 for z. |
@brandon-rhodes Thanks for the tip - installed the latest version from git as you mentioned, and the warning goes away. Thanks for the input! |
Great, I'm glad it worked! I hadn't known the bug was so obvious from a notebook, which could affect lots of users. I'll see about getting a new version out before adding any new features, so it can come out soon. Thanks for the report! |
I've just released 1.36. Let me know if you catch any regressions in the future! |
I revisited some code I had written last year with a fresh python environment (clean Python 3.7 installation, installed all dependencies into a virtualenv), and started getting a very large number of warnings when creating Topos objects.
'env/lib/python3.7/site-packages/skyfield/toposlib.py:21: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray'
The code still functioned, but there were so many warnings that it was hard to see the results in the notebook...I looked at the source, and followed the recommendation in the warning by changing:
self._velocity_au_per_d = ANGVEL * DAY_S * array((-y, x, 0.0))
to
self._velocity_au_per_d = ANGVEL * DAY_S * array((-y, x, 0.0),dtype=object)
in line 19 of toposlib.py.
This got rid of the warning, but it turned out this led to other problems.
When running:
I received the following exception:
Some looking around indicated that the exception is due to the dtype=object modification, and I found an open numpy issue that seems to relate to this issue, as well: numpy/numpy#17837
I have since done the easy thing to get my own code to work again, at the risk of numpy (presumably) changing further and breaking things more in the future, by editing the toposlib.py file again to simply ignore the warnings from that line.
This is a fragile 'fix', but I wanted to check if there was a more robust correction.
I'm using pip versions of numpy and skyfield on python 3.7.6; relevant package versions listed below.
astropy 4.2
Cartopy 0.18.0
matplotlib 3.3.3
numpy 1.19.5
scipy 1.6.0
sgp4 2.15
skyfield 1.35
Thanks for creating and supporting this great library!
The text was updated successfully, but these errors were encountered: