You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Interplay between copy and device in asarray()? #254
I feel we might need some clarification, but maybe we can start with a quick discussion.
I could be wrong, but we probably missed this in #96: What happens when we call asarray on an array on device 0 but set copy=False and device=device 1? Do we raise ValueError (as in other copy=False cases where a copy must be done), or do we ignore copy as the user clearly knows in this case a copy among the two devices is inevitable?
Another question: We probably owe it to clarify this in asarray() too, as in other *_like() cases?
If `device` is `None`, the default device must be used, not `x.device`.
Do we raise ValueError (as in other copy=False cases where a copy must be done), or do we ignore copy as the user clearly knows in this case a copy among the two devices is inevitable?
I'd suggest just raising the exception, because the two keywords provided conflict.
Another question: We probably owe it to clarify this in asarray() too, as in other *_like() cases?
Yes indeed. Although we may want to change that default in *_like. But either way asarray should say what its behavior is.
If by default x and y are not guaranteed to be on the same device, that's a bit of a foot gun. For other creation functions there's no array input, so the default device for the library is reasonable. But if there's an input array, it has a .device attribute, so that seems like a better default.
Activity
rgommers commentedon Sep 6, 2021
I'd suggest just raising the exception, because the two keywords provided conflict.
Yes indeed. Although we may want to change that default in
*_like. But either wayasarrayshould say what its behavior is.leofang commentedon Sep 8, 2021
Thanks, Ralf! Sounds good to me. I forgot we had this section that also provides the same answer to my question.
Why? I thought the default is fine.
I'll send a PR to address this.
rgommers commentedon Sep 14, 2021
If you use
_likethen it's typically for doing operations within some function, e.g.:If by default
xandyare not guaranteed to be on the same device, that's a bit of a foot gun. For other creation functions there's no array input, so the default device for the library is reasonable. But if there's an input array, it has a.deviceattribute, so that seems like a better default.leofang commentedon Sep 15, 2021
@rgommers I am glad you are undergoing the same thinking process as I did 😆 Let me direct you to your previous #96 (comment).