Skip to content
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

multi indexing of functions #943

Closed
mehrhardt opened this issue Feb 28, 2017 · 4 comments
Closed

multi indexing of functions #943

mehrhardt opened this issue Feb 28, 2017 · 4 comments

Comments

@mehrhardt
Copy link
Contributor

mehrhardt commented Feb 28, 2017

I guess this issue was raised somewhere already but I could not find it. So please apologies my duplicate.

In all my applications, the images are 2 or 3 dimensional so it would be good if ODL was supporting multi indexing. Here an example that does not work:

>>> X = odl.uniform_discr(min_pt=[-1, -1], max_pt=[1, 1], shape=[128, 128])
>>> x = X.one()
>>> x[1,1]
Traceback (most recent call last):

  File "<ipython-input-13-3e593ebbc211>", line 1, in <module>
    x[1,1]

  File "odl/discr/discretization.py", line 326, in __getitem__
    return self.ntuple.__getitem__(indices)

  File "odl/space/npy_ntuples.py", line 367, in __getitem__
    arr = self.data[indices]

IndexError: too many indices for array

Of course by now I know a way around it: x.asarray()[1,1] However, this does not satisfy my needs as I want to write code that I can interchangeably with ODL or numpy. Is it so difficult to implement this directly, e.g. x[1,1] := x.asarray()[1,1]?

@adler-j
Copy link
Member

adler-j commented Feb 28, 2017

I guess this issue was raised somewhere already but I could not find it. So please apologies my duplicate.

There is a huge effort in this direction, started with issue #342, then continued in #731, #857, #907, #908. The pull requests #739 and #861 are our WIP implementations of this.

Of course by now I know a way around it: x.asarray()[1,1] However, this does not satisfy my needs as I want to write code that I can interchangeably with ODL or numpy. Is it so difficult to implement this directly, e.g. x[1,1] := x.asarray()[1,1]?

We agree and we're working on it. However, on a deeper level this is non-trivial since we want to be able to support several backends, and up until lately there were no good GPU backends that allowed that syntax (there now is in libgpuarray).

You can anyway expect this feature to come to ODL Soon®.

@adler-j
Copy link
Member

adler-j commented Feb 28, 2017

Can I close this as duplicate btw, or is there anything new from the others this adds?

@kohr-h
Copy link
Member

kohr-h commented Feb 28, 2017

Just for the record, I'm pushing this stuff for finalization currently, including GPU support. So hang tight :-)

@kohr-h
Copy link
Member

kohr-h commented Mar 17, 2017

Closing as duplicate of ~10 issues taken together.

@kohr-h kohr-h closed this as completed Mar 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants