简体   繁体   English

是否有一个sympy默认文件,例如matplotlib具有〜/ matplotlib / .matplotlibrc?

[英]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.

相关问题 matplotlib 在 IPython 中不使用 matplotlibrc 文件 - matplotlib not using matplotlibrc file in IPython matplotlib 找不到配置文件 matplotlibrc - matplotlib cannot find configuration file matplotlibrc Matplotlib:有没有办法用 matplotlibrc 设置默认散布 styles? - Matplotlib: Is there a way to set default scatter styles with matplotlibrc? Pyinstaller Matplotlib [Errno 2] 没有这样的文件或目录:'C:\\Users\\Tobi\\AppData\\Local\\Temp\\_MEI142562\\matplotlib\\mpl-data\\matplotlibrc' - Pyinstaller Matplotlib [Errno 2] No such file or directory: 'C:\\Users\\Tobi\\AppData\\Local\\Temp\\_MEI142562\\matplotlib\\mpl-data\\matplotlibrc' 从matplotlibrc文件加载matplotlib rcparams时,Jupyter Notebook内联绘图中断 - Jupyter notebook inline plotting breaks, when loading matplotlib rcparams from matplotlibrc file Matplotlib/v-3.4.2 问题与 matplotlibrc 中的乳胶序言 - Matplotlib/v-3.4.2 problem with latex preamble in matplotlibrc OS X python脚本无法读取/Users/myname/.matplotlib/matplotlibrc - os x python script not reading /Users/myname/.matplotlib/matplotlibrc 在matplotlib中为绘图设置临时默认值 - Setting temporary defaults for plots in matplotlib 将 Matplotlib 和 Sympy 的图放在一起 - Putting together plots of Matplotlib and Sympy 如何在 matplotlib 中显示一个 sympy 方程 - How to show a sympy equation in matplotlib
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM