test_class_reliability_calculation.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 import unittest
5 import math
6 import rosunit
7 from phm_reliability_calculation.class_reliability_calculation import ReliabilityCalculation
8 
9 PKG = 'phm_reliability_calculation'
10 NAME = 'test_class_reliability_calculation'
11 
12 
13 class TestReliabilityCalculation(unittest.TestCase):
15 
16  usage_time = 100000
17  failure_rate = 0.5e-6
18 
19 
21  selected_reliability_model = "Exponential Distribution"
22  selected_reliability_unit = False
23  shape_parameter = 1
24 
25  result = self.rc.reliability_calculate_func(self.usage_time, self.failure_rate, selected_reliability_model, selected_reliability_unit, shape_parameter)
26  test_result = 0.951229424500714
27 
28  # result = math.exp(float(-1) * float(100000) * float(0.5e-6))
29 
30  self.assertAlmostEqual(result, test_result, 5)
31 
32 
34  selected_reliability_model = "Exponential Distribution"
35  selected_reliability_unit = True
36  shape_parameter = 1
37 
38  result = self.rc.reliability_calculate_func(self.usage_time, self.failure_rate, selected_reliability_model, selected_reliability_unit, shape_parameter)
39  test_result = 0.9999861112075613
40 
41  # result = math.exp(float(-1) * float(100000/3600) * float(0.5e-6))
42 
43  self.assertAlmostEqual(result, test_result, 5)
44 
45 
47  selected_reliability_model = "Rayleigh Distribution"
48  selected_reliability_unit = False
49  shape_parameter = 1
50 
51  result = self.rc.reliability_calculate_func(self.usage_time, self.failure_rate, selected_reliability_model, selected_reliability_unit, shape_parameter)
52  test_result = 0.0
53 
54  # result = math.exp(float(-1) * pow((float(100000) / float(0.5e-6)), 2))
55 
56  self.assertAlmostEqual(result, test_result, 5)
57 
58 
60  selected_reliability_model = "Rayleigh Distribution"
61  selected_reliability_unit = True
62  shape_parameter = 1
63 
64  result = self.rc.reliability_calculate_func(self.usage_time, self.failure_rate, selected_reliability_model, selected_reliability_unit, shape_parameter)
65  test_result = 0.0
66 
67  # result = math.exp(float(-1) * pow((float(100000/3600) / float(0.5e-6)), 2))
68 
69  self.assertAlmostEqual(result, test_result, 5)
70 
71 
73  selected_reliability_model = "Weibull Distribution"
74  selected_reliability_unit = False
75  shape_parameter = 1.5
76 
77  result = self.rc.reliability_calculate_func(self.usage_time, self.failure_rate, selected_reliability_model, selected_reliability_unit, shape_parameter)
78  test_result = 0.0
79 
80  # result = math.exp(float(-1) * pow((float(100000) / float(0.5e-6)), 1.5))
81 
82  self.assertAlmostEqual(result, test_result, 5)
83 
84 
86  selected_reliability_model = "Weibull Distribution"
87  selected_reliability_unit = True
88  shape_parameter = 1.5
89 
90  result = self.rc.reliability_calculate_func(self.usage_time, self.failure_rate, selected_reliability_model, selected_reliability_unit, shape_parameter)
91  test_result = 0.0
92 
93  # result = math.exp(float(-1) * pow((float(100000/3600) / float(0.5e-6)), 1.5))
94 
95  self.assertAlmostEqual(result, test_result, 5)
96 
97 
99  selected_reliability_model = "Curve Distribution"
100  selected_reliability_unit = False
101  shape_parameter = 1.5
102 
103  result = self.rc.reliability_calculate_func(self.usage_time, self.failure_rate, selected_reliability_model, selected_reliability_unit, shape_parameter)
104  test_result = 0.9888198936843544
105 
106  # result = math.exp(float(-1) * (float(math.exp(pow((float(100000) * float(0.5e-6)), 1.5))) - float(1)))
107 
108  self.assertAlmostEqual(result, test_result, 5)
109 
110 
112  selected_reliability_model = "Curve Distribution"
113  selected_reliability_unit = True
114  shape_parameter = 1.5
115 
116  result = self.rc.reliability_calculate_func(self.usage_time, self.failure_rate, selected_reliability_model, selected_reliability_unit, shape_parameter)
117  test_result = 0.9999999482391673
118 
119  # result = math.exp(float(-1) * (float(math.exp(pow((float(100000/3600) * float(0.5e-6)), 1.5))) - float(1)))
120 
121  self.assertAlmostEqual(result, test_result, 5)
122 
123 
125  selected_reliability_model = "None"
126  selected_reliability_unit = False
127  shape_parameter = 1.5
128 
129  result = self.rc.reliability_calculate_func(self.usage_time, self.failure_rate, selected_reliability_model, selected_reliability_unit, shape_parameter)
130  test_result = 1.0
131 
132  self.assertAlmostEqual(result, test_result, 5)
133 
134 
135 if __name__ == '__main__':
136  rosunit.unitrun(PKG, NAME, TestReliabilityCalculation, sysargs = "--cov", coverage_packages=[str(PKG)])
137 


phm_reliability_calculation
Author(s):
autogenerated on Thu Aug 13 2020 16:41:48