diff --git a/.travis.yml b/.travis.yml index 8dc04d398aa787d7ab6539ecc1ce40796fd0a2a9..7edc0474b840d97cbd2259aff3dc8d343f8c61f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,8 +26,8 @@ install: - "python bootstrap.py" - "CFLAGS=-coverage ./bin/buildout" script: - - "./bin/python -c 'from xbob.learn.libsvm import get_config; print(get_config())'" - - "./bin/coverage run --source=xbob.learn.libsvm ./bin/nosetests -sv" + - "./bin/python -c 'from bob.learn.libsvm import get_config; print(get_config())'" + - "./bin/coverage run --source=bob.learn.libsvm ./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 e4ff8a87de1bc18da4c9056e42c5fe211168e5dd..b45a42675dd050c4ff6c0c5d0f6cdc74dfe975c0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ include LICENSE README.rst bootstrap.py buildout.cfg recursive-include doc conf.py doxygen.rc *.rst -recursive-include xbob/learn/libsvm *.cpp *.h -recursive-include xbob/learn/libsvm/data *.* +recursive-include bob/learn/libsvm *.cpp *.h +recursive-include bob/learn/libsvm/data *.* diff --git a/README.rst b/README.rst index 7afe1745e60d7c5c82856cd778afb278f1a114e4..13127ae24265df42ce3ac83d7fe77a33f85881b8 100644 --- a/README.rst +++ b/README.rst @@ -2,16 +2,16 @@ .. Andre Anjos .. Fri 13 Dec 2013 12:35:22 CET -.. image:: https://travis-ci.org/bioidiap/xbob.learn.libsvm.svg?branch=master - :target: https://travis-ci.org/bioidiap/xbob.learn.libsvm -.. image:: https://coveralls.io/repos/bioidiap/xbob.learn.libsvm/badge.png - :target: https://coveralls.io/r/bioidiap/xbob.learn.libsvm -.. image:: http://img.shields.io/github/tag/bioidiap/xbob.learn.libsvm.png - :target: https://github.com/bioidiap/xbob.learn.libsvm -.. image:: http://img.shields.io/pypi/v/xbob.learn.libsvm.png - :target: https://pypi.python.org/pypi/xbob.learn.libsvm -.. image:: http://img.shields.io/pypi/dm/xbob.learn.libsvm.png - :target: https://pypi.python.org/pypi/xbob.learn.libsvm +.. image:: https://travis-ci.org/bioidiap/bob.learn.libsvm.svg?branch=master + :target: https://travis-ci.org/bioidiap/bob.learn.libsvm +.. image:: https://coveralls.io/repos/bioidiap/bob.learn.libsvm/badge.png + :target: https://coveralls.io/r/bioidiap/bob.learn.libsvm +.. image:: http://img.shields.io/github/tag/bioidiap/bob.learn.libsvm.png + :target: https://github.com/bioidiap/bob.learn.libsvm +.. image:: http://img.shields.io/pypi/v/bob.learn.libsvm.png + :target: https://pypi.python.org/pypi/bob.learn.libsvm +.. image:: http://img.shields.io/pypi/dm/bob.learn.libsvm.png + :target: https://pypi.python.org/pypi/bob.learn.libsvm ================================ Bob-Python bindings for LIBSVM @@ -28,8 +28,8 @@ automatically. You can just skip to the installation instructions. In case you have installed ``LIBSVM`` on a non-standard location (e.g. your home directory), then you can specify the path to the root of that installation -using the environment variable ``XBOB_PREFIX_PATH``, **before** building and -installing the package. For example, if ``XBOB_PREFIX_PATH`` is set to +using the environment variable ``BOB_PREFIX_PATH``, **before** building and +installing the package. For example, if ``BOB_PREFIX_PATH`` is set to ``/home/user/libsvm-3.12``, then we will search for the header file ``svm.h`` in ``/home/user/libsvm-3.12/include`` and expect that the library file file is found under ``/home/user/libsvm-3.12/lib``. @@ -37,11 +37,11 @@ found under ``/home/user/libsvm-3.12/lib``. If you are installing this package via ``pip`` for example, just set the environment variable like this:: - $ XBOB_PREFIX_PATH=/home/user/libsvm-3.12 pip install xbob.learn.libsvm + $ BOB_PREFIX_PATH=/home/user/libsvm-3.12 pip install bob.learn.libsvm If you are installing this package via ``zc.buildout``, we recommend you use -our `xbob.buildout `_ extension and -set the ``[environ]`` section to define ``XBOB_PREFIX_PATH``. +our `bob.buildout `_ extension and +set the ``[environ]`` section to define ``BOB_PREFIX_PATH``. Installation ------------ @@ -65,7 +65,7 @@ Testing You can run a set of tests using the nose test runner:: - $ nosetests -sv xbob.learn.libsvm + $ nosetests -sv bob.learn.libsvm .. warning:: @@ -82,7 +82,7 @@ You can run our documentation tests using sphinx itself:: You can test overall test coverage with:: - $ nosetests --with-coverage --cover-package=xbob.learn.libsvm + $ nosetests --with-coverage --cover-package=bob.learn.libsvm 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/learn/__init__.py b/bob/learn/__init__.py similarity index 100% rename from xbob/learn/__init__.py rename to bob/learn/__init__.py diff --git a/xbob/learn/libsvm/__init__.py b/bob/learn/libsvm/__init__.py similarity index 100% rename from xbob/learn/libsvm/__init__.py rename to bob/learn/libsvm/__init__.py diff --git a/xbob/learn/libsvm/data/heart.out b/bob/learn/libsvm/data/heart.out similarity index 100% rename from xbob/learn/libsvm/data/heart.out rename to bob/learn/libsvm/data/heart.out diff --git a/xbob/learn/libsvm/data/heart.svmdata b/bob/learn/libsvm/data/heart.svmdata similarity index 100% rename from xbob/learn/libsvm/data/heart.svmdata rename to bob/learn/libsvm/data/heart.svmdata diff --git a/xbob/learn/libsvm/data/heart.svmmodel b/bob/learn/libsvm/data/heart.svmmodel similarity index 100% rename from xbob/learn/libsvm/data/heart.svmmodel rename to bob/learn/libsvm/data/heart.svmmodel diff --git a/xbob/learn/libsvm/data/heart_no_probs.svmmodel b/bob/learn/libsvm/data/heart_no_probs.svmmodel similarity index 100% rename from xbob/learn/libsvm/data/heart_no_probs.svmmodel rename to bob/learn/libsvm/data/heart_no_probs.svmmodel diff --git a/xbob/learn/libsvm/data/iris.out b/bob/learn/libsvm/data/iris.out similarity index 100% rename from xbob/learn/libsvm/data/iris.out rename to bob/learn/libsvm/data/iris.out diff --git a/xbob/learn/libsvm/data/iris.svmdata b/bob/learn/libsvm/data/iris.svmdata similarity index 100% rename from xbob/learn/libsvm/data/iris.svmdata rename to bob/learn/libsvm/data/iris.svmdata diff --git a/xbob/learn/libsvm/data/iris.svmmodel b/bob/learn/libsvm/data/iris.svmmodel similarity index 100% rename from xbob/learn/libsvm/data/iris.svmmodel rename to bob/learn/libsvm/data/iris.svmmodel diff --git a/xbob/learn/libsvm/file.cpp b/bob/learn/libsvm/file.cpp similarity index 98% rename from xbob/learn/libsvm/file.cpp rename to bob/learn/libsvm/file.cpp index b5cce715da44f603e6ed8a97bc734998ff46d97a..2a5363416f4648a22f4208163a78a4e52abb0667 100644 --- a/xbob/learn/libsvm/file.cpp +++ b/bob/learn/libsvm/file.cpp @@ -7,7 +7,7 @@ * Copyright (C) 2011-2014 Idiap Research Institute, Martigny, Switzerland */ -#include +#include #include #include diff --git a/xbob/learn/libsvm/include/xbob.learn.libsvm/api.h b/bob/learn/libsvm/include/bob.learn.libsvm/api.h similarity index 70% rename from xbob/learn/libsvm/include/xbob.learn.libsvm/api.h rename to bob/learn/libsvm/include/bob.learn.libsvm/api.h index d9d51f7465e4bdf05352a5e7b4461e807c490605..2be6afb7c1e6d1246b5ee05f2b4b7dc8786ad3ca 100644 --- a/xbob/learn/libsvm/include/xbob.learn.libsvm/api.h +++ b/bob/learn/libsvm/include/bob.learn.libsvm/api.h @@ -5,17 +5,17 @@ * @brief C/C++ API for bob::machine */ -#ifndef XBOB_LEARN_LIBSVM_H -#define XBOB_LEARN_LIBSVM_H +#ifndef BOB_LEARN_LIBSVM_H +#define BOB_LEARN_LIBSVM_H #include -#include -#include -#include -#include +#include +#include +#include +#include -#define XBOB_LEARN_LIBSVM_MODULE_PREFIX xbob.learn.libsvm -#define XBOB_LEARN_LIBSVM_MODULE_NAME _library +#define BOB_LEARN_LIBSVM_MODULE_PREFIX bob.learn.libsvm +#define BOB_LEARN_LIBSVM_MODULE_NAME _library /******************* * C API functions * @@ -23,15 +23,15 @@ /* Enum defining entries in the function table */ enum _PyBobLearnLibsvm_ENUM{ - PyXbobLearnLibsvm_APIVersion_NUM = 0, - // Bindings for xbob.learn.libsvm.File + PyBobLearnLibsvm_APIVersion_NUM = 0, + // Bindings for bob.learn.libsvm.File PyBobLearnLibsvmFile_Type_NUM, PyBobLearnLibsvmFile_Check_NUM, - // Bindings for xbob.learn.libsvm.Machine + // Bindings for bob.learn.libsvm.Machine PyBobLearnLibsvmMachine_Type_NUM, PyBobLearnLibsvmMachine_Check_NUM, PyBobLearnLibsvmMachine_NewFromMachine_NUM, - // Bindings for xbob.learn.libsvm.Trainer + // Bindings for bob.learn.libsvm.Trainer PyBobLearnLibsvmTrainer_Type_NUM, PyBobLearnLibsvmTrainer_Check_NUM, // Bindings to general utilities @@ -42,17 +42,17 @@ enum _PyBobLearnLibsvm_ENUM{ PyBobLearnLibsvm_StringAsKernelType_NUM, PyBobLearnLibsvm_CStringAsKernelType_NUM, // Total number of C API pointers - PyXbobLearnLibsvm_API_pointers + PyBobLearnLibsvm_API_pointers }; /************** * Versioning * **************/ -#define PyXbobLearnLibsvm_APIVersion_TYPE int +#define PyBobLearnLibsvm_APIVersion_TYPE int /*************************************** - * Bindings for xbob.learn.libsvm.File * + * Bindings for bob.learn.libsvm.File * ***************************************/ typedef struct { @@ -66,7 +66,7 @@ typedef struct { #define PyBobLearnLibsvmFile_Check_PROTO (PyObject* o) /****************************************** - * Bindings for xbob.learn.libsvm.Machine * + * Bindings for bob.learn.libsvm.Machine * ******************************************/ typedef struct { @@ -83,7 +83,7 @@ typedef struct { #define PyBobLearnLibsvmMachine_NewFromMachine_PROTO (bob::learn::libsvm::Machine* m) /****************************************** - * Bindings for xbob.learn.libsvm.Trainer * + * Bindings for bob.learn.libsvm.Trainer * ******************************************/ typedef struct { @@ -119,18 +119,18 @@ typedef struct { #define PyBobLearnLibsvm_CStringAsKernelType_PROTO (const char* s) -#ifdef XBOB_LEARN_LIBSVM_MODULE +#ifdef BOB_LEARN_LIBSVM_MODULE - /* This section is used when compiling `xbob.learn.libsvm' itself */ + /* This section is used when compiling `bob.learn.libsvm' itself */ /************** * Versioning * **************/ - extern int PyXbobLearnLibsvm_APIVersion; + extern int PyBobLearnLibsvm_APIVersion; /*************************************** - * Bindings for xbob.learn.libsvm.File * + * Bindings for bob.learn.libsvm.File * ***************************************/ extern PyBobLearnLibsvmFile_Type_TYPE PyBobLearnLibsvmFile_Type; @@ -138,7 +138,7 @@ typedef struct { PyBobLearnLibsvmFile_Check_RET PyBobLearnLibsvmFile_Check PyBobLearnLibsvmFile_Check_PROTO; /****************************************** - * Bindings for xbob.learn.libsvm.Machine * + * Bindings for bob.learn.libsvm.Machine * ******************************************/ extern PyBobLearnLibsvmMachine_Type_TYPE PyBobLearnLibsvmMachine_Type; @@ -148,7 +148,7 @@ typedef struct { PyBobLearnLibsvmMachine_NewFromMachine_RET PyBobLearnLibsvmMachine_NewFromMachine PyBobLearnLibsvmMachine_NewFromMachine_PROTO; /****************************************** - * Bindings for xbob.learn.libsvm.Trainer * + * Bindings for bob.learn.libsvm.Trainer * ******************************************/ extern PyBobLearnLibsvmTrainer_Type_TYPE PyBobLearnLibsvmTrainer_Type; @@ -173,7 +173,7 @@ typedef struct { #else - /* This section is used in modules that use `xbob.learn.libsvm's' C-API */ + /* This section is used in modules that use `bob.learn.libsvm's' C-API */ /************************************************************************ * Macros to avoid symbol collision and allow for separate compilation. * @@ -182,18 +182,18 @@ typedef struct { ************************************************************************/ # if defined(PY_ARRAY_UNIQUE_SYMBOL) -# define XBOB_LEARN_LIBSVM_MAKE_API_NAME_INNER(a) XBOB_LEARN_LIBSVM_ ## a -# define XBOB_LEARN_LIBSVM_MAKE_API_NAME(a) XBOB_LEARN_LIBSVM_MAKE_API_NAME_INNER(a) -# define PyXbobLearnLibsvm_API XBOB_LEARN_LIBSVM_MAKE_API_NAME(PY_ARRAY_UNIQUE_SYMBOL) +# define BOB_LEARN_LIBSVM_MAKE_API_NAME_INNER(a) BOB_LEARN_LIBSVM_ ## a +# define BOB_LEARN_LIBSVM_MAKE_API_NAME(a) BOB_LEARN_LIBSVM_MAKE_API_NAME_INNER(a) +# define PyBobLearnLibsvm_API BOB_LEARN_LIBSVM_MAKE_API_NAME(PY_ARRAY_UNIQUE_SYMBOL) # endif # if defined(NO_IMPORT_ARRAY) - extern void **PyXbobLearnLibsvm_API; + extern void **PyBobLearnLibsvm_API; # else # if defined(PY_ARRAY_UNIQUE_SYMBOL) - void **PyXbobLearnLibsvm_API; + void **PyBobLearnLibsvm_API; # else - static void **PyXbobLearnLibsvm_API=NULL; + static void **PyBobLearnLibsvm_API=NULL; # endif # endif @@ -201,49 +201,49 @@ typedef struct { * Versioning * **************/ -# define PyXbobLearnLibsvm_APIVersion (*(PyXbobLearnLibsvm_APIVersion_TYPE *)PyXbobLearnLibsvm_API[PyXbobLearnLibsvm_APIVersion_NUM]) +# define PyBobLearnLibsvm_APIVersion (*(PyBobLearnLibsvm_APIVersion_TYPE *)PyBobLearnLibsvm_API[PyBobLearnLibsvm_APIVersion_NUM]) /*************************************** - * Bindings for xbob.learn.libsvm.File * + * Bindings for bob.learn.libsvm.File * ***************************************/ -# define PyBobLearnLibsvmFile_Type (*(PyBobLearnLibsvmFile_Type_TYPE *)PyXbobLearnLibsvm_API[PyBobLearnLibsvmFile_Type_NUM]) +# define PyBobLearnLibsvmFile_Type (*(PyBobLearnLibsvmFile_Type_TYPE *)PyBobLearnLibsvm_API[PyBobLearnLibsvmFile_Type_NUM]) -# define PyBobLearnLibsvmFile_Check (*(PyBobLearnLibsvmFile_Check_RET (*)PyBobLearnLibsvmFile_Check_PROTO) PyXbobLearnLibsvm_API[PyBobLearnLibsvmFile_Check_NUM]) +# define PyBobLearnLibsvmFile_Check (*(PyBobLearnLibsvmFile_Check_RET (*)PyBobLearnLibsvmFile_Check_PROTO) PyBobLearnLibsvm_API[PyBobLearnLibsvmFile_Check_NUM]) /****************************************** - * Bindings for xbob.learn.libsvm.Machine * + * Bindings for bob.learn.libsvm.Machine * ******************************************/ -# define PyBobLearnLibsvmMachine_Type (*(PyBobLearnLibsvmMachine_Type_TYPE *)PyXbobLearnLibsvm_API[PyBobLearnLibsvmMachine_Type_NUM]) +# define PyBobLearnLibsvmMachine_Type (*(PyBobLearnLibsvmMachine_Type_TYPE *)PyBobLearnLibsvm_API[PyBobLearnLibsvmMachine_Type_NUM]) -# define PyBobLearnLibsvmMachine_Check (*(PyBobLearnLibsvmMachine_Check_RET (*)PyBobLearnLibsvmMachine_Check_PROTO) PyXbobLearnLibsvm_API[PyBobLearnLibsvmMachine_Check_NUM]) +# define PyBobLearnLibsvmMachine_Check (*(PyBobLearnLibsvmMachine_Check_RET (*)PyBobLearnLibsvmMachine_Check_PROTO) PyBobLearnLibsvm_API[PyBobLearnLibsvmMachine_Check_NUM]) -# define PyBobLearnLibsvmMachine_NewFromMachine (*(PyBobLearnLibsvmMachine_NewFromMachine_RET (*)PyBobLearnLibsvmMachine_NewFromMachine_PROTO) PyXbobLearnLibsvm_API[PyBobLearnLibsvmMachine_NewFromMachine_NUM]) +# define PyBobLearnLibsvmMachine_NewFromMachine (*(PyBobLearnLibsvmMachine_NewFromMachine_RET (*)PyBobLearnLibsvmMachine_NewFromMachine_PROTO) PyBobLearnLibsvm_API[PyBobLearnLibsvmMachine_NewFromMachine_NUM]) /****************************************** - * Bindings for xbob.learn.libsvm.Trainer * + * Bindings for bob.learn.libsvm.Trainer * ******************************************/ -# define PyBobLearnLibsvmTrainer_Type (*(PyBobLearnLibsvmTrainer_Type_TYPE *)PyXbobLearnLibsvm_API[PyBobLearnLibsvmTrainer_Type_NUM]) +# define PyBobLearnLibsvmTrainer_Type (*(PyBobLearnLibsvmTrainer_Type_TYPE *)PyBobLearnLibsvm_API[PyBobLearnLibsvmTrainer_Type_NUM]) -# define PyBobLearnLibsvmTrainer_Check (*(PyBobLearnLibsvmTrainer_Check_RET (*)PyBobLearnLibsvmTrainer_Check_PROTO) PyXbobLearnLibsvm_API[PyBobLearnLibsvmTrainer_Check_NUM]) +# define PyBobLearnLibsvmTrainer_Check (*(PyBobLearnLibsvmTrainer_Check_RET (*)PyBobLearnLibsvmTrainer_Check_PROTO) PyBobLearnLibsvm_API[PyBobLearnLibsvmTrainer_Check_NUM]) /********************************* * Bindings to general utilities * *********************************/ -# define PyBobLearnLibsvm_MachineTypeAsString (*(PyBobLearnLibsvm_MachineTypeAsString_RET (*)PyBobLearnLibsvm_MachineTypeAsString_PROTO) PyXbobLearnLibsvm_API[PyBobLearnLibsvm_MachineTypeAsString_NUM]) +# define PyBobLearnLibsvm_MachineTypeAsString (*(PyBobLearnLibsvm_MachineTypeAsString_RET (*)PyBobLearnLibsvm_MachineTypeAsString_PROTO) PyBobLearnLibsvm_API[PyBobLearnLibsvm_MachineTypeAsString_NUM]) -# define PyBobLearnLibsvm_StringAsMachineType (*(PyBobLearnLibsvm_StringAsMachineType_RET (*)PyBobLearnLibsvm_StringAsMachineType_PROTO) PyXbobLearnLibsvm_API[PyBobLearnLibsvm_StringAsMachineType_NUM]) +# define PyBobLearnLibsvm_StringAsMachineType (*(PyBobLearnLibsvm_StringAsMachineType_RET (*)PyBobLearnLibsvm_StringAsMachineType_PROTO) PyBobLearnLibsvm_API[PyBobLearnLibsvm_StringAsMachineType_NUM]) -# define PyBobLearnLibsvm_CStringAsMachineType (*(PyBobLearnLibsvm_CStringAsMachineType_RET (*)PyBobLearnLibsvm_CStringAsMachineType_PROTO) PyXbobLearnLibsvm_API[PyBobLearnLibsvm_CStringAsMachineType_NUM]) +# define PyBobLearnLibsvm_CStringAsMachineType (*(PyBobLearnLibsvm_CStringAsMachineType_RET (*)PyBobLearnLibsvm_CStringAsMachineType_PROTO) PyBobLearnLibsvm_API[PyBobLearnLibsvm_CStringAsMachineType_NUM]) -# define PyBobLearnLibsvm_KernelTypeAsString (*(PyBobLearnLibsvm_KernelTypeAsString_RET (*)PyBobLearnLibsvm_KernelTypeAsString_PROTO) PyXbobLearnLibsvm_API[PyBobLearnLibsvm_KernelTypeAsString_NUM]) +# define PyBobLearnLibsvm_KernelTypeAsString (*(PyBobLearnLibsvm_KernelTypeAsString_RET (*)PyBobLearnLibsvm_KernelTypeAsString_PROTO) PyBobLearnLibsvm_API[PyBobLearnLibsvm_KernelTypeAsString_NUM]) -# define PyBobLearnLibsvm_StringAsKernelType (*(PyBobLearnLibsvm_StringAsKernelType_RET (*)PyBobLearnLibsvm_StringAsKernelType_PROTO) PyXbobLearnLibsvm_API[PyBobLearnLibsvm_StringAsKernelType_NUM]) +# define PyBobLearnLibsvm_StringAsKernelType (*(PyBobLearnLibsvm_StringAsKernelType_RET (*)PyBobLearnLibsvm_StringAsKernelType_PROTO) PyBobLearnLibsvm_API[PyBobLearnLibsvm_StringAsKernelType_NUM]) -# define PyBobLearnLibsvm_CStringAsKernelType (*(PyBobLearnLibsvm_CStringAsKernelType_RET (*)PyBobLearnLibsvm_CStringAsKernelType_PROTO) PyXbobLearnLibsvm_API[PyBobLearnLibsvm_CStringAsKernelType_NUM]) +# define PyBobLearnLibsvm_CStringAsKernelType (*(PyBobLearnLibsvm_CStringAsKernelType_RET (*)PyBobLearnLibsvm_CStringAsKernelType_PROTO) PyBobLearnLibsvm_API[PyBobLearnLibsvm_CStringAsKernelType_NUM]) # if !defined(NO_IMPORT_ARRAY) @@ -251,12 +251,12 @@ typedef struct { * Returns -1 on error, 0 on success. PyCapsule_Import will set an exception * if there's an error. */ - static int import_xbob_learn_libsvm(void) { + static int import_bob_learn_libsvm(void) { PyObject *c_api_object; PyObject *module; - module = PyImport_ImportModule(BOOST_PP_STRINGIZE(XBOB_LEARN_LIBSVM_MODULE_PREFIX) "." BOOST_PP_STRINGIZE(XBOB_LEARN_LIBSVM_MODULE_NAME)); + module = PyImport_ImportModule(BOOST_PP_STRINGIZE(BOB_LEARN_LIBSVM_MODULE_PREFIX) "." BOOST_PP_STRINGIZE(BOB_LEARN_LIBSVM_MODULE_NAME)); if (module == NULL) return -1; @@ -269,35 +269,35 @@ typedef struct { # if PY_VERSION_HEX >= 0x02070000 if (PyCapsule_CheckExact(c_api_object)) { - PyXbobLearnLibsvm_API = (void **)PyCapsule_GetPointer(c_api_object, + PyBobLearnLibsvm_API = (void **)PyCapsule_GetPointer(c_api_object, PyCapsule_GetName(c_api_object)); } # else if (PyCObject_Check(c_api_object)) { - XbobLearnLibsvm_API = (void **)PyCObject_AsVoidPtr(c_api_object); + BobLearnLibsvm_API = (void **)PyCObject_AsVoidPtr(c_api_object); } # endif Py_DECREF(c_api_object); Py_DECREF(module); - if (!XbobLearnLibsvm_API) { + if (!BobLearnLibsvm_API) { PyErr_Format(PyExc_ImportError, # if PY_VERSION_HEX >= 0x02070000 "cannot find C/C++ API capsule at `%s.%s._C_API'", # else "cannot find C/C++ API cobject at `%s.%s._C_API'", # endif - BOOST_PP_STRINGIZE(XBOB_LEARN_LIBSVM_MODULE_PREFIX), - BOOST_PP_STRINGIZE(XBOB_LEARN_LIBSVM_MODULE_NAME)); + BOOST_PP_STRINGIZE(BOB_LEARN_LIBSVM_MODULE_PREFIX), + BOOST_PP_STRINGIZE(BOB_LEARN_LIBSVM_MODULE_NAME)); return -1; } /* Checks that the imported version matches the compiled version */ - int imported_version = *(int*)PyXbobLearnLibsvm_API[PyXbobLearnLibsvm_APIVersion_NUM]; + int imported_version = *(int*)PyBobLearnLibsvm_API[PyBobLearnLibsvm_APIVersion_NUM]; - if (XBOB_LEARN_LIBSVM_API_VERSION != imported_version) { - PyErr_Format(PyExc_ImportError, "%s.%s 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", BOOST_PP_STRINGIZE(XBOB_LEARN_LIBSVM_MODULE_PREFIX), BOOST_PP_STRINGIZE(XBOB_LEARN_LIBSVM_MODULE_NAME), XBOB_LEARN_LIBSVM_API_VERSION, imported_version); + if (BOB_LEARN_LIBSVM_API_VERSION != imported_version) { + PyErr_Format(PyExc_ImportError, "%s.%s 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", BOOST_PP_STRINGIZE(BOB_LEARN_LIBSVM_MODULE_PREFIX), BOOST_PP_STRINGIZE(BOB_LEARN_LIBSVM_MODULE_NAME), BOB_LEARN_LIBSVM_API_VERSION, imported_version); return -1; } @@ -308,6 +308,6 @@ typedef struct { # endif //!defined(NO_IMPORT_ARRAY) -#endif /* XBOB_LEARN_LIBSVM_MODULE */ +#endif /* BOB_LEARN_LIBSVM_MODULE */ -#endif /* XBOB_LEARN_LIBSVM_H */ +#endif /* BOB_LEARN_LIBSVM_H */ diff --git a/bob/learn/libsvm/include/bob.learn.libsvm/config.h b/bob/learn/libsvm/include/bob.learn.libsvm/config.h new file mode 100644 index 0000000000000000000000000000000000000000..d154da20a95f1cb6a386dcb8e692ee26c0e70bf9 --- /dev/null +++ b/bob/learn/libsvm/include/bob.learn.libsvm/config.h @@ -0,0 +1,14 @@ +/** + * @author Andre Anjos + * @date Tue 25 Mar 2014 12:57:21 CET + * + * @brief General directives for all modules in bob.learn.libsvm + */ + +#ifndef BOB_LEARN_LIBSVM_CONFIG_H +#define BOB_LEARN_LIBSVM_CONFIG_H + +/* Macros that define versions and important names */ +#define BOB_LEARN_LIBSVM_API_VERSION 0x0200 + +#endif /* BOB_LEARN_LIBSVM_CONFIG_H */ diff --git a/xbob/learn/libsvm/include/xbob.learn.libsvm/file.h b/bob/learn/libsvm/include/bob.learn.libsvm/file.h similarity index 100% rename from xbob/learn/libsvm/include/xbob.learn.libsvm/file.h rename to bob/learn/libsvm/include/bob.learn.libsvm/file.h diff --git a/xbob/learn/libsvm/include/xbob.learn.libsvm/machine.h b/bob/learn/libsvm/include/bob.learn.libsvm/machine.h similarity index 100% rename from xbob/learn/libsvm/include/xbob.learn.libsvm/machine.h rename to bob/learn/libsvm/include/bob.learn.libsvm/machine.h diff --git a/xbob/learn/libsvm/include/xbob.learn.libsvm/trainer.h b/bob/learn/libsvm/include/bob.learn.libsvm/trainer.h similarity index 100% rename from xbob/learn/libsvm/include/xbob.learn.libsvm/trainer.h rename to bob/learn/libsvm/include/bob.learn.libsvm/trainer.h diff --git a/xbob/learn/libsvm/machine.cpp b/bob/learn/libsvm/machine.cpp similarity index 99% rename from xbob/learn/libsvm/machine.cpp rename to bob/learn/libsvm/machine.cpp index 747e782a57dc235adf3da3c16fccb9dd259dfe5e..108ad95061fd288faaded03a27806cc898ae80e1 100644 --- a/xbob/learn/libsvm/machine.cpp +++ b/bob/learn/libsvm/machine.cpp @@ -7,7 +7,7 @@ * Copyright (C) 2011-2013 Idiap Research Institute, Martigny, Switzerland */ -#include +#include #include #include diff --git a/bob/learn/libsvm/main.cpp b/bob/learn/libsvm/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d5e7eb111f9910fb1b3c13de4bb9cc3d8a323abe --- /dev/null +++ b/bob/learn/libsvm/main.cpp @@ -0,0 +1,160 @@ +/** + * @author Andre Anjos + * @date Fri 13 Dec 2013 12:35:59 CET + * + * @brief Bindings to bob::machine + */ + +#define BOB_LEARN_LIBSVM_MODULE +#include + +#ifdef NO_IMPORT_ARRAY +#undef NO_IMPORT_ARRAY +#endif +#include +#include +#include + +static PyMethodDef module_methods[] = { + {0} /* Sentinel */ +}; + +PyDoc_STRVAR(module_docstr, "bob::learn::libsvm's machine and trainers"); + +int PyBobLearnLibsvm_APIVersion = BOB_LEARN_LIBSVM_API_VERSION; + +#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 + +static PyObject* create_module (void) { + + PyBobLearnLibsvmFile_Type.tp_new = PyType_GenericNew; + if (PyType_Ready(&PyBobLearnLibsvmFile_Type) < 0) return 0; + + PyBobLearnLibsvmMachine_Type.tp_new = PyType_GenericNew; + if (PyType_Ready(&PyBobLearnLibsvmMachine_Type) < 0) return 0; + + PyBobLearnLibsvmTrainer_Type.tp_new = PyType_GenericNew; + if (PyType_Ready(&PyBobLearnLibsvmTrainer_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_LEARN_LIBSVM_API_VERSION) < 0) return 0; + if (PyModule_AddStringConstant(m, "__version__", BOB_EXT_MODULE_VERSION) < 0) return 0; + + /* register the types to python */ + Py_INCREF(&PyBobLearnLibsvmFile_Type); + if (PyModule_AddObject(m, "File", (PyObject *)&PyBobLearnLibsvmFile_Type) < 0) return 0; + + Py_INCREF(&PyBobLearnLibsvmMachine_Type); + if (PyModule_AddObject(m, "Machine", (PyObject *)&PyBobLearnLibsvmMachine_Type) < 0) return 0; + + Py_INCREF(&PyBobLearnLibsvmTrainer_Type); + if (PyModule_AddObject(m, "Trainer", (PyObject *)&PyBobLearnLibsvmTrainer_Type) < 0) return 0; + + static void* PyBobLearnLibsvm_API[PyBobLearnLibsvm_API_pointers]; + + /* exhaustive list of C APIs */ + + /************** + * Versioning * + **************/ + + PyBobLearnLibsvm_API[PyBobLearnLibsvm_APIVersion_NUM] = (void *)&PyBobLearnLibsvm_APIVersion; + + /*************************************** + * Bindings for bob.learn.libsvm.File * + ***************************************/ + + PyBobLearnLibsvm_API[PyBobLearnLibsvmFile_Type_NUM] = (void *)&PyBobLearnLibsvmFile_Type; + + PyBobLearnLibsvm_API[PyBobLearnLibsvmFile_Check_NUM] = (void *)&PyBobLearnLibsvmFile_Check; + + /****************************************** + * Bindings for bob.learn.libsvm.Machine * + ******************************************/ + + PyBobLearnLibsvm_API[PyBobLearnLibsvmMachine_Type_NUM] = (void *)&PyBobLearnLibsvmMachine_Type; + + PyBobLearnLibsvm_API[PyBobLearnLibsvmMachine_Check_NUM] = (void *)&PyBobLearnLibsvmMachine_Check; + + PyBobLearnLibsvm_API[PyBobLearnLibsvmMachine_NewFromMachine_NUM] = (void *)&PyBobLearnLibsvmMachine_NewFromMachine; + + /****************************************** + * Bindings for bob.learn.libsvm.Trainer * + ******************************************/ + + PyBobLearnLibsvm_API[PyBobLearnLibsvmTrainer_Type_NUM] = (void *)&PyBobLearnLibsvmTrainer_Type; + + PyBobLearnLibsvm_API[PyBobLearnLibsvmTrainer_Check_NUM] = (void *)&PyBobLearnLibsvmTrainer_Check; + + /********************************* + * Bindings to general utilities * + *********************************/ + + PyBobLearnLibsvm_API[PyBobLearnLibsvm_MachineTypeAsString_NUM] = (void *)&PyBobLearnLibsvm_MachineTypeAsString; + + PyBobLearnLibsvm_API[PyBobLearnLibsvm_StringAsMachineType_NUM] = (void *)&PyBobLearnLibsvm_StringAsMachineType; + + PyBobLearnLibsvm_API[PyBobLearnLibsvm_CStringAsMachineType_NUM] = (void *)&PyBobLearnLibsvm_CStringAsMachineType; + + PyBobLearnLibsvm_API[PyBobLearnLibsvm_KernelTypeAsString_NUM] = (void *)&PyBobLearnLibsvm_KernelTypeAsString; + + PyBobLearnLibsvm_API[PyBobLearnLibsvm_StringAsKernelType_NUM] = (void *)&PyBobLearnLibsvm_StringAsKernelType; + + PyBobLearnLibsvm_API[PyBobLearnLibsvm_CStringAsKernelType_NUM] = (void *)&PyBobLearnLibsvm_CStringAsKernelType; + +#if PY_VERSION_HEX >= 0x02070000 + + /* defines the PyCapsule */ + + PyObject* c_api_object = PyCapsule_New((void *)PyBobLearnLibsvm_API, + BOB_EXT_MODULE_PREFIX "." BOB_EXT_MODULE_NAME "._C_API", 0); + +#else + + PyObject* c_api_object = PyCObject_FromVoidPtr((void *)PyBobLearnLibsvm_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; + } + + if (import_bob_io_base() < 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/learn/libsvm/pyfile.cpp b/bob/learn/libsvm/pyfile.cpp similarity index 98% rename from xbob/learn/libsvm/pyfile.cpp rename to bob/learn/libsvm/pyfile.cpp index ccfe712414f9da40636a4568125f59924d519265..5a36db85fd71b2c94fe8fbdcd0b07491b607feb8 100644 --- a/xbob/learn/libsvm/pyfile.cpp +++ b/bob/learn/libsvm/pyfile.cpp @@ -7,18 +7,18 @@ * Copyright (C) 2011-2013 Idiap Research Institute, Martigny, Switzerland */ -#define XBOB_LEARN_LIBSVM_MODULE -#include -#include -#include -#include +#define BOB_LEARN_LIBSVM_MODULE +#include +#include +#include +#include #include /*********************************************** * Implementation of Support Vector File class * ***********************************************/ -PyDoc_STRVAR(s_file_str, XBOB_EXT_MODULE_PREFIX ".File"); +PyDoc_STRVAR(s_file_str, BOB_EXT_MODULE_PREFIX ".File"); PyDoc_STRVAR(s_file_doc, "File(path)\n\ @@ -159,7 +159,7 @@ PyObject* PyBobLearnLibsvmFile_Repr(PyBobLearnLibsvmFileObject* self) { /** * Expected output: * - * xbob.learn.libsvm.File('filename') + * bob.learn.libsvm.File('filename') */ PyObject* retval = PyUnicode_FromFormat("%s('%s')", @@ -181,7 +181,7 @@ PyObject* PyBobLearnLibsvmFile_Str(PyBobLearnLibsvmFileObject* self) { /** * Expected output: * - * xbob.learn.libsvm.File('filename') + * bob.learn.libsvm.File('filename') */ PyObject* retval = PyUnicode_FromFormat("%s('%s') ", diff --git a/xbob/learn/libsvm/pymachine.cpp b/bob/learn/libsvm/pymachine.cpp similarity index 98% rename from xbob/learn/libsvm/pymachine.cpp rename to bob/learn/libsvm/pymachine.cpp index e8920e90f6c0cca79b8e5911266eca97ff1653d3..5994cb0a112cbdc8faaf720e9d5ac0b74bbeabd6 100644 --- a/xbob/learn/libsvm/pymachine.cpp +++ b/bob/learn/libsvm/pymachine.cpp @@ -7,18 +7,18 @@ * Copyright (C) 2011-2014 Idiap Research Institute, Martigny, Switzerland */ -#define XBOB_LEARN_LIBSVM_MODULE -#include -#include -#include -#include +#define BOB_LEARN_LIBSVM_MODULE +#include +#include +#include +#include #include /******************************************************* * Implementation of Support Vector Machine base class * *******************************************************/ -PyDoc_STRVAR(s_svm_str, XBOB_EXT_MODULE_PREFIX ".Machine"); +PyDoc_STRVAR(s_svm_str, BOB_EXT_MODULE_PREFIX ".Machine"); PyDoc_STRVAR(s_svm_doc, "Machine(path)\n\ @@ -59,7 +59,7 @@ state recovery from previous sessions.\n\ "); /*********************************************** - * Implementation of xbob.learn.libsvm.Machine * + * Implementation of bob.learn.libsvm.Machine * ***********************************************/ static int PyBobLearnLibsvmMachine_init_svmfile @@ -416,7 +416,7 @@ PyObject* PyBobLearnLibsvmMachine_Repr(PyBobLearnLibsvmMachineObject* self) { /** * Expected output: * - * + * */ auto shape = make_safe(PyObject_GetAttrString((PyObject*)self, "shape")); @@ -441,7 +441,7 @@ PyObject* PyBobLearnLibsvmMachine_Str(PyBobLearnLibsvmMachineObject* self) { /** * Expected output: * - * xbob.learn.libsvm.Machine (float64) 3 inputs, 2 outputs + * bob.learn.libsvm.Machine (float64) 3 inputs, 2 outputs * properties... * * TODO: Not fully implemented yet @@ -932,8 +932,8 @@ PyDoc_STRVAR(s_save_doc, o.save(hdf5file) -> None\n\ \n\ Saves itself at a LIBSVM model file or into a\n\ -:py:class:`xbob.io.HDF5File`. Saving the SVM into an\n\ -:py:class:`xbob.io.HDF5File` object, has the advantage of saving\n\ +:py:class:`bob.io.HDF5File`. Saving the SVM into an\n\ +:py:class:`bob.io.HDF5File` object, has the advantage of saving\n\ input normalization options together with the machine, which are\n\ automatically reloaded when you re-initialize it from the same\n\ :py:class:`HDF5File`.\n\ diff --git a/xbob/learn/libsvm/pytrainer.cpp b/bob/learn/libsvm/pytrainer.cpp similarity index 98% rename from xbob/learn/libsvm/pytrainer.cpp rename to bob/learn/libsvm/pytrainer.cpp index 52a88f503df43d2afd2ab62294897aed3eb76902..cf17067a7b94b4db88737b11eadceff031fd1a7f 100644 --- a/xbob/learn/libsvm/pytrainer.cpp +++ b/bob/learn/libsvm/pytrainer.cpp @@ -7,18 +7,18 @@ * Copyright (C) 2011-2014 Idiap Research Institute, Martigny, Switzerland */ -#define XBOB_LEARN_LIBSVM_MODULE -#include -#include -#include -#include +#define BOB_LEARN_LIBSVM_MODULE +#include +#include +#include +#include #include /******************************************************* * Implementation of Support Vector Trainer base class * *******************************************************/ -PyDoc_STRVAR(s_svm_str, XBOB_EXT_MODULE_PREFIX ".Trainer"); +PyDoc_STRVAR(s_svm_str, BOB_EXT_MODULE_PREFIX ".Trainer"); PyDoc_STRVAR(s_svm_doc, "Trainer([machine_type='C_SVC', [kernel_type='RBF', [cache_size=100, [stop_epsilon=1e-3, [shrinking=True, [probability=False]]]]]]) -> new Trainer\n\ @@ -81,7 +81,7 @@ probability, bool\n\ "); /*********************************************** - * Implementation of xbob.learn.libsvm.Trainer * + * Implementation of bob.learn.libsvm.Trainer * ***********************************************/ static int PyBobLearnLibsvmTrainer_init @@ -508,7 +508,7 @@ PyObject* PyBobLearnLibsvmTrainer_Repr(PyBobLearnLibsvmTrainerObject* self) { /** * Expected output: * - * + * * * @TODO: Improve this output */ @@ -531,7 +531,7 @@ PyObject* PyBobLearnLibsvmTrainer_Str(PyBobLearnLibsvmTrainerObject* self) { /** * Expected output: * - * xbob.learn.libsvm.Trainer + * bob.learn.libsvm.Trainer * * TODO: Not fully implemented yet */ diff --git a/xbob/learn/libsvm/pyutils.cpp b/bob/learn/libsvm/pyutils.cpp similarity index 97% rename from xbob/learn/libsvm/pyutils.cpp rename to bob/learn/libsvm/pyutils.cpp index a0502b4e9f17ee63e0583d752a4c66ffeededdcd..7ac26ecebbe12126bef7f26507845aee50d65c5f 100644 --- a/xbob/learn/libsvm/pyutils.cpp +++ b/bob/learn/libsvm/pyutils.cpp @@ -7,9 +7,9 @@ * Copyright (C) 2011-2014 Idiap Research Institute, Martigny, Switzerland */ -#define XBOB_LEARN_LIBSVM_MODULE -#include -#include +#define BOB_LEARN_LIBSVM_MODULE +#include +#include PyObject* PyBobLearnLibsvm_MachineTypeAsString(bob::learn::libsvm::machine_t s) { switch(s) { diff --git a/xbob/learn/libsvm/test_machine.py b/bob/learn/libsvm/test_machine.py similarity index 98% rename from xbob/learn/libsvm/test_machine.py rename to bob/learn/libsvm/test_machine.py index a49e26936e2245d58e345748ebaa77609506b640..818535b90e68ff2743678475e2665de97f67f907 100644 --- a/xbob/learn/libsvm/test_machine.py +++ b/bob/learn/libsvm/test_machine.py @@ -13,7 +13,7 @@ import numpy import tempfile import pkg_resources import nose.tools -import xbob.io.base +import bob.io.base from . import File, Machine @@ -102,11 +102,11 @@ def test_can_save_hdf5(): machine = Machine(HEART_MACHINE) tmp = tempname('.hdf5') - machine.save(xbob.io.base.HDF5File(tmp, 'w')) + machine.save(bob.io.base.HDF5File(tmp, 'w')) del machine # make sure that the save machine is the same as before - machine = Machine(xbob.io.base.HDF5File(tmp)) + machine = Machine(bob.io.base.HDF5File(tmp)) nose.tools.eq_(machine.shape, (13,1)) nose.tools.eq_(machine.kernel_type, 'RBF') nose.tools.eq_(machine.machine_type, 'C_SVC') diff --git a/xbob/learn/libsvm/test_trainer.py b/bob/learn/libsvm/test_trainer.py similarity index 100% rename from xbob/learn/libsvm/test_trainer.py rename to bob/learn/libsvm/test_trainer.py diff --git a/xbob/learn/libsvm/trainer.cpp b/bob/learn/libsvm/trainer.cpp similarity index 99% rename from xbob/learn/libsvm/trainer.cpp rename to bob/learn/libsvm/trainer.cpp index f870395e32f11137e8ba77eaf83016fbe623f649..5021614e0b6c541e57519a59a244e4a271697a44 100644 --- a/xbob/learn/libsvm/trainer.cpp +++ b/bob/learn/libsvm/trainer.cpp @@ -7,7 +7,7 @@ * Copyright (C) 2011-2014 Idiap Research Institute, Martigny, Switzerland */ -#include +#include #include #include #include diff --git a/xbob/learn/libsvm/version.cpp b/bob/learn/libsvm/version.cpp similarity index 80% rename from xbob/learn/libsvm/version.cpp rename to bob/learn/libsvm/version.cpp index b8a73aaf58f3f88ae641a1d91d89de589f21b4d6..11bfde6c904316d56d1bd045012d439e2f6cc4af 100644 --- a/xbob/learn/libsvm/version.cpp +++ b/bob/learn/libsvm/version.cpp @@ -20,10 +20,10 @@ #ifdef NO_IMPORT_ARRAY #undef NO_IMPORT_ARRAY #endif -#include -#include -#include -#include +#include +#include +#include +#include static int dict_set(PyObject* d, const char* key, const char* value) { PyObject* v = Py_BuildValue("s", value); @@ -109,17 +109,17 @@ 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)); } /** - * xbob.io.base c/c++ api version + * bob.io.base c/c++ api version */ -static PyObject* xbob_io_base_version() { - return Py_BuildValue("{ss}", "api", BOOST_PP_STRINGIZE(XBOB_IO_BASE_API_VERSION)); +static PyObject* bob_io_base_version() { + return Py_BuildValue("{ss}", "api", BOOST_PP_STRINGIZE(BOB_IO_BASE_API_VERSION)); } static PyObject* build_version_dictionary() { @@ -134,8 +134,8 @@ 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, "xbob.io.base", xbob_io_base_version())) return 0; + if (!dict_steal(retval, "bob.blitz", bob_blitz_version())) return 0; + if (!dict_steal(retval, "bob.io.base", bob_io_base_version())) return 0; if (!dict_steal(retval, "Bob", bob_version())) return 0; Py_INCREF(retval); @@ -153,7 +153,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, @@ -166,15 +166,15 @@ 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_AddIntConstant(m, "api", XBOB_LEARN_LIBSVM_API_VERSION) < 0) + if (PyModule_AddIntConstant(m, "api", BOB_LEARN_LIBSVM_API_VERSION) < 0) return 0; - if (PyModule_AddStringConstant(m, "module", XBOB_EXT_MODULE_VERSION) < 0) + if (PyModule_AddStringConstant(m, "module", BOB_EXT_MODULE_VERSION) < 0) return 0; PyObject* externals = build_version_dictionary(); @@ -182,9 +182,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; } @@ -193,7 +193,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 0be471e48c4997dfce81286332ff5519ef3521cf..11c53a4f21cbf27fb180af88038a1603277d77a1 100644 --- a/buildout.cfg +++ b/buildout.cfg @@ -4,25 +4,25 @@ [buildout] parts = scripts -eggs = xbob.learn.libsvm -extensions = xbob.buildout +eggs = bob.learn.libsvm +extensions = bob.buildout mr.developer auto-checkout = * -develop = src/xbob.extension - src/xbob.blitz - src/xbob.io.base +develop = src/bob.extension + src/bob.blitz + src/bob.io.base . -; options for xbob.buildout extension +; options for bob.buildout extension debug = true verbose = true prefixes = /idiap/group/torch5spro/releases/preview/install/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 -xbob.io.base = git https://github.com/bioidiap/xbob.io.base +bob.extension = git https://github.com/bioidiap/bob.extension +bob.blitz = git https://github.com/bioidiap/bob.blitz +bob.io.base = git https://github.com/bioidiap/bob.io.base [scripts] -recipe = xbob.buildout:scripts +recipe = bob.buildout:scripts diff --git a/doc/c_cpp_api.rst b/doc/c_cpp_api.rst index a7e707c44104a753db0cf3c993dc3b828b9f5690..3c618b36ccbf16bb0ce16fe1794bdc7cd2e0548f 100644 --- a/doc/c_cpp_api.rst +++ b/doc/c_cpp_api.rst @@ -6,11 +6,11 @@ C++ API ========= -The C++ API of ``xbob.learn.libsvm`` allows users to leverage from automatic -converters for classes in :py:class:`xbob.learn.libsvm`. To use the C API, -clients should first, include the header file ```` on +The C++ API of ``bob.learn.libsvm`` allows users to leverage from automatic +converters for classes in :py:class:`bob.learn.libsvm`. To use the C API, +clients should first, include the header file ```` on their compilation units and then, make sure to call once -``import_xbob_learn_libsvm()`` at their module instantiation, as explained at +``import_bob_learn_libsvm()`` at their module instantiation, as explained at the `Python manual `_. @@ -19,9 +19,9 @@ the import function: .. code-block:: c++ - #include - #include - #include + #include + #include + #include PyMODINIT_FUNC initclient(void) { @@ -29,9 +29,9 @@ the import function: if (!m) return 0; - if (import_xbob_blitz() < 0) return 0; - if (import_xbob_io() < 0) return 0; - if (import_xbob_learn_libsvm() < 0) return 0; + if (import_bob_blitz() < 0) return 0; + if (import_bob_io() < 0) return 0; + if (import_bob_learn_libsvm() < 0) return 0; return m; @@ -40,7 +40,7 @@ the import function: .. note:: The include directory can be discovered using - :py:func:`xbob.learn.libsvm.get_include`. + :py:func:`bob.learn.libsvm.get_include`. File Interface -------------- diff --git a/doc/conf.py b/doc/conf.py index 29dcc2eea29c7d000b5c821def7846b773abe2b9..fe8dfe5b226ef202579cd7d487fb8e81dfcc0884 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.learn.libsvm' +project = u'bob.learn.libsvm' import time copyright = u'%s, Idiap Research Institute' % time.strftime('%Y') # Grab the setup entry -distribution = pkg_resources.require('xbob.learn.libsvm')[0] +distribution = pkg_resources.require('bob.learn.libsvm')[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_learn_libsvm' +#html_short_title = 'bob_learn_libsvm' # 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_learn_libsvm_doc' +htmlhelp_basename = 'bob_learn_libsvm_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_learn_libsvm.tex', u'Bob-LIBSVM Python Bindings', + ('index', 'bob_learn_libsvm.tex', u'Bob-LIBSVM Python Bindings', 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_learn_libsvm', u'Bob-LIBSVM Python Bindings', + ('index', 'bob_learn_libsvm', u'Bob-LIBSVM Python Bindings', [u'Idiap Research Institute'], 1) ] diff --git a/doc/doxygen.rc b/doc/doxygen.rc index cd8855c06bee19b684be53e3b8244fd3eb570067..bec65b53fd75342bc08f9971f84719be340f44d1 100644 --- a/doc/doxygen.rc +++ b/doc/doxygen.rc @@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = "xbob.learn.libsvm Pure C/C++ API" +PROJECT_NAME = "bob.learn.libsvm Pure C/C++ API" # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version @@ -1907,7 +1907,7 @@ SEARCH_INCLUDES = YES # preprocessor. # This tag requires that the tag SEARCH_INCLUDES is set to YES. -INCLUDE_PATH = xbob/learn/libsvm/include/xbob.learn.libsvm +INCLUDE_PATH = bob/learn/libsvm/include/bob.learn.libsvm # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the diff --git a/doc/guide.rst b/doc/guide.rst index 8f6c9e8d6b2aba75f7479a8f0e68ef9529e3986d..99c439468b5a848262244519e6fe2767facead32 100644 --- a/doc/guide.rst +++ b/doc/guide.rst @@ -8,19 +8,19 @@ import os import numpy - import xbob.learn.libsvm + import bob.learn.libsvm def F(m, f): from pkg_resources import resource_filename return resource_filename(m, os.path.join('data', f)) - heart_model = F('xbob.learn.libsvm', 'heart.svmmodel') + heart_model = F('bob.learn.libsvm', 'heart.svmmodel') - svm = xbob.learn.libsvm.Machine(heart_model) + svm = bob.learn.libsvm.Machine(heart_model) - heart_data = F('xbob.learn.libsvm', 'heart.svmdata') + heart_data = F('bob.learn.libsvm', 'heart.svmdata') - f = xbob.learn.libsvm.File(heart_data) + f = bob.learn.libsvm.File(heart_data) ====================================== Support Vector Machines and Trainers @@ -30,7 +30,7 @@ A **Support vector machine** (SVM) [1]_ is a very popular `supervised` learning technique. |project| provides a bridge to `LIBSVM`_ which allows you to `train` such a `machine` and use it for classification. This section contains a tutorial on how to use |project|'s Pythonic bindings to LIBSVM. It starts by -introducing the support vector :py:class:`xbob.learn.libsvm.Machine` followed +introducing the support vector :py:class:`bob.learn.libsvm.Machine` followed by the trainer usage. Machines @@ -53,9 +53,9 @@ remaining examples here. features to be discriminated). The number of features is 13. Our extensions to `LIBSVM`_ also allows you to feed data through a -:py:class:`xbob.learn.libsvm.Machine` using :py:class:`numpy.ndarray` objects +:py:class:`bob.learn.libsvm.Machine` using :py:class:`numpy.ndarray` objects and collect results in that format. For the following lines, we assume you have -available a :py:class:`xbob.learn.libsvm.Machine` named ``svm``. (For this +available a :py:class:`bob.learn.libsvm.Machine` named ``svm``. (For this example, the variable ``svm`` was generated from the ``heart_scale`` dataset using the application ``svm-train`` with default parameters). The ``shape`` attribute, indicates how many features a machine from this module can input and @@ -75,14 +75,14 @@ To run a single example through the SVM, just use the ``()`` operator: >> svm(numpy.ones((10,13), 'float64')) (1, 1, 1, 1, 1, 1, 1, 1, 1, 1) -Visit the documentation for :py:class:`xbob.learn.libsvm.Machine` to find more +Visit the documentation for :py:class:`bob.learn.libsvm.Machine` to find more information about these bindings and methods you can call on such a machine. -Visit the documentation for :py:class:`xbob.learn.libsvm.File` for information +Visit the documentation for :py:class:`bob.learn.libsvm.File` for information on loading `LIBSVM`_ data files directly into python and producing :py:class:`numpy.ndarray` objects. Below is a quick example: Suppose the variable ``f`` contains an object of -type :py:class:`xbob.learn.libsvm.File`. Then, you could read data (and labels) +type :py:class:`bob.learn.libsvm.File`. Then, you could read data (and labels) from the file like this: .. doctest:: @@ -124,15 +124,15 @@ training set for a two class problem: If you want to implement that generically, please do it. Then, an SVM [1]_ can be trained easily using the -:py:class:`xbob.learn.libsvm.Trainer` class. +:py:class:`bob.learn.libsvm.Trainer` class. .. doctest:: :options: +NORMALIZE_WHITESPACE - >>> trainer = xbob.learn.libsvm.Trainer() + >>> trainer = bob.learn.libsvm.Trainer() >>> machine = trainer.train(data) #ordering only affects labels -This returns a :py:class:`xbob.learn.libsvm.Machine` which can later be used +This returns a :py:class:`bob.learn.libsvm.Machine` which can later be used for classification, as explained before. .. doctest:: @@ -145,7 +145,7 @@ for classification, as explained before. The `training` procedure allows setting several different options. For instance, the default `kernel` is an `RBF`. If we would like a `linear SVM` instead, this can be set before calling the -:py:meth:`xbob.learn.libsvm.Trainer.train` method. +:py:meth:`bob.learn.libsvm.Trainer.train` method. .. doctest:: :options: +NORMALIZE_WHITESPACE diff --git a/doc/py_api.rst b/doc/py_api.rst index 34b9c4e38842f7f8180d56151b10718375f44980..a7fa6810e3971c720b60eda9790ec55ad0a0fa25 100644 --- a/doc/py_api.rst +++ b/doc/py_api.rst @@ -7,8 +7,8 @@ ============ This section includes information for using the pure Python API of -``xbob.learn.libsvm``. +``bob.learn.libsvm``. -.. automodule:: xbob.learn.libsvm +.. automodule:: bob.learn.libsvm diff --git a/setup.py b/setup.py index 229bc35a418a45fff1bd2360b1ad5124151c2c0c..ad5dcf54c14d4c017662cdc52ed2476d23f018ad 100644 --- a/setup.py +++ b/setup.py @@ -4,17 +4,17 @@ # Mon 16 Apr 08:18:08 2012 CEST from setuptools import setup, find_packages, dist -dist.Distribution(dict(setup_requires=['xbob.extension', 'xbob.blitz', 'xbob.io.base'])) -from xbob.extension.utils import egrep, find_header, find_library -from xbob.blitz.extension import Extension -import xbob.io.base +dist.Distribution(dict(setup_requires=['bob.extension', 'bob.blitz', 'bob.io.base'])) +from bob.extension.utils import egrep, find_header, find_library +from bob.blitz.extension import Extension +import bob.io.base import os package_dir = os.path.dirname(os.path.realpath(__file__)) -package_dir = os.path.join(package_dir, 'xbob', 'learn', 'libsvm', 'include') +package_dir = os.path.join(package_dir, 'bob', 'learn', 'libsvm', 'include') include_dirs = [ package_dir, - xbob.io.base.get_include(), + bob.io.base.get_include(), ] packages = ['bob-core >= 1.2.2', 'bob-io >= 1.2.2'] @@ -42,7 +42,7 @@ class libsvm: .. doctest:: :options: +NORMALIZE_WHITESPACE +ELLIPSIS - >>> from xbob.learn.libsvm import libsvm + >>> from bob.learn.libsvm import libsvm >>> l = libsvm('>= 3.12') >>> l.include_directory '...' @@ -59,7 +59,7 @@ class libsvm: """ Searches for libsvm in stock locations. Allows user to override. - If the user sets the environment variable XBOB_PREFIX_PATH, that prefixes + If the user sets the environment variable BOB_PREFIX_PATH, that prefixes the standard path locations. Parameters: @@ -141,7 +141,7 @@ class libsvm: .. doctest:: :options: +NORMALIZE_WHITESPACE +ELLIPSIS - >>> from xbob.learn.libsvm import libsvm + >>> from bob.learn.libsvm import libsvm >>> pkg = libsvm() >>> pkg.macros() [('HAVE_LIBSVM', '1'), ('LIBSVM_VERSION', '"..."')] @@ -157,10 +157,10 @@ define_macros = pkg.macros() setup( - name='xbob.learn.libsvm', + name='bob.learn.libsvm', version=version, description='Bob bindings to libsvm', - url='http://github.com/bioidiap/xbob.learn.libsvm', + url='http://github.com/bioidiap/bob.learn.libsvm', license='BSD', author='Andre Anjos', author_email='andre.anjos@idiap.ch', @@ -172,19 +172,19 @@ setup( install_requires=[ 'setuptools', - 'xbob.blitz', - 'xbob.io.base', + 'bob.blitz', + 'bob.io.base', ], namespace_packages=[ - "xbob", - "xbob.learn", + "bob", + "bob.learn", ], ext_modules = [ - Extension("xbob.learn.libsvm.version", + Extension("bob.learn.libsvm.version", [ - "xbob/learn/libsvm/version.cpp", + "bob/learn/libsvm/version.cpp", ], packages = packages, include_dirs = include_dirs, @@ -194,16 +194,16 @@ setup( library_dirs = library_dirs, libraries = libraries, ), - Extension("xbob.learn.libsvm._library", + Extension("bob.learn.libsvm._library", [ - "xbob/learn/libsvm/file.cpp", - "xbob/learn/libsvm/machine.cpp", - "xbob/learn/libsvm/trainer.cpp", - "xbob/learn/libsvm/pyutils.cpp", - "xbob/learn/libsvm/pyfile.cpp", - "xbob/learn/libsvm/pymachine.cpp", - "xbob/learn/libsvm/pytrainer.cpp", - "xbob/learn/libsvm/main.cpp", + "bob/learn/libsvm/file.cpp", + "bob/learn/libsvm/machine.cpp", + "bob/learn/libsvm/trainer.cpp", + "bob/learn/libsvm/pyutils.cpp", + "bob/learn/libsvm/pyfile.cpp", + "bob/learn/libsvm/pymachine.cpp", + "bob/learn/libsvm/pytrainer.cpp", + "bob/learn/libsvm/main.cpp", ], packages = packages, include_dirs = include_dirs, diff --git a/xbob/learn/libsvm/include/xbob.learn.libsvm/config.h b/xbob/learn/libsvm/include/xbob.learn.libsvm/config.h deleted file mode 100644 index c71ce6a0c332678f66b22beaba93db3685e47c34..0000000000000000000000000000000000000000 --- a/xbob/learn/libsvm/include/xbob.learn.libsvm/config.h +++ /dev/null @@ -1,14 +0,0 @@ -/** - * @author Andre Anjos - * @date Tue 25 Mar 2014 12:57:21 CET - * - * @brief General directives for all modules in xbob.learn.libsvm - */ - -#ifndef XBOB_LEARN_LIBSVM_CONFIG_H -#define XBOB_LEARN_LIBSVM_CONFIG_H - -/* Macros that define versions and important names */ -#define XBOB_LEARN_LIBSVM_API_VERSION 0x0200 - -#endif /* XBOB_LEARN_LIBSVM_CONFIG_H */ diff --git a/xbob/learn/libsvm/main.cpp b/xbob/learn/libsvm/main.cpp deleted file mode 100644 index 558d382c9ce752302a2f83185ba494ff7e7bdf70..0000000000000000000000000000000000000000 --- a/xbob/learn/libsvm/main.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/** - * @author Andre Anjos - * @date Fri 13 Dec 2013 12:35:59 CET - * - * @brief Bindings to bob::machine - */ - -#define XBOB_LEARN_LIBSVM_MODULE -#include - -#ifdef NO_IMPORT_ARRAY -#undef NO_IMPORT_ARRAY -#endif -#include -#include -#include - -static PyMethodDef module_methods[] = { - {0} /* Sentinel */ -}; - -PyDoc_STRVAR(module_docstr, "bob::learn::libsvm's machine and trainers"); - -int PyXbobLearnLibsvm_APIVersion = XBOB_LEARN_LIBSVM_API_VERSION; - -#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 - -static PyObject* create_module (void) { - - PyBobLearnLibsvmFile_Type.tp_new = PyType_GenericNew; - if (PyType_Ready(&PyBobLearnLibsvmFile_Type) < 0) return 0; - - PyBobLearnLibsvmMachine_Type.tp_new = PyType_GenericNew; - if (PyType_Ready(&PyBobLearnLibsvmMachine_Type) < 0) return 0; - - PyBobLearnLibsvmTrainer_Type.tp_new = PyType_GenericNew; - if (PyType_Ready(&PyBobLearnLibsvmTrainer_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_LEARN_LIBSVM_API_VERSION) < 0) return 0; - if (PyModule_AddStringConstant(m, "__version__", XBOB_EXT_MODULE_VERSION) < 0) return 0; - - /* register the types to python */ - Py_INCREF(&PyBobLearnLibsvmFile_Type); - if (PyModule_AddObject(m, "File", (PyObject *)&PyBobLearnLibsvmFile_Type) < 0) return 0; - - Py_INCREF(&PyBobLearnLibsvmMachine_Type); - if (PyModule_AddObject(m, "Machine", (PyObject *)&PyBobLearnLibsvmMachine_Type) < 0) return 0; - - Py_INCREF(&PyBobLearnLibsvmTrainer_Type); - if (PyModule_AddObject(m, "Trainer", (PyObject *)&PyBobLearnLibsvmTrainer_Type) < 0) return 0; - - static void* PyXbobLearnLibsvm_API[PyXbobLearnLibsvm_API_pointers]; - - /* exhaustive list of C APIs */ - - /************** - * Versioning * - **************/ - - PyXbobLearnLibsvm_API[PyXbobLearnLibsvm_APIVersion_NUM] = (void *)&PyXbobLearnLibsvm_APIVersion; - - /*************************************** - * Bindings for xbob.learn.libsvm.File * - ***************************************/ - - PyXbobLearnLibsvm_API[PyBobLearnLibsvmFile_Type_NUM] = (void *)&PyBobLearnLibsvmFile_Type; - - PyXbobLearnLibsvm_API[PyBobLearnLibsvmFile_Check_NUM] = (void *)&PyBobLearnLibsvmFile_Check; - - /****************************************** - * Bindings for xbob.learn.libsvm.Machine * - ******************************************/ - - PyXbobLearnLibsvm_API[PyBobLearnLibsvmMachine_Type_NUM] = (void *)&PyBobLearnLibsvmMachine_Type; - - PyXbobLearnLibsvm_API[PyBobLearnLibsvmMachine_Check_NUM] = (void *)&PyBobLearnLibsvmMachine_Check; - - PyXbobLearnLibsvm_API[PyBobLearnLibsvmMachine_NewFromMachine_NUM] = (void *)&PyBobLearnLibsvmMachine_NewFromMachine; - - /****************************************** - * Bindings for xbob.learn.libsvm.Trainer * - ******************************************/ - - PyXbobLearnLibsvm_API[PyBobLearnLibsvmTrainer_Type_NUM] = (void *)&PyBobLearnLibsvmTrainer_Type; - - PyXbobLearnLibsvm_API[PyBobLearnLibsvmTrainer_Check_NUM] = (void *)&PyBobLearnLibsvmTrainer_Check; - - /********************************* - * Bindings to general utilities * - *********************************/ - - PyXbobLearnLibsvm_API[PyBobLearnLibsvm_MachineTypeAsString_NUM] = (void *)&PyBobLearnLibsvm_MachineTypeAsString; - - PyXbobLearnLibsvm_API[PyBobLearnLibsvm_StringAsMachineType_NUM] = (void *)&PyBobLearnLibsvm_StringAsMachineType; - - PyXbobLearnLibsvm_API[PyBobLearnLibsvm_CStringAsMachineType_NUM] = (void *)&PyBobLearnLibsvm_CStringAsMachineType; - - PyXbobLearnLibsvm_API[PyBobLearnLibsvm_KernelTypeAsString_NUM] = (void *)&PyBobLearnLibsvm_KernelTypeAsString; - - PyXbobLearnLibsvm_API[PyBobLearnLibsvm_StringAsKernelType_NUM] = (void *)&PyBobLearnLibsvm_StringAsKernelType; - - PyXbobLearnLibsvm_API[PyBobLearnLibsvm_CStringAsKernelType_NUM] = (void *)&PyBobLearnLibsvm_CStringAsKernelType; - -#if PY_VERSION_HEX >= 0x02070000 - - /* defines the PyCapsule */ - - PyObject* c_api_object = PyCapsule_New((void *)PyXbobLearnLibsvm_API, - XBOB_EXT_MODULE_PREFIX "." XBOB_EXT_MODULE_NAME "._C_API", 0); - -#else - - PyObject* c_api_object = PyCObject_FromVoidPtr((void *)PyXbobLearnLibsvm_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; - } - - if (import_xbob_io_base() < 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(); -}