Python: Add support for handling numpy vectors and JIT compilation with Numba (Closes #34)#57
Python: Add support for handling numpy vectors and JIT compilation with Numba (Closes #34)#57
Conversation
|
An unfortunate effect of wrapping in this way is that the docstrings are hidden by the wrapper, so e.g. help(psy.GetRelHumFromVapPres) gives "Help on DUFunc in module numba.npyufunc.dufunc object...". There may be a way of fix this, I don't know. |
That's right -- it looks like this will be a limitation so will should probably ask people to just consult the online API -- not great but given the other options this seems reasonable. |
|
@C-H-Simpson how did you handle return type for the Calc functions (e.g. |
|
@dmey The Calc... functions can't be straightforwardly vectorized because they return a tuple. So I would recommend just not vectorizing them. Or rather, they are already vectorized because they are calling vectorized functions. |
|
@C-H-Simpson thanks -- this makes perfect sense! I will just need to check a few more things/tests so I will need a bit longer before we can release a new version -- hopefully will not be too long though! |
Splits CI jobs into 1-2: Python (with/without Numba); 3: C#; 4: R
|
@didierthevenard this PR is now ready to be merged in -- all tests pass. Please review when you have a moment and let me know for any issue. |
didierthevenard
left a comment
There was a problem hiding this comment.
A few comments added to the proposed changes. No issue with the code itself, it's mostly that new code that has been added (around the use of numba and vectorization) needs to have explaining comments.
👍. Please see now. |
didierthevenard
left a comment
There was a problem hiding this comment.
Thanks for the added comments. I fixed one typo and added a general comment about the last section in the code (the entire chunk that deals with Numba) - feel free to change if you can think of a better wording. Also wondering about the usefulness of the last line in the code.
…s/psychrolib into dmey/numba-support
Thanks -- looks good. Unused var removed in af64406. |
This PR adds the following improvements:
Support for handling numpy vectors as inputs/outputs and greater run time performance using Numba: when Numba is found, all functions are compiled using the Numba just in time (JIT) compiler. Note that there is a small overhead the first time the code is run due to the JIT.
CI: jobs are now split into 1-2: Python (with/without Numba); 3: C#; 4: R
README: content and style.