Re: [Numpy-discussion] Numpy helper function for __getitem__?

2015-09-02 Thread Chris Barker
On Sat, Aug 29, 2015 at 12:55 AM, Phil Elson wrote: > Biggus also has such a function: > https://github.com/SciTools/biggus/blob/master/biggus/__init__.py#L2878 > It handles newaxis outside of that function in: >

Re: [Numpy-discussion] Numpy helper function for __getitem__?

2015-08-29 Thread Phil Elson
Biggus also has such a function: https://github.com/SciTools/biggus/blob/master/biggus/__init__.py#L2878 It handles newaxis outside of that function in: https://github.com/SciTools/biggus/blob/master/biggus/__init__.py#L537. Again, it only aims to deal with orthogonal array indexing, not numpy

Re: [Numpy-discussion] Numpy helper function for __getitem__?

2015-08-26 Thread Stephan Hoyer
Indeed, the helper function I wrote for xray was not designed to handle None/np.newaxis or non-1d Boolean indexers, because those are not valid indexers for xray objects. I think it could be straightforwardly extended to handle None simply by not counting them towards the total number of

Re: [Numpy-discussion] Numpy helper function for __getitem__?

2015-08-25 Thread Fabien
On 08/24/2015 10:23 AM, Sebastian Berg wrote: Fabien, just to make sure you are aware. If you are overriding `__getitem__`, you should also implement `__setitem__`. NumPy does some magic if you do not. That will seem to make `__setitem__` work fine, but breaks down if you have advanced

Re: [Numpy-discussion] Numpy helper function for __getitem__?

2015-08-24 Thread Sebastian Berg
On So, 2015-08-23 at 11:08 -0700, Stephan Hoyer wrote: I don't think NumPy has a function like this (at least, not exposed to Python), but I wrote one for xray, expanded_indexer, that you are welcome to borrow: https://github.com/xray/xray/blob/v0.6.0/xray/core/indexing.py#L10 Yeah, we

[Numpy-discussion] Numpy helper function for __getitem__?

2015-08-23 Thread Fabien
Folks, My search engine was not able to help me on this one, possibly because I don't know exactly *what* I am looking for. I need to override __getitem__ for a class that wrapps a numpy array. I know the dimensions of my array (which can be variable from instance to instance), and I know

Re: [Numpy-discussion] Numpy helper function for __getitem__?

2015-08-23 Thread Stephan Hoyer
I don't think NumPy has a function like this (at least, not exposed to Python), but I wrote one for xray, expanded_indexer, that you are welcome to borrow: https://github.com/xray/xray/blob/v0.6.0/xray/core/indexing.py#L10 ​Stephan On Sunday, Aug 23, 2015 at 7:54 PM, Fabien

Re: [Numpy-discussion] Numpy helper function for __getitem__?

2015-08-23 Thread Fabien
On 08/23/2015 08:08 PM, Stephan Hoyer wrote: I don't think NumPy has a function like this (at least, not exposed to Python), but I wrote one for xray, expanded_indexer, that you are welcome to borrow: Hi Stephan, that's perfect, thanks! Fabien ___