MCPcopy Create free account
hub / github.com/holoviz/hvplot / TestProcessXarray

Class TestProcessXarray

hvplot/tests/testutil.py:36–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34
35
36class TestProcessXarray(TestCase):
37 def setUp(self):
38 try:
39 import xarray as xr
40 except ImportError:
41 raise SkipTest('xarray not available')
42 self.default_kwargs = {
43 'value_label': 'value',
44 'label': None,
45 'gridded': False,
46 'persist': False,
47 'use_dask': False,
48 'groupby': None,
49 'y': None,
50 'x': None,
51 'by': None,
52 'other_dims': [],
53 }
54 self.ds = xr.tutorial.open_dataset('air_temperature')
55
56 def test_process_1d_xarray_dataarray_with_no_coords(self):
57 import xarray as xr
58
59 da = xr.DataArray(data=[1, 2, 3])
60
61 data, x, y, by, groupby = process_xarray(data=da, **self.default_kwargs)
62 assert isinstance(data, pd.DataFrame)
63 assert x == 'index'
64 assert y == ['value']
65 assert not by
66 assert not groupby
67
68 def test_process_1d_xarray_dataarray_with_coords(self):
69 import xarray as xr
70
71 da = xr.DataArray(data=[1, 2, 3], coords={'day': [5, 6, 7]}, dims=['day'])
72
73 data, x, y, by, groupby = process_xarray(data=da, **self.default_kwargs)
74 assert isinstance(data, pd.DataFrame)
75 assert x == 'day'
76 assert y == ['value']
77 assert not by
78 assert not groupby
79
80 def test_process_1d_xarray_dataarray_with_coords_and_name(self):
81 import xarray as xr
82
83 da = xr.DataArray(data=[1, 2, 3], coords={'day': [5, 6, 7]}, dims=['day'], name='temp')
84
85 data, x, y, by, groupby = process_xarray(data=da, **self.default_kwargs)
86 assert isinstance(data, pd.DataFrame)
87 assert x == 'day'
88 assert y == ['temp']
89 assert not by
90 assert not groupby
91
92 def test_process_2d_xarray_dataarray_with_no_coords(self):
93 import xarray as xr

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…