Should numpy.allclose return True for arrays of different shape ?
Hi, I wanted to know if the following behaviour is a bug or intended behaviour: """ import numpy as N N.allclose(N.array([[1., 1.]]), N.array([1.])) """ eg should allclose return True if arrays have different shape ? cheers, David
David Cournapeau wrote:
Hi,
I wanted to know if the following behaviour is a bug or intended behaviour:
""" import numpy as N N.allclose(N.array([[1., 1.]]), N.array([1.])) """
eg should allclose return True if arrays have different shape ?
If they are broadcastable to each other, then yes:
from numpy import * array([[1., 1.]]) + array([1.]) array([[ 2., 2.]])
-- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
David Cournapeau wrote:
Hi,
I wanted to know if the following behaviour is a bug or intended behaviour:
""" import numpy as N N.allclose(N.array([[1., 1.]]), N.array([1.])) """
eg should allclose return True if arrays have different shape ?
If they are broadcastable to each other, then yes: Ok, I assumed it returns True because the second one is broadcastable to
Robert Kern wrote: the first one, but this is not intuitive to me. What is the rationale for it ? (not that I want to criticize it, just curious) David
David Cournapeau wrote:
David Cournapeau wrote:
Hi,
I wanted to know if the following behaviour is a bug or intended behaviour:
""" import numpy as N N.allclose(N.array([[1., 1.]]), N.array([1.])) """
eg should allclose return True if arrays have different shape ? If they are broadcastable to each other, then yes: Ok, I assumed it returns True because the second one is broadcastable to
Robert Kern wrote: the first one, but this is not intuitive to me. What is the rationale for it ? (not that I want to criticize it, just curious)
The primary use case is this: allclose(some_array, some_scalar) -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
participants (2)
-
David Cournapeau
-
Robert Kern