-
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
Changes from all commits
4943d17
a10ebd1
1aaf2da
54d2b86
df450c7
dfd383b
5dac262
ef68240
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,23 +21,15 @@ def nocompile(*args, **kwargs): | |
|
||
if os.getenv('PVLIB_USE_NUMBA', '0') != '0': | ||
try: | ||
from numba import jit, __version__ | ||
from numba import jit | ||
except ImportError: | ||
warnings.warn('Could not import numba, falling back to numpy ' + | ||
'calculation') | ||
jcompile = nocompile | ||
USE_NUMBA = False | ||
else: | ||
major, minor = __version__.split('.')[:2] | ||
if int(major + minor) >= 17: | ||
# need at least numba >= 0.17.0 | ||
jcompile = jit | ||
USE_NUMBA = True | ||
else: | ||
warnings.warn('Numba version must be >= 0.17.0, falling back to ' + | ||
'numpy') | ||
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 commentThe 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., There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reason I see is is that |
||
|
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.
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 howspa.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.