Skip to content

Commit

Permalink
Merge 'origin/master' into feature/9223_icat_filter_publish. Refs #9223.
Browse files Browse the repository at this point in the history
Conflicts:

- Code/Mantid/MantidQt/CustomDialogs/src/CatalogPublishDialog.cpp
  • Loading branch information
jawrainey committed Apr 9, 2014
2 parents eff77a2 + b0d8ba3 commit 0b2695c
Show file tree
Hide file tree
Showing 214 changed files with 4,562 additions and 1,638 deletions.
31 changes: 16 additions & 15 deletions Code/Mantid/Build/CMake/DarwinSetup.cmake
Expand Up @@ -26,7 +26,7 @@ if ( PYTHON_VERSION_MAJOR )
message ( STATUS "Python version is " ${PY_VER} )
else ()
# Older versions of CMake don't set these variables so just assume 2.6 as before
set ( PY_VER 2.6 )
set ( PY_VER 2.7 )
endif ()

###########################################################################
Expand All @@ -45,7 +45,8 @@ endif()
###########################################################################
# Mac-specific installation setup
###########################################################################
set ( CMAKE_INSTALL_PREFIX /Applications )
set ( CMAKE_INSTALL_PREFIX "" )
set ( CPACK_PACKAGE_EXECUTABLES MantidPlot )
set ( INBUNDLE MantidPlot.app/ )
# We know exactly where this has to be on Darwin
set ( PARAVIEW_APP_DIR "/Applications/${OSX_PARAVIEW_APP}" )
Expand Down Expand Up @@ -73,6 +74,12 @@ install ( FILES /Library/Python/${PY_VER}/site-packages/PyQt4/Qt.so
/Library/Python/${PY_VER}/site-packages/PyQt4/QtXml.so
/Library/Python/${PY_VER}/site-packages/PyQt4/__init__.py
DESTINATION ${BIN_DIR}/PyQt4 )
# Newer PyQt versions have a new internal library that we need to take
if ( EXISTS /Library/Python/${PY_VER}/site-packages/PyQt4/_qt.so )
install ( FILES /Library/Python/${PY_VER}/site-packages/PyQt4/_qt.so
DESTINATION ${BIN_DIR}/PyQt4 )
endif ()

install ( DIRECTORY /Library/Python/${PY_VER}/site-packages/PyQt4/uic DESTINATION ${BIN_DIR}/PyQt4 )

