Skip to content

Commit

Permalink
Romberg is deprecated... (#1131)
Browse files Browse the repository at this point in the history
and will be removed by SciPyi 1.15
  • Loading branch information
rocky authored Oct 22, 2024
1 parent 712337b commit 8c472bd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ API incompatibility
-------------------

* ``Matcher`` now requires an additional ``evaluation`` parameter
* ``Romberg`` removed as an ``NIntegrate[]`` method. It is depcrecated in SciPy and is to be removed by SciPy 1.15.


Bugs
Expand Down
18 changes: 3 additions & 15 deletions mathics/builtin/scipy_utils/integrators.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
if not check_requires_list(["scipy", "numpy"]):
raise ImportError

import numpy as np


def _scipy_interface(integrator, options_map, mandatory=None, adapt_func=None):
"""
Expand All @@ -24,7 +22,8 @@ def _scipy_proxy_func_filter(fun, a, b, **opts):
if native_opt[1]:
val = native_opt[1](val)
native_opts[native_opt[0]] = val
return adapt_func(integrator(fun, a, b, **native_opts))
if adapt_func is not None:
return adapt_func(integrator(fun, a, b, **native_opts))

def _scipy_proxy_func(fun, a, b, **opts):
native_opts = {}
Expand All @@ -42,7 +41,7 @@ def _scipy_proxy_func(fun, a, b, **opts):


try:
from scipy.integrate import nquad, quad, romberg
from scipy.integrate import nquad, quad
except Exception:
scipy_nintegrate_methods = {}
else:
Expand All @@ -69,17 +68,6 @@ def _scipy_proxy_func(fun, a, b, **opts):
False,
)
),
"Romberg": tuple(
(
_scipy_interface(
romberg,
{"tol": ("tol", None), "maxrec": ("divmax", None)},
None,
lambda x: (x, np.nan),
),
False,
)
),
}

scipy_nintegrate_methods["Automatic"] = scipy_nintegrate_methods["Quadrature"]
Expand Down
4 changes: 2 additions & 2 deletions test/builtin/numbers/test_nintegrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from mathics.core.builtin import check_requires_list

if check_requires_list(["scipy", "scipy.integrate"]):
methods = ["Automatic", "Romberg", "Internal", "NQuadrature"]
methods = ["Automatic", "Internal", "NQuadrature"]

generic_tests_for_nintegrate = [
(r"NIntegrate[x^2, {x,0,1}, {method} ]", r"1/3.", ""),
Expand Down Expand Up @@ -46,7 +46,7 @@
"1.",
None,
[
r"The Method option should be a built-in method name in {`Automatic`, `Internal`, `Simpson`, `NQuadrature`, `Quadrature`, `Romberg`}. Using `Automatic`"
r"The Method option should be a built-in method name in {`Automatic`, `Internal`, `Simpson`, `NQuadrature`, `Quadrature`}. Using `Automatic`"
],
),
],
Expand Down
Empty file added test/core/__init__.py
Empty file.

0 comments on commit 8c472bd

Please sign in to comment.