Skip to content

Commit c0f5b17

Browse files
committed
add params to sys_nl in repr_gallery; fix combine/split_tf outputs
1 parent b70c7fc commit c0f5b17

File tree

3 files changed

+43
-17
lines changed

3 files changed

+43
-17
lines changed

control/bdalg.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,12 @@ def combine_tf(tf_array, **kwargs):
557557
... [s / (s + 2)]],
558558
... name='G'
559559
... )
560-
<TransferFunction G: ['u[0]'] -> ['y[0]', 'y[1]']>
560+
TransferFunction(
561+
[[array([1])],
562+
[array([1, 0])]],
563+
[[array([1, 1])],
564+
[array([1, 2])]],
565+
name='G', outputs=2, inputs=1)
561566
562567
Combine NumPy arrays with transfer functions
563568
@@ -566,7 +571,14 @@ def combine_tf(tf_array, **kwargs):
566571
... [np.zeros((1, 2)), ct.tf([1], [1, 0])]],
567572
... name='G'
568573
... )
569-
<TransferFunction G: ['u[0]', 'u[1]', 'u[2]'] -> ['y[0]', 'y[1]', 'y[2]']>
574+
TransferFunction(
575+
[[array([1.]), array([0.]), array([0.])],
576+
[array([0.]), array([1.]), array([0.])],
577+
[array([0.]), array([0.]), array([1])]],
578+
[[array([1.]), array([1.]), array([1.])],
579+
[array([1.]), array([1.]), array([1.])],
580+
[array([1.]), array([1.]), array([1, 0])]],
581+
name='G', outputs=3, inputs=3)
570582
"""
571583
# Find common timebase or raise error
572584
dt_list = []
@@ -653,10 +665,21 @@ def split_tf(transfer_function):
653665
... name='G'
654666
... )
655667
>>> ct.split_tf(G)
656-
array([[<TransferFunction G: ['u[0]'] -> ['y[0]']>,
657-
<TransferFunction G: ['u[1]'] -> ['y[0]']>],
658-
[<TransferFunction G: ['u[0]'] -> ['y[1]']>,
659-
<TransferFunction G: ['u[1]'] -> ['y[1]']>]], dtype=object)
668+
array([[TransferFunction(
669+
array([87.8]),
670+
array([1, 1]),
671+
name='G', outputs=1, inputs=1), TransferFunction(
672+
array([-86.4]),
673+
array([1, 1]),
674+
name='G', outputs=1, inputs=1)],
675+
[TransferFunction(
676+
array([108.2]),
677+
array([1, 1]),
678+
name='G', outputs=1, inputs=1), TransferFunction(
679+
array([-109.6]),
680+
array([1, 1]),
681+
name='G', outputs=1, inputs=1)]],
682+
dtype=object)
660683
"""
661684
tf_split_lst = []
662685
for i_out in range(transfer_function.noutputs):

examples/repr_gallery.ipynb

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -411,9 +411,10 @@
411411
"Inputs (1): ['u[0]']\n",
412412
"Outputs (1): ['y[0]']\n",
413413
"States (2): ['x[0]', 'x[1]']\n",
414+
"Parameters: ['a', 'b']\n",
414415
"\n",
415-
"Update: <function nl_update at 0x14ddf1800>\n",
416-
"Output: <function nl_output at 0x14ddf18a0>\n",
416+
"Update: <function nl_update at 0x1258ed800>\n",
417+
"Output: <function nl_output at 0x1258ed8a0>\n",
417418
"----\n",
418419
"\n",
419420
"NonlinearIOSystem: sys_dnl, dt=0.1:\n",
@@ -424,8 +425,8 @@
424425
"States (2): ['x[0]', 'x[1]']\n",
425426
"dt = 0.1\n",
426427
"\n",
427-
"Update: <function dnl_update at 0x14ddf1940>\n",
428-
"Output: <function dnl_output at 0x14ddf19e0>\n",
428+
"Update: <function dnl_update at 0x1258ed940>\n",
429+
"Output: <function dnl_output at 0x1258ed9e0>\n",
429430
"----\n",
430431
"\n",
431432
"InterconnectedSystem: sys_ic, dt=0:\n",
@@ -495,8 +496,8 @@
495496
"Update: <bound method FlatSystem._flat_updfcn of <FlatSystem sys_fs: ['u[0]'] -> ['y[0]']>>\n",
496497
"Output: <bound method FlatSystem._flat_outfcn of <FlatSystem sys_fs: ['u[0]'] -> ['y[0]']>>\n",
497498
"\n",
498-
"Forward: <function fs_forward at 0x14ddf20c0>\n",
499-
"Reverse: <function fs_reverse at 0x14ddf2160>\n",
499+
"Forward: <function fs_forward at 0x1258ee0c0>\n",
500+
"Reverse: <function fs_reverse at 0x1258ee160>\n",
500501
"----\n",
501502
"\n",
502503
"FlatSystem: sys_fsnl, dt=0:\n",
@@ -506,11 +507,11 @@
506507
"Outputs (1): ['y[0]']\n",
507508
"States (2): ['x[0]', 'x[1]']\n",
508509
"\n",
509-
"Update: <function nl_update at 0x14ddf1800>\n",
510-
"Output: <function nl_output at 0x14ddf18a0>\n",
510+
"Update: <function nl_update at 0x1258ed800>\n",
511+
"Output: <function nl_output at 0x1258ed8a0>\n",
511512
"\n",
512-
"Forward: <function fs_forward at 0x14ddf20c0>\n",
513-
"Reverse: <function fs_reverse at 0x14ddf2160>\n",
513+
"Forward: <function fs_forward at 0x1258ee0c0>\n",
514+
"Reverse: <function fs_reverse at 0x1258ee160>\n",
514515
"----\n",
515516
"\n",
516517
"============================================================================\n",

examples/repr_gallery.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ def nl_update(t, x, u, params):
5050
def nl_output(t, x, u, params):
5151
return sys_ss.C @ x + sys_ss.D @ u
5252

53+
nl_params = {'a': 0, 'b': 1}
54+
5355
sys_nl = ct.nlsys(
54-
nl_update, nl_output, name='sys_nl',
56+
nl_update, nl_output, name='sys_nl', params=nl_params,
5557
states=sys_ss.nstates, inputs=sys_ss.ninputs, outputs=sys_ss.noutputs)
5658

5759
# Nonlinear system (with linear dynamics), discrete time

0 commit comments

Comments
 (0)