From f067dd7871f8d20be68a5054413c5f0446409165 Mon Sep 17 00:00:00 2001 From: Etienne Renault Date: Mon, 20 Apr 2015 11:28:04 +0200 Subject: [PATCH] Add setup method for spot. * wrap/python/spot.py: here. * wrap/python/tests/automata.ipynb: tests here. --- wrap/python/spot.py | 9 +++++++++ wrap/python/tests/automata.ipynb | 31 +++++++++++++------------------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/wrap/python/spot.py b/wrap/python/spot.py index 24b5b8b1e..e4e8b4810 100644 --- a/wrap/python/spot.py +++ b/wrap/python/spot.py @@ -25,6 +25,15 @@ from functools import lru_cache # Global BDD dict so that we do not have to create one in user code. _bdd_dict = make_bdd_dict() +# Load all preliminaries for a fancy display +def setup(show_bullet=True): + import os + os.environ['SPOT_DOTEXTRA'] = 'size="10.2,5" node[style=filled,fillcolor="#ffffaa"] edge[arrowhead=vee, arrowsize=.7]' + if show_bullet: + os.environ['SPOT_DOTDEFAULT'] = 'rbcf(Lato)' + else: + os.environ['SPOT_DOTDEFAULT'] = 'rcf(Lato)' + # Add a small LRU cache so that when we display automata into a # interactive widget, we avoid some repeated calls to dot for # identical inputs. diff --git a/wrap/python/tests/automata.ipynb b/wrap/python/tests/automata.ipynb index 36c30646e..fdf59c20c 100644 --- a/wrap/python/tests/automata.ipynb +++ b/wrap/python/tests/automata.ipynb @@ -18,7 +18,7 @@ "version": "3.4.2" }, "name": "", - "signature": "sha256:7bcd29a20e60c508a998923ed5875f91f69cd4f3e77dca19795b976dab016b90" + "signature": "sha256:a45a88a09bb68e3c3ea4856e0dc7ab83ccc4afa607806beb1fa902de88e28792" }, "nbformat": 3, "nbformat_minor": 0, @@ -30,13 +30,8 @@ "collapsed": false, "input": [ "import os\n", - "# Note that Spot (loaded by the kernel) will store a copy of\n", - "# the environment variable the first time it reads them, so\n", - "# if you change those variables, the new values will be ignored\n", - "# until you restart the kernel.\n", - "os.environ['SPOT_DOTEXTRA'] = 'size=\"10.2,5\" node[style=filled,fillcolor=\"#ffffaa\"] edge[arrowhead=vee, arrowsize=.7]'\n", - "os.environ['SPOT_DOTDEFAULT'] = 'rbcf(Lato)'\n", - "import spot" + "import spot\n", + "spot.setup(True)" ], "language": "python", "metadata": {}, @@ -176,7 +171,7 @@ "\n" ], "text": [ - " *' at 0x1052702d0> >" + " *' at 0x10f07d3c0> >" ] } ], @@ -308,7 +303,7 @@ "" ], "text": [ - "" + "" ] } ], @@ -454,7 +449,7 @@ "" ], "text": [ - "" + "" ] } ], @@ -547,7 +542,7 @@ "\n" ], "text": [ - " *' at 0x106ca0060> >" + " *' at 0x110aae060> >" ] } ], @@ -617,7 +612,7 @@ "\n" ], "text": [ - " *' at 0x106ca0120> >" + " *' at 0x110aae120> >" ] } ], @@ -686,7 +681,7 @@ "\n" ], "text": [ - " *' at 0x106ca0030> >" + " *' at 0x110aae030> >" ] } ], @@ -802,7 +797,7 @@ "" ], "text": [ - "" + "" ] } ], @@ -992,7 +987,7 @@ "" ], "text": [ - "" + "" ] } ], @@ -1085,7 +1080,7 @@ "\n" ], "text": [ - " *' at 0x1052dcfc0> >" + " *' at 0x10f0ecfc0> >" ] } ], @@ -1559,7 +1554,7 @@ "\n" ], "text": [ - " *' at 0x1052dcba0> >" + " *' at 0x10f0ecba0> >" ] } ],