[pyAgrum] fix a bug found by Quentin Falcand: lost reference to BN from Inference

parent 02a71239
......@@ -6557,6 +6557,11 @@ class LazyPropagation_double(_object):
self.this.append(this)
except __builtin__.Exception:
self.this = this
self._bn=args[0]#BN
__swig_destroy__ = _pyAgrum.delete_LazyPropagation_double
def __del__(self):
return None
......@@ -6863,6 +6868,11 @@ class ShaferShenoyInference_double(_object):
self.this.append(this)
except __builtin__.Exception:
self.this = this
self._bn=args[0]#BN
__swig_destroy__ = _pyAgrum.delete_ShaferShenoyInference_double
def __del__(self):
return None
......@@ -7164,6 +7174,11 @@ class VariableElimination_double(_object):
self.this.append(this)
except __builtin__.Exception:
self.this = this
self._bn=args[0]#BN
__swig_destroy__ = _pyAgrum.delete_VariableElimination_double
def __del__(self):
return None
......@@ -7423,6 +7438,11 @@ class GibbsSampling_double(_object):
self.this.append(this)
except __builtin__.Exception:
self.this = this
self._bn=BN
__swig_destroy__ = _pyAgrum.delete_GibbsSampling_double
def __del__(self):
return None
......@@ -7736,6 +7756,11 @@ class LoopyBeliefPropagation_double(ApproximationScheme):
self.this.append(this)
except __builtin__.Exception:
self.this = this
self._bn=BN
__swig_destroy__ = _pyAgrum.delete_LoopyBeliefPropagation_double
def __del__(self):
return None
......
......@@ -6557,6 +6557,11 @@ class LazyPropagation_double(_object):
self.this.append(this)
except __builtin__.Exception:
self.this = this
self._bn=args[0]#BN
__swig_destroy__ = _pyAgrum.delete_LazyPropagation_double
def __del__(self):
return None
......@@ -6863,6 +6868,11 @@ class ShaferShenoyInference_double(_object):
self.this.append(this)
except __builtin__.Exception:
self.this = this
self._bn=args[0]#BN
__swig_destroy__ = _pyAgrum.delete_ShaferShenoyInference_double
def __del__(self):
return None
......@@ -7164,6 +7174,11 @@ class VariableElimination_double(_object):
self.this.append(this)
except __builtin__.Exception:
self.this = this
self._bn=args[0]#BN
__swig_destroy__ = _pyAgrum.delete_VariableElimination_double
def __del__(self):
return None
......@@ -7423,6 +7438,11 @@ class GibbsSampling_double(_object):
self.this.append(this)
except __builtin__.Exception:
self.this = this
self._bn=BN
__swig_destroy__ = _pyAgrum.delete_GibbsSampling_double
def __del__(self):
return None
......@@ -7736,6 +7756,11 @@ class LoopyBeliefPropagation_double(ApproximationScheme):
self.this.append(this)
except __builtin__.Exception:
self.this = this
self._bn=BN
__swig_destroy__ = _pyAgrum.delete_LoopyBeliefPropagation_double
def __del__(self):
return None
......
%define IMPROVE_INFERENCE_API(classname)
%feature("shadow") classname::setEvidence %{
%feature("shadow") gum::classname<double>::setEvidence %{
def setEvidence(self, evidces):
if not isinstance(evidces, dict):
raise TypeError("setEvidence parameter must be a dict, not %s"%(type(evidces)))
......@@ -9,7 +8,7 @@ def setEvidence(self, evidces):
self.addEvidence(k,v)
%}
%feature("shadow") classname::updateEvidence %{
%feature("shadow") gum::classname<double>::updateEvidence %{
def updateEvidence(self, evidces):
if not isinstance(evidces, dict):
raise TypeError("setEvidence parameter must be a dict, not %s"%(type(evidces)))
......@@ -21,7 +20,7 @@ def updateEvidence(self, evidces):
self.addEvidence(k,v)
%}
%feature("shadow") classname::setTargets %{
%feature("shadow") gum::classname<double>::setTargets %{
def setTargets(self, targets):
if not isinstance(targets, set):
raise TypeError("setTargets parameter must be a set, not %s"%(type(targets)))
......@@ -33,7 +32,7 @@ def setTargets(self, targets):
// these void class extensions are rewritten by "shadow" declarations
%extend classname {
%extend gum::classname<double> {
void setEvidence(PyObject *evidces) {}
void updateEvidence(PyObject *evidces) {}
void setTargets(PyObject* targets) {}
......@@ -49,11 +48,11 @@ def setTargets(self, targets):
}
}
%enddef
IMPROVE_INFERENCE_API(gum::LazyPropagation<double>)
IMPROVE_INFERENCE_API(gum::ShaferShenoyInference<double>)
IMPROVE_INFERENCE_API(gum::VariableElimination<double>)
IMPROVE_INFERENCE_API(gum::GibbsSampling<double>)
IMPROVE_INFERENCE_API(gum::LoopyBeliefPropagation<double>)
IMPROVE_INFERENCE_API(LazyPropagation)
IMPROVE_INFERENCE_API(ShaferShenoyInference)
IMPROVE_INFERENCE_API(VariableElimination)
IMPROVE_INFERENCE_API(GibbsSampling)
IMPROVE_INFERENCE_API(LoopyBeliefPropagation)
%define IMPROVE_JOINT_INFERENCE_API(classname)
......@@ -95,3 +94,23 @@ IMPROVE_INFERENCE_API(gum::LoopyBeliefPropagation<double>)
IMPROVE_JOINT_INFERENCE_API(gum::LazyPropagation<double>)
IMPROVE_JOINT_INFERENCE_API(gum::ShaferShenoyInference<double>)
IMPROVE_JOINT_INFERENCE_API(gum::VariableElimination<double>)
// create a reference to python BN into python inference
%define IMPROVE_EXACT_INFERENCE_API(classname)
%pythonappend gum::classname<double>::classname %{
self._bn=args[0] #BN
%}
%enddef
IMPROVE_EXACT_INFERENCE_API(LazyPropagation)
IMPROVE_EXACT_INFERENCE_API(ShaferShenoyInference)
IMPROVE_EXACT_INFERENCE_API(VariableElimination)
%define IMPROVE_APPROX_INFERENCE_API(classname)
%pythonappend gum::classname<double>::classname %{
self._bn=BN
%}
%enddef
IMPROVE_APPROX_INFERENCE_API(GibbsSampling)
IMPROVE_APPROX_INFERENCE_API(LoopyBeliefPropagation)
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