numba / numba-scipy

numba_scipy extends Numba to make it aware of SciPy
https://numba-scipy.readthedocs.io/en/latest/
BSD 2-Clause "Simplified" License
250 stars 33 forks source link

Are you interested in a Minpack wrapper? #63

Open Nicholaswogan opened 3 years ago

Nicholaswogan commented 3 years ago

@stuartarchibald I made a wrapper for Minpack, which can be called from within numba jit compiled functions: https://github.com/Nicholaswogan/NumbaMinpack . scipy.optimize.root uses minpack. The wrapper is a bit hacky, but it has worked well for me.

Wondering if you would be interested in implementing NumbaMinpack into numba-scipy. If so, I can put together a pull request, which would add a folder numba-scipy/optimize .

esc commented 3 years ago

@Nicholaswogan thank you for bringing this to our attention. One of the advantages of the numba-scipy project, is that it is easy to install across OSX/Linux/Windows b/c it has minimal dependencies and ships zero binary code. So the gfortran dependency and the limit to OSX and Linux may be a bit too much for numba-scipy?

However, it would be very, very nice to be able to use scipy.optimize from within @njit decorated functions. So maybe a tighter integration of NumbaMinpack and numba-scipy may be an option? For example, mentioning the project in the numba-scipy README and maybe making it easier to install/use them together? Personally, I would even be in favour of potentially adding the project to the numba organization on Github. This would perhaps give it more exposure and also help to attract additional interested parties and also give it somewhat of an "official" stamp. What do you think about this? What do @stuartarchibald @seibert @sklam think about this suggestion?

Lastly -- and this is probably a bit of a longshot -- how about looking into using LFortran as a compiler? It also uses LLVM (maybe even llvmlite, if I am not mistaken) and there do appear to be some interesting routes in that direction.

Nicholaswogan commented 3 years ago

@esc That makes sense. The gfortran dependency wouldn't be cross platform, so it makes sense it wouldn't be the best for numba-scipy. I looked at the LFortran compiler. It doesn't look quite ready for compiling Minpack. But maybe a year or so down the road LFortran could be perfect for this kind of thing.

For example, mentioning the project in the numba-scipy README and maybe making it easier to install/use them together? Personally, I would even be in favour of potentially adding the project to the numba organization on Github. This would perhaps give it more exposure and also help to attract additional interested parties and also give it somewhat of an "official" stamp. What do you think about this?

I'm very open to any of these ideas! More exposure would certainly lead to good ideas from the numba community for improving the wrapper. Let me know what I can do to help.

esc commented 3 years ago

@esc That makes sense. The gfortran dependency wouldn't be cross platform, so it makes sense it wouldn't be the best for numba-scipy. I looked at the LFortran compiler. It doesn't look quite ready for compiling Minpack. But maybe a year or so down the road LFortran could be perfect for this kind of thing.

For example, mentioning the project in the numba-scipy README and maybe making it easier to install/use them together? Personally, I would even be in favour of potentially adding the project to the numba organization on Github. This would perhaps give it more exposure and also help to attract additional interested parties and also give it somewhat of an "official" stamp. What do you think about this?

I'm very open to any of these ideas! More exposure would certainly lead to good ideas from the numba community for improving the wrapper. Let me know what I can do to help.

I think the first step, which is also easy to get in, would be to mention NumbaMinpack in the numba-scipy documentation somewhere, either README or Sphinx or both. I'd be very open to accepting such a PR outright. This is actionable.

Pulling the repo in the Numba organization is a much bigger step, that the current maintainers will need to agree on and getting that consensus may take some time. This is in my court and "in progress", I would say.

stuartarchibald commented 3 years ago

@Nicholaswogan thanks for raising this (and writing the library!), really great to see minpack usable from Numba.

Thanks for providing guidance here @esc, suggest that the various items mentioned above are discussed at the next public meeting (they are every Tuesday!) to gather some community feedback in relation to this sort of use case.

Nicholaswogan commented 3 years ago

@stuartarchibald Sounds great! I'll be at the public meeting this coming Tuesday.

Nicholaswogan commented 3 years ago

@stuartarchibald let me know when the build template we talked about in this meeting is put together, and I'll try it on Minpack.

stuartarchibald commented 3 years ago

@stuartarchibald let me know when the build template we talked about in this meeting is put together, and I'll try it on Minpack.

Great, thanks, will let you know!

Nicholaswogan commented 2 years ago

@stuartarchibald I also put together a similar wrapper to LSODA, for solving ordinary differential equations: https://github.com/Nicholaswogan/NumbaLSODA . I used CMake with setup.py to install so its more platform independent, but I don't think it would work on Windows right out of the box.