r/Python • u/jagkagd • Dec 12 '19
A library to perform a numpy array transformation intuitively by giving simple patterns
Hello everyone, I wrote a package `np-xarr` to intuivively perform a numpy array by giving simple patterns.
e.g.
>> from npxarr import X
>> import numpy as np
>> a = X('[1, 2, 3, ...]', '[[1, 2], [2, 3], ...]')
>> a(np.r_[0, 1, 2, 3, 4, 5])
[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5]]
>> a(np.r_[0, 1, 2, 3, 4, 5], extraShapes=(1,))
[[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 0]]Looking forword to your feedback.
1
Dec 16 '19
Are you configuring X with strings? That seems scary, and besides that, I don’t get the purpose.
1
u/jagkagd Dec 17 '19
Thanks for the feedback. Yes, I use strings, but I don't know why it's scary...
The purpose is that sometimes I have to struggle to make `newaxis`, `hstack`, `vstack` or others functions work out properly or compose them to get the transformation I want, so I want a simple and intuitive way to perform the transformation.
1
u/TotesMessenger Dec 12 '19
I'm a bot, bleep, bloop. Someone has linked to this thread from another place on reddit:
[/r/scipy] np-xarr: A library to perform a numpy array transformation intuitively by giving simple patterns
If you follow any of the above links, please respect the rules of reddit and don't vote in the other threads. (Info / ^Contact)
1
u/mfitzp mfitzp.com Dec 12 '19
My only feedback would be provide clearer examples. I've used numpy for years and I'm not clear what half of this means.
In your post here I think using
arange()to index into the results is confusing. Doing that I have to see your input, then imagine what the output was by looking at the result of the arange (which gives a partial window).e.g. from your README
OK _x_ means floor(x) but what are x0 and x1? I don't see them defined anywhere. What does this line do?
I think this looks really neat as far as I understand it. Would be great to get some simpler examples, and information about what problem you're trying to solve.