Skip to content

Commit 848d47d

Browse files
committed
Restore commented np.random.seed
1 parent 53c8fa6 commit 848d47d

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

advanced/mathematical_optimization/index.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,20 +881,22 @@ Curve fitting
881881
:target: auto_examples/plot_curve_fit.html
882882
:align: right
883883

884+
.. Comment to make doctest pass
885+
>>> np.random.seed(0)
886+
884887
Least square problems occur often when fitting a non-linear to data.
885888
While it is possible to construct our optimization problem ourselves,
886889
scipy provides a helper function for this purpose:
887890
:func:`scipy.optimize.curve_fit`::
888891

889-
>>> np.random.seed(0) #doctest: +SKIP
890892

891893
>>> def f(t, omega, phi):
892894
... return np.cos(omega * t + phi)
893895
894896
>>> x = np.linspace(0, 3, 50)
895897
>>> y = f(x, 1.5, 1) + .1*np.random.normal(size=50)
896898

897-
>>> optimize.curve_fit(f, x, y) #doctest: +SKIP
899+
>>> optimize.curve_fit(f, x, y)
898900
(array([ 1.51854577, 0.92665541]), array([[ 0.00037994, -0.00056796],
899901
[-0.00056796, 0.00123978]]))
900902

intro/scipy.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,12 @@ our initial guess: ::
446446

447447
**Curve fitting**
448448

449+
.. Comment to make doctest pass
450+
>>> np.random.seed(42)
451+
449452
Suppose we have data sampled from ``f`` with some noise: ::
450453

451-
>>> np.random.seed(42)
454+
452455
>>> xdata = np.linspace(-10, 10, num=20)
453456
>>> ydata = f(xdata) + np.random.randn(xdata.size)
454457

0 commit comments

Comments
 (0)