diff --git a/Framework/PythonInterface/plugins/algorithms/ExportSampleLogsToCSVFile.py b/Framework/PythonInterface/plugins/algorithms/ExportSampleLogsToCSVFile.py index 5eab04d14a55c5e6d8a1f691e0491c0a0d71c65b..be7dd8390cf2485a6eb3d434089d55f1311c5faf 100644 --- a/Framework/PythonInterface/plugins/algorithms/ExportSampleLogsToCSVFile.py +++ b/Framework/PythonInterface/plugins/algorithms/ExportSampleLogsToCSVFile.py @@ -2,6 +2,7 @@ from __future__ import (absolute_import, division, print_function) from mantid.api import * from mantid.kernel import * +from distutils.version import LooseVersion import numpy as np import os from six.moves import range # pylint: disable=redefined-builtin @@ -179,7 +180,8 @@ class ExportSampleLogsToCSVFile(PythonAlgorithm): localtimediff = np.timedelta64(0, 's') epoch = '1990-01-01T00:00' - if np.__version__.startswith('1.7.'): + # older numpy assumes local timezone + if LooseVersion(np.__version__) < LooseVersion('1.9'): epoch = epoch+'Z' return np.datetime64(epoch) + localtimediff diff --git a/Framework/PythonInterface/test/python/mantid/kernel/DateAndTimeTest.py b/Framework/PythonInterface/test/python/mantid/kernel/DateAndTimeTest.py index 410c5cd8f3c18ee7b41f311daaa5da09633d7046..8e466dbd24dccaf02184aab73df320f9cb2af1de 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/DateAndTimeTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/DateAndTimeTest.py @@ -4,6 +4,7 @@ import unittest from mantid.kernel import DateAndTime import numpy from numpy import timedelta64, datetime64 +from distutils.version import LooseVersion class DateAndTimeTest(unittest.TestCase): @@ -31,7 +32,7 @@ class DateAndTimeTest(unittest.TestCase): self.assertEquals(dt, dt_np) def test_convert_from_np(self): - if numpy.__version__.startswith('1.7.'): + if LooseVersion(numpy.__version__) < LooseVersion('1.9'): dt_np = datetime64('2000-01-01T00:00Z') else: # newer numpy only uses UTC and warns on specifying timezones dt_np = datetime64('2000-01-01T00:00') diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/ExportSampleLogsToCSVFileTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/ExportSampleLogsToCSVFileTest.py index 6469448ed5a3bb3377e9056ccfc16e0f5ca7233b..c7a54d49750d510698c51933ac25c672a313efa5 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/ExportSampleLogsToCSVFileTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/ExportSampleLogsToCSVFileTest.py @@ -6,6 +6,7 @@ import mantid.kernel as kernel from testhelpers import run_algorithm from mantid.api import AnalysisDataService import os +from distutils.version import LooseVersion from six.moves import range @@ -300,7 +301,8 @@ class ExportVulcanSampleLogTest(unittest.TestCase): dtimesec = 0.0010 timefluc = 0.0001 runstart = '2014-02-15T13:34:03' - if numpy.__version__.startswith('1.7.'): # older numpy assumes local timezone + # older numpy assumes local timezone + if LooseVersion(numpy.__version__) < LooseVersion('1.9'): runstart = runstart + 'Z' runstart = datetime64(runstart, 'us') # microsecond needed for deltas