Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-iminuit for openSUSE:Factory 
checked in at 2021-09-16 23:15:04
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-iminuit (Old)
 and      /work/SRC/openSUSE:Factory/.python-iminuit.new.1899 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-iminuit"

Thu Sep 16 23:15:04 2021 rev:16 rq:919558 version:2.8.3

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-iminuit/python-iminuit.changes    
2021-08-11 11:47:41.913711758 +0200
+++ /work/SRC/openSUSE:Factory/.python-iminuit.new.1899/python-iminuit.changes  
2021-09-16 23:17:54.559999406 +0200
@@ -1,0 +2,16 @@
+Thu Sep 16 10:35:47 UTC 2021 - Atri Bhattacharya <[email protected]>
+
+- Update to version 2.8.3:
+  * util.propagate now discriminates between diverging derivates
+    (using the value NaN for the derivate) and non-converging
+    derivatives (using the best value computed so far for the
+    derivative).
+  * Update documentation.
+- Changes from version 2.8.2:
+  * Minuit.draw_mncontour can now be used by passing a single
+    float to keyword cl, in addition to passing a list of floats.
+  * Use pybind11::ssize_t everywhere instead of non-standard
+    ssize_t to fix compilation against Python-3.10 on Windows.
+  * Update documentation.
+
+-------------------------------------------------------------------

Old:
----
  iminuit-2.8.1.tar.gz

New:
----
  iminuit-2.8.3.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-iminuit.spec ++++++
--- /var/tmp/diff_new_pack.53bf1H/_old  2021-09-16 23:17:55.007999869 +0200
+++ /var/tmp/diff_new_pack.53bf1H/_new  2021-09-16 23:17:55.007999869 +0200
@@ -22,7 +22,7 @@
 %define skip_python36 1
 %define modname iminuit
 Name:           python-%{modname}
-Version:        2.8.1
+Version:        2.8.3
 Release:        0
 Summary:        Python bindings for MINUIT2
 License:        MIT

++++++ iminuit-2.8.1.tar.gz -> iminuit-2.8.3.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/iminuit-2.8.1/PKG-INFO new/iminuit-2.8.3/PKG-INFO
--- old/iminuit-2.8.1/PKG-INFO  2021-08-04 11:39:47.882949400 +0200
+++ new/iminuit-2.8.3/PKG-INFO  2021-09-03 17:08:02.901465400 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: iminuit
-Version: 2.8.1
+Version: 2.8.3
 Summary: Jupyter-friendly Python frontend for MINUIT2 in C++
 Home-page: http://github.com/scikit-hep/iminuit
 Author: Piti Ongmongkolkul and the iminuit team
@@ -49,14 +49,11 @@
         - Support for SciPy minimisers
         - Numba support (optional)
         
-        Checkout the comprehensive list of `tutorials`_ that demonstrate these 
features.
+        Checkout our large and comprehensive list of `tutorials`_ that take 
you all the way from beginner to power user. For help and how-to questions, 
please use the `discussions`_ on GitHub.
         
         .. image:: https://mybinder.org/badge_logo.svg
            :target: 
https://mybinder.org/v2/gh/scikit-hep/iminuit/develop?filepath=doc%2Ftutorial
         
-        .. image:: https://img.shields.io/gitter/room/Scikit-HEP/iminuit
-           :alt: Gitter
-        
         In a nutshell
         -------------
         
@@ -86,6 +83,7 @@
         
         .. _changelog: https://iminuit.readthedocs.io/en/stable/changelog.html
         .. _tutorials: https://iminuit.readthedocs.io/en/stable/tutorials.html
+        .. _discussions: https://github.com/scikit-hep/iminuit/discussions
         
 Platform: UNKNOWN
 Classifier: Development Status :: 5 - Production/Stable
@@ -113,3 +111,4 @@
 Requires-Python: >=3.6
 Description-Content-Type: text/x-rst
 Provides-Extra: test
