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

Skip to content

Commit 76665d0

Browse files
committed
Merge remote-tracking branch 'origin/v1.1.x'
Conflicts: CHANGELOG lib/matplotlib/__init__.py lib/matplotlib/backends/backend_agg.py lib/matplotlib/mathtext.py lib/matplotlib/patches.py lib/matplotlib/tests/test_axes.py
2 parents e8356dc + 9a8b35e commit 76665d0

File tree

124 files changed

+637
-177
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+637
-177
lines changed

CHANGELOG

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
2012-04-06 When path clipping changes a LINETO to a MOVETO, it also
2+
changes any CLOSEPOLY command to a LINETO to the initial
3+
point. This fixes a problem with pdf and svg where the
4+
CLOSEPOLY would then draw a line to the latest MOVETO
5+
position instead of the intended initial position. - JKS
6+
17
2012-03-27 Add support to ImageGrid for placing colorbars only at
28
one edge of each column/row. - RMM
39

@@ -18,7 +24,7 @@
1824
(rmax - rmin) gets too small. - MGD
1925

2026
2012-01-08 Add axes.streamplot to plot streamlines of a velocity field.
21-
Adapted from Tom Flannaghan streamplot implementation. -TSY
27+
Adapted from Tom Flannaghan streamplot implementation. -TSY
2228

2329
2011-12-29 ps and pdf markers are now stroked only if the line width
2430
is nonzero for consistency with agg, fixes issue #621. - JKS

doc/_templates/indexsidebar.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ <h3>News</h3>
55
to support matplotlib development.</p>
66

77

8-
<p>Matplotlib 1.1.0 is available for
9-
<a href="https://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.0/">download</a>.
8+
<p>Matplotlib 1.1.1 is available for
9+
<a href="https://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.1/">download</a>.
1010
See <a href="{{ pathto('users/whats_new') }}">what's new</a>
1111
and tips on <a href="{{ pathto('users/installing') }}">installing</a>.
1212
</p>

lib/matplotlib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ def tk_window_focus():
10071007
'matplotlib.tests.test_legend'
10081008
]
10091009

1010-
def test(verbosity=0):
1010+
def test(verbosity=1):
10111011
"""run the matplotlib test suite"""
10121012
old_backend = rcParams['backend']
10131013
try:

lib/matplotlib/_mathtext_data.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@
134134
r'\Psi' : ('cmr10', 15),
135135
r'\Omega' : ('cmr10', 12),
136136

137+
r'\prime' : ('cmsy10', 73),
138+
137139
# these are mathml names, I think. I'm just using them for the
138140
# tex methods noted
139141
r'\circumflexaccent' : ('cmr10', 124), # for \hat
@@ -246,7 +248,7 @@
246248
r'\spadesuit' : ('cmsy10', 7),
247249
r'?' : ('cmr10', 50),
248250
r'!' : ('cmr10', 29),
249-
r'&' : ('cmr10', 109)
251+
r'&' : ('cmr10', 109)
250252
}
251253

