Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feature/5421_IDA_ba…
Browse files Browse the repository at this point in the history
…yes_interface

Conflicts:
	Code/Mantid/MantidQt/CustomInterfaces/CMakeLists.txt
	Code/Mantid/scripts/Inelastic/IndirectBayes.py

Refs #5421
  • Loading branch information
Samuel Jackson committed Oct 24, 2013
2 parents f75e801 + 98c0b33 commit 814fabb
Show file tree
Hide file tree
Showing 224 changed files with 11,741 additions and 3,696 deletions.
10 changes: 7 additions & 3 deletions Code/Mantid/Build/CMake/DarwinSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ set ( PVPLUGINS_DIR MantidPlot.app/pvplugins )
set ( PVPLUGINS_SUBDIR pvplugins ) # Need to tidy these things up!

# Python packages
set ( PYTHON_PACKAGES_DIR ${CMAKE_LIBRARY_PATH}/Python )

install ( PROGRAMS /Library/Python/${PY_VER}/site-packages/sip.so DESTINATION ${BIN_DIR} )
# Explicitly specify which PyQt libraries we want because just taking the whole
Expand All @@ -75,8 +74,13 @@ install ( FILES /Library/Python/${PY_VER}/site-packages/PyQt4/Qt.so
/Library/Python/${PY_VER}/site-packages/PyQt4/__init__.py
DESTINATION ${BIN_DIR}/PyQt4 )
install ( DIRECTORY /Library/Python/${PY_VER}/site-packages/PyQt4/uic DESTINATION ${BIN_DIR}/PyQt4 )
# nxs package
install ( DIRECTORY ${PYTHON_PACKAGES_DIR}/nxs DESTINATION ${BIN_DIR} )

# Python packages in Third_Party need copying to build directory and the final package
file ( GLOB THIRDPARTY_PYTHON_PACKAGES ${CMAKE_LIBRARY_PATH}/Python/* )
foreach ( PYPACKAGE ${THIRDPARTY_PYTHON_PACKAGES} )
install ( DIRECTORY ${PYPACKAGE} DESTINATION ${BIN_DIR} )
file ( COPY ${PYPACKAGE} DESTINATION ${PROJECT_BINARY_DIR}/bin )
endforeach( PYPACKAGE )

install ( DIRECTORY ${QT_PLUGINS_DIR}/imageformats DESTINATION MantidPlot.app/Contents/Frameworks/plugins )

Expand Down
3 changes: 2 additions & 1 deletion Code/Mantid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ if ( ENABLE_CPACK )
# rhel requirements
set ( CPACK_RPM_PACKAGE_REQUIRES "boost >= 1.34.1,qt4 >= 4.2,nexus,nexus-python,qwt,gsl,glibc,qwtplot3d-qt4,OpenCASCADE-libs-modelling >= 6.3.0,OpenCASCADE-libs-foundation >= 6.3.0,OpenCASCADE-libs-visualization >= 6.3.0,OpenCASCADE-libs-ocaf >= 6.3.0,OpenCASCADE-libs-ocaf-lite >= 6.3.0,muParser,numpy" )
set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES},poco-crypto,poco-data,poco-mysql,poco-sqlite,poco-odbc,poco-util,poco-xml,poco-zip,poco-net,poco-netssl,poco-foundation,PyQt4,sip" )
# scipy & matplotlib (ipython is too low a version to be used)
set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES},python-ipython >= 1.1.0" )
# scipy & matplotlib
set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES},scipy,python-matplotlib" )
set ( CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES},mxml,hdf,hdf5" )

Expand Down
7 changes: 7 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/FileLoaderRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ namespace Mantid
m_log.debug() << "Registered '" << nameVersion.first << "' version '" << nameVersion.second << "' as file loader\n";
}

/// Unsubscribe a named algorithm and version from the loader registration
void unsubscribe(const std::string &name, const int version = -1);

/// Returns the name of an Algorithm that can load the given filename
const boost::shared_ptr<IAlgorithm> chooseLoader(const std::string &filename) const;
/// Checks whether the given algorithm can load the file
Expand Down Expand Up @@ -121,6 +124,10 @@ namespace Mantid
}
};

/// Remove a named algorithm & version from the given map
void removeAlgorithm(const std::string & name, const int version,
std::multimap<std::string,int> & typedLoaders);

/// The list of names. The index pointed to by LoaderFormat defines a set for that format
std::vector<std::multimap<std::string,int> > m_names;
/// Total number of names registered
Expand Down
2 changes: 2 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/IBackgroundFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class DLLExport IBackgroundFunction : public IFunctionWithLocation
virtual void fit(const std::vector<double>& X,const std::vector<double>& Y) = 0;
};

typedef boost::shared_ptr<IBackgroundFunction> IBackgroundFunction_sptr;

} // namespace API
} // namespace Mantid

Expand Down
2 changes: 2 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/LogManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ namespace Mantid

/// Empty the values out of all TimeSeriesProperty logs
void clearTimeSeriesLogs();
/// Empty all but the last value out of all TimeSeriesProperty logs
void clearOutdatedTimeSeriesLogValues();

/// Save the run to a NeXus file with a given group name
virtual void saveNexus(::NeXus::File * file, const std::string & group,bool keepOpen=false) const;
Expand Down
4 changes: 3 additions & 1 deletion Code/Mantid/Framework/API/inc/MantidAPI/ScriptRepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -550,10 +550,12 @@ They will work as was expected for folders @ref folders-sec.
@param option: flag to set for auto-update, or not. If true, new versions of the path will replace the local file as soon as they are available at the central repository.
@return int: number of files changed (because of the cascading of folders)
@exception ScriptRepoException : Invalid entry.
*/
virtual void setAutoUpdate(const std::string & path, bool option = true) = 0;
virtual int setAutoUpdate(const std::string & path, bool option = true) = 0;


};
Expand Down
57 changes: 37 additions & 20 deletions Code/Mantid/Framework/API/src/ExperimentInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <Poco/SAX/ContentHandler.h>
#include <Poco/SAX/SAXParser.h>
#include <Poco/ScopedLock.h>
#include <nexus/NeXusException.hpp>

