diff --git a/Framework/PythonInterface/mantid/api/src/FitFunctions/IFunctionAdapter.cpp b/Framework/PythonInterface/mantid/api/src/FitFunctions/IFunctionAdapter.cpp index b10aa0db5ca9a52ae2d5f991055748dd12a59176..cab183753b65b9c3b40c63897e2695a9ce30777b 100644 --- a/Framework/PythonInterface/mantid/api/src/FitFunctions/IFunctionAdapter.cpp +++ b/Framework/PythonInterface/mantid/api/src/FitFunctions/IFunctionAdapter.cpp @@ -167,6 +167,7 @@ void IFunctionAdapter::setAttribute(const std::string &attName, object value = object(handle<>(getAttributeValue(*this, attr))); callMethod<void, std::string, object>(getSelf(), "setAttributeValue", attName, value); + storeAttributeValue(attName, attr); } catch (UndefinedAttributeError &) { IFunction::setAttribute(attName, attr); } diff --git a/Framework/PythonInterface/test/python/plugins/functions/AttributeTest.py b/Framework/PythonInterface/test/python/plugins/functions/AttributeTest.py index 215175e9043f53d28cce5ba7d0e4e6fa153ea957..7f86dcd4ba6de194a605e4653e76d51299718e1b 100644 --- a/Framework/PythonInterface/test/python/plugins/functions/AttributeTest.py +++ b/Framework/PythonInterface/test/python/plugins/functions/AttributeTest.py @@ -54,6 +54,12 @@ class AttributeTest(unittest.TestCase): self.assertAlmostEqual(res[1], 0.29960535, 7) self.assertAlmostEqual(res[2], 0.07493335, 7) self.assertAlmostEqual(res[3], -0.09645745, 7) + + def test_set_and_get_attribute_value(self): + fun = FunctionFactory.createFunction("AttributeExample") + self.assertEqual(fun.getAttributeValue('Frequency'), 0.26) + fun.setAttributeValue('Frequency', 6.2) + self.assertEqual(fun.getAttributeValue('Frequency'), 6.2) if __name__ == '__main__': unittest.main() diff --git a/docs/source/release/v3.11.0/framework.rst b/docs/source/release/v3.11.0/framework.rst index 9d205adfc1d9282cae97c286b8548f6dfb0554dc..6421bb3fe9f3fa10499b7474a392688f9a826ba2 100644 --- a/docs/source/release/v3.11.0/framework.rst +++ b/docs/source/release/v3.11.0/framework.rst @@ -45,6 +45,12 @@ Python Python Algorithms ################# + +Python Fit Functions +#################### + +- A bug that makes it difficult to define and use attributes in python fit functions has been fixed. + | Full list of @@ -52,3 +58,5 @@ Full list of and `Python <http://github.com/mantidproject/mantid/pulls?q=is%3Apr+milestone%3A%22Release+3.11%22+is%3Amerged+label%3A%22Component%3A+Python%22>`__ changes on GitHub + +