# [SciPy-User] Is a worked paper example appropriate for documentation?

 Classic List Threaded
2 messages
Reply | Threaded
Open this post in threaded view
|
Report Content as Inappropriate

## [SciPy-User] Is a worked paper example appropriate for documentation?

 I am wondering if simple recipes for recreating paper figures are appropriate for documentation, and if so, where should they be put? I have code to recreate figure 1 from E T Y Lee's paper "Choosing nodes in parametric curve interpolation" (doi: 0010448589900031). I know very little about interpolation, but I worked this example because of the response to mathematica SE question # 10273. It seems to me like a good exploration of some of the more esoteric features of interpolation, and it spans a number of separate scipy.interpolate functions. Would adding code like this help or clutter existing documentation? As a side note I feel that I am late to the party for missing by Docathon a week. Thanks, Ned import numpy as np import matplotlib.pyplot as plt from scipy.interpolate import splprep, splev, CubicSpline p = np.array([[0, 26, 28, 54], [0, 24, 24, 0]]) dp = np.diff(p, axis=-1) def parametic_nodes(escale):      """Compute parametric knots location"""      t = np.hstack((0, np.cumsum(np.linalg.norm(dp, axis=0) ** escale)))      return t / np.max(t) us = np.arange(201) / 200 fig, ax = plt.subplots(2,2) ax[0, 0].plot(*splev(us, splprep(p, u=np.arange(4) / 3, s=0)[0])) ax[0, 0].plot(*splev(us, splprep(p, u=p[0, :] / 54, s=0)[0])) ax[0, 0].plot(*splev(us, splprep(p, u=parametic_nodes(1), s=0)[0])) ax[0, 1].plot(*splev(us, splprep(p, u=parametic_nodes(0), s=0)[0])) ax[0, 1].plot(*splev(us, splprep(p, u=parametic_nodes(0.5), s=0)[0])) ax[0, 1].plot(*splev(us, splprep(p, u=parametic_nodes(1), s=0)[0])) ax[1, 0].plot(*splev(us, splprep(p, u=parametic_nodes(0.35), s=0)[0])) ax[1, 0].plot(*splev(us, splprep(p, u=parametic_nodes(0.5), s=0)[0])) ax[1, 0].plot(*splev(us, splprep(p, u=parametic_nodes(0.65), s=0)[0])) ax[1, 1].plot(*CubicSpline(np.arange(4) / 3, p.T, bc_type='natural')(us).T) ax[1, 1].plot(*CubicSpline(parametic_nodes(0.5), p.T, bc_type='natural')(us).T) ax[1, 1].plot(*CubicSpline(parametic_nodes(1), p.T, bc_type='natural')(us).T) plt.show(block=False) _______________________________________________ SciPy-User mailing list [hidden email] https://mail.python.org/mailman/listinfo/scipy-user
Reply | Threaded
Open this post in threaded view
|
Report Content as Inappropriate

## Re: Is a worked paper example appropriate for documentation?

 On Sun, Mar 19, 2017 at 9:08 AM, Edward Richards wrote:I am wondering if simple recipes for recreating paper figures are appropriate for documentation, and if so, where should they be put? I have code to recreate figure 1 from E T Y Lee's paper "Choosing nodes in parametric curve interpolation" (doi: 0010448589900031). I know very little about interpolation, but I worked this example because of the response to mathematica SE question # 10273. It seems to me like a good exploration of some of the more esoteric features of interpolation, and it spans a number of separate scipy.interpolate functions. Would adding code like this help or clutter existing documentation?I'm not quite sure what to conclude from the plot, but with some more explanatory text it could be a useful. This kind of example would go in the tutorial section of the docs (here http://scipy.github.io/devdocs/tutorial/interpolate.html) As a side note I feel that I am late to the party for missing by Docathon a week.Thanks for showing up - late is much better than never.On Python 2.7, your example will show a very cryptic error:Traceback (most recent call last):  File "tmp13.py", line 17, in     ax[0, 0].plot(*splev(us, splprep(p, u=np.arange(4) / 3, s=0)[0]))  File "/home/rgommers/Code/scipy/scipy/interpolate/fitpack.py", line 151, in splprep    quiet)  File "/home/rgommers/Code/scipy/scipy/interpolate/_fitpack_impl.py", line 281, in splprep    task, ipar, s, t, nest, wrk, iwrk, per)SystemError: error return without exception setThis is due to integer division - you want to change your code so all arrays created with np.arange have float dtype.Also remove the ``block=False`` from the last line, that'll just lead to users confused about why their plot didn't show up.Cheers,Ralf  Thanks, Ned import numpy as np import matplotlib.pyplot as plt from scipy.interpolate import splprep, splev, CubicSpline p = np.array([[0, 26, 28, 54], [0, 24, 24, 0]]) dp = np.diff(p, axis=-1) def parametic_nodes(escale):     """Compute parametric knots location"""     t = np.hstack((0, np.cumsum(np.linalg.norm(dp, axis=0) ** escale)))     return t / np.max(t) us = np.arange(201) / 200 fig, ax = plt.subplots(2,2) ax[0, 0].plot(*splev(us, splprep(p, u=np.arange(4) / 3, s=0)[0])) ax[0, 0].plot(*splev(us, splprep(p, u=p[0, :] / 54, s=0)[0])) ax[0, 0].plot(*splev(us, splprep(p, u=parametic_nodes(1), s=0)[0])) ax[0, 1].plot(*splev(us, splprep(p, u=parametic_nodes(0), s=0)[0])) ax[0, 1].plot(*splev(us, splprep(p, u=parametic_nodes(0.5), s=0)[0])) ax[0, 1].plot(*splev(us, splprep(p, u=parametic_nodes(1), s=0)[0])) ax[1, 0].plot(*splev(us, splprep(p, u=parametic_nodes(0.35), s=0)[0])) ax[1, 0].plot(*splev(us, splprep(p, u=parametic_nodes(0.5), s=0)[0])) ax[1, 0].plot(*splev(us, splprep(p, u=parametic_nodes(0.65), s=0)[0])) ax[1, 1].plot(*CubicSpline(np.arange(4) / 3, p.T, bc_type='natural')(us).T) ax[1, 1].plot(*CubicSpline(parametic_nodes(0.5), p.T, bc_type='natural')(us).T) ax[1, 1].plot(*CubicSpline(parametic_nodes(1), p.T, bc_type='natural')(us).T) plt.show(block=False) _______________________________________________ SciPy-User mailing list [hidden email] https://mail.python.org/mailman/listinfo/scipy-user _______________________________________________ SciPy-User mailing list [hidden email] https://mail.python.org/mailman/listinfo/scipy-user
Loading...