Skip to content

Commit

Permalink
Re #9535. Added an option to output only parameters from Fit
Browse files Browse the repository at this point in the history
  • Loading branch information
mantid-roman committed May 28, 2014
1 parent 2c2a8ca commit cfd54fe
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Code/Mantid/Framework/CurveFitting/src/Fit.cpp
Expand Up @@ -562,6 +562,9 @@ namespace CurveFitting
declareProperty(new Kernel::PropertyWithValue<bool>("ConvolveMembers", false),
"If true and OutputCompositeMembers is true members of any Convolution are output convolved\n"
"with corresponding resolution");
declareProperty("OutputParametersOnly", false,
"Set to true to output only the parameters and not workspace(s) with the calculated values\n"
"(default is false, ignored if CreateOutput is false and Output is an empty string)." );
}

/** Executes the algorithm
Expand Down Expand Up @@ -797,14 +800,19 @@ namespace CurveFitting

setProperty("OutputParameters",result);

const bool unrollComposites = getProperty("OutputCompositeMembers");
bool convolveMembers = existsProperty("ConvolveMembers");
if ( convolveMembers )
bool outputParametersOnly = getProperty("OutputParametersOnly");

if ( !outputParametersOnly )
{
convolveMembers = getProperty("ConvolveMembers");
const bool unrollComposites = getProperty("OutputCompositeMembers");
bool convolveMembers = existsProperty("ConvolveMembers");
if ( convolveMembers )
{
convolveMembers = getProperty("ConvolveMembers");
}
m_domainCreator->separateCompositeMembersInOutput(unrollComposites,convolveMembers);
m_domainCreator->createOutputWorkspace(baseName,m_function,domain,values);
}
m_domainCreator->separateCompositeMembersInOutput(unrollComposites,convolveMembers);
m_domainCreator->createOutputWorkspace(baseName,m_function,domain,values);

}

Expand Down
53 changes: 53 additions & 0 deletions Code/Mantid/Framework/CurveFitting/test/FitMWTest.h
Expand Up @@ -227,6 +227,59 @@ class FitMWTest : public CxxTest::TestSuite

}

void test_all_output()
{
auto ws2 = createTestWorkspace(true);

API::IFunction_sptr fun(new Polynomial);
fun->setAttributeValue("n",1);

Fit fit;
fit.initialize();

fit.setProperty("Function",fun);
fit.setProperty("InputWorkspace",ws2);
fit.setProperty("WorkspaceIndex",0);
fit.setProperty("Output","out");

fit.execute();

TS_ASSERT(fit.isExecuted());

TS_ASSERT( Mantid::API::AnalysisDataService::Instance().doesExist( "out_Workspace" ) );
TS_ASSERT( Mantid::API::AnalysisDataService::Instance().doesExist( "out_Parameters" ) );

Mantid::API::AnalysisDataService::Instance().clear();

}

void test_output_parameters_only()
{
auto ws2 = createTestWorkspace(true);

API::IFunction_sptr fun(new Polynomial);
fun->setAttributeValue("n",1);

Fit fit;
fit.initialize();

fit.setProperty("Function",fun);
fit.setProperty("InputWorkspace",ws2);
fit.setProperty("WorkspaceIndex",0);
fit.setProperty("Output","out");
fit.setProperty("OutputParametersOnly",true);

fit.execute();

TS_ASSERT(fit.isExecuted());

TS_ASSERT( ! Mantid::API::AnalysisDataService::Instance().doesExist( "out_Workspace" ) );
TS_ASSERT( Mantid::API::AnalysisDataService::Instance().doesExist( "out_Parameters" ) );

Mantid::API::AnalysisDataService::Instance().clear();

}

void test_createDomain_creates_FunctionDomain1DSpectrum()
{
MatrixWorkspace_sptr ws2 = createTestWorkspace(true);
Expand Down

0 comments on commit cfd54fe

Please sign in to comment.