[Numpy-discussion] PR 14966: Adding a new argument to np.asfarray

Joseph Fox-Rabinovitz jfoxrabinovitz at gmail.com
Sat Nov 23 00:42:08 EST 2019


Hi,

I've submitted PR #14966, which makes a couple of small, backward
compatible, changes to the API of `asfarray`:

1. Added `copy` parameter that defaults to `False`
2. Added `None` option to the `dtype` parameter

Item #1 is inspired by situations like the one in Stack Overflow question
https://stackoverflow.com/q/58998475/2988730. Sometimes, you just need to
ensure a copy, and it's nice not to have to check things like if
`asfarray(x) is x: x = x.copy()`.

Item #2 solves the problem of trying to do `asfarray(x, dtype=x.dtype)` for
`x` that don't have a `dtype` attribute, like lists or tuples. I've made
every effort to make `dtype` and `copy` play together nicely.

On an unrelated note, I've also submitted #14967 to clean up the internals
of `mintypecode` a little in the same file.

Regards,

- Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20191123/2ac7ad75/attachment.html>


More information about the NumPy-Discussion mailing list