Skip to content

Commit

Permalink
remove all seperation of legacy and expression
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Jan 31, 2025
1 parent ffd7cd0 commit 9d6f4b5
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 138 deletions.
40 changes: 3 additions & 37 deletions holoviews/tests/core/data/test_daskinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@
from holoviews.core.util import PANDAS_VERSION
from holoviews.util.transform import dim

from ...utils import DASK_VERSION, dask_setup, dask_switcher
from .test_pandasinterface import BasePandasInterfaceTests

classic, expr = dask_setup()


class _DaskDatasetTest(BasePandasInterfaceTests):
class DaskDatasetTest(BasePandasInterfaceTests):
"""
Test of the pandas DaskDataset interface.
"""

datatype = 'dask'
data_type = dd.DataFrame

__test__ = False
__test__ = True

# Disabled tests for NotImplemented methods
def test_dataset_add_dimensions_values_hm(self):
Expand Down Expand Up @@ -130,38 +128,6 @@ def test_select_expression_lazy(self):
self.assertIsInstance(new_ds.data, dd.DataFrame)
self.assertEqual(new_ds.data.compute(), df[df.b == 10])


class DaskClassicDatasetTest(_DaskDatasetTest):

# No longer supported from Dask 2025.1

data_type = getattr(dd.core, "DataFrame", None)

__test__ = classic

@dask_switcher(query=False)
def setUp(self):
return super().setUp()


class DaskExprDatasetTest(_DaskDatasetTest):

__test__ = expr

@property
def data_type(self):
# Only available from 2025.1 and forward
if DASK_VERSION >= (2025, 1, 0):
return dd.DataFrame
else:
import dask_expr

return dask_expr.DataFrame

@dask_switcher(query=True)
def setUp(self):
return super().setUp()

def test_dataset_groupby(self):
# Dask-expr unique sort the order when running unique on column
super().test_dataset_groupby(sort=True)

Check failure on line 133 in holoviews/tests/core/data/test_daskinterface.py

View workflow job for this annotation

GitHub Actions / unit:test-39:ubuntu-latest

DaskDatasetTest.test_dataset_groupby AssertionError: Dataset not of matching length, 2 vs. 1.

Check failure on line 133 in holoviews/tests/core/data/test_daskinterface.py

View workflow job for this annotation

GitHub Actions / unit:test-39:macos-latest

DaskDatasetTest.test_dataset_groupby AssertionError: Dataset not of matching length, 2 vs. 1.
Expand Down
28 changes: 2 additions & 26 deletions holoviews/tests/core/data/test_spatialpandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
from holoviews.element import Path, Points, Polygons
from holoviews.element.comparison import ComparisonTestCase

from ...utils import dask_switcher
from .test_multiinterface import GeomTests


Expand Down Expand Up @@ -249,7 +248,7 @@ def test_geometry_array_constructor(self):
self.assertIsInstance(path.data.geometry.dtype, MultiPolygonDtype)


class DaskSpatialPandasBaseTest(GeomTests, RoundTripTests):
class DaskSpatialPandasTest(GeomTests, RoundTripTests):
"""
Test of the DaskSpatialPandasInterface.
"""
Expand All @@ -258,7 +257,7 @@ class DaskSpatialPandasBaseTest(GeomTests, RoundTripTests):

interface = DaskSpatialPandasInterface

__test__ = False
__test__ = True

def setUp(self):
if spatialpandas is None:
Expand Down Expand Up @@ -302,26 +301,3 @@ def test_dict_dataset_add_dimension_values(self):

def test_sort_by_value(self):
raise SkipTest("Not supported")


class DaskSpatialPandasClassicTest(DaskSpatialPandasBaseTest):
"""
Test of the Classic DaskSpatialPandasInterface, no longer exits since dask 2025.1
"""

__test__ = True

@dask_switcher(query=False, extras=["spatialpandas.dask"])
def setUp(self):
super().setUp()

class DaskSpatialPandasExprTest(DaskSpatialPandasBaseTest):
"""
Test of the Classic DaskSpatialPandasInterface, no longer exits since dask 2025.1
"""

__test__ = True

@dask_switcher(query=True, extras=["spatialpandas.dask"])
def setUp(self):
super().setUp()
7 changes: 2 additions & 5 deletions holoviews/tests/element/test_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
from holoviews.element.selection import spatial_select_columnar
from holoviews.util.transform import dim

from ..utils import dask_switcher

try:
import datashader as ds
except ImportError:
Expand Down Expand Up @@ -684,10 +682,9 @@ def pandas_df(self):
}, dtype=float)


@pytest.fixture(scope="function", params=[pytest.param(True, id='dask-classic'), pytest.param(False, id='dask-expr')])
@pytest.fixture(scope="function")
def dask_df(self, pandas_df, request):
with dask_switcher(query=request.param):
return dd.from_pandas(pandas_df, npartitions=2)
return dd.from_pandas(pandas_df, npartitions=2)

@pytest.fixture(scope="function")
def _method(self):
Expand Down
67 changes: 0 additions & 67 deletions holoviews/tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import logging
import os
import sys
from contextlib import contextmanager, suppress
from functools import lru_cache
from importlib import reload
from importlib.util import find_spec

import param
import pytest

from holoviews.core.util import _no_import_version
from holoviews.element.comparison import ComparisonTestCase

cwd = os.path.abspath(os.path.split(__file__)[0])
Expand Down Expand Up @@ -117,64 +111,3 @@ def tearDown(self):
for level, msgs in messages.items():
for msg in msgs:
log.log(LEVELS[level], msg)


DASK_UNAVAILABLE = find_spec("dask") is None
DASK_VERSION = _no_import_version("dask")


@lru_cache
def dask_setup():
"""
Set-up both dask dataframes, using lru_cahce to only do it once
"""
from datashader.data_libraries.dask import bypixel, dask_pipeline

classic, expr = False, False

# Removed in Dask 2025.1, and will raise AttributeError
if DASK_VERSION < (2025, 1, 0):
import dask.dataframe as dd

bypixel.pipeline.register(dd.core.DataFrame)(dask_pipeline)
classic = True
else:
# dask_expr import below will now fail with:
# cannot import name '_Frame' from 'dask.dataframe.core'
expr = True

with suppress(ImportError):
import dask_expr

bypixel.pipeline.register(dask_expr.DataFrame)(dask_pipeline)
expr = True

return classic, expr


@contextmanager
def dask_switcher(*, query=False, extras=None):
"""
Context manager to switch on/off dask-expr query planning.
Using a context manager as it is an easy way to
change the function to a decorator.
"""
if DASK_UNAVAILABLE:
pytest.skip("dask is not available")

classic, expr = dask_setup()

if not query and not classic:
pytest.skip("Classic DataFrame no longer supported by dask")
if query and not expr:
pytest.skip("dask-expr is not available")

import dask

dask.config.set(**{"dataframe.query-planning": query})
for module in ("dask.dataframe", *(extras or ())):
if module in sys.modules:
reload(sys.modules[module])
yield
3 changes: 0 additions & 3 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ PYTHONIOENCODING = "utf-8"
python = "3.9.*"
panel = "1.4.*"

[feature.py39.activation.env]
DASK_DATAFRAME__QUERY_PLANNING = "False"

[feature.py310.dependencies]
python = "3.10.*"
bokeh_sampledata = "*"
Expand Down

0 comments on commit 9d6f4b5

Please sign in to comment.