From f0fe60702b59966be821fd98e80f9bb06be3abdf Mon Sep 17 00:00:00 2001 From: Steffen Schneider Date: Sun, 29 Oct 2023 19:18:28 +0100 Subject: [PATCH 1/2] Simplify plotly docstring example (#102) --- cebra/integrations/plotly.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cebra/integrations/plotly.py b/cebra/integrations/plotly.py index d3edf509..474eb32e 100644 --- a/cebra/integrations/plotly.py +++ b/cebra/integrations/plotly.py @@ -174,7 +174,7 @@ def plot_embedding_interactive( CEBRA(max_iterations=10) >>> embedding = cebra_model.transform(X) >>> cebra_time = np.arange(X.shape[0]) - >>> fig = cebra.integrations.plotly.plot_embedding_interactive(embedding, embedding_labels=cebra_time) + >>> fig = cebra.plot_embedding_interactive(embedding, embedding_labels=cebra_time) """ return _EmbeddingInteractivePlot( From 4e594a4928286184b51cde5ae0ca962a31a0a471 Mon Sep 17 00:00:00 2001 From: Steffen Schneider Date: Sun, 29 Oct 2023 22:53:38 +0100 Subject: [PATCH 2/2] Restructure API docs for integrations (#103) --- .github/workflows/docs.yml | 8 +++++++- cebra/data/load.py | 17 ++++++++++++++++- cebra/integrations/plotly.py | 4 ++-- docs/source/api.rst | 10 +++++++++- docs/source/api/integrations/data.rst | 6 ++++++ docs/source/api/integrations/deeplabcut.rst | 8 ++++++++ docs/source/api/integrations/matplotlib.rst | 7 +++++++ docs/source/api/integrations/plotly.rst | 7 +++++++ docs/source/api/pytorch/helpers.rst | 8 -------- docs/source/api/pytorch/integrations.rst | 7 ------- docs/source/conf.py | 2 ++ 11 files changed, 64 insertions(+), 20 deletions(-) create mode 100644 docs/source/api/integrations/data.rst create mode 100644 docs/source/api/integrations/deeplabcut.rst create mode 100644 docs/source/api/integrations/matplotlib.rst create mode 100644 docs/source/api/integrations/plotly.rst delete mode 100644 docs/source/api/pytorch/integrations.rst diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index e846399c..83c9d829 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -59,7 +59,13 @@ jobs: - name: Install package run: | python -m pip install --upgrade pip setuptools wheel - sudo apt-get install -y pandoc + # NOTE(stes) Pandoc version must be at least (2.14.2) but less than (4.0.0). + # as of 29/10/23. Ubuntu 22.04 which is used for ubuntu-latest only has an + # old pandoc version (2.9.). We will hence install the latest version manually. + # previou: sudo apt-get install -y pandoc + wget https://github.com/jgm/pandoc/releases/download/3.1.9/pandoc-3.1.9-1-amd64.deb + sudo dpkg -i pandoc-3.1.9-1-amd64.deb + rm pandoc-3.1.9-1-amd64.deb pip install torch --extra-index-url https://download.pytorch.org/whl/cpu pip install '.[docs]' diff --git a/cebra/data/load.py b/cebra/data/load.py index 65662ff3..b03c58a5 100644 --- a/cebra/data/load.py +++ b/cebra/data/load.py @@ -9,7 +9,22 @@ # Please see LICENSE.md for the full license document: # https://github.com/AdaptiveMotorControlLab/CEBRA/LICENSE.md # -"""A simple API for loading various data formats used with CEBRA.""" +"""A simple API for loading various data formats used with CEBRA. + +Availability of different data formats depends on the installed +dependencies. If a dependency is not installed, an attempt to load +a file of that format will throw an error with further installation +instructions. + +Currently available formats: + +- HDF5 via ``h5py`` +- Pickle files via ``pickle`` +- Joblib files via ``joblib`` +- Various dataframe formats via ``pandas``. +- Matlab files via ``scipy.io.loadmat`` +- DeepLabCut (single animal) files via ``deeplabcut`` +""" import abc import pathlib diff --git a/cebra/integrations/plotly.py b/cebra/integrations/plotly.py index 474eb32e..8f0c2089 100644 --- a/cebra/integrations/plotly.py +++ b/cebra/integrations/plotly.py @@ -135,7 +135,7 @@ def plot_embedding_interactive( This is supposing that the dimensions provided to ``idx_order`` are in the range of the number of dimensions of the embedding (i.e., between 0 and :py:attr:`cebra.CEBRA.output_dimension` -1). - The function makes use of :py:func:`plotly.graph_objs._scatter.Scatter` and parameters from that function can be provided + The function makes use of :py:class:`plotly.graph_objects.Scatter` and parameters from that function can be provided as part of ``kwargs``. @@ -156,7 +156,7 @@ def plot_embedding_interactive( title: The title on top of the embedding. figsize: Figure width and height in inches. dpi: Figure resolution. - kwargs: Optional arguments to customize the plots. See :py:func:`plotly.graph_objs._scatter.Scatter` documentation for more + kwargs: Optional arguments to customize the plots. See :py:class:`plotly.graph_objects.Scatter` documentation for more details on which arguments to use. Returns: diff --git a/docs/source/api.rst b/docs/source/api.rst index a85ccb0a..8989337f 100644 --- a/docs/source/api.rst +++ b/docs/source/api.rst @@ -37,8 +37,16 @@ these components in other contexts and research code bases. api/pytorch/datasets api/pytorch/distributions api/pytorch/models - api/pytorch/integrations api/pytorch/helpers +.. toctree:: + :hidden: + :caption: Integrations + + api/integrations/data + api/integrations/matplotlib + api/integrations/plotly + api/integrations/deeplabcut + .. _Scikit-learn estimators: https://scikit-learn.org/stable/developers/develop.html diff --git a/docs/source/api/integrations/data.rst b/docs/source/api/integrations/data.rst new file mode 100644 index 00000000..88c0f3eb --- /dev/null +++ b/docs/source/api/integrations/data.rst @@ -0,0 +1,6 @@ +Data Loading +------------ + +.. automodule:: cebra.data.load + :show-inheritance: + :members: \ No newline at end of file diff --git a/docs/source/api/integrations/deeplabcut.rst b/docs/source/api/integrations/deeplabcut.rst new file mode 100644 index 00000000..44ebd4f6 --- /dev/null +++ b/docs/source/api/integrations/deeplabcut.rst @@ -0,0 +1,8 @@ +DeepLabCut +---------- + +.. automodule:: cebra.integrations.deeplabcut + :show-inheritance: + :members: + + diff --git a/docs/source/api/integrations/matplotlib.rst b/docs/source/api/integrations/matplotlib.rst new file mode 100644 index 00000000..45ed20f7 --- /dev/null +++ b/docs/source/api/integrations/matplotlib.rst @@ -0,0 +1,7 @@ +Plotting with ``matplotlib`` +---------------------------- + +.. automodule:: cebra.integrations.matplotlib + :show-inheritance: + :members: + diff --git a/docs/source/api/integrations/plotly.rst b/docs/source/api/integrations/plotly.rst new file mode 100644 index 00000000..e12f6123 --- /dev/null +++ b/docs/source/api/integrations/plotly.rst @@ -0,0 +1,7 @@ +Plotting with ``plotly`` +---------------------------- + +.. automodule:: cebra.integrations.plotly + :show-inheritance: + :members: + diff --git a/docs/source/api/pytorch/helpers.rst b/docs/source/api/pytorch/helpers.rst index 2900b218..6615e6f9 100644 --- a/docs/source/api/pytorch/helpers.rst +++ b/docs/source/api/pytorch/helpers.rst @@ -21,14 +21,6 @@ Registry :show-inheritance: -Plots ------ - -.. automodule:: cebra.integrations.matplotlib - :show-inheritance: - :members: - - Grid-Search ----------- diff --git a/docs/source/api/pytorch/integrations.rst b/docs/source/api/pytorch/integrations.rst deleted file mode 100644 index b475153f..00000000 --- a/docs/source/api/pytorch/integrations.rst +++ /dev/null @@ -1,7 +0,0 @@ -============ -Integrations -============ - -.. automodule:: cebra.integrations - :members: - :show-inheritance: diff --git a/docs/source/conf.py b/docs/source/conf.py index 9162ee29..e31a3056 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -101,6 +101,7 @@ def get_years(start_year=2021): "pandas": ("http://pandas.pydata.org/pandas-docs/dev", None), "scipy": ("http://docs.scipy.org/doc/scipy/reference/", None), "joblib": ("https://joblib.readthedocs.io/en/latest/", None), + "plotly": ("https://plotly.com/python-api-reference/", None) } # Config is documented here: https://sphinx-copybutton.readthedocs.io/en/latest/ @@ -116,6 +117,7 @@ def get_years(start_year=2021): "h5py", "pandas", "matplotlib", + "plotly" ] # autodoc_typehints = "none"