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
Based on some recent discussion, in particular this comment ( #7321 (comment) ), it would be good to rename is_arraylike to is_duck_array for clarity and possibly update the docstring of this function to reflect its intended usage.
I think we need to have more discussion about this proposal especially since there are other methods that might benefit from a rename is_dataframe_like.
@jsignell and I were talking through this a bit and thought about adding to the docstring something along the lines of:
This function tests specifically for an object that already has array
attributes (e.g. np.ndarray, dask.array.Array), not for something that
can be coerced into an array object (e.g. Python lists and tuples)
I'm fine with changing that as per @douglasdavis' proposal. However, I often forget about small details so it'd be great to hear from @shoyer and @jrbourbeau if they see anything missing.
Remind me what the use case for this function inside dask is?
If it's specifically for testing valid duck array types to return from computing a dask array, then this looks right to me.
With regards to the proposed docstring addition: it seems a little funny to include pandas.Series as an example of a "duck array" because it doesn't work like a numpy.ndarray object. Nor does pandas.Series implement __array_function__ (at least not yet, and perhaps not ever): pandas-dev/pandas#26380
With regards to the proposed docstring addition: it seems a little
funny to include pandas.Series as an example of a "duck array" because
it doesn't work like a numpy.ndarray object. Nor does pandas.Series
implement __array_function__ (at least not yet, and perhaps not ever):
pandas-dev/pandas#26380
I had to search a bit through docs to find rationale here. Apparently numpy uses the term "array-like" to mean "anything that could be coerced into an array, like a list". Quote from numpy docs:
“Duck array” works fine as a placeholder for now, but it’s pretty jargony and may confuse new users, so we may want to pick something else for the actual API functions. Unfortunately, “array-like” is already taken for the concept of “anything that can be coerced into an array” (including e.g. list objects),
If there isn't a great pressing need here I'm inclined to just keep this as it is. I understand that we conflict a bit with an internal nuance of Numpy's naming, but "duck array" seems only interpretable to a select few of us. I don't think that it's a good name. I think that it's more likely that a new dev will be confused by "duck array" than by "is_arraylike", so if this isn't blocking anyone's productivity today I recommend that we keep things as we are.
That sounds good to me. In that case, I think it'd be helpful to include a sentence in @douglasdavis's proposed docstring that points out this inconsistency with what numpy means by array_like.
I think we can be very verbose in that docstring since it's mostly targetting other dask developers and developers of downstream libraries ( aka not normal users)
Activity
jsignell commentedon Mar 19, 2021
I think we need to have more discussion about this proposal especially since there are other methods that might benefit from a rename
is_dataframe_like.@dask/maintenance for visibility
douglasdavis commentedon Mar 19, 2021
@jsignell and I were talking through this a bit and thought about adding to the docstring something along the lines of:
Any thoughts on this?
douglasdavis commentedon Mar 19, 2021
Beyond that, a quick
does the trick to rename all occurrences to
is_duck_array, is more discussion around this necessary or would a PR be the next step?jakirkham commentedon Mar 19, 2021
@shoyer @pentschev @jrbourbeau, any more thoughts here? 🙂
pentschev commentedon Mar 19, 2021
I'm fine with changing that as per @douglasdavis' proposal. However, I often forget about small details so it'd be great to hear from @shoyer and @jrbourbeau if they see anything missing.
shoyer commentedon Mar 20, 2021
Remind me what the use case for this function inside dask is?
If it's specifically for testing valid duck array types to return from computing a dask array, then this looks right to me.
With regards to the proposed docstring addition: it seems a little funny to include pandas.Series as an example of a "duck array" because it doesn't work like a numpy.ndarray object. Nor does pandas.Series implement
__array_function__(at least not yet, and perhaps not ever): pandas-dev/pandas#26380douglasdavis commentedon Mar 21, 2021
mrocklin commentedon Mar 22, 2021
I had to search a bit through docs to find rationale here. Apparently numpy uses the term "array-like" to mean "anything that could be coerced into an array, like a list". Quote from numpy docs:
If there isn't a great pressing need here I'm inclined to just keep this as it is. I understand that we conflict a bit with an internal nuance of Numpy's naming, but "duck array" seems only interpretable to a select few of us. I don't think that it's a good name. I think that it's more likely that a new dev will be confused by "duck array" than by "is_arraylike", so if this isn't blocking anyone's productivity today I recommend that we keep things as we are.
jsignell commentedon Mar 22, 2021
That sounds good to me. In that case, I think it'd be helpful to include a sentence in @douglasdavis's proposed docstring that points out this inconsistency with what numpy means by
array_like.jrbourbeau commentedon Mar 22, 2021
+1 expanding the
is_arraylikedocstring sounds greatjsignell commentedon Mar 22, 2021
I think we can be very verbose in that docstring since it's mostly targetting other dask developers and developers of downstream libraries ( aka not normal users)
jakirkham commentedon Mar 22, 2021
Updating the docstring makes sense and also was one of the suggestions in the PR from which this issue was spun out
Agree this is mainly an internal function (does it see outside usage?) and as such it is mostly important that the group here understands its purpose