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
Modularize Quantity helpers, ensuring scipy.special and erfa are loaded on demand #7636
Conversation
Hi there @mhvk 👋 - thanks for the pull request! I'm just a friendly 🤖 that checks for issues related to the changelog and making sure that this pull request is milestoned and labeled correctly. This is mainly intended for the maintainers, so if you are not a maintainer you can ignore this, and a maintainer will let you know if any action is required on your part 😃. Everything looks good from my point of view! 👍 If there are any issues with this message, please report them here. |
|
||
|
||
UFUNC_HELPERS = UfuncHelpers() | ||
UNSUPPORTED_UFUNCS = UFUNC_HELPERS.UNSUPPORTED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This becomes an unnecessary link, but keeping it for backwards compatibility (currently, it is also still being used in helpers
for unsupported numpy ufuncs; can update that to use setting to None
instead if people like this whole PR).
Re: CircleCI -- The error suggests something funky is going on with the cache lock in that CircleCI run. If restarting it makes it go away, I am not sure how to debug it... 🤷♀️ |
This needs a rebase anyway. Let's see if CircleCI fixes itself... |
13dcee0
to
d4971e0
Compare
OK, rebased... Hopefully things will pass now. |
Travis is still running but CircleCI already passed. Not sure what caused the previous failure! |
@mhvk - I've removed myself from the reviewers, as I'm not familiar enough with However, I very much like the general idea of splitting up the helpers and make sure we don't import big things unnecessarily. |
d4971e0
to
b900cfc
Compare
Rebased since erfa had become supported - that is now modularized as well, for those who use units but not coordinates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not an expert on astropy.units but these changes seem worthwhile to me. It's hard to see changes vs code that was moved, so I can't review everything line by line, but I think this is fine.
This so that it will be possible to split up the numpy, scipy, and future erfa parts.
Prepares for auto-loading.
Avoiding auto-load until scipy.special ufuncs are actually used.
6c11ba4
to
830baee
Compare
This PR has two purposes. The main one is to ensure that
scipy.special
is only loaded on demand, so that for a typical situation in whichastropy
is used butscipy.special
is not, the latter does not get imported unless one of its functions are actually applied to aQuantity
. This helps reduce the import time ofastropy.units
quite a bit (see below). The second purpose is to split up the very largequantity_helpers
file into more manageable pieces, by making it a module.Note that as part of this, it is becoming possible to "register" sets of ufuncs with the
units
module without actual loading -I hope to use thisthis is already used here forerfa
, but it could be exposed as well. I've not written any documentation for that yet, as I first want to be sure people agree the structure makes sense (also, it sets the format for the helper functions in stone, which I'm not sure I like).Excerpts from
python -X importtime -c 'import astropy.units
: