Skip to content
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

Test with the latest version of dask #1499

Merged
merged 2 commits into from
Mar 3, 2025
Merged

Test with the latest version of dask #1499

merged 2 commits into from
Mar 3, 2025

Conversation

maximlt
Copy link
Member

@maximlt maximlt commented Feb 17, 2025

No description provided.

@hoxbro
Copy link
Member

hoxbro commented Feb 18, 2025

Failing test(s) looks like an ordering issue:

image

import dask.dataframe as dd
import holoviews as hv
import pandas as pd
import hvplot.dask

class S: ...
self = S()
    
self.df = pd.DataFrame([[1, 2], [3, 4], [5, 6]], columns=['x', 'y'])
self.df = dd.from_pandas(self.df, npartitions=2)
kind = 'scatter'
element = hv.Scatter

plot = self.df.hvplot(x='index', y='y', by='x', kind=kind)
obj = hv.NdOverlay(
    {
        1: element(self.df[self.df.x == 1], 'index', 'y'),
        3: element(self.df[self.df.x == 3], 'index', 'y'),
        5: element(self.df[self.df.x == 5], 'index', 'y'),
    },
    'x',
)

@hoxbro
Copy link
Member

hoxbro commented Feb 18, 2025

Changing sort=True in this line make it sorted, though likely not the correct fix, but likely a fix is around these lines.

chart = chart.layout() if self.subplots else chart.overlay(sort=False)

@maximlt
Copy link
Member Author

maximlt commented Feb 18, 2025

I think something changed in HoloViews. This script runs fine with dask 2024.4.1 (dask-expr 1.0.11 installed but query-planning disabled) but the last line fails with dask 2025.1.0 as the order of the keys is different.

from packaging.version import Version
import dask
if Version(dask.__version__).release < (2025, 1, 0):
    # Important that this is done before before other imports
    dask.config.set({"dataframe.query-planning": False})

import pandas as pd
import dask.dataframe as dd

import holoviews as hv
hv.extension('bokeh')

df = pd.DataFrame([[1, 2], [3, 4], [5, 6]], columns=['x', 'y'])
ddf = dd.from_pandas(df, npartitions=2)

print(ddf.compute())

expected_ddf = hv.NdOverlay(
    {
        1: hv.Scatter(ddf[ddf.x == 1], 'index', 'y'),
        3: hv.Scatter(ddf[ddf.x == 3], 'index', 'y'),
        5: hv.Scatter(ddf[ddf.x == 5], 'index', 'y'),
    },
    'x',
)
actual_ddf = hv.Dataset(ddf, ['x', 'index'], ['y']).to(hv.Scatter, ['index'], ['y'], ['x']).overlay(sort=False)

print(f'{expected_ddf=}')
print(f'{expected_ddf.keys()=}')

print(f'{actual_ddf=}')
print(f'{actual_ddf.keys()=}')

from holoviews.element.comparison import Comparison

Comparison().compare_ndoverlays(expected_ddf, actual_ddf)

@hoxbro
Copy link
Member

hoxbro commented Feb 18, 2025

I think something changed in HoloViews. This script runs fine with dask 2024.4.1 (dask-expr 1.0.11 installed but query-planning disabled) but the last line fails with dask 2025.1.0 as the order of the keys is different.

A better comparison would be with query-planning enabled. Otherwise, the difference could be from the different dask implementations.

@maximlt
Copy link
Member Author

maximlt commented Feb 18, 2025

What changed between the different dask dataframe implementations is the output of ddf['x'].unique().compute().

@maximlt maximlt merged commit 2ddd83c into main Mar 3, 2025
11 checks passed
@maximlt maximlt deleted the latest_dask branch March 3, 2025 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants