-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add 'ulab' as an extmod; enable on nrf and most samd51 boards #2583
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
My test program prints the peak audio frequency detected:
|
@caternuson ya might find this useful! |
oooooooooo FFT. nice! |
As requested by @dhalbert this is now enabled for all nrf boards and most samd51 boards. |
Here's the spectrograph demo adapted for ulab: |
Nice job on this! I'd love to see the |
tested mic waterfall - works great! will be interesting to see what other projects we can do :) |
updated faster non-scrolling version : code.txt |
I think this is ready for review, including the "our style" docs even if they are mostly extremely short blurbs rather than full reference documentation. There are some hard faults that I have encountered (wrong argument types not caught, I think) but we can pursue those by PR'ing upstream. The one I know offhand I verified exists in micropython, so it's not introduced by us. I also have some ideas that might make the differences (vs micropython-ulab) we have to carry smaller, but I didn't put them into practice yet. (and they're just ideas, might not pan out) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for adding these docs! Very helpful. One typo and a question about the extra bits on array. Otherwise it looks great!
I noticed that ulab float arrays are actually using |
oh I was mistaken -- arrays use doubles on the unix port, but floats on real devices, so that's no concern |
It depends on your platform and the implementation, whether you have floats or a doubles: https://github.com/v923z/micropython-ulab/blob/936bb3bae55dfdc81d1c8d9580905ae0ac760a44/code/ndarray.h#L22 , also in micropython#4380 (comment) |
It is probably nit-picking, but the real part of the FFT is not what you want. This is why I implemented |
@v923z A philosophical difference between micropython and circuitpython is, how much like standard python and well known python packages should the product strive to be. Circuitpython has made a lot of decisions to be more like python. Our default is to try to make our reimplementations of standard Python features be subsets of the "standards". We think that this is helpful, because it removes friction when going between circuitpython and desktop python. Another adafruit software product is blinka, which lets ARM SBCs or even PCs with particular USB devices use packages implemented for CircuitPython to interface to hardware, another good reason to remove friction going between Python and CircuitPython. @tannewt could make a much more principled and impassioned explanation of this position than me. 😃 That means that, if we say "we are bringing in a numpy-like math library", we will probably make some changes to make it more like numpy. We might even name it numpy. But, whatever exactly these changes are, if they are things you don't want we will do our best to make sure it's circuitpython maintainers who bear the costs, not you. I think there's still the possibility to say: we're bringing in ulab, which is numpy inspired but not a numpy subset. In that case, we'd want our software to behave as much like upstream ulab. Personally, I think that trying to be a proper numpy subset is trouble. FFT is key functionality for us, but it becomes necessary to implement a proper complex type in ulab to match the numpy interface. As you outline, this has a serious negative effect on code size since aside from anything else, for binary operations we need new cases where complex can work with any of float, int8, uint18, int16, or uint16. |
@jepler do you feel this is ready for a first merge? I think it just needs a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One trivial style thing, but I realize now there are still some things under discussion.
Well, it is easier said than done. And I believe these costs can be avoided. As far as I see from your and Scott's comments, the problem is that Do you want to implement sub-modules as is done in Are special exceptions (e.g. in I can't stress enough that if you elect to maintain your own modifications in I strongly believe that the best course of action is to maintain a single code base, and make it such that you can simply plug the code into either Keeping these comments in mind, I wanted to ask, what you need to make the library compatible with
Bringing in complexes opens up a nasty can of worms: at that moment, you might want to be able call |
Hi @v923z, thanks for I like the idea of moving the non-numpy compatible stuff into a separate module. It also looks like you want to have different size tiers of the library. I wonder if having many non-numpy modules would be a better structure for ulab. That way compatibility is available at the module level and is checked at runtime on import rather than function use. |
Thanks for the invitation!
I think it is a necessity, actually. Some platforms are rather small, while others have a generous amount of flash. I have been thinking of merging the 1dim, and master branches, and let the user decide at compile time, what they want. That should not be too much work, and we could then have a single code base.
I am not entirely sure I see what you mean... |
I think we talked about this on Discord but I'll recap here. The idea is to split ulab into smaller modules than what numpy has so that functionality can be enabled at a more granular level. Enabling and disabling on module boundaries means that errors will be generated when an unsupported module is imported rather than when an unsupported function is called in the middle of code. |
Yeah, the discussion on discord was clear, but it is great that you summarised it here, for the benefit of the others. |
Needs merge from upstream due to translation changes. |
@tannewt
I might be able to push the changes to github tonight, but it might be tomorrow. |
I choose to believe these authors knew what they were doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me! Thank you for the hard work!
@tannewt I updated the locales only in this last update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me! Thank you!
huzzah! |
@tannewt do we need to merge this somewhere besides master to ensure it goes in 5.1.0? |
There's no 5.1.x branch yet, so no problem just merging to master. |
No description provided.