Skip to content

Commit

Permalink
refs #4328. Resolve merge conflict.
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Dec 15, 2011
2 parents 9f96d90 + 4326b7e commit 25fe889
Show file tree
Hide file tree
Showing 133 changed files with 2,179 additions and 659 deletions.
136 changes: 136 additions & 0 deletions Code/Mantid/Build/doxygen_to_sip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
"""Script that will grab doxygen strings from a
.cpp file and stuff them in the corresponding
.sip file under a %Docstring tag"""
import os
import sys
from optparse import OptionParser

#----------------------------------------------------------
def findInSubdirectory(filename, subdirectory=''):
if subdirectory:
path = subdirectory
else:
path = os.getcwd()
for root, dirs, names in os.walk(path):
if filename in names:
return os.path.join(root, filename)
raise 'File not found'

def find_cpp_file(basedir, classname):
return findInSubdirectory(classname + ".cpp", basedir)



#----------------------------------------------------------
def grab_doxygen(cppfile, method):
"""Grab the DOXYGEN documentation string from a .cpp file
cppfile :: full path to the .cpp file
method :: method definition to look for
"""
lines = open(cppfile, 'r').read().split('\n')
#print method
out = []
for i in range(len(lines)):
line = lines[i].strip()
if line.startswith(method):
# Go backwards above the class to grab the doxygen
for j in range(i-1, -1, -1):
out.insert(0, lines[j])
# Stop when you reach the start of the comment "/**"
if lines[j].strip().startswith('/**'):
break
# OK return the lines
return out
print "WARNING: Could not find method %s" % method
return None


#----------------------------------------------------------
def doxygen_to_docstring(doxygen, method):
""" Takes an array of DOXYGEN lines, and converts
them to a more pleasing python docstring format
@param doxygen :: list of strings contaning the doxygen
@param method :: method declaration string """
out = []
if doxygen is None:
return out
out.append("%Docstring")
out.append(method)
out.append('-' * len(method))
for line in doxygen:
line = line.strip()
if line.startswith("/**"): line = line[3:]
if line.endswith("*/"): line = line[:-2]
if line.startswith("*"): line = line[1:]
# Make the text indented by 4 spaces
line = " " + line
out.append(line)
out.append("%End")
out.append("")
return out

#----------------------------------------------------------
def process_sip(filename):
root = os.path.split(os.path.abspath(filename))[0]
# Read and split into a buncha lines
lines = open(filename, 'r').read().split('\n')
i = 0
classname = ''
classcpp = ''
outlines = []
for i in range(len(lines)):
# Copy to output
outlines.append(lines[i])

line = lines[i].strip()
if line.startswith("class "):
classname = line[6:].strip()
n = classname.find(':')
if n > 0: classname = classname[0:n].strip()
# Now, we look for the .cpp file
classcpp = find_cpp_file(root, classname)
print "Found class '%s' at %s" % (classname, classcpp)

if classname != "":
# We are within a real class
if line.endswith(";"):
# Within a function declaration
n = line.find(')')
if n > 0:
method = line[0:n+1]
n = method.find(' ')
# Make the string like this:
# "void ClassName::method(arguments)"
method = method[0:n+1] + classname + "::" + method[n+1:]
# Now extract the doxygen
doxygen = grab_doxygen(classcpp, method)
# Convert to a docstring
docstring = doxygen_to_docstring(doxygen, method)
# And add to the output
outlines += docstring
# Give back the generated lines
return outlines

if __name__=="__main__":

parser = OptionParser(description='Utility to delete a Mantid class from a project. '
'Please note, you may still have more fixes to do to get compilation!')
parser.add_option('-i', metavar='SIPFILE', dest="sipfile",
help='The .sip input file')

parser.add_option('-o', metavar='OUTPUTFILE', dest="outputfile",
help='The name of the output file')

(options, args) = parser.parse_args()

print "---- Reading from %s ---- " % options.sipfile
out = process_sip(options.sipfile)

if not (options.outputfile is None):
print "---- Writing to %s ---- " % options.outputfile
f = open(options.outputfile, 'w')
f.write('\n'.join(out))
f.close()



19 changes: 12 additions & 7 deletions Code/Mantid/Framework/API/inc/MantidAPI/Sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@
//------------------------------------------------------------------------------
#include "MantidAPI/DllConfig.h"
#include "MantidKernel/V3D.h"
#include "MantidGeometry/Objects/Object.h"
#include "MantidGeometry/Objects/Material.h"
#include <MantidGeometry/Crystal/OrientedLattice.h>
#include "MantidGeometry/Objects/Object.h"
#include <vector>

using Mantid::Geometry::OrientedLattice;

