Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addition of
numba
JIT'ing to a number of different functions.JITKW
is a constant passed to each@jit
decorator to easily enable/disable the compilation.Several functions also have a parallel
kwarg
to turn it on and off. I've tested a number of functions withparallel=True
, and many of them will crash due to what I believe is accessing mutable objects in a shared memory space. I've added a comment these.I've also found that several functions run faster without parallelization. I've also added a comment to note these.
In order to add numba acceleration to the
kb2d
function, I've had to remove all objects from the JIT'ed code. This includes thescipy.cKDTree
object, which is instead evaluated prior to being passed into the compiled function. While this increases memory use, the computation time is decreased by a factor of >100, so the trade-off is worth it for most problems. Because of this significant change, I've created a new functionkb2d_jit
that is accelerated, and left thekb2d
function as it was. Reimplementation of the k-d tree to allow numba compilation, would reduce the memory usage, but some language features used byscipy.KDTree
aren't currently supported so it would require significant rework.There's also an immense amount of reformatting, and a lot of unnecessary white space deletion. This is done by an auto-formatting tool,
autopep8
, to make the code conform to PEP 8 standards.