icecube / photospline

https://docs.icecube.aq/photospline/v2.0.7/
BSD 2-Clause "Simplified" License
5 stars 12 forks source link

Add support for numpy arrays to `evaluate` function. #34

Closed tomaskontrimas closed 1 year ago

tomaskontrimas commented 1 year ago

In our analysis we are using the photospline package from python to evaluate multiple splines with the same data (~20k points for each evaluation). Because splines are constructed with exactly the same knots, we could reuse centers values by calling the evaluate method. This results in ~50% faster evaluation in comparison to the evaluate_simple method (by not calling searchcenters, which does not seem to have optimised case when knots are distributed in a regular grid). See the screenshot for timings example:

image

The current evaluate implementation https://github.com/icecube/photospline/blob/5ad5d0be526350804fb0e449255cf6589a36bffa/src/python/photosplinemodule.cpp#L534 does not seem to support numpy arrays, but it seems possible to add it based on evaluate_simple implementation: https://github.com/icecube/photospline/blob/5ad5d0be526350804fb0e449255cf6589a36bffa/src/python/photosplinemodule.cpp#L633-L716

@jvansanten , @martwo and I are going to implement this change in a branch, but it would be nice to know first whether it sounds okay or if you have any suggestion.

tomaskontrimas commented 1 year ago

Closed by #35