Bug#1067234: symfit: autopkgtest regression with NumPy 1.26

2024-04-12 Thread Michael R. Crusoe

On Mon, 8 Apr 2024 17:09:33 + Graham Inggs  wrote:
> Control: tags -1 + patch
>
> Hi Maintainer
>
> While asserting that no warnings are raised is a useful test for the
> upstream developers, I don't think it makes sense for downstreams.
>
> I propose to disable the assertion as follows:
>
> --- a/tests/test_minimizers.py
> +++ b/tests/test_minimizers.py
> @@ -117,7 +117,7 @@
> # Should no longer raise warnings, because internally we practice
> # what we preach.
> fit_custom = BFGS(chi_squared, [a, b])
> - assert len(recwarn) == 0
> +# assert len(recwarn) == 0
>
> fit_custom_result = fit_custom.execute()
>
> Please let me know if you are happy with a team upload and I will proceed.
> As a bonus, I attach a patch that fixes several SyntaxWarnings that
> occur with Python 3.12.


Hey Graham,

A team upload is fine, thanks for the fixes; please go ahead and upload them.



OpenPGP_signature.asc
Description: OpenPGP digital signature


Bug#1067234: symfit: autopkgtest regression with NumPy 1.26

2024-04-08 Thread Graham Inggs
Control: tags -1 + patch

Hi Maintainer

While asserting that no warnings are raised is a useful test for the
upstream developers, I don't think it makes sense for downstreams.

I propose to disable the assertion as follows:

--- a/tests/test_minimizers.py
+++ b/tests/test_minimizers.py
@@ -117,7 +117,7 @@
 # Should no longer raise warnings, because internally we practice
 # what we preach.
 fit_custom = BFGS(chi_squared, [a, b])
-assert len(recwarn) == 0
+#assert len(recwarn) == 0

 fit_custom_result = fit_custom.execute()

Please let me know if you are happy with a team upload and I will proceed.
As a bonus, I attach a patch that fixes several SyntaxWarnings that
occur with Python 3.12.

Regards
Graham
Description: Fix several SyntaxWarnings
 Use raw strings to avoid invalid escape sequence
Author: Graham Inggs 
Last-Update: 2024-04-06

--- a/symfit/core/operators.py
+++ b/symfit/core/operators.py
@@ -45,7 +45,7 @@
 # return orig_ne(self.__class__, other)
 
 def call(self, *values, **named_values):
-"""
+r"""
 Call an expression to evaluate it at the given point.
 
 Future improvements: I would like if func and signature could be buffered after the
--- a/symfit/core/support.py
+++ b/symfit/core/support.py
@@ -293,7 +293,7 @@
 return jac
 
 def key2str(target):
-"""
+r"""
 In ``symfit`` there are many dicts with symbol: value pairs.
 These can not be used immediately as \*\*kwargs, even though this would make
 a lot of sense from the context.
@@ -321,4 +321,4 @@
 base_str += 'd{}{}'.format(var,  count if count > 1 else '')
 return base_str
 
-sympy.Derivative.name = property(name)
\ No newline at end of file
+sympy.Derivative.name = property(name)
--- a/symfit/core/fit.py
+++ b/symfit/core/fit.py
@@ -29,7 +29,7 @@
 from the model.
 """
 def __init__(self, model, *ordered_data, absolute_sigma=None, **named_data):
-"""
+r"""
 :param model: (dict of) sympy expression or ``Model`` object.
 :param bool absolute_sigma: True by default. If the sigma is only used
 for relative weights in your problem, you could consider setting it to
--- a/symfit/core/minimizers.py
+++ b/symfit/core/minimizers.py
@@ -208,7 +208,7 @@
 :class:`~symfit.core.minimizers.DifferentialEvolution`.
 """
 def __init__(self, *args, minimizers=None, **kwargs):
-'''
+r'''
 :param minimizers: a :class:`~collections.abc.Sequence` of
 :class:`~symfit.core.minimizers.BaseMinimizer` objects, which need
 to be run in order.
