Commit 5a9b0aa1 authored by Alexandre Duret-Lutz's avatar Alexandre Duret-Lutz

python: add bindings for ltsmin

* python/spot/ltsmin.i: New file.
* python/Makefile.am: Add it.
* python/spot/impl.i: Add bindings for kripke and fair_kripke.
* tests/python/ltsmin.ipynb: New file.
* tests/Makefile.am, doc/org/tut.org: Add it.
* tests/python/ipnbdoctest.py: Make it possible for notebook
to exit(77).
* debian/control: Make the Python package dependent
on libspotltsmin0.
* python/spot/__init__.py: Typo.
parent 215fcb79
...@@ -30,7 +30,7 @@ Package: libspot-dev ...@@ -30,7 +30,7 @@ Package: libspot-dev
Architecture: any Architecture: any
Section: libdevel Section: libdevel
Suggests: spot-doc Suggests: spot-doc
Depends: libspot0 (>= ${source:Version}), libspot0 (<< ${source:Version}.1~), libspotltsmin0 (>= ${source:Version}) , libspotltsmin0 (<< ${source:Version}.1~), ${misc:Depends}, libbddx-dev Depends: libspot0 (>= ${source:Version}), libspot0 (<< ${source:Version}.1~), libspotltsmin0 (>= ${source:Version}), libspotltsmin0 (<< ${source:Version}.1~), ${misc:Depends}, libbddx-dev
Description: headers for the Spot model checking library Description: headers for the Spot model checking library
C++ headers for the Spot library. C++ headers for the Spot library.
...@@ -70,7 +70,7 @@ Description: documentation for Spot ...@@ -70,7 +70,7 @@ Description: documentation for Spot
Package: python3-spot Package: python3-spot
Architecture: any Architecture: any
Section: python Section: python
Depends: ${shlibs:Depends}, ${misc:Depends}, ${python3:Depends}, libspot0 (>= ${source:Version}), libspot0 (<< ${source:Version}.1~) Depends: ${shlibs:Depends}, ${misc:Depends}, ${python3:Depends}, libspot0 (>= ${source:Version}), libspot0 (<< ${source:Version}.1~), libspotltsmin0 (>= ${source:Version}), libspotltsmin0 (<< ${source:Version}.1~)
Suggests: ipython3 Suggests: ipython3
Description: python3 binding for spot Description: python3 binding for spot
Spot allows manipulation of omega-automata as well Spot allows manipulation of omega-automata as well
......
...@@ -59,5 +59,7 @@ real notebooks instead. ...@@ -59,5 +59,7 @@ real notebooks instead.
in Python in Python
- [[https://spot.lrde.epita.fr/ipynb/randltl.html][=randltl.ipynb=]] demonstrates a Python-version of [[file:randltl.org][=randltl=]] - [[https://spot.lrde.epita.fr/ipynb/randltl.html][=randltl.ipynb=]] demonstrates a Python-version of [[file:randltl.org][=randltl=]]
- [[https://spot.lrde.epita.fr/ipynb/decompose.html][=decompose.ipynb=]] illustrates the =decompose_strength()= function - [[https://spot.lrde.epita.fr/ipynb/decompose.html][=decompose.ipynb=]] illustrates the =decompose_strength()= function
- [[https://spot.lrde.epita.fr/ipynb/testingaut.html][=testingaut.ipynb=]] shows the step necessary to build a testing - [[https://spot.lrde.epita.fr/ipynb/testingaut.html][=testingaut.ipynb=]] shows the steps necessary to build a testing
automaton automaton
- [[https://spot.lrde.epita.fr/ipynb/ltsmin.html][=ltsmin.ipynb=]] minimal test for loading a DiVinE model using
the LTSmin interface.
...@@ -32,15 +32,17 @@ AM_CPPFLAGS = -I$(PYTHONINC) -I$(top_builddir) -I$(top_srcdir) \ ...@@ -32,15 +32,17 @@ AM_CPPFLAGS = -I$(PYTHONINC) -I$(top_builddir) -I$(top_srcdir) \
# this. # this.
SWIGFLAGS = -c++ -python -py3 -O -nofastproxy SWIGFLAGS = -c++ -python -py3 -O -nofastproxy
EXTRA_DIST = spot/impl.i buddy.i EXTRA_DIST = buddy.i spot/impl.i spot/ltsmin.i
python_PYTHON = \ python_PYTHON = \
$(srcdir)/spot/__init__.py \ $(srcdir)/spot/__init__.py \
$(srcdir)/spot/impl.py \ $(srcdir)/spot/impl.py \
$(srcdir)/spot/ltsmin.py \
$(srcdir)/buddy.py $(srcdir)/buddy.py
pyexec_LTLIBRARIES = spot/_impl.la _buddy.la pyexec_LTLIBRARIES = _buddy.la spot/_impl.la spot/_ltsmin.la
MAINTAINERCLEANFILES = \ MAINTAINERCLEANFILES = \
$(srcdir)/spot/impl_wrap.cxx $(srcdir)/spot/impl.py \ $(srcdir)/spot/impl_wrap.cxx $(srcdir)/spot/impl.py \
$(srcdir)/spot/ltsmin_wrap.cxx $(srcdir)/spot/ltsmin.py \
$(srcdir)/buddy_wrap.cxx $(srcdir)/buddy.py $(srcdir)/buddy_wrap.cxx $(srcdir)/buddy.py
## spot ## spot
...@@ -56,6 +58,20 @@ $(srcdir)/spot/impl.py: $(srcdir)/spot/impl.i ...@@ -56,6 +58,20 @@ $(srcdir)/spot/impl.py: $(srcdir)/spot/impl.i
$(MAKE) $(AM_MAKEFLAGS) spot/impl_wrap.cxx $(MAKE) $(AM_MAKEFLAGS) spot/impl_wrap.cxx
## spot-ltsmin
spot__ltsmin_la_SOURCES = $(srcdir)/spot/ltsmin_wrap.cxx
spot__ltsmin_la_LDFLAGS = -avoid-version -module $(SYMBOLIC_LDFLAGS)
spot__ltsmin_la_LIBADD = $(top_builddir)/spot/libspot.la \
$(top_builddir)/spot/ltsmin/libspotltsmin.la
$(srcdir)/spot/ltsmin_wrap.cxx: $(srcdir)/spot/ltsmin.i
$(SWIG) $(SWIGFLAGS) -I$(srcdir) -I$(top_srcdir) $(srcdir)/spot/ltsmin.i
$(srcdir)/spot/ltsmin.py: $(srcdir)/spot/ltsmin.i
$(MAKE) $(AM_MAKEFLAGS) spot/ltsmin_wrap.cxx
## buddy ## buddy
_buddy_la_SOURCES = $(srcdir)/buddy_wrap.cxx _buddy_la_SOURCES = $(srcdir)/buddy_wrap.cxx
......
...@@ -872,5 +872,5 @@ def sat_minimize(aut, acc=None, colored=False, ...@@ -872,5 +872,5 @@ def sat_minimize(aut, acc=None, colored=False,
args += ',max-states=' + str(max_states) args += ',max-states=' + str(max_states)
if dichotomy: if dichotomy:
args += ',dichotomy'; args += ',dichotomy';
from spot_impl import sat_minimize as sm from spot.impl import sat_minimize as sm
return sm(aut, args, state_based) return sm(aut, args, state_based)
...@@ -143,6 +143,9 @@ ...@@ -143,6 +143,9 @@
#include <spot/parseaut/public.hh> #include <spot/parseaut/public.hh>
#include <spot/kripke/kripke.hh>
#include <spot/kripke/fairkripke.hh>
#include <spot/ta/ta.hh> #include <spot/ta/ta.hh>
#include <spot/ta/tgta.hh> #include <spot/ta/tgta.hh>
#include <spot/ta/taexplicit.hh> #include <spot/ta/taexplicit.hh>
...@@ -434,6 +437,9 @@ namespace std { ...@@ -434,6 +437,9 @@ namespace std {
%include <spot/parseaut/public.hh> %include <spot/parseaut/public.hh>
%include <spot/kripke/fairkripke.hh>
%include <spot/kripke/kripke.hh>
%include <spot/ta/ta.hh> %include <spot/ta/ta.hh>
%include <spot/ta/tgta.hh> %include <spot/ta/tgta.hh>
%include <spot/ta/taexplicit.hh> %include <spot/ta/taexplicit.hh>
......
// -*- coding: utf-8 -*-
// Copyright (C) 2016 Laboratoire de Recherche et Développement de
// l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
//
// Spot is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// Spot is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
%{
// Workaround for SWIG 2.0.2 using ptrdiff_t but not including cstddef.
// It matters with g++ 4.6.
#include <cstddef>
%}
%module(package="spot", director="1") ltsmin
%include "std_string.i"
%include "std_set.i"
%include "std_shared_ptr.i"
%shared_ptr(spot::bdd_dict)
%shared_ptr(spot::twa)
%shared_ptr(spot::kripke)
%shared_ptr(spot::fair_kripke)
%{
#include <spot/ltsmin/ltsmin.hh>
using namespace spot;
%}
%import(module="spot.impl") <spot/misc/common.hh>
%import(module="spot.impl") <spot/twa/bdddict.hh>
%import(module="spot.impl") <spot/twa/twa.hh>
%import(module="spot.impl") <spot/tl/formula.hh>
%import(module="spot.impl") <spot/tl/apcollect.hh>
%import(module="spot.impl") <spot/kripke/fairkripke.hh>
%import(module="spot.impl") <spot/kripke/kripke.hh>
namespace std {
%template(atomic_prop_set) set<spot::formula>;
}
%include <spot/ltsmin/ltsmin.hh>
%pythoncode %{
import spot
def load(filename, ap_set, dict=spot._bdd_dict,
dead=spot.formula_ap('dead'),
compress=2, debug=False):
s = spot.atomic_prop_set()
for ap in ap_set:
s.insert(spot.formula_ap(ap))
return load_ltsmin(filename, dict, s, dead, compress, debug)
%}
...@@ -298,6 +298,7 @@ TESTS_python = \ ...@@ -298,6 +298,7 @@ TESTS_python = \
python/ltl2tgba.test \ python/ltl2tgba.test \
python/ltlparse.py \ python/ltlparse.py \
python/ltlsimple.py \ python/ltlsimple.py \
python/ltsmin.ipynb \
python/minato.py \ python/minato.py \
python/optionmap.py \ python/optionmap.py \
python/parsetgba.py \ python/parsetgba.py \
...@@ -315,6 +316,8 @@ TESTS_python = \ ...@@ -315,6 +316,8 @@ TESTS_python = \
python/trival.py python/trival.py
endif endif
CLEANFILES = python/finite.dve2C python/finite.dve.cpp
SUFFIXES = .ipynb .html SUFFIXES = .ipynb .html
.ipynb.html: .ipynb.html:
$(IPYTHON) nbconvert $< --to html --stdout >$@ $(IPYTHON) nbconvert $< --to html --stdout >$@
......
...@@ -185,6 +185,10 @@ def run_cell(kc, cell): ...@@ -185,6 +185,10 @@ def run_cell(kc, cell):
out.ename = content['ename'] out.ename = content['ename']
out.evalue = content['evalue'] out.evalue = content['evalue']
out.traceback = content['traceback'] out.traceback = content['traceback']
# sys.exit(77) is used to Skip the test.
if out.ename == 'SystemExit' and out.evalue == '77':
sys.exit(77)
else: else:
print("unhandled iopub msg:", msg_type) print("unhandled iopub msg:", msg_type)
......
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