diff --git a/NEWS b/NEWS index f83b9d645..b87bdca74 100644 --- a/NEWS +++ b/NEWS @@ -112,6 +112,8 @@ New in spot 2.0.3a (not yet released) * Bindings for language_containment_checker were added. + * Bindings for randomize() were added. + * Under IPython the spot.ltsmin modules now offers a %%pml magic to define promela models, compile them with spins, and dynamically load them. This is diff --git a/python/spot/impl.i b/python/spot/impl.i index a544b4ff0..18044f8db 100644 --- a/python/spot/impl.i +++ b/python/spot/impl.i @@ -128,6 +128,7 @@ #include #include #include +#include #include #include #include @@ -435,6 +436,7 @@ namespace std { %include %include %include +%include %include %include %include diff --git a/tests/python/highlighting.ipynb b/tests/python/highlighting.ipynb index 4f79a6fca..2b73e6071 100644 --- a/tests/python/highlighting.ipynb +++ b/tests/python/highlighting.ipynb @@ -18,7 +18,7 @@ "version": "3.4.3+" }, "name": "", - "signature": "sha256:024df96495fac2f6862d63f78750ad9279a60f4e73ad02643779e5dc6a1f1982" + "signature": "sha256:30e1abf38b76bd072ff688d2b48f94eb5945807bfa9583a8f457ad3bc4966c4e" }, "nbformat": 3, "nbformat_minor": 0, @@ -155,7 +155,7 @@ "" ], "text": [ - "" + "" ] } ], @@ -255,7 +255,7 @@ "\n" ], "text": [ - " *' at 0x7fe2a40ed8a0> >" + " *' at 0x7fc0d01be8a0> >" ] } ], @@ -357,7 +357,7 @@ "\n" ], "text": [ - " *' at 0x7fe2a4061f90> >" + " *' at 0x7fc0d0132f90> >" ] } ], @@ -572,7 +572,7 @@ "\n" ], "text": [ - " *' at 0x7fe2a8edf0f0> >" + " *' at 0x7fc0d57b10f0> >" ] } ], @@ -751,7 +751,7 @@ "\n" ], "text": [ - " *' at 0x7fe2a8edf0f0> >" + " *' at 0x7fc0d57b10f0> >" ] } ], @@ -831,7 +831,7 @@ "\n" ], "text": [ - " *' at 0x7fe2a8edf090> >" + " *' at 0x7fc0d57b1090> >" ] }, { @@ -877,7 +877,7 @@ "\n" ], "text": [ - " *' at 0x7fe2a8edf030> >" + " *' at 0x7fc0d57b1030> >" ] } ], @@ -963,7 +963,7 @@ "\n" ], "text": [ - " *' at 0x7fe2a4061fc0> >" + " *' at 0x7fc0d0132fc0> >" ] } ], @@ -1088,7 +1088,7 @@ "\n" ], "text": [ - " *' at 0x7fe2a4061fc0> >" + " *' at 0x7fc0d0132fc0> >" ] }, { @@ -1145,7 +1145,7 @@ "\n" ], "text": [ - " *' at 0x7fe2a8edf090> >" + " *' at 0x7fc0d57b1090> >" ] }, { @@ -1191,7 +1191,7 @@ "\n" ], "text": [ - " *' at 0x7fe2a8edf030> >" + " *' at 0x7fc0d57b1030> >" ] } ], @@ -1398,7 +1398,7 @@ "\n" ], "text": [ - " *' at 0x7fe2a8edf150> >" + " *' at 0x7fc0d57b1150> >" ] }, { @@ -1472,7 +1472,7 @@ "\n" ], "text": [ - " *' at 0x7fe2a8edf120> >" + " *' at 0x7fc0d57b1120> >" ] }, { @@ -1556,7 +1556,7 @@ "\n" ], "text": [ - " *' at 0x7fe2a8edf180> >" + " *' at 0x7fc0d57b1180> >" ] } ], @@ -1702,12 +1702,157 @@ "\n" ], "text": [ - " *' at 0x7fe2a8edf270> >" + " *' at 0x7fc0d57b1270> >" ] } ], "prompt_number": 17 }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Disappearing highlights\n", + "\n", + "As explained at the top of this notebook, named properties (such as highlights) are fragile, and you should not really on them being preserved across algorithms. In-place algorithm are probably the worst, because they might modify the automaton and ignore the attached named properties. \n", + "\n", + "`randomize()` is one such in-place algorithm: it reorder states or transitions of the automaton. By doing so it renumber the states and edges, and that process would completely invalidate the highlights information. Fortunately `randomize()` know about highlights: it will preserve highlighted states, but it will drop all highlighted edges." + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "spot.randomize(b); b" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "pyout", + "prompt_number": 18, + "svg": [ + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "G\n", + "\n", + "\n", + "\n", + "4\n", + "\n", + "4\n", + "\n", + "\n", + "I->4\n", + "\n", + "\n", + "\n", + "\n", + "1\n", + "\n", + "1\n", + "\n", + "\n", + "4->1\n", + "\n", + "\n", + "1\n", + "\n", + "\n", + "0\n", + "\n", + "0\n", + "\n", + "\n", + "0->0\n", + "\n", + "\n", + "!b\n", + "\u24ff\n", + "\n", + "\n", + "0->0\n", + "\n", + "\n", + "b\n", + "\n", + "\n", + "1->0\n", + "\n", + "\n", + "!a & !b\n", + "\n", + "\n", + "1->1\n", + "\n", + "\n", + "a | b\n", + "\n", + "\n", + "3\n", + "\n", + "3\n", + "\n", + "\n", + "1->3\n", + "\n", + "\n", + "a & !b\n", + "\n", + "\n", + "2\n", + "\n", + "2\n", + "\n", + "\n", + "1->2\n", + "\n", + "\n", + "a & b\n", + "\n", + "\n", + "3->0\n", + "\n", + "\n", + "!a & b\n", + "\n", + "\n", + "3->3\n", + "\n", + "\n", + "a & b\n", + "\n", + "\n", + "2->2\n", + "\n", + "\n", + "a & !b\n", + "\u24ff\n", + "\n", + "\n", + "2->2\n", + "\n", + "\n", + "a & b\n", + "\n", + "\n", + "\n" + ], + "text": [ + " *' at 0x7fc0d57b1270> >" + ] + } + ], + "prompt_number": 18 + }, { "cell_type": "markdown", "metadata": {}, @@ -1721,7 +1866,8 @@ "cell_type": "code", "collapsed": false, "input": [ - "display(b.show('.<4'), b.show('.<2'))" + "spot.highlight_nondet_edges(b, 4) # let's get those highlighted edges back\n", + "display(b, b.show('.<4'), b.show('.<2'))" ], "language": "python", "metadata": {}, @@ -1730,15 +1876,136 @@ "metadata": {}, "output_type": "display_data", "svg": [ - "\n", - "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", "G\n", - "\n", + "\n", + "\n", + "\n", + "4\n", + "\n", + "4\n", + "\n", + "\n", + "I->4\n", + "\n", + "\n", + "\n", + "\n", + "1\n", + "\n", + "1\n", + "\n", + "\n", + "4->1\n", + "\n", + "\n", + "1\n", + "\n", + "\n", + "0\n", + "\n", + "0\n", + "\n", + "\n", + "0->0\n", + "\n", + "\n", + "!b\n", + "\u24ff\n", + "\n", + "\n", + "0->0\n", + "\n", + "\n", + "b\n", + "\n", + "\n", + "1->0\n", + "\n", + "\n", + "!a & !b\n", + "\n", + "\n", + "1->1\n", + "\n", + "\n", + "a | b\n", + "\n", + "\n", + "3\n", + "\n", + "3\n", + "\n", + "\n", + "1->3\n", + "\n", + "\n", + "a & !b\n", + "\n", + "\n", + "2\n", + "\n", + "2\n", + "\n", + "\n", + "1->2\n", + "\n", + "\n", + "a & b\n", + "\n", + "\n", + "3->0\n", + "\n", + "\n", + "!a & b\n", + "\n", + "\n", + "3->3\n", + "\n", + "\n", + "a & b\n", + "\n", + "\n", + "2->2\n", + "\n", + "\n", + "a & !b\n", + "\u24ff\n", + "\n", + "\n", + "2->2\n", + "\n", + "\n", + "a & b\n", + "\n", + "\n", + "\n" + ], + "text": [ + " *' at 0x7fc0d57b1270> >" + ] + }, + { + "metadata": {}, + "output_type": "display_data", + "svg": [ + "\n", + "\n", + "G\n", + "\n", "\n", "\n", "0\n", "\n", - "0\n", + "4\n", "\n", "\n", "I->0\n", @@ -1764,67 +2031,70 @@ "\n", "\n", "u1\n", - "\n", - "...\n", + "\n", + "...\n", "\n", "\n", "1->u1\n", - "\n", - "\n", + "\n", + "\n", "\n", "\n", "2\n", - "\n", - "2\n", + "\n", + "3\n", "\n", "\n", "1->2\n", - "\n", - "\n", - "!a & !b\n", + "\n", + "\n", + "a & !b\n", "\n", "\n", "3\n", - "\n", - "3\n", + "\n", + "2\n", "\n", "\n", "1->3\n", - "\n", - "\n", - "a & b\n", - "\n", - "\n", - "2->2\n", - "\n", - "\n", - "b\n", + "\n", + "\n", + "a & b\n", "\n", "\n", "2->2\n", - "\n", - "\n", - "!b\n", - "\u24ff\n", + "\n", + "\n", + "a & b\n", + "\n", + "\n", + "u2\n", + "\n", + "...\n", + "\n", + "\n", + "2->u2\n", + "\n", + "\n", "\n", "\n", "3->3\n", - "\n", - "\n", - "a & b\n", + "\n", + "\n", + "a & !b\n", + "\u24ff\n", "\n", "\n", "3->3\n", - "\n", - "\n", - "a & !b\n", - "\u24ff\n", + "\n", + "\n", + "a & b\n", "\n", "\n", "" ], "text": [ - "" + "" ] }, { @@ -1839,7 +2109,7 @@ "\n", "0\n", "\n", - "0\n", + "4\n", "\n", "\n", "I->0\n", @@ -1877,11 +2147,11 @@ "" ], "text": [ - "" + "" ] } ], - "prompt_number": 18 + "prompt_number": 19 } ], "metadata": {}