Skip to content

Commit

Permalink
refs #4201 Trivial merge has been performed
Browse files Browse the repository at this point in the history
Merge branch 'master' of https://github.com/mantidproject/mantid

Conflicts:
	Code/Mantid/Framework/MDAlgorithms/src/ConvertToMDEvents.cpp
  • Loading branch information
abuts committed Dec 7, 2011
2 parents f2db0a7 + e491126 commit 2287bdc
Show file tree
Hide file tree
Showing 99 changed files with 3,041 additions and 537 deletions.
12 changes: 12 additions & 0 deletions Code/Mantid/Build/CMake/CommonSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,18 @@ else()
message (STATUS "Could NOT find PyUnitTest - unit testing of python not available" )
endif()

# GUI testing via Squish
find_package ( Squish )
if ( SQUISH_FOUND )
# CMAKE_MODULE_PATH gets polluted when ParaView is present
set( MANTID_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} )
include( SquishAddTestSuite )
enable_testing()
message ( STATUS "Found Squish for GUI testing" )
else()
message ( STATUS "Could not find Squish - GUI testing not available" )
endif()

###########################################################################
# Set a flag to indicate that this script has been called
###########################################################################
Expand Down
62 changes: 62 additions & 0 deletions Code/Mantid/Build/CMake/SquishAddTestSuite.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
##############################################################################
#
# This macro will add a list of test suites into the ctest mechanism. The
# ctest name is generated from the name of the
#
##############################################################################
macro( SQUISH_ADD_TEST_SUITE )
foreach( _test_suite_path ${ARGN} )
set( testSuite ${CMAKE_CURRENT_SOURCE_DIR}/${_test_suite_path} )
string( REGEX MATCH "/.+$" _test_suite ${_test_suite_path} )
string( REGEX REPLACE "/" "" _test_suite ${_test_suite} )
string( REGEX REPLACE "suite_" "" _test_suite ${_test_suite} )
set( testName ${_test_suite}SquishTests )
#message( STATUS "Creating Squish test ${testName}" )
set( resultFile "${CMAKE_BINARY_DIR}/bin/Testing/TEST-${testName}.xml" )
add_test(${testName}
${CMAKE_COMMAND}
"-Dsquish_server_executable:STRING=${SQUISH_SERVER_EXECUTABLE}"
"-Dsquish_client_executable:STRING=${SQUISH_CLIENT_EXECUTABLE}"
"-Dsquish_test_suite:STRING=${testSuite}"
"-Dsquish_results_dir:STRING=${CMAKE_BINARY_DIR}/bin/Testing"
"-Dsquish_results_file:STRING=${resultFile}"
"-Dmantid_cmake_modules:STRING=${MANTID_CMAKE_MODULE_PATH}"
-P ${MANTID_CMAKE_MODULE_PATH}/SquishTestScript.cmake
)
set_tests_properties( ${testName} PROPERTIES FAIL_REGULAR_EXPRESSION
"FAILED;ERROR;FATAL"
)
endforeach( )
endmacro( SQUISH_ADD_TEST_SUITE )

##############################################################################
#
# This macro creates an envvars file in the test suite directory.
#
##############################################################################
macro( SQUISH_SUITE_ENVVARS testSuites )
set( env_file "envvars" )
# ARGN doesn't like to be used as CMake list
set( pair_list "" )
foreach( arg ${ARGN} )
set( pair_list ${pair_list} ${arg} )
endforeach( arg )
list( LENGTH pair_list count )
math( EXPR count "${count}/2" )
foreach( _test_suite_path ${testSuites} )
set( testSuite ${CMAKE_CURRENT_SOURCE_DIR}/${_test_suite_path} )
set( outFile ${testSuite}/${env_file} )
foreach( i RANGE 0 ${count} 2 )
math( EXPR index1 "${i}" )
math( EXPR index2 "${i}+1" )
list( GET pair_list ${index1} key )
list( GET pair_list ${index2} value )
set( key_value_pair "${key}=${value}\n" )
if( ${i} EQUAL 0 )
file( WRITE ${outFile} ${key_value_pair} )
else( ${i} EQUAL 0 )
file( APPEND ${outFile} ${key_value_pair} )
endif( ${i} EQUAL 0 )
endforeach( i RANGE 0 ${count} 2 )
endforeach( _test_suite_path ${testSuites} )
endmacro( SQUISH_SUITE_ENVVARS )
11 changes: 11 additions & 0 deletions Code/Mantid/Build/CMake/SquishRunTestSuite.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
echo 'Starting the squish server...'
start %1

echo 'Running the test suite...'
%2 --testsuite %3 --resultdir %4 --reportgen xmljunit,%5
set result=%ERRORLEVEL%

echo 'Stopping the squish server...'
%1 --stop

exit \b %result%
15 changes: 15 additions & 0 deletions Code/Mantid/Build/CMake/SquishRunTestSuite.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh
echo "Starting"
echo "Starting the squish server...$1 --daemon"
$1 --daemon

results="xmljunit,${5}"

