Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/v1.3.x'
Browse files Browse the repository at this point in the history
Conflicts:
	lib/matplotlib/__init__.py
	lib/matplotlib/units.py
  • Loading branch information
mdboom committed Aug 12, 2013
2 parents 51595a1 + c0fcab4 commit 7e64adf
Show file tree
Hide file tree
Showing 15 changed files with 165 additions and 125 deletions.
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ python:
- 3.3

install:
- pip install -q --use-mirrors nose python-dateutil numpy pep8
# This is a workaround to install the latest versions of pyparsing,
# which are not yet available on PyPI
- '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'
- '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'
- pip install -q --use-mirrors nose python-dateutil numpy pep8 pyparsing
- if [[ $TRAVIS_PYTHON_VERSION == '2.'* ]]; then pip -q install --use-mirrors PIL; fi
- sudo apt-get update && sudo apt-get -qq install inkscape
- python setup.py install
Expand Down
5 changes: 4 additions & 1 deletion INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,10 @@ libpng 1.2 (or later)
:term:`dateutil` 1.1 or later
Provides extensions to python datetime handling. If using pip,
easy_install or installing from source, the installer will attempt
to download and install `python_dateutil` from PyPI.
to download and install `python_dateutil` from PyPI. Note that
`python_dateutil` also depends on `six`. `pip` and other package
managers should handle installing that secondary dependency
automatically.

`pyparsing`
Required for matplotlib's mathtext math rendering support. If
Expand Down
Binary file modified doc/_static/logo_sidebar_horiz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 6 additions & 5 deletions doc/users/whats_new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,12 @@ New setup script
````````````````
matplotlib 1.3 includes an entirely rewritten setup script. We now
ship fewer dependencies with the tarballs and installers themselves.
Notably, `pytz`, `dateutil` and `pyparsing` are no longer included
with matplotlib. You can either install them manually first, or let
`pip` install them as dependencies along with matplotlib. It is now
possible to not include certain subcomponents, such as the unit test
data, in the install. See `setup.cfg.template` for more information.
Notably, `pytz`, `dateutil`, `pyparsing` and `six` are no longer
included with matplotlib. You can either install them manually first,
or let `pip` install them as dependencies along with matplotlib. It
is now possible to not include certain subcomponents, such as the unit
test data, in the install. See `setup.cfg.template` for more
information.

XDG base directory support
``````````````````````````
Expand Down
17 changes: 16 additions & 1 deletion lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
import sys

__version__ = '1.4.x'
__version__numpy__ = '1.4' # minimum required numpy version
__version__numpy__ = '1.5' # minimum required numpy version

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

if pyparsing.__version__ == '2.0.0':
raise ImportError(
"pyparsing 2.0.0 has bugs that prevent its use with "
"matplotlib")

# pyparsing 1.5.6 does not have <<= on the Forward class, but
# pyparsing 2.0.0 and later will spew deprecation warnings if
# using << instead. In order to support pyparsing 1.5.6 and above
# with a common code base, this small monkey patch is applied.
if not hasattr(pyparsing.Forward, '__ilshift__'):
def _forward_ilshift(self, other):
self.__lshift__(other)
return self
pyparsing.Forward.__ilshift__ = _forward_ilshift

import os, re, shutil, warnings
import distutils.sysconfig
import distutils.version
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/backend_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -3125,7 +3125,7 @@ def draw(self):

for loc in locators:
loc.refresh()
self.canvas.draw()
self.canvas.draw_idle()

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

self.draw()
self.draw_idle()

def save_figure(self, *args):
"""Save the current figure"""
Expand Down
24 changes: 17 additions & 7 deletions lib/matplotlib/backends/backend_webagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ def handle_event(self, event):
elif e_type == 'key_release':
self.key_release_event(key)
elif e_type == 'toolbar_button':
print('Toolbar button pressed: ', event['name'])
# TODO: Be more suspicious of the input
getattr(self.toolbar, event['name'])()
elif e_type == 'refresh':
Expand Down Expand Up @@ -296,8 +295,10 @@ def remove_web_socket(self, web_socket):
self.web_sockets.remove(web_socket)

def refresh_all(self):
for s in self.web_sockets:
s.send_image()
if self.web_sockets:
diff = self.canvas.get_diff_image()
for s in self.web_sockets:
s.send_diff_image(diff)

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

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

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

def send_image(self):
canvas = Gcf.get_fig_manager(self.fignum).canvas
diff = canvas.get_diff_image()
def send_diff_image(self, diff):
if self.supports_binary:
self.write_message(diff, binary=True)
else:
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/qt4_editor/formlayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def get(self):
elif isinstance(value, bool):
value = field.checkState() == Qt.Checked
elif isinstance(value, float):
value = float(field.text())
value = float(str(field.text()))
elif isinstance(value, int):
value = int(field.value())
elif isinstance(value, datetime.datetime):
Expand Down
10 changes: 10 additions & 0 deletions lib/matplotlib/backends/web_backend/mpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ figure.prototype.finalize = function (canvas_id_prefix, toolbar_id_prefix, messa
onload_creator = function(fig) {return function() {fig.context.drawImage(fig.imageObj, 0, 0);};};
this.imageObj.onload = onload_creator(fig);


this.imageObj.onunload = function() {
this.ws.close();
}

this.ws.onmessage = gen_on_msg_fn(this);
};

