Discussion:
[Numpy-discussion] New behavior of allclose
Charles R Harris
2015-11-04 19:28:48 UTC
Permalink
Hi All,

This is to open a discussion of a change of behavior of `np.allclose`. That
function uses `isclose` in numpy 1.10 with the result that array subtypes
are preserved whereas before they were not. In particular, memmaps are
returned when at least one of the inputs is a memmap. By and large I think
this is a good thing, OTOH, it is a change in behavior. It is easy to fix,
just run `np.array(result, copy=False)` on the current `result`, but I
thought I'd raise the topic on the list in case there is a good argument to
change things.

Chuck
Nathan Goldbaum
2015-11-04 19:36:01 UTC
Permalink
I actually brought this up before 1.10 came out:
https://github.com/numpy/numpy/issues/6196

The behavior change brought out a bug in our use of allclose, so while it
was annoying in the sense that our test suite started failing in a new way,
it was good in that our tests are now more correct.
Post by Charles R Harris
Hi All,
This is to open a discussion of a change of behavior of `np.allclose`.
That function uses `isclose` in numpy 1.10 with the result that array
subtypes are preserved whereas before they were not. In particular, memmaps
are returned when at least one of the inputs is a memmap. By and large I
think this is a good thing, OTOH, it is a change in behavior. It is easy to
fix, just run `np.array(result, copy=False)` on the current `result`, but I
thought I'd raise the topic on the list in case there is a good argument to
change things.
Chuck
_______________________________________________
NumPy-Discussion mailing list
https://mail.scipy.org/mailman/listinfo/numpy-discussion
Nathan Goldbaum
2015-11-04 19:42:28 UTC
Permalink
Oh oops, this is about np.allcose, not np.assert_allclose. Sorry for the
noise...
Post by Nathan Goldbaum
https://github.com/numpy/numpy/issues/6196
The behavior change brought out a bug in our use of allclose, so while it
was annoying in the sense that our test suite started failing in a new way,
it was good in that our tests are now more correct.
On Wed, Nov 4, 2015 at 1:28 PM, Charles R Harris <
Post by Charles R Harris
Hi All,
This is to open a discussion of a change of behavior of `np.allclose`.
That function uses `isclose` in numpy 1.10 with the result that array
subtypes are preserved whereas before they were not. In particular, memmaps
are returned when at least one of the inputs is a memmap. By and large I
think this is a good thing, OTOH, it is a change in behavior. It is easy to
fix, just run `np.array(result, copy=False)` on the current `result`, but I
thought I'd raise the topic on the list in case there is a good argument to
change things.
Chuck
_______________________________________________
NumPy-Discussion mailing list
https://mail.scipy.org/mailman/listinfo/numpy-discussion
Charles R Harris
2015-11-04 19:45:06 UTC
Permalink
Post by Nathan Goldbaum
Oh oops, this is about np.allcose, not np.assert_allclose. Sorry for the
noise...
Probably related ;) Did you open an issue for it?

Chuck
Nathan Goldbaum
2015-11-04 19:47:43 UTC
Permalink
Yup, https://github.com/numpy/numpy/issues/6196
Post by Charles R Harris
Post by Nathan Goldbaum
Oh oops, this is about np.allcose, not np.assert_allclose. Sorry for the
noise...
Probably related ;) Did you open an issue for it?
Chuck
_______________________________________________
NumPy-Discussion mailing list
https://mail.scipy.org/mailman/listinfo/numpy-discussion
Benjamin Root
2015-11-04 19:40:12 UTC
Permalink
I am not sure I understand what you mean. Specifically that np.isclose will
return a memmap if one of the inputs is a memmap. The result is a brand new
array, right? So, what is that result memmapping from? Also, how does this
impact np.allclose()? That function returns a scalar True/False, so what is
the change in behavior there?

By the way, the docs for isclose in 1.10.1 does not mention any behavior
changes.

