File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212def calculate_linthresh (data ):
1313 """Calculate the linear threshold for symlog scaling.
1414
15- Excludes machine-error zeros (values within ±sqrt(eps) of the data dtype),
15+ Excludes true zeros (values within ±tiny of the data dtype),
1616 then returns min(abs(valid)).
1717
1818 Operates on the original array without copies.
@@ -21,10 +21,9 @@ def calculate_linthresh(data):
2121 data: numpy array of data values
2222
2323 Returns:
24- linthresh value (float), clamped to at least 1.0
24+ linthresh value (float), floored at dtype tiny to avoid zero
2525 """
26- eps = np .finfo (data .dtype ).eps
27- threshold = np .sqrt (eps )
26+ threshold = np .finfo (data .dtype ).tiny
2827
2928 # Find min |x| > threshold without allocating a copy.
3029 # Using where= runs as a tight vectorized C loop, roughly 2-3 orders
@@ -37,7 +36,7 @@ def calculate_linthresh(data):
3736 if min_abs == np .inf :
3837 linthresh = 1.0
3938 else :
40- linthresh = max (float (min_abs ), 1.0 )
39+ linthresh = max (float (min_abs ), float ( np . finfo ( data . dtype ). tiny ) )
4140
4241 return linthresh
4342
You can’t perform that action at this time.
0 commit comments