+Provides-Extra: doc
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/iminuit-2.8.1/README.rst new/iminuit-2.8.3/README.rst
--- old/iminuit-2.8.1/README.rst        2021-08-04 11:39:20.000000000 +0200
+++ new/iminuit-2.8.3/README.rst        2021-09-03 17:07:34.000000000 +0200
@@ -37,14 +37,11 @@
 - Support for SciPy minimisers
 - Numba support (optional)
 
-Checkout the comprehensive list of `tutorials`_ that demonstrate these 
features.
+Checkout our large and comprehensive list of `tutorials`_ that take you all 
the way from beginner to power user. For help and how-to questions, please use 
the `discussions`_ on GitHub.
 
 .. image:: https://mybinder.org/badge_logo.svg
    :target: 
https://mybinder.org/v2/gh/scikit-hep/iminuit/develop?filepath=doc%2Ftutorial
 
-.. image:: https://img.shields.io/gitter/room/Scikit-HEP/iminuit
-   :alt: Gitter
-
 In a nutshell
 -------------
 
@@ -74,3 +71,4 @@
 
 .. _changelog: https://iminuit.readthedocs.io/en/stable/changelog.html
 .. _tutorials: https://iminuit.readthedocs.io/en/stable/tutorials.html
+.. _discussions: https://github.com/scikit-hep/iminuit/discussions
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/iminuit-2.8.1/cmake_ext.py 
new/iminuit-2.8.3/cmake_ext.py
--- old/iminuit-2.8.1/cmake_ext.py      2021-08-04 11:39:20.000000000 +0200
+++ new/iminuit-2.8.3/cmake_ext.py      2021-09-03 17:07:34.000000000 +0200
@@ -31,6 +31,11 @@
             f"-DCMAKE_BUILD_TYPE={cfg}",
         ]
 