252254
latex_to_cmex = {

lib/matplotlib/backends/backend_agg.py

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* integrate screen dpi w/ ppi and text
2222
"""
2323
from __future__ import division
24-
24+
import threading
2525
import numpy as np
2626

2727
from matplotlib import verbose, rcParams
@@ -59,11 +59,24 @@ class RendererAgg(RendererBase):
5959
context instance that controls the colors/styles
6060
"""
6161
debug=1
62+
63+
# we want to cache the fonts at the class level so that when
64+
# multiple figures are created we can reuse them. This helps with
65+
# a bug on windows where the creation of too many figures leads to
66+
# too many open file handles. However, storing them at the class
67+
# level is not thread safe. The solution here is to let the
68+
# FigureCanvas acquire a lock on the fontd at the start of the
69+
# draw, and release it when it is done. This allows multiple
70+
# renderers to share the cached fonts, but only one figure can
71+
# draw at at time and so the font cache is used by only one
72+
# renderer at a time
73+
74+
lock = threading.Lock()
75+
_fontd = maxdict(50)
6276
def __init__(self, width, height, dpi):
6377
if __debug__: verbose.report('RendererAgg.__init__', 'debug-annoying')
6478
RendererBase.__init__(self)
6579
self.texd = maxdict(50) # a cache of tex image rasters
66-
self._fontd = maxdict(50)
6780

6881
self.dpi = dpi
6982
self.width = width
@@ -82,6 +95,12 @@ def __init__(self, width, height, dpi):
8295
if __debug__: verbose.report('RendererAgg.__init__ done',
8396
'debug-annoying')
8497

98+
def _get_hinting_flag(self):
99+
if rcParams['text.hinting']:
100+
return LOAD_FORCE_AUTOHINT
101+
else:
102+
return LOAD_NO_HINTING
103+
85104
# for filtering to work with rasterization, methods needs to be wrapped.
86105
# maybe there is better way to do it.
87106
def draw_markers(self, *kl, **kw):
@@ -221,17 +240,17 @@ def _get_agg_font(self, prop):
221240
'debug-annoying')
222241

223242
key = hash(prop)
224-
font = self._fontd.get(key)
243+
font = RendererAgg._fontd.get(key)
225244

226245
if font is None:
227246
fname = findfont(prop)
228-
font = self._fontd.get(fname)
247+
font = RendererAgg._fontd.get(fname)
229248
if font is None:
230249
font = FT2Font(
231250
str(fname),
232251
hinting_factor=rcParams['text.hinting_factor'])
233-
self._fontd[fname] = font
234-
self._fontd[key] = font
252+
RendererAgg._fontd[fname] = font
253+
RendererAgg._fontd[key] = font
235254

236255
font.clear()
237256
size = prop.get_size_in_points()
@@ -366,6 +385,7 @@ def post_processing(image, dpi):
366385
image)
367386

368387

