[Numpy-tickets] [NumPy] #930: empty_like and zeros_like behave differently from ones_like
NumPy
numpy-tickets@scipy....
Mon Oct 13 20:40:46 CDT 2008
#930: empty_like and zeros_like behave differently from ones_like
------------------------+---------------------------------------------------
Reporter: jbosch | Owner: somebody
Type: defect | Status: new
Priority: low | Milestone:
Component: numpy.core | Version: 1.1
Severity: trivial | Keywords:
------------------------+---------------------------------------------------
The {{{empty_like}}} and {{{zeros_like}}} creation functions, which are
defined in python in numeric.py, differ in their handling of array-subtype
input from {{{ones_like}}}, which is defined in C as a ufunc.
In particular, if a subtype of ndarray is passed to {{{empty_like}}} or
{{{zeros_like}}}, neither {{{__array_wrap__}}} or {{{__array_finalize__}}}
is called, which makes it impossible for subtypes to define any extra
attributes they might need.
I believe this behavior could be fixed entirely by switching from:
{{{if isinstance(a,ndarray):}}}
to
{{{if type(a)==ndarray:}}}
at the top of those two functions, though there are probably more
efficient ways to accomplish the same thing.
--
Ticket URL: <http://scipy.org/scipy/numpy/ticket/930>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.
More information about the Numpy-tickets
mailing list