MCPcopy Index your code
hub / github.com/SLiCAP/SLiCAP_python / coeffsTransfer

Method coeffsTransfer

SLiCAP/SLiCAPlatex.py:662–718  ·  view source on GitHub ↗

Creates a tablestable that displays the numerator and denominator coefficients of a rational expression. If no label AND no caption are given this method returns a LaTeX tabular snippet. Else it returns a table snippet. :param stepVars: List with s

(self, transferCoeffs, label="", caption="", 
                       color="myyellow")

Source from the content-addressed store, hash-verified

660 return Snippet(TEX, self.format)
661
662 def coeffsTransfer(self, transferCoeffs, label="", caption="",
663 color="myyellow"):
664 """
665 Creates a tablestable that displays the numerator and denominator
666 coefficients of a rational expression.
667 If no label AND no caption are given this method returns a LaTeX
668 tabular snippet. Else it returns a table snippet.
669
670 :param stepVars: List with step variables (*str, sympy.Symbol*).
671 :type stepVars: list
672
673 :param stepArray: List with lists with step values for each step variable
674 :type stepArray: List
675
676 :param label: Reference label for the table. Defaults to an empty string.
677 :type label: str
678
679 :param caption: Table caption.
680 :type caption: str
681
682 :param color: Alternate row color name, should be defined in
683 'preambuleSLiCAP.tex' defaults to 'myyellow'. Use None for
684 no background color.
685 :type color: str
686
687 :return: SLiCAP Snippet object
688 :rtype: SLiCAP.SLiCAPprotos.Snippet
689
690 :example:
691
692 >>> import SLiCAP as sl
693 >>> import sympy as sp
694 >>>
695 >>> ltx = sl.LaTeXformatter()
696 >>> expr = sp.sympify("A_0*(1+s*b_1)/(((1+s*a_1))*((1+s*a_2)))")
697 >>> tr_coeffs = sl.coeffsTransfer(expr)
698 >>> ltx.coeffsTransfer(tr_coeffs,
699 label="tab-coeffs",
700 caption = "numerator and denominator " +
701 "coefficients").save("coeffs")
702 """
703 (gain, numerCoeffs, denomCoeffs) = transferCoeffs
704 num, den = gain.as_numer_denom()
705 for i in range(len(numerCoeffs)):
706 numerCoeffs[i] *= num
707 for i in range(len(denomCoeffs)):
708 denomCoeffs[i] *= den
709 alignstring = '[c]{ll}'
710 headerList = ['Coeff', 'Value']
711 linesList = []
712 for i in range(len(numerCoeffs)):
713 linesList.append([sp.sympify('b_' + str(i)), numerCoeffs[i]])
714 for i in range(len(denomCoeffs)):
715 linesList.append([sp.sympify('a_' + str(i)), denomCoeffs[i]])
716 TEX = _TEXcreateCSVtable(headerList, linesList, alignstring,
717 label=label, caption=caption, color=color)
718 return Snippet(TEX, self.format)
719

Callers

nothing calls this directly

Calls 2

SnippetClass · 0.90
_TEXcreateCSVtableFunction · 0.85

Tested by

no test coverage detected