From 4683870d2dba9e16ff15901a757b7ae54efbf2dd Mon Sep 17 00:00:00 2001 From: Kyle Sunden Date: Tue, 29 Nov 2022 16:46:02 -0600 Subject: [PATCH 1/2] Fill out example descriptions, including crossreferences --- docs/source/api/index.rst | 5 +++++ docs/source/index.rst | 2 +- examples/2Dfunc.py | 3 ++- examples/animation.py | 2 ++ examples/data_frame.py | 7 ++++--- examples/errorbar.py | 9 +++++---- examples/first.py | 3 ++- examples/hist.py | 3 ++- examples/lissajous.py | 19 +++++-------------- examples/mandelbrot.py | 4 ++++ examples/mulivariate_cmap.py | 8 +++++--- examples/simple_patch.py | 4 ++++ examples/simple_scatter.py | 3 ++- 13 files changed, 43 insertions(+), 29 deletions(-) diff --git a/docs/source/api/index.rst b/docs/source/api/index.rst index d7e21ef..aea4358 100644 --- a/docs/source/api/index.rst +++ b/docs/source/api/index.rst @@ -18,3 +18,8 @@ Wrappers .. automodule:: data_prototype.wrappers :members: + :undoc-members: + +.. automodule:: data_prototype.patches + :members: + :undoc-members: diff --git a/docs/source/index.rst b/docs/source/index.rst index 1c91676..14d732a 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -18,8 +18,8 @@ Examples .. toctree:: :maxdepth: 2 - gallery/index.rst api/index.rst + gallery/index.rst Backmatter ---------- diff --git a/examples/2Dfunc.py b/examples/2Dfunc.py index 9bd6dd4..6d200de 100644 --- a/examples/2Dfunc.py +++ b/examples/2Dfunc.py @@ -3,7 +3,8 @@ A functional 2D image ===================== - +A 2D image generated using :class:`.containers.FuncContainer` and +:class:`wrappers.ImageWrapper`. """ import matplotlib.pyplot as plt diff --git a/examples/animation.py b/examples/animation.py index 77161e3..316dbaf 100644 --- a/examples/animation.py +++ b/examples/animation.py @@ -3,6 +3,8 @@ An animated line ================ +An animated line using a custom container class, +:class:`.wrappers.LineWrapper`, and :class:`.wrappers.FormatedText`. """ import time diff --git a/examples/data_frame.py b/examples/data_frame.py index c8deff6..00eaff7 100644 --- a/examples/data_frame.py +++ b/examples/data_frame.py @@ -1,9 +1,10 @@ """ -================= +=============== Show data frame -================= +=============== -The hello-world +Wrapping a :class:`pandas.DataFrame` using :class:`.containers.DataFrameContainer` +and :class:`.wrappers.LineWrapper`. """ import matplotlib.pyplot as plt diff --git a/examples/errorbar.py b/examples/errorbar.py index 5eddb70..6e0451e 100644 --- a/examples/errorbar.py +++ b/examples/errorbar.py @@ -1,9 +1,10 @@ """ -================= -Show data frame -================= +============== +Errorbar graph +============== -The hello-world +Using :class:`.containers.ArrayContainer` and :class:`.wrappers.ErrorbarWrapper` +to plot a graph with error bars. """ import matplotlib.pyplot as plt diff --git a/examples/first.py b/examples/first.py index 5cda3d7..50ac6b9 100644 --- a/examples/first.py +++ b/examples/first.py @@ -3,7 +3,8 @@ A functional line ================= -The hello-world +Demonstrating the differences between :class:`.containers.FuncContainer` and +:class:`.containers.SeriesContainer` using :class:`.wrappers.LineWrapper`. """ import matplotlib.pyplot as plt diff --git a/examples/hist.py b/examples/hist.py index 8cf1c6b..1853862 100644 --- a/examples/hist.py +++ b/examples/hist.py @@ -3,7 +3,8 @@ A re-binning histogram ====================== - +A :class:`.containers.HistContainer` which is used with :class:`.wrappers.StepWrapper` +to provide a histogram which recomputes the bins based on a range selected. """ import matplotlib.pyplot as plt diff --git a/examples/lissajous.py b/examples/lissajous.py index 85706f3..0a9c710 100644 --- a/examples/lissajous.py +++ b/examples/lissajous.py @@ -5,6 +5,7 @@ Inspired by https://twitter.com/_brohrer_/status/1584681864648065027 +An animated scatter plot using a custom container and :class:`.wrappers.PathCollectionWrapper` """ import time @@ -19,7 +20,7 @@ from data_prototype.containers import _MatplotlibTransform, Desc -from data_prototype.wrappers import PathCollectionWrapper, FormatedText +from data_prototype.wrappers import PathCollectionWrapper class Lissajous: @@ -31,7 +32,6 @@ def describe(self): return { "x": Desc([self.N], float), "y": Desc([self.N], float), - "phase": Desc([], float), "time": Desc([], float), "sizes": Desc([], float), "paths": Desc([], float), @@ -53,7 +53,6 @@ def next_time(): return { "x": np.cos(5 * phase), "y": np.sin(3 * phase), - "phase": phase[0], "sizes": np.array([256]), "paths": [marker_obj.get_path().transformed(marker_obj.get_transform())], "edgecolors": "k", @@ -70,27 +69,19 @@ def update(frame, art): sot_c = Lissajous() -fc = FormatedText( - sot_c, - {"text": lambda phase: f"ϕ={phase:.2f} "}, - x=1, - y=1, - ha="right", -) fig, ax = plt.subplots() ax.set_xlim(-1.1, 1.1) ax.set_ylim(-1.1, 1.1) lw = PathCollectionWrapper(sot_c, offset_transform=ax.transData) ax.add_artist(lw) -ax.add_artist(fc) # ax.set_xticks([]) # ax.set_yticks([]) ax.set_aspect(1) ani = FuncAnimation( fig, - partial(update, art=(lw, fc)), - frames=60 * 15, - interval=1000 / 100, + partial(update, art=(lw,)), + frames=60, + interval=1000 / 100 * 15, # TODO: blitting does not work because wrappers do not inherent from Artist # blit=True, ) diff --git a/examples/mandelbrot.py b/examples/mandelbrot.py index ba4914c..8a4b878 100644 --- a/examples/mandelbrot.py +++ b/examples/mandelbrot.py @@ -3,6 +3,10 @@ (Infinitly) Zoomable Mandelbrot Set =================================== +A mandelbrot set which is computed using a :class:`.containers.FuncContainer` +and represented using a :class:`wrappers.ImageWrapper`. + +The mandelbrot recomputes as it is zoomed in and/or panned. """ diff --git a/examples/mulivariate_cmap.py b/examples/mulivariate_cmap.py index f737bbc..8b6377e 100644 --- a/examples/mulivariate_cmap.py +++ b/examples/mulivariate_cmap.py @@ -1,9 +1,11 @@ """ -===================== -A functional 2D image -===================== +========================= +Custom bivariate colormap +========================= +Using ``nu`` functions to account for two values when computing the color +of each pixel. """ import matplotlib.pyplot as plt diff --git a/examples/simple_patch.py b/examples/simple_patch.py index 53f0fb8..48f1c2a 100644 --- a/examples/simple_patch.py +++ b/examples/simple_patch.py @@ -3,6 +3,10 @@ Simple patch artists ==================== +Draw two fully specified rectangle patches. +Demonstrates :class:`.patches.RectangleWrapper` using +:class:`.containers.ArrayContainer`. + """ import numpy as np diff --git a/examples/simple_scatter.py b/examples/simple_scatter.py index 201edd7..4979a8b 100644 --- a/examples/simple_scatter.py +++ b/examples/simple_scatter.py @@ -3,7 +3,8 @@ An simple scatter plot using PathCollectionWrapper ================================================== -A quick example using ``containers.ArrayContainer`` and ``wrappers.PathCollectionWrapper``. +A quick scatter plot using :class:`.containers.ArrayContainer` and +:class:`.wrappers.PathCollectionWrapper`. """ import numpy as np From aee0d45800f36cd81b574d14b9c2aaaf6027e3f4 Mon Sep 17 00:00:00 2001 From: Kyle Sunden Date: Tue, 29 Nov 2022 17:08:20 -0600 Subject: [PATCH 2/2] Revert order of api and examples --- docs/source/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/index.rst b/docs/source/index.rst index 14d732a..1c91676 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -18,8 +18,8 @@ Examples .. toctree:: :maxdepth: 2 - api/index.rst gallery/index.rst + api/index.rst Backmatter ----------