From b24864817c8807890752501a53803c494a19aa6a Mon Sep 17 00:00:00 2001 From: Richard Bryan Date: Thu, 30 Jul 2015 14:00:07 -0400 Subject: [PATCH] use numpy.finfo instead of numpy.MachAr for speedup numpy.MachAr is expensive to use just to determine min/max float value; use numpy.finfo instead since it caches this information. This results in significant performance gains when updating axes limits frequently. --- lib/matplotlib/transforms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/transforms.py b/lib/matplotlib/transforms.py index 75fda8c1d230..3e1ba4a932ea 100644 --- a/lib/matplotlib/transforms.py +++ b/lib/matplotlib/transforms.py @@ -2738,7 +2738,7 @@ def nonsingular(vmin, vmax, expander=0.001, tiny=1e-15, increasing=True): swapped = True maxabsvalue = max(abs(vmin), abs(vmax)) - if maxabsvalue < (1e6 / tiny) * np.MachAr(float).xmin: + if maxabsvalue < (1e6 / tiny) * np.finfo(float).min: vmin = -expander vmax = expander