-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Simplify and future-proof numba import in spa.py #1944
Conversation
To-do: make the same change to |
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 all for simplifying things!
LGTM
@@ -21,23 +21,15 @@ def nocompile(*args, **kwargs): | |||
|
|||
if os.getenv('PVLIB_USE_NUMBA', '0') != '0': |
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.
if os.getenv('PVLIB_USE_NUMBA', '0') != '0': | |
if os.getenv('PVLIB_USE_NUMBA') is not None: |
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 think this change would require some corresponding changes in the part of solarposition.py
that controls how spa.py
is imported (by setting this environment variable to '0'
or '1'
), so I'm inclined to leave this as-is for now. It will be addressed someday with #1060.
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 didn't realize that it could be defined as zero (I just assumed it would be undefined). Fine with me to just leave it.
jcompile = nocompile | ||
USE_NUMBA = False | ||
jcompile = jit | ||
USE_NUMBA = True | ||
else: | ||
jcompile = nocompile | ||
USE_NUMBA = False |
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.
Is there a reason for inconsistent usage of upper vs. lower case, e.g., USE_NUMBA
vs. has_numba
?
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.
The reason I see is is that USE_NUMBA
is a module-level variable used inside a function far away from where it is defined while has_numba
is used once in the same scope immediately after its definition. But of course it's just style :)
Thanks @kandersolar for your continuous commitment to keeping pvlib in good shape! |
[ ] Closes #xxxxdocs/sphinx/source/reference
for API changes.docs/sphinx/source/whatsnew
for all changes. Includes link to the GitHub Issue with:issue:`num`
or this Pull Request with:pull:`num`
. Includes contributor name and/or GitHub username (link with:ghuser:`user`
).remote-data
) and Milestone are assigned to the Pull Request and linked Issue.spa.py
currently inspects numba's version string to determine whether it meets the required minimum of 0.17.0:pvlib-python/pvlib/spa.py
Lines 23 to 40 in 1601760
However, the way it performs the check isn't quite correct. Consider what will happen when
numba.__version__
eventually ticks over from0.x.y
to1.0.0
. That code on line 32 will compareint("1" + "0")
with 17 and incorrectly decide that the installed version of numba isn't new enough.Rather than fix the version check, I think it makes sense to just remove that check in
spa.py
altogether in favor of specifying the minimum in setup.py as usual. Even that is probably unnecessarily cautious; numba 0.17.0 is ancient and I think it would be safe to assume that any version of numba that pvlib might encounter today would be much more recent than that, but no harm in setting the minimum anyway.