From 7276fed90be2b0f9a6da35aa84bacace0f9b7da2 Mon Sep 17 00:00:00 2001
From: Gennady Pospelov <g.pospelov@fz-juelich.de>
Date: Wed, 9 May 2018 14:53:18 +0200
Subject: [PATCH] PythonAPI: replaced call par.value() with attribute par.value
 to be consistent with lmfit API.

---
 Tests/Functional/Python/PyFit/minimizer_api.py   |  9 +++++++++
 Tests/Functional/Python/PyFit/standalone_fits.py |  4 ++--
 Wrap/swig/extendFit.i                            | 14 ++++++++++++++
 auto/Wrap/libBornAgainFit.py                     |  5 +++++
 4 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/Tests/Functional/Python/PyFit/minimizer_api.py b/Tests/Functional/Python/PyFit/minimizer_api.py
index a474c767d46..a89e182f175 100644
--- a/Tests/Functional/Python/PyFit/minimizer_api.py
+++ b/Tests/Functional/Python/PyFit/minimizer_api.py
@@ -22,6 +22,15 @@ class TestMinimizerHelper:
 
 class MinimizerAPITest(unittest.TestCase):
 
+    def test_ParameterAttribute(self):
+        """
+        Testing p.value attribute
+        """
+        par = ba.Parameter("par", 1.0)
+        self.assertEqual(par.value, 1.0)
+        par.value = 42.0
+        self.assertEqual(par.value, 42.0)
+
     def test_ParametersSetIterator(self):
         """
         Testing of python iterator over defined fit parameters.
diff --git a/Tests/Functional/Python/PyFit/standalone_fits.py b/Tests/Functional/Python/PyFit/standalone_fits.py
index bbe063403b3..e4fbe98b3ae 100644
--- a/Tests/Functional/Python/PyFit/standalone_fits.py
+++ b/Tests/Functional/Python/PyFit/standalone_fits.py
@@ -20,8 +20,8 @@ class Rosenbrock:
         """
         Returns the value of Rosenbrock function
         """
-        x = params["x"].value()
-        y = params["y"].value()
+        x = params["x"].value
+        y = params["y"].value
         tmp1 = y - x * x
         tmp2 = 1 - x
         return 100 * tmp1 * tmp1 + tmp2 * tmp2
diff --git a/Wrap/swig/extendFit.i b/Wrap/swig/extendFit.i
index 71de0cec3d2..46685fbadb6 100644
--- a/Wrap/swig/extendFit.i
+++ b/Wrap/swig/extendFit.i
@@ -83,6 +83,20 @@ def __iter__(self):
 
 }
 
+// --- Parameter x.value attribute
+namespace Fit {
+
+%extend Parameter{
+%pythoncode %{
+__swig_getmethods__["value"] = value
+__swig_setmethods__["value"] = setValue
+if _newclass: value = property(value, setValue)
+%}
+};
+
+}
+
+
 // --- Setting up Minimizer callback ---
 
 %pythoncode %{
diff --git a/auto/Wrap/libBornAgainFit.py b/auto/Wrap/libBornAgainFit.py
index b5f1a6ebbc2..63a1a69d961 100644
--- a/auto/Wrap/libBornAgainFit.py
+++ b/auto/Wrap/libBornAgainFit.py
@@ -2021,6 +2021,11 @@ class Parameter(_object):
         """setError(Parameter self, double value)"""
         return _libBornAgainFit.Parameter_setError(self, value)
 
+
+    __swig_getmethods__["value"] = value
+    __swig_setmethods__["value"] = setValue
+    if _newclass: value = property(value, setValue)
+
     __swig_destroy__ = _libBornAgainFit.delete_Parameter
     __del__ = lambda self: None
 Parameter_swigregister = _libBornAgainFit.Parameter_swigregister
-- 
GitLab