Skip to content

Commit 278caba

Browse files
authored
Create initial docs (yewsg#4)
* init docs by sphinx. * Update documentation theme to blue * add doc to README
1 parent bc83bbd commit 278caba

18 files changed

+318
-168
lines changed

Diff for: README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Yews | Your Earthquake Waveform Solution
1717
.. image:: https://codecov.io/gh/lijunzh/yews/branch/master/graph/badge.svg
1818
:target: https://codecov.io/gh/lijunzh/yews
1919

20-
.. image:: https://anaconda.org/lijunzhu/yews/badges/version.svg
20+
.. image:: https://anaconda.org/lijunzhu/yews/badges/version.svg
2121
:target: https://anaconda.org/lijunzhu/yews
2222

2323
.. image:: https://badge.fury.io/py/yews.svg
@@ -72,7 +72,7 @@ Note:
7272
Documentation
7373
=============
7474

75-
Under construction.
75+
You can find the API documentation on the yews website: https://yews.info
7676

7777
Contributing
7878
============

Diff for: docs/requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sphinx
2+
-e git://github.com/snide/sphinx_rtd_theme.git#egg=sphinx_rtd_theme

Diff for: docs/source/_static/css/yews_theme.css

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
body {
22
font-family: "Lato","proxima-nova","Helvetica Neue",Arial,sans-serif;
3+
font-size: 1.2em;
4+
line-height: 2.0;
35
}
46

57
/* Default header fonts are ugly */
68
h1, h2, .rst-content .toctree-wrapper p.caption, h3, h4, h5, h6, legend, p.caption {
79
font-family: "Lato","proxima-nova","Helvetica Neue",Arial,sans-serif;
810
}
911

12+
/* Transform the title to uppercase */
13+
h1 {
14+
text-transform: uppercase;
15+
}
16+
1017
/* Use white for docs background */
1118
.wy-side-nav-search {
1219
background-color: #fff;
@@ -59,8 +66,7 @@ h1, h2, .rst-content .toctree-wrapper p.caption, h3, h4, h5, h6, legend, p.capti
5966

6067
/* Use our red for literals (it's very similar to the original color) */
6168
.rst-content tt.literal, .rst-content tt.literal, .rst-content code.literal {
62-
/*color: #F05732;*/
63-
color: #2D572C;
69+
color: #2980b9;
6470
}
6571

6672
.rst-content tt.xref, a .rst-content tt, .rst-content tt.xref,
@@ -69,21 +75,17 @@ h1, h2, .rst-content .toctree-wrapper p.caption, h3, h4, h5, h6, legend, p.capti
6975
}
7076

7177
/* Change link colors (except for the menu) */
72-
7378
a {
74-
/*color: #F05732;*/
75-
color: #386D37;
79+
color: #2980b9;
7680
}
7781

7882
a:hover {
79-
/*color: #F05732;*/
80-
color: #386D37;
83+
color: #2980b9;
8184
}
8285

8386

8487
a:visited {
85-
/*color: #D44D2C;*/
86-
color: #244623
88+
color: #2980b9;
8789
}
8890

8991
.wy-menu a {

Diff for: docs/source/conf.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
# If extensions (or modules to document with autodoc) are in another directory,
1212
# add these directories to sys.path here. If the directory is relative to the
1313
# documentation root, use os.path.abspath to make it absolute, like shown here.
14-
#
14+
1515
# import os
1616
# import sys
17-
# sys.path.insert(0, os.path.abspath('.'))
17+
# sys.path.insert(0, os.path.abspath('..'))
1818
import sphinx_rtd_theme
19+
import yews
1920

2021

2122
# -- Project information -----------------------------------------------------
@@ -25,7 +26,7 @@
2526
author = 'Lijun Zhu'
2627

2728
# The short X.Y version
28-
version = 'master (' + '0.0.1' + ')'
29+
version = 'master (' + yews.__version__ + ')'
2930
# The full version, including alpha/beta/rc tags
3031
release = 'master'
3132

Diff for: docs/source/dataset.rst

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
yews.datasets
2+
====================
3+
4+
All datasets are subclasses of :class:`torch.utils.data.Dataset`
5+
i.e, they have ``__getitem__`` and ``__len__`` methods implemented.
6+
Hence, they can all be passed to a :class:`torch.utils.data.DataLoader`
7+
which can load multiple samples parallelly using ``torch.multiprocessing`` workers.
8+
For example: ::
9+
10+
waveform_data = yews.datasets.Folder('path/to/waveform_folder_root/')
11+
data_loader = torch.utils.data.DataLoader(waveform_data,
12+
batch_size=4,
13+
shuffle=True,
14+
num_workers=args.nThreads)
15+
16+
The following datasets are available:
17+
18+
.. contents:: Datasets
19+
:local:
20+
21+
All the datasets have almost similar API. They all have two common arguments:
22+
``transform`` and ``target_transform`` to transform the input and target
23+
respectively.
24+
25+
26+
.. currentmodule:: yews.datasets
27+
28+
29+
DatasetArray
30+
~~~~~~~~~~~~~~~~~~~~~
31+
32+
.. autoclass:: DatasetArray
33+
:members: __getitem__
34+
:special-members:
35+
36+
DatasetFolder
37+
~~~~~~~~~~~~~~~~~~~~~
38+
39+
.. autoclass:: DatasetFolder
40+
:members: __getitem__
41+
:special-members:

Diff for: docs/source/index.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ seismic transformation for processing seismic waveforms using deep learning.
1010

1111
dataset
1212
models
13-
transform
13+
transforms
1414
train
1515

1616
.. automodule:: yews
17-
17+
:members:

Diff for: docs/source/models.rst

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
yews.models
2+
===========
3+
4+
The models subpackage contains definitions for the following model
5+
architectures:
6+
7+
.. contents:: Models
8+
:local:
9+
10+
.. currentmodule:: yews.models
11+
12+
CPIC
13+
----
14+
15+
.. autofunction:: cpic64

Diff for: docs/source/train.rst

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
yews.train
2+
----------
3+
4+
.. currentmodule:: yews.train
5+
6+
.. autoclass:: Trainer
7+
:members: train, validate
8+
:special-members:

Diff for: docs/source/transforms.rst

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
yews.transforms
2+
======================
3+
4+
.. currentmodule:: yews.transforms
5+
6+
Transforms are common waveform transformations. They can be chained together using :class:`Compose`.
7+
Additionally, there is the :mod:`yews.transforms.functional` module.
8+
Functional transforms give fine-grained control over the transformations.
9+
This is useful if you have to build a more complex transformation pipeline.
10+
11+
.. autoclass:: Compose
12+
13+
Transforms on Numpy Array
14+
-------------------------
15+
16+
.. autoclass:: ZeroMean
17+
18+
.. autoclass:: SoftClip
19+
20+
.. autoclass:: CutWaveform
21+
22+
Conversion Transforms
23+
---------------------
24+
25+
.. autoclass:: ToTensor
26+
:members: __call__
27+
:special-members:
28+
29+
Functional Transforms
30+
---------------------
31+
32+
Functional transforms give you fine-grained control of the transformation pipeline.
33+
As opposed to the transformations above, functional transforms don't contain a random number
34+
generator for their parameters.
35+
That means you have to specify/generate all parameters, but you can reuse the functional transform.
36+
For example, you can apply a functional transform to multiple images like this:
37+
38+
TODO: need to replace the image example by a seismic waveform example below:
39+
40+
.. code:: python
41+
42+
import yews.transforms.functional as TF
43+
import random
44+
45+
def my_segmentation_transforms(image, segmentation):
46+
if random.random() > 5:
47+
angle = random.randint(-30, 30)
48+
image = TF.rotate(image, angle)
49+
segmentation = TF.rotate(segmentation, angle)
50+
# more transforms ...
51+
return image, segmentation
52+
53+
.. automodule:: yews.transforms.functional
54+
:members:
55+

Diff for: yews/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
__summary__,
55
)
66

7-
from yews import dataset
7+
from yews import datasets
88
from yews import transforms
99
from yews import train
1010
from yews import models

Diff for: yews/dataset/__init__.py

-10
This file was deleted.

Diff for: yews/dataset/array.py

-44
This file was deleted.

Diff for: yews/dataset/classification.py

-51
This file was deleted.

Diff for: yews/dataset/folder.py

-46
This file was deleted.

0 commit comments

Comments
 (0)