Skip to content

[CO] Improve error message when calling impossible plot #110

@BonneelP

Description

@BonneelP

Hello all,

While working on a validation case for pyleecan I had the following issue:
This PR Eomys/pyleecan#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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions