Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add _repr_latex_ for Jupyter notebooks#276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
murrayrm merged 3 commits intopython-control:masterfromalchemyst:master
Apr 7, 2019
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletionscontrol/xferfcn.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -268,6 +268,45 @@ def __str__(self, var=None):
# represent as string, makes display work for IPython
__repr__ = __str__

def _repr_latex_(self, var=None):
"""LaTeX representation of the transfer function, for Jupyter notebook"""

mimo = self.inputs > 1 or self.outputs > 1

if var is None:
# ! TODO: replace with standard calls to lti functions
var = 's' if self.dt is None or self.dt == 0 else 'z'

out = ['$$']

if mimo:
out.append(r"\begin{bmatrix}")

for i in range(self.outputs):
for j in range(self.inputs):
# Convert the numerator and denominator polynomials to strings.
numstr = _tf_polynomial_to_string(self.num[i][j], var=var)
denstr = _tf_polynomial_to_string(self.den[i][j], var=var)

out += [r"\frac{", numstr, "}{", denstr, "}"]

if mimo and j < self.outputs - 1:
out.append("&")

if mimo:
out.append(r"\\")

if mimo:
out.append(r" \end{bmatrix}")

# See if this is a discrete time system with specific sampling time
if not (self.dt is None) and type(self.dt) != bool and self.dt > 0:
out += ["\quad dt = ", str(self.dt)]

out.append("$$")

return ''.join(out)

def __neg__(self):
"""Negate a transfer function."""

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp