New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Play nicer with ndarray subclasses #2486
Conversation
Mirrors the `subok` kwarg in `np.array`. If True, array-like's will be passed through as chunks unchanged. Default is False. This allows avoiding the `np.asarray` call, making it easier to work with non numpy arrays as chunks. To make this work we change `getarray` to a more generic `getter` function and add a `subok` parameter. Alternatively we could have kept the same format and created more getter functions, but this would have led to an explosion of functions for all the different combinations (which seemed less maintainable).
Similar to `asarray`, but doesn't convert chunks to instances of `ndarray`.
I'm not sure if |
No strong thoughts from me. |
Rename subok kwarg in `from_array` to `asarray`, switch defaults accordingly.
I've switched to use |
Planning to merge later today if no comment. |
|
||
if lock: | ||
lock.acquire() | ||
try: | ||
c = a[b] | ||
if type(c) != np.ndarray: | ||
if asarray: | ||
c = np.asarray(c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any value in making asarray
a callable that defaults to np.asarray
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Working with it as a boolean makes the optimizations easier to write and reason about. Could be done with a callable, but it'd be a bit trickier. Perhaps hold off until a use case presents itself? I'm not sure when that would be useful.
Sure
…On Wed, Jun 28, 2017 at 3:06 PM, Jim Crist ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In dask/array/core.py
<#2486 (comment)>:
>
if lock:
lock.acquire()
try:
c = a[b]
- if type(c) != np.ndarray:
+ if asarray:
c = np.asarray(c)
Working with it as a boolean makes the optimizations easier to write and
reason about. Could be done with a callable, but it'd be a bit trickier.
Perhaps hold off until a use case presents itself? I'm not sure when that
would be useful.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2486 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AASszE-_i-LRxqBz7TyTpogMADoxByqbks5sIqQegaJpZM4OEBhg>
.
|
Two changes:
subok
kwarg toda.from_array
.Mirrors the
subok
kwarg innp.array
. If True, array-like's will be passed through as chunks unchanged. Default is False. This allows avoiding thenp.asarray
call, making it easier to work with non numpy arrays as chunks.To make this work we change
getarray
to a more genericgetter
function and add asubok
parameter. Alternatively we could have kept the same format and created more getter functions, but this would have led to an explosion of functions for all the different combinations(which seemed less maintainable).
da.asanyarray
Similar to
da.asarray
, except avoids the call tonp.asarray
.