Repository navigation
Conversation
9190194 to
aab5a50
Compare
1690d01 to
040dbda
Compare
040dbda to
39e07c0
Compare
Currently the `_meta` of `values` doesn't get correctly updated when using cuDF DataFrames instead of Pandas ones. Thus the `_meta` winds up being a NumPy array instead of a CuPy array. It seems the `meta` handling code in Dask DataFrame hadn't been updated since Dask Array got its own `meta`. So simply update the `Array` construction code to use `meta`.
39e07c0 to
ce3a25d
Compare
_meta of values in Dask DataframeArray from DataFrame with meta
|
Interesting looks like this causes some issues with record arrays _______________________________ test_to_records ________________________________
def test_to_records():
pytest.importorskip("dask.array")
from dask.array.utils import assert_eq
df = pd.DataFrame(
{"x": ["a", "b", "c", "d"], "y": [2, 3, 4, 5]},
index=pd.Index([1.0, 2.0, 3.0, 4.0], name="ind"),
)
ddf = dd.from_pandas(df, 2)
> assert_eq(df.to_records(), ddf.to_records())
dask/dataframe/io/tests/test_io.py:532:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
a = rec.array([(1., 'a', 2), (2., 'b', 3), (3., 'c', 4), (4., 'd', 5)],
dtype=[('ind', '<f8'), ('x', 'O'), ('y', '<i8')])
b = array([(1., 'a', 2), (2., 'b', 3), (3., 'c', 4), (4., 'd', 5)],
dtype=(numpy.record, [('ind', '<f8'), ('x', 'O'), ('y', '<i8')]))
check_shape = True, check_graph = True, check_meta = True, check_chunks = True
kwargs = {}
a_original = rec.array([(1., 'a', 2), (2., 'b', 3), (3., 'c', 4), (4., 'd', 5)],
dtype=[('ind', '<f8'), ('x', 'O'), ('y', '<i8')])
b_original = dask.array<to_records, shape=(nan,), dtype=(numpy.record, [('ind', '<f8'), ('x', 'O'), ('y', '<i8')]), |
|
Actually am a little surprised that test passes on In [1]: import numpy as np
...: import pandas as pd
...: import dask.dataframe as dd
In [2]: df = pd.DataFrame(
...: {"x": ["a", "b", "c", "d"], "y": [2, 3, 4, 5]},
...: index=pd.Index([1.0, 2.0, 3.0, 4.0], name="ind"),
...: )
...: ddf = dd.from_pandas(df, 2)
In [3]: df.to_records()
Out[3]:
rec.array([(1., 'a', 2), (2., 'b', 3), (3., 'c', 4), (4., 'd', 5)],
dtype=[('ind', '<f8'), ('x', 'O'), ('y', '<i8')])
In [4]: ddf.to_records().compute()
Out[4]:
array([(1., 'a', 2), (2., 'b', 3), (3., 'c', 4), (4., 'd', 5)],
dtype=(numpy.record, [('ind', '<f8'), ('x', 'O'), ('y', '<i8')])) |
|
I think assert_eq for array is missing an overall computed type check. I will open a separate PR to see what that would look like. |
|
@jakirkham you might be interested in #7399, where I tried the same thing. As I mentioned there, there are some other issues that emerge if you allow any array-like object to be the |
|
Oops totally missed that 😅 Thanks for working on this Gabe! Should we close this one out to consolidate work in that PR or vice versa? No strong feelings either way 🙂 |
|
I don't have a preference either. If we want to take the finalize-preserves-subclasses approach I used to get tests passing, let's consolidate on #7399. But if we want to take the Worth noting that either way, this comment applies: #7399 (comment). Once we merge this, users doing |
|
@jakirkham @gjoseph92 and I are planning to meet up to talk through a plan tomorrow at 1pm eastern. Please feel free to join or suggest a different time if you want to be in on that :) |
|
Sounds good. Feel free to send me an invite 🙂 |
|
cc @douglasdavis (in case this discussion is of interest to you as well 🙂) |
|
Closing so we can consolidate work in PR ( #7399 ) |
Currently the
_metaofvaluesdoesn't get correctly updated when using cuDF DataFrames instead of Pandas ones. Thus the_metawinds up being a NumPy array instead of a CuPy array.It seems the
metahandling code in Dask DataFrame hadn't been updated since Dask Array got its ownmeta. So simply update theArrayconstruction code to usemeta.cc @rjzamora @kkraus14
black dask/flake8 dask