def test_plot_expected_2d(show_array_mock):
    arr = [1, 2, 3, 4]

    plot = SigPlot(arr)
    assert plot.inputs == [arr]

    with pytest.raises(ValueError):
        plot.plot(layer_type="2D")
def test_plot_3d(show_array_mock):
    arr = [[[1], [2], [3], [4]], [[5], [6], [7], [8]]]

    plot = SigPlot(arr)
    assert plot.inputs == [arr]

    subsize = len(arr[0])
    with pytest.raises(ValueError):
        plot.plot(layer_type="2D", subsize=subsize)
def test_plot_2d_no_subsize(show_array_mock):
    arr = [[1, 2, 3, 4], [5, 6, 7, 8]]

    plot = SigPlot(arr)
    assert plot.inputs == [arr]

    plot.plot(layer_type="2D")
    assert show_array_mock.call_count == 1
    assert show_array_mock.call_args[0] == (np.array(arr).flatten().tolist(), )
    assert show_array_mock.call_args[1] == {
        "layer_type": "2D",
        "subsize": len(arr[0])
    }
def test_plot_one_href(show_href_mock):
    href = "foo.tmp"
    plot = SigPlot(href)
    assert plot.inputs == [href]

    plot.plot()
    assert show_href_mock.call_count == 1
    assert show_href_mock.call_args[0] == ({
        "filename": href,
        "layerType": "1D"
    }, )
    assert show_href_mock.call_args[1] == {}
    assert plot.done
def test_plot_1d(show_array_mock):
    arr = np.array([1, 2, 3, 4])

    plot = SigPlot(arr)
    assert plot.inputs == [arr]

    plot.plot()
    assert show_array_mock.call_count == 1
    print(show_array_mock.call_args)
    assert show_array_mock.call_args[0] == (arr.tolist(), )
    assert show_array_mock.call_args[1] == {
        "layer_type": "1D",
        "subsize": None
    }
def test_plot_expected_2d_with_subsize(show_array_mock):
    arr = [1, 2, 3, 4]

    subsize = 2

    plot = SigPlot(arr)
    assert plot.inputs == [arr]

    plot.plot(layer_type="2D", subsize=subsize)
    assert show_array_mock.call_count == 1
    assert show_array_mock.call_args[0] == (np.array(arr).flatten().tolist(), )
    assert show_array_mock.call_args[1] == {
        "layer_type": "2D",
        "subsize": subsize
    }
def test_plot_two_href(show_href_mock):
    href1 = "foo.tmp"
    href2 = "sin.tmp"
    href = "|".join((href1, href2))
    plot = SigPlot(href)
    assert plot.inputs == [href1, href2]

    plot.plot()
    assert show_href_mock.call_count == 2
    args1, kwargs1 = show_href_mock.call_args_list[0]
    assert args1 == ({"filename": href1, "layerType": "1D"}, )
    assert kwargs1 == {}

    args2, kwargs2 = show_href_mock.call_args_list[1]
    assert args2 == ({"filename": href2, "layerType": "1D"}, )
    assert kwargs2 == {}
    assert plot.done
def test_plot_mixed(show_array_mock, show_href_mock):
    href = "foo.tmp"
    arr = [1, 2, 3, 4]

    plot = SigPlot(href, arr)
    assert plot.inputs == [href, arr]

    plot.plot()
    assert show_href_mock.call_count == 1
    assert show_array_mock.call_count == 1

    assert show_href_mock.call_args[0] == ({
        "filename": href,
        "layerType": "1D",
    }, )

    assert show_array_mock.call_args[0] == (arr, )
    assert show_array_mock.call_args[1] == {
        "layer_type": "1D",
        "subsize": None
    }