From 023a61bf0af549661fcd6a238c7e69d0950ef566 Mon Sep 17 00:00:00 2001
From: "Mads M. Pedersen" <mmpe@dtu.dk>
Date: Fri, 4 Nov 2016 14:23:02 +0100
Subject: [PATCH] add debug stuff to test_windap3

---
 .gitignore                                           | 1 +
 wetb/fatigue_tools/rainflowcounting/rainflowcount.py | 9 ++++-----
 wetb/fatigue_tools/tests/test_fatigue.py             | 3 ++-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore
index 6d3feb6..5c2598f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,3 +19,4 @@ wetb/hawc2/ascii2bin/tests/test_files/Hawc2ascii_bin.sel
 wetb/hawc2/ascii2bin/tests/test_files/Hawc2ascii_bin.dat
 wetb/prepost/tests/data/demo_dlc/remote*
 
+/wetb/fatigue_tools/rainflowcounting/compile.py
diff --git a/wetb/fatigue_tools/rainflowcounting/rainflowcount.py b/wetb/fatigue_tools/rainflowcounting/rainflowcount.py
index 8d1bdd7..bac7c26 100644
--- a/wetb/fatigue_tools/rainflowcounting/rainflowcount.py
+++ b/wetb/fatigue_tools/rainflowcounting/rainflowcount.py
@@ -6,7 +6,8 @@ from builtins import str
 from future import standard_library
 standard_library.install_aliases()
 import numpy as np
-
+from wetb.fatigue_tools.rainflowcounting import peak_trough
+from wetb.fatigue_tools.rainflowcounting import pair_range
 
 
 def check_signal(signal):
@@ -73,16 +74,14 @@ def rainflow_windap(signal, levels=255., thresshold=(255 / 50)):
 
 
         # If possible the module is compiled using cython otherwise the python implementation is used
-        from wetb.fatigue_tools.rainflowcounting.peak_trough import peak_trough
-        from wetb.fatigue_tools.rainflowcounting.pair_range import pair_range_amplitude_mean
 
 
         #Convert to list of local minima/maxima where difference > thresshold
-        sig_ext = peak_trough(signal, thresshold)
+        sig_ext = peak_trough.peak_trough(signal, thresshold)
 
 
         #rainflow count
-        ampl_mean = pair_range_amplitude_mean(sig_ext)
+        ampl_mean = pair_range.pair_range_amplitude_mean(sig_ext)
 
         ampl_mean = np.array(ampl_mean)
         ampl_mean = np.round(ampl_mean / thresshold) * gain * thresshold
diff --git a/wetb/fatigue_tools/tests/test_fatigue.py b/wetb/fatigue_tools/tests/test_fatigue.py
index b84ec1b..6e7c89f 100644
--- a/wetb/fatigue_tools/tests/test_fatigue.py
+++ b/wetb/fatigue_tools/tests/test_fatigue.py
@@ -59,7 +59,8 @@ class TestFatigueTools(unittest.TestCase):
     def test_windap3(self):
         data = Hawc2io.ReadHawc2(testfilepath + "test").ReadBinary([2]).flatten()
         from wetb.fatigue_tools.rainflowcounting import peak_trough
-        self.assertTrue(peak_trough.__file__.lower()[-4:] == ".pyd" or peak_trough.__file__.lower()[-3:] == ".so", "not compiled, %s"%sys.executable)
+        self.assertTrue(peak_trough.__file__.lower()[-4:] == ".pyd" or peak_trough.__file__.lower()[-3:] == ".so", 
+                        "not compiled, %s, %s\n%s"%(sys.executable, peak_trough.__file__, os.listdir(os.path.dirname(peak_trough.__file__))))
         np.testing.assert_array_equal(cycle_matrix(data, 4, 4, rainflow_func=rainflow_windap)[0], np.array([[  14., 65., 39., 24.],
                                                                    [  0., 1., 4., 0.],
                                                                    [  0., 0., 0., 0.],
-- 
GitLab