Ben Root
Post by Charles R Harris
Hi All,
This is to open a discussion of a change of behavior of `np.allclose`.
That function uses `isclose` in numpy 1.10 with the result that array
subtypes are preserved whereas before they were not. In particular, memmaps
are returned when at least one of the inputs is a memmap. By and large I
think this is a good thing, OTOH, it is a change in behavior. It is easy to
fix, just run `np.array(result, copy=False)` on the current `result`, but I
thought I'd raise the topic on the list in case there is a good argument to
change things.
Chuck
_______________________________________________
NumPy-Discussion mailing list
https://mail.scipy.org/mailman/listinfo/numpy-discussion
Charles R Harris
2015-11-04 19:43:48 UTC
Permalink
Post by Benjamin Root
I am not sure I understand what you mean. Specifically that np.isclose
will return a memmap if one of the inputs is a memmap. The result is a
brand new array, right? So, what is that result memmapping from? Also, how
does this impact np.allclose()? That function returns a scalar True/False,
so what is the change in behavior there?
By the way, the docs for isclose in 1.10.1 does not mention any behavior
changes.
Yep, it is a new issue, see #6475
<https://github.com/numpy/numpy/issues/6475>

Chuck
Ralf Gommers
2015-11-05 21:50:49 UTC
Permalink
Post by Charles R Harris
Hi All,
This is to open a discussion of a change of behavior of `np.allclose`.
That function uses `isclose` in numpy 1.10 with the result that array
subtypes are preserved whereas before they were not. In particular, memmaps
are returned when at least one of the inputs is a memmap. By and large I
think this is a good thing, OTOH, it is a change in behavior. It is easy to
fix, just run `np.array(result, copy=False)` on the current `result`, but I
thought I'd raise the topic on the list in case there is a good argument to
change things.
Why would it be good to return a memmap? And am I confused or does your
just merged PR [1] revert the behavior you say here is a good thing?

Ralf

[1] https://github.com/numpy/numpy/pull/6628
Benjamin Root
2015-11-05 22:00:34 UTC
Permalink
allclose() needs to return a bool so that one can do "if np.allclose(foo,
bar) is True" or some such. The "good behavior" is for np.isclose() to
return a memmap, which still confuses the heck out of me, but I am not a
memmap expert.
On Wed, Nov 4, 2015 at 8:28 PM, Charles R Harris <
Post by Charles R Harris
Hi All,
This is to open a discussion of a change of behavior of `np.allclose`.
That function uses `isclose` in numpy 1.10 with the result that array
subtypes are preserved whereas before they were not. In particular, memmaps
are returned when at least one of the inputs is a memmap. By and large I
think this is a good thing, OTOH, it is a change in behavior. It is easy to
fix, just run `np.array(result, copy=False)` on the current `result`, but I
thought I'd raise the topic on the list in case there is a good argument to
change things.
Why would it be good to return a memmap? And am I confused or does your
just merged PR [1] revert the behavior you say here is a good thing?
Ralf
[1] https://github.com/numpy/numpy/pull/6628
_______________________________________________
NumPy-Discussion mailing list
https://mail.scipy.org/mailman/listinfo/numpy-discussion
Charles R Harris
2015-11-05 22:15:26 UTC
Permalink
On Wed, Nov 4, 2015 at 8:28 PM, Charles R Harris <
Post by Charles R Harris
Hi All,
This is to open a discussion of a change of behavior of `np.allclose`.
That function uses `isclose` in numpy 1.10 with the result that array
subtypes are preserved whereas before they were not. In particular, memmaps
are returned when at least one of the inputs is a memmap. By and large I
think this is a good thing, OTOH, it is a change in behavior. It is easy to
fix, just run `np.array(result, copy=False)` on the current `result`, but I
thought I'd raise the topic on the list in case there is a good argument to
change things.
Why would it be good to return a memmap? And am I confused or does your
just merged PR [1] revert the behavior you say here is a good thing?
Good thing for isclose, not allclose. I was thinking of very large files
that might exceed memory in the isclose case, but an argument could be made
for other subtypes. Allclose, OTOH, always returns a scalar.

I went ahead with boolean for allclose because 1) it is backward
compatible, 2) Nathaniel tended in that direction, 3) the conversation here
is tending in that direction, 4) I tend in that direction, and finally, I
want to get 1.10.2rc1 out this weekend ;)

Chuck

Loading...