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

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

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

Edward Richards
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.

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,
ax[1, 1].plot(*CubicSpline(parametic_nodes(1), p.T,

SciPy-User mailing list
[hidden email]