Commit 70bc07ab authored by Nick Draper's avatar Nick Draper
Browse files

Merge branch 'master' of https://github.com/mantidproject/mantid into 28399_add_CNSN_copyright

# Conflicts:
#	Testing/SystemTests/tests/analysis/ErrorReporterServerTest.py
parents 1c422f4d 1d1bfa93
......@@ -135,15 +135,13 @@ class ReflectometryBackgroundSubtractionTest(unittest.TestCase):
'OutputWorkspace': 'output'}
self._assert_run_algorithm_throws(args)
# TODO: This test fails in python 2. It can be re-added when we
# move fully to python 3.
#def test_AveragePixelFit_error_peakRange_outside_spectra(self):
# args = {'InputWorkspace' : 'workspace_with_peak',
# 'ProcessingInstructions' : '1-7',
# 'BackgroundCalculationMethod' : 'AveragePixelFit',
# 'PeakRange' : '3-9',
# 'OutputWorkspace': 'output'}
# self._assert_run_algorithm_invalid_property(args)
def test_AveragePixelFit_error_peakRange_outside_spectra(self):
args = {'InputWorkspace' : 'workspace_with_peak',
'ProcessingInstructions' : '1-7',
'BackgroundCalculationMethod' : 'AveragePixelFit',
'PeakRange' : '3-9',
'OutputWorkspace': 'output'}
self._assert_run_algorithm_invalid_property(args)
def test_AveragePixelFit_error_peakRange_two_ranges(self):
args = {'InputWorkspace' : 'workspace_with_peak',
......
......@@ -932,16 +932,26 @@ void EventList::clearData() { this->clear(false); }
*/
void EventList::setMRU(EventWorkspaceMRU *newMRU) { mru = newMRU; }
/** Reserve a certain number of entries in the (NOT-WEIGHTED) event list. Do NOT
*call
* on weighted events!
/** Reserve a certain number of entries in event list of the specified eventType
*
* Calls std::vector<>::reserve() in order to pre-allocate the length of the
*event list vector.
*
* @param num :: number of events that will be in this EventList
*/
void EventList::reserve(size_t num) { this->events.reserve(num); }
void EventList::reserve(size_t num) {
switch (this->eventType) {
case TOF:
this->events.reserve(num);
break;
case WEIGHTED:
this->weightedEvents.reserve(num);
break;
case WEIGHTED_NOTIME:
this->weightedEventsNoTime.reserve(num);
break;
}
}
// ==============================================================================================
// --- Sorting functions -----------------------------------------------------
......
......@@ -151,14 +151,10 @@ inline DateAndTime::DateAndTime() : _nanoseconds(0) {}
/** Construct a date from nanoseconds.
* @param total_nanoseconds :: nanoseconds since Jan 1, 1990 (our epoch).
*/
inline DateAndTime::DateAndTime(const int64_t total_nanoseconds) {
inline DateAndTime::DateAndTime(const int64_t total_nanoseconds)
: _nanoseconds{
std::clamp(total_nanoseconds, MIN_NANOSECONDS, MAX_NANOSECONDS)} {
// Make sure that you cannot construct a date that is beyond the limits...
if (total_nanoseconds > MAX_NANOSECONDS)
_nanoseconds = MAX_NANOSECONDS;
else if (total_nanoseconds < MIN_NANOSECONDS)
_nanoseconds = MIN_NANOSECONDS;
else
_nanoseconds = total_nanoseconds;
}
/** + operator to add time.
......
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright &copy; 2018 ISIS Rutherford Appleton Laboratory UKRI,
# NScD Oak Ridge National Laboratory, European Spallation Source,
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +
from mantid.py3compat import mock
import systemtesting
from ErrorReporter.error_report_presenter import ErrorReporterPresenter # noqa
class ErrorReportServerTests(systemtesting.MantidSystemTest):
def setUp(self):
mock_view = mock.MagicMock()
self.error_report_presenter = ErrorReporterPresenter(mock_view, '1')
def test_no_share_sends_nothing(self):
status = self.error_report_presenter.error_handler(True, 2, '', '', '')
self.assertEqual(status, -1)
def test_share_non_identifiable_returns_created_status(self):
status = self.error_report_presenter.error_handler(True, 1, '', '', '')
self.assertEqual(status, 201)
def test_share_identifiable_works_for_empty_values(self):
status = self.error_report_presenter.error_handler(True, 0, '', '', '')
self.assertEqual(status, 201)
def test_share_identifiable_works_for_just_name(self):
status = self.error_report_presenter.error_handler(True, 0, 'public_name', '', '')
self.assertEqual(status, 201)
def test_share_identifiable_works_for_just_email(self):
status = self.error_report_presenter.error_handler(True, 0, '', 'public_email', '')
self.assertEqual(status, 201)
def test_share_identifiable_works_for_just_textbox(self):
status = self.error_report_presenter.error_handler(True, 0, '', '', 'Something went wrong')
self.assertEqual(status, 201)
def test_share_identifiable_works_with_no_name(self):
status = self.error_report_presenter.error_handler(True, 0, '', 'public_email', 'Something went wrong')
self.assertEqual(status, 201)
def test_share_identifiable_works_with_no_email(self):
status = self.error_report_presenter.error_handler(True, 0, 'public_name', '', 'Something went wrong')
self.assertEqual(status, 201)
def test_share_identifiable_works_with_no_textbox(self):
status = self.error_report_presenter.error_handler(True, 0, 'public_name', 'public_email', '')
self.assertEqual(status, 201)
def test_share_identifiable_works_with_all(self):
status = self.error_report_presenter.error_handler(True, 0, 'public_name', 'public_email', 'Something went wrong')
self.assertEqual(status, 201)
def excludeInPullRequests(self):
return True
def runTest(self):
self.setUp()
self.test_no_share_sends_nothing()
self.test_share_non_identifiable_returns_created_status()
self.test_share_identifiable_works_for_empty_values()
self.test_share_identifiable_works_for_just_name()
self.test_share_identifiable_works_for_just_email()
self.test_share_identifiable_works_for_just_textbox()
self.test_share_identifiable_works_with_no_name()
self.test_share_identifiable_works_with_no_email()
self.test_share_identifiable_works_with_no_textbox()
self.test_share_identifiable_works_with_all()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment