Skip to content
Snippets Groups Projects
Commit 74ac2228 authored by André Anjos's avatar André Anjos :speech_balloon:
Browse files

Fix documentation tests

parent 48912199
No related branches found
No related tags found
No related merge requests found
.. vim: set fileencoding=utf-8 :
.. Andre Anjos <andre.dos.anjos@gmail.com>
.. Tue 15 Oct 14:59:05 2013
=========
C++ API
=========
The C++ API of ``xbob.learn.activation`` allows users to leverage from
automatic converters for classes in :py:class:`xbob.learn.activation`. To use
the C API, clients should first, include the header file
``<xbob.learn.activation/api.h>`` on their compilation units and then, make
sure to call once ``import_xbob_learn_activation()`` at their module
instantiation, as explained at the `Python manual
<http://docs.python.org/2/extending/extending.html#using-capsules>`_.
Here is a dummy C example showing how to include the header and where to call
the import function:
.. code-block:: c++
#include <xbob.learn.activation/api.h>
PyMODINIT_FUNC initclient(void) {
PyObject* m Py_InitModule("client", ClientMethods);
if (!m) return;
// imports dependencies
if (import_xbob_blitz() < 0) {
PyErr_Print();
PyErr_SetString(PyExc_ImportError, "cannot import module");
return 0;
}
if (import_xbob_io_base() < 0) {
PyErr_Print();
PyErr_SetString(PyExc_ImportError, "cannot import module");
return 0;
}
if (import_xbob_learn_activation() < 0) {
PyErr_Print();
PyErr_SetString(PyExc_ImportError, "cannot import module");
return 0;
}
// imports xbob.learn.activation C-API
import_xbob_learn_activation();
}
.. note::
The include directory can be discovered using
:py:func:`xbob.learn.activation.get_include`.
Activation Functors
-------------------
.. cpp:type:: PyBobLearnActivationObject
The pythonic object representation for a ``bob::machine::Activation``
object. It is the base class of all activation functors available in
|project|. In C/C++ code, we recommend you only manipulate objects like this
to keep your code agnostic to the activation type being used.
.. code-block:: cpp
typedef struct {
PyObject_HEAD
bob::machine::Activation* base;
} PyBobLearnActivationObject;
.. cpp:member:: bob::machine::Activation* base
A pointer to the activation functor virtual implementation.
.. cpp:function:: int PyBobLearnActivation_Check(PyObject* o)
Checks if the input object ``o`` is a ``PyBobLearnActivationObject``.
Returns ``1`` if it is, and ``0`` otherwise.
.. cpp:function:: PyObject* PyBobLearnActivation_NewFromActivation(boost::shared_ptr<bob::machine::Activation> a)
Constructs a new :c:type:`PyBobLearnActivationObject` starting from a shared
pointer to a pre-allocated `bob::machine::Activation` instance. This API is
available so that return values from actuall C++ machines can be mapped into
Python. It is the sole way to build an object of type :py:class:`Activation`
without recurring to the derived classes.
.. note::
Other object definitions exist for each of the specializations for
activation functors found in |project|. They are exported through the module
C-API, but we don't recommend using them since you'd loose generality. In
case you do absolutely need to use any of these derivations, they have all
the same object configuration:
.. code-block:: c++
typedef struct {
PyBobLearnActivationObject parent;
bob::machine::<Subtype>Activation* base;
} PyBobLearn<Subtype>ActivationObject;
Presently, ``<Subtype>`` can be one of:
* Identity
* Linear
* Logistic
* HyperbolicTangent
* MultipliedHyperbolicTangent
Type objects are also named consistently like
``PyBobLearn<Subtype>Activation_Type``.
.. include:: links.rst
......@@ -58,12 +58,12 @@ source_suffix = '.rst'
master_doc = 'index'
# General information about the project.
project = u'xbob.learn.activation'
project = u'xbob.learn.misc'
import time
copyright = u'%s, Idiap Research Institute' % time.strftime('%Y')
# Grab the setup entry
distribution = pkg_resources.require('xbob.learn.activation')[0]
distribution = pkg_resources.require('xbob.learn.misc')[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_activation'
#html_short_title = 'xbob_learn_misc'
# 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_activation_doc'
htmlhelp_basename = 'xbob_learn_misc_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_activation.tex', u'Bob Activation Functions',
('index', 'xbob_learn_misc.tex', u'Bob Miscellaneous Machine Learning Tools',
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_activation', u'Bob Activation Function Documentation', [u'Idiap Research Institute'], 1)
('index', 'xbob_learn_misc', u'Bob Miscellaneous Machine Learning Tools', [u'Idiap Research Institute'], 1)
]
# Default processing flags for sphinx
......
This diff is collapsed.
......@@ -2,17 +2,16 @@
.. Andre Anjos <andre.anjos@idiap.ch>
.. Fri 13 Dec 2013 12:50:06 CET
..
.. Copyright (C) 2011-2013 Idiap Research Institute, Martigny, Switzerland
.. Copyright (C) 2011-2014 Idiap Research Institute, Martigny, Switzerland
=========================
Bob Activation Functors
=========================
======================================
Miscellaneous Machine Learning Tools
======================================
.. todolist::
This module contains some functionality from Bob bound to Python, available in
the C++ counter-part ``bob::machine``. It includes Activation functors from the
Machine Learning core.
This package includes various machine learning utitilities which have not yet
been ported into the new framework.
Documentation
-------------
......@@ -20,8 +19,8 @@ Documentation
.. toctree::
:maxdepth: 2
guide
py_api
c_cpp_api
Indices and tables
------------------
......
......@@ -7,8 +7,8 @@
============
This section includes information for using the pure Python API of
``xbob.learn.activation``.
``xbob.learn.misc``.
.. automodule:: xbob.learn.activation
.. automodule:: xbob.learn.misc
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment