def test_with_colors(): fig = Figure() assert fig.with_colors fig.with_colors = False assert not fig.with_colors with pytest.raises(ValueError): fig.with_colors = 1
def test_origin(): fig = Figure() assert fig.origin fig.origin = False assert not fig.origin with pytest.raises(ValueError): fig.origin = 1
def test_max_x(): fig = Figure() fig.with_colors = False fig.set_x_limits(max_=1) fig.plot([-1, -0.5, -0, 0.5, 1, 1.5], [-1, -0.5, -0, 0.5, 1, 1.5]) print(fig.show()) expected = ' | -1.200000 -0.925000 -0.650000 -0.375000 -0.100000 0.1750000 0.4500000 0.7250000 1 ' assert expected == fig.show().split('\n')[-1]
def test_min_max_x(): fig = Figure() fig.with_colors = False fig.set_x_limits(min_=0, max_=1) fig.plot([-1, -0.5, -0, 0.5, 1, 1.5], [-1, -0.5, -0, 0.5, 1, 1.5]) print(fig.show()) expected = ' | 0 0.1250000 0.2500000 0.3750000 0.5000000 0.6250000 0.7500000 0.8750000 1 ' assert expected == fig.show().split('\n')[-1]
def test_min_x(): fig = Figure() fig.with_colors = False fig.set_x_limits(min_=0) fig.plot([-1, -0.5, -0, 0.5, 1, 1.5], [-1, -0.5, -0, 0.5, 1, 1.5]) print(fig.show()) expected = ' | 0 0.2062500 0.4125000 0.6187500 0.8250000 1.0312500 1.2375000 1.4437500 1.6500000' assert expected == fig.show().split('\n')[-1]
def test_clear(): fig = Figure() assert fig._plots == [] fig.plot([0.1, 0.2], [0.1, 0.2]) fig.plot([0.1, 0.2], [0.1, 0.2]) fig.plot([0.1, 0.2], [0.1, 0.2]) assert len(fig._plots) == 3 fig.clear() assert fig._plots == [] fig.clear() assert fig._plots == []
def test_scatter(get_canvas): fig = Figure() fig.scatter([], []) assert len(fig._plots) == 0 fig.scatter([0.1, 0.2], [0.2, 0.3]) assert len(fig._plots) == 1 plot = fig._plots[0] assert isinstance(plot, Plot) assert plot.interp is None assert plot.lc == 'white' assert plot.width_vals() == [0.1, 0.2] assert plot.height_vals() == [0.2, 0.3] canvas = get_canvas() plot.write(canvas, with_colors=False, in_fmt=fig._in_fmt) assert canvas.point.call_count == 2 # two points assert canvas.point.call_args_list == [ call(0.1, 0.2, color=None), call(0.2, 0.3, color=None), ] assert canvas.line.call_count == 0 # scatter canvas = get_canvas() plot.write(canvas, with_colors=True, in_fmt=fig._in_fmt) assert canvas.point.call_count == 2 # two points assert canvas.point.call_args_list == [ call(0.1, 0.2, color=plot.lc), call(0.2, 0.3, color=plot.lc), ] assert canvas.line.call_count == 0 # scatter # different lc fig.scatter([0.1, 0.2], [0.2, 0.3]) assert len(fig._plots) == 2 plot2 = fig._plots[1] assert isinstance(plot2, Plot) assert plot2.lc == 'red' with pytest.raises(ValueError): fig.scatter([1, 2], [0])
def test_date_min_max_x(): fig = Figure() fig.with_colors = False day = orig_datetime.timedelta(days=1) now = orig_datetime.datetime(2018, 1, 16, 11, 9, 42, 100) x = [now + i * day for i in range(6)] fig.set_x_limits(min_=x[0], max_=x[-1]) fig.plot(x, [-1, -0.5, -0, 0.5, 1, 1.5]) print(fig.show()) expected = ' | 16T11:09 17T02:09 17T17:09 18T08:09 18T23:09 19T14:09 20T05:09 20T20:09 21T11:09 ' assert expected == fig.show().split('\n')[-1]
def test_min_max_y(): fig = Figure() fig.with_colors = False fig.set_y_limits(min_=0, max_=1) fig.plot([-1, -0.5, -0, 0.5, 1, 1.5], [-1, -0.5, -0, 0.5, 1, 1.5]) res = fig.show() print(res) assert res.split('\n')[1].startswith(' 1 |') assert res.split('\n')[-3].startswith(' 0 |')
def test_histogram(get_canvas, mocker): fig = Figure() fig.histogram([1, 1, 2, 3, 1], bins=3) assert len(fig._plots) == 1 hist = fig._plots[0] assert isinstance(hist, Histogram) assert hist.width_vals() == [1, 1, 2, 3, 1] assert hist.height_vals() == [3, 1, 1] # 3 x 1 assert hist.lc == 'white' canvas = get_canvas() canvas.dots_between = mocker.Mock(return_value=[1, 1]) canvas.xmin = 0 canvas.xmax = 5 hist.write(canvas, with_colors=False, in_fmt=fig._in_fmt) assert canvas.point.call_count == 0 assert canvas.line.call_count == 3 # 1 dot between 1 and 2
def test_date_min_max_y(): fig = Figure() fig.with_colors = False day = orig_datetime.timedelta(days=1) now = orig_datetime.datetime(2018, 1, 16, 11, 9, 42, 100) y = [now + i * day for i in range(6)] fig.set_y_limits(min_=y[0], max_=y[-1]) fig.plot([-1, -0.5, -0, 0.5, 1, 1.5], y) res = fig.show() print(res) assert res.split('\n')[1].startswith(' 21T11:09 |') assert res.split('\n')[-3].startswith(' 16T11:09 |')
def test_timehistogram_numpy(): fig = Figure() fig.with_colors = False day = np.timedelta64(1, 'D') now = np.datetime64('2018-01-16T11:09:42.000100') x = [now - i * day for i in range(10)] fig.histogram(x, bins=8) print(fig.show()) assert _histogram == fig.show()
def test_timehistogram_pendulum(): fig = Figure() fig.with_colors = False day = duration(days=1) now = datetime(2018, 1, 16, 11, 9, 42, 100) x = [now - i * day for i in range(10)] fig.histogram(x, bins=8) print(fig.show()) assert _histogram == fig.show()
def test_timehistogram_orig_dt(): fig = Figure() fig.with_colors = False day = orig_datetime.timedelta(days=1) now = orig_datetime.datetime(2018, 1, 16, 11, 9, 42, 100) x = [now - i * day for i in range(10)] fig.histogram(x, bins=8) print(fig.show()) assert _histogram == fig.show()
def test_timeseries_orig_dt(): fig = Figure() fig.with_colors = False day = orig_datetime.timedelta(days=1) now = orig_datetime.datetime(2018, 1, 16, 11, 9, 42, 100) x = [now - i * day for i in range(10)] x = list(reversed(x)) y = [0.5, -0.5, 0.5, -0.5, 0.5, -0.5, 0.5, -0.5, 0.5, -0.5] fig.plot(x, y) print(fig.show()) assert _timeseries == fig.show()
def test_color_mode(): fig = Figure() assert fig.color_mode == 'names' fig.color_mode = 'byte' assert fig.color_mode == 'byte' with pytest.raises(ValueError): fig.color_mode = 'rgba' with pytest.raises(ValueError): fig.color_mode = 15 fig.plot([0.5], [0.5]) with pytest.raises(RuntimeError): fig.color_mode = 'names'
def test_width(): fig = Figure() assert fig.width > 0 fig.width = 40 assert fig.width == 40 with pytest.raises(ValueError): fig.width = 0 with pytest.raises(ValueError): fig.width = -10 with pytest.raises(ValueError): fig.width = '40' res = fig.show().split('\n') assert all(len(r) > 40 and len(r) < 55 for r in res[2:-2])
def test_height(): fig = Figure() assert fig.height > 0 fig.height = 40 assert fig.height == 40 with pytest.raises(ValueError): fig.height = 0 with pytest.raises(ValueError): fig.height = -10 with pytest.raises(ValueError): fig.height = '40' res = fig.show().split('\n') assert len(res) > 40 assert len(res) < 45
def test_float_converter(): fig = Figure() fig.with_colors = False fig.width = 30 fig.height = 15 def _converter(v): return float(v) - 1 fig.register_float_converter(float, _converter) fig.register_float_converter(int, _converter) fig.plot(list(range(100)), [i % 20 for i in range(100)]) # axis are at the wrong position expected = """\ (Y) ^ 20.9000000 | 19.3800000 | ⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 17.8600000 | ⠀⠀⠀⡇⠀⠀⠀⣼⠀⠀⠀⠀⣼⠀⠀⠀⠀⣼⠀⠀⠀⠀⣼⠀⠀⠀⠀⡜⠀⠀ 16.3400000 | ⠀⠀⠀⡇⠀⠀⢀⢿⠀⠀⠀⢀⢿⠀⠀⠀⢀⢿⠀⠀⠀⢀⢿⠀⠀⠀⢀⠇⠀⠀ 14.8200000 | ⠀⠀⠀⡇⠀⠀⢸⢸⠀⠀⠀⢸⢸⠀⠀⠀⢸⢸⠀⠀⠀⢸⢸⠀⠀⠀⢸⠀⠀⠀ 13.3000000 | ⠀⠀⠀⡇⠀⠀⡇⢸⠀⠀⠀⡇⢸⠀⠀⠀⡇⢸⠀⠀⠀⡇⢸⠀⠀⠀⡇⠀⠀⠀ 11.7800000 | ⠀⠀⠀⡇⠀⢰⠁⢸⠀⠀⢰⠁⢸⠀⠀⢰⠁⢸⠀⠀⢰⠁⢸⠀⠀⢰⠁⠀⠀⠀ 10.2600000 | ⠀⠀⠀⡇⠀⡸⠀⢸⠀⠀⡸⠀⢸⠀⠀⡸⠀⢸⠀⠀⡸⠀⢸⠀⠀⡸⠀⠀⠀⠀ 8.74000000 | ⠀⠀⠀⡇⠀⡇⠀⢸⠀⠀⡇⠀⢸⠀⠀⡇⠀⢸⠀⠀⡇⠀⢸⠀⠀⡇⠀⠀⠀⠀ 7.22000000 | ⠀⠀⠀⡇⢸⠀⠀⢸⠀⢸⠀⠀⢸⠀⢸⠀⠀⢸⠀⢸⠀⠀⢸⠀⢸⠀⠀⠀⠀⠀ 5.70000000 | ⠀⠀⠀⡇⡎⠀⠀⢸⠀⡎⠀⠀⢸⠀⡎⠀⠀⢸⠀⡎⠀⠀⢸⠀⡎⠀⠀⠀⠀⠀ 4.18000000 | ⠀⠀⠀⣧⠃⠀⠀⢸⢠⠃⠀⠀⢸⢠⠃⠀⠀⢸⢠⠃⠀⠀⢸⢠⠃⠀⠀⠀⠀⠀ 2.66000000 | ⠀⠀⠀⣿⠀⠀⠀⢸⢸⠀⠀⠀⢸⢸⠀⠀⠀⢸⢸⠀⠀⠀⢸⢸⠀⠀⠀⠀⠀⠀ 1.14000000 | ⣀⣀⣀⣇⣀⣀⣀⣸⣇⣀⣀⣀⣸⣇⣀⣀⣀⣸⣇⣀⣀⣀⣸⣇⣀⣀⣀⣀⣀⣀ -0.3800000 | ⠀⠀⠰⡇⠀⠀⠀⠸⠁⠀⠀⠀⠸⠁⠀⠀⠀⠸⠁⠀⠀⠀⠸⠁⠀⠀⠀⠀⠀⠀ -1.9000000 | ⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -----------|-|---------|---------|---------|-> (X) | -9.900000 29.700000 69.300000 108.90000""" print(fig.show()) assert expected == fig.show()
def test_lbl_formatter(): fig = Figure() fig.with_colors = False fig.width = 30 fig.height = 15 def _num_formatter(val, chars, delta, left=False): align = '<' if left else '' return '{:{}{}d}'.format(int(val), align, chars) fig.register_label_formatter(float, _num_formatter) fig.register_label_formatter(int, _num_formatter) fig.plot(list(range(100)), [i % 20 for i in range(100)]) expected = """\ (Y) ^ 20 | 19 | ⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 17 | ⠀⠀⢸⠀⠀⠀⠀⣼⠀⠀⠀⠀⣼⠀⠀⠀⠀⣼⠀⠀⠀⠀⣼⠀⠀⠀⠀⡜⠀⠀ 16 | ⠀⠀⢸⠀⠀⠀⢀⢿⠀⠀⠀⢀⢿⠀⠀⠀⢀⢿⠀⠀⠀⢀⢿⠀⠀⠀⢀⠇⠀⠀ 14 | ⠀⠀⢸⠀⠀⠀⢸⢸⠀⠀⠀⢸⢸⠀⠀⠀⢸⢸⠀⠀⠀⢸⢸⠀⠀⠀⢸⠀⠀⠀ 13 | ⠀⠀⢸⠀⠀⠀⡇⢸⠀⠀⠀⡇⢸⠀⠀⠀⡇⢸⠀⠀⠀⡇⢸⠀⠀⠀⡇⠀⠀⠀ 11 | ⠀⠀⢸⠀⠀⢰⠁⢸⠀⠀⢰⠁⢸⠀⠀⢰⠁⢸⠀⠀⢰⠁⢸⠀⠀⢰⠁⠀⠀⠀ 10 | ⠀⠀⢸⠀⠀⡸⠀⢸⠀⠀⡸⠀⢸⠀⠀⡸⠀⢸⠀⠀⡸⠀⢸⠀⠀⡸⠀⠀⠀⠀ 8 | ⠀⠀⢸⠀⠀⡇⠀⢸⠀⠀⡇⠀⢸⠀⠀⡇⠀⢸⠀⠀⡇⠀⢸⠀⠀⡇⠀⠀⠀⠀ 7 | ⠀⠀⢸⠀⢸⠀⠀⢸⠀⢸⠀⠀⢸⠀⢸⠀⠀⢸⠀⢸⠀⠀⢸⠀⢸⠀⠀⠀⠀⠀ 5 | ⠀⠀⢸⠀⡎⠀⠀⢸⠀⡎⠀⠀⢸⠀⡎⠀⠀⢸⠀⡎⠀⠀⢸⠀⡎⠀⠀⠀⠀⠀ 4 | ⠀⠀⢸⢠⠃⠀⠀⢸⢠⠃⠀⠀⢸⢠⠃⠀⠀⢸⢠⠃⠀⠀⢸⢠⠃⠀⠀⠀⠀⠀ 2 | ⠀⠀⢸⢸⠀⠀⠀⢸⢸⠀⠀⠀⢸⢸⠀⠀⠀⢸⢸⠀⠀⠀⢸⢸⠀⠀⠀⠀⠀⠀ 1 | ⠀⠀⢸⡇⠀⠀⠀⢸⡇⠀⠀⠀⢸⡇⠀⠀⠀⢸⡇⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀ 0 | ⠤⠤⢼⠥⠤⠤⠤⠼⠥⠤⠤⠤⠼⠥⠤⠤⠤⠼⠥⠤⠤⠤⠼⠥⠤⠤⠤⠤⠤⠤ -1 | ⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -----------|-|---------|---------|---------|-> (X) | -9 29 69 108 """ print(fig.show()) assert expected == fig.show()
def test_show(): fig = Figure() fig.with_colors = False fig.histogram([1, 1, 2, 3, 1], bins=5) expected = """ (Y) ^ 3.30000000 | 3.21750000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 3.13500000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 3.05250000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 2.97000000 | ⠀⠀⠀⠀⠀⠀⢠⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 2.88750000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 2.80500000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 2.72250000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 2.64000000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 2.55750000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 2.47500000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 2.39250000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 2.31000000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 2.22750000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 2.14500000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 2.06250000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 1.98000000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 1.89750000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 1.81500000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 1.73250000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 1.65000000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 1.56750000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 1.48500000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 1.40250000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 1.32000000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 1.23750000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 1.15500000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 1.07250000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 0.99000000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⡀⠀⠀⠀⠀⠀⠀ 0.90750000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀ 0.82500000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀ 0.74250000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀ 0.66000000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀ 0.57750000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀ 0.49500000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀ 0.41250000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀ 0.33000000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀ 0.24750000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀ 0.16500000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀ 0.08250000 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀ 0 | ⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀⠀⠀⠀⠀⠀ -----------|-|---------|---------|---------|---------|---------|---------|---------|---------|-> (X) | 0.8000000 1.1000000 1.4000000 1.7000000 2 2.3000000 2.6000000 2.9000000 3.2000000""" print(fig.show()) # no legend, no origin assert expected == fig.show() assert fig.show(legend=True) == expected + '\n\nLegend:\n-------\n' # no label for histograms fig.clear() fig.plot([-0.1, 0.2], [-0.2, 0.3]) expected = """ (Y) ^ 0.35000000 | 0.33500000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 0.32000000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 0.30500000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 0.29000000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀ 0.27500000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀ 0.26000000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 0.24500000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 0.23000000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 0.21500000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 0.20000000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 0.18500000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 0.17000000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 0.15500000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 0.14000000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 0.12500000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 0.11000000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 0.09500000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 0.08000000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 0.06500000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 0.05000000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 0.03500000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 0.02000000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ 0.00500000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -0.0100000 | ⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⡏⠉⠉⡩⠋⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉ -0.0250000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -0.0400000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -0.0550000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -0.0700000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -0.0850000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -0.1000000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -0.1150000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -0.1300000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -0.1450000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -0.1600000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -0.1750000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -0.1900000 | ⠀⠀⠀⠀⠀⠀⠀⠀⡠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -0.2050000 | ⠀⠀⠀⠀⠀⠀⠠⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -0.2200000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -0.2350000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -0.2500000 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ -----------|-|---------|---------|---------|---------|---------|---------|---------|---------|-> (X) | -0.130000 -0.085000 -0.040000 0.0050000 0.0500000 0.0950000 0.1400000 0.1850000 0.2300000""" print(fig.show()) assert expected == fig.show() # no legend, origin assert fig.show(legend=True) == expected + '\n\nLegend:\n-------\n⠤⠤ Label 0' # no label for histograms
def create_chart(scriptpath, args): timerange = str(args.dayrange) interval = "" filename = scriptpath + timerange + "range_" + interval + "interval.json" urllib3.disable_warnings() if not path.isfile(filename) or ( time() - path.getmtime(filename)) / 60 > 15 or args.force: url = "https://bitcoincharts.com/charts/chart.json?m=bitstampUSD&SubmitButton=Draw&r={0}&i={1}"\ .format(timerange, interval) with open(filename, "w") as file: dump(requests.get(url, verify=False).json(), file) with open(filename, "r") as file: response = load(file) zipped = list(zip(*response)) timestamps = zipped[0] weighted = zipped[7] openprice = weighted[0] closeprice = weighted[-1] change = (closeprice - openprice) / openprice if change > 0: color = custom_text_color((38, 200, 0)) else: color = custom_text_color((255, 43, 0)) print(f'Current price: ${closeprice:.2f}, {color}{change:.2%}{ENDC}') if args.log: weighted = [log(i) for i in weighted] fig = Figure() fig.width = int(args.width) fig.height = int(args.height) fig.x_axis_round = 2 fig.set_x_limits(min_=min(timestamps), max_=max(timestamps)) fig.set_y_limits(min_=min(weighted), max_=max(weighted)) fig.y_label = "USD/BTC" fig.color_mode = 'byte' fig.y_axis_transform = lambda x: "${:,.2f}".format(x) if args.log: fig.y_axis_transform = lambda x: "${:,.2f}".format(exp(x)) fig.x_axis_transform = lambda x: '{:%m-%d-%y}'.format( datetime.fromtimestamp(x)) fig.plot(timestamps, weighted, lc=2, label="Bitcoin price") print(fig.show(legend=True)) print('Data provided by bitcoincharts [{0}]'.format( "http://bitcoincharts.com/")) print('Last Updated {:.2} minutes ago'.format( (time() - path.getmtime(filename)) / 60))
def limits(get_limits, set_limits): fig = Figure() assert get_limits(fig) == (0, 1) set_limits(fig, min_=0.5) assert get_limits(fig) == (0.5, 1) set_limits(fig) # resetting set_limits(fig, max_=0.5) assert get_limits(fig) == (0, 0.5) set_limits(fig) # resetting set_limits(fig, min_=0.5) set_limits(fig, max_=1.5) assert get_limits(fig) == (0.5, 1.5) set_limits(fig, min_=-2, max_=3.5) assert get_limits(fig) == (-2, 3.5) with pytest.raises(ValueError): set_limits(fig, min_=20, max_=3.5) set_limits(fig) # resetting set_limits(fig, max_=1.5) with pytest.raises(ValueError): set_limits(fig, min_=20) set_limits(fig) # resetting set_limits(fig, min_=1.5) with pytest.raises(ValueError): set_limits(fig, max_=-20) set_limits(fig) # resetting set_limits(fig, min_=1.5) assert get_limits(fig) == (1.5, 2.5) # min over default max -> max = min + 1 set_limits(fig) # resetting set_limits(fig, max_=-1.5) assert get_limits(fig) == (-2.5, -1.5) # max smaller than default min -> min = max - 1 fig.clear() fig.plot([0], [0]) set_limits(fig) # resetting assert get_limits(fig) == (-0.5, 0.5) # both min, max same, and 0 => +- 0.5 fig.clear() fig.plot([0.5], [0.5]) set_limits(fig) # resetting assert get_limits(fig) == (pytest.approx(0.45), pytest.approx(0.55)) # both min, max same, but not 0 => +-10% fig.clear() fig.plot([0.1, 0.2], [0.1, 0.2]) set_limits(fig) # resetting assert get_limits(fig) == (pytest.approx(0.09), pytest.approx(0.21)) # diff 0.1 => +-10% set_limits(fig, min_=0) assert get_limits(fig) == (0, pytest.approx(0.22)) # diff 0.2 => +10% set_limits(fig, max_=2) assert get_limits(fig) == (0, 2) # min/max set set_limits(fig) # resetting set_limits(fig, max_=2) assert get_limits(fig) == (pytest.approx(-0.09), 2) # diff 1.9 => -10% set_limits(fig) # resetting set_limits(fig, max_=0) # below value min assert get_limits(fig) == (-1, 0) # have a valid window below graph set_limits(fig) # resetting set_limits(fig, min_=1) # above value max assert get_limits(fig) == (1, 2) # have a valid window above graph
def plot_ram(self, show_legend=False) -> str: """ Creates a str with a histogram that can be printed to the command line. :param show_legend: Shows a legend :return: str """ ram = [ ram.size_update / 1000 # convert to MB for ram in self.image_size_events ] dates = [ram.time_stamp for ram in self.image_size_events] if len(ram) == 0: return "" # No memory usage detected if len(ram) == 1: return str(f"Single memory update found:\n" f"Memory usage on the {dates[0]} " f"was updated to {ram[0]} MB\n") # else fig = Figure() fig.y_ticks_fkt = lambda x, y: self.mean_y_value(ram, x, y) fig.width = 55 fig.height = 15 fig.set_x_limits(min_=min(dates)) min_ram = int(min(ram)) # raises error if not casted fig.set_y_limits(min_=min_ram) fig.y_label = "Usage [MB]" fig.x_label = "Time" # this will use the self written function _ # num_formatter, to convert the y-label to int values fig.register_label_formatter(float, _int_formatter) fig.plot(dates, ram, lc='green', label="Continuous Graph") fig.scatter(dates, ram, lc='red', label="Single Values") return fig.show(legend=show_legend)
def analyze(self, log_files: list_of_logs) -> log_inf_list: """ Analyze the given log files one by one. :param log_files: list of valid HTCondor log files :return: list with information of each log file """ logging.info('Starting the analyze mode') if not log_files: raise_value_error("No files to analyze") result_list = list() # create progressbar, do not redirect output with Progress(transient=True, redirect_stdout=False, redirect_stderr=False) as progress: task = progress.add_task("Analysing...", total=len(log_files)) for file in log_files: progress.update(task, advance=1) result_dict = dict() logging.debug(f"Analysing the HTCondor log file: {file}") msg = f"[green]Job analysis of: {file}[/green]" result_dict["description"] = msg job_dict, res_dict, time_dict, \ ram_history, occurred_errors = self.log_to_dict(file) if job_dict: result_dict["execution-details"] = job_dict if time_dict: result_dict["times"] = time_dict if res_dict: result_dict["all-resources"] = \ self.manage_thresholds(res_dict) # show HTCondor errors if occurred_errors: result_dict["errors"] = occurred_errors # managing the ram history if ram_history: ram = np.array(ram_history.get('Image size updates')) dates = np.array(ram_history.get('Dates')) if ram_history and len(ram) > 1: fig = Figure() fig.width = 55 fig.height = 15 fig.set_x_limits(min_=min(dates)) min_ram = int(min(ram)) # raises error if not casted fig.set_y_limits(min_=min_ram) fig.y_label = "Usage" fig.x_label = "Time" # this will use the self written function _ # num_formatter, to convert the y-label to int values fig.register_label_formatter(float, _int_formatter) fig.plot(dates, ram, lc='green', label="Continuous Graph") fig.scatter(dates, ram, lc='red', label="Single Values") result_dict["ram-history"] = fig.show( legend=self.show_legend) elif ram_history: msg = f"Single memory update found:\n" \ f"Memory usage on the {dates[0]} " \ f"was updatet to {ram[0]} MB" result_dict["ram-history"] = msg if self.show_list: job_spec_id = self.get_job_spec_id(file) if 'htc-err' in self.show_list: result_dict['htc-err'] = self.htcondor_stderr( job_spec_id + self.ext_err) if 'htc-out' in self.show_list: result_dict['htc-out'] = self.htcondor_stdout( job_spec_id + self.ext_out) result_list.append(result_dict) return result_list