From 0422f3a233b8711ed5868e04f7fe4393f65319e2 Mon Sep 17 00:00:00 2001
From: madsmpedersen <m@madsp.dk>
Date: Mon, 9 Nov 2015 10:16:33 +0100
Subject: [PATCH] added weibull test

---
 wetb/dlc/tests/test_high_level.py | 33 ++++++++++++++++++++++++++-----
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/wetb/dlc/tests/test_high_level.py b/wetb/dlc/tests/test_high_level.py
index ca652c2..ea1be64 100644
--- a/wetb/dlc/tests/test_high_level.py
+++ b/wetb/dlc/tests/test_high_level.py
@@ -4,9 +4,9 @@ Created on 09/10/2014
 @author: MMPE
 '''
 import unittest
-from wetb.dlc.high_level import DLCHighLevel
+from wetb.dlc.high_level import DLCHighLevel, Weibull
 import os
-
+import numpy as np
 
 class TestDLCHighLevel(unittest.TestCase):
 
@@ -19,7 +19,7 @@ class TestDLCHighLevel(unittest.TestCase):
         self.assertEqual(os.path.realpath(self.dlc_hl.res_path), os.path.realpath(os.path.join(os.getcwd(), "test_files/res")))
 
     def test_sensor_info(self):
-        self.assertEqual(list(self.dlc_hl.sensor_info().name), ['MxTB', 'MyTB', 'MxBR', 'PyBT', 'Power', 'Pitch', 'PitchBearing', 'Tip1TowerDistance', 'TipTowerDistance'])
+        self.assertEqual(list(self.dlc_hl.sensor_info().name), ['MxTB', 'MyTB', 'MxBR', 'PyBT', 'Pitch', 'PitchBearing', 'Tip1TowerDistance', 'TipTowerDistance'])
 
     def test_sensor_info_filter(self):
         self.assertEqual(list(self.dlc_hl.sensor_info(['fatigue']).m), [4, 4, 10])
@@ -67,8 +67,31 @@ class TestDLCHighLevel(unittest.TestCase):
             self.assertTrue(k in self.dlc_hl.sensor_info().keys(), k)
 
 
-    def test_extremeload_sensors(self):
-        self.dlc_hl = DLCHighLevel('test_files/DLC_test2.xlsx')
+
+
+
+    def test_weibull_1(self):
+        Vin = 0.0
+        Vout = 100
+        Vref = 50
+        Vstep = .1
+        shape_k = 2
+        weibull = Weibull(Vref * 0.2, shape_k, Vin, Vout, Vstep)
+
+        # total probability needs to be 1!
+        p_tot = np.array([value for key, value in weibull.items()]).sum()
+        self.assertAlmostEqual(p_tot, 1.0, 3)
+
+    def test_weibull_2(self):
+        Vin = 1.0
+        Vout = 100
+        Vref = 50
+        Vstep = 2
+        shape_k = 2
+        weibull = Weibull(Vref * 0.2, shape_k, Vin, Vout, Vstep)
+        # total probability needs to be 1!
+        p_tot = np.array([value for key, value in weibull.items()]).sum()
+        self.assertTrue(np.allclose(p_tot, 1.0))
 
 
 
-- 
GitLab