388+
369389
def new_figure_manager(num, *args, **kwargs):
370390
"""
371391
Create a new figure manager instance
@@ -406,7 +426,15 @@ def draw(self):
406426
if __debug__: verbose.report('FigureCanvasAgg.draw', 'debug-annoying')
407427

408428
self.renderer = self.get_renderer()
409-
self.figure.draw(self.renderer)
429+
# acquire a lock on the shared font cache
430+
RendererAgg.lock.acquire()
431+
432+
try:
433+
self.figure.draw(self.renderer)
434+
finally:
435+
RendererAgg.lock.release()
436+
437+
410438

411439
def get_renderer(self):
412440
l, b, w, h = self.figure.bbox.bounds

lib/matplotlib/backends/backend_gtk.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ def fn_name(): return sys._getframe(1).f_code.co_name
5050
# see http://groups.google.com/groups?q=screen+dpi+x11&hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&selm=7077.26e81ad5%40swift.cs.tcd.ie&rnum=5 for some info about screen dpi
5151
PIXELS_PER_INCH = 96
5252

53+
# Hide the benign warning that it can't stat a file that doesn't
54+
warnings.filterwarnings('ignore', '.*Unable to retrieve the file info for.*', gtk.Warning)
55+
5356
cursord = {
5457
cursors.MOVE : gdk.Cursor(gdk.FLEUR),
5558
cursors.HAND : gdk.Cursor(gdk.HAND2),

lib/matplotlib/mathtext.py

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,6 +2129,7 @@ def __init__(self):
21292129
# All forward declarations are here
21302130
accent = Forward()
21312131
ambi_delim = Forward()
2132+
apostrophe = Forward()
21322133
auto_delim = Forward()
21332134
binom = Forward()
21342135
bslash = Forward()
@@ -2198,6 +2199,8 @@ def __init__(self):
21982199
FollowedBy(Regex("[^A-Za-z]").leaveWhitespace() | StringEnd()))
21992200
symbol << (single_symbol | symbol_name).leaveWhitespace()
22002201

2202+
apostrophe << Regex("'+")
2203+
22012204
c_over_c << Suppress(bslash) + oneOf(self._char_over_chars.keys())
22022205

22032206
accent << Group(
@@ -2289,8 +2292,9 @@ def __init__(self):
22892292
subsuperop << oneOf(["_", "^"])
22902293

22912294
subsuper << Group(
2292-
(Optional(placeable) + OneOrMore(subsuperop - placeable))
2293-
| placeable
2295+
(Optional(placeable) + OneOrMore(subsuperop - placeable) + Optional(apostrophe))
2296+
| (placeable + Optional(apostrophe))
2297+
| apostrophe
22942298
)
22952299

22962300
token << ( simple
@@ -2451,8 +2455,6 @@ def customspace(self, s, loc, toks):
24512455
def symbol(self, s, loc, toks):
24522456
# print "symbol", toks
24532457
c = toks[0]
2454-
if c == "'":
2455-
c = '\prime'
24562458
try:
24572459
char = Char(c, self.get_state())
24582460
except ValueError:
@@ -2630,23 +2632,39 @@ def subsuper(self, s, loc, toks):
26302632
sub = None
26312633
super = None
26322634

2633-
if len(toks[0]) == 1:
2634-
return toks[0].asList()
2635-
elif len(toks[0]) == 2:
2636-
op, next = toks[0]
2635+
# Pick all of the apostrophe's out
2636+
napostrophes = 0
2637+
new_toks = []
2638+
for tok in toks[0]:
2639+
if isinstance(tok, str) and tok not in ('^', '_'):
2640+
napostrophes += len(tok)
2641+
else:
2642+
new_toks.append(tok)
2643+
toks = new_toks
2644+
2645+
if len(toks) == 0:
2646+
assert napostrophes
2647+
nucleus = Hbox(0.0)
2648+
elif len(toks) == 1:
2649+
if not napostrophes:
2650+
return toks[0] # .asList()
2651+
else:
2652+
nucleus = toks[0]
2653+
elif len(toks) == 2:
2654+
op, next = toks
26372655
nucleus = Hbox(0.0)
26382656
if op == '_':
26392657
sub = next
26402658
else:
26412659
super = next
2642-
elif len(toks[0]) == 3:
2643-
nucleus, op, next = toks[0]
2660+
elif len(toks) == 3:
2661+
nucleus, op, next = toks
26442662
if op == '_':
26452663
sub = next
26462664
else:
26472665
super = next
2648-
elif len(toks[0]) == 5:
2649-
nucleus, op1, next1, op2, next2 = toks[0]
2666+
elif len(toks) == 5:
2667+
nucleus, op1, next1, op2, next2 = toks
26502668
if op1 == op2:
26512669
if op1 == '_':
26522670
raise ParseFatalException("Double subscript")
@@ -2669,6 +2687,12 @@ def subsuper(self, s, loc, toks):
26692687
xHeight = state.font_output.get_xheight(
26702688
state.font, state.fontsize, state.dpi)
26712689

2690+
if napostrophes:
2691+
if super is None:
2692+
super = Hlist([])
2693+
for i in range(napostrophes):
2694+
super.children.extend(self.symbol(s, loc, ['\prime']))
2695+
26722696
# Handle over/under symbols, such as sum or integral
26732697
if self.is_overunder(nucleus):
26742698
vlist = []

lib/matplotlib/patches.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ def __str__(self):
505505
return self.__class__.__name__ \
506506
+ "(%g,%g;%gx%g)" % (self._x, self._y, self._width, self._height)
507507

508-
508+
509509
@docstring.dedent_interpd
510510
def __init__(self, xy, width, height, **kwargs):
511511
"""
Binary file not shown.

0 commit comments

Comments
 (0)