python - Does numpy.all_close check for shape for the array like elements being compared -
its not clear documentation whether numpy.all_close check shape.
the code allclose
is:
def allclose(a, b, rtol=1.e-5, atol=1.e-8): # doc... x = array(a, copy=false, ndmin=1) y = array(b, copy=false, ndmin=1) # special handling of 'inf'... errstate(invalid='ignore'): r = all(less_equal(abs(x-y), atol + rtol * abs(y))) return r
notice insures inputs arrays (with @ least 1 dim). that's why works nested lists.
secondly core action x-y
. checks absolute difference terms small. if can broadcast arrays math, can compare arrays. it's subtraction issues broadcasting valueerror
.
Comments
Post a Comment