Skip to content

Commit e2f971b

Browse files
committed
small updates to increase code coverage
1 parent 4ec3612 commit e2f971b

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

control/ctrlplot.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,9 @@ def pole_zero_subplots(
277277
from .grid import nogrid, sgrid, zgrid
278278
from .iosys import isctime
279279

280-
if rcParams is None:
281-
rcParams = _ctrlplot_rcParams
282-
283280
if fig is None:
284281
fig = plt.gcf()
282+
rcParams = config._get_param('ctrlplot', 'rcParams', rcParams)
285283

286284
if not isinstance(grid, list):
287285
grid = [grid] * nrows * ncols
@@ -525,8 +523,6 @@ def _update_plot_title(
525523
if fig is None:
526524
fig = plt.gcf()
527525
rcParams = config._get_param('ctrlplot', 'rcParams', kwargs, pop=True)
528-
if rcParams is None:
529-
rcParams = _ctrlplot_rcParams
530526

531527
if use_existing:
532528
# Get the current title, if it exists

control/tests/ctrlplot_test.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,10 @@ def test_deprecation_warnings():
771771
axs = ct.get_plot_axes(cplt.lines)
772772
assert np.all(axs == cplt.axes)
773773

774+
with pytest.warns(FutureWarning, match="deprecated"):
775+
ct.suptitle("updated title")
776+
assert cplt.figure._suptitle.get_text() == "updated title"
777+
774778

775779
def test_ControlPlot_init():
776780
sys = ct.rss(2, 2, 2)
@@ -782,6 +786,7 @@ def test_ControlPlot_init():
782786
assert np.all(cplt_raw.axes == cplt.axes)
783787
assert cplt_raw.figure == cplt.figure
784788

789+
785790
def test_pole_zero_subplots(savefig=False):
786791
ax_array = ct.pole_zero_subplots(2, 1, grid=[True, False])
787792
sys1 = ct.tf([1, 2], [1, 2, 3], name='sys1')
@@ -793,6 +798,16 @@ def test_pole_zero_subplots(savefig=False):
793798
if savefig:
794799
plt.savefig("ctrlplot-pole_zero_subplots.png")
795800

801+
# Single type of of grid for all axes
802+
ax_array = ct.pole_zero_subplots(2, 2, grid='empty')
803+
assert ax_array[0, 0].xaxis.get_label().get_text() == ''
804+
805+
# Discrete system grid
806+
ax_array = ct.pole_zero_subplots(2, 2, grid=True, dt=1)
807+
assert ax_array[0, 0].xaxis.get_label().get_text() == 'Real'
808+
assert ax_array[0, 0].get_lines()[0].get_color() == 'grey'
809+
810+
796811
if __name__ == "__main__":
797812
#
798813
# Interactive mode: generate plots for manual viewing

0 commit comments

Comments
 (0)