- edited description
numpy.greater_equal.outer uses stub from pypy's micronumpy and not numpy ufunc...
EDIT: Simpler bug reproduction on the bottom of report. EDIT2: Found "real" problem, probably, see last comments.
Not works in: pypy 5.1.1 with numpy from https://bitbucket.org/pypy/numpy/ ( 2de5fffe8210079d591a132b6d9a82eb619d5967 )
Works in: normal numpy in python2 and python3
Error:
File "lab4.py", line 12, in my_rq
Q,R = numpy.linalg.qr(numpy.flipud(A).T)
File "/usr/local/Cellar/pypy/5.1.1/libexec/site-packages/numpy/linalg/linalg.py", line 831, in qr
return wrap(q), wrap(triu(r))
File "/usr/local/Cellar/pypy/5.1.1/libexec/site-packages/numpy/lib/twodim_base.py", line 484, in triu
mask = tri(*m.shape[-2:], k=k-1, dtype=bool)
File "/usr/local/Cellar/pypy/5.1.1/libexec/site-packages/numpy/lib/twodim_base.py", line 415, in tri
arange(-k, M-k, dtype=_min_int(-k, M - k)))
ValueError: outer product only supported for binary functions
Code:
def my_rq(A):
Q,R = numpy.linalg.qr(numpy.flipud(A).T)
R = numpy.flipud(R.T)
Q = Q.T
return R[:,::-1], Q[::-1,:]
This code generates RQ decomposition from numpy.linalg.qr decomposition.
A matrix:
[[ 0.45827554 -0.29474237 -0.01395746]
[-0.05085589 -0.0545847 -0.54105993]
[ 0.10900958 0.17834548 -0.04426782]]
This simple code works with normal python numpy, but not with pypy's numpy:
import numpy
a = numpy.arange(3)
b = numpy.arange(1,4)
print(a)
print(b)
print(numpy.greater_equal.outer(a,b))
Comments (15)
-
reporter -
reporter - edited description
-
reporter - edited description
-
reporter - changed title to numpy.linalg.qr gives "ValueError: outer product only supported for binary functions"
-
reporter - edited description
-
reporter I've upgraded to new 5.1.1 tarball after https://bitbucket.org/pypy/pypy/issues/2292/511-source-tarball-is-really-510 but bug still persists.
-
reporter numpy.flipud(A).T
is the same in both versions, and equals:[[ 0.10900958 -0.05085589 0.45827554] [ 0.17834548 -0.0545847 -0.29474237] [-0.04426782 -0.54105993 -0.01395746]]
So it has to be something wrong with
numpy.linalg.qr
,triu
ortri
. -
reporter I've injected some
print
s into both numpies, and it seemsr
is the same in pypy version:[[-0.21365823 -0.04059207 0.00932179] [ 0.55272163 0.54466866 0.00130836] [-0.13719317 0.91389158 0.54497316]]
Later I've injected into tri and this:
print(N) print(-k) print(M-k) print(_min_int(0, N)) print(_min_int(-k, M - k))
gave the same output in both.
-
reporter print(arange(N, dtype=_min_int(0, N)), arange(-k, M-k, dtype=_min_int(-k, M - k)))
Injected into
tri
gives in both versions:[0 1 2] [1 2 3]
so it must be a bug in
greater_equal.outer
-
reporter - edited description
- changed title to numpy.greater_equal.outer gives "ValueError: outer product only supported for binary functions"
-
reporter - edited description
-
reporter It looks that
numpy.ufunc
outer
is not defined in this numpy. And inpypy
there is some stub ( why it's in pypy code and not here? ) that does only:def _outer(self, space, __args__): raise OperationError(space.w_ValueError, space.wrap( "outer product only supported for binary functions"))
(
/module/micronumpy/ufuncs.py
in pypy repo ) -
reporter There is
outer()
implemetation incore/src/umath/ufunc_object.c
... Why then stub version from micronumpy is used and not this one? -
reporter - changed title to numpy.greater_equal.outer uses stub from pypy's micronumpy and not numpy ufunc...
- edited description
-
- changed status to resolved
fixed in pypy/pypy changeset 0c3ac8d64955, please reopen if I missed an edge case
- Log in to comment