Skip to content
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

DeprecationWarning #486

Closed
reza-ghazi opened this issue Nov 24, 2020 · 6 comments
Closed

DeprecationWarning #486

reza-ghazi opened this issue Nov 24, 2020 · 6 comments

Comments

@reza-ghazi
Copy link

Good morning Brandon,

I ran the meridian_transit() function today, and I got the following Warning due to Deprecation Warning. That shows you should update the codes.

:7: DeprecationWarning: In future, it will be an error for 'np.bool_' scalars to be interpreted as an index
print([almanac.MERIDIAN_TRANSITS[yi] for yi in y])

On the other hand, the recent version of Skyfiled is 1.33, but I didn't see any changelog on the website regarding this version.

Best regards,

@brandon-rhodes
Copy link
Member

:7: DeprecationWarning: In future, it will be an error for 'np.bool_' scalars to be interpreted as an index

Well, how annoying. Using Booleans as indexes is so useful!

I suppose that because of this unwelcome change in NumPy, that all the search routines will have to coerce their output values to something like int8 in the case that they detect their object function has been returning Boolean values.

Thanks for letting me know.

The lack of a changelog entry must be because I forgot to push the docs? It was a quick release to fix a bug, so I might have skipped a few steps. Later this week I'm planning a more casual release, and hopefully the docs will catch up at that point.

@reza-ghazi
Copy link
Author

Thank's a lot.

@brandon-rhodes
Copy link
Member

I have committed a possible fix. To try it out, run:

pip install https://github.com/skyfielders/python-skyfield/archive/master.zip

— and then see if the deprecation warning goes away.

@JoshPaterson
Copy link
Contributor

I've been looking into alternatives to boolean indexing since it's used quite often in keplerlib.py and elementslib.py. Did either of you find any documentation that gives more information about this? When I go to the reference documentation for the current numpy version (1.19), it still discusses boolean indexing and doesn't mention any deprecation.

@brandon-rhodes
Copy link
Member

@JoshPaterson — You might be talking about a different technique: the use of an array of Booleans as long as the array being indexed? That will always be supported and is indeed a backbone of NumPy and libraries that rely on it, like Pandas. The deprecated use, by contrast, is the use of single ("scalar" in the deprecation warning) Booleans to select element 0 or element 1 out of an array. Try this:

import numpy as np

a = ['Zero', 'One']
y = np.array([True, False, False, True])
for yi in y:
    a[yi]
    break

When run with python -Wd, I get:

/home/brandon/skyfield/tmp1.py:8: DeprecationWarning: In future, it will be an error for 'np.bool_' scalars to be interpreted as an index
  a[yi]

@JoshPaterson
Copy link
Contributor

Yes, that is the source of the confusion! Thanks for explaining that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants