Skip to content

Commit 75f3aef

Browse files
committed
add test for dt in arg and kwarg
1 parent b9dc8df commit 75f3aef

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

control/tests/xferfcn_test.py

+7
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ def test_constructor_nodt(self):
101101
sys = TransferFunction(sysin)
102102
assert sys.dt is None
103103

104+
def test_constructor_double_dt(self):
105+
"""Test that providing dt as arg and kwarg prefers arg with warning"""
106+
with pytest.warns(UserWarning, match="received multiple dt.*"
107+
"using positional arg"):
108+
sys = TransferFunction(1, [1, 2, 3], 0.1, dt=0.2)
109+
assert sys.dt == 0.1
110+
104111
def test_add_inconsistent_dimension(self):
105112
"""Add two transfer function matrices of different sizes."""
106113
sys1 = TransferFunction([[[1., 2.]]], [[[4., 5.]]])

control/xferfcn.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ def __init__(self, *args, **kwargs):
218218
elif len(args) == 3:
219219
# Discrete time transfer function
220220
if 'dt' in kwargs:
221-
warn('received multiple dt arguments, using positional arg dt=%s'%dt)
221+
warn('received multiple dt arguments, '
222+
'using positional arg dt=%s' % dt)
222223
elif len(args) == 1:
223224
# TODO: not sure this can ever happen since dt is always present
224225
try:

0 commit comments

Comments
 (0)