Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update scipy #817

Merged
merged 4 commits into from
Jan 21, 2025
Merged

Update scipy #817

merged 4 commits into from
Jan 21, 2025

Conversation

jarrodmillman
Copy link
Member

@jarrodmillman jarrodmillman commented Jan 10, 2025

@mdhaber We are getting this error with 1.15.0 and 1.15.1

367     >>> sp.stats.wilcoxon(data['VIQ'])
Expected:
    WilcoxonResult(statistic=np.float64(0.0), pvalue=np.float64(1.8189894...e-12))
Got:
    WilcoxonResult(statistic=np.float64(0.0), pvalue=np.float64(3.488172636231201e-08))

/home/runner/work/scientific-python-lectures/scientific-python-lectures/packages/statistics/index.rst:367: DocTestFailure

Thoughts?

@mdhaber
Copy link
Contributor

mdhaber commented Jan 12, 2025

I discussed this with Stefan the other day.

The different result with SciPy 1.15.0 comes from the fact that we switched the method that is used automatically in case of ties. It used to be the "exact" method, which is by no means "exact" in case of ties.

So I think it would be fine to change the reference value.

@jarrodmillman jarrodmillman force-pushed the sp-1.15 branch 5 times, most recently from c489c2c to 4b059ba Compare January 15, 2025 07:49
@jarrodmillman
Copy link
Member Author

We are sometimes seeing this error now

884     >>> def f(x):
885     ...     return np.arctan(x) - np.arctan(np.linspace(0, 1, len(x)))
886 
887     >>> x0 = np.zeros(10)
888     >>> sp.optimize.leastsq(f, x0)
Expected:
    (array([0.        , 0.11111111, 0.22222222, 0.33333333, 0.44444444,
           0.55555556, 0.66666667, 0.77777778, 0.88888889, 1.        ]), 2)
Got:
    (array([0.        , 0.11111111, 0.22222222, 0.33333333, 0.44444444,
           0.55555556, 0.66666667, 0.77777778, 0.88888889, 1.        ]), 4)

/Users/runner/work/scientific-python-lectures/scientific-python-lectures/advanced/mathematical_optimization/index.rst:888: DocTestFailure

@stefanv
Copy link
Member

stefanv commented Jan 15, 2025

According to the docstring:

ier : int
    An integer flag. If it is equal to 1, 2, 3 or 4, the solution was
    found. Otherwise, the solution was not found. In either case, the
    optional output variable 'mesg' gives more information.

So, we could set full_output to True to see what the message is.

@jarrodmillman
Copy link
Member Author

Not sure why, but now the stopping criteria for leastsq is either 2 (relative error between iterations) or 4 (cosine of the angle). See https://github.com/scipy/scipy/blob/df134eab5a500c2146ed4552c8674a78d8154ee9/scipy/optimize/_minpack_py.py#L451 for more details.

@jarrodmillman jarrodmillman merged commit d833058 into scipy-lectures:main Jan 21, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants