Skip to content

Commit

Permalink
Merge pull request #66 from dstansby/doc-ex
Browse files Browse the repository at this point in the history
Fix doc example
  • Loading branch information
dstansby authored Aug 5, 2021
2 parents 4d7a11b + 123663d commit 867453e
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 10 deletions.
5 changes: 1 addition & 4 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@ sphinx:

python:
install:
- method: pip
path: .
extra_requirements:
- docs
- requirements: doc/requirements.txt
5 changes: 3 additions & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# -- Project information -----------------------------------------------------

project = 'streamtracer'
copyright = '2019, David Stansby'
copyright = '2019-2021, David Stansby'
author = 'David Stansby'

# The full version, including alpha/beta/rc tags
Expand All @@ -40,6 +40,7 @@
# ones.
extensions = ['sphinx_automodapi.automodapi',
'numpydoc',
'jupyter_sphinx',
]
numpydoc_show_class_members = False

Expand All @@ -57,7 +58,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = 'pydata_sphinx_theme'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand Down
29 changes: 25 additions & 4 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,39 @@ streamtracer is a python package for rapid streamline tracing. It is a wrapper
to compiled fortran code that does the heavy lifting, and is therefore
relatively fast.

To use, create a :class:`streamtracer.StreamTracer` object::
To use, create a :class:`streamtracer.StreamTracer` object

.. jupyter-execute::

import numpy as np
from streamtracer import StreamTracer, VectorGrid

nsteps = 10000
step_size = 0.1
tracer = StreamTracer(nsteps, step_size)

and a :class:`streamtracer.VectorGrid`::
and a :class:`streamtracer.VectorGrid`

.. jupyter-execute::

field = np.ones((10, 10, 10, 3))
grid_spacing = [1, 2, 1]
grid = VectorGrid(field, grid_spacing)

This can then be used to trace lines through a 3D cartesian vector field::
This can then be used to trace lines through a 3D cartesian vector field

.. jupyter-execute::

seeds = np.array([[0, 0, 0], [0, 0, 1]])
streamlines = StreamTracer.trace(seeds, grid)
tracer.trace(seeds, grid)

and the traced field lines can be accessed via. the ``.xs`` attribute

.. jupyter-execute::

print(f'Number of traced lines: {len(tracer.xs)}')
line_lengths = [len(x) for x in tracer.xs]
print(f'Line lengths: {line_lengths}')

For more information see the :mod:`streamtracer` API docs.

Expand Down Expand Up @@ -52,6 +69,10 @@ Code reference
Changelog
=========

1.1.2
-----
Fixed the example code listed above.

1.1.1
-----
Fixed wheel building to use the oldest supported version of numpy for each
Expand Down
7 changes: 7 additions & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
jupyter-sphinx
numpydoc
pydata-sphinx-theme
sphinx
sphinx-automodapi
sphinx_rtd_theme
streamtracer
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ tests =
pytest
pytest-cov
docs =
jupyter-sphinx
numpydoc
pydata-sphinx-theme
sphinx
sphinx-automodapi
sphinx_rtd_theme
1 change: 1 addition & 0 deletions streamtracer/streamline.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class StreamTracer:
def __init__(self, max_steps, step_size):
self.max_steps = max_steps
self.ds = step_size
self.xs = None

@property
def max_steps(self):
Expand Down

0 comments on commit 867453e

Please sign in to comment.