示例#1
0
def test_window_filter_logger_smoketest():
    set_recorder(value1=WindowFilterLogger(name="Value 1", filter_size=3))

    record(value1=1)
    record(value1=6)
    record(value1=-4)
    record(value1=5)
示例#2
0
def test_nonexisting_record():
    recorder_stub = RecorderStub()
    set_recorder(my_value=recorder_stub)

    record(other_value=42)

    assert recorder_stub.value == None
示例#3
0
def test_logger_smoketest():
    set_recorder(value1=Logger(name="Value 1"))
    set_recorder(value2=Logger(name="Value 2"))

    record(value1=1)
    record(value1=6)
    record(value1=-1)
    record(value2=0)
示例#4
0
def test_delegation_to_correct_record():
    my_recorder = RecorderStub()
    set_recorder(my_value=my_recorder)
    other_recorder = RecorderStub()
    set_recorder(other_value=other_recorder)

    record(my_value=42)

    assert my_recorder.value == 42
    assert other_recorder.value == None
示例#5
0
def test_lineplot_smoketest():
    # use backend which does not require a display for CI
    matplotlib.use("Agg")

    # all arguments
    set_recorder(
        value1=LinePlot(max_length=3, xlabel="Sample", ylabel="LinePlot"))

    # no arguments
    set_recorder(value2=LinePlot())

    set_recorder(value3=FilteredLinePlot(filter_size=3,
                                         max_length=7,
                                         xlabel="Sample",
                                         ylabel="FilteredLinePlot"))

    set_recorder(value3=DownsampledLinePlot(filter_size=3,
                                            max_length=7,
                                            xlabel="Sample",
                                            ylabel="DownsampledLinePlot"))

    random.seed(0)

    for _ in range(10):
        record(value1=random.random())
        record(value2=[random.random(), random.random()])
        record(value3=random.random())
        record(value4=random.random())
示例#6
0
def test_heatmap_smoketest():
    # use backend which does not require a display for CI
    matplotlib.use("Agg")

    # all arguments
    set_recorder(value1=Heatmap(xlabel="Sample", ylabel="Values 1", max_length=3))

    # no arguments
    set_recorder(value2=Heatmap())

    record(value1=[1, 9])
    record(value2=[42, 43, 44])
    record(value1=[3, 6])
    record(value2=[43, 44, 45])
    record(value1=[6, 3])
    record(value1=[9, 1])
    record(value1=[-1, 0])
示例#7
0
def run_example():
    # axis labels
    set_recorder(labeled=LinePlot(xlabel="Step", ylabel="Score"))

    # additional filtered values (window filter)
    set_recorder(filtered=FilteredLinePlot(filter_size=50, xlabel="(Filtered)"))

    # maximum history length
    set_recorder(detail=LinePlot(max_length=50, xlabel="(Detail)"))

    # downsampled values (record mean of every filter_size values)
    set_recorder(downsampled=DownsampledLinePlot(filter_size=5, xlabel="(Downsampled)"))

    # multiple curves for recording 1d-array values
    set_recorder(multiple=FilteredLinePlot(filter_size=50, xlabel="(Multiple)"))

    # heatmap for recording 1d-array values
    set_recorder(heatmap=Heatmap(xlabel="(Heatmap)"))

    # minimum update period (limit update rate for better performance)
    set_update_period(0.5)  # [seconds]

    # set number of columns
    set_num_columns(2)

    # example value generators
    score_gen = score_values()
    loss_gen = loss_values()
    multiple = array_values(3)
    heatmap = array_values(8)

    for _ in range(50):
        record(labeled=next(score_gen))
        for _ in range(20):
            loss = next(loss_gen)
            record(filtered=loss, downsampled=loss, detail=loss)
            record(multiple=next(multiple), heatmap=next(heatmap))
            time.sleep(0.01)
示例#8
0
def run_example():
    set_recorder(my_value=LinePlot())

    for _ in range(10):
        record(my_value=random())