Skip to content

Commit

Permalink
Adding some docs (#529)
Browse files Browse the repository at this point in the history
* Adds documentation for Objective.

* Remove unnecessary method.

* Fixed bug in Objective.copy().

* Fix some pre-commit issues.
  • Loading branch information
luisenp authored Jun 21, 2023
1 parent 28fc60b commit 5450659
Show file tree
Hide file tree
Showing 11 changed files with 344 additions and 78 deletions.
13 changes: 12 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import os
import sys

sys.path.insert(0, os.path.abspath(".."))
sys.path.insert(0, os.path.abspath(os.path.join("..", "..")))

# -- Project information -----------------------------------------------------

Expand Down Expand Up @@ -71,3 +71,14 @@
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
# html_static_path = ["_static"]


def skip_undocumented(app, what, name, obj, skip, options):
exclusions = ["__weakref__", "__module__"]
if not skip and obj.__doc__ is None and name not in exclusions:
return True
return None


def setup(app):
app.connect("autodoc-skip-member", skip_undocumented)
12 changes: 11 additions & 1 deletion docs/source/core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Core Module

Objective
---------
An objective function to optimize.
An objective function to optimize (see :class:`theseus.Objective`).

Cost Function
-------------
Expand All @@ -25,4 +25,14 @@ Reference
:nosignatures:

theseus.Objective
:no-undoc-members:
:nosignatures:
theseus.Objective.add
theseus.Objective.error
theseus.Objective.error_metric
theseus.Objective.update
theseus.Objective.retract_vars_sequence
theseus.CostFunction
:no-undoc-members:
:nosignatures:
theseus.Variable
16 changes: 16 additions & 0 deletions docs/source/generated/theseus.CostFunction.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
theseus.CostFunction
====================

.. currentmodule:: theseus

.. autoclass:: CostFunction


.. automethod:: __init__







6 changes: 6 additions & 0 deletions docs/source/generated/theseus.Objective.add.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
theseus.Objective.add
=====================

.. currentmodule:: theseus

.. automethod:: Objective.add
6 changes: 6 additions & 0 deletions docs/source/generated/theseus.Objective.error.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
theseus.Objective.error
=======================

.. currentmodule:: theseus

.. automethod:: Objective.error
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
theseus.Objective.retract\_vars\_sequence
=========================================

.. currentmodule:: theseus

.. automethod:: Objective.retract_vars_sequence
16 changes: 2 additions & 14 deletions docs/source/generated/theseus.Objective.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,29 @@

.. autosummary::

~Objective.__init__
~Objective.add
~Objective.copy
~Objective.dim
~Objective.disable_vectorization
~Objective.erase
~Objective.error
~Objective.error_squared_norm
~Objective.error_metric
~Objective.get_aux_var
~Objective.get_cost_function
~Objective.get_cost_function_name
~Objective.get_functions_connected_to_aux_var
~Objective.get_functions_connected_to_optim_var
~Objective.get_optim_var
~Objective.has_aux_var
~Objective.has_cost_function
~Objective.has_optim_var
~Objective.retract_optim_vars
~Objective.retract_vars_sequence
~Objective.size
~Objective.size_aux_vars
~Objective.size_cost_functions
~Objective.size_variables
~Objective.to
~Objective.update
~Objective.update_vectorization_if_needed





.. rubric:: Attributes

.. autosummary::

~Objective.batch_size
~Objective.vectorized


6 changes: 6 additions & 0 deletions docs/source/generated/theseus.Objective.update.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
theseus.Objective.update
========================

.. currentmodule:: theseus

.. automethod:: Objective.update
18 changes: 0 additions & 18 deletions docs/source/generated/theseus.Variable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,8 @@
.. automethod:: __init__


.. rubric:: Methods

.. autosummary::

~Variable.__init__
~Variable.copy
~Variable.to
~Variable.update





.. rubric:: Attributes

.. autosummary::

~Variable.device
~Variable.dtype
~Variable.ndim
~Variable.shape


2 changes: 2 additions & 0 deletions theseus/core/cost_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def masked_jacobians(
# jacobian of the error, by implementing abstract methods
# `error` and `jacobians`, respectively.
class CostFunction(TheseusFunction, abc.ABC):
"""A cost function in a differentiable optimization problem."""

def __init__(
self,
cost_weight: CostWeight,
Expand Down
Loading

0 comments on commit 5450659

Please sign in to comment.