Пример #1
0
def test_multiple_figures():
    reset_dbplot()
    for _ in xrange(2):
        dbplot(np.random.randn(20, 20), 'a', fig='1')
        dbplot(np.random.randn(20, 20), 'b', fig='1')
        dbplot(np.random.randn(20, 20), 'c', fig='2')
        dbplot(np.random.randn(20, 20), 'd', fig='2')
Пример #2
0
def test_particular_plot(n_steps=3):
    reset_dbplot()

    for i in xrange(n_steps):
        r = np.random.randn(1)
        dbplot(r,
               plot_type=partial(HistogramPlot, edges=np.linspace(-5, 5, 20)))
Пример #3
0
def test_multiple_figures():
    reset_dbplot()
    for _ in xrange(2):
        dbplot(np.random.randn(20, 20), 'a', fig='1')
        dbplot(np.random.randn(20, 20), 'b', fig='1')
        dbplot(np.random.randn(20, 20), 'c', fig='2')
        dbplot(np.random.randn(20, 20), 'd', fig='2')
Пример #4
0
def test_list_of_images():
    reset_dbplot()
    for _ in xrange(2):
        dbplot([
            np.random.randn(12, 30),
            np.random.randn(10, 10),
            np.random.randn(15, 10)
        ])
Пример #5
0
def test_moving_point_multiple_points():
    reset_dbplot()
    for i in xrange(5):
        dbplot(np.sin([i / 10., i / 15.]),
               'unlim buffer',
               plot_type=partial(MovingPointPlot))
        dbplot(np.sin([i / 10., i / 15.]),
               'lim buffer',
               plot_type=partial(MovingPointPlot, buffer_len=20))
Пример #6
0
def test_two_plots_in_the_same_axis_version_2():
    reset_dbplot()
    # Option 2: Give both plots the same 'axis' argument
    for i in xrange(5):
        data = np.random.randn(200)
        x = np.linspace(-5, 5, 100)
        with hold_dbplots():
            dbplot(data, 'histogram', plot_type='histogram', axis='hist')
            dbplot((x, 1./np.sqrt(2*np.pi*np.var(data)) * np.exp(-(x-np.mean(data))**2/(2*np.var(data)))), 'density', axis='hist', plot_type='line')
Пример #7
0
def test_two_plots_in_the_same_axis_version_1():
    reset_dbplot()
    # Option 1: Name the 'axis' argument to the second plot after the name of the first
    for i in xrange(5):
        data = np.random.randn(200)
        x = np.linspace(-5, 5, 100)
        with hold_dbplots():
            dbplot(data, 'histogram', plot_type='histogram')
            dbplot((x, 1./np.sqrt(2*np.pi*np.var(data)) * np.exp(-(x-np.mean(data))**2/(2*np.var(data)))), 'density', axis='histogram', plot_type='line')
Пример #8
0
def test_freeze_dbplot():
    reset_dbplot()
    def random_walk():
        data = 0
        for i in xrange(10):
            data += np.random.randn()
            dbplot(data, 'walk')#, plot_type=lambda: MovingPointPlot(axes_update_mode='expand'))

    random_walk()
    freeze_all_dbplots()
    random_walk()
Пример #9
0
def test_same_object():
    """
    There was a bug where when you plotted two of the same array, you got "already seen object".  This tests makes
    sure it's gotten rid of.  If it's gone, both matrices should plot.  Otherwise you'll get "Already seen object" showing
    up on one of the plots.
    """
    reset_dbplot()
    a = np.random.randn(20, 20)
    for _ in xrange(5):
        dbplot(a, 'a')
        dbplot(a, 'b')
Пример #10
0
def test_same_object():
    """
    There was a bug where when you plotted two of the same array, you got "already seen object".  This tests makes
    sure it's gotten rid of.  If it's gone, both matrices should plot.  Otherwise you'll get "Already seen object" showing
    up on one of the plots.
    """
    reset_dbplot()
    a = np.random.randn(20, 20)
    for _ in xrange(5):
        dbplot(a, 'a')
        dbplot(a, 'b')
