8000 Merge remote-tracking branch 'upstream/v1.3.x' · matplotlib/matplotlib@7e64adf · GitHub
[go: up one dir, main page]

Skip to content

Commit 7e64adf

Browse files
committed
Merge remote-tracking branch 'upstream/v1.3.x'
Conflicts: lib/matplotlib/__init__.py lib/matplotlib/units.py
2 parents 51595a1 + c0fcab4 commit 7e64adf

File tree

15 files changed

+165
-125
lines changed

15 files changed

+165
-125
lines changed

.travis.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ python:
77
- 3.3
88

99
install:
10-
- pip install -q --use-mirrors nose python-dateutil numpy pep8
11-
# This is a workaround to install the latest versions of pyparsing,
12-
# which are not yet available on PyPI
13-
- 'if [ ${TRAVIS_PYTHON_VERSION:0:1} == "3" ]; then pip -q install http://sourceforge.net/projects/pyparsing/files/pyparsing/pyparsing-2.0.0/pyparsing-2.0.0.tar.gz; fi'
14-
- 'if [ ${TRAVIS_PYTHON_VERSION:0:1} == "2" ]; then pip -q install http://sourceforge.net/projects/pyparsing/files/pyparsing/pyparsing-1.5.7/pyparsing-1.5.7.tar.gz; fi'
10+
- pip install -q --use-mirrors nose python-dateutil numpy pep8 pyparsing
1511
- if [[ $TRAVIS_PYTHON_VERSION == '2.'* ]]; then pip -q install --use-mirrors PIL; fi
1612
- sudo apt-get update && sudo apt-get -qq install inkscape
1713
- python setup.py install

INSTALL

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,10 @@ libpng 1.2 (or later)
199199
:term:`dateutil` 1.1 or later
200200
Provides extensions to python datetime handling. If using pip,
201201
easy_install or installing from source, the installer will attempt
202-
to download and install `python_dateutil` from PyPI.
202+
to download and install `python_dateutil` from PyPI. Note that
203+
`python_dateutil` also depends on `six`. `pip` and other package
204+
managers should handle installing that secondary dependency
205+
automatically.
203206

204207
`pyparsing`
205208
Required for matplotlib's mathtext math rendering support. If

doc/_static/logo_sidebar_horiz.png

-11 KB
Loading

doc/users/whats_new.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,11 +305,12 @@ New setup script
305305
````````````````
306306
matplotlib 1.3 includes an entirely rewritten setup script. We now
307307
ship fewer dependencies with the tarballs and installers themselves.
308-
Notably, `pytz`, `dateutil` and `pyparsing` are no longer included
309-
with matplotlib. You can either install them manually first, or let
310-
`pip` install them as dependencies along with matplotlib. It is now
311-
possible to not include certain subcomponents, such as the unit test
312-
data, in the install. See `setup.cfg.template` for more information.
308+
Notably, `pytz`, `dateutil`, `pyparsing` and `six` are no longer
309+
included with matplotlib. You can either install them manually first,
310+
or let `pip` install them as dependencies along with matplotlib. It
311+
is now possible to not include certain subcomponents, such as the unit
312+
test data, in the install. See `setup.cfg.template` for more
313+
information.
313314

314315
XDG base directory support
315316
``````````````````````````

lib/matplotlib/__init__.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
import sys
103103

104104
__version__ = '1.4.x'
105-
__version__numpy__ = '1.4' # minimum required numpy version
105+
__version__numpy__ = '1.5' # minimum required numpy version
106106

107107
try:
108108
import dateutil
@@ -120,6 +120,21 @@
120120
"matplotlib requires pyparsing >= {0}".format(
121121
'.'.join(str(x) for x in _required)))
122122

