Skip to content

Commit 74327a9

Browse files
committed
Add initial documentation and docstrings
1 parent 04163d4 commit 74327a9

File tree

11 files changed

+158
-31
lines changed

11 files changed

+158
-31
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.0.1dev2
1+
0.0.1dev3

aakr/_aakr.py

Lines changed: 50 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Module for models."""
1+
"""Module for Auto Associative Kernel Regression models."""
22

33

44
import numpy as np
@@ -9,15 +9,19 @@
99

1010

1111
class AAKR(TransformerMixin, BaseEstimator):
12-
"""A template estimator to be used as a reference implementation.
12+
"""Auto Associative Kernel Regressor.
1313
14-
For more information regarding how to build your own estimator, read more
15-
in the :ref:`User Guide <user_guide>`.
14+
Please see the :ref:`Getting started <readme.rst>` documentation for more
15+
information.
1616
1717
Parameters
1818
----------
19-
demo_param : str, default='demo_param'
20-
A parameter used for demonstation of how to pass and store paramters.
19+
metric : str, default='euclidean'
20+
Metric for calculating kernel distances.
21+
bw : float, default=1.0
22+
Kernel bandwith parameter.
23+
n_jobs : int, default=-1
24+
The number of jobs to run in parallel.
2125
2226
Examples
2327
--------
@@ -26,43 +30,74 @@ class AAKR(TransformerMixin, BaseEstimator):
2630
>>> X = np.arange(100).reshape(50, 2)
2731
>>> aakr = AAKR()
2832
>>> aakr.fit(X)
29-
AAKR(metric='euclidean', bw=1, n_jobs=None)
33+
AAKR(metric='euclidean', bw=1, n_jobs=-1)
3034
"""
31-
def __init__(self, metric='euclidean', bw=1, n_jobs=None):
35+
def __init__(self, metric='euclidean', bw=1, n_jobs=-1):
3236
self.metric = metric
3337
self.bw = bw
3438
self.n_jobs = n_jobs
3539

3640
def fit(self, X, y=None):
37-
"""A reference implementation of a fitting function for a transformer.
41+
"""Fit normal condition examples.
3842
3943
Parameters
4044
----------
41-
X : array-like, shape (n_samples, n_features)
45+
X : array-like of shape (n_samples, n_features)
4246
Training examples from normal conditions.
4347
y : None
44-
Not needed, exists for compability purposes.
48+
Not required, exists only for compability purposes.
4549
4650
Returns
4751
-------
4852
self : object
4953
Returns self.
5054
"""
55+
# Validation
5156
X = check_array(X)
57+
58+
# Save history
5259
self.X_ = X
60+
61+
return self
62+
63+
def partial_fit(self, X, y=None):
64+
"""Fit more normal condition examples.
65+
66+
Parameters
67+
----------
68+
X : array-like of shape (n_samples, n_features)
69+
Training examples from normal conditions.
70+
y : None
71+
Not required, exists only for compability purposes.
72+
73+
Returns
74+
-------
75+
self : object
76+
Returns self.
77+
"""
78+
# Validation
79+
X = check_array(X)
80+
81+
if self.X_.shape[1] != X.shape[1]:
82+
raise ValueError('Shape of input is different from what was seen'
83+
'in `fit`')
84+
85+
# Add new examples
86+
self.X_ = np.vstack((self.X_, X))
87+
5388
return self
5489

55-
def predict(self, X, **kwargs):
56-
""" A reference implementation of a prediction for a classifier.
90+
def transform(self, X, **kwargs):
91+
"""Transform given array into expected values in normal conditions.
5792
5893
Parameters
5994
----------
60-
X : array-like, shape (n_samples, n_features)
95+
X : array-like of shape (n_samples, n_features)
6196
The input samples.
6297
6398
Returns
6499
-------
65-
X_nc : ndarray, shape (n_samples, n_features)
100+
X_nc : ndarray of shape (n_samples, n_features)
66101
Expected values in normal conditions for each sample and feature.
67102
"""
68103
# Validation

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.http://sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/source/aakr.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
aakr package
2+
============
3+
4+
Module contents
5+
---------------
6+
7+
.. automodule:: aakr
8+
:members:
9+
:undoc-members:
10+
:show-inheritance:

