@@ -164,7 +164,7 @@ def parallel(sys1, *sysn, **kwargs):
164164 or `y`). See :class:`InputOutputSystem` for more information.
165165 states : str, or list of str, optional
166166 List of names for system states. If not given, state names will be
167- of of the form `x[i]` for interconnections of linear systems or
167+ of the form `x[i]` for interconnections of linear systems or
168168 '<subsys_name>.<state_name>' for interconnected nonlinear systems.
169169 name : string, optional
170170 System name (used for specifying signals). If unspecified, a generic
@@ -512,7 +512,7 @@ def connect(sys, Q, inputv, outputv):
512512
513513 return Ytrim * sys * Utrim
514514
515- def combine_tf (tf_array ):
515+ def combine_tf (tf_array , ** kwargs ):
516516 """Combine array-like of transfer functions into MIMO transfer function.
517517
518518 Parameters
@@ -528,6 +528,16 @@ def combine_tf(tf_array):
528528 TransferFunction
529529 Transfer matrix represented as a single MIMO TransferFunction object.
530530
531+ Other Parameters
532+ ----------------
533+ inputs, outputs : str, or list of str, optional
534+ List of strings that name the individual signals. If not given,
535+ signal names will be of the form `s[i]` (where `s` is one of `u`,
536+ or `y`). See :class:`InputOutputSystem` for more information.
537+ name : string, optional
538+ System name (used for specifying signals). If unspecified, a generic
539+ name <sys[id]> is generated with a unique integer id.
540+
531541 Raises
532542 ------
533543 ValueError
@@ -542,20 +552,34 @@ def combine_tf(tf_array):
542552 --------
543553 Combine two transfer functions
544554
545- >>> s = ct.TransferFunction.s
546- >>> ct.combine_tf([
547- ... [1 / (s + 1)],
548- ... [s / (s + 2)],
549- ... ])
550- TransferFunction([[array([1])], [array([1, 0])]], [[array([1, 1])], [array([1, 2])]])
555+ >>> s = ct.tf('s')
556+ >>> ct.combine_tf(
557+ ... [[1 / (s + 1)],
558+ ... [s / (s + 2)]],
559+ ... name='G'
560+ ... )
561+ TransferFunction(
562+ [[array([1])],
563+ [array([1, 0])]],
564+ [[array([1, 1])],
565+ [array([1, 2])]],
566+ name='G', outputs=2, inputs=1)
551567
552568 Combine NumPy arrays with transfer functions
553569
554- >>> ct.combine_tf([
555- ... [np.eye(2), np.zeros((2, 1))],
556- ... [np.zeros((1, 2)), ct.TransferFunction([1], [1, 0])],
557- ... ])
558- TransferFunction([[array([1.]), array([0.]), array([0.])], [array([0.]), array([1.]), array([0.])], [array([0.]), array([0.]), array([1])]], [[array([1.]), array([1.]), array([1.])], [array([1.]), array([1.]), array([1.])], [array([1.]), array([1.]), array([1, 0])]])
570+ >>> ct.combine_tf(
571+ ... [[np.eye(2), np.zeros((2, 1))],
572+ ... [np.zeros((1, 2)), ct.tf([1], [1, 0])]],
573+ ... name='G'
574+ ... )
575+ TransferFunction(
576+ [[array([1.]), array([0.]), array([0.])],
577+ [array([0.]), array([1.]), array([0.])],
578+ [array([0.]), array([0.]), array([1])]],
579+ [[array([1.]), array([1.]), array([1.])],
580+ [array([1.]), array([1.]), array([1.])],
581+ [array([1.]), array([1.]), array([1, 0])]],
582+ name='G', outputs=3, inputs=3)
559583 """
560584 # Find common timebase or raise error
561585 dt_list = []
@@ -595,8 +619,8 @@ def combine_tf(tf_array):
595619 f"row { row_index } ."
596620 )
597621 for j_in in range (col .ninputs ):
598- num_row .append (col .num [j_out ][ j_in ])
599- den_row .append (col .den [j_out ][ j_in ])
622+ num_row .append (col .num_array [j_out , j_in ])
623+ den_row .append (col .den_array [j_out , j_in ])
600624 num .append (num_row )
601625 den .append (den_row )
602626 for row_index , row in enumerate (num ):
@@ -611,10 +635,14 @@ def combine_tf(tf_array):
611635 "Mismatched number transfer function inputs in row "
612636 f"{ row_index } of denominator."
613637 )
614- return tf .TransferFunction (num , den , dt = dt )
638+ return tf .TransferFunction (num , den , dt = dt , ** kwargs )
639+
615640
616641def split_tf (transfer_function ):
617- """Split MIMO transfer function into NumPy array of SISO tranfer functions.
642+ """Split MIMO transfer function into NumPy array of SISO transfer functions.
643+
644+ System and signal names for the array of SISO transfer functions are
645+ copied from the MIMO system.
618646
619647 Parameters
620648 ----------
@@ -630,31 +658,42 @@ def split_tf(transfer_function):
630658 --------
631659 Split a MIMO transfer function
632660
633- >>> G = ct.TransferFunction(
634- ... [
635- ... [[87.8], [-86.4]],
636- ... [[108.2], [-109.6]],
637- ... ],
638- ... [
639- ... [[1, 1], [1, 1]],
640- ... [[1, 1], [1, 1]],
641- ... ],
661+ >>> G = ct.tf(
662+ ... [ [[87.8], [-86.4]],
663+ ... [[108.2], [-109.6]] ],
664+ ... [ [[1, 1], [1, 1]],
665+ ... [[1, 1], [1, 1]], ],
666+ ... name='G'
642667 ... )
643668 >>> ct.split_tf(G)
644- array([[TransferFunction(array([87.8]), array([1, 1])),
645- TransferFunction(array([-86.4]), array([1, 1]))],
646- [TransferFunction(array([108.2]), array([1, 1])),
647- TransferFunction(array([-109.6]), array([1, 1]))]], dtype=object)
669+ array([[TransferFunction(
670+ array([87.8]),
671+ array([1, 1]),
672+ name='G', outputs=1, inputs=1), TransferFunction(
673+ array([-86.4]),
674+ array([1, 1]),
675+ name='G', outputs=1, inputs=1)],
676+ [TransferFunction(
677+ array([108.2]),
678+ array([1, 1]),
679+ name='G', outputs=1, inputs=1), TransferFunction(
680+ array([-109.6]),
681+ array([1, 1]),
682+ name='G', outputs=1, inputs=1)]],
683+ dtype=object)
648684 """
649685 tf_split_lst = []
650686 for i_out in range (transfer_function .noutputs ):
651687 row = []
652688 for i_in in range (transfer_function .ninputs ):
653689 row .append (
654690 tf .TransferFunction (
655- transfer_function .num [i_out ][ i_in ],
656- transfer_function .den [i_out ][ i_in ],
691+ transfer_function .num_array [i_out , i_in ],
692+ transfer_function .den_array [i_out , i_in ],
657693 dt = transfer_function .dt ,
694+ inputs = transfer_function .input_labels [i_in ],
695+ outputs = transfer_function .output_labels [i_out ],
696+ name = transfer_function .name
658697 )
659698 )
660699 tf_split_lst .append (row )
0 commit comments