using namespace Mantid::Geometry;
using namespace Mantid::Kernel;
Expand Down Expand Up @@ -867,6 +868,8 @@ namespace API
* @param file :: open NeXus file
* @param[out] parameterStr :: special string for all the parameters.
* Feed that to ExperimentInfo::readParameterMap() after the instrument is done.
* @throws Exception::NotFoundError If instrument definition is not in the nexus file and cannot
* be loaded from the IDF.
*/
void ExperimentInfo::loadExperimentInfoNexus(::NeXus::File * file, std::string & parameterStr)
{
Expand All @@ -890,34 +893,50 @@ namespace API
this->mutableRun().loadNexus(file, "logs");
}

// Now the instrument source
instrumentXml = "";
instrumentName = "";

// Try to get the instrument file
file->openGroup("instrument", "NXinstrument");
file->readData("name", instrumentName);

try {
file->openGroup("instrument_xml", "NXnote");
file->readData("data", instrumentXml );
file->closeGroup();
}
catch (NeXus::Exception& ex) {
// Just carry on - it might not be there (e.g. old-style processed files)
g_log.debug(ex.what());
}

// We first assume this is a new version file, but if the next step fails we assume its and old version file.
int version = 1;
try {
file->readData("instrument_source", instrumentFilename);
}
catch(...) {
}
catch (NeXus::Exception&) {
version = 0;
// In the old version 'processed' file, this was held at the top level (as was the parameter map)
file->closeGroup();
file->readData("instrument_source", instrumentFilename);
try {
file->readData("instrument_source", instrumentFilename);
}
catch (NeXus::Exception& ex) {
// Just carry on - it might not be there (e.g. for SNS files)
g_log.debug(ex.what());
}
}

file->openGroup("instrument_parameter_map", "NXnote");
file->readData("data", parameterStr);
file->closeGroup();
try {
file->openGroup("instrument_parameter_map", "NXnote");
file->readData("data", parameterStr);
file->closeGroup();
}
catch (NeXus::Exception& ex) {
// Just carry on - it might not be there (e.g. for SNS files)
g_log.debug(ex.what());
}

if (version > 0)
if ( version == 1 )
{
file->openGroup("instrument_xml", "NXnote");
file->readData("data", instrumentXml );
file->closeGroup();
file->closeGroup();
}

Expand All @@ -937,16 +956,14 @@ namespace API
}
catch (std::exception & e)
{
g_log.error() << "Error loading instrument IDF file for '" << instrumentName << "'." << std::endl;
g_log.error() << e.what() << std::endl;
g_log.error() << "Error loading instrument IDF file for '" << instrumentName << "'.\n";
g_log.debug() << e.what() << std::endl;
throw;
}
}
else
{
// The filename in the file = just bare file.
// So Get the full path back to the instrument directory.
instrumentFilename = ConfigService::Instance().getInstrumentDirectory() + "/" + instrumentFilename;
g_log.debug() << "Using instrument IDF XML text contained in .nxs file." << std::endl;
g_log.debug() << "Using instrument IDF XML text contained in nexus file.\n";
}


Expand Down
42 changes: 42 additions & 0 deletions Code/Mantid/Framework/API/src/FileLoaderRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ namespace Mantid
const int version = it->second;
logger.debug() << "Checking " << name << " version " << version << std::endl;

