np.diff on boolean arrays now raises

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

np.diff on boolean arrays now raises

Jaime Fernández del Río
There is an ongoing discussion on github:


In 1.13 np.diff has started raising on boolean arrays, since subtraction of  boolean arrays is now deprecated.

A decision has to be made whether:
  • raising an error is the correct thing to do, and only the docstring needs updating, or
  • backwards compatibility is more important and diff should still work on boolean arrays.
If you have opinions on the subject, or enjoy arguing for the sake of it, please share your thoughts either here or on github.

Thanks!

--
(\__/)
( O.o)
( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes de dominación mundial.

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: np.diff on boolean arrays now raises

ralfgommers


On Thu, Jun 15, 2017 at 7:08 PM, Jaime Fernández del Río <[hidden email]> wrote:
There is an ongoing discussion on github:


In 1.13 np.diff has started raising on boolean arrays, since subtraction of  boolean arrays is now deprecated.

A decision has to be made whether:
  • raising an error is the correct thing to do, and only the docstring needs updating, or
  • backwards compatibility is more important and diff should still work on boolean arrays.

The issue is bigger than np.diff. For example, there's a problem with the scipy.ndimage morphology functions (https://github.com/scipy/scipy/issues/7493) that looks pretty serious. All ndimage.binary_* functions (7 of them) for example return boolean arrays, and chaining those is now broken. Unfortunately it seems that that wasn't covered by the ndimage test suite.

Possibly reverting the breaking change in 1.13.1 is the best way to fix this.

Ralf



_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: np.diff on boolean arrays now raises

Sebastian Berg
On Thu, 2017-06-15 at 22:35 +1200, Ralf Gommers wrote:

>
>
> On Thu, Jun 15, 2017 at 7:08 PM, Jaime Fernández del Río <jaime.frio@
> gmail.com> wrote:
> > There is an ongoing discussion on github:
> >
> > https://github.com/numpy/numpy/issues/9251
> >
> > In 1.13 np.diff has started raising on boolean arrays, since
> > subtraction of  boolean arrays is now deprecated.
> >
> > A decision has to be made whether:
> > raising an error is the correct thing to do, and only the docstring
> > needs updating, or
> > backwards compatibility is more important and diff should still
> > work on boolean arrays.
> >
>
> The issue is bigger than np.diff. For example, there's a problem with
> the scipy.ndimage morphology functions (https://github.com/scipy/scip
> y/issues/7493) that looks pretty serious. All ndimage.binary_*
> functions (7 of them) for example return boolean arrays, and chaining
> those is now broken. Unfortunately it seems that that wasn't covered
> by the ndimage test suite.
>
> Possibly reverting the breaking change in 1.13.1 is the best way to
> fix this.
>
Sure, I would say there is nothing wrong with reverting for now (and it
simply is the safe and easy way).
Though it would be good to address the issue of what should happen in
the future with diff (and possibly the subtract deprecation itself). If
we stick to it, but its necessary, we could delay the deprecation and
make it a VisibleDeprecationWarning.

- Sebastian


> Ralf
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> [hidden email]
> https://mail.python.org/mailman/listinfo/numpy-discussion
_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion

signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: np.diff on boolean arrays now raises

Charles R Harris
In reply to this post by ralfgommers


On Thu, Jun 15, 2017 at 4:35 AM, Ralf Gommers <[hidden email]> wrote:


On Thu, Jun 15, 2017 at 7:08 PM, Jaime Fernández del Río <[hidden email]> wrote:
There is an ongoing discussion on github:


In 1.13 np.diff has started raising on boolean arrays, since subtraction of  boolean arrays is now deprecated.

A decision has to be made whether:
  • raising an error is the correct thing to do, and only the docstring needs updating, or
  • backwards compatibility is more important and diff should still work on boolean arrays.

The issue is bigger than np.diff. For example, there's a problem with the scipy.ndimage morphology functions (https://github.com/scipy/scipy/issues/7493) that looks pretty serious. All ndimage.binary_* functions (7 of them) for example return boolean arrays, and chaining those is now broken. Unfortunately it seems that that wasn't covered by the ndimage test suite.

Possibly reverting the breaking change in 1.13.1 is the best way to fix this.

There were two related deprecations of boolean operators: subtraction and negative. I haven't heard any complaints about the second, which I think is less controversial, but I think reversion is the way to go for subtraction, at least for 1.13.1. The main virtue of the deprecations is clarity, xor is more informative when applied to boolean values than `-`, although the latter is certainly correct in F_2.

Chuck 


_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: np.diff on boolean arrays now raises

Charles R Harris


On Thu, Jun 15, 2017 at 6:16 AM, Charles R Harris <[hidden email]> wrote:


On Thu, Jun 15, 2017 at 4:35 AM, Ralf Gommers <[hidden email]> wrote:


On Thu, Jun 15, 2017 at 7:08 PM, Jaime Fernández del Río <[hidden email]> wrote:
There is an ongoing discussion on github:


In 1.13 np.diff has started raising on boolean arrays, since subtraction of  boolean arrays is now deprecated.

A decision has to be made whether:
  • raising an error is the correct thing to do, and only the docstring needs updating, or
  • backwards compatibility is more important and diff should still work on boolean arrays.

The issue is bigger than np.diff. For example, there's a problem with the scipy.ndimage morphology functions (https://github.com/scipy/scipy/issues/7493) that looks pretty serious. All ndimage.binary_* functions (7 of them) for example return boolean arrays, and chaining those is now broken. Unfortunately it seems that that wasn't covered by the ndimage test suite.

Possibly reverting the breaking change in 1.13.1 is the best way to fix this.

There were two related deprecations of boolean operators: subtraction and negative. I haven't heard any complaints about the second, which I think is less controversial, but I think reversion is the way to go for subtraction, at least for 1.13.1. The main virtue of the deprecations is clarity, xor is more informative when applied to boolean values than `-`, although the latter is certainly correct in F_2.


Chuck


_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion
Loading...