HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/anaconda3/Lib/site-packages/hvplot/tests/teststreaming.py
from unittest import TestCase

import pandas as pd

from holoviews.streams import Buffer, Pipe


class TestExplicitStreamPlotting(TestCase):
    def setUp(self):
        import hvplot.pandas  # noqa

        self.df = pd.DataFrame([[1, 2], [3, 4], [5, 6]], columns=['x', 'y'])

    def test_pipe_stream(self):
        stream = Pipe(data=self.df)
        plot = self.df.hvplot('x', 'y', stream=stream)
        pd.testing.assert_frame_equal(plot[()].data, self.df)
        new_df = pd.DataFrame([[7, 8], [9, 10]], columns=['x', 'y'])
        stream.send(new_df)
        pd.testing.assert_frame_equal(plot[()].data, new_df)

    def test_buffer_stream(self):
        stream = Buffer(data=self.df, index=False)
        plot = self.df.hvplot('x', 'y', stream=stream)
        pd.testing.assert_frame_equal(plot[()].data, self.df)
        new_df = pd.DataFrame([[7, 8], [9, 10]], columns=['x', 'y'])
        stream.send(new_df)
        pd.testing.assert_frame_equal(plot[()].data, pd.concat([self.df, new_df]))