Bug in frompyfunc starting at 10000 elements?
Hi all, I'm wondering if this is a bug...
Something strange happens with my ufunc as soon as I use 10000 elements. As the test shows, the ufunc computes the correct result for either the first or last 9999 elements, but both at the same time is no good.
Turns out I'm only running numpy 1.3.0 with Python 2.6.4... could someone with a more recent installation maybe check to see if this has been fixed?
Thanks,
def test_ufunc(): np = numpy
rng = np.random.RandomState(2342) a = rng.randn(10000, 2) b = rng.randn(10000, 1)
f = lambda x,y:x*y ufunc = np.frompyfunc(lambda *x:numpy.prod(x), 2, 1)
def g(x,y): return np.asarray(ufunc(x,y), dtype='float64')
assert numpy.allclose(f(a[:1],b[:1]), g(a[:1],b[:1])) # PASS assert numpy.allclose(f(a[1:],b[1:]), g(a[1:],b[1:])) # PASS assert numpy.allclose(f(a,b), g(a,b)) # FAIL
Confirmed in NumPy 1.4.1, Py 2.6.5.
David
On Fri, 21 May 2010, James Bergstra wrote:
Hi all, I'm wondering if this is a bug...
Something strange happens with my ufunc as soon as I use 10000 elements. As the test shows, the ufunc computes the correct result for either the first or last 9999 elements, but both at the same time is no good.
Turns out I'm only running numpy 1.3.0 with Python 2.6.4... could someone with a more recent installation maybe check to see if this has been fixed?
Thanks,
def test_ufunc(): np = numpy
rng = np.random.RandomState(2342) a = rng.randn(10000, 2) b = rng.randn(10000, 1)
f = lambda x,y:x*y ufunc = np.frompyfunc(lambda *x:numpy.prod(x), 2, 1)
def g(x,y): return np.asarray(ufunc(x,y), dtype='float64')
assert numpy.allclose(f(a[:1],b[:1]), g(a[:1],b[:1])) # PASS assert numpy.allclose(f(a[1:],b[1:]), g(a[1:],b[1:])) # PASS assert numpy.allclose(f(a,b), g(a,b)) # FAIL
And in 2.0.0.dev8437.
More hints:
Assume has shape (N, Da) and b has shape (N, Db)
* There is a problem wben N >= 10000, Db=1 and Da > 1. * There is no problem when N >= 10000, Da=1 and Db > 1. * The first row is OK, but for all others, there is one error per row, appearing in first column, then last column, first, etc.
Happy debugging !
David H.
On Fri, May 21, 2010 at 9:22 PM, David WardeFarley dwf@cs.toronto.edu wrote:
Confirmed in NumPy 1.4.1, Py 2.6.5.
David
On Fri, 21 May 2010, James Bergstra wrote:
Hi all, I'm wondering if this is a bug...
Something strange happens with my ufunc as soon as I use 10000 elements. As the test shows, the ufunc computes the correct result for either the first or last 9999 elements, but both at the same time is no good.
Turns out I'm only running numpy 1.3.0 with Python 2.6.4... could someone with a more recent installation maybe check to see if this has been fixed?
Thanks,
def test_ufunc(): np = numpy
rng = np.random.RandomState(2342) a = rng.randn(10000, 2) b = rng.randn(10000, 1)
f = lambda x,y:x*y ufunc = np.frompyfunc(lambda *x:numpy.prod(x), 2, 1)
def g(x,y): return np.asarray(ufunc(x,y), dtype='float64')
assert numpy.allclose(f(a[:1],b[:1]), g(a[:1],b[:1])) # PASS assert numpy.allclose(f(a[1:],b[1:]), g(a[1:],b[1:])) # PASS assert numpy.allclose(f(a,b), g(a,b)) # FAIL
NumPyDiscussion mailing list NumPyDiscussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpydiscussion
participants (3)

David Huard

David WardeFarley

James Bergstra