hvplot 0.9.3a1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hvplot/__init__.py +322 -0
- hvplot/_version.py +16 -0
- hvplot/backend_transforms.py +329 -0
- hvplot/converter.py +2855 -0
- hvplot/cudf.py +26 -0
- hvplot/dask.py +42 -0
- hvplot/data/crime.csv +56 -0
- hvplot/datasets.yaml +48 -0
- hvplot/fugue.py +64 -0
- hvplot/ibis.py +21 -0
- hvplot/intake.py +32 -0
- hvplot/interactive.py +968 -0
- hvplot/networkx.py +625 -0
- hvplot/pandas.py +30 -0
- hvplot/plotting/__init__.py +63 -0
- hvplot/plotting/andrews_curves.py +99 -0
- hvplot/plotting/core.py +2288 -0
- hvplot/plotting/lag_plot.py +34 -0
- hvplot/plotting/parallel_coordinates.py +85 -0
- hvplot/plotting/scatter_matrix.py +220 -0
- hvplot/polars.py +21 -0
- hvplot/sample_data.py +30 -0
- hvplot/streamz.py +21 -0
- hvplot/tests/__init__.py +0 -0
- hvplot/tests/conftest.py +44 -0
- hvplot/tests/data/README.md +5 -0
- hvplot/tests/data/RGB-red.byte.tif +0 -0
- hvplot/tests/plotting/__init__.py +0 -0
- hvplot/tests/plotting/testcore.py +108 -0
- hvplot/tests/plotting/testohlc.py +34 -0
- hvplot/tests/plotting/testscattermatrix.py +138 -0
- hvplot/tests/test_links.py +99 -0
- hvplot/tests/testbackend_transforms.py +89 -0
- hvplot/tests/testcharts.py +452 -0
- hvplot/tests/testfugue.py +46 -0
- hvplot/tests/testgeo.py +468 -0
- hvplot/tests/testgeowithoutgv.py +60 -0
- hvplot/tests/testgridplots.py +259 -0
- hvplot/tests/testhelp.py +75 -0
- hvplot/tests/testibis.py +17 -0
- hvplot/tests/testinteractive.py +1442 -0
- hvplot/tests/testnetworkx.py +26 -0
- hvplot/tests/testoperations.py +385 -0
- hvplot/tests/testoptions.py +596 -0
- hvplot/tests/testoverrides.py +74 -0
- hvplot/tests/testpanel.py +70 -0
- hvplot/tests/testpatch.py +135 -0
- hvplot/tests/testplotting.py +69 -0
- hvplot/tests/teststreaming.py +28 -0
- hvplot/tests/testtransforms.py +39 -0
- hvplot/tests/testui.py +383 -0
- hvplot/tests/testutil.py +378 -0
- hvplot/tests/util.py +82 -0
- hvplot/ui.py +1032 -0
- hvplot/util.py +677 -0
- hvplot/utilities.py +129 -0
- hvplot/xarray.py +62 -0
- hvplot-0.9.3a1.dist-info/LICENSE +29 -0
- hvplot-0.9.3a1.dist-info/METADATA +243 -0
- hvplot-0.9.3a1.dist-info/RECORD +63 -0
- hvplot-0.9.3a1.dist-info/WHEEL +5 -0
- hvplot-0.9.3a1.dist-info/entry_points.txt +2 -0
- hvplot-0.9.3a1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Tests for panel widgets and param objects as arguments
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from unittest import TestCase, SkipTest
|
|
6
|
+
|
|
7
|
+
from hvplot.util import process_xarray # noqa
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def look_for_class(panel, classname, items=None):
|
|
11
|
+
"""
|
|
12
|
+
Descend a panel object and find any instances of the given class
|
|
13
|
+
"""
|
|
14
|
+
import panel as pn
|
|
15
|
+
|
|
16
|
+
if items is None:
|
|
17
|
+
items = []
|
|
18
|
+
if isinstance(panel, pn.layout.ListPanel):
|
|
19
|
+
for p in panel:
|
|
20
|
+
items = look_for_class(p, classname, items)
|
|
21
|
+
elif isinstance(panel, classname):
|
|
22
|
+
items.append(panel)
|
|
23
|
+
return items
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class TestPanelObjects(TestCase):
|
|
27
|
+
def setUp(self):
|
|
28
|
+
try:
|
|
29
|
+
import panel as pn # noqa
|
|
30
|
+
import hvplot.pandas # noqa
|
|
31
|
+
except ImportError:
|
|
32
|
+
raise SkipTest('panel not available')
|
|
33
|
+
|
|
34
|
+
from bokeh.sampledata.iris import flowers
|
|
35
|
+
|
|
36
|
+
self.flowers = flowers
|
|
37
|
+
self.cols = list(self.flowers.columns[:-1])
|
|
38
|
+
|
|
39
|
+
def test_using_explicit_widgets_works(self):
|
|
40
|
+
import panel as pn
|
|
41
|
+
|
|
42
|
+
x = pn.widgets.Select(name='x', value='sepal_length', options=self.cols)
|
|
43
|
+
y = pn.widgets.Select(name='y', value='sepal_width', options=self.cols)
|
|
44
|
+
kind = pn.widgets.Select(name='kind', value='scatter', options=['bivariate', 'scatter'])
|
|
45
|
+
by_species = pn.widgets.Checkbox(name='By species')
|
|
46
|
+
color = pn.widgets.ColorPicker(value='#ff0000')
|
|
47
|
+
|
|
48
|
+
@pn.depends(by_species.param.value, color.param.value)
|
|
49
|
+
def by_species_fn(by_species, color):
|
|
50
|
+
return 'species' if by_species else color
|
|
51
|
+
|
|
52
|
+
self.flowers.hvplot(x, y=y, kind=kind.param.value, c=color)
|
|
53
|
+
|
|
54
|
+
def test_casting_widgets_to_different_classes(self):
|
|
55
|
+
import panel as pn
|
|
56
|
+
|
|
57
|
+
pane = self.flowers.hvplot.scatter(
|
|
58
|
+
groupby='species', legend='top_right', widgets={'species': pn.widgets.DiscreteSlider}
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
assert len(look_for_class(pane, pn.widgets.DiscreteSlider)) == 1
|
|
62
|
+
|
|
63
|
+
def test_using_explicit_widgets_with_groupby_does_not_raise_error(self):
|
|
64
|
+
import panel as pn
|
|
65
|
+
|
|
66
|
+
x = pn.widgets.Select(name='x', value='sepal_length', options=self.cols)
|
|
67
|
+
y = pn.widgets.Select(name='y', value='sepal_width', options=self.cols)
|
|
68
|
+
|
|
69
|
+
pane = self.flowers.hvplot(x, y, groupby='species')
|
|
70
|
+
assert isinstance(pane, pn.param.ParamFunction)
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Tests patching of supported libraries
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from unittest import TestCase, SkipTest
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
|
|
9
|
+
from hvplot.plotting import hvPlotTabular, hvPlot
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class TestPatchPandas(TestCase):
|
|
13
|
+
def setUp(self):
|
|
14
|
+
import hvplot.pandas # noqa
|
|
15
|
+
|
|
16
|
+
def test_pandas_series_patched(self):
|
|
17
|
+
import pandas as pd
|
|
18
|
+
|
|
19
|
+
series = pd.Series([0, 1, 2])
|
|
20
|
+
self.assertIsInstance(series.hvplot, hvPlotTabular)
|
|
21
|
+
|
|
22
|
+
def test_pandas_dataframe_patched(self):
|
|
23
|
+
import pandas as pd
|
|
24
|
+
|
|
25
|
+
df = pd.DataFrame([[1, 2], [3, 4], [5, 6]], columns=['x', 'y'])
|
|
26
|
+
self.assertIsInstance(df.hvplot, hvPlotTabular)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class TestPatchDask(TestCase):
|
|
30
|
+
def setUp(self):
|
|
31
|
+
try:
|
|
32
|
+
import dask.dataframe as dd # noqa
|
|
33
|
+
except ImportError:
|
|
34
|
+
raise SkipTest('Dask not available')
|
|
35
|
+
import hvplot.dask # noqa
|
|
36
|
+
|
|
37
|
+
def test_dask_series_patched(self):
|
|
38
|
+
import pandas as pd
|
|
39
|
+
import dask.dataframe as dd
|
|
40
|
+
|
|
41
|
+
series = pd.Series([0, 1, 2])
|
|
42
|
+
dseries = dd.from_pandas(series, 2)
|
|
43
|
+
self.assertIsInstance(dseries.hvplot, hvPlotTabular)
|
|
44
|
+
|
|
45
|
+
def test_dask_dataframe_patched(self):
|
|
46
|
+
import pandas as pd
|
|
47
|
+
import dask.dataframe as dd
|
|
48
|
+
|
|
49
|
+
df = pd.DataFrame([[1, 2], [3, 4], [5, 6]], columns=['x', 'y'])
|
|
50
|
+
ddf = dd.from_pandas(df, 2)
|
|
51
|
+
self.assertIsInstance(ddf.hvplot, hvPlotTabular)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class TestPatchXArray(TestCase):
|
|
55
|
+
def setUp(self):
|
|
56
|
+
try:
|
|
57
|
+
import xarray as xr # noqa
|
|
58
|
+
except ImportError:
|
|
59
|
+
raise SkipTest('XArray not available')
|
|
60
|
+
import hvplot.xarray # noqa
|
|
61
|
+
|
|
62
|
+
def test_xarray_dataarray_patched(self):
|
|
63
|
+
import xarray as xr
|
|
64
|
+
|
|
65
|
+
array = np.random.rand(100, 100)
|
|
66
|
+
xr_array = xr.DataArray(array, coords={'x': range(100), 'y': range(100)}, dims=('y', 'x'))
|
|
67
|
+
self.assertIsInstance(xr_array.hvplot, hvPlot)
|
|
68
|
+
|
|
69
|
+
def test_xarray_dataset_patched(self):
|
|
70
|
+
import xarray as xr
|
|
71
|
+
|
|
72
|
+
array = np.random.rand(100, 100)
|
|
73
|
+
xr_array = xr.DataArray(array, coords={'x': range(100), 'y': range(100)}, dims=('y', 'x'))
|
|
74
|
+
xr_ds = xr.Dataset({'z': xr_array})
|
|
75
|
+
self.assertIsInstance(xr_ds.hvplot, hvPlot)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class TestPatchStreamz(TestCase):
|
|
79
|
+
def setUp(self):
|
|
80
|
+
try:
|
|
81
|
+
import streamz # noqa
|
|
82
|
+
except ImportError:
|
|
83
|
+
raise SkipTest('streamz not available')
|
|
84
|
+
import hvplot.streamz # noqa
|
|
85
|
+
|
|
86
|
+
def test_streamz_dataframe_patched(self):
|
|
87
|
+
from streamz.dataframe import Random
|
|
88
|
+
|
|
89
|
+
random_df = Random()
|
|
90
|
+
self.assertIsInstance(random_df.hvplot, hvPlotTabular)
|
|
91
|
+
|
|
92
|
+
def test_streamz_series_patched(self):
|
|
93
|
+
from streamz.dataframe import Random
|
|
94
|
+
|
|
95
|
+
random_df = Random()
|
|
96
|
+
self.assertIsInstance(random_df.x.hvplot, hvPlotTabular)
|
|
97
|
+
|
|
98
|
+
def test_streamz_dataframes_patched(self):
|
|
99
|
+
from streamz.dataframe import Random
|
|
100
|
+
|
|
101
|
+
random_df = Random()
|
|
102
|
+
self.assertIsInstance(random_df.groupby('x').sum().hvplot, hvPlotTabular)
|
|
103
|
+
|
|
104
|
+
def test_streamz_seriess_patched(self):
|
|
105
|
+
from streamz.dataframe import Random
|
|
106
|
+
|
|
107
|
+
random_df = Random()
|
|
108
|
+
self.assertIsInstance(random_df.groupby('x').sum().y.hvplot, hvPlotTabular)
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class TestPatchPolars(TestCase):
|
|
112
|
+
def setUp(self):
|
|
113
|
+
try:
|
|
114
|
+
import polars as pl # noqa
|
|
115
|
+
except ImportError:
|
|
116
|
+
raise SkipTest('Polars not available')
|
|
117
|
+
import hvplot.polars # noqa
|
|
118
|
+
|
|
119
|
+
def test_polars_series_patched(self):
|
|
120
|
+
import polars as pl
|
|
121
|
+
|
|
122
|
+
pseries = pl.Series([0, 1, 2])
|
|
123
|
+
self.assertIsInstance(pseries.hvplot, hvPlotTabular)
|
|
124
|
+
|
|
125
|
+
def test_polars_dataframe_patched(self):
|
|
126
|
+
import polars as pl
|
|
127
|
+
|
|
128
|
+
pdf = pl.DataFrame({'x': [1, 3, 5], 'y': [2, 4, 6]})
|
|
129
|
+
self.assertIsInstance(pdf.hvplot, hvPlotTabular)
|
|
130
|
+
|
|
131
|
+
def test_polars_lazyframe_patched(self):
|
|
132
|
+
import polars as pl
|
|
133
|
+
|
|
134
|
+
pldf = pl.LazyFrame({'x': [1, 3, 5], 'y': [2, 4, 6]})
|
|
135
|
+
self.assertIsInstance(pldf.hvplot, hvPlotTabular)
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Tests pandas.options.backend setting
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from unittest import TestCase, SkipTest
|
|
6
|
+
|
|
7
|
+
import holoviews as hv
|
|
8
|
+
import pandas as pd
|
|
9
|
+
import pytest
|
|
10
|
+
|
|
11
|
+
from packaging.version import Version
|
|
12
|
+
from parameterized import parameterized
|
|
13
|
+
|
|
14
|
+
from hvplot.converter import HoloViewsConverter
|
|
15
|
+
from hvplot.plotting import plot
|
|
16
|
+
from hvplot.tests.util import makeDataFrame
|
|
17
|
+
|
|
18
|
+
no_args = ['line', 'area', 'hist', 'box', 'kde', 'density', 'bar', 'barh']
|
|
19
|
+
x_y = ['scatter', 'hexbin']
|
|
20
|
+
|
|
21
|
+
no_args_mapping = [
|
|
22
|
+
(kind, el) for kind, el in HoloViewsConverter._kind_mapping.items() if kind in no_args
|
|
23
|
+
]
|
|
24
|
+
x_y_mapping = [(kind, el) for kind, el in HoloViewsConverter._kind_mapping.items() if kind in x_y]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class TestPandasHoloviewsPlotting(TestCase):
|
|
28
|
+
def setUp(self):
|
|
29
|
+
if Version(pd.__version__) < Version('0.25.1'):
|
|
30
|
+
raise SkipTest('entrypoints for plotting.backends was added in pandas 0.25.1')
|
|
31
|
+
pd.options.plotting.backend = 'holoviews'
|
|
32
|
+
|
|
33
|
+
@parameterized.expand(no_args_mapping)
|
|
34
|
+
def test_pandas_series_plot_returns_holoviews_object(self, kind, el):
|
|
35
|
+
series = pd.Series([0, 1, 2])
|
|
36
|
+
plot = getattr(series.plot, kind)()
|
|
37
|
+
self.assertIsInstance(plot, el)
|
|
38
|
+
|
|
39
|
+
@parameterized.expand(no_args_mapping)
|
|
40
|
+
def test_pandas_dataframe_plot_returns_holoviews_object(self, kind, el):
|
|
41
|
+
df = pd.DataFrame([0, 1, 2])
|
|
42
|
+
plot = getattr(df.plot, kind)()
|
|
43
|
+
self.assertIsInstance(plot, el)
|
|
44
|
+
|
|
45
|
+
@parameterized.expand(x_y_mapping)
|
|
46
|
+
def test_pandas_dataframe_plot_returns_holoviews_object_when_x_and_y_set(self, kind, el):
|
|
47
|
+
df = pd.DataFrame({'a': [0, 1, 2], 'b': [5, 7, 2]})
|
|
48
|
+
plot = getattr(df.plot, kind)(x='a', y='b')
|
|
49
|
+
self.assertIsInstance(plot, el)
|
|
50
|
+
|
|
51
|
+
def test_pandas_dataframe_plot_does_not_implement_pie(self):
|
|
52
|
+
df = pd.DataFrame({'a': [0, 1, 2], 'b': [5, 7, 2]})
|
|
53
|
+
with self.assertRaisesRegex(NotImplementedError, 'pie'):
|
|
54
|
+
df.plot.pie(y='a')
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class TestPandasHvplotPlotting(TestPandasHoloviewsPlotting):
|
|
58
|
+
def setUp(self):
|
|
59
|
+
if Version(pd.__version__) < Version('0.25.1'):
|
|
60
|
+
raise SkipTest('entrypoints for plotting.backends was added in pandas 0.25.1')
|
|
61
|
+
pd.options.plotting.backend = 'hvplot'
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def test_plot_supports_polars():
|
|
65
|
+
pl = pytest.importorskip('polars')
|
|
66
|
+
dfp = pl.DataFrame(makeDataFrame())
|
|
67
|
+
out = plot(dfp, 'line')
|
|
68
|
+
assert isinstance(out, hv.NdOverlay)
|
|
69
|
+
assert out.keys() == dfp.columns
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
from unittest import TestCase
|
|
2
|
+
|
|
3
|
+
import pandas as pd
|
|
4
|
+
|
|
5
|
+
from holoviews.streams import Buffer, Pipe
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TestExplicitStreamPlotting(TestCase):
|
|
9
|
+
def setUp(self):
|
|
10
|
+
import hvplot.pandas # noqa
|
|
11
|
+
|
|
12
|
+
self.df = pd.DataFrame([[1, 2], [3, 4], [5, 6]], columns=['x', 'y'])
|
|
13
|
+
|
|
14
|
+
def test_pipe_stream(self):
|
|
15
|
+
stream = Pipe(data=self.df)
|
|
16
|
+
plot = self.df.hvplot('x', 'y', stream=stream)
|
|
17
|
+
pd.testing.assert_frame_equal(plot[()].data, self.df)
|
|
18
|
+
new_df = pd.DataFrame([[7, 8], [9, 10]], columns=['x', 'y'])
|
|
19
|
+
stream.send(new_df)
|
|
20
|
+
pd.testing.assert_frame_equal(plot[()].data, new_df)
|
|
21
|
+
|
|
22
|
+
def test_buffer_stream(self):
|
|
23
|
+
stream = Buffer(data=self.df, index=False)
|
|
24
|
+
plot = self.df.hvplot('x', 'y', stream=stream)
|
|
25
|
+
pd.testing.assert_frame_equal(plot[()].data, self.df)
|
|
26
|
+
new_df = pd.DataFrame([[7, 8], [9, 10]], columns=['x', 'y'])
|
|
27
|
+
stream.send(new_df)
|
|
28
|
+
pd.testing.assert_frame_equal(plot[()].data, pd.concat([self.df, new_df]))
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from unittest import SkipTest
|
|
2
|
+
|
|
3
|
+
import holoviews as hv
|
|
4
|
+
import numpy as np
|
|
5
|
+
import pandas as pd
|
|
6
|
+
|
|
7
|
+
from holoviews.element.comparison import ComparisonTestCase
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class TestPandasTransforms(ComparisonTestCase):
|
|
11
|
+
def setUp(self):
|
|
12
|
+
import hvplot.pandas # noqa
|
|
13
|
+
|
|
14
|
+
def test_pandas_transform(self):
|
|
15
|
+
demo_df = pd.DataFrame({'value': np.random.randn(50), 'probability': np.random.rand(50)})
|
|
16
|
+
percent = hv.dim('probability') * 100
|
|
17
|
+
scatter = demo_df.hvplot.scatter(
|
|
18
|
+
x='value', y='probability', transforms=dict(probability=percent)
|
|
19
|
+
)
|
|
20
|
+
self.assertEqual((scatter.data['probability']).values, demo_df['probability'].values * 100)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class TestXArrayTransforms(ComparisonTestCase):
|
|
24
|
+
def setUp(self):
|
|
25
|
+
try:
|
|
26
|
+
import xarray as xr # noqa
|
|
27
|
+
except ImportError:
|
|
28
|
+
raise SkipTest('xarray not available')
|
|
29
|
+
import hvplot.xarray # noqa
|
|
30
|
+
|
|
31
|
+
def test_xarray_transform(self):
|
|
32
|
+
import xarray as xr
|
|
33
|
+
|
|
34
|
+
data = np.arange(0, 60).reshape(6, 10)
|
|
35
|
+
x = np.arange(10)
|
|
36
|
+
y = np.arange(6)
|
|
37
|
+
da = xr.DataArray(data, coords={'y': y, 'x': x}, dims=('y', 'x'), name='value')
|
|
38
|
+
img = da.hvplot.image(transforms=dict(value=hv.dim('value') * 10))
|
|
39
|
+
self.assertEqual(img.data.value.data, da.data * 10)
|