// Use static cast for speed. Checks have been done at registration to check the types
auto alg = boost::static_pointer_cast<FileLoaderType>(factory.create(name, version)); // highest version
try
{
Expand All @@ -75,6 +76,20 @@ namespace Mantid
// Public members
//----------------------------------------------------------------------------------------------

/**
* If the name does not exist then it does nothing
* @param name Name of the algorithm to remove from the search list
* @aparam version An optional version to remove. -1 indicates remove all (Default=-1)
*/
void FileLoaderRegistryImpl::unsubscribe(const std::string &name, const int version)
{
auto iend = m_names.end();
for(auto it = m_names.begin(); it != iend; ++it)
{
removeAlgorithm(name, version, *it);
}
}

/**
* Queries each registered algorithm and asks it how confident it is that it can
* load the given file. The name of the one with the highest confidence is returned.
Expand Down Expand Up @@ -161,5 +176,32 @@ namespace Mantid
{
}

/**
* @param name A string containing the algorithm name
* @param version The version to remove. -1 indicates all instances
* @param typedLoaders A map of names to version numbers
**/
void FileLoaderRegistryImpl::removeAlgorithm(const std::string & name, const int version,
std::multimap<std::string,int> & typedLoaders)
{
if(version == -1) // remove all
{
typedLoaders.erase(name);
}
else // find the right version
{
auto range = typedLoaders.equal_range(name);
for(auto ritr = range.first; ritr != range.second; ++ritr)
{
if(ritr->second == version)
{
typedLoaders.erase(ritr);
break;
}
}
}
}


} // namespace API
} // namespace Mantid
17 changes: 16 additions & 1 deletion Code/Mantid/Framework/API/src/LogManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,22 @@ Kernel::Logger& LogManager::g_log = Kernel::Logger::get("LogManager");
}
}


/** Clears out all but the last entry of all logs of type TimeSeriesProperty
* Check the documentation/definition of TimeSeriesProperty::clearOutdated for
* the definition of 'last entry'.
*/
void LogManager::clearOutdatedTimeSeriesLogValues()
{
auto & props = getProperties();
for ( auto it = props.begin(); it != props.end(); ++it)
{
if ( auto tsp = dynamic_cast<ITimeSeriesProperty*>(*it) )
{
tsp->clearOutdated();
}
}
}

//--------------------------------------------------------------------------------------------
/** Save the object to an open NeXus file.
* @param file :: open NeXus file
Expand Down
30 changes: 30 additions & 0 deletions Code/Mantid/Framework/API/test/LogManagerTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,37 @@ class LogManagerTest : public CxxTest::TestSuite
TS_ASSERT_EQUALS( runInfo.getPropertyValueAsType<int>(intProp), 99 );
}

void clearOutdatedTimeSeriesLogValues()
{
// Set up a Run object with 3 properties in it (1 time series, 2 single value)
LogManager runInfo;
const std::string stringProp("aStringProp");
const std::string stringVal("testing");
runInfo.addProperty(stringProp,stringVal);
const std::string intProp("anIntProp");
runInfo.addProperty(intProp,99);
const std::string tspProp("tsp");
addTestTimeSeries(runInfo,"tsp");

// Check it's set up right
TS_ASSERT_EQUALS( runInfo.getProperties().size(), 3 );
auto tsp = runInfo.getTimeSeriesProperty<double>(tspProp);
TS_ASSERT_EQUALS( tsp->realSize(), 10 );

auto lastTime = tsp->lastTime();
auto lastValue = tsp->lastValue();

// Do the clearing work
TS_ASSERT_THROWS_NOTHING( runInfo.clearOutdatedTimeSeriesLogValues() );

// Check the time-series property has 1 entry, & the others are unchanged
TS_ASSERT_EQUALS( runInfo.getProperties().size(), 3 );
TS_ASSERT_EQUALS( tsp->realSize(), 1 );
TS_ASSERT_EQUALS( tsp->firstTime(), lastTime );
TS_ASSERT_EQUALS( tsp->firstValue(), lastValue );
TS_ASSERT_EQUALS( runInfo.getPropertyValueAsType<std::string>(stringProp), stringVal );
TS_ASSERT_EQUALS( runInfo.getPropertyValueAsType<int>(intProp), 99 );
}

/** Save and load to NXS file */
void test_nexus()
Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/Algorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ set ( SRC_FILES
src/FindDetectorsOutsideLimits.cpp
src/FindPeaks.cpp
src/FindPeakBackground.cpp
src/FitPeak.cpp
src/FlatPlateAbsorption.cpp
src/GeneralisedSecondDifference.cpp
src/GenerateEventsFilter.cpp
Expand Down Expand Up @@ -327,6 +328,7 @@ set ( INC_FILES
inc/MantidAlgorithms/FindDetectorsOutsideLimits.h
inc/MantidAlgorithms/FindPeaks.h
inc/MantidAlgorithms/FindPeakBackground.h
inc/MantidAlgorithms/FitPeak.h
inc/MantidAlgorithms/FlatPlateAbsorption.h
inc/MantidAlgorithms/GSLFunctions.h
inc/MantidAlgorithms/GeneralisedSecondDifference.h
Expand Down Expand Up @@ -554,6 +556,7 @@ set ( TEST_FILES
FindDetectorsOutsideLimitsTest.h
FindPeaksTest.h
FindPeakBackgroundTest.h
FitPeakTest.h
FlatPlateAbsorptionTest.h
GenerateEventsFilterTest.h
GeneratePeaksTest.h
Expand Down

0 comments on commit 814fabb

Please sign in to comment.