namespace Mantid
{
//-----------------------------------------------------------------------------
// Geometry forward declarations
//------------------------------------------------------------------------------
namespace Geometry
{
class OrientedLattice;
}

namespace API
{
Expand Down Expand Up @@ -101,11 +106,11 @@ namespace Mantid
/** @name Access the sample's lattice structure and orientation */
//@{
/// Get a reference to the sample's OrientedLattice
const OrientedLattice & getOrientedLattice() const;
const Geometry::OrientedLattice & getOrientedLattice() const;
/// Get a reference to the sample's OrientedLattice
OrientedLattice & getOrientedLattice();
Geometry::OrientedLattice & getOrientedLattice();
/// Set the OrientedLattice defining the sample's lattice and orientation
void setOrientedLattice(OrientedLattice * latt);
void setOrientedLattice(Geometry::OrientedLattice * latt);
bool hasOrientedLattice() const;
//@}

Expand Down Expand Up @@ -143,7 +148,7 @@ namespace Mantid
/// An owned pointer to the SampleEnvironment object
boost::shared_ptr<SampleEnvironment> m_environment;
/// Pointer to the OrientedLattice of the sample, NULL if not set.
OrientedLattice * m_lattice;
Geometry::OrientedLattice * m_lattice;

/// Vector of child samples
std::vector<boost::shared_ptr<Sample> > m_samples;
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/src/FrameworkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ void FrameworkManagerImpl::setGlobalLocaleToAscii()
void FrameworkManagerImpl::clear()
{
clearAlgorithms();
clearData();
clearInstruments();
clearData();
MemoryManager::Instance().releaseFreeMemory();
}

Expand Down
7 changes: 4 additions & 3 deletions Code/Mantid/Framework/API/src/Sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@
#include "MantidGeometry/IComponent.h"
#include "MantidGeometry/Crystal/OrientedLattice.h"
#include "MantidGeometry/Objects/ShapeFactory.h"

#include "MantidNexusCPP/NeXusException.hpp"

using namespace Mantid::Kernel;
using Mantid::Geometry::ShapeFactory;

namespace Mantid
{

namespace API
{

using namespace Mantid::Kernel;
using Geometry::ShapeFactory;
using Geometry::Object;
using Geometry::Material;
using Geometry::OrientedLattice;
using Kernel::V3D;

/**
Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/Framework/API/test/ExperimentInfoTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <set>
#include "MantidKernel/ConfigService.h"
#include "MantidKernel/SingletonHolder.h"
#include "MantidGeometry/Crystal/OrientedLattice.h"

using namespace Mantid::API;
using namespace Mantid::Kernel;
Expand Down
3 changes: 2 additions & 1 deletion Code/Mantid/Framework/Algorithms/src/CopySample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The following information can be copied:
#include "MantidKernel/System.h"
#include "MantidAPI/IMDEventWorkspace.h"
#include "MantidAPI/SampleEnvironment.h"
#include "MantidGeometry/Crystal/OrientedLattice.h"

namespace Mantid
{
Expand Down Expand Up @@ -149,7 +150,7 @@ namespace Algorithms
to.setThickness(from.getThickness());
to.setWidth(from.getWidth());
}
if ((latticeFlag) && from.hasOrientedLattice()) to.setOrientedLattice(new OrientedLattice(from.getOrientedLattice()));
if ((latticeFlag) && from.hasOrientedLattice()) to.setOrientedLattice(new Geometry::OrientedLattice(from.getOrientedLattice()));
}


Expand Down
18 changes: 16 additions & 2 deletions Code/Mantid/Framework/Algorithms/src/GetDetOffsetsMultiPeaks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,26 @@ namespace Mantid
findpeaks->setProperty<bool>("HighBackground", true);
findpeaks->executeAsSubAlg();
ITableWorkspace_sptr peakslist = findpeaks->getProperty("PeaksList");
std::vector<double> centers = Kernel::VectorHelper::splitStringIntoVector<double>(peakPositions);
std::vector<double> peakPos = Kernel::VectorHelper::splitStringIntoVector<double>(peakPositions);
double errsumold = 1000.0;
for (int i = 0; i < peakslist->rowCount(); ++i)
{
double errsum = 0.0;
// Get references to the data
const double centre = peakslist->getRef<double>("centre",i);
if(centre > 0 && (centers[i]-centre) < offset)offset = centers[i]-centre;
double tryoffset = 0;
if(centre > 0) tryoffset = peakPos[i]-centre;
for (int j = 0; j < peakslist->rowCount(); ++j)
{
const double centrej = peakslist->getRef<double>("centre",j);
if(centrej > 0) errsum += std::fabs(peakPos[j]-(centrej+tryoffset));
}
if (errsum < errsumold)
{
//See formula in AlignDetectors
offset = tryoffset/(peakPos[i]-tryoffset);
errsumold = errsum;
}
}
return offset;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class GetDetOffsetsMultiPeaksTest : public CxxTest::TestSuite
TS_ASSERT_THROWS_NOTHING( output = boost::dynamic_pointer_cast<MatrixWorkspace>(AnalysisDataService::Instance().retrieve(outputWS)) );
if (!output) return;

TS_ASSERT_DELTA( output->dataY(0)[0], -0.0196, 0.002);
TS_ASSERT_DELTA( output->dataY(0)[0], -0.00196, 0.0002);

AnalysisDataService::Instance().remove(outputWS);
}
Expand Down Expand Up @@ -98,7 +98,7 @@ class GetDetOffsetsMultiPeaksTest : public CxxTest::TestSuite
OffsetsWorkspace_sptr output = offsets.getProperty("OutputWorkspace");
if (!output) return;

TS_ASSERT_DELTA( output->getValue(1), -0.0196, 0.002);
TS_ASSERT_DELTA( output->getValue(1), -0.00196, 0.0002);
TS_ASSERT_EQUALS( output->getValue(1), output->getValue(2));
TS_ASSERT_EQUALS( output->getValue(1), output->getValue(3));

Expand Down Expand Up @@ -149,7 +149,7 @@ class GetDetOffsetsMultiPeaksTestPerformance : public CxxTest::TestSuite
OffsetsWorkspace_sptr output;
TS_ASSERT_THROWS_NOTHING( output = offsets.getProperty("OutputWorkspace") );
if (!output) return;
TS_ASSERT_DELTA( output->dataY(0)[0], -0.0196, 0.002);
TS_ASSERT_DELTA( output->dataY(0)[0], -0.00196, 0.0002);
}

};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "MantidAPI/Algorithm.h"
#include <boost/tuple/tuple.hpp>
#include "MantidAPI/IPeaksWorkspace.h"
#include "MantidGeometry/Crystal/UnitCell.h"
#include "MantidKernel/V3D.h"
#include <set>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace Crystal
/// Counter of possible peaks
size_t numInRange;
/// Crystal applied
OrientedLattice crystal;
Geometry::OrientedLattice crystal;
/// Min D spacing to apply.
double minD;
/// Max D spacing to apply.
Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/Framework/Crystal/src/CalculateUMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ namespace Crystal
using namespace Mantid::Kernel;
using namespace Mantid::API;
using namespace Mantid::DataObjects;
using Mantid::Geometry::OrientedLattice;


//----------------------------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/Framework/Crystal/src/LoadIsawUB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ The ISAW UB Matrix file format is: TODO
using namespace Mantid::Kernel::Strings;
using Mantid::Kernel::DblMatrix;
using Mantid::Geometry::UnitCell;
using Mantid::Geometry::OrientedLattice;

namespace Mantid
{
Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/Framework/Crystal/src/PeakIntegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Integrate and calculate error of integration of each peak from single crystal da
#include "MantidGeometry/IComponent.h"
#include "MantidGeometry/ICompAssembly.h"
#include "MantidGeometry/Instrument/RectangularDetector.h"
#include "MantidGeometry/Crystal/OrientedLattice.h"
#include <boost/algorithm/string.hpp>
#include "MantidKernel/VectorHelper.h"

Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/Framework/Crystal/src/SaveIsawUB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

using Mantid::Kernel::DblMatrix;
using Mantid::Geometry::UnitCell;
using Mantid::Geometry::OrientedLattice;

namespace Mantid
{
Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/Framework/Crystal/src/SetUB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ If the UB matrix is all zeros (default), it will calculate it from lattice param

using namespace Mantid::Kernel;
using namespace Mantid::API;
using Mantid::Geometry::OrientedLattice;

namespace Mantid
{
Expand Down
2 changes: 2 additions & 0 deletions Code/Mantid/Framework/Crystal/test/CalculateUMatrixTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
#include "MantidDataObjects/PeaksWorkspace.h"
#include "MantidKernel/V3D.h"
#include "MantidTestHelpers/ComponentCreationHelper.h"

using namespace Mantid;
using namespace Mantid::Crystal;
using Mantid::Geometry::OrientedLattice;
using namespace Mantid::API;
using namespace Mantid::DataObjects;
using namespace Mantid::Kernel;
Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/Framework/Crystal/test/FindUBUsingFFTTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using namespace Mantid;
using namespace Mantid::Crystal;
using Mantid::Geometry::OrientedLattice;
using namespace Mantid::API;
using namespace Mantid::DataObjects;
using namespace Mantid::Kernel;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@

using namespace Mantid;
using namespace Mantid::Crystal;
using Mantid::Geometry::OrientedLattice;
using namespace Mantid::API;
using namespace Mantid::DataObjects;
using namespace Mantid::Kernel;


class FindUBUsingIndexedPeaksTest : public CxxTest::TestSuite
{
public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

using namespace Mantid;
using namespace Mantid::Crystal;
using Mantid::Geometry::OrientedLattice;
using namespace Mantid::API;
using namespace Mantid::DataObjects;
using namespace Mantid::Kernel;
Expand Down

0 comments on commit 25fe889

Please sign in to comment.