Skip to content

Commit

Permalink
improve error msg for plot coilis
Browse files Browse the repository at this point in the history
  • Loading branch information
dpanici committed Aug 16, 2024
1 parent 2646876 commit e39d08f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions desc/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -2384,6 +2384,8 @@ def plot_coils(coils, grid=None, fig=None, return_data=False, **kwargs):
dictionary of the data plotted, only returned if ``return_data=True``
"""
from desc.coils import _Coil

Check warning on line 2387 in desc/plotting.py

View check run for this annotation

Codecov / codecov/patch

desc/plotting.py#L2387

Added line #L2387 was not covered by tests

lw = kwargs.pop("lw", 5)
ls = kwargs.pop("ls", "solid")
figsize = kwargs.pop("figsize", (10, 10))
Expand All @@ -2394,6 +2396,12 @@ def plot_coils(coils, grid=None, fig=None, return_data=False, **kwargs):
ValueError,
f"plot_coils got unexpected keyword argument: {kwargs.keys()}",
)
errorif(

Check warning on line 2399 in desc/plotting.py

View check run for this annotation

Codecov / codecov/patch

desc/plotting.py#L2399

Added line #L2399 was not covered by tests
not isinstance(coils, _Coil),
ValueError,
"Expected `coils` to be object of type `_Coil`, instead got type"
f" {type(coils)}",
)

if not isinstance(lw, (list, tuple)):
lw = [lw]
Expand Down
2 changes: 2 additions & 0 deletions tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,8 @@ def test_plot_coils():
coil.rotate(angle=np.pi / N)
coils = CoilSet.linspaced_angular(coil, I, [0, 0, 1], np.pi / NFP, N // NFP // 2)
coils2 = MixedCoilSet.from_symmetry(coils, NFP, True)
with pytest.raises(ValueError, match="Expected `coils`"):
plot_coils("not a coil")
fig, data = plot_coils(coils2, return_data=True)

def flatten_coils(coilset):
Expand Down

0 comments on commit e39d08f

Please sign in to comment.