diff --git a/.readthedocs.yml b/.readthedocs.yml index 3ec8ab9..25fc682 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -5,7 +5,4 @@ sphinx: python: install: - - method: pip - path: . - extra_requirements: - - docs + - requirements: doc/requirements.txt diff --git a/doc/conf.py b/doc/conf.py index 9f53bd3..ee3b0d7 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -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 @@ -40,6 +40,7 @@ # ones. extensions = ['sphinx_automodapi.automodapi', 'numpydoc', + 'jupyter_sphinx', ] numpydoc_show_class_members = False @@ -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, diff --git a/doc/index.rst b/doc/index.rst index 4ffcbe4..fa501b1 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -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. @@ -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 diff --git a/doc/requirements.txt b/doc/requirements.txt new file mode 100644 index 0000000..8bcf348 --- /dev/null +++ b/doc/requirements.txt @@ -0,0 +1,7 @@ +jupyter-sphinx +numpydoc +pydata-sphinx-theme +sphinx +sphinx-automodapi +sphinx_rtd_theme +streamtracer diff --git a/setup.cfg b/setup.cfg index aa8e8b5..eb4a48c 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,7 +21,9 @@ tests = pytest pytest-cov docs = + jupyter-sphinx numpydoc + pydata-sphinx-theme sphinx sphinx-automodapi sphinx_rtd_theme diff --git a/streamtracer/streamline.py b/streamtracer/streamline.py index d79bcf2..18d5f0e 100755 --- a/streamtracer/streamline.py +++ b/streamtracer/streamline.py @@ -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):