-
Notifications
You must be signed in to change notification settings - Fork 105
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
asarray() for power spaces #83
Comments
Or both, using an optional boolean flag |
That is definitely a decent middle way. |
Depends a bit on what one expects when asking a power space vector to become an array. Syntactically, one could index the vector with a single integer, |
I agree, but we should also note that the |
Correct, so then it's clear that only the flat version will fly. Any reason to make an optional n-dim array version for power spaces? If not, we don't differentiate. |
Users could anyway themselves: >>> x.asarray().reshape(...) If they want nd version. Another argument for the linear version is that we can make it recursive, so it will work on productspaces of productspaces. One interesting question is how we handle unmatched dtypes in this case, I suppose using numpy.find_common_type would make the most sense. |
That's an interesting issue. Using the |
This could be solved as part of #857 by going through the equivalent tensor-based power space. |
Well that is part of the problem, but what about >>> pspace = odl.ProductSpace(odl.rn(5), odl.rn(6))
>>> array = pspace.zero().asarray() what is |
Well, the issue was about power spaces from the beginning, so that's strictly speaking another issue. Not sure what to do in the general case. Is a single array ever needed for general product spaces or is it rather so that different things will happen in different components anyway? Strongly depends on the set of use cases. |
Well any user would expect some form of continuity, i.e if we make different choices we would get weird situations like
My suggestion would be to leave the "shape preserving case" for #857, and let |
That's true, so then we need to settle on the least common denominator for this case, which would probably be the linear array. Or not implementing >>> pspace = odl.rn(3) ** 2
>>> pspace
odl.rn((2, 3))
>>> pspace.asarray().shape
(2, 3) |
I've actually implemented this in #972, where the implementation is to make it a nd-array (i.e. asarray does NOT work with non-powerspaces) I felt this was the best way to do stuff given that tensors are comming. Further, the "make linear array" would have very few use-cases, most of which get over-ridden by |
This has been done in #1139. |
This could be implemented as calling asarray() on all subspaces, creating a N+1:d array. Another option is to create a linear array.
The text was updated successfully, but these errors were encountered: