Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cb6964d

Browse filesBrowse files
authored
Merge pull request #7573 from dopplershift/fix-round
Make rounding behavior consistent
2 parents 984e9b0 + a7e8922 commit cb6964d
Copy full SHA for cb6964d

File tree

Expand file treeCollapse file tree

6 files changed

+15
-12
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+15
-12
lines changed

‎doc/api/api_changes.rst

Copy file name to clipboardExpand all lines: doc/api/api_changes.rst
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ CocoaAgg backend removed
4040
~~~~~~~~~~~~~~~~~~~~~~~~
4141
The deprecated and not fully functional CocoaAgg backend has been removed.
4242

43+
`round` removed from TkAgg Backend
44+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
45+
The TkAgg backend had its own implementation of the `round` function. This
46+
was unused internally and has been removed. Instead, use either the
47+
`round` builtin function or `numpy.round`.
48+
4349
'hold' functionality deprecated
4450
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4551
The 'hold' keyword argument and all functions and methods related

‎examples/pylab_examples/date_index_formatter.py

Copy file name to clipboardExpand all lines: examples/pylab_examples/date_index_formatter.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"""
1010

1111
from __future__ import print_function
12-
import numpy
12+
import numpy as np
1313
from matplotlib.mlab import csv2rec
1414
import matplotlib.pyplot as plt
1515
import matplotlib.cbook as cbook
@@ -27,7 +27,7 @@ def __init__(self, dates, fmt='%Y-%m-%d'):
2727

2828
def __call__(self, x, pos=0):
2929
'Return the label for time x at position pos'
30-
ind = int(round(x))
30+
ind = int(np.round(x))
3131
if ind >= len(self.dates) or ind < 0:
3232
return ''
3333

@@ -37,6 +37,6 @@ def __call__(self, x, pos=0):
3737

3838
fig, ax = plt.subplots()
3939
ax.xaxis.set_major_formatter(formatter)
40-
ax.plot(numpy.arange(len(r)), r.close, 'o-')
40+
ax.plot(np.arange(len(r)), r.close, 'o-')
4141
fig.autofmt_xdate()
4242
plt.show()

‎lib/matplotlib/backends/backend_agg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_agg.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
210210

211211
#print x, y, int(x), int(y), s
212212
self._renderer.draw_text_image(
213-
font, round(x - xd + xo), round(y + yd + yo) + 1, angle, gc)
213+
font, np.round(x - xd + xo), np.round(y + yd + yo) + 1, angle, gc)
214214

215215
def get_text_width_height_descent(self, s, prop, ismath):
216216
"""
@@ -257,8 +257,8 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
257257
w, h, d = self.get_text_width_height_descent(s, prop, ismath)
258258
xd = d * sin(radians(angle))
259259
yd = d * cos(radians(angle))
260-
x = round(x + xd)
261-
y = round(y + yd)
260+
x = np.round(x + xd)
261+
y = np.round(y + yd)
262262

263263
self._renderer.draw_text_image(Z, x, y, angle, gc)
264264

‎lib/matplotlib/backends/backend_tkagg.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_tkagg.py
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@
5050
}
5151

5252

53-
def round(x):
54-
return int(math.floor(x+0.5))
55-
5653
def raise_msg_to_str(msg):
5754
"""msg is a return arg from a raise. Join with new lines"""
5855
if not is_string_like(msg):

‎lib/matplotlib/image.py

Copy file name to clipboardExpand all lines: lib/matplotlib/image.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def flush_images():
152152
gc = renderer.new_gc()
153153
gc.set_clip_rectangle(parent.bbox)
154154
gc.set_clip_path(parent.get_clip_path())
155-
renderer.draw_image(gc, round(l), round(b), data)
155+
renderer.draw_image(gc, np.round(l), np.round(b), data)
156156
gc.restore()
157157
del image_group[:]
158158

‎lib/matplotlib/ticker.py

Copy file name to clipboardExpand all lines: lib/matplotlib/ticker.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1760,8 +1760,8 @@ def _raw_ticks(self, vmin, vmax):
17601760
step = max(1, step)
17611761
best_vmin = (_vmin // step) * step
17621762

1763-
low = round(Base(step).le(_vmin - best_vmin) / step)
1764-
high = round(Base(step).ge(_vmax - best_vmin) / step)
1763+
low = np.round(Base(step).le(_vmin - best_vmin) / step)
1764+
high = np.round(Base(step).ge(_vmax - best_vmin) / step)
17651765
ticks = np.arange(low, high + 1) * step + best_vmin + offset
17661766
nticks = ((ticks <= vmax) & (ticks >= vmin)).sum()
17671767
if nticks >= self._min_n_ticks:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.