Skip to content

Commit

Permalink
Merge branch 'master' into feature/10368_apply_corrections_preview_plot
Browse files Browse the repository at this point in the history
Conflicts:
	Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/IndirectTab.h

Refs #10368
  • Loading branch information
DanNixon committed Nov 12, 2014
2 parents b36a204 + 6bb6db0 commit 45f2acf
Show file tree
Hide file tree
Showing 62 changed files with 2,899 additions and 417 deletions.
2 changes: 2 additions & 0 deletions .clang-format
@@ -0,0 +1,2 @@
BasedOnStyle: LLVM

2 changes: 2 additions & 0 deletions Code/Mantid/Build/CMake/DarwinSetup.cmake
Expand Up @@ -159,6 +159,8 @@ file ( GLOB THIRDPARTY_PYTHON_PACKAGES ${CMAKE_LIBRARY_PATH}/Python/* )
foreach ( PYPACKAGE ${THIRDPARTY_PYTHON_PACKAGES} )
if ( IS_DIRECTORY ${PYPACKAGE} )
install ( DIRECTORY ${PYPACKAGE} DESTINATION ${BIN_DIR} )
else()
install ( FILES ${PYPACKAGE} DESTINATION ${BIN_DIR} )
endif()
file ( COPY ${PYPACKAGE} DESTINATION ${PROJECT_BINARY_DIR}/bin )
endforeach( PYPACKAGE )
Expand Down
122 changes: 63 additions & 59 deletions Code/Mantid/Framework/API/src/Algorithm.cpp
Expand Up @@ -523,30 +523,55 @@ namespace Mantid
}
}

// ----- Check for processing groups -------------
// default true so that it has the right value at the check below the catch block should checkGroups throw
bool callProcessGroups = true;
try
{
// Checking the input is a group. Throws if the sizes are wrong
callProcessGroups = this->checkGroups();
}
catch(std::exception& ex)
{
getLogger().error() << "Error in execution of algorithm "<< this->name() << "\n"
<< ex.what() << "\n";
notificationCenter().postNotification(new ErrorNotification(this,ex.what()));
m_running = false;
if (m_isChildAlgorithm || m_runningAsync || m_rethrow)
{
m_runningAsync = false;
throw;
}
return false;
}

// ----- Perform validation of the whole set of properties -------------
std::map<std::string, std::string> errors = this->validateInputs();
if (!errors.empty())
if (!callProcessGroups) // for groups this is called on each workspace separately
{
size_t numErrors = errors.size();
// Log each issue
auto & errorLog = getLogger().error();
auto & warnLog = getLogger().warning();
for (auto it = errors.begin(); it != errors.end(); it++)
std::map<std::string, std::string> errors = this->validateInputs();
if (!errors.empty())
{
if (this->existsProperty(it->first))
errorLog << "Invalid value for " << it->first << ": " << it->second << "\n";
else
size_t numErrors = errors.size();
// Log each issue
auto & errorLog = getLogger().error();
auto & warnLog = getLogger().warning();
for (auto it = errors.begin(); it != errors.end(); it++)
{
numErrors -= 1; // don't count it as an error
warnLog << "validateInputs() references non-existant property \""
<< it->first << "\"\n";
if (this->existsProperty(it->first))
errorLog << "Invalid value for " << it->first << ": " << it->second << "\n";
else
{
numErrors -= 1; // don't count it as an error
warnLog << "validateInputs() references non-existant property \""
<< it->first << "\"\n";
}
}
// Throw because something was invalid
if (numErrors > 0)
{
notificationCenter().postNotification(new ErrorNotification(this,"Some invalid Properties found"));
throw std::runtime_error("Some invalid Properties found");
}
}
// Throw because something was invalid
if (numErrors > 0)
{
notificationCenter().postNotification(new ErrorNotification(this,"Some invalid Properties found"));
throw std::runtime_error("Some invalid Properties found");
}
}

Expand All @@ -562,50 +587,29 @@ namespace Mantid
m_history = boost::make_shared<AlgorithmHistory>(algHist);
}

// ----- Check for processing groups -------------
// default true so that it has the right value at the check below the catch block should checkGroups throw
bool callProcessGroups = true;
try
{
// Checking the input is a group. Throws if the sizes are wrong
callProcessGroups = this->checkGroups();
if (callProcessGroups)
{
// This calls this->execute() again on each member of the group.
start_time = Mantid::Kernel::DateAndTime::getCurrentTime();
// Start a timer
Timer timer;
// Call the concrete algorithm's exec method
const bool completed = processGroups();
// Check for a cancellation request in case the concrete algorithm doesn't
interruption_point();
// Get how long this algorithm took to run
const float duration = timer.elapsed();

if(completed)
{
// Log that execution has completed.
reportCompleted(duration, true/*indicat that this is for group processing*/);
}
return completed;
}
}
catch(std::exception& ex)
// ----- Process groups -------------
// If checkGroups() threw an exception but there ARE group workspaces
// (means that the group sizes were incompatible)
if (callProcessGroups)
{
getLogger().error() << "Error in execution of algorithm "<< this->name() << std::endl
<< ex.what()<<std::endl;
notificationCenter().postNotification(new ErrorNotification(this,ex.what()));
m_running = false;
if (m_isChildAlgorithm || m_runningAsync || m_rethrow)
// This calls this->execute() again on each member of the group.
start_time = Mantid::Kernel::DateAndTime::getCurrentTime();
// Start a timer
Timer timer;
// Call the concrete algorithm's exec method
const bool completed = processGroups();
// Check for a cancellation request in case the concrete algorithm doesn't
interruption_point();
// Get how long this algorithm took to run
const float duration = timer.elapsed();

if(completed)
{
m_runningAsync = false;
throw;
// Log that execution has completed.
reportCompleted(duration, true/*indicat that this is for group processing*/);
}
return completed;
}
// If checkGroups() threw an exception but there ARE group workspaces
// (means that the group sizes were incompatible)
if (callProcessGroups)
return false;

