[pypy-issue] [issue964] numpypy.zeros() returns wrong result
tracker at bugs.pypy.org
Sat Dec 31 23:12:55 CET 2011
mikefc <coolbutuseless at gmail.com> added the comment:
There were 3 (related) problems here that I attempted to fix. Patch with tests
included. Please feel free to make changes to the patch and apply if good.
problem 1: to_str for concrete arrays with ndims==0 is broken.
If you look at ConcreteArray.to_str, there is one path conditional upon ndims==0
which prints the extra '[' in the repr. However, I think that if ndims==0, the
value should be a weigh in here? I just removed the code path for ndims==0
problem 2: if a=numpy.array(0.2); repr(a) caused a method not implemented error
Scalar.get_concrete() currently calls BaseArray().get_concrete() which is not
implemented. I just tried adding get_concrete() to Scalar but got a translate
error. Anyone know why?
Instead, I made changes to BaseArray.descr_repr() such that if self.shape is 0,
it is asserted as a Scalar and and get_concrete_or_scalar() is called instead.
problem 3: zeros() should return a scalar rather than a ConcreteArray
Added code such that if argument given results in shape==, then create a scalar
rather than a W_NDimArray.
status: unread -> chatting
PyPy bug tracker <tracker at bugs.pypy.org>
More information about the pypy-issue