M(ath)YAML: evaluate math expressions in YAML files.
Project description
myaml
M(ath)YAML: evaluate math expressions in YAML files.
Install
pip install myaml
Usage
myaml
allows you to define math expressions in YAML files:
# test.yaml
---
- x1:
x: 2**(3 - 1)
y: (12 % 9) - sqrt(9)
- x2:
x: (2**3) - 1.0
y: -0.75 ** (9 - cos(3.1415) * log(2.718))
- x3:
x: hello world
y: /this/is/a/path
Math expressions will be evaluated at load-time. Any other strings will be left intact:
>>> import myaml
>>> xs = myaml.safe_load('test.yaml')
>>> xs
[
{'x1': {'x': 4, 'y': 0}},
{'x2': {'x': 7, 'y': -0.056315}},
{'x3': {
'x': 'hello world',
'y': '/this/is/a/path'
}}
]
Notes
myaml
supports arbitrary nesting, conforming with YAML spec.myaml
is built on top of PyYAML'ssafe_load
.- expressions should be SymPy compatible, since
parse_expr
is used for evaluation.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
myaml-0.0.4.tar.gz
(3.0 kB
view hashes)
Built Distribution
myaml-0.0.4-py3-none-any.whl
(7.2 kB
view hashes)