Repository navigation
Conversation
`np.concatenate` doesn't preserve array subclasses. This doesn't much matter, except it means our `meta` could be accurate from the chunks, but not for the final array returned from `compute` (after chunks are concatenated), which throws off some `assert_eq` tests.
Don't assume it's a NumPy array and just pass `dtype`
|
Brief update here: turns out pandas ExtensionArrays don't work as dask.Array chunks/meta out of the box. There are many places throughout the Array code where we expect Some of this should be pretty easy to fix; I'm pushing a commit here (d6fe64f) that gets elemwise and some reductions sorta working. But there are other things that will be difficult to generalize to arbitrary duck dtypes: for example, the |
|
The failures that you ran into in this change are related to the failures that I encountered on #7491. The |
|
Do you know how does this behaves when using the Distributed Scheduler? |
|
Manually testing some basic stuff on a LocalCluster seems to work fine. Anything in particular you were wondering about? |
|
Wasn't sure how well some of the more obscure types behaved when being serialized for example. Though that might not be too relevant (memory-mapping makes more sense with the threaded scheduler for example) |
|
@gjoseph92 @jakirkham I am kicking myself for not writing this up better after our meeting several months ago, but I think we decided to raise an informative error rather than trying to handle ExtensionArrays. There are some comments in #7375 (comment) as well but none of those seem to address what we want to do with these two PRs. |
|
Yeah I think that sounds right, but must admit my memory is a bit fuzzy |
Currently, if your
map_partitionsfunction returns an array-like object that's not a NumPy array (and has a dtype which isn't a NumPy dtype),map_partitionswill fail when constructingmeta. This PR allows whatevermetawas produced to pass through directly to the Array. This should make mapped functions that return pandas ExtensionArrays "just work" (can add some tests that that's so if we want to go ahead with this). And if the ExtensionArray type won't behave well as an Array chunk type for a particular operation, then hopefully doing that operation on themetashould fail as well.This was a 1-line change, but it then breaks other tests:
DataFrame.to_recordsnow produces an Array where themetais annp.recarray, not annp.ndarraycomputean Array ofrecarrays, the chunks get concatenated withnp.concatenate, which doesn't preserve ndarray subclasses. This causesassert_eqto complain that the type changed when computed (meta type isrecarray, computed type isndarray).concatenatepreserve ndarray subclasses,test_to_npy_stackfails, because themetafor the Array indicatedndarray, but the result was actuallymemmap(because the chunks arememmaps, which we now preserve).So that's why I also added logic for concatenate to preserve ndarray subclasses. If we even are okay with that change, I'd be fine splitting it to a separate PR for clarity.
cc @jrbourbeau: is this worth doing?
Related to #7377 (comment) and #7206.
black dask/flake8 dask