Skip to content
Snippets Groups Projects
Commit bad87c49 authored by Bhuvan Bezawada's avatar Bhuvan Bezawada
Browse files

Cleaned up some code files

re #23145
parent a0ab98ad
No related branches found
No related tags found
No related merge requests found
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
#include <cxxtest/TestSuite.h> #include <cxxtest/TestSuite.h>
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidGeometry/Instrument/ComponentInfo.h" #include "MantidGeometry/Instrument/ComponentInfo.h"
#include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidGeometry/Instrument/DetectorInfo.h"
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidTestHelpers/ComponentCreationHelper.h" #include "MantidTestHelpers/ComponentCreationHelper.h"
#include "MantidTestHelpers/FakeObjects.h" #include "MantidTestHelpers/FakeObjects.h"
#include "MantidTestHelpers/InstrumentCreationHelper.h" #include "MantidTestHelpers/InstrumentCreationHelper.h"
...@@ -393,8 +393,8 @@ public: ...@@ -393,8 +393,8 @@ public:
size_t numberOfBins = 1; size_t numberOfBins = 1;
workspace.initialize(numberOfHistograms, numberOfBins + 1, numberOfBins); workspace.initialize(numberOfHistograms, numberOfBins + 1, numberOfBins);
for (int32_t i = 0; i < numberOfHistograms; ++i) for (int32_t i = 0; i < numberOfHistograms; ++i)
workspace.getSpectrum(i) workspace.getSpectrum(i).setSpectrumNo(
.setSpectrumNo(static_cast<int32_t>(numberOfHistograms) - i); static_cast<int32_t>(numberOfHistograms) - i);
bool includeMonitors = false; bool includeMonitors = false;
bool startYNegative = true; bool startYNegative = true;
const std::string instrumentName("SimpleFakeInstrument"); const std::string instrumentName("SimpleFakeInstrument");
......
#ifndef MANTID_GEOMETRY_DETECTORINFO_H_ #ifndef MANTID_GEOMETRY_DETECTORINFO_H_
#define MANTID_GEOMETRY_DETECTORINFO_H_ #define MANTID_GEOMETRY_DETECTORINFO_H_
#include "MantidGeometry/DllConfig.h"
#include "MantidKernel/DateAndTime.h"
#include "MantidKernel/Quat.h"
#include "MantidKernel/V3D.h"
//#include "MantidGeometry/Instrument/DetectorInfoIterator.h"
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <mutex> #include <mutex>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "MantidGeometry/DllConfig.h"
#include "MantidKernel/DateAndTime.h"
#include "MantidKernel/Quat.h"
#include "MantidKernel/V3D.h"
namespace Mantid { namespace Mantid {
using detid_t = int32_t; using detid_t = int32_t;
namespace Beamline { namespace Beamline {
......
...@@ -13,12 +13,10 @@ namespace Geometry { ...@@ -13,12 +13,10 @@ namespace Geometry {
class MANTID_GEOMETRY_DLL DetectorInfoItem { class MANTID_GEOMETRY_DLL DetectorInfoItem {
public: public:
DetectorInfoItem(const DetectorInfoItem &copy) DetectorInfoItem(const DetectorInfoItem &copy)
: m_detectorInfo(copy.m_detectorInfo), m_index(copy.m_index) { : m_detectorInfo(copy.m_detectorInfo), m_index(copy.m_index) {}
}
DetectorInfoItem& operator=(const DetectorInfoItem &rhs) { DetectorInfoItem &operator=(const DetectorInfoItem &rhs) {
this->m_index = rhs.m_index; this->m_index = rhs.m_index;
return *this; return *this;
} }
...@@ -62,10 +60,10 @@ private: ...@@ -62,10 +60,10 @@ private:
// Variables to hold data // Variables to hold data
const DetectorInfo &m_detectorInfo; const DetectorInfo &m_detectorInfo;
size_t m_index; size_t m_index = 0;
}; };
} // namespace Geometry } // namespace Geometry
} // namespace Mantid } // namespace Mantid
#endif #endif /* MANTID_GEOMETRY_DETECTORINFOITEM_H_ */
...@@ -2,12 +2,11 @@ ...@@ -2,12 +2,11 @@
#ifndef MANTID_GEOMETRY_DETECTORINFOITERATOR_H_ #ifndef MANTID_GEOMETRY_DETECTORINFOITERATOR_H_
#define MANTID_GEOMETRY_DETECTORINFOITERATOR_H_ #define MANTID_GEOMETRY_DETECTORINFOITERATOR_H_
//#include "MantidGeometry/Instrument/DetectorInfo.h"
#include "MantidGeometry/Instrument/DetectorInfoItem.h"
#include <boost/iterator/iterator_facade.hpp> #include <boost/iterator/iterator_facade.hpp>
#include <memory> #include <memory>
#include "MantidGeometry/Instrument/DetectorInfoItem.h"
namespace Mantid { namespace Mantid {
namespace Geometry { namespace Geometry {
...@@ -20,10 +19,13 @@ class MANTID_GEOMETRY_DLL DetectorInfoIterator ...@@ -20,10 +19,13 @@ class MANTID_GEOMETRY_DLL DetectorInfoIterator
public: public:
DetectorInfoIterator(const DetectorInfo &detectorInfo, const size_t index) DetectorInfoIterator(const DetectorInfo &detectorInfo, const size_t index)
: m_item(detectorInfo, index), m_detectorInfo(detectorInfo), m_index(index) {} : m_item(detectorInfo, index) {
} // m_detectorInfo(detectorInfo), m_index(index) {}
DetectorInfoIterator(const DetectorInfoIterator&detInfoIterator) : DetectorInfoIterator(const DetectorInfoIterator &detInfoIterator)
m_index(detInfoIterator.m_index), m_detectorInfo(detInfoIterator.m_detectorInfo), m_item(detInfoIterator.m_detectorInfo, detInfoIterator.m_index) {} : m_item(detInfoIterator.m_item) {
} // m_detectorInfo(detInfoIterator.m_detectorInfo),
// m_item(detInfoIterator.m_detectorInfo, detInfoIterator.m_index) {}
private: private:
friend class boost::iterator_core_access; friend class boost::iterator_core_access;
...@@ -46,11 +48,11 @@ private: ...@@ -46,11 +48,11 @@ private:
} }
DetectorInfoItem m_item; DetectorInfoItem m_item;
DetectorInfo m_detectorInfo; // DetectorInfo m_detectorInfo;
size_t m_index; // size_t m_index;
}; };
} // namespace Geometry } // namespace Geometry
} // namespace Mantid } // namespace Mantid
#endif #endif /* MANTID_GEOMETRY_DETECTORINFOITERATOR_H_ */
#include "MantidGeometry/Instrument/DetectorInfo.h"
#include "MantidBeamline/DetectorInfo.h"
#include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument.h"
#include "MantidGeometry/Instrument/Detector.h" #include "MantidGeometry/Instrument/Detector.h"
#include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidGeometry/Instrument/DetectorInfoIterator.h"
#include "MantidGeometry/Instrument/ReferenceFrame.h" #include "MantidGeometry/Instrument/ReferenceFrame.h"
#include "MantidBeamline/DetectorInfo.h"
#include "MantidKernel/EigenConversionHelpers.h" #include "MantidKernel/EigenConversionHelpers.h"
#include "MantidKernel/Exception.h" #include "MantidKernel/Exception.h"
#include "MantidKernel/MultiThreaded.h" #include "MantidKernel/MultiThreaded.h"
#include "MantidKernel/make_unique.h" #include "MantidKernel/make_unique.h"
#include "MantidGeometry/Instrument/DetectorInfoIterator.h"
namespace Mantid { namespace Mantid {
namespace Geometry { namespace Geometry {
...@@ -346,8 +345,9 @@ DetectorInfo::scanInterval(const std::pair<size_t, size_t> &index) const { ...@@ -346,8 +345,9 @@ DetectorInfo::scanInterval(const std::pair<size_t, size_t> &index) const {
* i.e., time intervals must be set with this method before merging individual * i.e., time intervals must be set with this method before merging individual
* scans. */ * scans. */
void DetectorInfo::setScanInterval( void DetectorInfo::setScanInterval(
const size_t index, const std::pair<Types::Core::DateAndTime, const size_t index,
Types::Core::DateAndTime> &interval) { const std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime>
&interval) {
m_detectorInfo->setScanInterval(index, {interval.first.totalNanoseconds(), m_detectorInfo->setScanInterval(index, {interval.first.totalNanoseconds(),
interval.second.totalNanoseconds()}); interval.second.totalNanoseconds()});
} }
...@@ -356,8 +356,9 @@ void DetectorInfo::setScanInterval( ...@@ -356,8 +356,9 @@ void DetectorInfo::setScanInterval(
* *
* Prefer this over setting intervals for individual detectors since it enables * Prefer this over setting intervals for individual detectors since it enables
* internal performance optimization. See also overload for other details. */ * internal performance optimization. See also overload for other details. */
void DetectorInfo::setScanInterval(const std::pair< void DetectorInfo::setScanInterval(
Types::Core::DateAndTime, Types::Core::DateAndTime> &interval) { const std::pair<Types::Core::DateAndTime, Types::Core::DateAndTime>
&interval) {
m_detectorInfo->setScanInterval( m_detectorInfo->setScanInterval(
{interval.first.totalNanoseconds(), interval.second.totalNanoseconds()}); {interval.first.totalNanoseconds(), interval.second.totalNanoseconds()});
} }
......
...@@ -164,7 +164,7 @@ public: ...@@ -164,7 +164,7 @@ public:
auto iter = detectorInfo.begin(); auto iter = detectorInfo.begin();
auto iterCopy = DetectorInfoIterator(iter); auto iterCopy = DetectorInfoIterator(iter);
TS_ASSERT_EQUALS(iter->getIndex(), 0); TS_ASSERT_EQUALS(iter->getIndex(), 0);
TS_ASSERT_EQUALS(iterCopy->getIndex(), 0); TS_ASSERT_EQUALS(iterCopy->getIndex(), 0);
...@@ -178,8 +178,8 @@ public: ...@@ -178,8 +178,8 @@ public:
TS_ASSERT_EQUALS(iterCopy->getIndex(), 1); TS_ASSERT_EQUALS(iterCopy->getIndex(), 1);
TS_ASSERT_EQUALS(iter->position(), 1); TS_ASSERT_EQUALS(iter->position(), 1);
TS_ASSERT_EQUALS(iterCopy->position(),1); TS_ASSERT_EQUALS(iterCopy->position(), 1);
} }
}; };
#endif /* MANTID_HISTOGRAMDATA_HISTOGRAMITERATORTEST_H_ */ #endif /* MANTID_GEOMETRY_DETECTORINFOITERATORTEST_H_ */
#include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidGeometry/Instrument/DetectorInfo.h"
#include "MantidKernel/Quat.h" #include "MantidKernel/Quat.h"
#include "MantidKernel/V3D.h" #include "MantidKernel/V3D.h"
#include <boost/iterator/iterator_facade.hpp>
#include <boost/python/class.hpp> #include <boost/python/class.hpp>
#include <boost/python/copy_const_reference.hpp> #include <boost/python/copy_const_reference.hpp>
#include <boost/python/copy_non_const_reference.hpp>
#include <boost/python/iterator.hpp>
#include <boost/python/return_by_value.hpp> #include <boost/python/return_by_value.hpp>
#include <boost/python/return_value_policy.hpp> #include <boost/python/return_value_policy.hpp>
#include <boost/python/iterator.hpp> #include <iterator>
#include <boost/iterator/iterator_facade.hpp>
#include <Python.h>
#include <boost/python.hpp>
#include "MantidGeometry/Instrument/DetectorInfoItem.h" #include "MantidGeometry/Instrument/DetectorInfoItem.h"
#include "MantidGeometry/Instrument/DetectorInfoIterator.h" #include "MantidGeometry/Instrument/DetectorInfoIterator.h"
using Mantid::Geometry::DetectorInfoItem;
using Mantid::Geometry::DetectorInfoIterator;
using Mantid::Geometry::DetectorInfo; using Mantid::Geometry::DetectorInfo;
using Mantid::Geometry::DetectorInfoItem;
using Mantid::Geometry::DetectorInfoIterator;
using Mantid::Kernel::Quat; using Mantid::Kernel::Quat;
using Mantid::Kernel::V3D; using Mantid::Kernel::V3D;
using namespace boost::python; using namespace boost::python;
...@@ -41,10 +40,20 @@ void export_DetectorInfo() { ...@@ -41,10 +40,20 @@ void export_DetectorInfo() {
void (DetectorInfo::*setMasked)(const size_t, bool) = void (DetectorInfo::*setMasked)(const size_t, bool) =
&DetectorInfo::setMasked; &DetectorInfo::setMasked;
/*
Mantid::Geometry::DetectorInfoIterator group_begin(DetectorInfo &self) {
return self.begin();
}
Mantid::Geometry::DetectorInfoIterator group_end(DetectorInfo &self) {
return self.end();
}*/
// Export to Python // Export to Python
class_<DetectorInfo, boost::noncopyable>("DetectorInfo", no_init) class_<DetectorInfo, boost::noncopyable>("DetectorInfo", no_init)
.def("__iter__", range(&DetectorInfo::begin, &DetectorInfo::end)) .def("__iter__", range<return_value_policy<copy_const_reference>>(
&DetectorInfo::begin, &DetectorInfo::end))
.def("__len__", &DetectorInfo::size, (arg("self")), .def("__len__", &DetectorInfo::size, (arg("self")),
"Returns the size of the DetectorInfo, i.e., the number of " "Returns the size of the DetectorInfo, i.e., the number of "
...@@ -68,9 +77,10 @@ void export_DetectorInfo() { ...@@ -68,9 +77,10 @@ void export_DetectorInfo() {
"Sets all mask flags to false (unmasked).") "Sets all mask flags to false (unmasked).")
.def("isEquivalent", &DetectorInfo::isEquivalent, .def("isEquivalent", &DetectorInfo::isEquivalent,
(arg("self"), arg("other")), "Returns True if the content of this " (arg("self"), arg("other")),
"detector is equivalent to the content " "Returns True if the content of this "
"of the other detector.") "detector is equivalent to the content "
"of the other detector.")
.def("twoTheta", twoTheta, (arg("self"), arg("index")), .def("twoTheta", twoTheta, (arg("self"), arg("index")),
"Returns 2 theta (scattering angle w.r.t beam direction).") "Returns 2 theta (scattering angle w.r.t beam direction).")
......
#include <boost/python/class.hpp> #include <boost/python/class.hpp>
#include <boost/python/module.hpp> #include <boost/python/module.hpp>
#include "MantidGeometry/Instrument/DetectorInfoItem.h" #include "MantidGeometry/Instrument/DetectorInfoItem.h"
#include "MantidKernel/V3D.h" #include "MantidKernel/V3D.h"
...@@ -11,6 +12,6 @@ void export_DetectorInfoItem() { ...@@ -11,6 +12,6 @@ void export_DetectorInfoItem() {
// Export to Python // Export to Python
class_<DetectorInfoItem>("DetectorInfoItem", no_init) class_<DetectorInfoItem>("DetectorInfoItem", no_init)
.add_property("position", &DetectorInfoItem::position); .add_property("position", &DetectorInfoItem::position);
//.def("position", &DetectorInfoItem::position, arg("self")); //.def("position", &DetectorInfoItem::position, arg("self"));
} }
...@@ -107,14 +107,16 @@ class DetectorInfoTest(unittest.TestCase): ...@@ -107,14 +107,16 @@ class DetectorInfoTest(unittest.TestCase):
""" """
def test_iteration(self): def test_iteration(self):
import time
time.sleep(20)
info = self._ws.detectorInfo() info = self._ws.detectorInfo()
#self.assertEquals(len(info), 0) #self.assertEquals(len(info), 0)
#self.assertEquals(info.size(), 0) #self.assertEquals(info.size(), 0)
for a in info: for a in info:
#self.assertEquals(type(a), DetectorInfoItem) #self.assertEquals(type(a), DetectorInfoItem)
#self.assertEquals(info.position(0), "") #self.assertEquals(info.position(0), "")
#self.assertEquals(a.position, 100) print(a.position)
print(a) #print(a)
self.fail() self.fail()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment