Re: [Numpy-discussion] How to compare an array of arrays elementwise to None in

2017-07-19 Thread Sebastian Berg
On Wed, 2017-07-19 at 08:31 +, martin.gfel...@swisscom.com wrote: > Thank you for your help! > > Sebastian, I couldn't agree more with someone's bug being someone > else's feature! A fast identity ufunc would be useful, though.  > An `object_identity` ufunc should be very easy to implement,

Re: [Numpy-discussion] How to compare an array of arrays elementwise to None in Numpy 1.13 (was easy before)?

2017-07-17 Thread Robert Kern
On Mon, Jul 17, 2017 at 10:52 AM, Eric Wieser wrote: > Here’s a hack that lets you keep using ==: > > class IsCompare: > __array_priority__ = 99 # needed to make it work on either side of > `==` > def __init__(self, val): self._val = val > def __eq__(self, other): return other i

Re: [Numpy-discussion] How to compare an array of arrays elementwise to None in Numpy 1.13 (was easy before)?

2017-07-17 Thread Eric Wieser
Here’s a hack that lets you keep using ==: class IsCompare: __array_priority__ = 99 # needed to make it work on either side of `==` def __init__(self, val): self._val = val def __eq__(self, other): return other is self._val def __neq__(self, other): return other is not self._v

Re: [Numpy-discussion] How to compare an array of arrays elementwise to None in Numpy 1.13 (was easy before)?

2017-07-17 Thread Robert Kern
On Mon, Jul 17, 2017 at 2:13 AM, wrote: > > Dear all > > I have object array of arrays, which I compare element-wise to None in various places: > > >>> a = numpy.array([numpy.arange(5),None,numpy.nan,numpy.arange(6),None],dtype=numpy.object) > >>> a > array([array([0, 1, 2, 3, 4]), None, nan, arra

Re: [Numpy-discussion] How to compare an array of arrays elementwise to None in Numpy 1.13 (was easy before)?

2017-07-17 Thread Sebastian Berg
On Mon, 2017-07-17 at 09:13 +, martin.gfel...@swisscom.com wrote: > Dear all > > I have object array of arrays, which I compare element-wise to None > in various places: > > > > > a = > > > > numpy.array([numpy.arange(5),None,numpy.nan,numpy.arange(6),Non > > > > e],dtype=numpy.object) > > >