@@ -324,7 +324,7 @@
 
 def execute(self, bounds=None, jacobian=None, hessian=None,
 constraints=None, *, tol=1e-9, **minimize_options):
-"""
+r"""
 Calls the wrapped algorithm.
 
 :param bounds: The bounds for the parameters. Usually filled by
@@ -790,7 +790,7 @@
 return lbounds, ubounds
 
 def execute(self, jacobian=None, method='trf', **minpack_options):
-"""
+r"""
 :param \*\*minpack_options: Any named arguments to be passed to
 :func:`scipy.optimize.least_squares`
 """
--- a/symfit/core/fit_results.py
+++ b/symfit/core/fit_results.py
@@ -26,7 +26,7 @@
 :class:`~symfit.core.models.Model`'s.
 """
 def __init__(self, model, popt, covariance_matrix, minimizer, objective, message, *, constraints=None, **minimizer_output):
-"""
+r"""
 :param model: :class:`~symfit.core.models.Model` that was fit to.
 :param popt: best fit parameters, same ordering as in model.params.
 :param covariance_matrix: covariance matrix.
@@ -276,4 +276,4 @@
 f_is = [f_is[var] for var in model.dependent_vars]
 SS_res = np.sum([np.sum((y_i - f_i)**2) for y_i, f_i in zip(y_is, f_is) if y_i is not None])
 SS_tot = np.sum([np.sum((y_i - y_bar)**2) for y_i, y_bar in zip(y_is, y_bars) if y_i is not None])
-return 1 - SS_res/SS_tot
\ No newline at end of file
+return 1 - SS_res/SS_tot
--- a/symfit/core/objectives.py
+++ b/symfit/core/objectives.py
@@ -386,7 +386,7 @@
 
 
 class HessianObjectiveJacApprox(HessianObjective):
-"""
+r"""
 This object should only be used as a Mixin for covariance matrix estimation.
 Since the covariance matrix for the least-squares method is proportional to
 the Hessian of :math:`S`, this function attempts to return the Hessian
@@ -552,4 +552,4 @@
 )
 return np.array(evaluated_hess[0])
 else:
-return None
\ No newline at end of file
+return None


Bug#1067234: symfit: autopkgtest regression with NumPy 1.26

2024-03-20 Thread Timo Röhling
Source: symfit
Version: 0.5.6-2
Severity: serious

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Dear maintainer,

your package has an autopkgtest regression with NumPy 1.26.
Hopefully relevant excerpt from the test log:

  130s # Should no longer raise warnings, because internally we practice
  130s # what we preach.
  130s fit_custom = BFGS(chi_squared, [a, b])
  130s >   assert len(recwarn) == 0
  
  130s E   assert 1 == 0
  130s E+  where 1 = len(WarningsRecorder(record=True))
  130s
  130s tests/test_minimizers.py:120: AssertionError
  130s === warnings summary 
===
  130s symfit/core/operators.py:48
  130s   
/tmp/autopkgtest-lxc.jjpx74xp/downtmp/build.gp1/src/symfit/core/operators.py:48:
 SyntaxWarning: invalid escape sequence '\*'
  130s """
  130s
  130s symfit/core/support.py:296
  130s   
/tmp/autopkgtest-lxc.jjpx74xp/downtmp/build.gp1/src/symfit/core/support.py:296: 
SyntaxWarning: invalid escape sequence '\*'
  130s """
  130s
  130s symfit/core/printing.py:13
  130s   
/tmp/autopkgtest-lxc.jjpx74xp/downtmp/build.gp1/src/symfit/core/printing.py:13: 
DeprecationWarning: pkg_resources is deprecated as an API. See 
https://setuptools.pypa.io/en/latest/pkg_resources.html
  130s import pkg_resources
  130s
  130s 
../../../../../usr/lib/python3/dist-packages/pkg_resources/__init__.py:2871
  130s   /usr/lib/python3/dist-packages/pkg_resources/__init__.py:2871: 
DeprecationWarning: Deprecated call to 
`pkg_resources.declare_namespace('mpl_toolkits')`.
  130s   Implementing implicit namespace packages (as specified in PEP 420) is 
