@@ -272,38 +272,40 @@ def _repr_latex_(self, var=None):
272272 """LaTeX representation of the transfer function, for Jupyter notebook"""
273273
274274 mimo = self .inputs > 1 or self .outputs > 1
275+
275276 if var is None :
276277 # ! TODO: replace with standard calls to lti functions
277278 var = 's' if self .dt is None or self .dt == 0 else 'z'
278279
280+ out = ['$$' ]
281+
279282 if mimo :
280- outstr = r"$$\begin{bmatrix}"
281- else :
282- outstr = "$$"
283+ out .append (r"\begin{bmatrix}" )
283284
284285 for i in range (self .outputs ):
285286 for j in range (self .inputs ):
286287 # Convert the numerator and denominator polynomials to strings.
287288 numstr = _tf_polynomial_to_string (self .num [i ][j ], var = var )
288289 denstr = _tf_polynomial_to_string (self .den [i ][j ], var = var )
289290
291+ out += [r"\frac{" , numstr , "}{" , denstr , "}" ]
290292
291- outstr += r"\frac{" + numstr + "}{" + denstr + "}"
292293 if mimo and j < self .outputs - 1 :
293- outstr += "&"
294+ out .append ("&" )
295+
294296 if mimo :
295- outstr += r"\\ "
297+ out . append ( r"\\" )
296298
297299 if mimo :
298- outstr += r" \end{bmatrix}"
300+ out . append ( r" \end{bmatrix}")
299301
300302 # See if this is a discrete time system with specific sampling time
301303 if not (self .dt is None ) and type (self .dt ) != bool and self .dt > 0 :
302- outstr += "\quad dt = " + self .dt . __str__ ()
304+ out += [ "\quad dt = " , str ( self .dt )]
303305
304- outstr += "$$"
306+ out . append ( "$$" )
305307
306- return outstr
308+ return '' . join ( out )
307309
308310 def __neg__ (self ):
309311 """Negate a transfer function."""
0 commit comments