DiODeProject / DiODeProject/MuMoT
Allow for creating models from Python strings
- Dominant language
- Python
- Stars
- 24
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
Following on from #67 I I think it would be a very good thing if MuMoT models could be created and referenced in Notebooks without using Notebook cell execution numbers. At present the example Notebooks contain cells like:
```
%%model
$
U -> A : g_A
U -> B : g_B
A -> U : a_A
B -> U : a_B
A + U -> A + A : r_A
B + U -> B + B : r_B
A + B -> A + U : s
A + B -> B + U : s
$
```
then
```python
model1 = mumot.parseModel(In[2])
```
This approach causes problems for the user if they want to re-run a given cell as then calls like `mumot.parseModel(In[X})` in subsequent cells won't work without manual editing of the cell execution number.
I suggest that what's needed is a Python function to generate a model from a multi-line string:
```python
model_1 = mumot.model_from_latex("""
U -> A : g_A
U -> B : g_B
A -> U : a_A
B -> U : a_B
A + U -> A + A : r_A
B + U -> B + B : r_B
A + B -> A + U : s
A + B -> B + U : s
""")
```
This is almost as readable as the but should allow Notebooks to be run more flexibly and robustly. You'd loose the LaTeX rendering beneath the `%%model` magic cells but that seems redundant given that `MuMoTmodel.show()` produces a more attractive rendering of that information.
Another advantage of allowing models to be generated by parsing a Python string is that it would make it easier to create models for unit testing outside Notebooks.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.