Skip to content

Commit

Permalink
Docstrings corrected so that sphinx generates doctest in documentatio…
Browse files Browse the repository at this point in the history
…n correctly
  • Loading branch information
mcarbajo committed Dec 10, 2017
1 parent bdbb175 commit 065cf16
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions fda/FDataGrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class FDataGrid:
Examples:
The number of columns of data_matrix have to be the length of
sample_points.
>>> FDataGrid(numpy.array([1,2,4,5,8]), range(6))
Traceback (most recent call last):
....
Expand Down Expand Up @@ -210,6 +211,7 @@ def derivative(self, order=1):
Examples:
First order derivative
>>> fdata = FDataGrid([1,2,4,5,8], range(5))
>>> fdata.derivative()
FDataGrid(
Expand All @@ -219,6 +221,7 @@ def derivative(self, order=1):
,names=['Data set - 1 derivative', 'xlabel', 'ylabel'])
Second order derivative
>>> fdata = FDataGrid([1,2,4,5,8], range(5))
>>> fdata.derivative(2)
FDataGrid(
Expand Down
1 change: 1 addition & 0 deletions fda/kernel_smoothers.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def knn(argvals, k=None, kernel=kernels.uniform, w=None, cv=False):
[ 0. , 0. , 0. , 0.5, 0.5]])
In case there are two points at the same distance it will take both.
>>> knn(numpy.array([1,2,3,5,7]), 2).round(3)
array([[ 0.5 , 0.5 , 0. , 0. , 0. ],
[ 0.333, 0.333, 0.333, 0. , 0. ],
Expand Down
6 changes: 4 additions & 2 deletions fda/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def gcv(fdatagrid, s_matrix, penalisation_function=None):
.. math::
GCV(\\nu)=\\Xi(\\nu,n)\\frac{1}{n} \\sum_i \\left(y_i - \\hat{
y}_i^\\nu}\\right)^2
y}_i^\\nu\\right)^2
Where :math:`\\hat{y}_i^{\\nu}` is the adjusted :math:`y_i` and
:math:`\\Xi` is a penalisation function. By default the penalisation
Expand Down Expand Up @@ -116,6 +116,7 @@ def minimise(fdatagrid, parameters,
Examples:
Creates a FDataGrid object of the function :math:`y=x^2` and peforms
smoothing by means of the k-nearest neighbours method.
>>> x = numpy.linspace(-2, 2, 5)
>>> fd = fda.FDataGrid(x ** 2, x)
>>> res = minimise(fd, [2,3], smoothing_method=kernel_smoothers.knn)
Expand All @@ -139,7 +140,8 @@ def minimise(fdatagrid, parameters,
,names=['Data set', 'xlabel', 'ylabel'])
Other validation methods can be used such as cross-validation or
general corss validation using other penalisation functions.
general cross validation using other penalisation functions.
>>> res = minimise(fd, [2,3], smoothing_method=kernel_smoothers.knn,
... cv_method=cv)
>>> numpy.array(res['scores']).round(2)
Expand Down

0 comments on commit 065cf16

Please sign in to comment.