Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error msg for plot coils when non-coil object is passed in #1198

Merged
merged 4 commits into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion desc/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

from desc.backend import sign
from desc.basis import fourier, zernike_radial_poly
from desc.coils import CoilSet
from desc.coils import CoilSet, _Coil
from desc.compute import data_index, get_transforms
from desc.compute.utils import _parse_parameterization, surface_averages_map
from desc.equilibrium.coords import map_coordinates
Expand Down Expand Up @@ -2394,6 +2394,11 @@
ValueError,
f"plot_coils got unexpected keyword argument: {kwargs.keys()}",
)
errorif(

Check warning on line 2397 in desc/plotting.py

View check run for this annotation

Codecov / codecov/patch

desc/plotting.py#L2397

Added line #L2397 was not covered by tests
not isinstance(coils, _Coil),
ValueError,
"Expected `coils` to be 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
Loading