From 09782c735c0935cf647fd1aa35b983e5d72015e6 Mon Sep 17 00:00:00 2001
From: Pete Peterson <petersonpf@ornl.gov>
Date: Thu, 25 Jan 2018 09:11:51 -0500
Subject: [PATCH] Expand check for numpy version

rhel7 is using numpy 1.7 and ubuntu14.04 is using numpy 1.8
---
 .../plugins/algorithms/ExportSampleLogsToCSVFile.py           | 4 +++-
 .../test/python/mantid/kernel/DateAndTimeTest.py              | 3 ++-
 .../plugins/algorithms/ExportSampleLogsToCSVFileTest.py       | 4 +++-
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/Framework/PythonInterface/plugins/algorithms/ExportSampleLogsToCSVFile.py b/Framework/PythonInterface/plugins/algorithms/ExportSampleLogsToCSVFile.py
index 5eab04d14a5..be7dd8390cf 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 410c5cd8f3c..8e466dbd24d 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 6469448ed5a..c7a54d49750 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
 
-- 
GitLab