Commit c3b7a691 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

python: add __repr__ for rs_pair

* spot/twa/acc.hh: Hide default constructors, so that we can have
keyword arguments on the main constructor.
* python/spot/impl.i: Add __repr__.
* tests/python/setacc.py: Test it.
parent 5bb9c87d
......@@ -670,6 +670,29 @@ def state_is_accepting(self, src) -> "bool":
%include <spot/taalgos/minimize.hh>
%extend spot::acc_cond::rs_pair {
std::string __repr__()
{
std::ostringstream os;
os << "spot.rs_pair(fin=[";
char* sep = "";
for (unsigned s: self->fin.sets())
{
os << sep << s;
sep = ", ";
}
os << "], inf=[";
sep = "";
for (unsigned s: self->inf.sets())
{
os << sep << s;
sep = ", ";
}
os << "])";
return os.str();
}
}
%extend spot::trival {
std::string __repr__()
{
......
......@@ -1135,8 +1135,10 @@ namespace spot
/// false in Streett, and true in Rabin.
struct SPOT_API rs_pair
{
#ifndef SWIG
rs_pair() = default;
rs_pair(const rs_pair&) = default;
#endif
rs_pair(acc_cond::mark_t fin, acc_cond::mark_t inf):
fin(fin),
......
......@@ -50,8 +50,7 @@ assert b == False
assert len(v) == 0
(b, v) = spot.acc_cond("(Fin(0)|Inf(1))&(Fin(2)|Inf(0))").is_streett_like()
assert b == True
assert len(v) == 2
assert v[0].fin == [0]
assert v[0].inf == [1]
assert v[1].fin == [2]
assert v[1].inf == [0]
assert repr(v) == \
'(spot.rs_pair(fin=[0], inf=[1]), spot.rs_pair(fin=[2], inf=[0]))'
v2 = (spot.rs_pair(fin=[0], inf=[1]), spot.rs_pair(fin=[2], inf=[0]))
assert v == v2
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