From a02c3534fc4a309c9a49d8a47cf18f2a98aba0b1 Mon Sep 17 00:00:00 2001 From: Andre Anjos <andre.anjos@idiap.ch> Date: Mon, 26 May 2014 13:22:14 +0200 Subject: [PATCH] xbob -> bob --- .travis.yml | 4 +- MANIFEST.in | 2 +- README.rst | 24 +-- {xbob => bob}/__init__.py | 0 {xbob => bob}/core/__init__.py | 0 {xbob => bob}/core/convert.cpp | 18 +- bob/core/include/bob.core/config.h | 14 ++ .../core/include/bob.core}/random.h | 154 +++++++------- {xbob => bob}/core/log.py | 0 {xbob => bob}/core/logging.cpp | 12 +- {xbob => bob}/core/random/__init__.py | 2 +- {xbob => bob}/core/random/binomial.cpp | 8 +- {xbob => bob}/core/random/discrete.cpp | 10 +- {xbob => bob}/core/random/gamma.cpp | 8 +- {xbob => bob}/core/random/lognormal.cpp | 8 +- bob/core/random/main.cpp | 196 ++++++++++++++++++ {xbob => bob}/core/random/mt19937.cpp | 6 +- {xbob => bob}/core/random/mt19937.h | 0 {xbob => bob}/core/random/normal.cpp | 8 +- {xbob => bob}/core/random/uniform.cpp | 8 +- {xbob => bob}/core/test_convert.py | 0 {xbob => bob}/core/test_logging.py | 0 {xbob => bob}/core/test_random.py | 2 +- {xbob => bob}/core/version.cpp | 28 +-- buildout.cfg | 16 +- doc/c_cpp_api.rst | 18 +- doc/conf.py | 12 +- doc/guide.rst | 28 +-- doc/py_api.rst | 24 +-- setup.py | 44 ++-- xbob/core/include/xbob.core/config.h | 14 -- xbob/core/random/main.cpp | 196 ------------------ 32 files changed, 432 insertions(+), 432 deletions(-) rename {xbob => bob}/__init__.py (100%) rename {xbob => bob}/core/__init__.py (100%) rename {xbob => bob}/core/convert.cpp (94%) create mode 100644 bob/core/include/bob.core/config.h rename {xbob/core/include/xbob.core => bob/core/include/bob.core}/random.h (71%) rename {xbob => bob}/core/log.py (100%) rename {xbob => bob}/core/logging.cpp (97%) rename {xbob => bob}/core/random/__init__.py (93%) rename {xbob => bob}/core/random/binomial.cpp (98%) rename {xbob => bob}/core/random/discrete.cpp (98%) rename {xbob => bob}/core/random/gamma.cpp (98%) rename {xbob => bob}/core/random/lognormal.cpp (98%) create mode 100644 bob/core/random/main.cpp rename {xbob => bob}/core/random/mt19937.cpp (98%) rename {xbob => bob}/core/random/mt19937.h (100%) rename {xbob => bob}/core/random/normal.cpp (98%) rename {xbob => bob}/core/random/uniform.cpp (99%) rename {xbob => bob}/core/test_convert.py (100%) rename {xbob => bob}/core/test_logging.py (100%) rename {xbob => bob}/core/test_random.py (99%) rename {xbob => bob}/core/version.cpp (84%) delete mode 100644 xbob/core/include/xbob.core/config.h delete mode 100644 xbob/core/random/main.cpp diff --git a/.travis.yml b/.travis.yml index fd472b6..ba9e22b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,8 +25,8 @@ install: - "python bootstrap.py" - "CFLAGS=-coverage ./bin/buildout" script: - - "./bin/python -c 'from xbob.core import get_config; print(get_config())'" - - "./bin/coverage run --source=xbob.core ./bin/nosetests -sv" + - "./bin/python -c 'from bob.core import get_config; print(get_config())'" + - "./bin/coverage run --source=bob.core ./bin/nosetests -sv" - "./bin/sphinx-build -b doctest doc sphinx" - "./bin/sphinx-build -b html doc sphinx" after_success: diff --git a/MANIFEST.in b/MANIFEST.in index 09ed020..4b6cf9d 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,3 @@ include LICENSE README.rst bootstrap.py buildout.cfg recursive-include doc conf.py *.rst -recursive-include xbob *.cpp *.h +recursive-include bob *.cpp *.h diff --git a/README.rst b/README.rst index cffa770..b22afea 100644 --- a/README.rst +++ b/README.rst @@ -2,16 +2,16 @@ .. Andre Anjos <andre.anjos@idiap.ch> .. Thu 29 Aug 2013 16:07:57 CEST -.. image:: https://travis-ci.org/bioidiap/xbob.core.svg?branch=master - :target: https://travis-ci.org/bioidiap/xbob.core -.. image:: https://coveralls.io/repos/bioidiap/xbob.core/badge.png - :target: https://coveralls.io/r/bioidiap/xbob.core -.. image:: http://img.shields.io/github/tag/bioidiap/xbob.core.png - :target: https://github.com/bioidiap/xbob.core -.. image:: http://img.shields.io/pypi/v/xbob.core.png - :target: https://pypi.python.org/pypi/xbob.core -.. image:: http://img.shields.io/pypi/dm/xbob.core.png - :target: https://pypi.python.org/pypi/xbob.core +.. image:: https://travis-ci.org/bioidiap/bob.core.svg?branch=master + :target: https://travis-ci.org/bioidiap/bob.core +.. image:: https://coveralls.io/repos/bioidiap/bob.core/badge.png + :target: https://coveralls.io/r/bioidiap/bob.core +.. image:: http://img.shields.io/github/tag/bioidiap/bob.core.png + :target: https://github.com/bioidiap/bob.core +.. image:: http://img.shields.io/pypi/v/bob.core.png + :target: https://pypi.python.org/pypi/bob.core +.. image:: http://img.shields.io/pypi/dm/bob.core.png + :target: https://pypi.python.org/pypi/bob.core ============================== Python bindings for bob.core @@ -42,7 +42,7 @@ Testing You can run a set of tests using the nose test runner:: - $ nosetests -sv xbob.core + $ nosetests -sv bob.core .. warning:: @@ -59,7 +59,7 @@ You can run our documentation tests using sphinx itself:: You can test overall test coverage with:: - $ nosetests --with-coverage --cover-package=xbob.core + $ nosetests --with-coverage --cover-package=bob.core The ``coverage`` egg must be installed for this to work properly. diff --git a/xbob/__init__.py b/bob/__init__.py similarity index 100% rename from xbob/__init__.py rename to bob/__init__.py diff --git a/xbob/core/__init__.py b/bob/core/__init__.py similarity index 100% rename from xbob/core/__init__.py rename to bob/core/__init__.py diff --git a/xbob/core/convert.cpp b/bob/core/convert.cpp similarity index 94% rename from xbob/core/convert.cpp rename to bob/core/convert.cpp index 5d3e071..edef221 100644 --- a/xbob/core/convert.cpp +++ b/bob/core/convert.cpp @@ -5,12 +5,12 @@ * @brief Pythonic bindings to C++ constructs on bob.core */ -#include <xbob.core/config.h> +#include <bob.core/config.h> #ifdef NO_IMPORT_ARRAY #undef NO_IMPORT_ARRAY #endif -#include <xbob.blitz/cppapi.h> -#include <xbob.blitz/cleanup.h> +#include <bob.blitz/cppapi.h> +#include <bob.blitz/cleanup.h> #include <bob/core/array_convert.h> @@ -245,7 +245,7 @@ PyDoc_STRVAR(module_docstr, "bob::core::array::convert bindings"); #if PY_VERSION_HEX >= 0x03000000 static PyModuleDef module_definition = { PyModuleDef_HEAD_INIT, - XBOB_EXT_MODULE_NAME, + BOB_EXT_MODULE_NAME, module_docstr, -1, module_methods, @@ -258,18 +258,18 @@ static PyObject* create_module (void) { # if PY_VERSION_HEX >= 0x03000000 PyObject* m = PyModule_Create(&module_definition); # else - PyObject* m = Py_InitModule3(XBOB_EXT_MODULE_NAME, module_methods, module_docstr); + PyObject* m = Py_InitModule3(BOB_EXT_MODULE_NAME, module_methods, module_docstr); # endif if (!m) return 0; auto m_ = make_safe(m); /* register some constants */ - if (PyModule_AddStringConstant(m, "__version__", XBOB_EXT_MODULE_VERSION) < 0) return 0; + if (PyModule_AddStringConstant(m, "__version__", BOB_EXT_MODULE_VERSION) < 0) return 0; /* imports dependencies */ - if (import_xbob_blitz() < 0) { + if (import_bob_blitz() < 0) { PyErr_Print(); - PyErr_Format(PyExc_ImportError, "cannot import `%s'", XBOB_EXT_MODULE_NAME); + PyErr_Format(PyExc_ImportError, "cannot import `%s'", BOB_EXT_MODULE_NAME); return 0; } @@ -278,7 +278,7 @@ static PyObject* create_module (void) { } -PyMODINIT_FUNC XBOB_EXT_ENTRY_NAME (void) { +PyMODINIT_FUNC BOB_EXT_ENTRY_NAME (void) { # if PY_VERSION_HEX >= 0x03000000 return # endif diff --git a/bob/core/include/bob.core/config.h b/bob/core/include/bob.core/config.h new file mode 100644 index 0000000..671b4bb --- /dev/null +++ b/bob/core/include/bob.core/config.h @@ -0,0 +1,14 @@ +/** + * @author Andre Anjos <andre.anjos@idiap.ch> + * @date Fri 1 Nov 07:10:59 2013 + * + * @brief General directives for all modules in bob.core + */ + +#ifndef BOB_CORE_CONFIG_H +#define BOB_CORE_CONFIG_H + +/* Macros that define versions and important names */ +#define BOB_CORE_API_VERSION 0x0200 + +#endif /* BOB_CORE_CONFIG_H */ diff --git a/xbob/core/include/xbob.core/random.h b/bob/core/include/bob.core/random.h similarity index 71% rename from xbob/core/include/xbob.core/random.h rename to bob/core/include/bob.core/random.h index b556b82..e4b003e 100644 --- a/xbob/core/include/xbob.core/random.h +++ b/bob/core/include/bob.core/random.h @@ -5,18 +5,18 @@ * @brief C/C++-API for the random module */ -#ifndef XBOB_CORE_RANDOM_H -#define XBOB_CORE_RANDOM_H +#ifndef BOB_CORE_RANDOM_H +#define BOB_CORE_RANDOM_H #include <Python.h> -#include <xbob.core/config.h> +#include <bob.core/config.h> #include <boost/shared_ptr.hpp> #include <boost/random.hpp> /* Define Module Name and Prefix for other Modules - Note: We cannot use XBOB_EXT_* macros here, unfortunately */ -#define XBOB_CORE_RANDOM_PREFIX "xbob.core.random" -#define XBOB_CORE_RANDOM_FULL_NAME "xbob.core.random._library" + Note: We cannot use BOB_EXT_* macros here, unfortunately */ +#define BOB_CORE_RANDOM_PREFIX "bob.core.random" +#define BOB_CORE_RANDOM_FULL_NAME "bob.core.random._library" /******************* * C API functions * @@ -26,11 +26,11 @@ * Versioning * **************/ -#define PyXbobCoreRandom_APIVersion_NUM 0 -#define PyXbobCoreRandom_APIVersion_TYPE int +#define PyBobCoreRandom_APIVersion_NUM 0 +#define PyBobCoreRandom_APIVersion_TYPE int /***************************************** - * Bindings for xbob.core.random.mt19937 * + * Bindings for bob.core.random.mt19937 * *****************************************/ /* Type definition for PyBoostMt19937Object */ @@ -62,7 +62,7 @@ typedef struct { #define PyBoostMt19937_NewWithSeed_PROTO (Py_ssize_t seed) /***************************************** - * Bindings for xbob.core.random.uniform * + * Bindings for bob.core.random.uniform * *****************************************/ /* Type definition for PyBoostUniformObject */ @@ -91,7 +91,7 @@ typedef struct { #define PyBoostUniform_SimpleNew_PROTO (int type_num, PyObject* min, PyObject* max) /**************************************** - * Bindings for xbob.core.random.normal * + * Bindings for bob.core.random.normal * ****************************************/ /* Type definition for PyBoostNormalObject */ @@ -120,7 +120,7 @@ typedef struct { #define PyBoostNormal_SimpleNew_PROTO (int type_num, PyObject* mean, PyObject* sigma) /******************************************* - * Bindings for xbob.core.random.lognormal * + * Bindings for bob.core.random.lognormal * *******************************************/ /* Type definition for PyBoostLogNormalObject */ @@ -149,7 +149,7 @@ typedef struct { #define PyBoostLogNormal_SimpleNew_PROTO (int type_num, PyObject* mean, PyObject* sigma) /*************************************** - * Bindings for xbob.core.random.gamma * + * Bindings for bob.core.random.gamma * ***************************************/ /* Type definition for PyBoostGammaObject */ @@ -178,7 +178,7 @@ typedef struct { #define PyBoostGamma_SimpleNew_PROTO (int type_num, PyObject* alpha) /****************************************** - * Bindings for xbob.core.random.binomial * + * Bindings for bob.core.random.binomial * ******************************************/ /* Type definition for PyBoostBinomialObject */ @@ -207,7 +207,7 @@ typedef struct { #define PyBoostBinomial_SimpleNew_PROTO (int type_num, PyObject* alpha, PyObject* beta) /****************************************** - * Bindings for xbob.core.random.discrete * + * Bindings for bob.core.random.discrete * ******************************************/ /* Type definition for PyBoostDiscreteObject */ @@ -236,20 +236,20 @@ typedef struct { #define PyBoostDiscrete_SimpleNew_PROTO (int type_num, PyObject* probabilities) /* Total number of C API pointers */ -#define PyXbobCoreRandom_API_pointers 30 +#define PyBobCoreRandom_API_pointers 30 -#ifdef XBOB_CORE_RANDOM_MODULE +#ifdef BOB_CORE_RANDOM_MODULE - /* This section is used when compiling `xbob.core.random' itself */ + /* This section is used when compiling `bob.core.random' itself */ /************** * Versioning * **************/ - extern int PyXbobCoreRandom_APIVersion; + extern int PyBobCoreRandom_APIVersion; /***************************************** - * Bindings for xbob.core.random.mt19937 * + * Bindings for bob.core.random.mt19937 * *****************************************/ extern PyBoostMt19937_Type_TYPE PyBoostMt19937_Type; @@ -263,7 +263,7 @@ typedef struct { PyBoostMt19937_NewWithSeed_RET PyBoostMt19937_NewWithSeed PyBoostMt19937_NewWithSeed_PROTO; /***************************************** - * Bindings for xbob.core.random.uniform * + * Bindings for bob.core.random.uniform * *****************************************/ extern PyBoostUniform_Type_TYPE PyBoostUniform_Type; @@ -275,7 +275,7 @@ typedef struct { PyBoostUniform_SimpleNew_RET PyBoostUniform_SimpleNew PyBoostUniform_SimpleNew_PROTO; /**************************************** - * Bindings for xbob.core.random.normal * + * Bindings for bob.core.random.normal * ****************************************/ extern PyBoostNormal_Type_TYPE PyBoostNormal_Type; @@ -287,7 +287,7 @@ typedef struct { PyBoostNormal_SimpleNew_RET PyBoostNormal_SimpleNew PyBoostNormal_SimpleNew_PROTO; /******************************************* - * Bindings for xbob.core.random.lognormal * + * Bindings for bob.core.random.lognormal * *******************************************/ extern PyBoostLogNormal_Type_TYPE PyBoostLogNormal_Type; @@ -299,7 +299,7 @@ typedef struct { PyBoostLogNormal_SimpleNew_RET PyBoostLogNormal_SimpleNew PyBoostLogNormal_SimpleNew_PROTO; /*************************************** - * Bindings for xbob.core.random.gamma * + * Bindings for bob.core.random.gamma * ***************************************/ extern PyBoostGamma_Type_TYPE PyBoostGamma_Type; @@ -311,7 +311,7 @@ typedef struct { PyBoostGamma_SimpleNew_RET PyBoostGamma_SimpleNew PyBoostGamma_SimpleNew_PROTO; /****************************************** - * Bindings for xbob.core.random.binomial * + * Bindings for bob.core.random.binomial * ******************************************/ extern PyBoostBinomial_Type_TYPE PyBoostBinomial_Type; @@ -323,7 +323,7 @@ typedef struct { PyBoostBinomial_SimpleNew_RET PyBoostBinomial_SimpleNew PyBoostBinomial_SimpleNew_PROTO; /****************************************** - * Bindings for xbob.core.random.discrete * + * Bindings for bob.core.random.discrete * ******************************************/ extern PyBoostDiscrete_Type_TYPE PyBoostDiscrete_Type; @@ -339,12 +339,12 @@ typedef struct { /* This section is used in modules that use `blitz.array's' C-API */ # if defined(NO_IMPORT_ARRAY) - extern void **PyXbobCoreRandom_API; + extern void **PyBobCoreRandom_API; # else # if defined(PY_ARRAY_UNIQUE_SYMBOL) - void **PyXbobCoreRandom_API; + void **PyBobCoreRandom_API; # else - static void **PyXbobCoreRandom_API=NULL; + static void **PyBobCoreRandom_API=NULL; # endif # endif @@ -352,105 +352,105 @@ typedef struct { * Versioning * **************/ -# define PyXbobCoreRandom_APIVersion (*(PyXbobCoreRandom_APIVersion_TYPE *)PyXbobCoreRandom_API[PyXbobCoreRandom_APIVersion_NUM]) +# define PyBobCoreRandom_APIVersion (*(PyBobCoreRandom_APIVersion_TYPE *)PyBobCoreRandom_API[PyBobCoreRandom_APIVersion_NUM]) /***************************************** - * Bindings for xbob.core.random.mt19937 * + * Bindings for bob.core.random.mt19937 * *****************************************/ -# define PyBoostMt19937_Type (*(PyBoostMt19937_Type_TYPE *)PyXbobCoreRandom_API[PyBoostMt19937_Type_NUM]) +# define PyBoostMt19937_Type (*(PyBoostMt19937_Type_TYPE *)PyBobCoreRandom_API[PyBoostMt19937_Type_NUM]) -# define PyBoostMt19937_Check (*(PyBoostMt19937_Check_RET (*)PyBoostMt19937_Check_PROTO) PyXbobCoreRandom_API[PyBoostMt19937_Check_NUM]) +# define PyBoostMt19937_Check (*(PyBoostMt19937_Check_RET (*)PyBoostMt19937_Check_PROTO) PyBobCoreRandom_API[PyBoostMt19937_Check_NUM]) -# define PyBoostMt19937_Converter (*(PyBoostMt19937_Converter_RET (*)PyBoostMt19937_Converter_PROTO) PyXbobCoreRandom_API[PyBoostMt19937_Converter_NUM]) +# define PyBoostMt19937_Converter (*(PyBoostMt19937_Converter_RET (*)PyBoostMt19937_Converter_PROTO) PyBobCoreRandom_API[PyBoostMt19937_Converter_NUM]) -# define PyBoostMt19937_SimpleNew (*(PyBoostMt19937_SimpleNew_RET (*)PyBoostMt19937_SimpleNew_PROTO) PyXbobCoreRandom_API[PyBoostMt19937_SimpleNew_NUM]) +# define PyBoostMt19937_SimpleNew (*(PyBoostMt19937_SimpleNew_RET (*)PyBoostMt19937_SimpleNew_PROTO) PyBobCoreRandom_API[PyBoostMt19937_SimpleNew_NUM]) -# define PyBoostMt19937_NewWithSeed (*(PyBoostMt19937_NewWithSeed_RET (*)PyBoostMt19937_NewWithSeed_PROTO) PyXbobCoreRandom_API[PyBoostMt19937_NewWithSeed_NUM]) +# define PyBoostMt19937_NewWithSeed (*(PyBoostMt19937_NewWithSeed_RET (*)PyBoostMt19937_NewWithSeed_PROTO) PyBobCoreRandom_API[PyBoostMt19937_NewWithSeed_NUM]) /***************************************** - * Bindings for xbob.core.random.uniform * + * Bindings for bob.core.random.uniform * *****************************************/ -# define PyBoostUniform_Type (*(PyBoostUniform_Type_TYPE *)PyXbobCoreRandom_API[PyBoostUniform_Type_NUM]) +# define PyBoostUniform_Type (*(PyBoostUniform_Type_TYPE *)PyBobCoreRandom_API[PyBoostUniform_Type_NUM]) -# define PyBoostUniform_Check (*(PyBoostUniform_Check_RET (*)PyBoostUniform_Check_PROTO) PyXbobCoreRandom_API[PyBoostUniform_Check_NUM]) +# define PyBoostUniform_Check (*(PyBoostUniform_Check_RET (*)PyBoostUniform_Check_PROTO) PyBobCoreRandom_API[PyBoostUniform_Check_NUM]) -# define PyBoostUniform_Converter (*(PyBoostUniform_Converter_RET (*)PyBoostUniform_Converter_PROTO) PyXbobCoreRandom_API[PyBoostUniform_Converter_NUM]) +# define PyBoostUniform_Converter (*(PyBoostUniform_Converter_RET (*)PyBoostUniform_Converter_PROTO) PyBobCoreRandom_API[PyBoostUniform_Converter_NUM]) -# define PyBoostUniform_SimpleNew (*(PyBoostUniform_SimpleNew_RET (*)PyBoostUniform_SimpleNew_PROTO) PyXbobCoreRandom_API[PyBoostUniform_SimpleNew_NUM]) +# define PyBoostUniform_SimpleNew (*(PyBoostUniform_SimpleNew_RET (*)PyBoostUniform_SimpleNew_PROTO) PyBobCoreRandom_API[PyBoostUniform_SimpleNew_NUM]) /**************************************** - * Bindings for xbob.core.random.normal * + * Bindings for bob.core.random.normal * ****************************************/ -# define PyBoostNormal_Type (*(PyBoostNormal_Type_TYPE *)PyXbobCoreRandom_API[PyBoostNormal_Type_NUM]) +# define PyBoostNormal_Type (*(PyBoostNormal_Type_TYPE *)PyBobCoreRandom_API[PyBoostNormal_Type_NUM]) -# define PyBoostNormal_Check (*(PyBoostNormal_Check_RET (*)PyBoostNormal_Check_PROTO) PyXbobCoreRandom_API[PyBoostNormal_Check_NUM]) +# define PyBoostNormal_Check (*(PyBoostNormal_Check_RET (*)PyBoostNormal_Check_PROTO) PyBobCoreRandom_API[PyBoostNormal_Check_NUM]) -# define PyBoostNormal_Converter (*(PyBoostNormal_Converter_RET (*)PyBoostNormal_Converter_PROTO) PyXbobCoreRandom_API[PyBoostNormal_Converter_NUM]) +# define PyBoostNormal_Converter (*(PyBoostNormal_Converter_RET (*)PyBoostNormal_Converter_PROTO) PyBobCoreRandom_API[PyBoostNormal_Converter_NUM]) -# define PyBoostNormal_SimpleNew (*(PyBoostNormal_SimpleNew_RET (*)PyBoostNormal_SimpleNew_PROTO) PyXbobCoreRandom_API[PyBoostNormal_SimpleNew_NUM]) +# define PyBoostNormal_SimpleNew (*(PyBoostNormal_SimpleNew_RET (*)PyBoostNormal_SimpleNew_PROTO) PyBobCoreRandom_API[PyBoostNormal_SimpleNew_NUM]) /******************************************* - * Bindings for xbob.core.random.lognormal * + * Bindings for bob.core.random.lognormal * *******************************************/ -# define PyBoostLogNormal_Type (*(PyBoostLogNormal_Type_TYPE *)PyXbobCoreRandom_API[PyBoostLogNormal_Type_NUM]) +# define PyBoostLogNormal_Type (*(PyBoostLogNormal_Type_TYPE *)PyBobCoreRandom_API[PyBoostLogNormal_Type_NUM]) -# define PyBoostLogNormal_Check (*(PyBoostLogNormal_Check_RET (*)PyBoostLogNormal_Check_PROTO) PyXbobCoreRandom_API[PyBoostLogNormal_Check_NUM]) +# define PyBoostLogNormal_Check (*(PyBoostLogNormal_Check_RET (*)PyBoostLogNormal_Check_PROTO) PyBobCoreRandom_API[PyBoostLogNormal_Check_NUM]) -# define PyBoostLogNormal_Converter (*(PyBoostLogNormal_Converter_RET (*)PyBoostLogNormal_Converter_PROTO) PyXbobCoreRandom_API[PyBoostLogNormal_Converter_NUM]) +# define PyBoostLogNormal_Converter (*(PyBoostLogNormal_Converter_RET (*)PyBoostLogNormal_Converter_PROTO) PyBobCoreRandom_API[PyBoostLogNormal_Converter_NUM]) -# define PyBoostLogNormal_SimpleNew (*(PyBoostLogNormal_SimpleNew_RET (*)PyBoostLogNormal_SimpleNew_PROTO) PyXbobCoreRandom_API[PyBoostLogNormal_SimpleNew_NUM]) +# define PyBoostLogNormal_SimpleNew (*(PyBoostLogNormal_SimpleNew_RET (*)PyBoostLogNormal_SimpleNew_PROTO) PyBobCoreRandom_API[PyBoostLogNormal_SimpleNew_NUM]) /*************************************** - * Bindings for xbob.core.random.gamma * + * Bindings for bob.core.random.gamma * ***************************************/ -# define PyBoostGamma_Type (*(PyBoostGamma_Type_TYPE *)PyXbobCoreRandom_API[PyBoostGamma_Type_NUM]) +# define PyBoostGamma_Type (*(PyBoostGamma_Type_TYPE *)PyBobCoreRandom_API[PyBoostGamma_Type_NUM]) -# define PyBoostGamma_Check (*(PyBoostGamma_Check_RET (*)PyBoostGamma_Check_PROTO) PyXbobCoreRandom_API[PyBoostGamma_Check_NUM]) +# define PyBoostGamma_Check (*(PyBoostGamma_Check_RET (*)PyBoostGamma_Check_PROTO) PyBobCoreRandom_API[PyBoostGamma_Check_NUM]) -# define PyBoostGamma_Converter (*(PyBoostGamma_Converter_RET (*)PyBoostGamma_Converter_PROTO) PyXbobCoreRandom_API[PyBoostGamma_Converter_NUM]) +# define PyBoostGamma_Converter (*(PyBoostGamma_Converter_RET (*)PyBoostGamma_Converter_PROTO) PyBobCoreRandom_API[PyBoostGamma_Converter_NUM]) -# define PyBoostGamma_SimpleNew (*(PyBoostGamma_SimpleNew_RET (*)PyBoostGamma_SimpleNew_PROTO) PyXbobCoreRandom_API[PyBoostGamma_SimpleNew_NUM]) +# define PyBoostGamma_SimpleNew (*(PyBoostGamma_SimpleNew_RET (*)PyBoostGamma_SimpleNew_PROTO) PyBobCoreRandom_API[PyBoostGamma_SimpleNew_NUM]) /****************************************** - * Bindings for xbob.core.random.binomial * + * Bindings for bob.core.random.binomial * ******************************************/ -# define PyBoostBinomial_Type (*(PyBoostBinomial_Type_TYPE *)PyXbobCoreRandom_API[PyBoostBinomial_Type_NUM]) +# define PyBoostBinomial_Type (*(PyBoostBinomial_Type_TYPE *)PyBobCoreRandom_API[PyBoostBinomial_Type_NUM]) -# define PyBoostBinomial_Check (*(PyBoostBinomial_Check_RET (*)PyBoostBinomial_Check_PROTO) PyXbobCoreRandom_API[PyBoostBinomial_Check_NUM]) +# define PyBoostBinomial_Check (*(PyBoostBinomial_Check_RET (*)PyBoostBinomial_Check_PROTO) PyBobCoreRandom_API[PyBoostBinomial_Check_NUM]) -# define PyBoostBinomial_Converter (*(PyBoostBinomial_Converter_RET (*)PyBoostBinomial_Converter_PROTO) PyXbobCoreRandom_API[PyBoostBinomial_Converter_NUM]) +# define PyBoostBinomial_Converter (*(PyBoostBinomial_Converter_RET (*)PyBoostBinomial_Converter_PROTO) PyBobCoreRandom_API[PyBoostBinomial_Converter_NUM]) -# define PyBoostBinomial_SimpleNew (*(PyBoostBinomial_SimpleNew_RET (*)PyBoostBinomial_SimpleNew_PROTO) PyXbobCoreRandom_API[PyBoostBinomial_SimpleNew_NUM]) +# define PyBoostBinomial_SimpleNew (*(PyBoostBinomial_SimpleNew_RET (*)PyBoostBinomial_SimpleNew_PROTO) PyBobCoreRandom_API[PyBoostBinomial_SimpleNew_NUM]) /****************************************** - * Bindings for xbob.core.random.discrete * + * Bindings for bob.core.random.discrete * ******************************************/ -# define PyBoostDiscrete_Type (*(PyBoostDiscrete_Type_TYPE *)PyXbobCoreRandom_API[PyBoostDiscrete_Type_NUM]) +# define PyBoostDiscrete_Type (*(PyBoostDiscrete_Type_TYPE *)PyBobCoreRandom_API[PyBoostDiscrete_Type_NUM]) -# define PyBoostDiscrete_Check (*(PyBoostDiscrete_Check_RET (*)PyBoostDiscrete_Check_PROTO) PyXbobCoreRandom_API[PyBoostDiscrete_Check_NUM]) +# define PyBoostDiscrete_Check (*(PyBoostDiscrete_Check_RET (*)PyBoostDiscrete_Check_PROTO) PyBobCoreRandom_API[PyBoostDiscrete_Check_NUM]) -# define PyBoostDiscrete_Converter (*(PyBoostDiscrete_Converter_RET (*)PyBoostDiscrete_Converter_PROTO) PyXbobCoreRandom_API[PyBoostDiscrete_Converter_NUM]) +# define PyBoostDiscrete_Converter (*(PyBoostDiscrete_Converter_RET (*)PyBoostDiscrete_Converter_PROTO) PyBobCoreRandom_API[PyBoostDiscrete_Converter_NUM]) -# define PyBoostDiscrete_SimpleNew (*(PyBoostDiscrete_SimpleNew_RET (*)PyBoostDiscrete_SimpleNew_PROTO) PyXbobCoreRandom_API[PyBoostDiscrete_SimpleNew_NUM]) +# define PyBoostDiscrete_SimpleNew (*(PyBoostDiscrete_SimpleNew_RET (*)PyBoostDiscrete_SimpleNew_PROTO) PyBobCoreRandom_API[PyBoostDiscrete_SimpleNew_NUM]) # if !defined(NO_IMPORT_ARRAY) /** * Returns -1 on error, 0 on success. */ - static int import_xbob_core_random(void) { + static int import_bob_core_random(void) { PyObject *c_api_object; PyObject *module; - module = PyImport_ImportModule(XBOB_CORE_RANDOM_FULL_NAME); + module = PyImport_ImportModule(BOB_CORE_RANDOM_FULL_NAME); if (module == NULL) return -1; @@ -463,34 +463,34 @@ typedef struct { # if PY_VERSION_HEX >= 0x02070000 if (PyCapsule_CheckExact(c_api_object)) { - PyXbobCoreRandom_API = (void **)PyCapsule_GetPointer(c_api_object, + PyBobCoreRandom_API = (void **)PyCapsule_GetPointer(c_api_object, PyCapsule_GetName(c_api_object)); } # else if (PyCObject_Check(c_api_object)) { - PyXbobCoreRandom_API = (void **)PyCObject_AsVoidPtr(c_api_object); + PyBobCoreRandom_API = (void **)PyCObject_AsVoidPtr(c_api_object); } # endif Py_DECREF(c_api_object); Py_DECREF(module); - if (!PyXbobCoreRandom_API) { + if (!PyBobCoreRandom_API) { PyErr_SetString(PyExc_ImportError, "cannot find C/C++ API " # if PY_VERSION_HEX >= 0x02070000 "capsule" # else "cobject" # endif - " at `" XBOB_CORE_RANDOM_FULL_NAME "._C_API'"); + " at `" BOB_CORE_RANDOM_FULL_NAME "._C_API'"); return -1; } /* Checks that the imported version matches the compiled version */ - int imported_version = *(int*)PyXbobCoreRandom_API[PyXbobCoreRandom_APIVersion_NUM]; + int imported_version = *(int*)PyBobCoreRandom_API[PyBobCoreRandom_APIVersion_NUM]; - if (XBOB_CORE_API_VERSION != imported_version) { - PyErr_Format(PyExc_ImportError, XBOB_CORE_RANDOM_FULL_NAME " import error: you compiled against API version 0x%04x, but are now importing an API with version 0x%04x which is not compatible - check your Python runtime environment for errors", XBOB_CORE_API_VERSION, imported_version); + if (BOB_CORE_API_VERSION != imported_version) { + PyErr_Format(PyExc_ImportError, BOB_CORE_RANDOM_FULL_NAME " import error: you compiled against API version 0x%04x, but are now importing an API with version 0x%04x which is not compatible - check your Python runtime environment for errors", BOB_CORE_API_VERSION, imported_version); return -1; } @@ -501,6 +501,6 @@ typedef struct { # endif //!defined(NO_IMPORT_ARRAY) -#endif /* XBOB_CORE_RANDOM_MODULE */ +#endif /* BOB_CORE_RANDOM_MODULE */ -#endif /* XBOB_CORE_RANDOM_H */ +#endif /* BOB_CORE_RANDOM_H */ diff --git a/xbob/core/log.py b/bob/core/log.py similarity index 100% rename from xbob/core/log.py rename to bob/core/log.py diff --git a/xbob/core/logging.cpp b/bob/core/logging.cpp similarity index 97% rename from xbob/core/logging.cpp rename to bob/core/logging.cpp index d5346a6..588ccb5 100644 --- a/xbob/core/logging.cpp +++ b/bob/core/logging.cpp @@ -9,8 +9,8 @@ #include <boost/shared_array.hpp> #include <boost/make_shared.hpp> #include <bob/core/logging.h> -#include <xbob.core/config.h> -#include <xbob.blitz/cleanup.h> +#include <bob.core/config.h> +#include <bob.blitz/cleanup.h> #define PYTHON_LOGGING_DEBUG 0 @@ -492,7 +492,7 @@ PyDoc_STRVAR(module_docstr, "C++ logging handling"); #if PY_VERSION_HEX >= 0x03000000 static PyModuleDef module_definition = { PyModuleDef_HEAD_INIT, - XBOB_EXT_MODULE_NAME, + BOB_EXT_MODULE_NAME, module_docstr, -1, module_methods, @@ -505,20 +505,20 @@ static PyObject* create_module (void) { # if PY_VERSION_HEX >= 0x03000000 PyObject* m = PyModule_Create(&module_definition); # else - PyObject* m = Py_InitModule3(XBOB_EXT_MODULE_NAME, module_methods, module_docstr); + PyObject* m = Py_InitModule3(BOB_EXT_MODULE_NAME, module_methods, module_docstr); # endif if (!m) return 0; auto m_ = make_safe(m); /* register some constants */ - if (PyModule_AddStringConstant(m, "__version__", XBOB_EXT_MODULE_VERSION) < 0) return 0; + if (PyModule_AddStringConstant(m, "__version__", BOB_EXT_MODULE_VERSION) < 0) return 0; Py_INCREF(m); return m; } -PyMODINIT_FUNC XBOB_EXT_ENTRY_NAME (void) { +PyMODINIT_FUNC BOB_EXT_ENTRY_NAME (void) { # if PY_VERSION_HEX >= 0x03000000 return # endif diff --git a/xbob/core/random/__init__.py b/bob/core/random/__init__.py similarity index 93% rename from xbob/core/random/__init__.py rename to bob/core/random/__init__.py index 7c3c228..a36c44f 100644 --- a/xbob/core/random/__init__.py +++ b/bob/core/random/__init__.py @@ -8,7 +8,7 @@ class variate_generator: engine An instance of the RNG you would like to use. This has to be an - object of the class :py:class:`xbob.core.random.mt19937`, already + object of the class :py:class:`bob.core.random.mt19937`, already initialized. distribution diff --git a/xbob/core/random/binomial.cpp b/bob/core/random/binomial.cpp similarity index 98% rename from xbob/core/random/binomial.cpp rename to bob/core/random/binomial.cpp index d4fe6f9..e94d685 100644 --- a/xbob/core/random/binomial.cpp +++ b/bob/core/random/binomial.cpp @@ -5,12 +5,12 @@ * @brief Binomial distributions (with integers or floating point numbers) */ -#define XBOB_CORE_RANDOM_MODULE -#include <xbob.core/random.h> -#include <xbob.blitz/cppapi.h> +#define BOB_CORE_RANDOM_MODULE +#include <bob.core/random.h> +#include <bob.blitz/cppapi.h> #include <boost/make_shared.hpp> -PyDoc_STRVAR(s_binomial_str, XBOB_EXT_MODULE_PREFIX ".binomial"); +PyDoc_STRVAR(s_binomial_str, BOB_EXT_MODULE_PREFIX ".binomial"); PyDoc_STRVAR(s_binomial_doc, "binomial(dtype, [t=1.0, p=0.5]]) -> new binomial distribution\n\ diff --git a/xbob/core/random/discrete.cpp b/bob/core/random/discrete.cpp similarity index 98% rename from xbob/core/random/discrete.cpp rename to bob/core/random/discrete.cpp index d705896..2794557 100644 --- a/xbob/core/random/discrete.cpp +++ b/bob/core/random/discrete.cpp @@ -5,10 +5,10 @@ * @brief Discrete distributions (with integers or floating point numbers) */ -#define XBOB_CORE_RANDOM_MODULE -#include <xbob.core/random.h> -#include <xbob.blitz/cppapi.h> -#include <xbob.blitz/cleanup.h> +#define BOB_CORE_RANDOM_MODULE +#include <bob.core/random.h> +#include <bob.blitz/cppapi.h> +#include <bob.blitz/cleanup.h> #include <boost/make_shared.hpp> #include <boost/version.hpp> @@ -16,7 +16,7 @@ #include <boost/random/discrete_distribution.hpp> #endif -PyDoc_STRVAR(s_discrete_str, XBOB_EXT_MODULE_PREFIX ".discrete"); +PyDoc_STRVAR(s_discrete_str, BOB_EXT_MODULE_PREFIX ".discrete"); /* How to create a new PyBoostDiscreteObject */ static PyObject* PyBoostDiscrete_New(PyTypeObject* type, PyObject*, PyObject*) { diff --git a/xbob/core/random/gamma.cpp b/bob/core/random/gamma.cpp similarity index 98% rename from xbob/core/random/gamma.cpp rename to bob/core/random/gamma.cpp index d03aec1..973f1f0 100644 --- a/xbob/core/random/gamma.cpp +++ b/bob/core/random/gamma.cpp @@ -5,12 +5,12 @@ * @brief Gamma distributions (with integers or floating point numbers) */ -#define XBOB_CORE_RANDOM_MODULE -#include <xbob.core/random.h> -#include <xbob.blitz/cppapi.h> +#define BOB_CORE_RANDOM_MODULE +#include <bob.core/random.h> +#include <bob.blitz/cppapi.h> #include <boost/make_shared.hpp> -PyDoc_STRVAR(s_gamma_str, XBOB_EXT_MODULE_PREFIX ".gamma"); +PyDoc_STRVAR(s_gamma_str, BOB_EXT_MODULE_PREFIX ".gamma"); PyDoc_STRVAR(s_gamma_doc, "gamma(dtype, [alpha=1.]]) -> new gamma distribution\n\ diff --git a/xbob/core/random/lognormal.cpp b/bob/core/random/lognormal.cpp similarity index 98% rename from xbob/core/random/lognormal.cpp rename to bob/core/random/lognormal.cpp index e9f6064..34fffdb 100644 --- a/xbob/core/random/lognormal.cpp +++ b/bob/core/random/lognormal.cpp @@ -5,12 +5,12 @@ * @brief LogNormal distributions (with floating point numbers) */ -#define XBOB_CORE_RANDOM_MODULE -#include <xbob.core/random.h> -#include <xbob.blitz/cppapi.h> +#define BOB_CORE_RANDOM_MODULE +#include <bob.core/random.h> +#include <bob.blitz/cppapi.h> #include <boost/make_shared.hpp> -PyDoc_STRVAR(s_lognormal_str, XBOB_EXT_MODULE_PREFIX ".lognormal"); +PyDoc_STRVAR(s_lognormal_str, BOB_EXT_MODULE_PREFIX ".lognormal"); PyDoc_STRVAR(s_lognormal_doc, "lognormal(dtype, [mean=0., sigma=1.]]) -> new log-normal distribution\n\ diff --git a/bob/core/random/main.cpp b/bob/core/random/main.cpp new file mode 100644 index 0000000..3fcf13c --- /dev/null +++ b/bob/core/random/main.cpp @@ -0,0 +1,196 @@ +/** + * @author Andre Anjos <andre.anjos@idiap.ch> + * @date Fri 25 Oct 16:54:55 2013 + * + * @brief Bindings to boost::random + */ + +#define BOB_CORE_RANDOM_MODULE +#include <bob.core/random.h> + +#ifdef NO_IMPORT_ARRAY +#undef NO_IMPORT_ARRAY +#endif +#include <bob.blitz/capi.h> +#include <bob.blitz/cleanup.h> + +static PyMethodDef module_methods[] = { + {0} /* Sentinel */ +}; + +PyDoc_STRVAR(module_docstr, +"boost::random classes and methods" +); + +#if PY_VERSION_HEX >= 0x03000000 +static PyModuleDef module_definition = { + PyModuleDef_HEAD_INIT, + BOB_EXT_MODULE_NAME, + module_docstr, + -1, + module_methods, + 0, 0, 0, 0 +}; +#endif + +int PyBobCoreRandom_APIVersion = BOB_CORE_API_VERSION; + +static PyObject* create_module (void) { + + PyBoostMt19937_Type.tp_new = PyType_GenericNew; + if (PyType_Ready(&PyBoostMt19937_Type) < 0) return 0; + + PyBoostUniform_Type.tp_new = PyType_GenericNew; + if (PyType_Ready(&PyBoostUniform_Type) < 0) return 0; + + PyBoostNormal_Type.tp_new = PyType_GenericNew; + if (PyType_Ready(&PyBoostNormal_Type) < 0) return 0; + + PyBoostLogNormal_Type.tp_new = PyType_GenericNew; + if (PyType_Ready(&PyBoostLogNormal_Type) < 0) return 0; + + PyBoostGamma_Type.tp_new = PyType_GenericNew; + if (PyType_Ready(&PyBoostGamma_Type) < 0) return 0; + + PyBoostBinomial_Type.tp_new = PyType_GenericNew; + if (PyType_Ready(&PyBoostBinomial_Type) < 0) return 0; + + PyBoostDiscrete_Type.tp_new = PyType_GenericNew; + if (PyType_Ready(&PyBoostDiscrete_Type) < 0) return 0; + +# if PY_VERSION_HEX >= 0x03000000 + PyObject* m = PyModule_Create(&module_definition); +# else + PyObject* m = Py_InitModule3(BOB_EXT_MODULE_NAME, module_methods, module_docstr); +# endif + if (!m) return 0; + auto m_ = make_safe(m); + + /* register some constants */ + if (PyModule_AddIntConstant(m, "__api_version__", BOB_CORE_API_VERSION) < 0) return 0; + if (PyModule_AddStringConstant(m, "__version__", BOB_EXT_MODULE_VERSION) < 0) return 0; + + /* register the types to python */ + Py_INCREF(&PyBoostMt19937_Type); + if (PyModule_AddObject(m, "mt19937", (PyObject *)&PyBoostMt19937_Type) < 0) return 0; + + Py_INCREF(&PyBoostUniform_Type); + if (PyModule_AddObject(m, "uniform", (PyObject *)&PyBoostUniform_Type) < 0) return 0; + + Py_INCREF(&PyBoostNormal_Type); + if (PyModule_AddObject(m, "normal", (PyObject *)&PyBoostNormal_Type) < 0) return 0; + + Py_INCREF(&PyBoostLogNormal_Type); + if (PyModule_AddObject(m, "lognormal", (PyObject *)&PyBoostLogNormal_Type) < 0) return 0; + + Py_INCREF(&PyBoostGamma_Type); + if (PyModule_AddObject(m, "gamma", (PyObject *)&PyBoostGamma_Type) < 0) return 0; + + Py_INCREF(&PyBoostBinomial_Type); + if (PyModule_AddObject(m, "binomial", (PyObject *)&PyBoostBinomial_Type) < 0) return 0; + + Py_INCREF(&PyBoostDiscrete_Type); + if (PyModule_AddObject(m, "discrete", (PyObject *)&PyBoostDiscrete_Type) < 0) return 0; + + static void* PyBobCoreRandom_API[PyBobCoreRandom_API_pointers]; + + /* exhaustive list of C APIs */ + PyBobCoreRandom_API[PyBobCoreRandom_APIVersion_NUM] = (void *)&PyBobCoreRandom_APIVersion; + + /***************************************** + * Bindings for bob.core.random.mt19937 * + *****************************************/ + + PyBobCoreRandom_API[PyBoostMt19937_Type_NUM] = (void *)&PyBoostMt19937_Type; + PyBobCoreRandom_API[PyBoostMt19937_Check_NUM] = (void *)PyBoostMt19937_Check; + PyBobCoreRandom_API[PyBoostMt19937_Converter_NUM] = (void *)PyBoostMt19937_Converter; + PyBobCoreRandom_API[PyBoostMt19937_SimpleNew_NUM] = (void *)PyBoostMt19937_SimpleNew; + PyBobCoreRandom_API[PyBoostMt19937_NewWithSeed_NUM] = (void *)PyBoostMt19937_NewWithSeed; + + /***************************************** + * Bindings for bob.core.random.uniform * + *****************************************/ + + PyBobCoreRandom_API[PyBoostUniform_Type_NUM] = (void *)&PyBoostUniform_Type; + PyBobCoreRandom_API[PyBoostUniform_Check_NUM] = (void *)PyBoostUniform_Check; + PyBobCoreRandom_API[PyBoostUniform_Converter_NUM] = (void *)PyBoostUniform_Converter; + PyBobCoreRandom_API[PyBoostUniform_SimpleNew_NUM] = (void *)PyBoostUniform_SimpleNew; + + /**************************************** + * Bindings for bob.core.random.normal * + ****************************************/ + + PyBobCoreRandom_API[PyBoostNormal_Type_NUM] = (void *)&PyBoostNormal_Type; + PyBobCoreRandom_API[PyBoostNormal_Check_NUM] = (void *)PyBoostNormal_Check; + PyBobCoreRandom_API[PyBoostNormal_Converter_NUM] = (void *)PyBoostNormal_Converter; + PyBobCoreRandom_API[PyBoostNormal_SimpleNew_NUM] = (void *)PyBoostNormal_SimpleNew; + + /******************************************* + * Bindings for bob.core.random.lognormal * + *******************************************/ + + PyBobCoreRandom_API[PyBoostLogNormal_Type_NUM] = (void *)&PyBoostLogNormal_Type; + PyBobCoreRandom_API[PyBoostLogNormal_Check_NUM] = (void *)PyBoostLogNormal_Check; + PyBobCoreRandom_API[PyBoostLogNormal_Converter_NUM] = (void *)PyBoostLogNormal_Converter; + PyBobCoreRandom_API[PyBoostLogNormal_SimpleNew_NUM] = (void *)PyBoostLogNormal_SimpleNew; + + /*************************************** + * Bindings for bob.core.random.gamma * + ***************************************/ + + PyBobCoreRandom_API[PyBoostGamma_Type_NUM] = (void *)&PyBoostGamma_Type; + PyBobCoreRandom_API[PyBoostGamma_Check_NUM] = (void *)PyBoostGamma_Check; + PyBobCoreRandom_API[PyBoostGamma_Converter_NUM] = (void *)PyBoostGamma_Converter; + PyBobCoreRandom_API[PyBoostGamma_SimpleNew_NUM] = (void *)PyBoostGamma_SimpleNew; + + /****************************************** + * Bindings for bob.core.random.binomial * + ******************************************/ + + PyBobCoreRandom_API[PyBoostBinomial_Type_NUM] = (void *)&PyBoostBinomial_Type; + PyBobCoreRandom_API[PyBoostBinomial_Check_NUM] = (void *)PyBoostBinomial_Check; + PyBobCoreRandom_API[PyBoostBinomial_Converter_NUM] = (void *)PyBoostBinomial_Converter; + PyBobCoreRandom_API[PyBoostBinomial_SimpleNew_NUM] = (void *)PyBoostBinomial_SimpleNew; + + /****************************************** + * Bindings for bob.core.random.discrete * + ******************************************/ + + PyBobCoreRandom_API[PyBoostDiscrete_Type_NUM] = (void *)&PyBoostDiscrete_Type; + PyBobCoreRandom_API[PyBoostDiscrete_Check_NUM] = (void *)PyBoostDiscrete_Check; + PyBobCoreRandom_API[PyBoostDiscrete_Converter_NUM] = (void *)PyBoostDiscrete_Converter; + PyBobCoreRandom_API[PyBoostDiscrete_SimpleNew_NUM] = (void *)PyBoostDiscrete_SimpleNew; + +#if PY_VERSION_HEX >= 0x02070000 + + /* defines the PyCapsule */ + + PyObject* c_api_object = PyCapsule_New((void *)PyBobCoreRandom_API, + BOB_EXT_MODULE_PREFIX "." BOB_EXT_MODULE_NAME "._C_API", 0); + +#else + + PyObject* c_api_object = PyCObject_FromVoidPtr((void *)PyBobCoreRandom_API, 0); + +#endif + + if (c_api_object) PyModule_AddObject(m, "_C_API", c_api_object); + + /* imports dependencies */ + if (import_bob_blitz() < 0) { + PyErr_Print(); + PyErr_Format(PyExc_ImportError, "cannot import `%s'", BOB_EXT_MODULE_NAME); + return 0; + } + + Py_INCREF(m); + return m; + +} + +PyMODINIT_FUNC BOB_EXT_ENTRY_NAME (void) { +# if PY_VERSION_HEX >= 0x03000000 + return +# endif + create_module(); +} diff --git a/xbob/core/random/mt19937.cpp b/bob/core/random/mt19937.cpp similarity index 98% rename from xbob/core/random/mt19937.cpp rename to bob/core/random/mt19937.cpp index 2903b2f..2f7f0cd 100644 --- a/xbob/core/random/mt19937.cpp +++ b/bob/core/random/mt19937.cpp @@ -5,10 +5,10 @@ * @brief Bindings for the MT19937 random number generator */ -#define XBOB_CORE_RANDOM_MODULE -#include <xbob.core/random.h> +#define BOB_CORE_RANDOM_MODULE +#include <bob.core/random.h> -PyDoc_STRVAR(s_mt19937_str, XBOB_EXT_MODULE_PREFIX ".mt19937"); +PyDoc_STRVAR(s_mt19937_str, BOB_EXT_MODULE_PREFIX ".mt19937"); PyDoc_STRVAR(s_mt19937_doc, "mt19937([seed]) -> new random number generator\n\ diff --git a/xbob/core/random/mt19937.h b/bob/core/random/mt19937.h similarity index 100% rename from xbob/core/random/mt19937.h rename to bob/core/random/mt19937.h diff --git a/xbob/core/random/normal.cpp b/bob/core/random/normal.cpp similarity index 98% rename from xbob/core/random/normal.cpp rename to bob/core/random/normal.cpp index a93d02a..af1c86c 100644 --- a/xbob/core/random/normal.cpp +++ b/bob/core/random/normal.cpp @@ -5,12 +5,12 @@ * @brief Normal distributions (with integers or floating point numbers) */ -#define XBOB_CORE_RANDOM_MODULE -#include <xbob.core/random.h> -#include <xbob.blitz/cppapi.h> +#define BOB_CORE_RANDOM_MODULE +#include <bob.core/random.h> +#include <bob.blitz/cppapi.h> #include <boost/make_shared.hpp> -PyDoc_STRVAR(s_normal_str, XBOB_EXT_MODULE_PREFIX ".normal"); +PyDoc_STRVAR(s_normal_str, BOB_EXT_MODULE_PREFIX ".normal"); /* How to create a new PyBoostNormalObject */ static PyObject* PyBoostNormal_New(PyTypeObject* type, PyObject*, PyObject*) { diff --git a/xbob/core/random/uniform.cpp b/bob/core/random/uniform.cpp similarity index 99% rename from xbob/core/random/uniform.cpp rename to bob/core/random/uniform.cpp index 4c16b33..4f75834 100644 --- a/xbob/core/random/uniform.cpp +++ b/bob/core/random/uniform.cpp @@ -5,12 +5,12 @@ * @brief Uniform distributions (with integers or floating point numbers) */ -#define XBOB_CORE_RANDOM_MODULE -#include <xbob.core/random.h> -#include <xbob.blitz/cppapi.h> +#define BOB_CORE_RANDOM_MODULE +#include <bob.core/random.h> +#include <bob.blitz/cppapi.h> #include <boost/make_shared.hpp> -PyDoc_STRVAR(s_uniform_str, XBOB_EXT_MODULE_PREFIX ".uniform"); +PyDoc_STRVAR(s_uniform_str, BOB_EXT_MODULE_PREFIX ".uniform"); /* How to create a new PyBoostUniformObject */ static PyObject* PyBoostUniform_New(PyTypeObject* type, PyObject*, PyObject*) { diff --git a/xbob/core/test_convert.py b/bob/core/test_convert.py similarity index 100% rename from xbob/core/test_convert.py rename to bob/core/test_convert.py diff --git a/xbob/core/test_logging.py b/bob/core/test_logging.py similarity index 100% rename from xbob/core/test_logging.py rename to bob/core/test_logging.py diff --git a/xbob/core/test_random.py b/bob/core/test_random.py similarity index 99% rename from xbob/core/test_random.py rename to bob/core/test_random.py index b1dd872..f908254 100644 --- a/xbob/core/test_random.py +++ b/bob/core/test_random.py @@ -3,7 +3,7 @@ # Andre Anjos <andre.anjos@idiap.ch> # Sat 2 Nov 10:05:23 2013 -"""Tests for xbob.core.random +"""Tests for bob.core.random """ from __future__ import division diff --git a/xbob/core/version.cpp b/bob/core/version.cpp similarity index 84% rename from xbob/core/version.cpp rename to bob/core/version.cpp index a4dc58a..4a63f4c 100644 --- a/xbob/core/version.cpp +++ b/bob/core/version.cpp @@ -7,7 +7,7 @@ #include <Python.h> -#include <xbob.core/config.h> +#include <bob.core/config.h> #include <bob/config.h> @@ -24,8 +24,8 @@ #ifdef NO_IMPORT_ARRAY #undef NO_IMPORT_ARRAY #endif -#include <xbob.blitz/capi.h> -#include <xbob.blitz/cleanup.h> +#include <bob.blitz/capi.h> +#include <bob.blitz/cleanup.h> static int dict_set(PyObject* d, const char* key, const char* value) { PyObject* v = Py_BuildValue("s", value); @@ -101,10 +101,10 @@ static PyObject* numpy_version() { } /** - * xbob.blitz c/c++ api version + * bob.blitz c/c++ api version */ -static PyObject* xbob_blitz_version() { - return Py_BuildValue("{ss}", "api", BOOST_PP_STRINGIZE(XBOB_BLITZ_API_VERSION)); +static PyObject* bob_blitz_version() { + return Py_BuildValue("{ss}", "api", BOOST_PP_STRINGIZE(BOB_BLITZ_API_VERSION)); } static PyObject* build_version_dictionary() { @@ -118,7 +118,7 @@ static PyObject* build_version_dictionary() { if (!dict_steal(retval, "Compiler", compiler_version())) return 0; if (!dict_steal(retval, "Python", python_version())) return 0; if (!dict_steal(retval, "NumPy", numpy_version())) return 0; - if (!dict_steal(retval, "xbob.blitz", xbob_blitz_version())) return 0; + if (!dict_steal(retval, "bob.blitz", bob_blitz_version())) return 0; if (!dict_steal(retval, "Bob", bob_version())) return 0; Py_INCREF(retval); @@ -136,7 +136,7 @@ PyDoc_STRVAR(module_docstr, #if PY_VERSION_HEX >= 0x03000000 static PyModuleDef module_definition = { PyModuleDef_HEAD_INIT, - XBOB_EXT_MODULE_NAME, + BOB_EXT_MODULE_NAME, module_docstr, -1, module_methods, @@ -149,16 +149,16 @@ static PyObject* create_module (void) { # if PY_VERSION_HEX >= 0x03000000 PyObject* m = PyModule_Create(&module_definition); # else - PyObject* m = Py_InitModule3(XBOB_EXT_MODULE_NAME, module_methods, module_docstr); + PyObject* m = Py_InitModule3(BOB_EXT_MODULE_NAME, module_methods, module_docstr); # endif if (!m) return 0; auto m_ = make_safe(m); ///< protects against early returns /* register version numbers and constants */ - if (PyModule_AddStringConstant(m, "module", XBOB_EXT_MODULE_VERSION) < 0) + if (PyModule_AddStringConstant(m, "module", BOB_EXT_MODULE_VERSION) < 0) return 0; - if (PyModule_AddIntConstant(m, "api", XBOB_CORE_API_VERSION) < 0) + if (PyModule_AddIntConstant(m, "api", BOB_CORE_API_VERSION) < 0) return 0; PyObject* externals = build_version_dictionary(); @@ -166,9 +166,9 @@ static PyObject* create_module (void) { if (PyModule_AddObject(m, "externals", externals) < 0) return 0; /* imports dependencies */ - if (import_xbob_blitz() < 0) { + if (import_bob_blitz() < 0) { PyErr_Print(); - PyErr_Format(PyExc_ImportError, "cannot import `%s'", XBOB_EXT_MODULE_NAME); + PyErr_Format(PyExc_ImportError, "cannot import `%s'", BOB_EXT_MODULE_NAME); return 0; } @@ -177,7 +177,7 @@ static PyObject* create_module (void) { } -PyMODINIT_FUNC XBOB_EXT_ENTRY_NAME (void) { +PyMODINIT_FUNC BOB_EXT_ENTRY_NAME (void) { # if PY_VERSION_HEX >= 0x03000000 return # endif diff --git a/buildout.cfg b/buildout.cfg index 5dc5595..06bbb1a 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -4,23 +4,23 @@ [buildout] parts = scripts -eggs = xbob.core -extensions = xbob.buildout +eggs = bob.core +extensions = bob.buildout mr.developer auto-checkout = * -develop = src/xbob.extension - src/xbob.blitz +develop = src/bob.extension + src/bob.blitz . -; options for xbob.buildout extension +; options for bob.buildout extension debug = true verbose = true prefixes = /idiap/group/torch5spro/nightlies/last/bob/linux-x86_64-release /Users/andre/work/bob/b/dbg/ [sources] -xbob.extension = git https://github.com/bioidiap/xbob.extension branch=prototype -xbob.blitz = git https://github.com/bioidiap/xbob.blitz +bob.extension = git https://github.com/bioidiap/bob.extension +bob.blitz = git https://github.com/bioidiap/bob.blitz [scripts] -recipe = xbob.buildout:scripts +recipe = bob.buildout:scripts diff --git a/doc/c_cpp_api.rst b/doc/c_cpp_api.rst index 712b618..71da296 100644 --- a/doc/c_cpp_api.rst +++ b/doc/c_cpp_api.rst @@ -6,10 +6,10 @@ C++ API ========= -The C++ API of ``xbob.core`` allows users to leverage from automatic converters -for classes in :py:class:`xbob.core.random`. To use the C API, clients should -first, include the header file ``<xbob.core/random.h>`` on their compilation -units and then, make sure to call once ``import_xbob_core_random()`` at their +The C++ API of ``bob.core`` allows users to leverage from automatic converters +for classes in :py:class:`bob.core.random`. To use the C API, clients should +first, include the header file ``<bob.core/random.h>`` on their compilation +units and then, make sure to call once ``import_bob_core_random()`` at their module instantiation, as explained at the `Python manual <http://docs.python.org/2/extending/extending.html#using-capsules>`_. @@ -18,8 +18,8 @@ the import function: .. code-block:: c++ - #include <xbob.blitz/capi.h> - #include <xbob.core/random.h> + #include <bob.blitz/capi.h> + #include <bob.core/random.h> PyMODINIT_FUNC initclient(void) { @@ -28,14 +28,14 @@ the import function: if (!m) return; // imports dependencies - if (import_xbob_blitz() < 0) { + if (import_bob_blitz() < 0) { PyErr_Print(); PyErr_SetString(PyExc_ImportError, "cannot import module"); return 0; } // imports dependencies - if (import_xbob_core_random() < 0) { + if (import_bob_core_random() < 0) { PyErr_Print(); PyErr_SetString(PyExc_ImportError, "cannot import module"); return 0; @@ -48,7 +48,7 @@ the import function: .. note:: The include directory can be discovered using - :py:func:`xbob.core.get_include`. + :py:func:`bob.core.get_include`. Mersenne Twister Random Number Generator (mt19937) -------------------------------------------------- diff --git a/doc/conf.py b/doc/conf.py index f330208..960d1c2 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -58,12 +58,12 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'xbob.core' +project = u'bob.core' import time copyright = u'%s, Idiap Research Institute' % time.strftime('%Y') # Grab the setup entry -distribution = pkg_resources.require('xbob.core')[0] +distribution = pkg_resources.require('bob.core')[0] # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -129,7 +129,7 @@ if sphinx.__version__ >= "1.0": #html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = 'xbob_core' +#html_short_title = 'bob_core' # The name of an image file (relative to this directory) to place at the top # of the sidebar. @@ -187,7 +187,7 @@ html_favicon = 'img/favicon.ico' #html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'xbob_core_doc' +htmlhelp_basename = 'bob_core_doc' # -- Options for LaTeX output -------------------------------------------------- @@ -201,7 +201,7 @@ latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'xbob_core.tex', u'Bob Core Routines', + ('index', 'bob_core.tex', u'Bob Core Routines', u'Biometrics Group, Idiap Research Institute', 'manual'), ] @@ -241,7 +241,7 @@ rst_epilog = """ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'xbob_core', u'Bob Core Routines Documentation', [u'Idiap Research Institute'], 1) + ('index', 'bob_core', u'Bob Core Routines Documentation', [u'Idiap Research Institute'], 1) ] # Default processing flags for sphinx diff --git a/doc/guide.rst b/doc/guide.rst index 3467f61..1fe6027 100644 --- a/doc/guide.rst +++ b/doc/guide.rst @@ -5,7 +5,7 @@ .. testsetup:: coretest import numpy - import xbob.core + import bob.core ============ User Guide @@ -14,7 +14,7 @@ Array Conversion ---------------- -The function :py:func:`xbob.core.convert` allows you to convert objects of type +The function :py:func:`bob.core.convert` allows you to convert objects of type :py:class:`numpy.ndarray` between different types, with range compression or decompression. For example, here we demonstrate a conversion using default ranges. In this type of conversion, our implementation will assume that the @@ -28,7 +28,7 @@ expand it to the range of ``uint16_t`` numbers, as desired by the programmer: >>> x array([[ 0, 255, 0], [255, 0, 255]], dtype=uint8) - >>> xbob.core.convert(x, 'uint16') + >>> bob.core.convert(x, 'uint16') array([[ 0, 65535, 0], [65535, 0, 65535]], dtype=uint16) @@ -40,7 +40,7 @@ example: :options: +NORMALIZE_WHITESPACE >>> x = numpy.array([0, 10, 20, 30, 40], 'uint8') - >>> xbob.core.convert(x, 'float64', source_range=(0,40), dest_range=(0.,1.)) + >>> bob.core.convert(x, 'float64', source_range=(0,40), dest_range=(0.,1.)) array([ 0. , 0.25, 0.5 , 0.75, 1. ]) Any range not specified is assumed to default on the type range. @@ -50,22 +50,22 @@ Random Number Generation ------------------------ You can build a new random number generator (RNG) of type -:py:class:`xbob.core.random.mt19937` using one of two possible ways: +:py:class:`bob.core.random.mt19937` using one of two possible ways: 1. Use the default constructor, which initializes with the default seed: .. doctest:: coretest :options: +NORMALIZE_WHITESPACE - >>> xbob.core.random.mt19937() - xbob.core.random.mt19937() + >>> bob.core.random.mt19937() + bob.core.random.mt19937() 2. Pass a seed while initializing: .. doctest:: coretest :options: +NORMALIZE_WHITESPACE - >>> rng = xbob.core.random.mt19937(34) + >>> rng = bob.core.random.mt19937(34) RNGs can be compared for equality. The ``==`` operator checks if both generators are on the exact same state and would generate the same sequence of @@ -74,11 +74,11 @@ numbers when exposed to the same distributions. For example: .. doctest:: coretest :options: +NORMALIZE_WHITESPACE - >>> rng1 = xbob.core.random.mt19937(111) - >>> rng2 = xbob.core.random.mt19937(111) + >>> rng1 = bob.core.random.mt19937(111) + >>> rng2 = bob.core.random.mt19937(111) >>> rng1 == rng2 True - >>> rng3 = xbob.core.random.mt19937(12) + >>> rng3 = bob.core.random.mt19937(12) >>> rng1 == rng3 False @@ -99,9 +99,9 @@ effectively generates random numbers: .. doctest:: coretest :options: +NORMALIZE_WHITESPACE - >>> rng = xbob.core.random.mt19937() + >>> rng = bob.core.random.mt19937() >>> # creates an uniform distribution of integers inside [0, 10] - >>> u = xbob.core.random.uniform(int, 0, 10) + >>> u = bob.core.random.uniform(int, 0, 10) >>> u(rng) # doctest: +SKIP 8 @@ -113,7 +113,7 @@ random numbers, we provide a class that mimics the behavior of .. doctest:: coretest :options: +NORMALIZE_WHITESPACE - >>> ugen = xbob.core.random.variate_generator(rng, u) + >>> ugen = bob.core.random.variate_generator(rng, u) >>> ugen() # doctest: +SKIP 6 diff --git a/doc/py_api.rst b/doc/py_api.rst index 8e597ba..bb62b23 100644 --- a/doc/py_api.rst +++ b/doc/py_api.rst @@ -5,44 +5,44 @@ .. testsetup:: coretest import numpy - import xbob.core + import bob.core ============ Python API ============ This section includes information for using the pure Python API of -``xbob.core``. +``bob.core``. Classes ------- -.. autoclass:: xbob.core.random.mt19937 +.. autoclass:: bob.core.random.mt19937 -.. autoclass:: xbob.core.random.uniform +.. autoclass:: bob.core.random.uniform -.. autoclass:: xbob.core.random.normal +.. autoclass:: bob.core.random.normal -.. autoclass:: xbob.core.random.lognormal +.. autoclass:: bob.core.random.lognormal -.. autoclass:: xbob.core.random.gamma +.. autoclass:: bob.core.random.gamma -.. autoclass:: xbob.core.random.binomial +.. autoclass:: bob.core.random.binomial -.. autoclass:: xbob.core.random.discrete +.. autoclass:: bob.core.random.discrete -.. autoclass:: xbob.core.random.variate_generator +.. autoclass:: bob.core.random.variate_generator Functions --------- -.. autofunction:: xbob.core.convert +.. autofunction:: bob.core.convert C++ API Helpers --------------- -.. autofunction:: xbob.core.get_include +.. autofunction:: bob.core.get_include diff --git a/setup.py b/setup.py index f6320a9..7711eb4 100644 --- a/setup.py +++ b/setup.py @@ -4,12 +4,12 @@ # Mon 16 Apr 08:18:08 2012 CEST from setuptools import setup, find_packages, dist -dist.Distribution(dict(setup_requires=['xbob.blitz'])) -from xbob.blitz.extension import Extension +dist.Distribution(dict(setup_requires=['bob.blitz'])) +from bob.blitz.extension import Extension import os package_dir = os.path.dirname(os.path.realpath(__file__)) -package_dir = os.path.join(package_dir, 'xbob', 'core', 'include') +package_dir = os.path.join(package_dir, 'bob', 'core', 'include') include_dirs = [package_dir] packages = ['bob-core >= 1.2.2', 'boost'] @@ -17,10 +17,10 @@ version = '2.0.0a0' setup( - name='xbob.core', + name='bob.core', version=version, description='Bindings for bob.core', - url='http://github.com/bioidiap/xbob.core', + url='http://github.com/bioidiap/bob.core', license='BSD', author='Andre Anjos', author_email='andre.anjos@idiap.ch', @@ -32,48 +32,48 @@ setup( install_requires=[ 'setuptools', - 'xbob.blitz', + 'bob.blitz', ], namespace_packages=[ - "xbob", + "bob", ], ext_modules = [ - Extension("xbob.core.version", + Extension("bob.core.version", [ - "xbob/core/version.cpp", + "bob/core/version.cpp", ], version = version, packages = packages, include_dirs = include_dirs, ), - Extension("xbob.core._convert", + Extension("bob.core._convert", [ - "xbob/core/convert.cpp", + "bob/core/convert.cpp", ], version = version, packages = packages, include_dirs = include_dirs, ), - Extension("xbob.core._logging", + Extension("bob.core._logging", [ - "xbob/core/logging.cpp", + "bob/core/logging.cpp", ], version = version, packages = packages, include_dirs = include_dirs, ), - Extension("xbob.core.random._library", + Extension("bob.core.random._library", [ - "xbob/core/random/mt19937.cpp", - "xbob/core/random/uniform.cpp", - "xbob/core/random/normal.cpp", - "xbob/core/random/lognormal.cpp", - "xbob/core/random/gamma.cpp", - "xbob/core/random/binomial.cpp", - "xbob/core/random/discrete.cpp", - "xbob/core/random/main.cpp", + "bob/core/random/mt19937.cpp", + "bob/core/random/uniform.cpp", + "bob/core/random/normal.cpp", + "bob/core/random/lognormal.cpp", + "bob/core/random/gamma.cpp", + "bob/core/random/binomial.cpp", + "bob/core/random/discrete.cpp", + "bob/core/random/main.cpp", ], version = version, packages = packages, diff --git a/xbob/core/include/xbob.core/config.h b/xbob/core/include/xbob.core/config.h deleted file mode 100644 index a2b2412..0000000 --- a/xbob/core/include/xbob.core/config.h +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @author Andre Anjos <andre.anjos@idiap.ch> - * @date Fri 1 Nov 07:10:59 2013 - * - * @brief General directives for all modules in xbob.core - */ - -#ifndef XBOB_CORE_CONFIG_H -#define XBOB_CORE_CONFIG_H - -/* Macros that define versions and important names */ -#define XBOB_CORE_API_VERSION 0x0200 - -#endif /* XBOB_CORE_CONFIG_H */ diff --git a/xbob/core/random/main.cpp b/xbob/core/random/main.cpp deleted file mode 100644 index fbec6f1..0000000 --- a/xbob/core/random/main.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/** - * @author Andre Anjos <andre.anjos@idiap.ch> - * @date Fri 25 Oct 16:54:55 2013 - * - * @brief Bindings to boost::random - */ - -#define XBOB_CORE_RANDOM_MODULE -#include <xbob.core/random.h> - -#ifdef NO_IMPORT_ARRAY -#undef NO_IMPORT_ARRAY -#endif -#include <xbob.blitz/capi.h> -#include <xbob.blitz/cleanup.h> - -static PyMethodDef module_methods[] = { - {0} /* Sentinel */ -}; - -PyDoc_STRVAR(module_docstr, -"boost::random classes and methods" -); - -#if PY_VERSION_HEX >= 0x03000000 -static PyModuleDef module_definition = { - PyModuleDef_HEAD_INIT, - XBOB_EXT_MODULE_NAME, - module_docstr, - -1, - module_methods, - 0, 0, 0, 0 -}; -#endif - -int PyXbobCoreRandom_APIVersion = XBOB_CORE_API_VERSION; - -static PyObject* create_module (void) { - - PyBoostMt19937_Type.tp_new = PyType_GenericNew; - if (PyType_Ready(&PyBoostMt19937_Type) < 0) return 0; - - PyBoostUniform_Type.tp_new = PyType_GenericNew; - if (PyType_Ready(&PyBoostUniform_Type) < 0) return 0; - - PyBoostNormal_Type.tp_new = PyType_GenericNew; - if (PyType_Ready(&PyBoostNormal_Type) < 0) return 0; - - PyBoostLogNormal_Type.tp_new = PyType_GenericNew; - if (PyType_Ready(&PyBoostLogNormal_Type) < 0) return 0; - - PyBoostGamma_Type.tp_new = PyType_GenericNew; - if (PyType_Ready(&PyBoostGamma_Type) < 0) return 0; - - PyBoostBinomial_Type.tp_new = PyType_GenericNew; - if (PyType_Ready(&PyBoostBinomial_Type) < 0) return 0; - - PyBoostDiscrete_Type.tp_new = PyType_GenericNew; - if (PyType_Ready(&PyBoostDiscrete_Type) < 0) return 0; - -# if PY_VERSION_HEX >= 0x03000000 - PyObject* m = PyModule_Create(&module_definition); -# else - PyObject* m = Py_InitModule3(XBOB_EXT_MODULE_NAME, module_methods, module_docstr); -# endif - if (!m) return 0; - auto m_ = make_safe(m); - - /* register some constants */ - if (PyModule_AddIntConstant(m, "__api_version__", XBOB_CORE_API_VERSION) < 0) return 0; - if (PyModule_AddStringConstant(m, "__version__", XBOB_EXT_MODULE_VERSION) < 0) return 0; - - /* register the types to python */ - Py_INCREF(&PyBoostMt19937_Type); - if (PyModule_AddObject(m, "mt19937", (PyObject *)&PyBoostMt19937_Type) < 0) return 0; - - Py_INCREF(&PyBoostUniform_Type); - if (PyModule_AddObject(m, "uniform", (PyObject *)&PyBoostUniform_Type) < 0) return 0; - - Py_INCREF(&PyBoostNormal_Type); - if (PyModule_AddObject(m, "normal", (PyObject *)&PyBoostNormal_Type) < 0) return 0; - - Py_INCREF(&PyBoostLogNormal_Type); - if (PyModule_AddObject(m, "lognormal", (PyObject *)&PyBoostLogNormal_Type) < 0) return 0; - - Py_INCREF(&PyBoostGamma_Type); - if (PyModule_AddObject(m, "gamma", (PyObject *)&PyBoostGamma_Type) < 0) return 0; - - Py_INCREF(&PyBoostBinomial_Type); - if (PyModule_AddObject(m, "binomial", (PyObject *)&PyBoostBinomial_Type) < 0) return 0; - - Py_INCREF(&PyBoostDiscrete_Type); - if (PyModule_AddObject(m, "discrete", (PyObject *)&PyBoostDiscrete_Type) < 0) return 0; - - static void* PyXbobCoreRandom_API[PyXbobCoreRandom_API_pointers]; - - /* exhaustive list of C APIs */ - PyXbobCoreRandom_API[PyXbobCoreRandom_APIVersion_NUM] = (void *)&PyXbobCoreRandom_APIVersion; - - /***************************************** - * Bindings for xbob.core.random.mt19937 * - *****************************************/ - - PyXbobCoreRandom_API[PyBoostMt19937_Type_NUM] = (void *)&PyBoostMt19937_Type; - PyXbobCoreRandom_API[PyBoostMt19937_Check_NUM] = (void *)PyBoostMt19937_Check; - PyXbobCoreRandom_API[PyBoostMt19937_Converter_NUM] = (void *)PyBoostMt19937_Converter; - PyXbobCoreRandom_API[PyBoostMt19937_SimpleNew_NUM] = (void *)PyBoostMt19937_SimpleNew; - PyXbobCoreRandom_API[PyBoostMt19937_NewWithSeed_NUM] = (void *)PyBoostMt19937_NewWithSeed; - - /***************************************** - * Bindings for xbob.core.random.uniform * - *****************************************/ - - PyXbobCoreRandom_API[PyBoostUniform_Type_NUM] = (void *)&PyBoostUniform_Type; - PyXbobCoreRandom_API[PyBoostUniform_Check_NUM] = (void *)PyBoostUniform_Check; - PyXbobCoreRandom_API[PyBoostUniform_Converter_NUM] = (void *)PyBoostUniform_Converter; - PyXbobCoreRandom_API[PyBoostUniform_SimpleNew_NUM] = (void *)PyBoostUniform_SimpleNew; - - /**************************************** - * Bindings for xbob.core.random.normal * - ****************************************/ - - PyXbobCoreRandom_API[PyBoostNormal_Type_NUM] = (void *)&PyBoostNormal_Type; - PyXbobCoreRandom_API[PyBoostNormal_Check_NUM] = (void *)PyBoostNormal_Check; - PyXbobCoreRandom_API[PyBoostNormal_Converter_NUM] = (void *)PyBoostNormal_Converter; - PyXbobCoreRandom_API[PyBoostNormal_SimpleNew_NUM] = (void *)PyBoostNormal_SimpleNew; - - /******************************************* - * Bindings for xbob.core.random.lognormal * - *******************************************/ - - PyXbobCoreRandom_API[PyBoostLogNormal_Type_NUM] = (void *)&PyBoostLogNormal_Type; - PyXbobCoreRandom_API[PyBoostLogNormal_Check_NUM] = (void *)PyBoostLogNormal_Check; - PyXbobCoreRandom_API[PyBoostLogNormal_Converter_NUM] = (void *)PyBoostLogNormal_Converter; - PyXbobCoreRandom_API[PyBoostLogNormal_SimpleNew_NUM] = (void *)PyBoostLogNormal_SimpleNew; - - /*************************************** - * Bindings for xbob.core.random.gamma * - ***************************************/ - - PyXbobCoreRandom_API[PyBoostGamma_Type_NUM] = (void *)&PyBoostGamma_Type; - PyXbobCoreRandom_API[PyBoostGamma_Check_NUM] = (void *)PyBoostGamma_Check; - PyXbobCoreRandom_API[PyBoostGamma_Converter_NUM] = (void *)PyBoostGamma_Converter; - PyXbobCoreRandom_API[PyBoostGamma_SimpleNew_NUM] = (void *)PyBoostGamma_SimpleNew; - - /****************************************** - * Bindings for xbob.core.random.binomial * - ******************************************/ - - PyXbobCoreRandom_API[PyBoostBinomial_Type_NUM] = (void *)&PyBoostBinomial_Type; - PyXbobCoreRandom_API[PyBoostBinomial_Check_NUM] = (void *)PyBoostBinomial_Check; - PyXbobCoreRandom_API[PyBoostBinomial_Converter_NUM] = (void *)PyBoostBinomial_Converter; - PyXbobCoreRandom_API[PyBoostBinomial_SimpleNew_NUM] = (void *)PyBoostBinomial_SimpleNew; - - /****************************************** - * Bindings for xbob.core.random.discrete * - ******************************************/ - - PyXbobCoreRandom_API[PyBoostDiscrete_Type_NUM] = (void *)&PyBoostDiscrete_Type; - PyXbobCoreRandom_API[PyBoostDiscrete_Check_NUM] = (void *)PyBoostDiscrete_Check; - PyXbobCoreRandom_API[PyBoostDiscrete_Converter_NUM] = (void *)PyBoostDiscrete_Converter; - PyXbobCoreRandom_API[PyBoostDiscrete_SimpleNew_NUM] = (void *)PyBoostDiscrete_SimpleNew; - -#if PY_VERSION_HEX >= 0x02070000 - - /* defines the PyCapsule */ - - PyObject* c_api_object = PyCapsule_New((void *)PyXbobCoreRandom_API, - XBOB_EXT_MODULE_PREFIX "." XBOB_EXT_MODULE_NAME "._C_API", 0); - -#else - - PyObject* c_api_object = PyCObject_FromVoidPtr((void *)PyXbobCoreRandom_API, 0); - -#endif - - if (c_api_object) PyModule_AddObject(m, "_C_API", c_api_object); - - /* imports dependencies */ - if (import_xbob_blitz() < 0) { - PyErr_Print(); - PyErr_Format(PyExc_ImportError, "cannot import `%s'", XBOB_EXT_MODULE_NAME); - return 0; - } - - Py_INCREF(m); - return m; - -} - -PyMODINIT_FUNC XBOB_EXT_ENTRY_NAME (void) { -# if PY_VERSION_HEX >= 0x03000000 - return -# endif - create_module(); -} -- GitLab