# Python packages in Third_Party need copying to build directory and the final package
Expand Down Expand Up @@ -101,27 +108,21 @@ execute_process(
# Strip off any /CR or /LF
string(STRIP ${OSX_VERSION} OSX_VERSION)

if (OSX_VERSION VERSION_LESS 10.6)
message (FATAL_ERROR "The minimum supported version of Mac OS X is 10.6 (Snow Leopard).")
endif()

if (OSX_VERSION VERSION_GREATER 10.6 OR OSX_VERSION VERSION_EQUAL 10.6)
set ( OSX_CODENAME "Snow Leopard" )
endif()

if (OSX_VERSION VERSION_GREATER 10.7 OR OSX_VERSION VERSION_EQUAL 10.7)
set ( OSX_CODENAME "Lion")
if (OSX_VERSION VERSION_LESS 10.8)
message (FATAL_ERROR "The minimum supported version of Mac OS X is 10.8 (Mountain Lion).")
endif()

if (OSX_VERSION VERSION_GREATER 10.8 OR OSX_VERSION VERSION_EQUAL 10.8)
set ( OSX_CODENAME "Mountain Lion")
endif()

if (OSX_VERSION VERSION_GREATER 10.9 OR OSX_VERSION VERSION_EQUAL 10.9)
set ( OSX_CODENAME "Mavericks")
endif()

message (STATUS "Operating System: Mac OS X ${OSX_VERSION} (${OSX_CODENAME})")

string (REPLACE " " "" CPACK_SYSTEM_NAME ${OSX_CODENAME})
set ( CPACK_OSX_PACKAGE_VERSION 10.6 )
set ( CPACK_PREFLIGHT_SCRIPT ${CMAKE_SOURCE_DIR}/Installers/MacInstaller/installer_hooks/preflight )

set ( CPACK_GENERATOR PackageMaker )
set ( CPACK_GENERATOR DragNDrop )

9 changes: 2 additions & 7 deletions Code/Mantid/CMakeLists.txt
Expand Up @@ -172,13 +172,8 @@ set ( ENABLE_CPACK CACHE BOOL "Switch to enable CPack package generation")
if ( ENABLE_CPACK )
include ( CPackCommon )

# Mac Packagemaker settings
if (OSX_VERSION VERSION_LESS 10.8)
set ( CPACK_RESOURCE_FILE_README ${CMAKE_SOURCE_DIR}/Installers/MacInstaller/MacOSX-README.rtf )
else()
set ( CPACK_RESOURCE_FILE_README ${CMAKE_SOURCE_DIR}/Installers/MacInstaller/MacOSX10-8-README.rtf )
endif ()
set ( CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/Installers/WinInstaller/License.rtf )
# Mac package settings
set ( CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/Installers/WinInstaller/License.txt )

IF ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
include ( CPackLinuxSetup )
Expand Down
15 changes: 12 additions & 3 deletions Code/Mantid/Framework/API/inc/MantidAPI/IDomainCreator.h
Expand Up @@ -15,6 +15,7 @@ namespace Mantid
{
class FunctionDomain;
class IFunctionValues;
class Workspace;
}

namespace API
Expand Down Expand Up @@ -89,12 +90,20 @@ namespace Mantid
/// @param function :: A pointer to the fitting function
/// @param domain :: The domain containing x-values for the function
/// @param values :: A FunctionValues instance containing the fitting data
virtual void createOutputWorkspace(
/// @param outputWorkspacePropertyName :: Name of the property to declare and set to the created output workspace.
/// If empty do not create the property, just return a pointer
/// @return A shared pointer to the created workspace.
virtual boost::shared_ptr<API::Workspace> createOutputWorkspace(
const std::string& baseName,
API::IFunction_sptr function,
boost::shared_ptr<API::FunctionDomain> domain,
boost::shared_ptr<API::IFunctionValues> values)
{UNUSED_ARG(baseName);UNUSED_ARG(function);UNUSED_ARG(domain);UNUSED_ARG(values);}
boost::shared_ptr<API::IFunctionValues> values,
const std::string& outputWorkspacePropertyName = "OutputWorkspace"
)
{
UNUSED_ARG(baseName);UNUSED_ARG(function);UNUSED_ARG(domain);UNUSED_ARG(values);UNUSED_ARG(outputWorkspacePropertyName);
throw std::logic_error("Method createOutputWorkspace() isn't implemented");
}

/// Initialize the function
/// @param function :: A function to initialize.
Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/IMDIterator.h
Expand Up @@ -116,6 +116,9 @@ class IMDWorkspace;
/// Find neighbouring indexes.
virtual std::vector<size_t> findNeighbourIndexes() const = 0;

/// Get the linear index.
virtual size_t getLinearIndex() const = 0;

protected:
/// Normalization method for getNormalizedSignal()
Mantid::API::MDNormalization m_normalization;
Expand Down
Expand Up @@ -83,6 +83,8 @@ namespace API

virtual std::vector<size_t> findNeighbourIndexes() const;

virtual size_t getLinearIndex() const;

private:
void calcWorkspacePos(size_t newWI);

Expand Down
Expand Up @@ -54,6 +54,12 @@ class MANTID_API_DLL MultiDomainFunction : public CompositeFunction
virtual void function(const FunctionDomain& domain, FunctionValues& values)const;
/// Derivatives of function with respect to active parameters
virtual void functionDeriv(const FunctionDomain& domain, Jacobian& jacobian);
/// Called at the start of each iteration
virtual void iterationStarting();
/// Called at the end of an iteration
virtual void iterationFinished();
/// Create a list of equivalent functions
virtual std::vector<IFunction_sptr> createEquivalentFunctions() const;

/// Associate a function and a domain
void setDomainIndex(size_t funIndex, size_t domainIndex);
Expand All @@ -63,6 +69,8 @@ class MANTID_API_DLL MultiDomainFunction : public CompositeFunction
void clearDomainIndices();
/// Get the largest domain index
size_t getMaxIndex() const {return m_maxIndex;}
/// Get domain indices for a member function
void getDomainIndices(size_t i, size_t nDomains, std::vector<size_t>& domains)const;

/// Returns the number of attributes associated with the function
virtual size_t nLocalAttributes()const {return 1;}
Expand All @@ -80,7 +88,6 @@ class MANTID_API_DLL MultiDomainFunction : public CompositeFunction
/// Counts number of the domains
void countNumberOfDomains();
void countValueOffsets(const CompositeDomain& domain)const;
void getFunctionDomains(size_t i, const CompositeDomain& cd, std::vector<size_t>& domains)const;

/// Domain index map: finction -> domain
std::map<size_t, std::vector<size_t> > m_domains;
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/src/CatalogManager.cpp
Expand Up @@ -55,7 +55,7 @@ namespace Mantid
}

