Skip to content

Commit

Permalink
rename plot flags in plot2D and add deprecation warning (#2885)
Browse files Browse the repository at this point in the history
  • Loading branch information
oskooi authored Aug 22, 2024
1 parent bea1b20 commit aed9c6a
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 16 deletions.
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

0 comments on commit aed9c6a

Please sign in to comment.