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: !eval 2**(3 - 1)
y: !eval (12 % 9) - sqrt(9)
- x2:
x: !eval (2**3) - 1.0
y: !eval -0.75 ** (9 - cos(3.1415) * log(2.718))
- x3:
x: hello world
y: /this/is/a/path
Expressions annotated with !eval
tag 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-1.0.1.tar.gz
(2.5 kB
view details)
Built Distribution
myaml-1.0.1-py3-none-any.whl
(6.8 kB
view details)
File details
Details for the file myaml-1.0.1.tar.gz
.
File metadata
- Download URL: myaml-1.0.1.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.7.0 requests/2.25.1 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6761ea4e271b2808cb1c91cb8abcfbde073d0b54649da37a67e5094b22e672b9 |
|
MD5 | 079d202bdb8ed11e5875e9d9565171b1 |
|
BLAKE2b-256 | cb3642e65be64c0a243064b44e29969b6f2d3d598933b8abad6dbdbe3f3550c8 |
File details
Details for the file myaml-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: myaml-1.0.1-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.7.0 requests/2.25.1 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6dc04e22a7418b04bfb9747d847081add0896dad5b02388a6dc20b6d3d9d434b |
|
MD5 | 91072289d54218ca36019fbb6c59e00b |
|
BLAKE2b-256 | 15969b6dbc05a680b9a6bd84e88298e6ede5d9b00f7a4e0481fac725b0aab63a |