docs/source/conf.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ def add_source_parser(_old_add_source_parser, self, *args, **kwargs):
4141

4242
# -- Project information -----------------------------------------------------
4343

44-
project = 'finscraper'
44+
project = 'aakr'
4545
copyright = '2020, Jesse Myrberg'
4646
author = 'Jesse Myrberg'
4747

4848
# The full version, including alpha/beta/rc tags
4949
with open('../../VERSION', 'r') as f:
50-
release = f.read().strip()
50+
version = f.read().strip()
51+
release = version
5152

5253

5354
# -- General configuration ---------------------------------------------------
@@ -56,10 +57,15 @@ def add_source_parser(_old_add_source_parser, self, *args, **kwargs):
5657
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
5758
# ones.
5859
extensions = [
59-
'm2r',
60+
'm2r2',
6061
'sphinxcontrib.napoleon',
61-
'sphinx.ext.autodoc',
6262
'sphinx_rtd_theme',
63+
'sphinx.ext.autodoc',
64+
'sphinx.ext.autosummary',
65+
'sphinx.ext.doctest',
66+
'sphinx.ext.intersphinx',
67+
'sphinx.ext.viewcode',
68+
'numpydoc'
6369
]
6470

6571
# Autodoc settings
@@ -102,13 +108,13 @@ def add_source_parser(_old_add_source_parser, self, *args, **kwargs):
102108

103109
html_theme_options = {
104110
'canonical_url': '',
105-
#'analytics_id': 'UA-XXXXXXX-1', # Provided by Google in your dashboard
111+
# 'analytics_id': 'UA-XXXXXXX-1', # Provided by Google in your dashboard
106112
'logo_only': False,
107113
'display_version': True,
108114
'prev_next_buttons_location': 'bottom',
109115
'style_external_links': False,
110-
#'vcs_pageview_mode': '',
111-
#'style_nav_header_background': 'white',
116+
# 'vcs_pageview_mode': '',
117+
# 'style_nav_header_background': 'white',
112118
# Toc options
113119
'collapse_navigation': True,
114120
'sticky_navigation': True,
@@ -120,4 +126,4 @@ def add_source_parser(_old_add_source_parser, self, *args, **kwargs):
120126
# Add any paths that contain custom static files (such as style sheets) here,
121127
# relative to this directory. They are copied after the builtin static files,
122128
# so a file named "default.css" will overwrite the builtin "default.css".
123-
html_static_path = ['_static']
129+
html_static_path = ['_static']

docs/source/index.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.. include:: readme.rst
2+
3+
.. toctree::
4+
:caption: Documentation
5+
:maxdepth: 2
6+
7+
Getting started <readme.rst>
8+
9+
.. toctree::
10+
:caption: API
11+
:maxdepth: 4
12+
13+
aakr

docs/source/readme.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.. mdinclude:: ../../README.md

requirements-dev.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
pytest==5.4.2
2-
twine==3.2.0
2+
pytest-cov==2.10.1
3+
twine==3.2.0
4+
sphinx==3.3.1
5+
sphinx_rtd_theme==0.5.0
6+
numpydoc==1.1.0
7+
m2r2==0.2.7
8+
sphinxcontrib-napoleon==0.7

scripts/build-documentation.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/bin/sh
22

3-
conda activate finscraper && \
3+
conda activate aakr && \
44
rm -rf docs/build && \
5-
sphinx-apidoc -f -o docs/source finscraper && \
5+
sphinx-apidoc -f -o docs/source aakr && \
66
rm -rf docs/source/modules.rst && \
77
sphinx-build -b html docs/source docs/build
8-
open -a /Applications/Safari.app file://~/Documents/Personal/finscraper/docs/build/index.html
8+
open -a /Applications/Safari.app file:///Users/e103089/Documents/Personal/aakr/docs/build/index.html

0 commit comments

Comments
 (0)