Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c5e0245

Browse files
committed
More standardization of floating point slop in mpl_toolkits.
A few instances I missed in fb18d95. At least grepping for delta doesn't yield anything else.
1 parent a6da11e commit c5e0245

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lib/mpl_toolkits/axisartist/floating_axes.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
# TODO :
66
# see if tick_iterator method can be simplified by reusing the parent method.
77

8+
import functools
9+
810
import numpy as np
911

12+
import matplotlib as mpl
1013
from matplotlib import _api, cbook
1114
import matplotlib.axes as maxes
1215
import matplotlib.patches as mpatches
@@ -121,10 +124,11 @@ def f1():
121124
dd[mm] = dd2[mm] + np.pi / 2
122125

123126
tick_to_axes = self.get_tick_transform(axes) - axes.transAxes
127+
in_01 = functools.partial(
128+
mpl.transforms._interval_contains_close, (0, 1))
124129
for x, y, d, d2, lab in zip(xx1, yy1, dd, dd2, labels):
125130
c2 = tick_to_axes.transform((x, y))
126-
delta = 0.00001
127-
if 0-delta <= c2[0] <= 1+delta and 0-delta <= c2[1] <= 1+delta:
131+
if in_01(c2[0]) and in_01(c2[1]):
128132
d1, d2 = np.rad2deg([d, d2])
129133
yield [x, y], d1, d2, lab
130134

lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
"""
22
An experimental support for curvilinear grid.
33
"""
4+
5+
import functools
46
from itertools import chain
57

68
import numpy as np
79

10+
import matplotlib as mpl
811
from matplotlib import _api
912
from matplotlib.path import Path
1013
from matplotlib.transforms import Affine2D, IdentityTransform
@@ -231,10 +234,11 @@ def f1():
231234
dd[mm] = dd2[mm] + np.pi / 2
232235

233236
tick_to_axes = self.get_tick_transform(axes) - axes.transAxes
237+
in_01 = functools.partial(
238+
mpl.transforms._interval_contains_close, (0, 1))
234239
for x, y, d, d2, lab in zip(xx1, yy1, dd, dd2, labels):
235240
c2 = tick_to_axes.transform((x, y))
236-
delta = 0.00001
237-
if 0-delta <= c2[0] <= 1+delta and 0-delta <= c2[1] <= 1+delta:
241+
if in_01(c2[0]) and in_01(c2[1]):
238242
d1, d2 = np.rad2deg([d, d2])
239243
yield [x, y], d1, d2, lab
240244

0 commit comments

Comments
 (0)