PR 14966: Adding a new argument to np.asfarray

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

PR 14966: Adding a new argument to np.asfarray

Joseph Fox-Rabinovitz
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

_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion