diff --git a/Tests/Functional/Python/PyFit/minimizer_api.py b/Tests/Functional/Python/PyFit/minimizer_api.py index a474c767d4697d3133f937d4a90bb68b21e75ed4..a89e182f175a6d1c87d3025c0894474b395face2 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 bbe063403b3650ba026e80c1453c093330e51ab6..e4fbe98b3aefb7526e6d2ca1e2a6eb4176f5ecbd 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 71de0cec3d218ed22844da31bde1f00d22df199c..46685fbadb64227e4443a5d472d125e02ec3f965 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 b5f1a6ebbc29d74646fd30529c71504742f028db..63a1a69d96133729cbf18ac46f8e4567568c119b 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