Simple 1D array library for numerical work (think NumPy, but slow)
Just a quick test library I made to add some NumPy features to normal Python lists and make it slightly easier to deal with numeric stuff in Pythonista.
- unary and binary operators (e.g. array([1,2,3]) + array([4, 5, 6]))
- indexing with boolean and integer arrays (e.g. x[x > 10])
- vectorizes the math library (e.g. sin([1, 2, 3]))
- a few NumPy functions like arange, linspace, zeros, etc.
See the main() function at the end of the file for some examples.
Note that all operations will still be slow as everything is done in Python. Also the code hasn't been fully tested, so some things may not work.
If we can tweak the sample plotting code in Pythonista to mimic Matplotlib a bit, then we can probably come up with a usable platform for basic scientific stuff.
Nice idea ... maybe you can persuade me to make more functions
Remark, I do not know how important the last parameter retstep of linspace (in real numpy for Py2.7) is. Should be easily a added ...
Question: If someone (me e.g.) joins this (YOUR) numpy-pythonista-project, how to talk and share code?
Talk here could be possible but better probably in IRC channel #pythonista?
Other suggestion, if one is not afraid to learn some small wiki commands, could be 'my' wiki for pythonista (readable for anonymous, or not, editable by members of 'your' project?)
Peter = PKHG
Is it correct, that you used 'spaces' to indent in place of 'tab'?
I could easily change to the array.py using 'tab' s ;-)
Sure, I'd love some help :)
retstep isn't too important, but fairly simple -- just added it
Haven't really thought about how to manage multiple contributions, perhaps just posting here and using gist would do for now? I have no objection to a wiki though.
I actually wrote most of the code on a PC, so the spaces came from my editor. Tabs are fine by me.
Yesterday there was my "Oma and Opa"-day, I think one will need MATRIX - stuff
See you later ...
Started: at http://petergragert.info/pythonista_by_pkhg/pmwiki.php/Roger/NumpyThings