diff --git a/README.rst b/README.rst index ddbdfd4664c129ade129d31d212664834cec32d9..650b3a2c3618d29c306073533f51f15446307a8c 100644 --- a/README.rst +++ b/README.rst @@ -1,10 +1,10 @@ +.. |pipeline| image:: https://gitlab.lis-lab.fr/baptiste.bauvin/summit/badges/master/pipeline.svg + :alt: Pipeline status + .. image:: https://img.shields.io/badge/License-GPL%20v3-blue.svg :target: http://www.gnu.org/licenses/gpl-3.0 :alt: License: GPL v3 -.. |pipeline| image:: https://gitlab.lis-lab.fr/baptiste.bauvin/summit/badges/master/pipeline.svg - :alt: Pipeline status - |pipeline| .. image:: https://gitlab.lis-lab.fr/baptiste.bauvin/summit/badges/master/coverage.svg @@ -20,13 +20,8 @@ This project aims to be an easy-to-use solution to run a prior benchmark on a da Getting Started --------------- -Prerequisites (will be automatically installed) -<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - SuMMIT has been designed and uses continuous integration for Linux platforms (ubuntu 18.04), but we try to keep it as compatible as possible with Mac and Windows. -Last tests on each platform : - +----------+-------------------+ | Platform | Last positive test| +==========+===================+ @@ -38,11 +33,14 @@ Last tests on each platform : +----------+-------------------+ +Prerequisites +<<<<<<<<<<<<< + To be able to use this project, you'll need : * `Python 3 <https://docs.python.org/3/>`_ -And the following python modules : +And the following python modules will be automatically installed : * `numpy <http://www.numpy.org/>`_, `scipy <https://scipy.org/>`_, * `matplotlib <http://matplotlib.org/>`_ - Used to plot results, @@ -82,6 +80,7 @@ To run the test suite of SuMMIT, run : cd path/to/summit pytest +The coverage report is automatically generated and stored in the ``htmlcov/`` directory Running on simulated data <<<<<<<<<<<<<<<<<<<<<<<<< diff --git a/docs/source/api.rst b/docs/source/api.rst index 6999ad11ec276454994f380661ec50d7dbf488f6..185c395b5f3dbe5288d495b113ad73a5d98ca374 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -1,9 +1,13 @@ API Documentation ================= -Multiview dataset management module ------------------------------------ -.. automodule:: summit.multiview_platform.utils.dataset - :members: - :inherited-members: + +.. toctree:: + :maxdepth: 3 + + api_files/dataset + autoapi/summit/multiview_platform/monoview_classifiers/index + autoapi/summit/multiview_platform/multiview_classifiers/index + + diff --git a/docs/source/api_files/dataset.rst b/docs/source/api_files/dataset.rst new file mode 100644 index 0000000000000000000000000000000000000000..a41cca087bfe81079182d4f74b0e9384e793e978 --- /dev/null +++ b/docs/source/api_files/dataset.rst @@ -0,0 +1,6 @@ +Multiview dataset management module +----------------------------------- + +.. automodule:: summit.multiview_platform.utils.dataset + :members: + :inherited-members: \ No newline at end of file diff --git a/docs/source/conf.py b/docs/source/conf.py index 2875ddb1eb61cf4673effe8a312191fba11c3419..82190952429ff520f90ed83a7cadfc63faf7d6d1 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -54,11 +54,20 @@ extensions = ['sphinx.ext.autodoc', # 'sphinx.ext.ifconfig', # 'sphinx.ext.viewcode', # 'sphinx.ext.githubpages', - 'sphinx.ext.napoleon',] - - + 'sphinx.ext.napoleon', + 'autoapi.extension' + ] + +autoapi_type = 'python' +autoapi_dirs = [os.path.join(repo_path, "summit", "multiview_platform", "monoview_classifiers", ""), + os.path.join(repo_path, "summit", "multiview_platform", "multiview_classifiers", "")] +autoapi_options = ["members", "show-module-summary", 'undoc-members'] +autoapi_ignore = ["*additions*"] +autoapi_keep_files = False +auto_api_add_toctree_entry = False +autoapi_template_dir = os.path.join(repo_path, "docs", "source", "templates_autoapi") # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ['_templates', 'templates_autoapi'] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: @@ -190,9 +199,12 @@ rst_prolog = """ .. role:: python(code) :language: python -.. role :: yaml(code) +.. role:: yaml(code) :language: yaml +.. role:: mod(code) + :language: python + .. |platf| replace:: SuMMIT .. |HP| replace:: hyper-parameter diff --git a/docs/source/index.rst b/docs/source/index.rst index 1151c1cfac10eedc4922cc3ec8deb9bf82cd622f..285ab422dfb4fb7ec285e0e5a42621cc24ab3963 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -12,12 +12,19 @@ This documentation consists in a short read me, with instructions to install and All the content labelled WIP is Work In Progress .. toctree:: - :maxdepth: 1 + :maxdepth: 2 tutorials/index + +.. toctree:: + :maxdepth: 3 + api +Read me +========= + .. include:: readme_link.rst diff --git a/docs/source/templates_autoapi/python/module.rst b/docs/source/templates_autoapi/python/module.rst new file mode 100644 index 0000000000000000000000000000000000000000..f682d9a29a2062613707bbdf52fc3d3041f66959 --- /dev/null +++ b/docs/source/templates_autoapi/python/module.rst @@ -0,0 +1,105 @@ +{% if not obj.display %} +:orphan: + +{% endif %} +:mod:`{{ obj.name }}` +======={{ "=" * obj.name|length }} + +.. py:module:: {{obj.name}} + +{% if obj.docstring %} +.. autoapi-nested-parse:: + + {{ obj.docstring|prepare_docstring|indent(3) }} + +{% endif %} + +{% block subpackages %} +{% set visible_subpackages = obj.subpackages|selectattr("display")|list %} +{% if visible_subpackages %} +Subpackages +----------- + +.. toctree:: + :titlesonly: + :maxdepth: 3 + +{% for subpackage in visible_subpackages %} + {{ subpackage.short_name }}/index.rst + +{% endfor %} + + +{% endif %} +{% endblock %} +{% block submodules %} +{% set visible_submodules = obj.submodules|selectattr("display")|list %} +{% if visible_submodules %} +Submodules +---------- + +.. toctree:: + :titlesonly: + :maxdepth: 1 + +{% for submodule in visible_submodules %} + {{ submodule.short_name }}/index.rst + +{% endfor %} + + +{% endif %} +{% endblock %} +{% block content %} +{% if obj.all is not none %} +{% set visible_children = obj.children|selectattr("short_name", "in", obj.all)|list %} +{% elif obj.type is equalto("package") %} +{% set visible_children = obj.children|selectattr("display")|list %} +{% else %} +{% set visible_children = obj.children|selectattr("display")|rejectattr("imported")|list %} +{% endif %} +{% if visible_children %} +{{ obj.short_name }} +{{ "-" * obj.short_name|length }} + +{% set visible_classes = visible_children|selectattr("type", "equalto", "class")|list %} +{% set visible_functions = visible_children|selectattr("type", "equalto", "function")|list %} +{% if "show-module-summary" in autoapi_options and (visible_classes or visible_functions) %} +{% block classes %} +{% if visible_classes %} + +Classes +~~~~~~~ + +.. autoapisummary:: + +{% for klass in visible_classes %} + {{ klass.id }} + +{% endfor %} + + +{% endif %} +{% endblock %} + +{% block functions %} +{% if visible_functions %} +Functions +~~~~~~~~~ + +.. autoapisummary:: + +{% for function in visible_functions %} + {{ function.id }} + +{% endfor %} + + +{% endif %} +{% endblock %} +{% endif %} +{% for obj_item in visible_children %} +{{ obj_item.rendered|indent(0) }} +{% endfor %} +{% endif %} +{% endblock %} diff --git a/docs/source/templates_autoapi/python/package.rst b/docs/source/templates_autoapi/python/package.rst new file mode 100644 index 0000000000000000000000000000000000000000..6e70183d2e2cd4143df2194b9725a1c9c0efaa74 --- /dev/null +++ b/docs/source/templates_autoapi/python/package.rst @@ -0,0 +1,110 @@ +{% if not obj.display %} +:orphan: + +{% endif %} +:mod:`{{ obj.name }}` +======={{ "=" * obj.name|length }} + +.. py:module:: {{obj.name}} + +{% if obj.docstring %} +.. autoapi-nested-parse:: + + {{ obj.docstring|prepare_docstring|indent(3) }} + +{% endif %} + +{% block subpackages %} +{% set visible_subpackages = obj.subpackages|selectattr("display")|list %} +{% if visible_subpackages %} +Subpackages +----------- + +.. toctree:: + :titlesonly: + :maxdepth: 3 + +{% for subpackage in visible_subpackages %} + {{ subpackage.short_name }}/index.rst + +{% endfor %} + + +{% endif %} +{% endblock %} +{% block submodules %} +{% set visible_submodules = obj.submodules|selectattr("display")|list %} +{% if visible_submodules %} +{% if obj.short_name is equalto("monoview_classifiers") %} +Available monoview classifiers +------------------------------ +{% elif obj.short_name is equalto("multiview_classifiers") %} +Available multiview classifiers +------------------------------- +{% endif %} + +.. toctree:: + :titlesonly: + :maxdepth: 1 + +{% for submodule in visible_submodules %} + {{ submodule.short_name }}/index.rst + +{% endfor %} + + +{% endif %} +{% endblock %} +{% block content %} +{% if obj.all is not none %} +{% set visible_children = obj.children|selectattr("short_name", "in", obj.all)|list %} +{% elif obj.type is equalto("package") %} +{% set visible_children = obj.children|selectattr("display")|list %} +{% else %} +{% set visible_children = obj.children|selectattr("display")|rejectattr("imported")|list %} +{% endif %} +{% if visible_children %} +{{ obj.short_name }} +{{ "-" * obj.short_name|length }} + +{% set visible_classes = visible_children|selectattr("type", "equalto", "class")|list %} +{% set visible_functions = visible_children|selectattr("type", "equalto", "function")|list %} +{% if "show-module-summary" in autoapi_options and (visible_classes or visible_functions) %} +{% block classes %} +{% if visible_classes %} + +Classes +~~~~~~~ + +.. autoapisummary:: + +{% for klass in visible_classes %} + {{ klass.id }} + +{% endfor %} + + +{% endif %} +{% endblock %} + +{% block functions %} +{% if visible_functions %} +Functions +~~~~~~~~~ + +.. autoapisummary:: + +{% for function in visible_functions %} + {{ function.id }} + +{% endfor %} + + +{% endif %} +{% endblock %} +{% endif %} +{% for obj_item in visible_children %} +{{ obj_item.rendered|indent(0) }} +{% endfor %} +{% endif %} +{% endblock %} diff --git a/docs/source/tutorials/hps_theory.rst b/docs/source/tutorials/hps_theory.rst index ae819bcff773f3da14b45e188f599c67c771f2f6..13e1a3685ccc76701414e61b63401623d8d93b2f 100644 --- a/docs/source/tutorials/hps_theory.rst +++ b/docs/source/tutorials/hps_theory.rst @@ -1,3 +1,4 @@ +:orphan: ============================ Hyper-parameter 101 ============================ diff --git a/docs/source/tutorials/images/example_0/zoom_plotly.gif b/docs/source/tutorials/images/example_0/zoom_plotly.gif new file mode 100644 index 0000000000000000000000000000000000000000..5be247545c014ba5ce79583e1dcdc4ad7bbc5c5c Binary files /dev/null and b/docs/source/tutorials/images/example_0/zoom_plotly.gif differ diff --git a/setup.py b/setup.py index 407b77d6439567da51a63e5af5c13ad9c014b8ef..773e677c18ede85726486aa79976482c39bfcdee 100644 --- a/setup.py +++ b/setup.py @@ -58,7 +58,7 @@ def setup_package(): install_requires=requirements, extras_requires={ 'dev': ['pytest', 'pytest-cov'], - 'doc': ['sphinx', 'numpydoc', 'docutils']}, + 'doc': ['sphinx', 'numpydoc', 'docutils', 'sphinx-autoapi']}, # Il est d'usage de mettre quelques metadata à propos de sa lib # Pour que les robots puissent facilement la classer. diff --git a/summit/multiview_platform/monoview_classifiers/adaboost.py b/summit/multiview_platform/monoview_classifiers/adaboost.py index 5bd49ef47fcf6541e021257fa7942e6a7dab3ca5..605041556c5b0f488d0c1474a45fa031e57792e9 100644 --- a/summit/multiview_platform/monoview_classifiers/adaboost.py +++ b/summit/multiview_platform/monoview_classifiers/adaboost.py @@ -1,3 +1,4 @@ +""" Ada""" import os import time diff --git a/summit/multiview_platform/utils/dataset.py b/summit/multiview_platform/utils/dataset.py index 953bcb16cabf747cc95f9f50d761dd14d023027f..25c396fa8fcb84fcb0e4e7152bd266fb824f7c77 100644 --- a/summit/multiview_platform/utils/dataset.py +++ b/summit/multiview_platform/utils/dataset.py @@ -75,7 +75,7 @@ class Dataset(): def to_numpy_array(self, sample_indices=None, view_indices=None): """ - To concatenate the needed views in one big numpy array while saving the + Concatenates the needed views in one big numpy array while saving the limits of each view in a list, to be able to retrieve them later. Parameters @@ -192,15 +192,6 @@ class RAMDataset(Dataset): return self.view_names[view_idx] def init_attrs(self): - """ - Used to init the two attributes that are modified when self.dataset - changes - - Returns - ------- - - """ - self.nb_view = len(self.views) self.view_dict = dict((view_ind, self.view_names[view_ind]) for view_ind in range(self.nb_view)) @@ -239,10 +230,6 @@ class RAMDataset(Dataset): pass def get_nb_class(self, sample_indices=None): - """ - Gets the number of class of the dataset - - """ sample_indices = self.init_sample_indices(sample_indices) return len(np.unique(self.labels[sample_indices])) @@ -277,9 +264,9 @@ class RAMDataset(Dataset): class HDF5Dataset(Dataset): """ - Class of Dataset + Dataset class - This class is used to encapsulate the multiview dataset while keeping it stored on the disk instead of in RAM. + This is used to encapsulate the multiview dataset while keeping it stored on the disk instead of in RAM. Parameters @@ -311,7 +298,7 @@ class HDF5Dataset(Dataset): The name for each unique value of the labels given in labels. is_temp : bool - Used if a temporary dataset has to be used by the benchmark. + Used if a temporary dataset has to be stored by the benchmark. Attributes ---------- @@ -327,7 +314,7 @@ class HDF5Dataset(Dataset): """ - # The following methods use hdf5 + # The following methods use h5py def __init__(self, views=None, labels=None, are_sparse=False, file_name="dataset.hdf5", view_names=None, path="", @@ -379,7 +366,7 @@ class HDF5Dataset(Dataset): for i in range(labels.shape[0])] def get_v(self, view_index, sample_indices=None): - r""" Extract the view and returns a numpy.ndarray containing the description + """ Extract the view and returns a numpy.ndarray containing the description of the samples specified in sample_indices Parameters @@ -452,14 +439,14 @@ class HDF5Dataset(Dataset): Returns ------- - + int """ return self.dataset["Metadata"].attrs["datasetLength"] def get_view_dict(self): """ - Returns the dictionary with view indices as keys and their corresponding - names as values + Returns the dictionary containing view indices as keys and their + corresponding names as values """ view_dict = {} for view_index in range(self.nb_view): @@ -481,7 +468,8 @@ class HDF5Dataset(Dataset): Returns ------- - + list + seleted labels' names """ selected_labels = self.get_labels(sample_indices) if decode: @@ -609,11 +597,6 @@ class HDF5Dataset(Dataset): def add_gaussian_noise(self, random_state, path, noise_std=0.15): - """In this function, we add a guaussian noise centered in 0 with specified - std to each view, according to it's range (the noise will be - mutliplied by this range) and we crop the noisy signal according to the - view's attributes limits. - This is done by creating a new dataset, to keep clean data.""" noisy_dataset = h5py.File(path + self.get_name() + "_noised.hdf5", "w") self.dataset.copy("Metadata", noisy_dataset) self.dataset.copy("Labels", noisy_dataset) @@ -643,7 +626,7 @@ class HDF5Dataset(Dataset): # The following methods are hdf5 free def get_name(self): - """Ony works if there are not multiple dots in the files name""" + """Gets the name of the dataset hdf5 file""" return os.path.split(self.dataset.filename)[-1].split('.')[0]