Commit 0f698196 authored by Manuel Günther's avatar Manuel Günther
Browse files

Replaced mal-functioning PyArray_IsAnyScalar with novel PyBob_NumberCheck.

parent 580a3930
......@@ -10,6 +10,7 @@
#define BOB_LEARN_MLP_MODULE
#include <bob.blitz/cppapi.h>
#include <bob.blitz/cleanup.h>
#include <bob.extension/defines.h>
#include <bob.learn.mlp/api.h>
#include <bob.learn.activation/api.h>
#include <structmember.h>
......@@ -297,7 +298,7 @@ static PyObject* PyBobLearnCost_f
arg = PyList_GET_ITEM(tmp, 0);
}
if (PyArray_IsAnyScalar(arg))
if (PyBob_NumberCheck(arg))
return apply_scalar(self, s_f_str,
boost::bind(&bob::learn::mlp::Cost::f, self->cxx, _1, _2), args, kwds);
......@@ -346,7 +347,7 @@ static PyObject* PyBobLearnCost_f_prime
arg = PyList_GET_ITEM(tmp, 0);
}
if (PyArray_IsAnyScalar(arg))
if (PyBob_NumberCheck(arg))
return apply_scalar(self, s_f_prime_str,
boost::bind(&bob::learn::mlp::Cost::f_prime,
self->cxx, _1, _2), args, kwds);
......@@ -409,7 +410,7 @@ static PyObject* PyBobLearnCost_error
arg = PyList_GET_ITEM(tmp, 0);
}
if (PyArray_IsAnyScalar(arg))
if (PyBob_NumberCheck(arg))
return apply_scalar(self, s_error_str,
boost::bind(&bob::learn::mlp::Cost::error, self->cxx, _1, _2), args, kwds);
......
......@@ -10,6 +10,7 @@
#define BOB_LEARN_MLP_MODULE
#include <bob.blitz/cppapi.h>
#include <bob.blitz/cleanup.h>
#include <bob.extension/defines.h>
#include <bob.io.base/api.h>
#include <bob.learn.activation/api.h>
#include <bob.learn.mlp/api.h>
......@@ -275,7 +276,7 @@ static PyObject* PyBobLearnMLPMachine_getWeights
static int PyBobLearnMLPMachine_setWeights (PyBobLearnMLPMachineObject* self,
PyObject* weights, void* /*closure*/) {
if (PyArray_IsAnyScalar(weights)){
if (PyBob_NumberCheck(weights)){
double v = PyFloat_AsDouble(weights);
if (PyErr_Occurred()) return -1;
self->cxx->setWeights(v);
......@@ -361,7 +362,7 @@ static PyObject* PyBobLearnMLPMachine_getBiases
static int PyBobLearnMLPMachine_setBiases (PyBobLearnMLPMachineObject* self,
PyObject* biases, void* /*closure*/) {
if (PyArray_IsAnyScalar(biases)){
if (PyBob_NumberCheck(biases)){
double v = PyFloat_AsDouble(biases);
if (PyErr_Occurred()) return -1;
self->cxx->setBiases(v);
......@@ -435,7 +436,7 @@ static PyObject* PyBobLearnMLPMachine_getInputSubtraction
static int PyBobLearnMLPMachine_setInputSubtraction
(PyBobLearnMLPMachineObject* self, PyObject* o, void* /*closure*/) {
if (PyArray_IsAnyScalar(o)){
if (PyBob_NumberCheck(o)){
double v = PyFloat_AsDouble(o);
if (PyErr_Occurred()) return -1;
self->cxx->setInputSubtraction(v);
......@@ -482,7 +483,7 @@ static PyObject* PyBobLearnMLPMachine_getInputDivision
static int PyBobLearnMLPMachine_setInputDivision (PyBobLearnMLPMachineObject* self,
PyObject* o, void* /*closure*/) {
if (PyArray_IsAnyScalar(o)) {
if (PyBob_NumberCheck(o)) {
double v = PyFloat_AsDouble(o);
if (PyErr_Occurred()) return -1;
self->cxx->setInputDivision(v);
......
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