echo "Running the test suite...$2 --testsuite $3 --resultdir $4 --reportgen ${results}"
$2 --testsuite $3 --resultdir $4 --reportgen ${results}
returnValue=$?

echo "Stopping the squish server...$1 --stop"
$1 --stop

exit $returnValue
43 changes: 43 additions & 0 deletions Code/Mantid/Build/CMake/SquishTestScript.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#
# This script launches a GUI test suite using Squish. You should not call
# the script directly; instead, you should access it via the
# SQUISH_ADD_TEST_SUITE macro.
#
# This script starts the Squish server, launches the test suite on the
# client, and finally stops the squish server. If any of these steps
# fail (including if the tests do not pass) then a fatal error is
# raised.
#
# Based on the SQUISH_ADD_TEST macro
#
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)

message(STATUS "squish_server_executable='${squish_server_executable}'")
message(STATUS "squish_client_executable='${squish_client_executable}'")
message(STATUS "squish_test_suite='${squish_test_suite}'")
message(STATUS "squish_results_dir='${squish_results_dir}'")
message(STATUS "squish_results_file='${squish_results_file}'")

# run the test
if (WIN32)
execute_process(
COMMAND ${mantid_cmake_modules}/SquishRunTestSuite.bat ${squish_server_executable} ${squish_client_executable} ${squish_test_suite} ${squish_results_dir} ${squish_results_file}
RESULT_VARIABLE test_rv
)
endif (WIN32)

if (UNIX)
execute_process(
COMMAND ${mantid_cmake_modules}/SquishRunTestSuite.sh ${squish_server_executable} ${squish_client_executable} ${squish_test_suite} ${squish_results_dir} ${squish_results_file}
RESULT_VARIABLE test_rv
)
endif (UNIX)

# check for an error with running the test
if(NOT "${test_rv}" STREQUAL "0")
message(FATAL_ERROR "Error running Squish test")
endif(NOT "${test_rv}" STREQUAL "0")

file(READ ${squish_results_file} error_log)
message(STATUS ${error_log})

