as title. I am a newer of micropython, and I want to use scipy and numpy in pyboard. what can I do then?
thanks in advance.
How to use scipy in micropython
Re: How to use scipy in micropython
Hi and welcome,
there is not much you can do as their is and will never be a port of numpy and scipy to Micropython. These are very huge libraries, which will never fit on a microcontroller, both in terms of memory and in terms of complexity.
The thing you can do, try to isolate what you want to do and see if this would be feasible to run on a microcontroller (e. g. does it use other libraries written in other languages like Fortran, does it use large amounts of memory?, will it perform reasonable fast enough on a 32 bit machine at around 80 MHz, etc.). If yes, use the numpy and scipy source code to understand the particular implementation, strip it down to the bare minimum and give it a test.
there is not much you can do as their is and will never be a port of numpy and scipy to Micropython. These are very huge libraries, which will never fit on a microcontroller, both in terms of memory and in terms of complexity.
The thing you can do, try to isolate what you want to do and see if this would be feasible to run on a microcontroller (e. g. does it use other libraries written in other languages like Fortran, does it use large amounts of memory?, will it perform reasonable fast enough on a 32 bit machine at around 80 MHz, etc.). If yes, use the numpy and scipy source code to understand the particular implementation, strip it down to the bare minimum and give it a test.

 Posts: 9
 Joined: Tue Jul 11, 2017 9:35 am
Re: How to use scipy in micropython
Thanks for your reply. Now I have to code my own array/fft/fir and so on. They are the keys of my job.
Thanks again.
Thanks again.
Re: How to use scipy in micropython
You don't really "have" to, MicroPython is a mature project within its niche, and other people coded at least some of those things already  search the forum. Of course, what they did might not satisfy you, and you indeed may need to implement it in right way for yourself.
 pythoncoder
 Posts: 2899
 Joined: Fri Jul 18, 2014 8:01 am
 Location: UK
 Contact:
Re: How to use scipy in micropython
MicropPython supports the array module. You might also like to look at my attempts at FFT https://github.com/peterhinch/micropythonfourier.git and FIR https://github.com/peterhinch/micropythonfilters.git. They don't aim to compete with the big libraries  their aim is fast execution on the Pyboard.mhwang1973 wrote:Thanks for your reply. Now I have to code my own array/fft/fir and so on. They are the keys of my job.
Thanks again.
Peter Hinch
Re: How to use scipy in micropython
FFT is so important for signal processing and many other usages, also ESP32 has ADC and DAC.
It will be very nice if FFT is built into MicroPython.
It will be very nice if FFT is built into MicroPython.
 pythoncoder
 Posts: 2899
 Joined: Fri Jul 18, 2014 8:01 am
 Location: UK
 Contact:
ESP32 ADC's and DFT
From initial tests the ESP32 ADC and DAC aren't as accurate as those on the Pyboard.
As a general point re FFT, a DFT routine in Python will be portable and examples abound on the web. To sate the obvious it may not be fast enough for realtime DSP even if you use the high performance code emitters. The solution is to use assembler. My Arm Thumb attempt is fairly fast, but could undoubtedly be optimised further, perhaps by up to a factor of two.
I doubt that the MicroPython maintainers will write an optimised DFT in assembler for each target arch. It's up to us, the users, to do this; it's more gruntwork than rocket science Likewise FIR and IIR filters benefit hugely from asm.
I have no particular ambition to use an ESP32 for DSP.
As a general point re FFT, a DFT routine in Python will be portable and examples abound on the web. To sate the obvious it may not be fast enough for realtime DSP even if you use the high performance code emitters. The solution is to use assembler. My Arm Thumb attempt is fairly fast, but could undoubtedly be optimised further, perhaps by up to a factor of two.
I doubt that the MicroPython maintainers will write an optimised DFT in assembler for each target arch. It's up to us, the users, to do this; it's more gruntwork than rocket science Likewise FIR and IIR filters benefit hugely from asm.
I have no particular ambition to use an ESP32 for DSP.
Peter Hinch