Configuration¶
If you’re familiar with Manim’s configuration system, manim-eng’s shouldn’t come as too much of a surprise. There are three ways to set configuration:
Editing the global
config_engobject, an instance ofManimEngConfig;Using the
tempconfig_eng()context manager; andUsing a
manim-eng.tomlconfiguration file.
config_eng¶
This is the fundamental underlying representation of manim-eng’s configuration, and all
other methods ultimately edit this object. To get an idea of all of the available
options, check out the ManimEngConfig API documentation.
It is worth noting that, unlike Manim’s
ManimConfig (which underlies its config
object), ManimEngConfig (and hence config_eng) does not support using
dict-like syntax to set values.
The tempconfig_eng context manager¶
This works very similarly to Manim’s tempconfig() — you pass a
dictionary representing the configuration you wish to temporarily apply, and once the
context manager exits the edited values are returned to their previous values.
>>> from manim_eng import *
>>> config_eng.symbol.bipole_width
0.4
>>> with tempconfig_eng({"symbol": {"bipole_width": 0.5}}):
... print(config_eng.symbol.bipole_width)
...
0.5
>>> config_eng.symbol.bipole_width
0.4
Tip
To set a nested value, you need to nest dictionaries. For example, to temporarily
set the config_eng.symbol.bipole_width configuration value to 0.5, you would
not be able to use
{"symbol.bipole_width": 0.5}
but would instead need to use
{"symbol": {"bipole_width": 0.5}}
as above.
The manim-eng.toml config files¶
There are two levels of config file: user-level and project-level. The user-level file is
~/.config/manim/manim-eng.tomlon Linux and macOS; and~AppDataRoamingManimmanim-eng.tomlon Windows.
Project-level configuration is placed in a file called manim-eng.toml in the
root of your project’s working directory.
The structure of a manim-eng.toml¶
Like the tempconfig() above, a
manim-eng.toml needs to reflect the structure of ManimEngConfig. This
essentially means that, where a subclass exists in ManimEngConfig, that
translates to a TOML table, and where a field exists, that becomes a TOML field.
By way of an example, if we wanted to set config_eng.symbol.bipole_width to 0.5,
the contents of a manim-eng.toml to do so would be as below.
[symbol]
bipole_width = 0.5
Configuration priority¶
When determining values for a given configuration value, the following order is used:
Values set in code, either by directly editing
config_engor using thetempconfig_eng()context manager.Values set in the project-level
manim-eng.toml.Values set in the user-level
manim-eng.toml.The default values (see the
ManimEngConfigdocumentation).