Skip to content

Commit

Permalink
Merge pull request #18 from fenfisdi/issue/12/update_docstrings
Browse files Browse the repository at this point in the history
Updated documentation - minor refactors on code

Features

* base documentation with examples and how to install the package
* refactored the predefined models into sub-packages
* renamed ``Optimize.minimize`` -> ``Optimize.optimize``
  • Loading branch information
jearistiz authored May 21, 2021
2 parents ce5db75 + dd7fb56 commit f2f3e9d
Show file tree
Hide file tree
Showing 28 changed files with 595 additions and 76 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ instance/

# Sphinx documentation
docs/_build/
docs/source/_build

# PyBuilder
.pybuilder/
Expand Down
5 changes: 4 additions & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 0.1.dev1
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
Expand All @@ -13,6 +13,9 @@ sphinx:
formats:
- pdf

build:
image: testing

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.9
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

``DINJO Is Not Just An Optimizer`` is a Python framework designed for the optimization of initial value problems' parameters.

Lets say you have some 'experimental' data of a state variable ``S`` of the initial value problem ``dS/dt = f(t, S; p), S(t_0) = f_0`` where ``p`` is a list of parameters.
Lets say you have some 'experimental' data of a state variable ``S`` corresponding to the initial value problem ``dS/dt = f(t, S; p), S(t_0) = f_0`` where ``p`` is a list of parameters. If you want to know the optimal value of ``p`` so that the solution of the initial value problem fits your experimental data, you can use DINJO to get an approximate value of the optimal ``p``.

