[英]Is there a sympy defaults file, like matplotlib has ~/matplotlib/.matplotlibrc?
Is there a sympy
defaults file, like matplotlib
has ~/matplotlib/.matplotlibrc
? 是否有一个
sympy
默认文件,例如matplotlib
具有~/matplotlib/.matplotlibrc
?
Presently, the default LaTeX output for the following code uses smallmatrix
, which is too small: 目前,以下代码的默认LaTeX输出使用
smallmatrix
,该值太小:
>>> mat = Matrix([[0 1], [1 0]])
>>> latex(mat)
\left[\begin{smallmatrix} ...
I would like it to use matrix
by default. 我希望它默认使用
matrix
。 For now, I do it with: 现在,我这样做:
>>> latex(mat, mat_str='matrix')
\left[\begin{matrix} ...
I would like to have the ability to set a default without having to use mat_str='matrix'
我想不必使用
mat_str='matrix'
即可设置默认值
You could always just write your own small wrapper to latex
您总是可以将自己的小包装纸写到
latex
def latex(*args, **kwargs):
kwargs.setdefault('mat_str', 'matrix')
sympy.latex(*args, **kwargs)
If you want to change the behavior of init_printing
, there's an open issue for it. 如果要更改
init_printing
的行为,则存在一个未解决的问题 。
Doesn't look like sympy reads any defaults files. 看起来sympy不会读取任何默认文件。 Matrices types are hardcoded in /sympy/printing/latex.py with the following comment:
矩阵类型在/sympy/printing/latex.py中进行硬编码,并带有以下注释:
mat_str: Which matrix environment string to emit.
mat_str:发出哪个矩阵环境字符串。 "smallmatrix", "matrix", "array", etc. Defaults to "smallmatrix" for inline mode, "matrix" for matrices of no more than 10 columns, and "array" otherwise.
“ smallmatrix”,“ matrix”,“ array”等。对于内联模式,默认为“ smallmatrix”,对于不超过10列的矩阵,默认为“ matrix”,否则为“ array”。
You can change hardecoded defaults by modifying the following fragment (currently at line 1169): 您可以通过修改以下片段(当前在1169行)来更改硬编码的默认值:
mat_str = self._settings['mat_str']
if mat_str is None:
if self._settings['mode'] == 'inline':
mat_str = 'smallmatrix'
else:
if (expr.cols <= 10) is True:
mat_str = 'matrix'
else:
mat_str = 'array'
Just replace 'smallmatrix' with 'matrix' and use mat_str parameter if you need to override it. 只需将“ smallmatrix”替换为“ matrix”,并在需要覆盖时使用mat_str参数即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.