From 19cd2cda6f760e21924f31c32c6047d26b2cb49d Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Thu, 5 Nov 2015 13:41:42 +0100 Subject: [PATCH] python: add binding for is_unambiguous Fixes #117. * wrap/python/spot.py, wrap/python/spot_impl.i: Add binding. * wrap/python/tests/remfin.py: Add a small test case. * NEWS: Mention it. --- NEWS | 3 +++ wrap/python/spot.py | 6 +++++- wrap/python/spot_impl.i | 2 ++ wrap/python/tests/remfin.py | 6 ++++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 13e9282eb..d4bfa5b63 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,9 @@ New in spot 1.99.5a (not yet released) Boolean argument. This argument used to be optionnal (defaulting to True), but it no longer is. + Python: + * Add bindings for is_unambiguous(). + Bug fixes: * automaton parser was ignoring the "unambiguous" property. diff --git a/wrap/python/spot.py b/wrap/python/spot.py index 55e145e1d..25855977d 100644 --- a/wrap/python/spot.py +++ b/wrap/python/spot.py @@ -626,10 +626,14 @@ twa.postprocess = postprocess # instance methods (i.e., self passed as first argument # automatically), because only used-defined functions are converted as # instance methods. -for meth in ('scc_filter', 'scc_filter_states'): +def _add_twa_graph(meth): setattr(twa_graph, meth, (lambda self, *args, **kwargs: globals()[meth](self, *args, **kwargs))) +for meth in ('scc_filter', 'scc_filter_states', + 'is_deterministic', 'is_unambiguous'): + _add_twa_graph(meth) + # Wrapper around a formula iterator to which we add some methods of formula # (using _addfilter and _addmap), so that we can write things like # formulas.simplify().is_X_free(). diff --git a/wrap/python/spot_impl.i b/wrap/python/spot_impl.i index 0e99b22eb..17401976b 100644 --- a/wrap/python/spot_impl.i +++ b/wrap/python/spot_impl.i @@ -128,6 +128,7 @@ #include "twaalgos/sccfilter.hh" #include "twaalgos/stats.hh" #include "twaalgos/isdet.hh" +#include "twaalgos/isunamb.hh" #include "twaalgos/simulation.hh" #include "twaalgos/postproc.hh" #include "twaalgos/product.hh" @@ -307,6 +308,7 @@ namespace std { %include "twaalgos/sccfilter.hh" %include "twaalgos/stats.hh" %include "twaalgos/isdet.hh" +%include "twaalgos/isunamb.hh" %include "twaalgos/simulation.hh" %include "twaalgos/postproc.hh" %include "twaalgos/product.hh" diff --git a/wrap/python/tests/remfin.py b/wrap/python/tests/remfin.py index 8b1c7d96e..880d6588b 100644 --- a/wrap/python/tests/remfin.py +++ b/wrap/python/tests/remfin.py @@ -41,3 +41,9 @@ assert(aut1.get_name() == None) aut1.set_name("test me") assert(aut1.get_name() == "test me") # The method is the same as the function + +a = spot.translate('true', 'low', 'any') +assert(a.prop_deterministic() == False) +assert(a.prop_unambiguous() == False) +assert(a.is_deterministic() == True) +assert(a.is_unambiguous() == True)