def powerLawLatex(power, multFact=1, offset=0, pcov=None): offsetStr = smartFormat(offset, alwaysShowSign=True, **formatDic) if not (offsetStr[0] == "+" or offsetStr[0] == "-"): offsetStr = "+" + offsetStr latex = r"$" + smartFormat(multFact, **formatDic) + \ r" \cdot N^{" + smartFormat(power, **formatDic) + r"} " + \ offsetStr + \ r"$" return latex
def texTable(array, headings=None, tableFormat=None, numFormat=[(1,5)], precision=[5], nanSub=['---'], inftyThresh=[np.infty]): if not isinstance(array, np.ndarray): array = np.array(array) nRows = np.shape(array)[0] print nRows try: nCols = np.shape(array)[1] except: nCols = nRows nRows = 1 #-- Begin environment and specify centering, etc. for each col table = r"\begin{tabular}{" if tableFormat != None: table += tableFormat else: table += "c"*nCols table += r"}" + "\n" #-- Add headings if present if headings != None: table += r" & ".join(headings) else: table += r" & ".join([r"\ " for n in range(nCols)]) #-- Add horizontal line table += r" \\ \midrule" #-- Add table entries for rowN in range(nRows): table += "\n" + r" & ".join([smartFormat(array[rowN,colN]) for colN in range(nCols)]) table += r"\\ \addlinespace[5pt]" if headings == None: table += r" \midrule" + "\n" else: table += "\n" #-- Close out environment table += r"\end{tabular}" + "\n" return table
def expPowerLatex(expExponent, powerLawExp, multFact, pcov=None): latex = r"$" + smartFormat(multFact, **formatDic) + \ r"\cdot e^{" + smartFormat(expExponent, **formatDic) + \ r"\cdot N}\cdot N^{" + smartFormat(powerLawExp, **formatDic) + \ r"}$" return latex
def exponentialLatex(expExponent, multFact=1, pcov=None): latex = r"$" + smartFormat(multFact, **formatDic) + \ r"\cdot e^{" + smartFormat(expExponent, **formatDic) + \ r"\cdot N}$" return latex
def smart_ticks_formatter(value, index): return smartFormat(value, **sfmtargs)