// Read or write locks every input/output workspace
this->lockWorkspaces();
Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/Algorithms/CMakeLists.txt
Expand Up @@ -54,6 +54,7 @@ set ( SRC_FILES
src/CopyInstrumentParameters.cpp
src/CopyLogs.cpp
src/CopySample.cpp
src/CorelliCrossCorrelate.cpp
src/CorrectFlightPaths.cpp
src/CorrectKiKf.cpp
src/CorrectToFile.cpp
Expand Down Expand Up @@ -302,6 +303,7 @@ set ( INC_FILES
inc/MantidAlgorithms/CopyInstrumentParameters.h
inc/MantidAlgorithms/CopyLogs.h
inc/MantidAlgorithms/CopySample.h
inc/MantidAlgorithms/CorelliCrossCorrelate.h
inc/MantidAlgorithms/CorrectFlightPaths.h
inc/MantidAlgorithms/CorrectKiKf.h
inc/MantidAlgorithms/CorrectToFile.h
Expand Down Expand Up @@ -562,6 +564,7 @@ set ( TEST_FILES
CopyInstrumentParametersTest.h
CopyLogsTest.h
CopySampleTest.h
CorelliCrossCorrelateTest.h
CorrectFlightPathsTest.h
CorrectKiKfTest.h
CorrectToFileTest.h
Expand Down
@@ -0,0 +1,59 @@
#ifndef MANTID_ALGORITHMS_CORELLICROSSCORRELATE_H_
#define MANTID_ALGORITHMS_CORELLICROSSCORRELATE_H_

#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidDataObjects/EventWorkspace.h"

namespace Mantid {
namespace Algorithms {

/** CorelliCrossCorrelate : TODO: DESCRIPTION
Copyright &copy; 2014 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge
National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport CorelliCrossCorrelate : public API::Algorithm {
public:
CorelliCrossCorrelate();
virtual ~CorelliCrossCorrelate();

virtual const std::string name() const { return "CorelliCrossCorrelate"; };
virtual int version() const { return 1; };
virtual const std::string category() const { return "Diffraction;Events"; };
virtual const std::string summary() const {
return "Cross-correlation calculation for the elastic signal from Corelli.";
};

private:
std::map<std::string, std::string> validateInputs();
void init();
void exec();

/// Input workspace
DataObjects::EventWorkspace_const_sptr inputWS;
DataObjects::EventWorkspace_sptr outputWS;
};

} // namespace Algorithms
} // namespace Mantid

#endif /* MANTID_ALGORITHMS_CORELLICROSSCORRELATE_H_ */

0 comments on commit 45f2acf

Please sign in to comment.