123+
if pyparsing.__version__ == '2.0.0':
124+
raise ImportError(
125+
"pyparsing 2.0.0 has bugs that prevent its use with "
126+
"matplotlib")
127+
128+
# pyparsing 1.5.6 does not have <<= on the Forward class, but
129+
# pyparsing 2.0.0 and later will spew deprecation warnings if
130+
# using << instead. In order to support pyparsing 1.5.6 and above
131+
# with a common code base, this small monkey patch is applied.
132+
if not hasattr(pyparsing.Forward, '__ilshift__'):
133+
def _forward_ilshift(self, other):
134+
self.__lshift__(other)
135+
return self
136+
pyparsing.Forward.__ilshift__ = _forward_ilshift
137+
123138
import os, re, shutil, warnings
124139
import distutils.sysconfig
125140
import distutils.version

lib/matplotlib/backend_bases.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3125,7 +3125,7 @@ def draw(self):
31253125

31263126
for loc in locators:
31273127
loc.refresh()
3128-
self.canvas.draw()
3128+
self.canvas.draw_idle()
31293129

31303130
def _update_view(self):
31313131
"""Update the viewlim and position from the view and
@@ -3146,7 +3146,7 @@ def _update_view(self):
31463146
a.set_position(pos[i][0], 'original')
31473147
a.set_position(pos[i][1], 'active')
31483148

3149-
self.draw()
3149+
self.draw_idle()
31503150

31513151
def save_figure(self, *args):
31523152
"""Save the current figure"""

lib/matplotlib/backends/backend_webagg.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ def handle_event(self, event):
253253
elif e_type == 'key_release':
254254
self.key_release_event(key)
255255
elif e_type == 'toolbar_button':
256-
print('Toolbar button pressed: ', event['name'])
257256
# TODO: Be more suspicious of the input
258257
getattr(self.toolbar, event['name'])()
259258
elif e_type == 'refresh':
@@ -296,8 +295,10 @@ def remove_web_socket(self, web_socket):
296295
self.web_sockets.remove(web_socket)
297296

298297
def refresh_all(self):
299-
for s in self.web_sockets:
300-
s.send_image()
298+
if self.web_sockets:
299+
diff = self.canvas.get_diff_image()
300+
for s in self.web_sockets:
301+
s.send_diff_image(diff)
301302

302303
def send_event(self, event_type, **kwargs):
303304
for s in self.web_sockets:
@@ -377,7 +378,7 @@ class FavIcon(tornado.web.RequestHandler):
377378
def get(self):
378379
self.set_header('Content-Type', 'image/png')
379380
with open(os.path.join(WebAggApplication._mpl_dirs['images'],
380-
'matplotlib.png')) as fd:
381+
'matplotlib.png'), 'rb') as fd:
381382
self.write(fd.read())
382383

383384
class SingleFigurePage(tornado.web.RequestHandler):
@@ -473,6 +474,8 @@ def open(self, fignum):
473474
_, _, w, h = manager.canvas.figure.bbox.bounds
474475
manager.resize(w, h)
475476
self.on_message('{"type":"refresh"}')
477+
if hasattr(self, 'set_nodelay'):
478+
self.set_nodelay(True)
476479

477480
def on_close(self):
478481
Gcf.get_fig_manager(self.fignum).remove_web_socket(self)
@@ -484,6 +487,15 @@ def on_message(self, message):
484487
# whole.
485488
if message['type'] == 'supports_binary':
486489
self.supports_binary = message['value']
490+
elif message['type'] == 'ack':
491+
# Network latency tends to decrease if traffic is
492+
# flowing in both directions. Therefore, the browser
493+
# sends back an "ack" message after each image frame
494+
# is received. This could also be used as a simple
495+
# sanity check in the future, but for now the
496+
# performance increase is enough to justify it, even
497+
# if the server does nothing with it.
498+
pass
487499
else:
488500
canvas = Gcf.get_fig_manager(self.fignum).canvas
489501
canvas.handle_event(message)
@@ -493,9 +505,7 @@ def send_event(self, event_type, **kwargs):
493505
payload.update(kwargs)
494506
self.write_message(json.dumps(payload))
495507

496-
def send_image(self):
497-
canvas = Gcf.get_fig_manager(self.fignum).canvas
498-
diff = canvas.get_diff_image()
508+
def send_diff_image(self, diff):
499509
if self.supports_binary:
500510
self.write_message(diff, binary=True)
501511
else:

lib/matplotlib/backends/qt4_editor/formlayout.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def get(self):
353353
elif isinstance(value, bool):
354354
value = field.checkState() == Qt.Checked
355355
elif isinstance(value, float):
356-
value = float(field.text())
356+
value = float(str(field.text()))
357357
elif isinstance(value, int):
358358
value = int(field.value())
359359
elif isinstance(value, datetime.datetime):

lib/matplotlib/backends/web_backend/mpl.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ figure.prototype.finalize = function (canvas_id_prefix, toolbar_id_prefix, messa
6666
onload_creator = function(fig) {return function() {fig.context.drawImage(fig.imageObj, 0, 0);};};
6767
this.imageObj.onload = onload_creator(fig);
6868

69+
70+
this.imageObj.onunload = function() {
71+
this.ws.close();
72+
}
73+
6974
this.ws.onmessage = gen_on_msg_fn(this);
7075
};
7176

@@ -88,11 +93,13 @@ function gen_on_msg_fn(fig)
8893
}
8994
fig.imageObj.src = (window.URL || window.webkitURL).createObjectURL(
9095
evt.data);
96+
fig.ws.send('{"type": "ack"}')
9197
return;
9298
}
9399
} else {
94100
if (evt.data.slice(0, 21) == "data:image/png;base64") {
95101
fig.imageObj.src = evt.data;
102+
fig.ws.send('{"type": "ack"}')
96103
return;
97104
}
98105
}
@@ -132,6 +139,9 @@ function gen_on_msg_fn(fig)
132139
fig.rubberband_canvas.width = size[0];
133140
fig.rubberband_canvas.height = size[1];
134141
fig.ws.send(JSON.stringify({type: 'refresh'}));
142+
fig.ws.send(JSON.stringify(
143+
{type: 'supports_binary',
144+
value: fig.supports_binary}));
135145
}
136146
break;
137147

lib/matplotlib/mathtext.py

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2179,69 +2179,69 @@ def __init__(self):
21792179
if key != 'self':
21802180
val.setName(key)
21812181

2182-
float_literal << Regex(r"[-+]?([0-9]+\.?[0-9]*|\.[0-9]+)")
2183-
int_literal << Regex("[-+]?[0-9]+")
2182+
float_literal <<= Regex(r"[-+]?([0-9]+\.?[0-9]*|\.[0-9]+)")
2183+
int_literal <<= Regex("[-+]?[0-9]+")
21842184

2185-
lbrace << Literal('{').suppress()
2186-
rbrace << Literal('}').suppress()
2187-
lbracket << Literal('[').suppress()
2188-
rbracket << Literal(']').suppress()
2189-
bslash << Literal('\\')
2185+
lbrace <<= Literal('{').suppress()
2186+
rbrace <<= Literal('}').suppress()
2187+
lbracket <<= Literal('[').suppress()
2188+
rbracket <<= Literal(']').suppress()
2189+
bslash <<= Literal('\\')
21902190

2191-
space << oneOf(self._space_widths.keys())
2192-
customspace << (Suppress(Literal(r'\hspace'))
2191+
space <<= oneOf(self._space_widths.keys())
2192+
customspace <<= (Suppress(Literal(r'\hspace'))
21932193
- ((lbrace + float_literal + rbrace)
21942194
| Error(r"Expected \hspace{n}")))
21952195

21962196
unicode_range = u"\U00000080-\U0001ffff"
2197-
single_symbol << Regex(UR"([a-zA-Z0-9 +\-*/<>=:,.;!\?&'@()\[\]|%s])|(\\[%%${}\[\]_|])" %
2197+
single_symbol <<= Regex(UR"([a-zA-Z0-9 +\-*/<>=:,.;!\?&'@()\[\]|%s])|(\\[%%${}\[\]_|])" %
21982198
unicode_range)
2199-
symbol_name << (Combine(bslash + oneOf(tex2uni.keys())) +
2199+
symbol_name <<= (Combine(bslash + oneOf(tex2uni.keys())) +
22002200
FollowedBy(Regex("[^A-Za-z]").leaveWhitespace() | StringEnd()))
2201-
symbol << (single_symbol | symbol_name).leaveWhitespace()
2201+
symbol <<= (single_symbol | symbol_name).leaveWhitespace()
22022202

2203-
apostrophe << Regex("'+")
2203+
apostrophe <<= Regex("'+")
22042204

2205-
c_over_c << Suppress(bslash) + oneOf(self._char_over_chars.keys())
2205+
c_over_c <<= Suppress(bslash) + oneOf(self._char_over_chars.keys())
22062206

2207-
accent << Group(
2207+
accent <<= Group(
22082208
Suppress(bslash)
22092209
+ oneOf(self._accent_map.keys() + list(self._wide_accents))
22102210
- placeable
22112211
)
22122212

2213-
function << Suppress(bslash) + oneOf(list(self._function_names))
2213+
function <<= Suppress(bslash) + oneOf(list(self._function_names))
22142214

2215-
start_group << Optional(latexfont) + lbrace
2216-
end_group << rbrace.copy()
2217-
simple_group << Group(lbrace + ZeroOrMore(token) + rbrace)
2218-
required_group<< Group(lbrace + OneOrMore(token) + rbrace)
2219-
group << Group(start_group + ZeroOrMore(token) + end_group)
2215+
start_group <<= Optional(latexfont) + lbrace
2216+
end_group <<= rbrace.copy()
2217+
simple_group <<= Group(lbrace + ZeroOrMore(token) + rbrace)
2218+
required_group<<= Group(lbrace + OneOrMore(token) + rbrace)
2219+
group <<= Group(start_group + ZeroOrMore(token) + end_group)
22202220

2221-
font << Suppress(bslash) + oneOf(list(self._fontnames))
2222-
latexfont << Suppress(bslash) + oneOf(['math' + x for x in self._fontnames])
2221+
font <<= Suppress(bslash) + oneOf(list(self._fontnames))
2222+
latexfont <<= Suppress(bslash) + oneOf(['math' + x for x in self._fontnames])
22232223

2224-
frac << Group(
2224+
frac <<= Group(
22252225
Suppress(Literal(r"\frac"))
22262226
- ((required_group + required_group) | Error(r"Expected \frac{num}{den}"))
22272227
)
22282228

2229-
stackrel << Group(
2229+
stackrel <<= Group(
22302230
Suppress(Literal(r"\stackrel"))
22312231
- ((required_group + required_group) | Error(r"Expected \stackrel{num}{den}"))
22322232
)
22332233

2234-
binom << Group(
2234+
binom <<= Group(
22352235
Suppress(Literal(r"\binom"))
22362236
- ((required_group + required_group) | Error(r"Expected \binom{num}{den}"))
22372237
)
22382238

2239-
ambi_delim << oneOf(list(self._ambi_delim))
2240-
left_delim << oneOf(list(self._left_delim))
2241-
right_delim << oneOf(list(self._right_delim))
2242-
right_delim_safe << oneOf(list(self._right_delim - set(['}'])) + [r'\}'])
2239+
ambi_delim <<= oneOf(list(self._ambi_delim))
2240+
left_delim <<= oneOf(list(self._left_delim))
2241+
right_delim <<= oneOf(list(self._right_delim))
2242+
right_delim_safe <<= oneOf(list(self._right_delim - set(['}'])) + [r'\}'])
22432243

2244-
genfrac << Group(
2244+
genfrac <<= Group(
22452245
Suppress(Literal(r"\genfrac"))
22462246
- (((lbrace + Optional(ambi_delim | left_delim, default='') + rbrace)
22472247
+ (lbrace + Optional(ambi_delim | right_delim_safe, default='') + rbrace)
@@ -2250,27 +2250,27 @@ def __init__(self):
22502250
| Error(r"Expected \genfrac{ldelim}{rdelim}{rulesize}{style}{num}{den}"))
22512251
)
22522252

2253-
sqrt << Group(
2253+
sqrt <<= Group(
22542254
Suppress(Literal(r"\sqrt"))
22552255
- ((Optional(lbracket + int_literal + rbracket, default=None)
22562256
+ required_group)
22572257
| Error("Expected \sqrt{value}"))
22582258
)
22592259

2260-
overline << Group(
2260+
overline <<= Group(
22612261
Suppress(Literal(r"\overline"))
22622262
- (required_group | Error("Expected \overline{value}"))
22632263
)
22642264

2265-
unknown_symbol<< Combine(bslash + Regex("[A-Za-z]*"))
2265+
unknown_symbol<<= Combine(bslash + Regex("[A-Za-z]*"))
22662266

2267-
operatorname << Group(
2267+
operatorname <<= Group(
22682268
Suppress(Literal(r"\operatorname"))
22692269
- ((lbrace + ZeroOrMore(simple | unknown_symbol) + rbrace)
22702270
| Error("Expected \operatorname{value}"))
22712271
)
22722272

2273-
placeable << ( accent # Must be first
2273+
placeable <<= ( accent # Must be first
22742274
| symbol # Must be second
22752275
| c_over_c
22762276
| function
@@ -2284,39 +2284,39 @@ def __init__(self):
22842284
| operatorname
22852285
)
22862286

2287-
simple << ( space
2287+
simple <<= ( space
22882288
| customspace
22892289
| font
22902290
| subsuper
22912291
)
22922292

2293-
subsuperop << oneOf(["_", "^"])
2293+
subsuperop <<= oneOf(["_", "^"])
22942294

2295-
subsuper << Group(
2295+
subsuper <<= Group(
22962296
(Optional(placeable) + OneOrMore(subsuperop - placeable) + Optional(apostrophe))
22972297
| (placeable + Optional(apostrophe))
22982298
| apostrophe
22992299
)
23002300

2301-
token << ( simple
2301+
token <<= ( simple
23022302
| auto_delim
23032303
| unknown_symbol # Must be last
23042304
)
23052305

2306-
auto_delim << (Suppress(Literal(r"\left"))
2306+
auto_delim <<= (Suppress(Literal(r"\left"))
23072307
- ((left_delim | ambi_delim) | Error("Expected a delimiter"))
23082308
+ Group(ZeroOrMore(simple | auto_delim))
23092309
+ Suppress(Literal(r"\right"))
23102310
- ((right_delim | ambi_delim) | Error("Expected a delimiter"))
23112311
)
23122312

2313-
math << OneOrMore(token)
2313+
math <<= OneOrMore(token)
23142314

2315-
math_string << QuotedString('$', '\\', unquoteResults=False)
2315+
math_string <<= QuotedString('$', '\\', unquoteResults=False)
23162316

2317-
non_math << Regex(r"(?:(?:\\[$])|[^$])*").leaveWhitespace()
2317+
non_math <<= Regex(r"(?:(?:\\[$])|[^$])*").leaveWhitespace()
23182318

2319-
main << (non_math + ZeroOrMore(math_string + non_math)) + StringEnd()
2319+
main <<= (non_math + ZeroOrMore(math_string + non_math)) + StringEnd()
23202320

23212321
# Set actions
23222322
for key, val in locals().items():

0 commit comments

Comments
 (0)
0