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

Rename plot flags in plot2D and add deprecation warning #2885

Merged
merged 1 commit into from
Aug 22, 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
16 changes: 8 additions & 8 deletions python/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4757,10 +4757,10 @@ def plot2D(
field_parameters: Optional[dict] = None,
colorbar_parameters: Optional[dict] = None,
frequency: Optional[float] = None,
plot_eps_flag: bool = True,
plot_sources_flag: bool = True,
plot_monitors_flag: bool = True,
plot_boundaries_flag: bool = True,
show_epsilon: bool = True,
show_sources: bool = True,
show_monitors: bool = True,
show_boundary_layers: bool = True,
nb: bool = False,
**kwargs,
) -> None:
Expand Down Expand Up @@ -4886,10 +4886,10 @@ def plot2D(
field_parameters=field_parameters,
colorbar_parameters=colorbar_parameters,
frequency=frequency,
plot_eps_flag=plot_eps_flag,
plot_sources_flag=plot_sources_flag,
plot_monitors_flag=plot_monitors_flag,
plot_boundaries_flag=plot_boundaries_flag,
show_epsilon=show_epsilon,
show_sources=show_sources,
show_monitors=show_monitors,
show_boundary_layers=show_boundary_layers,
nb=nb,
**kwargs,
)
Expand Down
39 changes: 31 additions & 8 deletions python/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -953,13 +953,36 @@ def plot2D(
field_parameters: Optional[dict] = None,
colorbar_parameters: Optional[dict] = None,
frequency: Optional[float] = None,
plot_eps_flag: bool = True,
plot_sources_flag: bool = True,
plot_monitors_flag: bool = True,
plot_boundaries_flag: bool = True,
show_epsilon: bool = True,
show_sources: bool = True,
show_monitors: bool = True,
show_boundary_layers: bool = True,
nb: bool = False,
**kwargs
) -> Axes:

plot_eps_flag = kwargs.get("plot_eps_flag")
if plot_eps_flag:
warnings.warn("plot_eps_flag is deprecated. Use show_epsilon instead.")
show_epsilon = plot_eps_flag

plot_sources_flag = kwargs.get("plot_sources_flag")
if plot_sources_flag:
warnings.warn("plot_sources_flag is deprecated. " "Use show_sources instead.")
show_sources = plot_sources_flag

plot_monitors_flag = kwargs.get("plot_monitors_flag")
if plot_monitors_flag:
warnings.warn("plot_monitors_flag is deprecated. Use show_monitors " "instead.")
show_monitors = plot_monitors_flag

plot_boundaries_flag = kwargs.get("plot_boundaries_flag")
if plot_boundaries_flag:
warnings.warn(
"plot_boundaries_flag is deprecated. Use " "show_boundary_layers instead."
)
show_boundary_layers = plot_monitors_flag

# Ensure a figure axis exists
if ax is None and mp.am_master():
from matplotlib import pyplot as plt
Expand All @@ -980,7 +1003,7 @@ def plot2D(
)

# Plot geometry
if plot_eps_flag:
if show_epsilon:
ax = plot_eps(
sim,
ax,
Expand All @@ -992,7 +1015,7 @@ def plot2D(
)

# Plot boundaries
if plot_boundaries_flag:
if show_boundary_layers:
ax = plot_boundaries(
sim,
ax,
Expand All @@ -1001,7 +1024,7 @@ def plot2D(
)

# Plot sources
if plot_sources_flag:
if show_sources:
ax = plot_sources(
sim,
ax,
Expand All @@ -1011,7 +1034,7 @@ def plot2D(
)

# Plot monitors
if plot_monitors_flag:
if show_monitors:
ax = plot_monitors(
sim,
ax,
Expand Down