preferred to `pkg_resources.declare_namespace`. See 
https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
  130s declare_namespace(pkg)
  130s
  130s symfit/core/fit.py:32
  130s   
/tmp/autopkgtest-lxc.jjpx74xp/downtmp/build.gp1/src/symfit/core/fit.py:32: 
SyntaxWarning: invalid escape sequence '\_'
  130s """
  130s
  130s symfit/core/minimizers.py:211
  130s   
/tmp/autopkgtest-lxc.jjpx74xp/downtmp/build.gp1/src/symfit/core/minimizers.py:211:
 SyntaxWarning: invalid escape sequence '\*'
  130s '''
  130s
  130s symfit/core/minimizers.py:327
  130s   
/tmp/autopkgtest-lxc.jjpx74xp/downtmp/build.gp1/src/symfit/core/minimizers.py:327:
 SyntaxWarning: invalid escape sequence '\*'
  130s """
  130s
  130s symfit/core/minimizers.py:793
  130s   
/tmp/autopkgtest-lxc.jjpx74xp/downtmp/build.gp1/src/symfit/core/minimizers.py:793:
 SyntaxWarning: invalid escape sequence '\*'
  130s """
  130s
  130s symfit/core/fit_results.py:29
  130s   
/tmp/autopkgtest-lxc.jjpx74xp/downtmp/build.gp1/src/symfit/core/fit_results.py:29:
 SyntaxWarning: invalid escape sequence '\*'
  130s """
  130s
  130s symfit/core/objectives.py:389
  130s   
/tmp/autopkgtest-lxc.jjpx74xp/downtmp/build.gp1/src/symfit/core/objectives.py:389:
 SyntaxWarning: invalid escape sequence '\c'
  130s """
  130s
  130s ../../../../../usr/lib/python3/dist-packages/dateutil/tz/tz.py:37
  130s   /usr/lib/python3/dist-packages/dateutil/tz/tz.py:37: 
DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and 
scheduled for removal in a future version. Use timezone-aware objects to 
represent datetimes in UTC: datetime.datetime.fromtimestamp(timestamp, 
datetime.UTC).
  130s EPOCH = datetime.datetime.utcfromtimestamp(0)
  130s
  130s tests/test_auto_fit.py: 3 warnings
  130s tests/test_constrained.py: 14 warnings
  130s tests/test_finite_difference.py: 1 warning
  130s tests/test_fit_result.py: 5 warnings
  130s tests/test_general.py: 16 warnings
  130s tests/test_minimizers.py: 2 warnings
  130s tests/test_objectives.py: 1 warning
  130s tests/test_ode.py: 1 warning
  130s   
/tmp/autopkgtest-lxc.jjpx74xp/downtmp/build.gp1/src/symfit/core/fit.py:278: 
DeprecationWarning: `product` is deprecated as of NumPy 1.25.0, and will be 
removed in NumPy 2.0. Please use `prod` instead.
  130s cov_matrix = self._covariance_matrix(best_fit_params,
  130s
  130s tests/test_auto_fit.py: 2 warnings
  130s tests/test_constrained.py: 13 warnings
  130s tests/test_finite_difference.py: 2 warnings
  130s tests/test_fit_result.py: 1 warning
  130s tests/test_general.py: 12 warnings
  130s tests/test_global_opt.py: 3 warnings
  130s tests/test_ode.py: 7 warnings
  130s   
/tmp/autopkgtest-lxc.jjpx74xp/downtmp/build.gp1/src/symfit/core/fit.py:301: 
DeprecationWarning: `product` is deprecated as of NumPy 1.25.0, and will be 
removed in NumPy 2.0. Please use `prod` instead.
  130s cov_matrix = self._covariance_matrix(best_fit_params,
  130s
  130s tests/test_general.py::test_likelihood_fitting_exponential
  130s   /usr/lib/python3/dist-packages/_pytest/python.py:194: 
DeprecationWarning: `product` is deprecated as of NumPy 1.25.0, and will be 
removed in NumPy 2.0. Please use `prod` instead.
  130s result = testfunction(**testargs)
  130s
  130s --