Skip to content

Commit

Permalink
PRF: only do expensive things once
Browse files Browse the repository at this point in the history
Looking up MachAr was taking about 10ms which is way to slow to be
inside of the mouse motion event loop.

We are using it to get a constant so we can look it up and compute
the constant once at the top.
  • Loading branch information
tacaswell committed Jul 28, 2015
1 parent ed44362 commit 2d0cc7d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/matplotlib/transforms.py
Expand Up @@ -50,7 +50,8 @@
from .path import Path

DEBUG = False

# we need this later, but this is very expensive to set up
MINFLOAT = np.MachAr(float).xmin
MaskedArray = ma.MaskedArray


Expand Down Expand Up @@ -2738,7 +2739,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) * MINFLOAT:
vmin = -expander
vmax = expander

Expand Down

0 comments on commit 2d0cc7d

Please sign in to comment.