diff --git a/NEWS b/NEWS
index c50079e42..e7973d198 100644
--- a/NEWS
+++ b/NEWS
@@ -227,6 +227,10 @@ New in spot 2.4.4.dev (net yet released)
- The "product-states" property of automata is now accessible via
spot.twa.get_product_states() and spot.set.get_product_states().
+ - twa_word instances can be displayed as SVG pictures, with one
+ signal per atomic proposition. For some examples, see the use of
+ the show() method in https://spot.lrde.epita.fr/ipynb/word.html
+
Deprecation notices:
(These functions still work but compilers emit warnings.)
diff --git a/python/spot/__init__.py b/python/spot/__init__.py
index 1a4856264..b8064e6d4 100644
--- a/python/spot/__init__.py
+++ b/python/spot/__init__.py
@@ -1010,3 +1010,92 @@ def show_mp_hierarchy(cl):
return SVG(mp_hierarchy_svg(cl))
formula.show_mp_hierarchy = show_mp_hierarchy
+
+@_extend(twa_word)
+class twa_word:
+ def as_svg(self):
+ """
+ Build an SVG picture representing the word as a collection of
+ signals for each atomic proposition.
+ """
+ # Get the list of atomic proposition used
+ sup = buddy.bddtrue
+ for cond in list(self.prefix) + list(self.cycle):
+ sup = sup & buddy.bdd_support(cond)
+ ap = []
+ while sup != buddy.bddtrue:
+ a = buddy.bdd_var(sup)
+ ap.append(a)
+ sup = buddy.bdd_high(sup)
+
+ # Prepare canvas
+ psize = len(self.prefix)
+ csize = len(self.cycle)
+ d = {
+ 'endprefix': 50 * psize,
+ 'endcycle': 50 * (psize + csize),
+ 'w': 50 * (psize + csize * 2),
+ 'height': 50 * len(ap),
+ 'height2': 50 * len(ap) + 10,
+ 'h3': 50 * len(ap) + 12,
+ 'bgcolor': '#f4f4f4',
+ 'bgl': 'stroke="white" stroke-width="4"',
+ 'bgt': 'stroke="white" stroke-width="1"',
+ 'txt': 'text-anchor="start" font-size="20"',
+ 'red': 'stroke="#ff0000" stroke-width="2"',
+ 'sml': 'text-anchor="start" font-size="10"'
+ }
+ txt = '''
+'
+
+ def show(self):
+ """
+ Display the word as an SVG picture of signals.
+ """
+ from IPython.display import SVG
+ return SVG(self.as_svg())
diff --git a/tests/python/word.ipynb b/tests/python/word.ipynb
index 2ee85888a..4bc52263c 100644
--- a/tests/python/word.ipynb
+++ b/tests/python/word.ipynb
@@ -15,7 +15,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.5.3"
+ "version": "3.6.4"
},
"name": ""
},
@@ -47,7 +47,7 @@
"cell_type": "code",
"collapsed": false,
"input": [
- "aut = spot.translate('G(Fa <-> XXb)'); aut"
+ "aut = spot.translate('!a & G(Fa <-> XXb)'); aut"
],
"language": "python",
"metadata": {},
@@ -63,150 +63,121 @@
"\n",
"\n",
- "