python: more conventional __repr__ for several types

* NEWS: Mention the change.
* python/spot/__init__.py: Add _repr_latex_ for twa_word, and
remove __repr__ and __str__ for atomic_prop_set.
* python/spot/impl.i: Implement __repr__ and __str__ for
atomic_prop_set.  Fix __repr__ for trival, acc_code, acc_cond,
mark_t.  Remove __repr__ for twa_run and twa_word.
* tests/python/acc_cond.ipynb, tests/python/accparse.ipynb,
tests/python/atva16-fig2a.ipynb, tests/python/automata.ipynb,
tests/python/bdditer.py, tests/python/contains.ipynb,
tests/python/gen.ipynb, tests/python/highlighting.ipynb,
tests/python/ltlsimple.py, tests/python/ltsmin-dve.ipynb,
tests/python/product.ipynb, tests/python/relabel.py,
tests/python/satmin.ipynb tests/python/stutter-inv.ipynb,
tests/python/word.ipynb: Adjust test cases.
* tests/python/formulas.ipynb: Add test for atomic_prop_set.
This commit is contained in:
Alexandre Duret-Lutz 2018-11-02 17:18:42 +01:00
parent c3b7a691e4
commit 60296317c7
19 changed files with 686 additions and 700 deletions

View file

@ -166,7 +166,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.impl.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fca777b2090> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f4e4c5e8de0> >"
]
},
"execution_count": 2,
@ -191,25 +191,24 @@
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Prefix:\n",
" 0\n",
" | !a\n",
" 1\n",
" | a\n",
"Cycle:\n",
" 2\n",
" | a & b\t{0}"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
"name": "stdout",
"output_type": "stream",
"text": [
"Prefix:\n",
" 0\n",
" | !a\n",
" 1\n",
" | a\n",
"Cycle:\n",
" 2\n",
" | a & b\t{0}\n",
"\n"
]
}
],
"source": [
"run = aut.accepting_run(); run"
"run = aut.accepting_run()\n",
"print(run)"
]
},
{
@ -250,10 +249,20 @@
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"!a; a; cycle{a & b}\n"
]
},
{
"data": {
"text/latex": [
"$\\lnot a; a; \\mathsf{cycle}\\{a \\land b\\}$"
],
"text/plain": [
"!a; a; cycle{a & b}"
"<spot.twa_word; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_word > *' at 0x7f4e4c5e8b70> >"
]
},
"execution_count": 5,
@ -262,7 +271,9 @@
}
],
"source": [
"word = spot.twa_word(run); word"
"word = spot.twa_word(run)\n",
"print(word) # print as a string\n",
"word # LaTeX-style representation in notebooks"
]
},
{
@ -341,19 +352,16 @@
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"!a; cycle{a & b}"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
"name": "stdout",
"output_type": "stream",
"text": [
"!a; cycle{a & b}\n"
]
}
],
"source": [
"word.simplify()\n",
"word"
"print(word)"
]
},
{
@ -370,8 +378,11 @@
"outputs": [
{
"data": {
"text/latex": [
"$\\lnot a; \\mathsf{cycle}\\{a \\land b\\}$"
],
"text/plain": [
"!a; cycle{a & b}"
"<spot.twa_word; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_word > *' at 0x7f4e4c652810> >"
]
},
"execution_count": 9,
@ -418,8 +429,11 @@
"outputs": [
{
"data": {
"text/latex": [
"$a; a \\land b; \\mathsf{cycle}\\{\\lnot a \\land \\lnot b; \\lnot a \\land b\\}$"
],
"text/plain": [
"a; a & b; cycle{!a & !b; !a & b}"
"<spot.twa_word; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_word > *' at 0x7f4e4c574600> >"
]
},
"execution_count": 11,
@ -464,7 +478,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Words can be easily converted as automata"
"Words can be easily converted to automata"
]
},
{
@ -550,7 +564,7 @@
"</svg>\n"
],
"text/plain": [
"<spot.impl.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7fca7775f690> >"
"<spot.twa_graph; proxy of <Swig Object of type 'std::shared_ptr< spot::twa_graph > *' at 0x7f4e4c6528a0> >"
]
},
"execution_count": 13,
@ -579,7 +593,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
"version": "3.6.7"
}
},
"nbformat": 4,