Commit 0e70e3e7 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

Updated doctest and fixed some parsing errors

parent 4782082b
......@@ -263,7 +263,7 @@ static PyObject* PyBobLearnEMMAPGMMTrainer_initialize(PyBobLearnEMMAPGMMTrainerO
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobLearnEMGMMMachine_Type, &gmm_machine)){
PyErr_Format(PyExc_RuntimeError, "%s.%s. Was not possible to read :py:class:`bob.learn.em.GMMMachine`", Py_TYPE(self)->tp_name, initialize.name());
Py_RETURN_NONE;
return 0;
}
self->cxx->initialize(*gmm_machine->cxx);
BOB_CATCH_MEMBER("cannot perform the initialize method", 0)
......@@ -296,7 +296,7 @@ static PyObject* PyBobLearnEMMAPGMMTrainer_eStep(PyBobLearnEMMAPGMMTrainerObject
PyBobLearnEMGMMMachineObject* gmm_machine;
PyBlitzArrayObject* data = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O&", kwlist, &PyBobLearnEMGMMMachine_Type, &gmm_machine,
&PyBlitzArray_Converter, &data)) Py_RETURN_NONE;
&PyBlitzArray_Converter, &data)) return 0;
auto data_ = make_safe(data);
self->cxx->eStep(*gmm_machine->cxx, *PyBlitzArrayCxx_AsBlitz<double,2>(data));
......@@ -327,7 +327,7 @@ static PyObject* PyBobLearnEMMAPGMMTrainer_mStep(PyBobLearnEMMAPGMMTrainerObject
PyBobLearnEMGMMMachineObject* gmm_machine;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobLearnEMGMMMachine_Type, &gmm_machine)) Py_RETURN_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobLearnEMGMMMachine_Type, &gmm_machine)) return 0;
self->cxx->mStep(*gmm_machine->cxx);
......@@ -353,7 +353,7 @@ static PyObject* PyBobLearnEMMAPGMMTrainer_compute_likelihood(PyBobLearnEMMAPGMM
char** kwlist = compute_likelihood.kwlist(0);
PyBobLearnEMGMMMachineObject* gmm_machine;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobLearnEMGMMMachine_Type, &gmm_machine)) Py_RETURN_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobLearnEMGMMMachine_Type, &gmm_machine)) return 0;
double value = self->cxx->computeLikelihood(*gmm_machine->cxx);
return Py_BuildValue("d", value);
......
......@@ -168,7 +168,7 @@ static PyObject* PyBobLearnEMMLGMMTrainer_initialize(PyBobLearnEMMLGMMTrainerObj
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobLearnEMGMMMachine_Type, &gmm_machine)){
PyErr_Format(PyExc_RuntimeError, "%s.%s. Was not possible to read :py:class:`bob.learn.em.GMMMachine`", Py_TYPE(self)->tp_name, initialize.name());
Py_RETURN_NONE;
return 0;
}
self->cxx->initialize(*gmm_machine->cxx);
BOB_CATCH_MEMBER("cannot perform the initialize method", 0)
......@@ -201,7 +201,7 @@ static PyObject* PyBobLearnEMMLGMMTrainer_eStep(PyBobLearnEMMLGMMTrainerObject*
PyBobLearnEMGMMMachineObject* gmm_machine;
PyBlitzArrayObject* data = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O&", kwlist, &PyBobLearnEMGMMMachine_Type, &gmm_machine,
&PyBlitzArray_Converter, &data)) Py_RETURN_NONE;
&PyBlitzArray_Converter, &data)) return 0;
auto data_ = make_safe(data);
self->cxx->eStep(*gmm_machine->cxx, *PyBlitzArrayCxx_AsBlitz<double,2>(data));
......@@ -232,7 +232,7 @@ static PyObject* PyBobLearnEMMLGMMTrainer_mStep(PyBobLearnEMMLGMMTrainerObject*
PyBobLearnEMGMMMachineObject* gmm_machine;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobLearnEMGMMMachine_Type, &gmm_machine)) Py_RETURN_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobLearnEMGMMMachine_Type, &gmm_machine)) return 0;
self->cxx->mStep(*gmm_machine->cxx);
......@@ -258,7 +258,7 @@ static PyObject* PyBobLearnEMMLGMMTrainer_compute_likelihood(PyBobLearnEMMLGMMTr
char** kwlist = compute_likelihood.kwlist(0);
PyBobLearnEMGMMMachineObject* gmm_machine;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobLearnEMGMMMachine_Type, &gmm_machine)) Py_RETURN_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobLearnEMGMMMachine_Type, &gmm_machine)) return 0;
double value = self->cxx->computeLikelihood(*gmm_machine->cxx);
return Py_BuildValue("d", value);
......
......@@ -37,7 +37,7 @@ class IVectorTrainer (_IVectorTrainer):
"""
#Initialization
self.initialize(ivector_machine, data);
self.initialize(ivector_machine);
for i in range(self._max_iterations):
#eStep
......
......@@ -212,7 +212,7 @@ static PyObject* PyBobLearnEMEMPCATrainer_initialize(PyBobLearnEMEMPCATrainerObj
PyBlitzArrayObject* data = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O&", kwlist, &PyBobLearnLinearMachine_Type, &linear_machine,
&PyBlitzArray_Converter, &data)) Py_RETURN_NONE;
&PyBlitzArray_Converter, &data)) return 0;
auto data_ = make_safe(data);
self->cxx->initialize(*linear_machine->cxx, *PyBlitzArrayCxx_AsBlitz<double,2>(data));
......@@ -242,7 +242,7 @@ static PyObject* PyBobLearnEMEMPCATrainer_eStep(PyBobLearnEMEMPCATrainerObject*
PyBobLearnLinearMachineObject* linear_machine;
PyBlitzArrayObject* data = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O&", kwlist, &PyBobLearnLinearMachine_Type, &linear_machine,
&PyBlitzArray_Converter, &data)) Py_RETURN_NONE;
&PyBlitzArray_Converter, &data)) return 0;
auto data_ = make_safe(data);
self->cxx->eStep(*linear_machine->cxx, *PyBlitzArrayCxx_AsBlitz<double,2>(data));
......@@ -273,7 +273,7 @@ static PyObject* PyBobLearnEMEMPCATrainer_mStep(PyBobLearnEMEMPCATrainerObject*
PyBobLearnLinearMachineObject* linear_machine;
PyBlitzArrayObject* data = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O&", kwlist, &PyBobLearnLinearMachine_Type, &linear_machine,
&PyBlitzArray_Converter, &data)) Py_RETURN_NONE;
&PyBlitzArray_Converter, &data)) return 0;
auto data_ = make_safe(data);
self->cxx->mStep(*linear_machine->cxx, *PyBlitzArrayCxx_AsBlitz<double,2>(data));
......@@ -301,7 +301,7 @@ static PyObject* PyBobLearnEMEMPCATrainer_compute_likelihood(PyBobLearnEMEMPCATr
char** kwlist = compute_likelihood.kwlist(0);
PyBobLearnLinearMachineObject* linear_machine;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobLearnLinearMachine_Type, &linear_machine)) Py_RETURN_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobLearnLinearMachine_Type, &linear_machine)) return 0;
double value = self->cxx->computeLikelihood(*linear_machine->cxx);
return Py_BuildValue("d", value);
......
......@@ -315,11 +315,11 @@ static PyObject* PyBobLearnEMGaussian_resize(PyBobLearnEMGaussianObject* self, P
char** kwlist = resize.kwlist(0);
int input = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &input)) Py_RETURN_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &input)) return 0;
if (input <= 0){
PyErr_Format(PyExc_TypeError, "input must be greater than zero");
resize.print_usage();
Py_RETURN_NONE;
return 0;
}
self->cxx->setNInputs(input);
......@@ -345,7 +345,7 @@ static PyObject* PyBobLearnEMGaussian_loglikelihood(PyBobLearnEMGaussianObject*
PyBlitzArrayObject* input = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&", kwlist, &PyBlitzArray_Converter, &input)) Py_RETURN_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&", kwlist, &PyBlitzArray_Converter, &input)) return 0;
//protects acquired resources through this scope
auto input_ = make_safe(input);
......@@ -369,7 +369,7 @@ static PyObject* PyBobLearnEMGaussian_loglikelihood_(PyBobLearnEMGaussianObject*
char** kwlist = log_likelihood_.kwlist(0);
PyBlitzArrayObject* input = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&", kwlist, &PyBlitzArray_Converter, &input)) Py_RETURN_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&", kwlist, &PyBlitzArray_Converter, &input)) return 0;
//protects acquired resources through this scope
auto input_ = make_safe(input);
......
......@@ -553,7 +553,7 @@ static PyObject* PyBobLearnEMGMMMachine_loglikelihood(PyBobLearnEMGMMMachineObje
PyBlitzArrayObject* input = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&", kwlist, &PyBlitzArray_Converter, &input)) Py_RETURN_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&", kwlist, &PyBlitzArray_Converter, &input)) return 0;
//protects acquired resources through this scope
auto input_ = make_safe(input);
......@@ -581,7 +581,7 @@ static PyObject* PyBobLearnEMGMMMachine_loglikelihood_(PyBobLearnEMGMMMachineObj
PyBlitzArrayObject* input = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&", kwlist, &PyBlitzArray_Converter, &input)) Py_RETURN_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&", kwlist, &PyBlitzArray_Converter, &input)) return 0;
//protects acquired resources through this scope
auto input_ = make_safe(input);
......@@ -612,11 +612,17 @@ static PyObject* PyBobLearnEMGMMMachine_accStatistics(PyBobLearnEMGMMMachineObje
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O!", kwlist, &PyBlitzArray_Converter,&input,
&PyBobLearnEMGMMStats_Type, &stats))
Py_RETURN_NONE;
return 0;
//protects acquired resources through this scope
auto input_ = make_safe(input);
self->cxx->accStatistics(*PyBlitzArrayCxx_AsBlitz<double,2>(input), *stats->cxx);
blitz::Array<double,2> blitz_test = *PyBlitzArrayCxx_AsBlitz<double,2>(input);
if (blitz_test.extent(1)==0)
self->cxx->accStatistics(*PyBlitzArrayCxx_AsBlitz<double,1>(input), *stats->cxx);
else
self->cxx->accStatistics(blitz_test, *stats->cxx);
BOB_CATCH_MEMBER("cannot accumulate the statistics", 0)
Py_RETURN_NONE;
......@@ -641,15 +647,18 @@ static PyObject* PyBobLearnEMGMMMachine_accStatistics_(PyBobLearnEMGMMMachineObj
PyBlitzArrayObject* input = 0;
PyBobLearnEMGMMStatsObject* stats = 0;
if(!PyArg_ParseTupleAndKeywords(args, kwargs, "O&O!", kwlist, &PyBlitzArray_Converter,&input,
&PyBobLearnEMGMMStats_Type, &stats))
Py_RETURN_NONE;
return 0;
//protects acquired resources through this scope
auto input_ = make_safe(input);
self->cxx->accStatistics_(*PyBlitzArrayCxx_AsBlitz<double,2>(input), *stats->cxx);
blitz::Array<double,2> blitz_test = *PyBlitzArrayCxx_AsBlitz<double,2>(input);
if (blitz_test.extent(1)==0)
self->cxx->accStatistics_(*PyBlitzArrayCxx_AsBlitz<double,1>(input), *stats->cxx);
else
self->cxx->accStatistics_(blitz_test, *stats->cxx);
BOB_CATCH_MEMBER("cannot accumulate the statistics", 0)
Py_RETURN_NONE;
......@@ -685,7 +694,6 @@ static PyObject* PyBobLearnEMGMMMachine_setVarianceThresholds_method(PyBobLearnE
return 0;
BOB_CATCH_MEMBER("cannot accumulate set the variance threshold", 0)
Py_RETURN_NONE;
}
......@@ -710,7 +718,7 @@ static PyObject* PyBobLearnEMGMMMachine_get_gaussian(PyBobLearnEMGMMMachineObjec
int i = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &i)) Py_RETURN_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &i)) return 0;
boost::shared_ptr<bob::learn::em::Gaussian> gaussian = self->cxx->getGaussian(i);
......
......@@ -482,7 +482,7 @@ static PyObject* PyBobLearnEMGMMStats_resize(PyBobLearnEMGMMStatsObject* self, P
int n_gaussians = 0;
int n_inputs = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii", kwlist, &n_gaussians, &n_inputs)) Py_RETURN_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii", kwlist, &n_gaussians, &n_inputs)) return 0;
if (n_gaussians <= 0){
PyErr_Format(PyExc_TypeError, "n_gaussians must be greater than zero");
......
......@@ -442,7 +442,7 @@ static PyObject* PyBobLearnEMISVBase_resize(PyBobLearnEMISVBaseObject* self, PyO
int rU = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &rU)) Py_RETURN_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &rU)) return 0;
if (rU <= 0){
PyErr_Format(PyExc_TypeError, "rU must be greater than zero");
......
......@@ -420,7 +420,7 @@ static PyObject* PyBobLearnEMISVMachine_estimateX(PyBobLearnEMISVMachineObject*
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O&", kwlist, &PyBobLearnEMGMMStats_Type, &stats,
&PyBlitzArray_Converter,&input))
Py_RETURN_NONE;
return 0;
//protects acquired resources through this scope
auto input_ = make_safe(input);
......@@ -451,7 +451,7 @@ static PyObject* PyBobLearnEMISVMachine_estimateUx(PyBobLearnEMISVMachineObject*
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O&", kwlist, &PyBobLearnEMGMMStats_Type, &stats,
&PyBlitzArray_Converter,&input))
Py_RETURN_NONE;
return 0;
//protects acquired resources through this scope
auto input_ = make_safe(input);
......@@ -482,7 +482,7 @@ static PyObject* PyBobLearnEMISVMachine_ForwardUx(PyBobLearnEMISVMachineObject*
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O&", kwlist, &PyBobLearnEMGMMStats_Type, &stats,
&PyBlitzArray_Converter,&ux_input))
Py_RETURN_NONE;
return 0;
//protects acquired resources through this scope
auto ux_input_ = make_safe(ux_input);
......@@ -510,7 +510,7 @@ static PyObject* PyBobLearnEMISVMachine_Forward(PyBobLearnEMISVMachineObject* se
PyBobLearnEMGMMStatsObject* stats = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobLearnEMGMMStats_Type, &stats))
Py_RETURN_NONE;
return 0;
//protects acquired resources through this scope
double score = self->cxx->forward(*stats->cxx);
......
......@@ -391,7 +391,7 @@ static PyObject* PyBobLearnEMISVTrainer_initialize(PyBobLearnEMISVTrainerObject*
PyObject* stats = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!", kwlist, &PyBobLearnEMISVBase_Type, &isv_base,
&PyList_Type, &stats)) Py_RETURN_NONE;
&PyList_Type, &stats)) return 0;
std::vector<std::vector<boost::shared_ptr<bob::learn::em::GMMStats> > > training_data;
if(extract_GMMStats_2d(stats ,training_data)==0)
......@@ -405,7 +405,7 @@ static PyObject* PyBobLearnEMISVTrainer_initialize(PyBobLearnEMISVTrainerObject*
/*** e_step ***/
static auto e_step = bob::extension::FunctionDoc(
"e_step",
"eStep",
"Call the e-step procedure (for the U subspace).",
"",
true
......@@ -423,7 +423,7 @@ static PyObject* PyBobLearnEMISVTrainer_e_step(PyBobLearnEMISVTrainerObject* sel
PyObject* stats = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!", kwlist, &PyBobLearnEMISVBase_Type, &isv_base,
&PyList_Type, &stats)) Py_RETURN_NONE;
&PyList_Type, &stats)) return 0;
std::vector<std::vector<boost::shared_ptr<bob::learn::em::GMMStats> > > training_data;
if(extract_GMMStats_2d(stats ,training_data)==0)
......@@ -437,7 +437,7 @@ static PyObject* PyBobLearnEMISVTrainer_e_step(PyBobLearnEMISVTrainerObject* sel
/*** m_step ***/
static auto m_step = bob::extension::FunctionDoc(
"m_step",
"mStep",
"Call the m-step procedure (for the U subspace).",
"",
true
......@@ -486,7 +486,7 @@ static PyObject* PyBobLearnEMISVTrainer_enrol(PyBobLearnEMISVTrainerObject* self
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!i", kwlist, &PyBobLearnEMISVMachine_Type, &isv_machine,
&PyList_Type, &stats, &n_iter)) Py_RETURN_NONE;
&PyList_Type, &stats, &n_iter)) return 0;
std::vector<boost::shared_ptr<bob::learn::em::GMMStats> > training_data;
if(extract_GMMStats_1d(stats ,training_data)==0)
......
......@@ -484,7 +484,7 @@ static PyObject* PyBobLearnEMIVectorMachine_Forward(PyBobLearnEMIVectorMachineOb
PyBobLearnEMGMMStatsObject* stats = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobLearnEMGMMStats_Type, &stats))
Py_RETURN_NONE;
return 0;
blitz::Array<double,1> ivector(self->cxx->getDimRt());
self->cxx->forward(*stats->cxx, ivector);
......@@ -512,7 +512,7 @@ static PyObject* PyBobLearnEMIVectorMachine_resize(PyBobLearnEMIVectorMachineObj
int rT = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &rT)) Py_RETURN_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &rT)) return 0;
if (rT < 1){
PyErr_Format(PyExc_TypeError, "rU must be greater than one");
......@@ -545,7 +545,7 @@ static PyObject* PyBobLearnEMIVectorMachine_compute_Id_TtSigmaInvT__(PyBobLearnE
PyBobLearnEMGMMStatsObject* stats = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobLearnEMGMMStats_Type, &stats))
Py_RETURN_NONE;
return 0;
blitz::Array<double,2> output(self->cxx->getDimRt(), self->cxx->getDimRt());
......@@ -574,7 +574,7 @@ static PyObject* PyBobLearnEMIVectorMachine_compute_TtSigmaInvFnorm__(PyBobLearn
PyBobLearnEMGMMStatsObject* stats = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobLearnEMGMMStats_Type, &stats))
Py_RETURN_NONE;
return 0;
blitz::Array<double,1> output(self->cxx->getDimRt());
......
......@@ -323,7 +323,7 @@ static PyObject* PyBobLearnEMIVectorTrainer_initialize(PyBobLearnEMIVectorTraine
PyBobLearnEMIVectorMachineObject* ivector_machine = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobLearnEMIVectorMachine_Type, &ivector_machine)) Py_RETURN_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobLearnEMIVectorMachine_Type, &ivector_machine)) return 0;
self->cxx->initialize(*ivector_machine->cxx);
......@@ -335,7 +335,7 @@ static PyObject* PyBobLearnEMIVectorTrainer_initialize(PyBobLearnEMIVectorTraine
/*** e_step ***/
static auto e_step = bob::extension::FunctionDoc(
"e_step",
"eStep",
"Call the e-step procedure (for the U subspace).",
"",
true
......@@ -353,7 +353,7 @@ static PyObject* PyBobLearnEMIVectorTrainer_e_step(PyBobLearnEMIVectorTrainerObj
PyObject* stats = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!", kwlist, &PyBobLearnEMIVectorMachine_Type, &ivector_machine,
&PyList_Type, &stats)) Py_RETURN_NONE;
&PyList_Type, &stats)) return 0;
std::vector<bob::learn::em::GMMStats> training_data;
if(extract_GMMStats_1d(stats ,training_data)==0)
......@@ -366,7 +366,7 @@ static PyObject* PyBobLearnEMIVectorTrainer_e_step(PyBobLearnEMIVectorTrainerObj
/*** m_step ***/
static auto m_step = bob::extension::FunctionDoc(
"m_step",
"mStep",
"Call the m-step procedure (for the U subspace).",
"",
true
......@@ -381,7 +381,7 @@ static PyObject* PyBobLearnEMIVectorTrainer_m_step(PyBobLearnEMIVectorTrainerObj
PyBobLearnEMIVectorMachineObject* ivector_machine = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobLearnEMIVectorMachine_Type, &ivector_machine)) Py_RETURN_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobLearnEMIVectorMachine_Type, &ivector_machine)) return 0;
self->cxx->mStep(*ivector_machine->cxx);
......
......@@ -488,7 +488,7 @@ static PyObject* PyBobLearnEMJFABase_resize(PyBobLearnEMJFABaseObject* self, PyO
int rU = 0;
int rV = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii", kwlist, &rU, &rV)) Py_RETURN_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii", kwlist, &rU, &rV)) return 0;
if (rU <= 0){
PyErr_Format(PyExc_TypeError, "rU must be greater than zero");
......
......@@ -457,7 +457,7 @@ static PyObject* PyBobLearnEMJFAMachine_estimateX(PyBobLearnEMJFAMachineObject*
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O&", kwlist, &PyBobLearnEMGMMStats_Type, &stats,
&PyBlitzArray_Converter,&input))
Py_RETURN_NONE;
return 0;
//protects acquired resources through this scope
auto input_ = make_safe(input);
......@@ -488,7 +488,7 @@ static PyObject* PyBobLearnEMJFAMachine_estimateUx(PyBobLearnEMJFAMachineObject*
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O&", kwlist, &PyBobLearnEMGMMStats_Type, &stats,
&PyBlitzArray_Converter,&input))
Py_RETURN_NONE;
return 0;
//protects acquired resources through this scope
auto input_ = make_safe(input);
......@@ -519,7 +519,7 @@ static PyObject* PyBobLearnEMJFAMachine_ForwardUx(PyBobLearnEMJFAMachineObject*
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O&", kwlist, &PyBobLearnEMGMMStats_Type, &stats,
&PyBlitzArray_Converter,&ux_input))
Py_RETURN_NONE;
return 0;
//protects acquired resources through this scope
auto ux_input_ = make_safe(ux_input);
......@@ -548,7 +548,7 @@ static PyObject* PyBobLearnEMJFAMachine_Forward(PyBobLearnEMJFAMachineObject* se
PyBobLearnEMGMMStatsObject* stats = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!", kwlist, &PyBobLearnEMGMMStats_Type, &stats))
Py_RETURN_NONE;
return 0;
//protects acquired resources through this scope
double score = self->cxx->forward(*stats->cxx);
......
......@@ -567,7 +567,7 @@ static PyObject* PyBobLearnEMJFATrainer_initialize(PyBobLearnEMJFATrainerObject*
PyObject* stats = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!", kwlist, &PyBobLearnEMJFABase_Type, &jfa_base,
&PyList_Type, &stats)) Py_RETURN_NONE;
&PyList_Type, &stats)) return 0;
std::vector<std::vector<boost::shared_ptr<bob::learn::em::GMMStats> > > training_data;
if(extract_GMMStats_2d(stats ,training_data)==0)
......@@ -599,7 +599,7 @@ static PyObject* PyBobLearnEMJFATrainer_e_step1(PyBobLearnEMJFATrainerObject* se
PyObject* stats = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!", kwlist, &PyBobLearnEMJFABase_Type, &jfa_base,
&PyList_Type, &stats)) Py_RETURN_NONE;
&PyList_Type, &stats)) return 0;
std::vector<std::vector<boost::shared_ptr<bob::learn::em::GMMStats> > > training_data;
if(extract_GMMStats_2d(stats ,training_data)==0)
......@@ -632,7 +632,7 @@ static PyObject* PyBobLearnEMJFATrainer_m_step1(PyBobLearnEMJFATrainerObject* se
PyObject* stats = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!", kwlist, &PyBobLearnEMJFABase_Type, &jfa_base,
&PyList_Type, &stats)) Py_RETURN_NONE;
&PyList_Type, &stats)) return 0;
std::vector<std::vector<boost::shared_ptr<bob::learn::em::GMMStats> > > training_data;
if(extract_GMMStats_2d(stats ,training_data)==0)
......@@ -664,7 +664,7 @@ static PyObject* PyBobLearnEMJFATrainer_finalize1(PyBobLearnEMJFATrainerObject*
PyObject* stats = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!", kwlist, &PyBobLearnEMJFABase_Type, &jfa_base,
&PyList_Type, &stats)) Py_RETURN_NONE;
&PyList_Type, &stats)) return 0;
std::vector<std::vector<boost::shared_ptr<bob::learn::em::GMMStats> > > training_data;
if(extract_GMMStats_2d(stats ,training_data)==0)
......@@ -696,7 +696,7 @@ static PyObject* PyBobLearnEMJFATrainer_e_step2(PyBobLearnEMJFATrainerObject* se
PyObject* stats = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!", kwlist, &PyBobLearnEMJFABase_Type, &jfa_base,
&PyList_Type, &stats)) Py_RETURN_NONE;
&PyList_Type, &stats)) return 0;
std::vector<std::vector<boost::shared_ptr<bob::learn::em::GMMStats> > > training_data;
if(extract_GMMStats_2d(stats ,training_data)==0)
......@@ -728,7 +728,7 @@ static PyObject* PyBobLearnEMJFATrainer_m_step2(PyBobLearnEMJFATrainerObject* se
PyObject* stats = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!", kwlist, &PyBobLearnEMJFABase_Type, &jfa_base,
&PyList_Type, &stats)) Py_RETURN_NONE;
&PyList_Type, &stats)) return 0;
std::vector<std::vector<boost::shared_ptr<bob::learn::em::GMMStats> > > training_data;
if(extract_GMMStats_2d(stats ,training_data)==0)
......@@ -760,7 +760,7 @@ static PyObject* PyBobLearnEMJFATrainer_finalize2(PyBobLearnEMJFATrainerObject*
PyObject* stats = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!", kwlist, &PyBobLearnEMJFABase_Type, &jfa_base,
&PyList_Type, &stats)) Py_RETURN_NONE;
&PyList_Type, &stats)) return 0;
std::vector<std::vector<boost::shared_ptr<bob::learn::em::GMMStats> > > training_data;
if(extract_GMMStats_2d(stats ,training_data)==0)
......@@ -792,7 +792,7 @@ static PyObject* PyBobLearnEMJFATrainer_e_step3(PyBobLearnEMJFATrainerObject* se
PyObject* stats = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!", kwlist, &PyBobLearnEMJFABase_Type, &jfa_base,
&PyList_Type, &stats)) Py_RETURN_NONE;
&PyList_Type, &stats)) return 0;
std::vector<std::vector<boost::shared_ptr<bob::learn::em::GMMStats> > > training_data;
if(extract_GMMStats_2d(stats ,training_data)==0)
......@@ -824,7 +824,7 @@ static PyObject* PyBobLearnEMJFATrainer_m_step3(PyBobLearnEMJFATrainerObject* se
PyObject* stats = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!", kwlist, &PyBobLearnEMJFABase_Type, &jfa_base,
&PyList_Type, &stats)) Py_RETURN_NONE;
&PyList_Type, &stats)) return 0;
std::vector<std::vector<boost::shared_ptr<bob::learn::em::GMMStats> > > training_data;
if(extract_GMMStats_2d(stats ,training_data)==0)
......@@ -856,7 +856,7 @@ static PyObject* PyBobLearnEMJFATrainer_finalize3(PyBobLearnEMJFATrainerObject*
PyObject* stats = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!", kwlist, &PyBobLearnEMJFABase_Type, &jfa_base,
&PyList_Type, &stats)) Py_RETURN_NONE;
&PyList_Type, &stats)) return 0;
std::vector<std::vector<boost::shared_ptr<bob::learn::em::GMMStats> > > training_data;
if(extract_GMMStats_2d(stats ,training_data)==0)
......@@ -891,7 +891,7 @@ static PyObject* PyBobLearnEMJFATrainer_enrol(PyBobLearnEMJFATrainerObject* self
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!i", kwlist, &PyBobLearnEMJFAMachine_Type, &jfa_machine,
&PyList_Type, &stats, &n_iter)) Py_RETURN_NONE;
&PyList_Type, &stats, &n_iter)) return 0;
std::vector<boost::shared_ptr<bob::learn::em::GMMStats> > training_data;
if(extract_GMMStats_1d(stats ,training_data)==0)
......
......@@ -339,7 +339,7 @@ static PyObject* PyBobLearnEMKMeansMachine_resize(PyBobLearnEMKMeansMachineObjec
int n_means = 0;
int n_inputs = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii", kwlist, &n_means, &n_inputs)) Py_RETURN_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii", kwlist, &n_means, &n_inputs)) return 0;
if (n_means <= 0){
PyErr_Format(PyExc_TypeError, "n_means must be greater than zero");
......@@ -375,7 +375,7 @@ static PyObject* PyBobLearnEMKMeansMachine_get_mean(PyBobLearnEMKMeansMachineObj
char** kwlist = get_mean.kwlist(0);
int i = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &i)) Py_RETURN_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "i", kwlist, &i)) return 0;
return PyBlitzArrayCxx_AsConstNumpy(self->cxx->getMean(i));
......@@ -400,7 +400,7 @@ static PyObject* PyBobLearnEMKMeansMachine_set_mean(PyBobLearnEMKMeansMachineObj
int i = 0;
PyBlitzArrayObject* mean = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iO&", kwlist, &i, &PyBlitzArray_Converter, &mean)) Py_RETURN_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "iO&", kwlist, &i, &PyBlitzArray_Converter, &mean)) return 0;
//protects acquired resources through this scope
auto mean_ = make_safe(mean);
......@@ -434,7 +434,7 @@ static PyObject* PyBobLearnEMKMeansMachine_get_distance_from_mean(PyBobLearnEMKM
PyBlitzArrayObject* input = 0;
int i = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&i", kwlist, &PyBlitzArray_Converter, &input, &i)){
Py_RETURN_NONE;
return 0;
}
//protects acquired resources through this scope
......@@ -463,7 +463,7 @@ static PyObject* PyBobLearnEMKMeansMachine_get_closest_mean(PyBobLearnEMKMeansMa
char** kwlist = get_closest_mean.kwlist(0);
PyBlitzArrayObject* input = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&", kwlist, &PyBlitzArray_Converter, &input)) Py_RETURN_NONE;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&", kwlist, &PyBlitzArray_Converter, &input)) return 0;
//protects acquired resources through this scope
auto input_ = make_safe(input);
......@@ -494,7 +494,7 @@ static PyObject* PyBobLearnEMKMeansMachine_get_min_distance(PyBobLearnEMKMeansMa
char** kwlist = get_min_distance.kwlist(0);
PyBlitzArrayObject* input = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&", kwlist, &PyBlitzArray_Converter, &input)) Py_RETURN_NONE;