If you want to know the optimal value of ``p`` so that the solution of the initial value problem fits your experimental data, you can use DINJO to get an approximate value of the optimal ``p``.
**Visit [DINJO's official documentation](https://dinjo.readthedocs.io/)**
6 changes: 3 additions & 3 deletions dinjo/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ class Parameter(Variable):
"""Represents a parameter of the differential equations definining
an initial value problem.
Attributes
----------
In addition to the attributes defined in
:class:`dinjo.model.Variable`:
:py:class:`dinjo.model.Variable`
Attributes
----------
bounds : 2-tuple of floats.
list containing the minimum and maximum values that the
parameter can take ``(min, max)``.
Expand Down
2 changes: 1 addition & 1 deletion dinjo/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def rms(solution_reference) -> float:

return cost_func(solution_reference)

def minimize(
def optimize(
self,
cost_method: str = 'root_mean_square',
algorithm: str = 'differential_evolution',
Expand Down
11 changes: 0 additions & 11 deletions dinjo/predefined/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +0,0 @@
from ._seir_model import ModelSEIR
from ._seirv_model import ModelSEIRV
from ._seirv_fixed import ModelSimpleSEIRV
from ._sir_model import ModelSIR

__all__ = [
'ModelSEIR',
'ModelSEIRV',
'ModelSimpleSEIRV',
'ModelSIR',
]
11 changes: 11 additions & 0 deletions dinjo/predefined/epidemiology/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from ._seir_model import ModelSEIR
from ._seirv_model import ModelSEIRV
from ._seirv_fixed import ModelSimpleSEIRV
from ._sir_model import ModelSIR

__all__ = [
'ModelSEIR',
'ModelSEIRV',
'ModelSimpleSEIRV',
'ModelSIR',
]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List

from ..model import ModelIVP
from ...model import ModelIVP


class ModelSEIR(ModelIVP):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List

from ..model import ModelIVP
from ...model import ModelIVP


class ModelSimpleSEIRV(ModelIVP):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List

from ..model import ModelIVP
from ...model import ModelIVP


class ModelSEIRV(ModelIVP):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List

from ..model import ModelIVP
from ...model import ModelIVP


class ModelSIR(ModelIVP):
Expand Down
5 changes: 5 additions & 0 deletions dinjo/predefined/physics/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from ._harmonic_oscillator import ModelOscillator

__all__ = [
'ModelOscillator',
]
16 changes: 16 additions & 0 deletions dinjo/predefined/physics/_harmonic_oscillator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from ...model import ModelIVP


class ModelOscillator(ModelIVP):
def build_model(self, t, y, w):
"""Harmonic Oscillator differential equations
"""
q, p = y

# Hamilton's equations
dydt = [
p,
- (w ** 2) * q
]

return dydt
Binary file added docs/source/_static/ho_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
copyright = '2021, Juan Esteban Aristizabal-Zuluaga and FEnFiSDi'
author = 'Juan Esteban Aristizabal-Zuluaga and FEnFiSDi'

version = '0.1.0'
release = '0.1.0'
version = '0.0'
release = '0.0.dev1'

# -- General configuration ---------------------------------------------------

Expand All @@ -50,7 +50,10 @@
autodoc_default_options = {
'members': True,
'private-members':
'',
'_seir_model, '
'_seirv_model, '
'_seirv_fixed, '
'_sir_model',
'special-members': '__init__',
'inherited-members': False,
'show-inheritance': False,
Expand Down
10 changes: 10 additions & 0 deletions docs/source/dinjo/dinjo.model.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.. _code-dinjo.model:

=========================
:mod:`dinjo.model` module
=========================

.. automodule:: dinjo.model
:members:
:undoc-members: reference_t_values
:show-inheritance:
10 changes: 10 additions & 0 deletions docs/source/dinjo/dinjo.optimizer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.. _code-dinjo.optimizer:

=============================
:mod:`dinjo.optimizer` module
=============================

.. automodule:: dinjo.optimizer
:members:
:undoc-members:
:show-inheritance:
62 changes: 62 additions & 0 deletions docs/source/dinjo/dinjo.predefined.epidemiology.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
.. _code-dinjo.predefined.epidemiology:

===============================================
:mod:`dinjo.predefined.epidemiology` subpackage
===============================================

For your convenience, the classes
:py:class:`~dinjo.predefined.epidemiology._seir_model.ModelSEIR`,
:py:class:`~dinjo.predefined.epidemiology._seirv_model.ModelSEIRV`,
:py:class:`~dinjo.predefined.epidemiology._seirv_fixed.ModelSimpleSEIRV`,
:py:class:`~dinjo.predefined.epidemiology._sir_model.ModelSIR`
can be imported directly from the subpackage
:mod:`dinjo.predefined.epidemiology`:

.. code-block:: python
from dinjo.predefined.epidemiology import (
ModelSEIR,
ModelSEIRV,
ModelSimpleSEIRV,
ModelSIR
)
Submodules
==========

:mod:`dinjo.predefined.epidemiology._seir_model`
------------------------------------------------

.. automodule:: dinjo.predefined.epidemiology._seir_model
:members:
:undoc-members:
:show-inheritance:


:mod:`dinjo.predefined.epidemiology._seirv_model`
-------------------------------------------------

.. automodule:: dinjo.predefined.epidemiology._seirv_model
:members:
:undoc-members:
:show-inheritance:


:mod:`dinjo.predefined.epidemiology._seirv_fixed`
-------------------------------------------------

.. automodule:: dinjo.predefined.epidemiology._seirv_fixed
:members:
:undoc-members:
:show-inheritance:


:mod:`dinjo.predefined.epidemiology._sir_model`
------------------------------------------------

.. automodule:: dinjo.predefined.epidemiology._sir_model
:members:
:undoc-members:
:show-inheritance:

21 changes: 17 additions & 4 deletions docs/source/dinjo/dinjo.predefined.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
dinjo.predefined package
========================
.. _code-dinjo.predefined:

Module contents
---------------
==================================
:mod:`dinjo.predefined` subpackage
==================================


Package contents
================

.. automodule:: dinjo.predefined
:members:
:undoc-members:
:show-inheritance:


Subpackages
===========

.. toctree::
:maxdepth: 4

dinjo.predefined.epidemiology
45 changes: 20 additions & 25 deletions docs/source/dinjo/dinjo.rst
Original file line number Diff line number Diff line change
@@ -1,37 +1,32 @@
dinjo
=====
.. _code-dinjo:

====================
:mod:`dinjo` package
====================

Package contents
================

.. automodule:: dinjo
:members:
:undoc-members:
:show-inheritance:


Subpackages
-----------
===========

.. toctree::
:maxdepth: 4

dinjo.predefined


Submodules
==========

dinjo.model
-----------

.. automodule:: dinjo.model
:members:
:undoc-members:
:show-inheritance:

dinjo.optimizer
---------------

.. automodule:: dinjo.optimizer
:members:
:undoc-members:
:show-inheritance:

Module contents
===============
.. toctree::
:maxdepth: 4

.. automodule:: dinjo
:members:
:undoc-members:
:show-inheritance:
dinjo.model
dinjo.optimizer
Loading

0 comments on commit f2f3e9d

Please sign in to comment.