1- import math
21import importlib
32
43import MLC .Log .log as lg
@@ -108,11 +107,11 @@ def formal(self):
108107
109108 def _process_division (self , dividend , divisor ):
110109 if type (divisor ) == np .ndarray :
111- divisor = [Division_Node .PROTECTION if abs (x ) < Division_Node .PROTECTION else x for x in divisor ]
112- return np .sign (divisor ) * dividend / np .asarray (divisor )
110+ new_divisor = [Division_Node .PROTECTION if np . abs (x ) < Division_Node .PROTECTION else np . abs ( x ) for x in divisor ]
111+ return np .sign (divisor ) * dividend / np .asarray (new_divisor )
113112 else :
114113 if abs (divisor ) < Division_Node .PROTECTION :
115- return dividend / Division_Node .PROTECTION
114+ return np . sign ( divisor ) * dividend / Division_Node .PROTECTION
116115
117116 return dividend / divisor
118117
@@ -149,7 +148,7 @@ def formal(self):
149148
150149 def op_simplify (self ):
151150 if not self ._nodes [0 ].is_sensor ():
152- arg = math .sin (float (self ._nodes [0 ].to_string ()))
151+ arg = np .sin (float (self ._nodes [0 ].to_string ()))
153152 return Leaf_Node (process_float (arg ))
154153 else :
155154 return self
@@ -168,7 +167,7 @@ def formal(self):
168167
169168 def op_simplify (self ):
170169 if not self ._nodes [0 ].is_sensor ():
171- arg = math .cos (float (self ._nodes [0 ].to_string ()))
170+ arg = np .cos (float (self ._nodes [0 ].to_string ()))
172171 return Leaf_Node (process_float (arg ))
173172 else :
174173 return self
@@ -189,7 +188,7 @@ def formal(self):
189188
190189 def _process_arg (self , arg ):
191190 if type (arg ) == np .ndarray :
192- return [Logarithm_Node .PROTECTION if abs (x ) < Logarithm_Node .PROTECTION else abs (x ) for x in arg ]
191+ return [Logarithm_Node .PROTECTION if np . abs (x ) < Logarithm_Node .PROTECTION else np . abs (x ) for x in arg ]
193192 else :
194193 if abs (arg ) < Logarithm_Node .PROTECTION :
195194 return Logarithm_Node .PROTECTION
@@ -199,9 +198,9 @@ def _process_arg(self, arg):
199198 def op_simplify (self ):
200199 if not self ._nodes [0 ].is_sensor ():
201200 if float (self ._nodes [0 ].to_string ()) < Logarithm_Node .SIMPLIFY_PROTECTION :
202- arg = math .log (Logarithm_Node .SIMPLIFY_PROTECTION )
201+ arg = np .log (Logarithm_Node .SIMPLIFY_PROTECTION )
203202 else :
204- arg = math .log (float (self ._nodes [0 ].to_string ()))
203+ arg = np .log (float (self ._nodes [0 ].to_string ()))
205204
206205 return Leaf_Node (process_float (arg ))
207206 else :
@@ -223,9 +222,9 @@ def op_simplify(self):
223222 if not self ._nodes [0 ].is_sensor ():
224223 lg .logger_ .debug ("[EXP NODE] Value: " + self ._nodes [0 ].to_string ())
225224 try :
226- arg = math .exp (float (self ._nodes [0 ].to_string ()))
225+ arg = np .exp (float (self ._nodes [0 ].to_string ()))
227226 except OverflowError :
228- # FIXME: See what to do with this expression, because there are problems with
227+ # FIXME: See what to do with this expression, because there are problems when
229228 # an infinite value is the argumento of a sinusoidal function
230229 return Leaf_Node (process_float (float ("inf" )))
231230
@@ -247,7 +246,7 @@ def formal(self):
247246
248247 def op_simplify (self ):
249248 if not self ._nodes [0 ].is_sensor ():
250- arg = math .tanh (float (self ._nodes [0 ].to_string ()))
249+ arg = np .tanh (float (self ._nodes [0 ].to_string ()))
251250 return Leaf_Node (process_float (arg ))
252251 else :
253252 return self
0 commit comments