1616from PySide6 .QtCore import * # @UnusedWildImport
1717from PySide6 .QtGui import * # @UnusedWildImport
1818from PySide6 .QtWidgets import * # @UnusedWildImport
19-
2019from extrap .gui .Utils import formatFormula
2120from extrap .gui .Utils import formatNumber
2221from extrap .gui .plots .AbstractPlotWidget import AbstractPlotWidget
@@ -569,9 +568,8 @@ def calculate_function(self, function, length_x_axis, x_min=None, x_max=None):
569568 number_of_x_points , x_list , x_values = self ._calculate_evaluation_points (length_x_axis , x_min , x_max )
570569 else :
571570 number_of_x_points , x_list , x_values = self ._calculate_evaluation_points (length_x_axis )
572- previous = numpy .seterr (invalid = 'ignore' , divide = 'ignore' )
573- y_list = function .evaluate (x_list ).reshape (- 1 )
574- numpy .seterr (** previous )
571+ with numpy .errstate (invalid = 'ignore' , divide = 'ignore' ):
572+ y_list = function .evaluate (x_list ).reshape (- 1 )
575573 cord_list = self ._create_drawing_iterator (x_values , y_list )
576574
577575 return cord_list
@@ -585,10 +583,9 @@ def calculate_aggregate_callpath_function(self, functions, length_x_axis):
585583
586584 y_list = numpy .zeros (number_of_x_points )
587585
588- previous = numpy .seterr (invalid = 'ignore' , divide = 'ignore' )
589- for function in functions :
590- y_list += function .evaluate (x_list ).reshape (- 1 )
591- numpy .seterr (** previous )
586+ with numpy .errstate (invalid = 'ignore' , divide = 'ignore' ):
587+ for function in functions :
588+ y_list += function .evaluate (x_list ).reshape (- 1 )
592589
593590 cord_list = self ._create_drawing_iterator (x_values , y_list )
594591
@@ -741,43 +738,41 @@ def calculateMaxY(self, modelList):
741738 y = max (model .predictions )
742739 y_max = max (y , y_max )
743740
744- previous = numpy .seterr (invalid = 'ignore' , divide = 'ignore' )
745-
746- if self .combine_all_callpath :
747- y_agg = 0
741+ with numpy .errstate (invalid = 'ignore' , divide = 'ignore' ):
742+ if self .combine_all_callpath :
743+ y_agg = 0
744+ for model in modelList :
745+ function = model .hypothesis .function
746+ y_agg = y_agg + function .evaluate (pv_list )
747+ y_max = max (y_agg , y_max )
748+
749+ pv_list [param ] = 1
750+ y_agg = 0
751+ for model in modelList :
752+ function = model .hypothesis .function
753+ y = function .evaluate (pv_list )
754+ if math .isinf (y ):
755+ y = max (model .predictions )
756+ y_agg += y
757+ y_max = max (y_agg , y_max )
758+
759+ # Check the value at the end of the displayed interval
748760 for model in modelList :
749761 function = model .hypothesis .function
750- y_agg = y_agg + function .evaluate (pv_list )
751- y_max = max (y_agg , y_max )
762+ y = function .evaluate (pv_list )
763+ if math .isinf (y ):
764+ y = max (model .predictions )
765+ y_max = max (y , y_max )
752766
767+ # Check the value at the beginning of the displayed interval
753768 pv_list [param ] = 1
754- y_agg = 0
755769 for model in modelList :
756770 function = model .hypothesis .function
757771 y = function .evaluate (pv_list )
758772 if math .isinf (y ):
759773 y = max (model .predictions )
760- y_agg += y
761- y_max = max (y_agg , y_max )
762-
763- # Check the value at the end of the displayed interval
764- for model in modelList :
765- function = model .hypothesis .function
766- y = function .evaluate (pv_list )
767- if math .isinf (y ):
768- y = max (model .predictions )
769- y_max = max (y , y_max )
770-
771- # Check the value at the beginning of the displayed interval
772- pv_list [param ] = 1
773- for model in modelList :
774- function = model .hypothesis .function
775- y = function .evaluate (pv_list )
776- if math .isinf (y ):
777- y = max (model .predictions )
778- y_max = max (y , y_max )
774+ y_max = max (y , y_max )
779775
780- numpy .seterr (** previous )
781776 # Ensure that the maximum value is never too small
782777 if y_max < 0.000001 :
783778 y_max = 1
0 commit comments