Skip to content

Commit 86b1aad

Browse files
committed
ticker.py: always use np.round
1 parent c287b9f commit 86b1aad

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

lib/matplotlib/ticker.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -983,8 +983,8 @@ def __call__(self, x, pos=None):
983983
# only label the decades
984984
fx = math.log(x) / math.log(b)
985985
is_x_decade = _is_close_to_int(fx)
986-
exponent = round(fx) if is_x_decade else np.floor(fx)
987-
coeff = round(b ** (fx - exponent))
986+
exponent = np.round(fx) if is_x_decade else np.floor(fx)
987+
coeff = np.round(b ** (fx - exponent))
988988

989989
if self.labelOnlyBase and not is_x_decade:
990990
return ''
@@ -1064,16 +1064,16 @@ def __call__(self, x, pos=None):
10641064
# only label the decades
10651065
fx = math.log(x) / math.log(b)
10661066
is_x_decade = _is_close_to_int(fx)
1067-
exponent = round(fx) if is_x_decade else np.floor(fx)
1068-
coeff = round(b ** (fx - exponent))
1067+
exponent = np.round(fx) if is_x_decade else np.floor(fx)
1068+
coeff = np.round(b ** (fx - exponent))
10691069

10701070
if self.labelOnlyBase and not is_x_decade:
10711071
return ''
10721072
if self._sublabels is not None and coeff not in self._sublabels:
10731073
return ''
10741074

10751075
if is_x_decade:
1076-
fx = round(fx)
1076+
fx = np.round(fx)
10771077

10781078
# use string formatting of the base if it is not an integer
10791079
if b % 1 == 0.0:
@@ -1101,7 +1101,7 @@ def _non_decade_format(self, sign_string, base, fx, usetex):
11011101
exponent = math.floor(fx)
11021102
coeff = b ** (fx - exponent)
11031103
if _is_close_to_int(coeff):
1104-
coeff = round(coeff)
1104+
coeff = np.round(coeff)
11051105
return r'$\mathdefault{%s%g\times%s^{%d}}$' \
11061106
% (sign_string, coeff, base, exponent)
11071107

@@ -1276,13 +1276,13 @@ def __call__(self, x, pos=None):
12761276
return ""
12771277
if x <= 0 or x >= 1:
12781278
return ""
1279-
if _is_close_to_int(2 * x) and round(2 * x) == 1:
1279+
if _is_close_to_int(2 * x) and np.round(2 * x) == 1:
12801280
s = self._one_half
12811281
elif x < 0.5 and _is_decade(x, rtol=1e-7):
1282-
exponent = round(math.log10(x))
1282+
exponent = np.round(math.log10(x))
12831283
s = "10^{%d}" % exponent
12841284
elif x > 0.5 and _is_decade(1 - x, rtol=1e-7):
1285-
exponent = round(math.log10(1 - x))
1285+
exponent = np.round(math.log10(1 - x))
12861286
s = self._one_minus("10^{%d}" % exponent)
12871287
elif x < 0.1:
12881288
s = self._format_value(x, self.locs)
@@ -2239,7 +2239,7 @@ def _decade_greater(x, base):
22392239

22402240

22412241
def _is_close_to_int(x):
2242-
return math.isclose(x, round(x))
2242+
return math.isclose(x, np.round(x))
22432243

22442244

22452245
class LogLocator(Locator):
@@ -2904,8 +2904,8 @@ def __call__(self):
29042904

29052905
vmin, vmax = sorted(self.axis.get_view_interval())
29062906
t0 = majorlocs[0]
2907-
tmin = round((vmin - t0) / minorstep)
2908-
tmax = round((vmax - t0) / minorstep) + 1
2907+
tmin = np.round((vmin - t0) / minorstep)
2908+
tmax = np.round((vmax - t0) / minorstep) + 1
29092909
locs = (np.arange(tmin, tmax) * minorstep) + t0
29102910

29112911
return self.raise_if_exceeds(locs)

0 commit comments

Comments
 (0)