Commit 2bc9bac4 authored by Manuel Günther's avatar Manuel Günther

Switched to new FunctionDoc::kwlist function and corrected some documented parameters.

parent 80920c93
......@@ -44,11 +44,11 @@ static void scale_inner(PyBlitzArrayObject* input, PyBlitzArrayObject* input_mas
}
PyObject* PyBobIpBase_scale(PyObject*, PyObject* args, PyObject* kwargs) {
TRY
BOB_TRY
/* Parses input arguments in a single shot */
static char* kwlist1[] = {c("src"), c("scaling_factor"), NULL};
static char* kwlist2[] = {c("src"), c("dst"), NULL};
static char* kwlist3[] = {c("src"), c("src_mask"), c("dst"), c("dst_mask"), NULL};
char** kwlist1 = s_scale.kwlist(0);
char** kwlist2 = s_scale.kwlist(1);
char** kwlist3 = s_scale.kwlist(2);
// get the number of command line arguments
Py_ssize_t nargs = (args?PyTuple_Size(args):0) + (kwargs?PyDict_Size(kwargs):0);
......@@ -138,11 +138,11 @@ PyObject* PyBobIpBase_scale(PyObject*, PyObject* args, PyObject* kwargs) {
}
Py_RETURN_NONE;
CATCH_("scale", 0)
BOB_CATCH_FUNCTION("scale", 0)
}
bob::extension::FunctionDoc s_getScaledOutputShape = bob::extension::FunctionDoc(
bob::extension::FunctionDoc s_scaledOutputShape = bob::extension::FunctionDoc(
"scaled_output_shape",
"This function returns the shape of the scaled image for the given image and scale",
"The function tries its best to compute an integral-valued shape given the shape of the input image and the given scale factor. "
......@@ -157,10 +157,10 @@ bob::extension::FunctionDoc s_getScaledOutputShape = bob::extension::FunctionDoc
.add_return("scaled_shape", "(int, int) or (int, int, int)", "The shape of the scaled ``dst`` image required in a call to :py:func:`bob.ip.base.scale`")
;
PyObject* PyBobIpBase_getScaledOutputShape(PyObject*, PyObject* args, PyObject* kwargs) {
TRY
PyObject* PyBobIpBase_scaledOutputShape(PyObject*, PyObject* args, PyObject* kwargs) {
BOB_TRY
static char* kwlist1[] = {c("src"), c("scaling_factor"), 0};
char** kwlist1 = s_scaledOutputShape.kwlist();
// TODO: implement from shape
// static char* kwlist2[] = {c("shape"), c("scale"), 0};
......@@ -185,7 +185,7 @@ PyObject* PyBobIpBase_getScaledOutputShape(PyObject*, PyObject* args, PyObject*
}
return 0;
CATCH_("cannot get scaled output shape", 0)
BOB_CATCH_FUNCTION("cannot get scaled output shape", 0)
}
......@@ -221,11 +221,11 @@ static void rotate_inner(PyBlitzArrayObject* input, PyBlitzArrayObject* input_ma
}
PyObject* PyBobIpBase_rotate(PyObject*, PyObject* args, PyObject* kwargs) {
TRY
BOB_TRY
/* Parses input arguments in a single shot */
static char* kwlist1[] = {c("src"), c("angle"), NULL};
static char* kwlist2[] = {c("src"), c("dst"), c("angle"), NULL};
static char* kwlist3[] = {c("src"), c("src_mask"), c("dst"), c("dst_mask"), c("angle"), NULL};
char** kwlist1 = s_rotate.kwlist(0);
char** kwlist2 = s_rotate.kwlist(1);
char** kwlist3 = s_rotate.kwlist(2);
// get the number of command line arguments
Py_ssize_t nargs = (args?PyTuple_Size(args):0) + (kwargs?PyDict_Size(kwargs):0);
......@@ -309,11 +309,11 @@ PyObject* PyBobIpBase_rotate(PyObject*, PyObject* args, PyObject* kwargs) {
}
Py_RETURN_NONE;
CATCH_("rotate", 0)
BOB_CATCH_FUNCTION("rotate", 0)
}
bob::extension::FunctionDoc s_getRotatedOutputShape = bob::extension::FunctionDoc(
bob::extension::FunctionDoc s_rotatedOutputShape = bob::extension::FunctionDoc(
"rotated_output_shape",
"This function returns the shape of the rotated image for the given image and angle",
0,
......@@ -327,10 +327,10 @@ bob::extension::FunctionDoc s_getRotatedOutputShape = bob::extension::FunctionDo
.add_return("rotated_shape", "(int, int) or (int, int, int)", "The shape of the rotated ``dst`` image required in a call to :py:func:`bob.ip.base.rotate`")
;
PyObject* PyBobIpBase_getRotatedOutputShape(PyObject*, PyObject* args, PyObject* kwargs) {
TRY
PyObject* PyBobIpBase_rotatedOutputShape(PyObject*, PyObject* args, PyObject* kwargs) {
BOB_TRY
static char* kwlist1[] = {c("src"), c("angle"), 0};
char** kwlist1 = s_rotatedOutputShape.kwlist();
// TODO: implement from shape
// static char* kwlist2[] = {c("shape"), c("scale"), 0};
......@@ -355,7 +355,7 @@ PyObject* PyBobIpBase_getRotatedOutputShape(PyObject*, PyObject* args, PyObject*
}
return 0;
CATCH_("cannot get rotated output shape", 0)
BOB_CATCH_FUNCTION("cannot get rotated output shape", 0)
}
......@@ -374,9 +374,9 @@ bob::extension::FunctionDoc s_maxRectInMask = bob::extension::FunctionDoc(
;
PyObject* PyBobIpBase_maxRectInMask(PyObject*, PyObject* args, PyObject* kwargs) {
TRY
BOB_TRY
/* Parses input arguments in a single shot */
static char* kwlist[] = {c("mask"), NULL};
char** kwlist = s_maxRectInMask.kwlist();
PyBlitzArrayObject* mask = 0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O&", kwlist, &PyBlitzArray_Converter, &mask)) return 0;
......@@ -392,7 +392,7 @@ PyObject* PyBobIpBase_maxRectInMask(PyObject*, PyObject* args, PyObject* kwargs)
return Py_BuildValue("(iiii)", rect[0], rect[1], rect[2], rect[3]);
CATCH_("in max_rect_in_mask", 0)
BOB_CATCH_FUNCTION("in max_rect_in_mask", 0)
}
......@@ -427,9 +427,9 @@ bob::extension::FunctionDoc s_extrapolateMask = bob::extension::FunctionDoc(
;
PyObject* PyBobIpBase_extrapolateMask(PyObject*, PyObject* args, PyObject* kwargs) {
TRY
BOB_TRY
/* Parses input arguments in a single shot */
static char* kwlist[] = {c("mask"), c("img"), c("random_sigma"), c("neighbors"), c("rng"), NULL};
char** kwlist = s_extrapolateMask.kwlist(1);
PyBlitzArrayObject* mask,* img;
double sigma = -1.;
......@@ -479,7 +479,7 @@ PyObject* PyBobIpBase_extrapolateMask(PyObject*, PyObject* args, PyObject* kwarg
Py_RETURN_NONE;
CATCH_("in extrapolate_mask", 0)
BOB_CATCH_FUNCTION("in extrapolate_mask", 0)
}
......@@ -51,11 +51,11 @@ template <typename T, char C> void inner_histogram(PyBlitzArrayObject* src, PyBl
}
PyObject* PyBobIpBase_histogram(PyObject*, PyObject* args, PyObject* kwargs) {
TRY
static char* kwlist1[] = {c("src"), c("bin_count"), NULL};
static char* kwlist2[] = {c("src"), c("hist"), NULL};
static char* kwlist3[] = {c("src"), c("min_max"), c("bin_count"), NULL};
static char* kwlist4[] = {c("src"), c("min_max"), c("hist"), NULL};
BOB_TRY
char** kwlist1 = s_histogram.kwlist(0);
char** kwlist2 = s_histogram.kwlist(1);
char** kwlist3 = s_histogram.kwlist(2);
char** kwlist4 = s_histogram.kwlist(3);
PyBlitzArrayObject* src = 0,* hist = 0;
PyObject* min_max = 0;
......@@ -102,6 +102,12 @@ PyObject* PyBobIpBase_histogram(PyObject*, PyObject* args, PyObject* kwargs) {
return 0;
}
// check input size
if (src->ndim != 2){
PyErr_Format(PyExc_TypeError, "'histogram' : The input image must be 2D.");
return 0;
}
// allocate the output, if needed
bool return_out = false;
if (!hist){
......@@ -164,7 +170,7 @@ PyObject* PyBobIpBase_histogram(PyObject*, PyObject* args, PyObject* kwargs) {
Py_RETURN_NONE;
}
CATCH_("in histogram", 0)
BOB_CATCH_FUNCTION("in histogram", 0)
}
......@@ -185,9 +191,9 @@ template <typename T1, typename T2> PyObject* inner_histogramEq(PyBlitzArrayObje
}
PyObject* PyBobIpBase_histogramEqualization(PyObject*, PyObject* args, PyObject* kwargs) {
TRY
static char* kwlist1[] = {c("src"), NULL};
static char* kwlist2[] = {c("src"), c("dst"), NULL};
BOB_TRY
char** kwlist1 = s_histogramEqualization.kwlist(0);
char** kwlist2 = s_histogramEqualization.kwlist(1);
PyBlitzArrayObject* src = 0,* dst = 0;
......@@ -249,7 +255,7 @@ PyObject* PyBobIpBase_histogramEqualization(PyObject*, PyObject* args, PyObject*
}
return 0;
CATCH_("in histogram_equalization", 0)
BOB_CATCH_FUNCTION("in histogram_equalization", 0)
}
......@@ -272,8 +278,8 @@ template <typename T> PyObject* inner_gammaCorrection(PyBlitzArrayObject* src, P
}
PyObject* PyBobIpBase_gammaCorrection(PyObject*, PyObject* args, PyObject* kwargs) {
TRY
static char* kwlist[] = {c("src"), c("gamma"), c("dst"), NULL};
BOB_TRY
char** kwlist = s_gammaCorrection.kwlist();
PyBlitzArrayObject* src = 0,* dst = 0;
double gamma;
......@@ -305,7 +311,7 @@ PyObject* PyBobIpBase_gammaCorrection(PyObject*, PyObject* args, PyObject* kwarg
PyErr_Format(PyExc_ValueError, "'gamma_correction' of %s arrays is currently not supported, only uint8, uint16 or float64 arrays are", PyBlitzArray_TypenumAsString(dst->type_num));
return 0;
}
CATCH_("in gamma_correction", 0)
BOB_CATCH_FUNCTION("in gamma_correction", 0)
}
......@@ -355,15 +361,9 @@ template <typename T> PyObject* inner_zigzag(PyBlitzArrayObject* src, PyBlitzArr
}
PyObject* PyBobIpBase_zigzag(PyObject*, PyObject* args, PyObject* kwds) {
TRY
BOB_TRY
/* Parses input arguments in a single shot */
static const char* const_kwlist[] = {
"src",
"dst",
"right_first",
0 /* Sentinel */
};
static char** kwlist = const_cast<char**>(const_kwlist);
char** kwlist = s_zigzag.kwlist();
PyBlitzArrayObject* src = 0;
PyBlitzArrayObject* dst = 0;
......@@ -405,7 +405,7 @@ PyObject* PyBobIpBase_zigzag(PyObject*, PyObject* args, PyObject* kwds) {
}
return 0;
CATCH_("in zigzag", 0)
BOB_CATCH_FUNCTION("in zigzag", 0)
}
......@@ -456,9 +456,9 @@ static inline PyObject* integral_middle(PyBlitzArrayObject* src, PyBlitzArrayObj
}
PyObject* PyBobIpBase_integral(PyObject*, PyObject* args, PyObject* kwds) {
TRY
BOB_TRY
/* Parses input arguments in a single shot */
static char* kwlist[] = {c("src"), c("dst"), c("sqr"), c("add_zero_border"), NULL};
char** kwlist = s_integral.kwlist();
PyBlitzArrayObject* src = 0,* dst = 0,* sqr = 0;
PyObject* azb = 0;
......@@ -493,7 +493,7 @@ PyObject* PyBobIpBase_integral(PyObject*, PyObject* args, PyObject* kwds) {
}
return 0;
CATCH_("in integral", 0)
BOB_CATCH_FUNCTION("in integral", 0)
}
bob::extension::FunctionDoc s_block = bob::extension::FunctionDoc(
......@@ -527,9 +527,9 @@ static inline void block_inner(PyBlitzArrayObject* input, blitz::TinyVector<int,
}
PyObject* PyBobIpBase_block(PyObject*, PyObject* args, PyObject* kwds) {
TRY
BOB_TRY
/* Parses input arguments in a single shot */
static char* kwlist[] = {c("input"), c("block_size"), c("block_overlap"), c("output"), c("flat"), NULL};
char** kwlist = s_block.kwlist();
PyBlitzArrayObject* input = 0,* output = 0;
blitz::TinyVector<int,2> size, overlap(0,0);
......@@ -584,7 +584,7 @@ PyObject* PyBobIpBase_block(PyObject*, PyObject* args, PyObject* kwds) {
} else
Py_RETURN_NONE;
CATCH_("in block", 0)
BOB_CATCH_FUNCTION("in block", 0)
}
......@@ -602,9 +602,9 @@ bob::extension::FunctionDoc s_blockOutputShape = bob::extension::FunctionDoc(
;
PyObject* PyBobIpBase_blockOutputShape(PyObject*, PyObject* args, PyObject* kwds) {
TRY
BOB_TRY
/* Parses input arguments in a single shot */
static char* kwlist[] = {c("input"), c("block_size"), c("block_overlap"), c("flat"), NULL};
char** kwlist = s_blockOutputShape.kwlist();
PyBlitzArrayObject* input = 0;
blitz::TinyVector<int,2> size, overlap(0,0);
......@@ -627,7 +627,7 @@ PyObject* PyBobIpBase_blockOutputShape(PyObject*, PyObject* args, PyObject* kwds
return Py_BuildValue("(iiii)", shape[0], shape[1], shape[2], shape[3]);
}
CATCH_("in block_output_shape", 0)
BOB_CATCH_FUNCTION("in block_output_shape", 0)
}
......@@ -666,9 +666,9 @@ static inline PyObject* lbphs_inner(PyBlitzArrayObject* input, PyBobIpBaseLBPObj
}
PyObject* PyBobIpBase_lbphs(PyObject*, PyObject* args, PyObject* kwds) {
TRY
BOB_TRY
/* Parses input arguments in a single shot */
static char* kwlist[] = {c("input"), c("lbp"), c("block_size"), c("block_overlap"), c("output"), NULL};
char** kwlist = s_lbphs.kwlist();
PyBlitzArrayObject* input = 0,* output = 0;
PyBobIpBaseLBPObject* lbp;
......@@ -702,7 +702,7 @@ PyObject* PyBobIpBase_lbphs(PyObject*, PyObject* args, PyObject* kwds) {
}
return 0;
CATCH_("in lbphs", 0)
BOB_CATCH_FUNCTION("in lbphs", 0)
}
......@@ -720,9 +720,9 @@ bob::extension::FunctionDoc s_lbphsOutputShape = bob::extension::FunctionDoc(
;
PyObject* PyBobIpBase_lbphsOutputShape(PyObject*, PyObject* args, PyObject* kwds) {
TRY
BOB_TRY
/* Parses input arguments in a single shot */
static char* kwlist[] = {c("input"), c("lbp"), c("block_size"), c("block_overlap"), NULL};
char** kwlist = s_lbphsOutputShape.kwlist();
PyBlitzArrayObject* input = 0;
PyBobIpBaseLBPObject* lbp;
......@@ -741,7 +741,7 @@ PyObject* PyBobIpBase_lbphsOutputShape(PyObject*, PyObject* args, PyObject* kwds
return Py_BuildValue("(ii)", shape[0], shape[1]);
CATCH_("in lbphs_output_shape", 0)
BOB_CATCH_FUNCTION("in lbphs_output_shape", 0)
}
......
This diff is collapsed.
......@@ -42,11 +42,11 @@ static auto FaceEyesNorm_doc = bob::extension::ClassDoc(
static int PyBobIpBaseFaceEyesNorm_init(PyBobIpBaseFaceEyesNormObject* self, PyObject* args, PyObject* kwargs) {
TRY
BOB_TRY
char* kwlist1[] = {c("crop_size"), c("eyes_distance"), c("eyes_center"), NULL};
char* kwlist2[] = {c("crop_size"), c("right_eye"), c("left_eye"), NULL};
char* kwlist3[] = {c("other"), NULL};
char** kwlist1 = FaceEyesNorm_doc.kwlist(0);
char** kwlist2 = FaceEyesNorm_doc.kwlist(1);
char** kwlist3 = FaceEyesNorm_doc.kwlist(2);
// get the number of command line arguments
Py_ssize_t nargs = (args?PyTuple_Size(args):0) + (kwargs?PyDict_Size(kwargs):0);
......@@ -97,7 +97,7 @@ static int PyBobIpBaseFaceEyesNorm_init(PyBobIpBaseFaceEyesNormObject* self, PyO
return -1;
}
CATCH("cannot create FaceEyesNorm object", -1)
BOB_CATCH_MEMBER("cannot create FaceEyesNorm object", -1)
}
static void PyBobIpBaseFaceEyesNorm_delete(PyBobIpBaseFaceEyesNormObject* self) {
......@@ -110,7 +110,7 @@ int PyBobIpBaseFaceEyesNorm_Check(PyObject* o) {
}
static PyObject* PyBobIpBaseFaceEyesNorm_RichCompare(PyBobIpBaseFaceEyesNormObject* self, PyObject* other, int op) {
TRY
BOB_TRY
if (!PyBobIpBaseFaceEyesNorm_Check(other)) {
PyErr_Format(PyExc_TypeError, "cannot compare `%s' with `%s'", Py_TYPE(self)->tp_name, Py_TYPE(other)->tp_name);
......@@ -126,7 +126,7 @@ static PyObject* PyBobIpBaseFaceEyesNorm_RichCompare(PyBobIpBaseFaceEyesNormObje
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
CATCH("cannot compare FaceEyesNorm objects", 0)
BOB_CATCH_MEMBER("cannot compare FaceEyesNorm objects", 0)
}
......@@ -139,17 +139,17 @@ static auto eyesDistance = bob::extension::VariableDoc(
"The distance between the eyes in the normalized image, with read and write access"
);
PyObject* PyBobIpBaseFaceEyesNorm_getEyesDistance(PyBobIpBaseFaceEyesNormObject* self, void*){
TRY
BOB_TRY
return Py_BuildValue("d", self->cxx->getEyesDistance());
CATCH("eyes_distance could not be read", 0)
BOB_CATCH_MEMBER("eyes_distance could not be read", 0)
}
int PyBobIpBaseFaceEyesNorm_setEyesDistance(PyBobIpBaseFaceEyesNormObject* self, PyObject* value, void*){
TRY
BOB_TRY
double d = PyFloat_AsDouble(value);
if (PyErr_Occurred()) return -1;
self->cxx->setEyesDistance(d);
return 0;
CATCH("eyes_distance could not be set", -1)
BOB_CATCH_MEMBER("eyes_distance could not be set", -1)
}
static auto eyesAngle = bob::extension::VariableDoc(
......@@ -158,17 +158,17 @@ static auto eyesAngle = bob::extension::VariableDoc(
"The angle between the eyes in the normalized image (relative to the horizontal line), with read and write access"
);
PyObject* PyBobIpBaseFaceEyesNorm_getEyesAngle(PyBobIpBaseFaceEyesNormObject* self, void*){
TRY
BOB_TRY
return Py_BuildValue("d", self->cxx->getEyesAngle());
CATCH("eyes_angle could not be read", 0)
BOB_CATCH_MEMBER("eyes_angle could not be read", 0)
}
int PyBobIpBaseFaceEyesNorm_setEyesAngle(PyBobIpBaseFaceEyesNormObject* self, PyObject* value, void*){
TRY
BOB_TRY
double d = PyFloat_AsDouble(value);
if (PyErr_Occurred()) return -1;
self->cxx->setEyesAngle(d);
return 0;
CATCH("eyes_angle could not be set", -1)
BOB_CATCH_MEMBER("eyes_angle could not be set", -1)
}
static auto cropSize = bob::extension::VariableDoc(
......@@ -177,13 +177,13 @@ static auto cropSize = bob::extension::VariableDoc(
"The size of the normalized image, with read and write access"
);
PyObject* PyBobIpBaseFaceEyesNorm_getCropSize(PyBobIpBaseFaceEyesNormObject* self, void*){
TRY
BOB_TRY
auto r = self->cxx->getCropSize();
return Py_BuildValue("(ii)", r[0], r[1]);
CATCH("crop_size could not be read", 0)
BOB_CATCH_MEMBER("crop_size could not be read", 0)
}
int PyBobIpBaseFaceEyesNorm_setCropSize(PyBobIpBaseFaceEyesNormObject* self, PyObject* value, void*){
TRY
BOB_TRY
blitz::TinyVector<int,2> r;
if (!PyArg_ParseTuple(value, "ii", &r[0], &r[1])){
PyErr_Format(PyExc_RuntimeError, "%s %s expects a tuple of two ints", Py_TYPE(self)->tp_name, cropSize.name());
......@@ -191,7 +191,7 @@ int PyBobIpBaseFaceEyesNorm_setCropSize(PyBobIpBaseFaceEyesNormObject* self, PyO
}
self->cxx->setCropSize(r);
return 0;
CATCH("crop_size could not be set", -1)
BOB_CATCH_MEMBER("crop_size could not be set", -1)
}
static auto cropOffset = bob::extension::VariableDoc(
......@@ -200,13 +200,13 @@ static auto cropOffset = bob::extension::VariableDoc(
"The transformation center in the processed image, which is usually the center between the eyes; with read and write access"
);
PyObject* PyBobIpBaseFaceEyesNorm_getCropOffset(PyBobIpBaseFaceEyesNormObject* self, void*){
TRY
BOB_TRY
auto r = self->cxx->getCropOffset();
return Py_BuildValue("(dd)", r[0], r[1]);
CATCH("crop_offset could not be read", 0)
BOB_CATCH_MEMBER("crop_offset could not be read", 0)
}
int PyBobIpBaseFaceEyesNorm_setCropOffset(PyBobIpBaseFaceEyesNormObject* self, PyObject* value, void*){
TRY
BOB_TRY
blitz::TinyVector<double,2> r;
if (!PyArg_ParseTuple(value, "dd", &r[0], &r[1])){
PyErr_Format(PyExc_RuntimeError, "%s %s expects a tuple of two floats", Py_TYPE(self)->tp_name, cropOffset.name());
......@@ -214,7 +214,7 @@ int PyBobIpBaseFaceEyesNorm_setCropOffset(PyBobIpBaseFaceEyesNormObject* self, P
}
self->cxx->setCropOffset(r);
return 0;
CATCH("crop_offset could not be set", -1)
BOB_CATCH_MEMBER("crop_offset could not be set", -1)
}
static auto lastAngle = bob::extension::VariableDoc(
......@@ -223,9 +223,9 @@ static auto lastAngle = bob::extension::VariableDoc(
"The rotation angle that was applied on the latest normalized image, read access only"
);
PyObject* PyBobIpBaseFaceEyesNorm_getLastAngle(PyBobIpBaseFaceEyesNormObject* self, void*){
TRY
BOB_TRY
return Py_BuildValue("d", self->cxx->getLastAngle());
CATCH("last_angle could not be read", 0)
BOB_CATCH_MEMBER("last_angle could not be read", 0)
}
static auto lastScale = bob::extension::VariableDoc(
......@@ -234,9 +234,9 @@ static auto lastScale = bob::extension::VariableDoc(
"The scale that was applied on the latest normalized image, read access only"
);
PyObject* PyBobIpBaseFaceEyesNorm_getLastScale(PyBobIpBaseFaceEyesNormObject* self, void*){
TRY
BOB_TRY
return Py_BuildValue("d", self->cxx->getLastScale());
CATCH("last_scale could not be read", 0)
BOB_CATCH_MEMBER("last_scale could not be read", 0)
}
static auto lastOffset = bob::extension::VariableDoc(
......@@ -245,10 +245,10 @@ static auto lastOffset = bob::extension::VariableDoc(
"The original transformation offset (eye center) in the normalization process, read access only"
);
PyObject* PyBobIpBaseFaceEyesNorm_getLastOffset(PyBobIpBaseFaceEyesNormObject* self, void*){
TRY
BOB_TRY
auto r = self->cxx->getLastOffset();
return Py_BuildValue("(dd)", r[0], r[1]);
CATCH("last_offset could not be read", 0)
BOB_CATCH_MEMBER("last_offset could not be read", 0)
}
static auto geomNorm = bob::extension::VariableDoc(
......@@ -257,11 +257,11 @@ static auto geomNorm = bob::extension::VariableDoc(
"The geometric normalization class that was used to compute the last normalization, read access only"
);
PyObject* PyBobIpBaseFaceEyesNorm_getGeomNorm(PyBobIpBaseFaceEyesNormObject* self, void*){
TRY
BOB_TRY
PyBobIpBaseGeomNormObject* geomNorm = (PyBobIpBaseGeomNormObject*)PyBobIpBaseGeomNorm_Type.tp_alloc(&PyBobIpBaseGeomNorm_Type, 0);
geomNorm->cxx = self->cxx->getGeomNorm();
return Py_BuildValue("O", geomNorm);
CATCH("geom_norm could not be read", 0)
BOB_CATCH_MEMBER("geom_norm could not be read", 0)
}
static PyGetSetDef PyBobIpBaseFaceEyesNorm_getseters[] = {
......@@ -362,10 +362,10 @@ static void extract_inner(PyBobIpBaseFaceEyesNormObject* self, PyBlitzArrayObjec
}
static PyObject* PyBobIpBaseFaceEyesNorm_extract(PyBobIpBaseFaceEyesNormObject* self, PyObject* args, PyObject* kwargs) {
TRY
static char* kwlist1[] = {c("input"), c("right_eye"), c("left_eye"), 0};
static char* kwlist2[] = {c("input"), c("output"), c("right_eye"), c("left_eye"), 0};
static char* kwlist3[] = {c("input"), c("input_mask"), c("output"), c("output_mask"), c("right_eye"), c("left_eye"), 0};
BOB_TRY
char** kwlist1 = extract.kwlist(0);
char** kwlist2 = extract.kwlist(1);
char** kwlist3 = extract.kwlist(2);
// get the number of command line arguments
Py_ssize_t nargs = (args?PyTuple_Size(args):0) + (kwargs?PyDict_Size(kwargs):0);
......@@ -465,7 +465,7 @@ static PyObject* PyBobIpBaseFaceEyesNorm_extract(PyBobIpBaseFaceEyesNormObject*
Py_RETURN_NONE;
}
CATCH("cannot extract face from image", 0)
BOB_CATCH_MEMBER("cannot extract face from image", 0)
}
static PyMethodDef PyBobIpBaseFaceEyesNorm_methods[] = {
......
......@@ -35,9 +35,9 @@ template <typename T, int D> PyObject* inner_median(PyBlitzArrayObject* src, PyB
}
PyObject* PyBobIpBase_median(PyObject*, PyObject* args, PyObject* kwargs) {
TRY
BOB_TRY
static char* kwlist[] = {c("src"), c("radius"), c("dst"), NULL};
char** kwlist = s_median.kwlist();
PyBlitzArrayObject* src,* dst = 0;
blitz::TinyVector<int,2> radius;
......@@ -76,7 +76,7 @@ PyObject* PyBobIpBase_median(PyObject*, PyObject* args, PyObject* kwargs) {
return 0;
}
CATCH_("in median", 0)
BOB_CATCH_FUNCTION("in median", 0)
}
bob::extension::FunctionDoc s_sobel = bob::extension::FunctionDoc(
......@@ -97,9 +97,9 @@ bob::extension::FunctionDoc s_sobel = bob::extension::FunctionDoc(
;
PyObject* PyBobIpBase_sobel(PyObject*, PyObject* args, PyObject* kwargs) {
TRY
BOB_TRY
static char* kwlist[] = {c("src"), c("border"), c("dst"), NULL};
char** kwlist = s_sobel.kwlist();
PyBlitzArrayObject* src,* dst = 0;
bob::sp::Extrapolation::BorderType border = bob::sp::Extrapolation::Mirror;
......@@ -129,7 +129,7 @@ PyObject* PyBobIpBase_sobel(PyObject*, PyObject* args, PyObject* kwargs) {
Py_INCREF(dst);
return PyBlitzArray_AsNumpyArray(dst, 0);
CATCH_("in sobel", 0)
BOB_CATCH_FUNCTION("in sobel", 0)
}
......@@ -35,10 +35,10 @@ static auto Gaussian_doc = bob::extension::ClassDoc(
);
static int PyBobIpBaseGaussian_init(PyBobIpBaseGaussianObject* self, PyObject* args, PyObject* kwargs) {
TRY
BOB_TRY
char* kwlist1[] = {c("sigma"), c("radius"), c("border"), NULL};
char* kwlist2[] = {c("gaussian"), NULL};
char** kwlist1 = Gaussian_doc.kwlist(0);
char** kwlist2 = Gaussian_doc.kwlist(1);
// get the number of command line arguments
Py_ssize_t nargs = (args?PyTuple_Size(args):0) + (kwargs?PyDict_Size(kwargs):0);
......@@ -68,7 +68,7 @@ static int PyBobIpBaseGaussian_init(PyBobIpBaseGaussianObject* self, PyObject* a
self->cxx.reset(new bob::ip::base::Gaussian(radius[0], radius[1], sigma[0], sigma[1], border));
return 0;
CATCH("cannot create Gaussian", -1)
BOB_CATCH_MEMBER("cannot create Gaussian", -1)
}
static void PyBobIpBaseGaussian_delete(PyBobIpBaseGaussianObject* self) {
......@@ -81,7 +81,7 @@ int PyBobIpBaseGaussian_Check(PyObject* o) {
}
static PyObject* PyBobIpBaseGaussian_RichCompare(PyBobIpBaseGaussianObject* self, PyObject* other, int op) {
TRY
BOB_TRY
if (!PyBobIpBaseGaussian_Check(other)) {
PyErr_Format(PyExc_TypeError, "cannot compare `%s' with `%s'", Py_TYPE(self)->tp_name, Py_TYPE(other)->tp_name);
......@@ -97,7 +97,7 @@ static PyObject* PyBobIpBaseGaussian_RichCompare(PyBobIpBaseGaussianObject* self
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
CATCH("cannot compare Gaussian objects", 0)
BOB_CATCH_MEMBER("cannot compare Gaussian objects", 0)
}
......@@ -112,12 +112,12 @@ static auto sigma = bob::extension::VariableDoc(
".. note::\n\n The :py:attr:`radius` of the kernel is **not** reset by setting the ``sigma`` value."
);
PyObject* PyBobIpBaseGaussian_getSigma(PyBobIpBaseGaussianObject* self, void*){
TRY
BOB_TRY
return Py_BuildValue("(dd)", self->cxx->getSigmaY(), self->cxx->getSigmaX());
CATCH("sigma could not be read", 0)
BOB_CATCH_MEMBER("sigma could not be read", 0)
}
int PyBobIpBaseGaussian_setSigma(PyBobIpBaseGaussianObject* self, PyObject* value, void*){
TRY
BOB_TRY
blitz::TinyVector<double,2> r;
if (!PyArg_ParseTuple(value, "dd", &r[0], &r[1])){
PyErr_Format(PyExc_RuntimeError, "%s %s expects a tuple of two floats", Py_TYPE(self)->tp_name, sigma.name());
......@@ -125,7 +125,7 @@ int PyBobIpBaseGaussian_setSigma(PyBobIpBaseGaussianObject* self, PyObject* valu
}
self->cxx->setSigma(r);
return 0;
CATCH("sigma could not be set", -1)
BOB_CATCH_MEMBER("sigma could not be set", -1)
}
static auto radius = bob::extension::VariableDoc(
......@@ -135,12 +135,12 @@ static auto radius = bob::extension::VariableDoc(
"When setting the radius to a negative value, it will be automatically computed as ``3*``:py:attr:`sigma`."
);
PyObject* PyBobIpBaseGaussian_getRadius(PyBobIpBaseGaussianObject* self, void*){
TRY
BOB_TRY
return Py_BuildValue("(ii)", self->cxx->getRadiusY(), self->cxx->getRadiusX());
CATCH("radius could not be read", 0)
BOB_CATCH_MEMBER("radius could not be read", 0)
}
int PyBobIpBaseGaussian_setRadius(PyBobIpBaseGaussianObject* self, PyObject* value, void*){
TRY
BOB_TRY
blitz::TinyVector<int,2> r;
if (!PyArg_ParseTuple(value, "ii", &r[0], &r[1])){
PyErr_Format(PyExc_RuntimeError, "%s %s expects a tuple of two integers", Py_TYPE(self)->tp_name, radius.name());
......@@ -150,7 +150,7 @@ int PyBobIpBaseGaussian_setRadius(PyBobIpBaseGaussianObject* self, PyObject* val
if (r[1] < 0) r[1] = std::max(int(self->cxx->getSigmaX() * 3 + 0.5), 1);
self->cxx->setRadius(r);
return 0;
CATCH("radius could not be set", -1)
BOB_CATCH_MEMBER("radius could not be set", -1)
}
static auto border = bob::extension::VariableDoc(
......@@ -159,17 +159,17 @@ static auto border = bob::extension::VariableDoc(
"The extrapolation method used by the convolution at the border, with read and write access"
);
PyObject* PyBobIpBaseGaussian_getBorder(PyBobIpBaseGaussianObject* self, void*){
TRY
BOB_TRY
return Py_BuildValue("i", self->cxx->getConvBorder());
CATCH("border could not be read", 0)
BOB_CATCH_MEMBER("border could not be read", 0)
}
int PyBobIpBaseGaussian_setBorder(PyBobIpBaseGaussianObject* self, PyObject* value, void*){
TRY
BOB_TRY
bob::sp::Extrapolation::BorderType b;
if (!PyBobSpExtrapolationBorder_Converter(value, &b)) return -1;
self->cxx->setConvBorder(b);
return 0;
CATCH("border could not be set", -1)
BOB_CATCH_MEMBER("border could not be set", -1)