本文整理汇总了Python中matrix2latex.matrix2latex函数的典型用法代码示例。如果您正苦于以下问题:Python matrix2latex函数的具体用法?Python matrix2latex怎么用?Python matrix2latex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了matrix2latex函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_none
def test_none():
m = [[1,None,None], [2,2,1], [2,1,2]]
t = matrix2latex(m)
assertEqual(t, "none")
m2 = [[1,float('NaN'),float('NaN')], [2,2,1], [2,1,2]]
t2 = matrix2latex(m)
assertEqual(t2, "none")
t3 = matrix2latex(m, format='$%d$')
assertEqual(t3, "none")
开发者ID:TheChymera,项目名称:matrix2latex,代码行数:11,代码来源:test.py
示例2: test_pandas_columns
def test_pandas_columns():
try:
import pandas as pd
import numpy as np
d = {'one' : pd.Series([1., 2., 3.], index=['a', 'b', 'c']),
'two' : pd.Series([1., 2., 3., 4.], index=['a', 'b', 'c', 'd'])}
df = pd.DataFrame(d)
t = matrix2latex(df)
# print 'pandas', t, df.to_records()
assertEqual(t, "pandas_columns")
t = matrix2latex(df, headerRow=None, headerColumn=None)
assertEqual(t, "pandas_columns_noHeaders")
except ImportError:
pass
开发者ID:TheChymera,项目名称:matrix2latex,代码行数:15,代码来源:test.py
示例3: test_pandas_series
def test_pandas_series():
try:
import pandas as pd
import numpy as np
s = pd.Series([2, 4, 2, 42, 5], index=['a', 'b', 'c', 'd', 'e'])
# print 'PANDAS\n', s
# print 'PANDAS\n', s.to_dict(), s.tolist(), hasattr(s, 'to_dict')
t = matrix2latex(s)
# print 'pandas Series', t
t2 = matrix2latex(pd.DataFrame(s))
# print 'pandas DataFrame', t2
assertEqual(t, "pandas_series")
assertEqual(t2, "pandas_series_dataFrame")
except ImportError:
pass
开发者ID:TheChymera,项目名称:matrix2latex,代码行数:15,代码来源:test.py
示例4: test_labels2
def test_labels2():
# only difference from above test is names, note how above function
# handles having too few headerRow
cl = ["a", "b"]
rl = ["names", "c", "d", "e"]
t = matrix2latex(m, None, headerColumn=cl, headerRow=rl)
assertEqual(t, "labels2")
开发者ID:TheChymera,项目名称:matrix2latex,代码行数:7,代码来源:test.py
示例5: test_labels3
def test_labels3():
# pass in environment as dictionary
e = dict()
e['headerColumn'] = ["a", "b"]
e['headerRow'] = ["names", "c", "d", "e"]
t = matrix2latex(m, None, **e)
assertEqual(t, "labels3")
开发者ID:TheChymera,项目名称:matrix2latex,代码行数:7,代码来源:test.py
示例6: test_infty1
def test_infty1():
try:
import numpy as np
m = [[1,np.inf,float('inf')], [2,2,float('-inf')], [-np.inf,1,2]]
t = matrix2latex(m)
assertEqual(t, "infty1")
except (ImportError, AttributeError):
pass
开发者ID:TheChymera,项目名称:matrix2latex,代码行数:8,代码来源:test.py
示例7: test_numpy
def test_numpy():
try:
import numpy as np
for a in (np.matrix, np.array):
t = matrix2latex(a(m), None, "align*", "pmatrix")
assertEqual(t, "numpy")
# Systems without numpy raises import error,
# pypy raises attribute since matrix is not implemented, this is ok.
except (ImportError, AttributeError):
pass
开发者ID:TheChymera,项目名称:matrix2latex,代码行数:10,代码来源:test.py
示例8: test_format_formatColumn_Warning
def test_format_formatColumn_Warning():
# Test for warning: http://stackoverflow.com/a/3892301/1942837
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always") # Cause all warnings to always be triggered.
# specify both format and formatColumn
t = matrix2latex([[123456e10, 123456e10]],
format='%g', formatColumn=['%.1g', '%g'])
assert len(w) == 1
assert issubclass(w[-1].category, Warning)
assertEqual(t, 'format_formatColumn_Warning')
开发者ID:TheChymera,项目名称:matrix2latex,代码行数:10,代码来源:test_syntaxError.py
示例9: test_pandas_dataframe
def test_pandas_dataframe():
try:
import pandas as pd
import numpy as np
m = [[1, 1], [2, 4], [3, 9]] # python nested list
m = pd.DataFrame(m)
#m = pd.DataFrame.from_csv('http://chymera.eu/data/test/r_data.csv', parse_dates=False, index_col=False)
# print 'PANDAS\n', m
# print 'PANDAS\n', m.to_records()
t = matrix2latex(m)
assertEqual(t, "pandas_dataframe")
except ImportError:
pass
开发者ID:TheChymera,项目名称:matrix2latex,代码行数:13,代码来源:test.py
示例10: tableEvtsAllRange
def tableEvtsAllRange(ch):
if ch == "Mu": channel = "muon"
else: channel = "electron"
n_2btag = evalNumEvts("lljjmass", ch)
print n_2btag
n_1btag = evalNumEvts("lljjmass_1btag", ch)
n_0btag = evalNumEvts("lljjmass_0btag", ch)
hr = [' ','0 b-tag yields', '1 b-tag yields','2 b-tag yields']
hc = ["Background"]
for m in masses:
hc.append(str(m)+" GeV")
numbers = []
numbers.append([ n_0btag["Background"], n_1btag["Background"], n_2btag["Background"] ])
for m in masses:
signal = "GluGluToHToZZTo2L2Q_M-"+str(m)+"_8TeV"
numbers.append([ n_0btag[signal], n_1btag[signal], n_2btag[signal]])
t = matrix2latex(numbers, "evtsAllRange_"+ch, headerColumn=hc, headerRow=hr, format='%.2f', alignment = '|c|c|c|',caption='List of expected background and signal yields in the '+channel+' channel with 1~fb$^{-1}$of data after all selection and within the $ZZ$ invariant mass range [0,1000]')
开发者ID:decosa,项目名称:H2l2qAnalysis,代码行数:18,代码来源:evtsNumbers.py
示例11: get_notes
def get_notes(self):
# get notes as a latex matrix
notes = self._get_notes()
# used by matrix2latex
# header row
hr = ['dataset', 'recipe', 'note']
# format column
fc = ['%s', '%s', '%s']
alignment = 'l l p{7.5cm}'
m = []
for note in notes:
txt = note.get('note')
txt = unicode(txt).encode('utf-8').replace('æ', '\\ae ').replace('å','\\aa ').replace('ø','\\o ')
m.append([note.get('dataset'), note.get('recipe_type'), txt])
caption = 'Comments to videos in questionnaire'
label = 'tab:notes'
t = matrix2latex(m, 'notes', headerRow=hr, caption=caption, label=label, formatColumn=fc, alignment=alignment)
return t
开发者ID:laugejepsen,项目名称:thesis,代码行数:20,代码来源:data_analysis.py
示例12: tableEvtsMassWind
def tableEvtsMassWind(var, ch):
if ch == "Mu": channel = "$2\mu2j$"
else: channel = "$2e2j$"
if var == "lljjmass": cat = "2 b-tag"
elif var == "lljjmass_1btag": cat = "1 b-tag"
else: cat = "0 b-tag"
hr = ['Mass [GeV]','Signal', '$Z$+Jets', '$tt$', 'ZZ/WZ/WW', 'TotalBkg']
hc = [str(m) for m in masses]
numbers = []
for m in masses:
nEvts = evalNumEvts(var, ch, m)
signal = "GluGluToHToZZTo2L2Q_M-"+str(m)+"_8TeV"
numbers.append([
nEvts[signal],
nEvts["DYJetsToLL_M-50"],
nEvts["TT"],
nEvts["ZZ/WZ/WW"],
nEvts["Background"]
])
t = matrix2latex(numbers, var+"_"+ch+"_evts", headerColumn=hc, headerRow=hr, format='%.2f', alignment = '|c|c|c|c|c|',caption='Expected yields of signal and background with 1~fb$^{-1}$ based on simulation in the '+cat+' category. The numbers show '+channel+' expectations. Tighter $mZZ$ mass requirements are applied as (-6\%, +\0\%) of the mass hypothesis.')
开发者ID:decosa,项目名称:H2l2qAnalysis,代码行数:24,代码来源:evtsNumbers.py
示例13: test_string
def test_string():
t = matrix2latex([['a', 'b', '1'], ['1', '2', '3']], format='%s')
assertEqual(t, "string")
开发者ID:TheChymera,项目名称:matrix2latex,代码行数:3,代码来源:test.py
示例14: test_infty2
def test_infty2():
# same as above but without numpy
inf = float('inf')
m = [[1,inf,float('inf')], [2,2,float('-inf')], [-inf,1,2]]
t = matrix2latex(m)
assertEqual(t, "infty1")
开发者ID:TheChymera,项目名称:matrix2latex,代码行数:6,代码来源:test.py
示例15: test_labels1
def test_labels1():
cl = ["a", "b"]
rl = ["c", "d", "e"]
t = matrix2latex(m, None, headerColumn=cl, headerRow=rl)
assertEqual(t, "labels1")
开发者ID:TheChymera,项目名称:matrix2latex,代码行数:5,代码来源:test.py
示例16: test_environment2
def test_environment2():
t = matrix2latex(m, None, "foo", "bar")
assertEqual(t, "environment2")
开发者ID:TheChymera,项目名称:matrix2latex,代码行数:3,代码来源:test.py
示例17: test_environment1
def test_environment1():
t = matrix2latex(m, None, "table", "center", "tabular")
assertEqual(t, "environment1")
开发者ID:TheChymera,项目名称:matrix2latex,代码行数:3,代码来源:test.py
示例18: test_nicefloat_4g
def test_nicefloat_4g():
t = matrix2latex([123456e-10, 1e-15, 12345e5], format='$%.4g$')
assertEqual(t, 'nicefloat_4g')
开发者ID:TheChymera,项目名称:matrix2latex,代码行数:3,代码来源:test.py
示例19: test_alignment2
def test_alignment2():
cl = ["a", "b"]
rl = ["names", "c", "d", "e"]
t = matrix2latex(m, alignment='r', headerColumn=cl, headerRow = rl)
t = t.split('\n')[2].strip()
assert t == r"\begin{tabular}{rrrr}", t
开发者ID:TheChymera,项目名称:matrix2latex,代码行数:6,代码来源:test.py
示例20: test_transpose1
def test_transpose1():
t = matrix2latex(m, transpose=True)
assertEqual(t, "transpose1")
开发者ID:TheChymera,项目名称:matrix2latex,代码行数:3,代码来源:test.py
注:本文中的matrix2latex.matrix2latex函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论