[pypy-issue] [issue1008] numpypy: commit the code for empty_like, zeros_like, ones_like

Dmitrey tracker at bugs.pypy.org
Mon Jan 23 13:15:48 CET 2012


Dmitrey <dmitrey15 at ukr.net> added the comment:

here's numpy zeros_like func latest version with 3 new parameters (in Linux
channel it's still old-style 1-argument version):

def zeros_like(a, dtype=None, order='K', subok=True):
    """
    Return an array of zeros with the same shape and type as a given array.

    With default parameters, is equivalent to ``a.copy().fill(0)``.

    Parameters
    ----------
    a : array_like
        The shape and data-type of `a` define these same attributes of
        the returned array.
    dtype : data-type, optional
        Overrides the data type of the result.
    order : {'C', 'F', 'A', or 'K'}, optional
        Overrides the memory layout of the result. 'C' means C-order,
        'F' means F-order, 'A' means 'F' if `a` is Fortran contiguous,
        'C' otherwise. 'K' means match the layout of `a` as closely
        as possible.
    Returns
    -------
    out : ndarray
        Array of z    
    (examples)
    """
    res = empty_like(a, dtype=dtype, order=order, subok=subok)
    res.fill(0)
    return res

So, there are some questions about it:
1) Does parameter "order" have any sense for numpypy? Or we could just don't
take it into account?
2) subok=True is not mentioned in documentation of the func. AFAIK it's related
to subclassing - if set to False, return ndarray instead of its subclass on
input (I have checked it right now). Have you any remarks or suggestions on it?
3) empty_like is defined in c code, will it be ok to replace their code by our
python-written one, similar to the code mentioned below (+ the new missing yet
arguments)?

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1008>
________________________________________


More information about the pypy-issue mailing list