1 change: 1 addition & 0 deletions Code/Mantid/Framework/API/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ set ( SRC_FILES
src/FileFinder.cpp
src/FileProperty.cpp
src/FrameworkManager.cpp
src/FunctionDomain.cpp
src/FunctionFactory.cpp
src/IDataFileChecker.cpp
src/IEventList.cpp
Expand Down
31 changes: 25 additions & 6 deletions Code/Mantid/Framework/API/inc/MantidAPI/FunctionDomain.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
#include "MantidAPI/DllConfig.h"
#include "MantidKernel/Exception.h"

#include <vector>

namespace Mantid
{
namespace API
{
/** Abstract class that represents the domain of a function.
/** Base class that represents the domain of a function.
A domain is a generalisation of x (argument) and y (value) arrays.
A domain consists at least of a list of function arguments for which a function should
be evaluated and a buffer for the calculated values. If used in fitting also contains
Expand Down Expand Up @@ -43,14 +45,31 @@ namespace API
class MANTID_API_DLL FunctionDomain
{
public:
/// Constructor.
FunctionDomain(size_t n);
/// Virtual destructor
virtual ~FunctionDomain(){}
/// Return the number of points, values, etc in the domain
virtual size_t size() const = 0;
virtual size_t size() const {return m_calculated.size();}
/// store i-th calculated value. 0 <= i < size()
virtual void setCalculated(size_t i,double value) = 0;
virtual void setCalculated(size_t i,double value) {m_calculated[i] = value;}
/// get i-th calculated value. 0 <= i < size()
virtual double getCalculated(size_t i) const = 0;
/// Virtual destructor
virtual ~FunctionDomain(){}
virtual double getCalculated(size_t i) const {return m_calculated[i];}
/// set a fitting data value
virtual void setFitData(size_t i,double value);
virtual void setFitData(const std::vector<double>& values);
/// get a fitting data value
virtual double getFitData(size_t i) const;
/// set a fitting weight
virtual void setFitWeight(size_t i,double value);
virtual void setFitWeights(const std::vector<double>& values);
/// get a fitting weight
virtual double getFitWeight(size_t i) const;
protected:
void setDataSize();
std::vector<double> m_calculated; ///< buffer for calculated values
std::vector<double> m_data; ///< buffer for fit data
std::vector<double> m_weights; ///< buffer for fitting weights (reciprocal errors)
};

} // namespace API
Expand Down
2 changes: 2 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/IFitFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ class MANTID_API_DLL IFitFunction: public virtual IFunction
setWorkspace(ws,copyData);
setSlicing(slicing);
}
/// Get the workspace
virtual boost::shared_ptr<const API::Workspace> getWorkspace()const = 0;
virtual void setWorkspace(boost::shared_ptr<const Workspace> ws,bool copyData) = 0;
virtual void setSlicing(const std::string& slicing) = 0;

Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/inc/MantidAPI/IFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class MANTID_API_DLL IFunction
/// @param ws :: Shared pointer to a workspace
virtual void setWorkspace(boost::shared_ptr<const Workspace> ws) = 0;
/// Get the workspace
virtual boost::shared_ptr<const API::Workspace> getWorkspace()const = 0;
//virtual boost::shared_ptr<const API::Workspace> getWorkspace()const = 0;
/// Iinialize the function
virtual void initialize(){this->init();}

Expand Down
9 changes: 9 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/ITableWorkspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ class ITableWorkspace_DllExport ITableWorkspace: public API::Workspace
return getRow(rowCount()-1);
}

/** Does this type of TableWorkspace need a custom sorting call (e.g. PeaksWorkspace)
* @return true if the workspace needs custom sorting calls */
virtual bool customSort() const
{ return false; }

/// Overridable method to custom-sort the workspace
virtual void sort(std::vector< std::pair<std::string, bool> > & criteria);


/// Access the column with name \c name trough a ColumnVector object
TableColumnHelper getVector(const std::string& name)
{
Expand Down
34 changes: 23 additions & 11 deletions Code/Mantid/Framework/API/inc/MantidAPI/TempFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//----------------------------------------------------------------------
#include "MantidAPI/DllConfig.h"
#include "MantidAPI/IFunction.h"
#include "MantidAPI/IFitFunction.h"
#include "MantidAPI/IFunctionMW.h"
#include "MantidKernel/Exception.h"

#ifdef _WIN32
Expand All @@ -17,7 +17,7 @@ namespace Mantid
{
namespace API
{
/** This is a temporari helper class to aid transition from IFitFunction to IFunction.
/** This is a temporary helper class to aid transition from IFitFunction to IFunction.
@author Roman Tolchenov, Tessella Support Services plc
@date 17/11/2011
Expand Down Expand Up @@ -46,15 +46,15 @@ class MANTID_API_DLL TempFunction: public virtual IFunction
{
public:
/// Constructor
TempFunction(IFitFunction* function);
TempFunction(IFunctionMW* function);

/// Returns the function's name
virtual std::string name()const {return m_function->name();}
/// Set the workspace. Make
/// @param ws :: Shared pointer to a workspace
virtual void setWorkspace(boost::shared_ptr<const Workspace> ws) { UNUSED_ARG(ws) }
/// Get the workspace
virtual boost::shared_ptr<const API::Workspace> getWorkspace()const {return m_function->getWorkspace();}
//virtual boost::shared_ptr<const API::Workspace> getWorkspace()const {return m_function->getWorkspace();}

/// The categories the Fit function belong to.
/// Categories must be listed as a comma separated list.
Expand All @@ -63,12 +63,8 @@ class MANTID_API_DLL TempFunction: public virtual IFunction
/// "Muon\\Custom"
virtual const std::string category() const { return m_function->category();}

/// Function you want to fit to.
/// @param out :: The buffer for writing the calculated values. Must be big enough to accept dataSize() values
virtual void function(FunctionDomain& domain)const {
UNUSED_ARG(domain)
throw Kernel::Exception::NotImplementedError("TempFunction not implemented.");
}
virtual void function(FunctionDomain& domain)const;
virtual void functionDeriv(FunctionDomain& domain, Jacobian& jacobian);

/// Set i-th parameter
virtual void setParameter(size_t i, const double& value, bool explicitlySet = true) {m_function->setParameter(i,value,explicitlySet);}
Expand Down Expand Up @@ -151,7 +147,23 @@ class MANTID_API_DLL TempFunction: public virtual IFunction
virtual void addTie(ParameterTie* tie) {m_function->addTie(tie);}

/// Pointer to underlying IFitFunction
IFitFunction* m_function;
IFunctionMW* m_function;
};

/**
* The domain for 1D functions.
*/
class MANTID_API_DLL FunctionDomain1D: public FunctionDomain
{
public:
FunctionDomain1D(double start, double end, size_t n);
FunctionDomain1D(const std::vector<double>& xvalues);
/// get an x value
/// @param i :: Index
double getX(size_t i) const {return m_X.at(i);}
protected:
std::vector<double> m_X; ///< vector of function arguments
friend class TempFunction;
};


Expand Down
7 changes: 1 addition & 6 deletions Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceProperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ namespace Mantid
else
{
error = "Workspace " + this->value() + " is not of the correct type";
g_log.debug() << "Problem validating workspace: " << error << ". \""
<< m_workspaceName << "\" is not of type " << Kernel::PropertyWithValue< boost::shared_ptr<TYPE> >::type() << std::endl;
}
return error;
}
Expand Down Expand Up @@ -391,8 +389,6 @@ namespace Mantid
if( m_optional ) return "";
//Return a user level error
error = "Enter a name for the Output workspace";
//the debug message has more detail to put it in context
g_log.debug() << "Problem validating workspace: " << error << std::endl;
return error;
}
}
Expand Down Expand Up @@ -420,8 +416,7 @@ namespace Mantid
{
error = "Workspace \"" + this->value() + "\" was not found in the Analysis Data Service";
}
if( !error.empty() )
g_log.debug() << "Problem validating workspace: " << error << "." << std::endl;

return error;
}

Expand Down

0 comments on commit 2287bdc

Please sign in to comment.