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.
This commit is contained in:
Alexandre Duret-Lutz 2016-01-24 19:45:59 +01:00
parent 215fcb799a
commit 5a9b0aa1c1
9 changed files with 635 additions and 6 deletions

View file

@ -32,15 +32,17 @@ AM_CPPFLAGS = -I$(PYTHONINC) -I$(top_builddir) -I$(top_srcdir) \
# this.
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 = \
$(srcdir)/spot/__init__.py \
$(srcdir)/spot/impl.py \
$(srcdir)/spot/ltsmin.py \
$(srcdir)/buddy.py
pyexec_LTLIBRARIES = spot/_impl.la _buddy.la
pyexec_LTLIBRARIES = _buddy.la spot/_impl.la spot/_ltsmin.la
MAINTAINERCLEANFILES = \
$(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
## spot
@ -56,6 +58,20 @@ $(srcdir)/spot/impl.py: $(srcdir)/spot/impl.i
$(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_la_SOURCES = $(srcdir)/buddy_wrap.cxx

View file

@ -872,5 +872,5 @@ def sat_minimize(aut, acc=None, colored=False,
args += ',max-states=' + str(max_states)
if 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)

View file

@ -143,6 +143,9 @@
#include <spot/parseaut/public.hh>
#include <spot/kripke/kripke.hh>
#include <spot/kripke/fairkripke.hh>
#include <spot/ta/ta.hh>
#include <spot/ta/tgta.hh>
#include <spot/ta/taexplicit.hh>
@ -434,6 +437,9 @@ namespace std {
%include <spot/parseaut/public.hh>
%include <spot/kripke/fairkripke.hh>
%include <spot/kripke/kripke.hh>
%include <spot/ta/ta.hh>
%include <spot/ta/tgta.hh>
%include <spot/ta/taexplicit.hh>

66
python/spot/ltsmin.i Normal file
View file

@ -0,0 +1,66 @@
// -*- 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)
%}