Expand All @@ -88,11 +93,13 @@ function gen_on_msg_fn(fig)
}
fig.imageObj.src = (window.URL || window.webkitURL).createObjectURL(
evt.data);
fig.ws.send('{"type": "ack"}')
return;
}
} else {
if (evt.data.slice(0, 21) == "data:image/png;base64") {
fig.imageObj.src = evt.data;
fig.ws.send('{"type": "ack"}')
return;
}
}
Expand Down Expand Up @@ -132,6 +139,9 @@ function gen_on_msg_fn(fig)
fig.rubberband_canvas.width = size[0];
fig.rubberband_canvas.height = size[1];
fig.ws.send(JSON.stringify({type: 'refresh'}));
fig.ws.send(JSON.stringify(
{type: 'supports_binary',
value: fig.supports_binary}));
}
break;

Expand Down
90 changes: 45 additions & 45 deletions lib/matplotlib/mathtext.py
Original file line number Diff line number Diff line change
Expand Up @@ -2179,69 +2179,69 @@ def __init__(self):
if key != 'self':
val.setName(key)

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

lbrace << Literal('{').suppress()
rbrace << Literal('}').suppress()
lbracket << Literal('[').suppress()
rbracket << Literal(']').suppress()
bslash << Literal('\\')
lbrace <<= Literal('{').suppress()
rbrace <<= Literal('}').suppress()
lbracket <<= Literal('[').suppress()
rbracket <<= Literal(']').suppress()
bslash <<= Literal('\\')

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

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

apostrophe << Regex("'+")
apostrophe <<= Regex("'+")

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

accent << Group(
accent <<= Group(
Suppress(bslash)
+ oneOf(self._accent_map.keys() + list(self._wide_accents))
- placeable
)

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

start_group << Optional(latexfont) + lbrace
end_group << rbrace.copy()
simple_group << Group(lbrace + ZeroOrMore(token) + rbrace)
required_group<< Group(lbrace + OneOrMore(token) + rbrace)
group << Group(start_group + ZeroOrMore(token) + end_group)
start_group <<= Optional(latexfont) + lbrace
end_group <<= rbrace.copy()
simple_group <<= Group(lbrace + ZeroOrMore(token) + rbrace)
required_group<<= Group(lbrace + OneOrMore(token) + rbrace)
group <<= Group(start_group + ZeroOrMore(token) + end_group)

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

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

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

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

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

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

sqrt << Group(
sqrt <<= Group(
Suppress(Literal(r"\sqrt"))
- ((Optional(lbracket + int_literal + rbracket, default=None)
+ required_group)
| Error("Expected \sqrt{value}"))
)

overline << Group(
overline <<= Group(
Suppress(Literal(r"\overline"))
- (required_group | Error("Expected \overline{value}"))
)

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

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

placeable << ( accent # Must be first
placeable <<= ( accent # Must be first
| symbol # Must be second
| c_over_c
| function
Expand All @@ -2284,39 +2284,39 @@ def __init__(self):
| operatorname
)

simple << ( space
simple <<= ( space
| customspace
| font
| subsuper
)

subsuperop << oneOf(["_", "^"])
subsuperop <<= oneOf(["_", "^"])

subsuper << Group(
subsuper <<= Group(
(Optional(placeable) + OneOrMore(subsuperop - placeable) + Optional(apostrophe))
| (placeable + Optional(apostrophe))
| apostrophe
)

token << ( simple
token <<= ( simple
| auto_delim
| unknown_symbol # Must be last
)

auto_delim << (Suppress(Literal(r"\left"))
auto_delim <<= (Suppress(Literal(r"\left"))
- ((left_delim | ambi_delim) | Error("Expected a delimiter"))
+ Group(ZeroOrMore(simple | auto_delim))
+ Suppress(Literal(r"\right"))
- ((right_delim | ambi_delim) | Error("Expected a delimiter"))
)

math << OneOrMore(token)
math <<= OneOrMore(token)

math_string << QuotedString('$', '\\', unquoteResults=False)
math_string <<= QuotedString('$', '\\', unquoteResults=False)

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

main << (non_math + ZeroOrMore(math_string + non_math)) + StringEnd()
main <<= (non_math + ZeroOrMore(math_string + non_math)) + StringEnd()

# Set actions
for key, val in locals().items():
Expand Down
Loading

0 comments on commit 7e64adf

Please sign in to comment.