Пример #11
0
def test_dbplot(n_steps = 3):

    reset_dbplot()

    arr = np.random.rand(10, 10)
    for i in xrange(n_steps):
        arr_sq=arr**2
        arr = arr_sq/np.mean(arr_sq)
        dbplot(arr, 'arr')
        for j in xrange(3):
            barr = np.random.randn(10, 2)
            dbplot(barr, 'barr', plot_type=partial(LinePlot))
Пример #12
0
def test_dbplot(n_steps=3):

    reset_dbplot()

    arr = np.random.rand(10, 10)
    for i in xrange(n_steps):
        arr_sq = arr**2
        arr = arr_sq / np.mean(arr_sq)
        dbplot(arr, 'arr')
        for j in xrange(3):
            barr = np.random.randn(10, 2)
            dbplot(barr, 'barr', plot_type=partial(LinePlot))
Пример #13
0
def test_history_plot_updating():
    """
    This test checks that we've fixed the bug mentioned in issue 1: https://github.com/QUVA-Lab/artemis/issues/1
    That was, when you are updating multiple plots with history in a loop, everytime any of the plots is updated, they
    all get updated with the most recent data.  You'll see this in plot 'c' - with the bug, it moves in steps, with 3
    of the same sample in a row.  If it works it should be spikey.
    """
    reset_dbplot()
    for i in xrange(10):
        dbplot(np.random.randn(20, 20), 'a')
        dbplot(np.random.randn(20, 20), 'b')
        dbplot(np.random.randn(), 'c', plot_type=partial(MovingPointPlot))
Пример #14
0
def test_history_plot_updating():
    """
    This test checks that we've fixed the bug mentioned in issue 1: https://github.com/QUVA-Lab/artemis/issues/1
    That was, when you are updating multiple plots with history in a loop, everytime any of the plots is updated, they
    all get updated with the most recent data.  You'll see this in plot 'c' - with the bug, it moves in steps, with 3
    of the same sample in a row.  If it works it should be spikey.
    """
    reset_dbplot()
    for i in xrange(10):
        dbplot(np.random.randn(20, 20), 'a')
        dbplot(np.random.randn(20, 20), 'b')
        dbplot(np.random.randn(), 'c', plot_type=partial(MovingPointPlot))
Пример #15
0
def test_dbplot_logscale(n_steps = 3):
    reset_dbplot()

    arr = np.random.rand(10, 10)

    for i in xrange(n_steps):
        arr_sq=arr**2
        arr = arr_sq/np.mean(arr_sq)
        dbplot(arr, 'arr')
        for j in xrange(3):
            barr = np.random.randn(10, 2)
            kw = {"y_axis_type":"log"}
            dbplot(barr, 'barr', plot_type=partial(LinePlot,y_axis_type='log'))
Пример #16
0
def test_moving_point_multiple_points():
    reset_dbplot()
    p1 = 5.
    p2 = 8.
    for i in xrange(50):
        with hold_dbplots(draw_every=5):
            dbplot(np.sin([i / p1, i / p2]),
                   'unlim buffer',
                   plot_type=partial(MovingPointPlot))
            dbplot(np.sin([i / p1, i / p2]),
                   'lim buffer',
                   plot_type=partial(MovingPointPlot, buffer_len=20))
            dbplot(
                np.sin([i / p1, i / p2]),
                'resampling buffer',
                plot_type=partial(ResamplingLineHistory, buffer_len=20)
            )  # Only looks bad because of really small buffer length from testing.
Пример #17
0
def test_particular_plot(n_steps = 3):
    reset_dbplot()

    for i in xrange(n_steps):
        r = np.random.randn(1)
        dbplot(r, plot_type=partial(HistogramPlot,edges=np.linspace(-5, 5, 20)))
Пример #18
0
def test_list_of_images():
    reset_dbplot()
    for _ in xrange(2):
        dbplot([np.random.randn(12, 30), np.random.randn(10, 10), np.random.randn(15, 10)])
Пример #19
0
def test_moving_point_multiple_points():
    reset_dbplot()
    for i in xrange(5):
        dbplot(np.sin([i/10., i/15.]), 'unlim buffer', plot_type = partial(MovingPointPlot))
        dbplot(np.sin([i/10., i/15.]), 'lim buffer', plot_type = partial(MovingPointPlot,buffer_len=20))