SciDataTool icon indicating copy to clipboard operation
SciDataTool copied to clipboard

[CO] Improve error message when calling impossible plot

Open BonneelP opened this issue 3 years ago • 0 comments

Hello all,

While working on a validation case for pyleecan I had the following issue: This PR https://github.com/Eomys/pyleecan/pull/529 introduces a new test "test_Bore_sym" in Tests/Validation/Magnetics/test_FEMM_periodicity.py where I compute the flux with/without angular sym. In both cases I set Nt_tot=1 and then I call (out of a copy/paste from another test with Nt_tot>1):

    out.mag.B.plot_2D_Data(
        "time",
        "angle[0]{°}",
        data_list=[out2.mag.B],
        legend_list=["Periodic", "Full"],
        save_path=join(save_path, simu.name + "_B_time.png"),
        is_show_fig=False,
        **dict_2D
    )

and I get the following error: image

I guess the error is that I'm calling a plot on an axis with a size one. If I increase Nt_tot=4, there is no error. So I think it is just a matter of adding a check and a clearer error message (the requested plot doesn't make sense).

From the same copy paste, I also had: image I'm requesting time[1] which doesn't exist, so we could also provide a dedicated error message for this case.

Best regards, Pierre

BonneelP avatar Jun 14 '22 08:06 BonneelP