Commit 19348c89 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

python: give access to the "product-states" property

* python/spot/impl.i (get_product_states, set_product_states): New.
* tests/python/product.ipynb: Use it.
* NEWS: Mention it.
parent 904cfb27
......@@ -212,6 +212,11 @@ New in spot 2.4.3.dev (not yet released)
- The new function spot::check_determinism() sets both
prop_semi_deterministic() and prop_universal() appropriately.
Python:
- The "product-states" property of automata is now accessible via
spot.twa.get_product_states() and spot.set.get_product_states().
Deprecation notices:
(These functions still work but compilers emit warnings.)
......
......@@ -428,8 +428,10 @@ namespace swig
namespace std {
%template(liststr) list<std::string>;
%template(pairunsigned) pair<unsigned, unsigned>;
%template(vectorformula) vector<spot::formula>;
%template(vectorunsigned) vector<unsigned>;
%template(vectorpairunsigned) vector<pair<unsigned, unsigned>>;
%template(vectorbool) vector<bool>;
%template(vectorbdd) vector<bdd>;
%template(vectorstring) vector<string>;
......@@ -465,6 +467,19 @@ namespace std {
DeprecationWarning)
%}
// Must occur before the twa declaration
%typemap(out) SWIGTYPE* spot::twa::get_product_states %{
if (!$1)
$result = SWIG_Py_Void();
else
{
unsigned sz = $1->size();
$result = PyList_New(sz);
for (unsigned i = 0; i < sz; ++i)
PyList_SetItem($result, i, swig::from((*$1)[i]));
}
%}
%include <spot/twa/twa.hh>
%include <spot/tl/apcollect.hh>
......@@ -769,6 +784,21 @@ def state_is_accepting(self, src) -> "bool":
return self->get_named_prop<std::vector<std::string>>("state-names");
}
void set_product_states(std::vector<std::pair<unsigned, unsigned>> pairs)
{
self->set_named_prop("product-states", new
std::vector<std::pair<unsigned,
unsigned>>(std::move(pairs)));
}
std::vector<std::pair<unsigned, unsigned>>* get_product_states()
{
return self->get_named_prop
<std::vector<std::pair<unsigned, unsigned>>>("product-states");
}
twa* highlight_state(unsigned state, unsigned color)
{
auto hs =
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment