Repository navigation
ENH: add support for NEP 35 constructors (array, asarray, asanyarray, ascontiguousarray and asfortranarray) with like=Quantity(...)) - #17125
Conversation
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
|
👋 Thank you for your draft pull request! Do you know that you can use |
082fb3b to
555f3b1
Compare
7de3505 to
11c532f
Compare
mhvk
left a comment
There was a problem hiding this comment.
Looks good generally, but wondering a bit about whether code can be refactored to a common implementation.
| def asarray(a, dtype=None, order=None, *, device=None, copy=None): | ||
| return asarray_impl(a, dtype, order, device=device, copy=copy) | ||
|
|
||
| def asarray_impl(a, dtype=None, order=None, *, device=None, copy=None): |
There was a problem hiding this comment.
Like my comment for np.zeros, etc., I think all these functions could share a common implementation if one passed along function=np.asarray, etc.
It is a pity that for these the wrapping with function_helper does not work. Really, the super call should work - I guess this is a bug on the numpy side?
|
Yeah, also the tests are very redundant to satisfy completion meta tests. I'm genuinely wondering wether it's preferable to try and refactor now or later, when we have a complete set of implementations and we can see the whole picture. |
11c532f to
59e58ba
Compare
|
rebased and refactored with |
59e58ba to
5b549c7
Compare
…rray`, `ascontiguousarray` and `asfortranarray`) with like=Quantity(...))
5b549c7 to
fb5b88c
Compare
mhvk
left a comment
There was a problem hiding this comment.
Thanks, looks all good! (I think I'd have used **kwargs to combine some, but, really, this is better!)
Description
ref #17124, builds on top of #17120