-
-
Notifications
You must be signed in to change notification settings - Fork 99
/
testpatch.py
127 lines (96 loc) · 3.82 KB
/
testpatch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
"""
Tests patching of supported libraries
"""
from unittest import TestCase, SkipTest
import numpy as np
from hvplot.plotting import hvPlotTabular, hvPlot
class TestPatchPandas(TestCase):
def setUp(self):
import hvplot.pandas # noqa
def test_pandas_series_patched(self):
import pandas as pd
series = pd.Series([0, 1, 2])
self.assertIsInstance(series.hvplot, hvPlotTabular)
def test_pandas_dataframe_patched(self):
import pandas as pd
df = pd.DataFrame([[1, 2], [3, 4], [5, 6]], columns=['x', 'y'])
self.assertIsInstance(df.hvplot, hvPlotTabular)
class TestPatchDask(TestCase):
def setUp(self):
try:
import dask.dataframe as dd # noqa
except:
raise SkipTest('Dask not available')
import hvplot.dask # noqa
def test_dask_series_patched(self):
import pandas as pd
import dask.dataframe as dd
series = pd.Series([0, 1, 2])
dseries = dd.from_pandas(series, 2)
self.assertIsInstance(dseries.hvplot, hvPlotTabular)
def test_dask_dataframe_patched(self):
import pandas as pd
import dask.dataframe as dd
df = pd.DataFrame([[1, 2], [3, 4], [5, 6]], columns=['x', 'y'])
ddf = dd.from_pandas(df, 2)
self.assertIsInstance(ddf.hvplot, hvPlotTabular)
class TestPatchXArray(TestCase):
def setUp(self):
try:
import xarray as xr # noqa
except:
raise SkipTest('XArray not available')
import hvplot.xarray # noqa
def test_xarray_dataarray_patched(self):
import xarray as xr
array = np.random.rand(100, 100)
xr_array = xr.DataArray(array, coords={'x': range(100), 'y': range(100)}, dims=('y', 'x'))
self.assertIsInstance(xr_array.hvplot, hvPlot)
def test_xarray_dataset_patched(self):
import xarray as xr
array = np.random.rand(100, 100)
xr_array = xr.DataArray(array, coords={'x': range(100), 'y': range(100)}, dims=('y', 'x'))
xr_ds = xr.Dataset({'z': xr_array})
self.assertIsInstance(xr_ds.hvplot, hvPlot)
class TestPatchStreamz(TestCase):
def setUp(self):
try:
import streamz # noqa
except:
raise SkipTest('streamz not available')
import hvplot.streamz # noqa
def test_streamz_dataframe_patched(self):
from streamz.dataframe import Random
random_df = Random()
self.assertIsInstance(random_df.hvplot, hvPlotTabular)
def test_streamz_series_patched(self):
from streamz.dataframe import Random
random_df = Random()
self.assertIsInstance(random_df.x.hvplot, hvPlotTabular)
def test_streamz_dataframes_patched(self):
from streamz.dataframe import Random
random_df = Random()
self.assertIsInstance(random_df.groupby('x').sum().hvplot, hvPlotTabular)
def test_streamz_seriess_patched(self):
from streamz.dataframe import Random
random_df = Random()
self.assertIsInstance(random_df.groupby('x').sum().y.hvplot, hvPlotTabular)
class TestPatchPolars(TestCase):
def setUp(self):
try:
import polars as pl # noqa
except:
raise SkipTest('Polars not available')
import hvplot.polars # noqa
def test_polars_series_patched(self):
import polars as pl
pseries = pl.Series([0, 1, 2])
self.assertIsInstance(pseries.hvplot, hvPlotTabular)
def test_polars_dataframe_patched(self):
import polars as pl
pdf = pl.DataFrame({'x': [1, 3, 5], 'y': [2, 4, 6]})
self.assertIsInstance(pdf.hvplot, hvPlotTabular)
def test_polars_lazyframe_patched(self):
import polars as pl
pldf = pl.LazyFrame({'x': [1, 3, 5], 'y': [2, 4, 6]})
self.assertIsInstance(pldf.hvplot, hvPlotTabular)