Skip to content

Commit

Permalink
Merge pull request #19161 from mantidproject/19115_muon_multi_fit_bug
Browse files Browse the repository at this point in the history
Bug in output from multi-domain fitting.
  • Loading branch information
martyngigg committed Mar 16, 2017
2 parents c19ae30 + 2071e20 commit 29e3bb8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
4 changes: 1 addition & 3 deletions Framework/API/src/IFunction.cpp
Expand Up @@ -206,9 +206,7 @@ std::string IFunction::asString() const {
}
// print the parameters
for (size_t i = 0; i < nParams(); i++) {
if (!isFixed(i)) {
ostr << ',' << parameterName(i) << '=' << getParameter(i);
}
ostr << ',' << parameterName(i) << '=' << getParameter(i);
}

// collect non-default constraints
Expand Down
4 changes: 2 additions & 2 deletions Framework/API/test/FunctionFactoryTest.h
Expand Up @@ -433,9 +433,9 @@ class FunctionFactoryTest : public CxxTest::TestSuite {
void test_MultiDomainFunction_creation_moreComplex() {
const std::string fnString =
"composite=MultiDomainFunction,NumDeriv=true;(name=FunctionFactoryTest_"
"FunctA,a0=0,a1=0.5;name=FunctionFactoryTest_FunctB,b0=0.1,ties="
"FunctA,a0=0,a1=0.5;name=FunctionFactoryTest_FunctB,b0=0.1,b1=0.2,ties="
"(b1=0.2),$domains=i);(name=FunctionFactoryTest_FunctA,a0=0,a1=0.5;"
"name=FunctionFactoryTest_FunctB,b0=0.1,$domains=i);ties=(f1.f1."
"name=FunctionFactoryTest_FunctB,b0=0.1,b1=0.2,$domains=i);ties=(f1.f1."
"b1=f0.f1.b1)";
IFunction_sptr fun;
TS_ASSERT_THROWS_NOTHING(
Expand Down
9 changes: 4 additions & 5 deletions Framework/API/test/ImmutableCompositeFunctionTest.h
Expand Up @@ -279,10 +279,9 @@ class ImmutableCompositeFunctionTest : public CxxTest::TestSuite {
icf.addTies("b2=b1,a2=a1/5");
icf.applyTies();

TS_ASSERT_EQUALS(
icf.asString(),
"name=ImmutableCompositeFunctionTest_"
"Function,NumDeriv=false,a1=11,b1=12,ties=(a2=a1/5,b2=b1)");
TS_ASSERT_EQUALS(icf.asString(), "name=ImmutableCompositeFunctionTest_"
"Function,NumDeriv=false,a1=11,b1=12,a2=2."
"2,b2=12,ties=(a2=a1/5,b2=b1)");

auto fun = FunctionFactory::Instance().createInitialized(icf.asString());
TS_ASSERT(fun);
Expand All @@ -309,7 +308,7 @@ class ImmutableCompositeFunctionTest : public CxxTest::TestSuite {

TS_ASSERT_EQUALS(icf.asString(), "name=ImmutableCompositeFunctionTest_"
"FunctionWithTies,NumDeriv=false,a1=1,b1="
"2");
"2,a2=0.25,b2=1");

auto fun = FunctionFactory::Instance().createInitialized(icf.asString());
TS_ASSERT(fun);
Expand Down
29 changes: 23 additions & 6 deletions Framework/API/test/MultiDomainFunctionTest.h
Expand Up @@ -441,16 +441,33 @@ class MultiDomainFunctionTest : public CxxTest::TestSuite {
}

void test_string_representation() {
const std::string expected =
"composite=MultiDomainFunction,NumDeriv=true;"
"name=MultiDomainFunctionTest_Function,A=0,B=1,$domains=i;"
"name=MultiDomainFunctionTest_Function,B=2,$domains=i;"
"name=MultiDomainFunctionTest_Function,B=3,$domains=i;ties=(f1.A="
"f0.A,f2.A=f0.A)";
const std::string expected = "composite=MultiDomainFunction,NumDeriv=true;"
"name=MultiDomainFunctionTest_Function,A=0,B="
"1,$domains=i;name=MultiDomainFunctionTest_"
"Function,A=0,B=2,$domains=i;name="
"MultiDomainFunctionTest_Function,A=0,B=3,$"
"domains=i;ties=(f1.A=f0.A,f2.A=f0.A)";
TS_ASSERT_EQUALS(multi.asString(), expected);
TS_ASSERT_EQUALS(multi.asString(), multi.clone()->asString());
}

void test_equivalent_functions() {
std::string ini =
"composite=MultiDomainFunction;"
"name=MultiDomainFunctionTest_Function,A=1,B=2,$domains=i;"
"name=MultiDomainFunctionTest_Function,A=3,B=4,$domains=i;ties=(f1.A="
"f0.B)";
auto mfun = boost::dynamic_pointer_cast<CompositeFunction>(
FunctionFactory::Instance().createInitialized(ini));

auto eqFuns = mfun->createEquivalentFunctions();
TS_ASSERT_EQUALS(eqFuns.size(), 2);
TS_ASSERT_EQUALS(eqFuns[0]->asString(),
"name=MultiDomainFunctionTest_Function,A=1,B=2");
TS_ASSERT_EQUALS(eqFuns[1]->asString(),
"name=MultiDomainFunctionTest_Function,A=2,B=4");
}

private:
MultiDomainFunction multi;
JointDomain domain;
Expand Down

0 comments on commit 29e3bb8

Please sign in to comment.