+        # Adding CMake arguments set as environment variable
+        # (needed e.g. to build for ARM OSx on conda-forge)
+        if "CMAKE_ARGS" in os.environ:
+            cmake_args += [item for item in os.environ["CMAKE_ARGS"].split(" 
") if item]
+
         build_args = ["--config", cfg]  # needed by some generators, e.g. on 
Windows
 
         if self.compiler.compiler_type == "msvc":
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/iminuit-2.8.1/setup.cfg new/iminuit-2.8.3/setup.cfg
--- old/iminuit-2.8.1/setup.cfg 2021-08-04 11:39:47.882949400 +0200
+++ new/iminuit-2.8.3/setup.cfg 2021-09-03 17:08:02.905465400 +0200
@@ -46,12 +46,12 @@
 
 [options.extras_require]
 test = 
-       cmake
        cython
        flake8
        ipykernel
        jax
        jaxlib
+       joblib
        jupyter_client
        matplotlib
        nbconvert
@@ -70,6 +70,12 @@
        sphinx_rtd_theme
        tabulate
        nbsphinx
+doc = 
+       sphinx==4.1
+       sphinx-rtd-theme
+       nbsphinx
+       ipykernel
+       matplotlib
 
 [check-manifest]
 ignore = 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/iminuit-2.8.1/src/fcn.cpp 
new/iminuit-2.8.3/src/fcn.cpp
--- old/iminuit-2.8.1/src/fcn.cpp       2021-08-04 11:39:20.000000000 +0200
+++ new/iminuit-2.8.3/src/fcn.cpp       2021-09-03 17:07:34.000000000 +0200
@@ -31,7 +31,7 @@
     if (cfcn_) {
       return cfcn_(x.size(), x.data());
     } else {
-      py::array_t<double> a(static_cast<ssize_t>(x.size()), x.data());
+      py::array_t<double> a(static_cast<py::ssize_t>(x.size()), x.data());
       return check_value(py::cast<double>(fcn_(a)), x);
     }
   }
@@ -41,7 +41,7 @@
 std::vector<double> FCN::Gradient(const std::vector<double>& x) const {
   ++ngrad_;
   if (array_call_) {
-    py::array_t<double> a(static_cast<ssize_t>(x.size()), x.data());
+    py::array_t<double> a(static_cast<py::ssize_t>(x.size()), x.data());
     return check_vector(py::cast<std::vector<double>>(grad_(a)), x);
   }
   return check_vector(py::cast<std::vector<double>>(grad_(*py::cast(x))), x);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/iminuit-2.8.1/src/iminuit/minuit.py 
new/iminuit-2.8.3/src/iminuit/minuit.py
--- old/iminuit-2.8.1/src/iminuit/minuit.py     2021-08-04 11:39:20.000000000 
+0200
+++ new/iminuit-2.8.3/src/iminuit/minuit.py     2021-09-03 17:07:34.000000000 
+0200
@@ -1704,7 +1704,7 @@
         bound: Union[float, Tuple[Tuple[float, float], Tuple[float, float]]] = 
2,
     ) -> Tuple[Collection[float], Collection[float], 
Collection[Collection[float]]]:
         """
-        Draw 2D contour around minimum (required matplotlib).
+        Draw 2D contour around minimum (requires matplotlib).
 
         See :meth:`contour` for details on parameters and interpretation. 
Please also read
         the docs of :meth:`mncontour` to understand the difference between the 
two.
@@ -1744,22 +1744,26 @@
 
         Parameters
         ----------
-        x :
+        x : str
             Variable name of the first parameter.
-        y :
+        y : str
             Variable name of the second parameter.
-        cl :
+        cl : float or None
             Confidence level of the contour. If None, a standard 68 % contour 
is computed
-            (Default: None). Setting this to another value requires the scipy 
module to
+            (default: None). Setting this to another value requires the scipy 
module to
             be installed.
-        size :
-            Number of points on the contour to find. Default 100. Increasing 
this makes
+        size : int
+            Number of points on the contour to find (default: 100). Increasing 
this makes
             the contour smoother, but requires more computation time.
 
         Returns
         -------
         points : array of float (N x 2)
             Contour points of the form [[x1, y1]...[xn, yn]].
+            Note that the last point [xn, yn] is not identical to [x1, y1]. To 
draw a
+            closed contour, please use a closed polygon, like 
matplotlib.patch.Polygon
+            with the closed=True option, or simulate a closed curve by 
appending the
+            first point at the end of the array.
 
         See Also
         --------
@@ -1796,37 +1800,67 @@
         return np.array(ce)
 
     def draw_mncontour(
-        self, x: str, y: str, *, cl: Optional[Iterable[float]] = None, size: 
int = 100
+        self,
+        x: str,
+        y: str,
+        *,
+        cl: Optional[Iterable[float]] = None,
+        size: int = 100,
     ) -> Any:
         """
         Draw 2D Minos confidence region (requires matplotlib).
 
-        See :meth:`mncontour` for details on parameters and interpretation.
+        See :meth:`mncontour` for details on the interpretation of the region.
+
+        Parameters
+        ----------
+        x :
+            Variable name of the first parameter.
+        y :
+            Variable name of the second parameter.
+        cl : int, list of int, or None
+            Confidence level(s) of the contour(s) (default: None). If None 
(default),
+            a standard 68 % contour is drawn. It is possible to draw several 
contours by
+            passing a list of confidence levels between zero and one. Setting 
this to
+            value other than None requires the scipy module to be installed.
+        size :
+            Number of points on each contour(s) (default: 100). Increasing 
this makes
+            the contour smoother, but requires more computation time.
 
         Examples
         --------
         .. plot:: plots/mncontour.py
             :include-source:
 
+        Returns
+        -------
+        ContourSet
+            Instance of a ContourSet class from matplot.contour.
+
         See Also
         --------
         mncontour
         """
         from matplotlib import pyplot as plt
+        from matplotlib.path import Path
         from matplotlib.contour import ContourSet
 
-        cls = [None] if cl is None else cl
+        cls = cl if isinstance(cl, Iterable) else [cl]
 
         c_val = []
         c_pts = []
+        codes = []
         for cl in cls:  # type:ignore
             pts = self.mncontour(x, y, cl=cl, size=size)
-            # close curve
-            pts = list(pts)
-            pts.append(pts[0])
+            # add extra point whose coordinates are ignored
+            pts = np.append(pts, pts[:1], axis=0)
             c_val.append(cl if cl is not None else 0.68)
             c_pts.append([pts])  # level can have more than one contour in mpl
-        cs = ContourSet(plt.gca(), c_val, c_pts)
+            codes.append(
+                [[Path.MOVETO] + [Path.LINETO] * (size - 2) + [Path.CLOSEPOLY]]
+            )
+        assert len(c_val) == len(codes), f"{len(c_val)} {len(codes)}"
+        cs = ContourSet(plt.gca(), c_val, c_pts, codes)
         plt.clabel(cs)
         plt.xlabel(x)
         plt.ylabel(y)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/iminuit-2.8.1/src/iminuit/util.py 
new/iminuit-2.8.3/src/iminuit/util.py
--- old/iminuit-2.8.1/src/iminuit/util.py       2021-08-04 11:39:20.000000000 
+0200
+++ new/iminuit-2.8.3/src/iminuit/util.py       2021-09-03 17:07:34.000000000 
+0200
@@ -890,7 +890,7 @@
 
 
 def _jacobi(
-    fn: Callable, x: np.ndarray, dx: np.ndarray, tol: float
+    fn: Callable, x: np.ndarray, dx: np.ndarray, tol: float, debug: bool = 
False
 ) -> Tuple[np.ndarray, np.ndarray]:
     assert x.ndim == 1
     assert dx.ndim == 1
@@ -900,6 +900,7 @@
     yrank = np.ndim(y)
     jac = np.zeros((1 if yrank == 0 else len(y), len(x)))
     h = np.zeros(len(x))
+    divergence = True
     for i, hi in enumerate(dx):
         if i > 0:
             h[i - 1] = 0
@@ -916,11 +917,25 @@
             d = 0.5 * (du + dd)
             delta = du - dd
             if np.all(np.abs(delta) <= tol * np.abs(d)):
+                if debug:
+                    print(
+                        f"jacobi: iter={iter} converged; delta={delta} "
+                        f"threshold={tol * np.abs(d)}"
+                    )
                 jac[:, i] = d
                 break
             esq = np.dot(delta, delta)
-            if esq > prev_esq:
-                # no convergence, use previous more accurate jac[:, i]
+            if debug:
+                print(f"jacobi: iter={iter} d={d} esq={esq} h={h}")
+            if iter > 0 and esq < prev_esq:
+                divergence = False
+            if esq >= prev_esq:
+                if divergence:
+                    print(f"jacobi: iter={iter} divergence detected")
+                    jac[:, i] = np.nan
+                else:
+                    print(f"jacobi: iter={iter} no convergence")
+                    # no convergence, use previous more accurate jac[:, i]
                 break
             jac[:, i] = d
             prev_esq = esq
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/iminuit-2.8.1/src/iminuit/version.py 
new/iminuit-2.8.3/src/iminuit/version.py
--- old/iminuit-2.8.1/src/iminuit/version.py    2021-08-04 11:39:20.000000000 
+0200
+++ new/iminuit-2.8.3/src/iminuit/version.py    2021-09-03 17:07:34.000000000 
+0200
@@ -7,7 +7,7 @@
 # - Increase MAINTENANCE when fixing bugs without adding features
 # - During development, add suffix .devN with N >= 0
 # - For release candidates, add suffix .rcN with N >= 0
-version = "2.8.1"
+version = "2.8.3"
 
 # We list the corresponding ROOT version of the C++ Minuit2 library here
 root_version = "v6-25-01-1694-g187368db19"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/iminuit-2.8.1/src/iminuit.egg-info/PKG-INFO 
new/iminuit-2.8.3/src/iminuit.egg-info/PKG-INFO
--- old/iminuit-2.8.1/src/iminuit.egg-info/PKG-INFO     2021-08-04 
11:39:47.000000000 +0200
+++ new/iminuit-2.8.3/src/iminuit.egg-info/PKG-INFO     2021-09-03 
17:08:02.000000000 +0200
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: iminuit
-Version: 2.8.1
+Version: 2.8.3
 Summary: Jupyter-friendly Python frontend for MINUIT2 in C++
 Home-page: http://github.com/scikit-hep/iminuit
 Author: Piti Ongmongkolkul and the iminuit team
@@ -49,14 +49,11 @@
         - Support for SciPy minimisers
         - Numba support (optional)
         
-        Checkout the comprehensive list of `tutorials`_ that demonstrate these 
features.
+        Checkout our large and comprehensive list of `tutorials`_ that take 
you all the way from beginner to power user. For help and how-to questions, 
please use the `discussions`_ on GitHub.
         
         .. image:: https://mybinder.org/badge_logo.svg
            :target: 
https://mybinder.org/v2/gh/scikit-hep/iminuit/develop?filepath=doc%2Ftutorial
         
-        .. image:: https://img.shields.io/gitter/room/Scikit-HEP/iminuit
-           :alt: Gitter
-        
         In a nutshell
         -------------
         
@@ -86,6 +83,7 @@
         
         .. _changelog: https://iminuit.readthedocs.io/en/stable/changelog.html
         .. _tutorials: https://iminuit.readthedocs.io/en/stable/tutorials.html
+        .. _discussions: https://github.com/scikit-hep/iminuit/discussions
         
 Platform: UNKNOWN
 Classifier: Development Status :: 5 - Production/Stable
@@ -113,3 +111,4 @@
 Requires-Python: >=3.6
 Description-Content-Type: text/x-rst
 Provides-Extra: test
+Provides-Extra: doc
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/iminuit-2.8.1/src/iminuit.egg-info/requires.txt 
new/iminuit-2.8.3/src/iminuit.egg-info/requires.txt
--- old/iminuit-2.8.1/src/iminuit.egg-info/requires.txt 2021-08-04 
11:39:47.000000000 +0200
+++ new/iminuit-2.8.3/src/iminuit.egg-info/requires.txt 2021-09-03 
17:08:02.000000000 +0200
@@ -1,12 +1,19 @@
 numpy
 
+[doc]
+sphinx==4.1
+sphinx-rtd-theme
+nbsphinx
+ipykernel
+matplotlib
+
 [test]
-cmake
 cython
 flake8
 ipykernel
 jax
 jaxlib
+joblib
 jupyter_client
 matplotlib
 nbconvert
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/iminuit-2.8.1/tests/test_draw.py 
new/iminuit-2.8.3/tests/test_draw.py
--- old/iminuit-2.8.1/tests/test_draw.py        2021-08-04 11:39:20.000000000 
+0200
+++ new/iminuit-2.8.3/tests/test_draw.py        2021-09-03 17:07:34.000000000 
+0200
@@ -1,49 +1,88 @@
 import pytest
 from iminuit import Minuit
+from pathlib import Path
+import numpy as np
+
 
 mpl = pytest.importorskip("matplotlib")
+plt = pytest.importorskip("matplotlib.pyplot")
 mpl.use("Agg")
 
 
 def f1(x, y):
-    return (1 - x) ** 2 + 100 * (y - 1) ** 2
-
-
-def f2(par):
-    return f1(par[0], par[1])
+    return (1 - x) ** 2 + np.exp((y - 1) ** 2)
 
 
 f1.errordef = 1
-f2.errordef = 1
 
 
[email protected](params=("normal", "numpy"))
-def minuit(request):
-    if request.param == "normal":
-        m = Minuit(f1, x=0, y=0)
-    else:
-        m = Minuit(f2, (0, 0), name=("x", "y"))
[email protected]
+def minuit():
+    m = Minuit(f1, x=0, y=0)
     m.migrad()
     return m
 
 
-def test_profile(minuit):
-    minuit.draw_profile("x")  # plots with hesse errors
[email protected]
+def fig(request):
+    fig = plt.figure()
+    yield fig
+    p = Path(__file__).parent / "fig"
+    if not p.exists():
+        p.mkdir()
+    fig.savefig(p / (request.node.name + ".svg"))
+    del fig
+
+
[email protected]("arg", ("x", "y"))
+def test_profile_1(fig, minuit, arg):
+    # plots with hesse errors
+    minuit.draw_profile(arg)
+    plt.ylim(0, 5)
+
+
[email protected]("arg", ("x", "y"))
+def test_profile_2(fig, minuit, arg):
+    # plots with minos errors
     minuit.minos()
-    minuit.draw_profile("x")  # plots with minos errors
+    minuit.draw_profile(arg)
+    plt.ylim(0, 5)
+
 
[email protected]("arg", ("x", "y"))
+def test_mnprofile_1(fig, minuit, arg):
+    # plots with hesse errors
+    minuit.draw_mnprofile(arg)
+    plt.ylim(0, 5)
 
-def test_mnprofile(minuit):
-    minuit.draw_mnprofile("x")  # plots with hesse errors
+
[email protected]("arg", ("x", "y"))
+def test_mnprofile_2(fig, minuit, arg):
+    # plots with minos errors
     minuit.minos()
-    minuit.draw_mnprofile("x")  # plots with minos errors
+    minuit.draw_mnprofile(arg)
+    plt.ylim(0, 5)
 
 
-def test_mncontour(minuit):
+def test_mncontour_1(fig, minuit):
     minuit.draw_mncontour("x", "y")
 
 
-def test_drawcontour(minuit):
+def test_mncontour_2(fig, minuit):
+    minuit.draw_mncontour("x", "y", cl=0.68)
+
+
+def test_mncontour_3(fig, minuit):
+    minuit.draw_mncontour("x", "y", cl=[0.68, 0.9])
+
+
+def test_contour_1(fig, minuit):
     minuit.draw_contour("x", "y")
-    minuit.draw_contour("x", "x", size=20, bound=2)
-    minuit.draw_contour("x", "x", size=20, bound=((-10, 10), (-10, 10)))
+
+
+def test_contour_2(fig, minuit):
+    minuit.draw_contour("x", "y", size=20, bound=2)
+
+
+def test_contour_3(fig, minuit):
+    minuit.draw_contour("x", "y", size=100, bound=((-0.5, 2.5), (-1, 3)))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/iminuit-2.8.1/tests/test_util.py 
new/iminuit-2.8.3/tests/test_util.py
--- old/iminuit-2.8.1/tests/test_util.py        2021-08-04 11:39:20.000000000 
+0200
+++ new/iminuit-2.8.3/tests/test_util.py        2021-09-03 17:07:34.000000000 
+0200
@@ -539,13 +539,46 @@
         util._jacobi(lambda x: x ** 2, x, dx, 1e-3)
 
 
-def test_jacobi_no_convergence():
[email protected]("fail", (False, True))
+def test_jacobi_low_resolution(fail, capsys):
+    x = np.array([1])
+    dx = np.array([1])
+
+    y, jac = util._jacobi(
+        lambda x: np.exp(x.astype(np.float32)),
+        x,
+        dx,
+        1e-10 if fail else 1e-3,
+        debug=True,
+    )
+
+    assert fail == ("no convergence" in capsys.readouterr()[0])
+
+    np.testing.assert_allclose(y, np.exp(1), rtol=1e-3)
+    np.testing.assert_allclose(jac, np.exp(1), rtol=1e-3)
+
+
+def test_jacobi_divergence_1(capsys):
     rng = np.random.default_rng(1)
 
     x = np.array([1])
     dx = np.array([1])
 
-    y, jac = util._jacobi(lambda x: rng.normal(), x, dx, 1e-323)
+    y, jac = util._jacobi(lambda x: rng.normal(), x, dx, 0.1, debug=True)
+
+    assert "divergence" in capsys.readouterr()[0]
 
     np.testing.assert_allclose(y, 0, atol=1)
-    np.testing.assert_allclose(jac, 0, atol=1)
+    np.testing.assert_equal(jac, np.nan)
+
+
+def test_jacobi_divergence_2(capsys):
+    x = np.array([1e-10])
+    dx = np.array([0.1])
+
+    y, jac = util._jacobi(lambda x: 1 / x, x, dx, 1e-3, debug=True)
+
+    assert "divergence" in capsys.readouterr()[0]
+
+    np.testing.assert_allclose(y, 1e10)
+    np.testing.assert_equal(jac, np.nan)

Reply via email to