Skip to content

Commit

Permalink
Added sphinx docs
Browse files Browse the repository at this point in the history
  • Loading branch information
John Hwang authored and John Hwang committed Aug 7, 2017
1 parent b729770 commit bc75cc2
Show file tree
Hide file tree
Showing 25 changed files with 1,914 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
*.so.*
*.sm
*.out
*__pycache__*
.DS_Store
smt/src/rbf/rbfclib.cpp
smt/src/idw/idwclib.cpp
smt/src/rmts/rmtsclib.cpp
smt/src/rmts/rmtsclib.cpp
21 changes: 21 additions & 0 deletions doc2/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = SMT
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
python preprocess.py
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
15 changes: 15 additions & 0 deletions doc2/_src_docs/methods.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Methods
=======

Placeholder text.

.. toctree::
:maxdepth: 1

methods/rbf
methods/idw
methods/rmtb
methods/rmtc
methods/ls
methods/pa2
methods/krg
128 changes: 128 additions & 0 deletions doc2/_src_docs/methods/idw.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
Inverse-distance weighting
==========================

.. code-block:: python
import numpy as np
import matplotlib.pyplot as plt
from smt.methods import IDW
xt = np.array([0., 1., 2., 3., 4.])
yt = np.array([0., 1., 1.5, 0.5, 1.0])
sm = IDW(p=2)
sm.set_training_values(xt, yt)
sm.train()
num = 100
x = np.linspace(0., 4., num)
y = sm.predict_values(x)
plt.plot(xt, yt, 'o')
plt.plot(x, y)
plt.xlabel('x')
plt.ylabel('x')
plt.legend(['Training data', 'Prediction'])
plt.show()
.. plot::

import numpy as np
import matplotlib.pyplot as plt

from smt.methods import IDW

xt = np.array([0., 1., 2., 3., 4.])
yt = np.array([0., 1., 1.5, 0.5, 1.0])

sm = IDW(p=2)
sm.set_training_values(xt, yt)
sm.train()

num = 100
x = np.linspace(0., 4., num)
y = sm.predict_values(x)

plt.plot(xt, yt, 'o')
plt.plot(x, y)
plt.xlabel('x')
plt.ylabel('x')
plt.legend(['Training data', 'Prediction'])
plt.show()

::

___________________________________________________________________________
IDW
___________________________________________________________________________
Problem size
# training points. : 5
___________________________________________________________________________
Training
Training ...
Training - done. Time (sec): 0.0001831
___________________________________________________________________________
Evaluation
# eval points. : 100
Predicting ...
Predicting - done. Time (sec): 0.0000508
Prediction time/pt. (sec) : 0.0000005

.. list-table:: List of options
:header-rows: 1
:widths: 15, 10, 20, 20, 30
:stub-columns: 0

* - Option
- Default
- Acceptable values
- Acceptable values
- Description
* - print_global
- True
- [None]
- ['bool']
- Global print toggle. If False, all printing is suppressed
* - print_training
- True
- [None]
- ['bool']
- Whether to print training information
* - print_prediction
- True
- [None]
- ['bool']
- Whether to print prediction information
* - print_problem
- True
- [None]
- ['bool']
- Whether to print problem information
* - print_solver
- True
- [None]
- ['bool']
- Whether to print solver information
* - p
- 2.5
- [None]
- ['int', 'float']
- order of distance norm
* - data_dir
- None
- [None]
- ['str']
- Directory for loading / saving cached data; None means do not save or load
6 changes: 6 additions & 0 deletions doc2/_src_docs/methods/idw.rstx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Inverse-distance weighting
==========================

.. embed-test-plot-print :: _src_docs/methods/test_simple.py , Test , test_idw

.. embed-options-table :: IDW
138 changes: 138 additions & 0 deletions doc2/_src_docs/methods/krg.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
Kriging
=======

.. code-block:: python
import numpy as np
import matplotlib.pyplot as plt
from smt.methods import KRG
xt = np.array([0., 1., 2., 3., 4.])
yt = np.array([0., 1., 1.5, 0.5, 1.0])
sm = KRG(theta0=[1e-2])
sm.set_training_values(xt, yt)
sm.train()
num = 100
x = np.linspace(0., 4., num)
y = sm.predict_values(x)
plt.plot(xt, yt, 'o')
plt.plot(x, y)
plt.xlabel('x')
plt.ylabel('x')
plt.legend(['Training data', 'Prediction'])
plt.show()
.. plot::

import numpy as np
import matplotlib.pyplot as plt

from smt.methods import KRG

xt = np.array([0., 1., 2., 3., 4.])
yt = np.array([0., 1., 1.5, 0.5, 1.0])

sm = KRG(theta0=[1e-2])
sm.set_training_values(xt, yt)
sm.train()

num = 100
x = np.linspace(0., 4., num)
y = sm.predict_values(x)

plt.plot(xt, yt, 'o')
plt.plot(x, y)
plt.xlabel('x')
plt.ylabel('x')
plt.legend(['Training data', 'Prediction'])
plt.show()

::

___________________________________________________________________________
Kriging
___________________________________________________________________________
Problem size
# training points. : 5
___________________________________________________________________________
Training
Training ...
Training - done. Time (sec): 0.0056038
___________________________________________________________________________
Evaluation
# eval points. : 100
Predicting ...
Predicting - done. Time (sec): 0.0001500
Prediction time/pt. (sec) : 0.0000015

.. list-table:: List of options
:header-rows: 1
:widths: 15, 10, 20, 20, 30
:stub-columns: 0

* - Option
- Default
- Acceptable values
- Acceptable values
- Description
* - print_global
- True
- [None]
- ['bool']
- Global print toggle. If False, all printing is suppressed
* - print_training
- True
- [None]
- ['bool']
- Whether to print training information
* - print_prediction
- True
- [None]
- ['bool']
- Whether to print prediction information
* - print_problem
- True
- [None]
- ['bool']
- Whether to print problem information
* - print_solver
- True
- [None]
- ['bool']
- Whether to print solver information
* - theta0
- None
- [None]
- ['list', 'ndarray']
- Initial hyperparameters
* - poly
- constant
- ['constant', 'linear', 'quadratic']
- ['function']
- regr. term
* - corr
- squar_exp
- ['abs_exp', 'squar_exp']
- ['function']
- type of corr. func.
* - data_dir
- None
- [None]
- ['str']
- Directory for loading / saving cached data; None means do not save or load
6 changes: 6 additions & 0 deletions doc2/_src_docs/methods/krg.rstx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Kriging
=======

.. embed-test-plot-print :: _src_docs/methods/test_simple.py , Test , test_krg

.. embed-options-table :: KRG
Loading

0 comments on commit bc75cc2

Please sign in to comment.