| 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 | def test_pandas_dim_size_alias(self): |
| 23 | df = pd.DataFrame({'x': np.linspace(0, 4, 5), 'y': np.linspace(1, 5, 5)}) |
| 24 | dim_expr = hv.dim('y') * 10 |
| 25 | scatter = df.hvplot.scatter('x', 'y', s=dim_expr) |
| 26 | plot_opts = scatter.opts.get().kwargs |
| 27 | assert repr(plot_opts.get('size')) == repr(dim_expr) |
| 28 | |
| 29 | def test_pandas_dim_color_expression(self): |
| 30 | df = pd.DataFrame({'x': np.linspace(0, 4, 5), 'y': np.linspace(-2, 2, 5)}) |
| 31 | dim_expr = hv.dim('y') * 10 |
| 32 | scatter = df.hvplot.scatter('x', 'y', color=dim_expr) |
| 33 | plot_opts = scatter.opts.get().kwargs |
| 34 | assert repr(plot_opts.get('color')) == repr(dim_expr) |
| 35 | assert plot_opts.get('colorbar') is True |
| 36 | |
| 37 | def test_pandas_color_alias_column(self): |
| 38 | df = pd.DataFrame({'x': np.linspace(0, 4, 5), 'y': np.linspace(1, 5, 5)}) |
| 39 | scatter = df.hvplot.scatter('x', 'y', c='y') |
| 40 | plot_opts = scatter.opts.get().kwargs |
| 41 | assert repr(plot_opts.get('color')) == repr(hv.dim('y')) |
| 42 | |
| 43 | # def test_pandas_dim_size_matplotlib_backend(self): |
| 44 | # hv.extension('matplotlib') |
| 45 | |
| 46 | # df = pd.DataFrame({'x': np.linspace(0, 4, 5), 'y': np.linspace(1, 5, 5)}) |
| 47 | # dim_expr = hv.dim('y') * 10 |
| 48 | |
| 49 | # scatter = df.hvplot.scatter('x', 'y', size=dim_expr) |
| 50 | # plot_opts = scatter.opts.get().kwargs |
| 51 | # # Matplotlib uses 's' not 'size' |
| 52 | # assert 's' in plot_opts |
| 53 | |
| 54 | |
| 55 | class TestXArrayTransforms(ComparisonTestCase): |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…