Skip to content

Commit acaea54

Browse files
committed
@murrayrm suggested changes e.g change default_frequency_range to private
1 parent fa43785 commit acaea54

3 files changed

Lines changed: 11 additions & 17 deletions

File tree

control/bdalg.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
"""
5555

5656
import numpy as np
57-
from scipy.signal.ltisys import StateSpace
5857
from . import xferfcn as tf
5958
from . import statesp as ss
6059
from . import frdata as frd
@@ -175,7 +174,7 @@ def negate(sys):
175174
>>> sys2 = negate(sys1) # Same as sys2 = -sys1.
176175
177176
"""
178-
return -sys;
177+
return -sys
179178

180179
#! TODO: expand to allow sys2 default to work in MIMO case?
181180
def feedback(sys1, sys2=1, sign=-1):
@@ -281,10 +280,7 @@ def append(*sys):
281280
>>> sys = append(sys1, sys2)
282281
283282
"""
284-
if not isinstance(sys[0], StateSpace):
285-
s1 = ss._convert_to_statespace(sys[0])
286-
else:
287-
s1 = sys[0]
283+
s1 = ss._convert_to_statespace(sys[0])
288284
for s in sys[1:]:
289285
s1 = s1.append(s)
290286
return s1

control/freqplot.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def bode_plot(syslist, omega=None,
199199
omega_was_given = False # used do decide whether to include nyq. freq
200200
if omega_limits is None:
201201
# Select a default range if none is provided
202-
omega = default_frequency_range(syslist, Hz=Hz,
202+
omega = _default_frequency_range(syslist, Hz=Hz,
203203
number_of_samples=omega_num)
204204
else:
205205
omega_limits = np.asarray(omega_limits)
@@ -591,16 +591,14 @@ def nyquist_plot(syslist, omega=None, plot=True, omega_limits=None,
591591
if omega is None:
592592
if omega_limits is None:
593593
# Select a default range if none is provided
594-
omega = default_frequency_range(syslist, Hz=False,
594+
omega = _default_frequency_range(syslist, Hz=False,
595595
number_of_samples=omega_num)
596596
else:
597597
omega_limits = np.asarray(omega_limits)
598598
if len(omega_limits) != 2:
599599
raise ValueError("len(omega_limits) must be 2")
600-
if omega_num:
601-
num = omega_num
602-
else:
603-
num = config.defaults['freqplot.number_of_samples']
600+
num = \
601+
ct.config._get_param('freqplot','number_of_samples', omega_num)
604602
omega = np.logspace(np.log10(omega_limits[0]),
605603
np.log10(omega_limits[1]), num=num,
606604
endpoint=True)
@@ -717,7 +715,7 @@ def gangof4_plot(P, C, omega=None, **kwargs):
717715
# Select a default range if none is provided
718716
# TODO: This needs to be made more intelligent
719717
if omega is None:
720-
omega = default_frequency_range((P, C, S))
718+
omega = _default_frequency_range((P, C, S))
721719

722720
# Set up the axes with labels so that multiple calls to
723721
# gangof4_plot will superimpose the data. See details in bode_plot.
@@ -798,7 +796,7 @@ def gangof4_plot(P, C, omega=None, **kwargs):
798796
#
799797

800798
# Compute reasonable defaults for axes
801-
def default_frequency_range(syslist, Hz=None, number_of_samples=None,
799+
def _default_frequency_range(syslist, Hz=None, number_of_samples=None,
802800
feature_periphery_decades=None):
803801
"""Compute a reasonable default frequency range for frequency
804802
domain plots.
@@ -832,7 +830,7 @@ def default_frequency_range(syslist, Hz=None, number_of_samples=None,
832830
--------
833831
>>> from matlab import ss
834832
>>> sys = ss("1. -2; 3. -4", "5.; 7", "6. 8", "9.")
835-
>>> omega = default_frequency_range(sys)
833+
>>> omega = _default_frequency_range(sys)
836834
837835
"""
838836
# This code looks at the poles and zeros of all of the systems that

control/nichols.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
import numpy as np
5353
import matplotlib.pyplot as plt
5454
from .ctrlutil import unwrap
55-
from .freqplot import default_frequency_range
55+
from .freqplot import _default_frequency_range
5656
from . import config
5757

5858
__all__ = ['nichols_plot', 'nichols', 'nichols_grid']
@@ -91,7 +91,7 @@ def nichols_plot(sys_list, omega=None, grid=None):
9191

9292
# Select a default range if none is provided
9393
if omega is None:
94-
omega = default_frequency_range(sys_list)
94+
omega = _default_frequency_range(sys_list)
9595

9696
for sys in sys_list:
9797
# Get the magnitude and phase of the system

0 commit comments

Comments
 (0)