// If we reached this point then the session is corrupt/invalid.
throw std::runtime_error("The session ID you have provided is invalid");
throw std::runtime_error("The session ID you have provided is invalid.");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/src/IFunction.cpp
Expand Up @@ -1024,7 +1024,7 @@ void IFunction::convertValue(std::vector<double>& values, Kernel::Unit_sptr& out
{
// Get l1, l2 and theta (see also RemoveBins.calculateDetectorPosition())
Instrument_const_sptr instrument = ws->getInstrument();
Geometry::IObjComponent_const_sptr sample = instrument->getSample();
Geometry::IComponent_const_sptr sample = instrument->getSample();
if (sample == NULL)
{
g_log.error() << "No sample defined instrument. Cannot convert units for function\n"
Expand Down
10 changes: 5 additions & 5 deletions Code/Mantid/Framework/API/src/MatrixWorkspace.cpp
Expand Up @@ -752,8 +752,8 @@ namespace Mantid
{
Instrument_const_sptr instrument = getInstrument();

Geometry::IObjComponent_const_sptr source = instrument->getSource();
Geometry::IObjComponent_const_sptr sample = instrument->getSample();
Geometry::IComponent_const_sptr source = instrument->getSource();
Geometry::IComponent_const_sptr sample = instrument->getSample();
if ( source == NULL || sample == NULL )
{
throw Kernel::Exception::InstrumentDefinitionError("Instrument not sufficiently defined: failed to get source and/or sample");
Expand All @@ -778,8 +778,8 @@ namespace Mantid
*/
double MatrixWorkspace::detectorTwoTheta(Geometry::IDetector_const_sptr det) const
{
Geometry::IObjComponent_const_sptr source = getInstrument()->getSource();
Geometry::IObjComponent_const_sptr sample = getInstrument()->getSample();
Geometry::IComponent_const_sptr source = getInstrument()->getSource();
Geometry::IComponent_const_sptr sample = getInstrument()->getSample();
if ( source == NULL || sample == NULL )
{
throw Kernel::Exception::InstrumentDefinitionError("Instrument not sufficiently defined: failed to get source and/or sample");
Expand Down Expand Up @@ -1556,7 +1556,7 @@ namespace Mantid
try
{
Geometry::Instrument_const_sptr inst = this->getInstrument();
Geometry::IObjComponent_const_sptr sample = inst->getSample();
Geometry::IComponent_const_sptr sample = inst->getSample();
if (sample)
{
Kernel::V3D sample_pos = sample->getPos();
Expand Down
5 changes: 5 additions & 0 deletions Code/Mantid/Framework/API/src/MatrixWorkspaceMDIterator.cpp
Expand Up @@ -311,6 +311,11 @@ namespace API
throw std::runtime_error("MatrixWorkspaceMDIterator does not implement findNeighbourIndexes");
}

size_t MatrixWorkspaceMDIterator::getLinearIndex() const
{
throw std::runtime_error("MatrixWorkspaceMDIterator does not implement getLinearIndex");
}


} // namespace Mantid
} // namespace API
85 changes: 81 additions & 4 deletions Code/Mantid/Framework/API/src/MultiDomainFunction.cpp
Expand Up @@ -80,13 +80,16 @@ namespace API

/**
* Populates a vector with domain indices assigned to function i.
* @param i :: Index of a function to get the domain info about.
* @param nDomains :: Maximum number of domains.
* @param domains :: (Output) vector to collect domain indixes.
*/
void MultiDomainFunction::getFunctionDomains(size_t i, const CompositeDomain& cd, std::vector<size_t>& domains)const
void MultiDomainFunction::getDomainIndices(size_t i, size_t nDomains, std::vector<size_t>& domains)const
{
auto it = m_domains.find(i);
if (it == m_domains.end())
{// apply to all domains
domains.resize(cd.getNParts());
domains.resize(nDomains);
for(size_t i = 0; i < domains.size(); ++i)
{
domains[i] = i;
Expand Down Expand Up @@ -128,7 +131,7 @@ namespace API
{
// find the domains member function must be applied to
std::vector<size_t> domains;
getFunctionDomains(iFun, cd, domains);
getDomainIndices(iFun, cd.getNParts(), domains);

for(auto i = domains.begin(); i != domains.end(); ++i)
{
Expand Down Expand Up @@ -163,7 +166,7 @@ namespace API
{
// find the domains member function must be applied to
std::vector<size_t> domains;
getFunctionDomains(iFun, cd, domains);
getDomainIndices(iFun, cd.getNParts(), domains);

for(auto i = domains.begin(); i != domains.end(); ++i)
{
Expand All @@ -174,6 +177,28 @@ namespace API
}
}

/**
* Called at the start of each iteration. Call iterationStarting() of the members.
*/
void MultiDomainFunction::iterationStarting()
{
for(size_t iFun = 0; iFun < nFunctions(); ++iFun)
{
getFunction(iFun)->iterationStarting();
}
}

/**
* Called at the end of an iteration. Call iterationFinished() of the members.
*/
void MultiDomainFunction::iterationFinished()
{
for(size_t iFun = 0; iFun < nFunctions(); ++iFun)
{
getFunction(iFun)->iterationFinished();
}
}

/// Return a value of attribute attName
IFunction::Attribute MultiDomainFunction::getLocalAttribute(size_t i, const std::string& attName)const
{
Expand Down Expand Up @@ -251,6 +276,58 @@ namespace API
setDomainIndices(i,indx);
}

/**
* Split this function into independent functions. The number of functions in the
* returned vector must be equal to the number
* of domains. The result of evaluation of the i-th function on the i-th domain must be
* the same as if this MultiDomainFunction was evaluated.
*/
std::vector<IFunction_sptr> MultiDomainFunction::createEquivalentFunctions() const
{
size_t nDomains = m_maxIndex + 1;
std::vector<CompositeFunction_sptr> compositeFunctions(nDomains);
for(size_t iFun = 0; iFun < nFunctions(); ++iFun)
{
// find the domains member function must be applied to
std::vector<size_t> domains;
getDomainIndices(iFun, nDomains, domains);

for(auto i = domains.begin(); i != domains.end(); ++i)
{
size_t j = *i;
CompositeFunction_sptr cf = compositeFunctions[j];
if ( !cf )
{
// create a composite function for each domain
cf = CompositeFunction_sptr(new CompositeFunction());
compositeFunctions[j] = cf;
}
// add copies of all functions applied to j-th domain to a single compositefunction
cf->addFunction( FunctionFactory::Instance().createInitialized( getFunction(iFun)->asString() ));
}
}
std::vector<IFunction_sptr> outFunctions(nDomains);
// fill in the output vector
// check functions containing a single member and take it out of the composite
for(size_t i = 0; i < compositeFunctions.size(); ++i)
{
auto fun = compositeFunctions[i];
if ( !fun || fun->nFunctions() == 0 )
{
throw std::runtime_error("There is no function for domain " + boost::lexical_cast<std::string>(i));
}
if ( fun->nFunctions() > 1 )
{
outFunctions[i] = fun;
}
else
{
outFunctions[i] = fun->getFunction(0);
}
}
return outFunctions;
}


} // namespace API
} // namespace Mantid
18 changes: 9 additions & 9 deletions Code/Mantid/Framework/API/test/AlgorithmHasPropertyTest.h
Expand Up @@ -62,34 +62,34 @@ class AlgorithmHasPropertyTest : public CxxTest::TestSuite

void test_Algorithm_With_Correct_Property_Is_Valid()
{
AlgorithmHasProperty *check = new AlgorithmHasProperty("OutputWorkspace");
AlgorithmHasProperty check("OutputWorkspace");
IAlgorithm_sptr tester(new AlgorithmWithWorkspace);
tester->initialize();
tester->execute();

TS_ASSERT_EQUALS(check->isValid(tester), "");
TS_ASSERT_EQUALS(check.isValid(tester), "");
}

void test_Algorithm_Without_Property_Is_Invalid()
{
AlgorithmHasProperty *check = new AlgorithmHasProperty("OutputWorkspace");
AlgorithmHasProperty check("OutputWorkspace");
IAlgorithm_sptr tester(new AlgorithmWithNoWorkspace);
tester->initialize();
tester->execute();

TS_ASSERT_EQUALS(check->isValid(tester),
"Algorithm object does not have the required property \"OutputWorkspace\"");
TS_ASSERT_EQUALS(check.isValid(tester),
"Algorithm object does not have the required property \"OutputWorkspace\"");
}

void test_Algorithm_With_Invalid_Property_Is_Invalid()
{
AlgorithmHasProperty *check = new AlgorithmHasProperty("OutputValue");
AlgorithmHasProperty check("OutputValue");
IAlgorithm_sptr tester(new AlgorithmWithInvalidProperty);
tester->initialize();

TS_ASSERT_EQUALS(check->isValid(tester),
"Algorithm object contains the required property \"OutputValue\" but "
"it has an invalid value: -1");
TS_ASSERT_EQUALS(check.isValid(tester),
"Algorithm object contains the required property \"OutputValue\" but "
"it has an invalid value: -1");
}


Expand Down

0 comments on commit 0b2695c

Please sign in to comment.