Open purepani opened 6 months ago
Can you give an example of what you would like to have? E.g. some example syntax that doesn't currently work but just so I have an idea of what you would like to work?
Sure! The way the library normally works is something like this:
x=np.random((4, 5, 6))
y = einops.rearrange(x, 'i j k - > j k i')
y.shape# (5, 6, 4)
All the functions in the library work like this. It would be nice if, when there's a multivector where each component is an array, I could do the same code as above:
vals=np.random((4, 4, 5, 6))
x=alg.vector(vals)
y = einops.rearrange(x, 'i j k - > j k i')
One way to do this would be to support "passing through" the array api standard if one exists for the objects, since einops supports anything that also supports it. I'm not sure if that's reasonable or possible to do, but I figured I'd suggest it.
Einops is super nice for manipulating arrays in a bunch of useful ways by referring to their axes, so it'd be nice to be able to do it through a multivector.
I agree that it would be nice, but we have to see if it is compatible with the kingdon API. As you also show in your example, the first dimension is used by kingdon for the coefficients of a multivector. So only subsequent dimensions should be exposed to einops. This is already done when you index multivectors, e.g.
vals=np.random((4, 4, 5, 6))
x=alg.vector(vals)
x[0, 0, 0] = [1, 2, 3, 4]
would set those particular coefficients. So if we could formalize this in a way that einops understands, then I welcome this functionality! If you have experience with einops then feel free to make a PR, because I don't know when I will have time to get round to this myself.
If I have time I may get to it, but if I don't end up getting to it, and you happen to have time, einops supports the python array api, so if you implement that, it should just work. See https://data-apis.org/array-api/latest/
Not asking you to do it, just thought I'd give the information just in case!
Thanks for the info. At the very least I'll try not to offend against the array API ;).
Would it be possible to have compatibility with einops when using an array type like numpy arrays? It would be useful to be able to manipulate the arrays directly through the multivector object rather than having to go through component by component.