Skip to content

Doc typo #1267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4d97b2c
Checkable pan/zoom buttons for QT NavigationToolbar
Aug 27, 2012
70358ac
Allow imsave() to handle RGB(A) input arrays
WeatherGod Sep 9, 2012
22c4a19
Added a test for imsave
WeatherGod Sep 9, 2012
069526a
Enable dynamic updating for the OS X backend
dmcdougall Sep 11, 2012
ef9471a
Upping version on master to 1.3.x
mdboom Sep 12, 2012
284fc0c
Merge branch 'v1.2.x'
mdboom Sep 12, 2012
54cfed6
Fix mri_demo.py fails with mpl 1.2.0rc1
cgohlke Sep 12, 2012
5ee5223
Fix 2to3 and packaging of dateutil
cgohlke Sep 12, 2012
3e65956
Merge pull request #1234 from cgohlke/patch-2
mdboom Sep 12, 2012
6b6e476
Merge pull request #1232 from dmcdougall/mac_dynamic
mdboom Sep 12, 2012
84dd08a
Fix poly_editor.py on Python 3
cgohlke Sep 12, 2012
3dfd380
Merge pull request #1236 from cgohlke/patch-3
mdboom Sep 12, 2012
d1ce640
Fix matplotlib.testing.util.MiniExpect.expect hangs on Windows
cgohlke Sep 12, 2012
6f95056
backend_pgf: fix parsing of CR+LF newlines
Sep 12, 2012
5d73cfb
Merge pull request #1240 from pwuertz/pgf-backend
Sep 12, 2012
d434480
Merge pull request #1239 from cgohlke/patch-7
mdboom Sep 13, 2012
d804231
Merge pull request #1233 from cgohlke/patch-1
mdboom Sep 13, 2012
5b2a72a
Merge pull request #1224 from WeatherGod/imshow_alpha
mdboom Sep 13, 2012
d2a1346
Merge remote-tracking branch 'upstream/v1.2.x'
mdboom Sep 13, 2012
5864941
Merge pull request #1152 from ChrisBeaumont/checkable_navbar
pelson Sep 13, 2012
3c73aac
Merge remote-tracking branch 'upstream/v1.2.x'
mdboom Sep 14, 2012
62069bd
Update six.py to version 1.2
cgohlke Sep 16, 2012
1e72892
Merge pull request #1261 from cgohlke/patch-8
mdboom Sep 17, 2012
3e0c006
Fix typo in docstring
dmcdougall Sep 17, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
This is an object-orient plotting library.
This is an object-oriented plotting library.

A procedural interface is provided by the companion pyplot module,
which may be imported directly, e.g::
Expand Down Expand Up @@ -99,7 +99,7 @@
"""
from __future__ import print_function

__version__ = '1.2.0rc1'
__version__ = '1.3.x'
__version__numpy__ = '1.4' # minimum required numpy version

import os, re, shutil, subprocess, sys, warnings
Expand Down
18 changes: 18 additions & 0 deletions lib/matplotlib/backends/backend_qt4.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,9 @@ def __init__(self, canvas, parent, coordinates=True):
""" coordinates: should we show the coordinates on the right? """
self.canvas = canvas
self.coordinates = coordinates
self._actions = {}
"""A mapping of toolitem method names to their QActions"""

QtGui.QToolBar.__init__( self, parent )
NavigationToolbar2.__init__( self, canvas )

Expand All @@ -516,6 +519,9 @@ def _init_toolbar(self):
else:
a = self.addAction(self._icon(image_file + '.png'),
text, getattr(self, callback))
self._actions[callback] = a
if callback in ['zoom', 'pan']:
a.setCheckable(True)
if tooltip_text is not None:
a.setToolTip(tooltip_text)

Expand Down Expand Up @@ -574,6 +580,18 @@ def edit_parameters(self):

figureoptions.figure_edit(axes, self)

def _update_buttons_checked(self):
#sync button checkstates to match active mode
self._actions['pan'].setChecked(self._active == 'PAN')
self._actions['zoom'].setChecked(self._active == 'ZOOM')

def pan(self, *args):
super(NavigationToolbar2QT, self).pan(*args)
self._update_buttons_checked()

def zoom(self, *args):
super(NavigationToolbar2QT, self).zoom(*args)
self._update_buttons_checked()

def dynamic_update( self ):
self.canvas.draw()
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -1246,7 +1246,7 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None,
If *format* is *None* and *fname* is a string, the output
format is deduced from the extension of the filename.
*arr*:
A 2D array.
An MxN (luminance), MxNx3 (RGB) or MxNx4 (RGBA) array.
Keyword arguments:
*vmin*/*vmax*: [ None | scalar ]
*vmin* and *vmax* set the color scaling for the image by fixing the
Expand All @@ -1269,7 +1269,7 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None,
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure

figsize = [x / float(dpi) for x in arr.shape[::-1]]
figsize = [x / float(dpi) for x in (arr.shape[1], arr.shape[0])]
fig = Figure(figsize=figsize, dpi=dpi, frameon=False)
canvas = FigureCanvas(fig)
im = fig.figimage(arr, cmap=cmap, vmin=vmin, vmax=vmax, origin=origin)
Expand Down
20 changes: 20 additions & 0 deletions lib/matplotlib/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,26 @@ def test_imsave():

assert_array_equal(arr_dpi1, arr_dpi100)

def test_imsave_color_alpha():
# The goal is to test that imsave will accept arrays with ndim=3 where
# the third dimension is color and alpha without raising any exceptions
from numpy import random
random.seed(1)
data = random.rand(256, 128, 4)

buff = io.BytesIO()
plt.imsave(buff, data)

buff.seek(0)
arr_buf = plt.imread(buff)

assert arr_buf.shape == data.shape

# Unfortunately, the AGG process "flattens" the RGBA data
# into an equivalent RGB data with no transparency. So we
# Can't directly compare the arrays like we could in some
# other imsave tests.

@image_comparison(baseline_images=['image_clip'])
def test_image_clip():
from math import pi
Expand Down
51 changes: 32 additions & 19 deletions lib/six.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import types

__author__ = "Benjamin Peterson <benjamin@python.org>"
__version__ = "1.1.0-mpl"
__version__ = "1.2.0-mpl"


# True if we are running on Python 3.
Expand All @@ -26,19 +26,23 @@
text_type = unicode
binary_type = str

# It's possible to have sizeof(long) != sizeof(Py_ssize_t).
class X(object):
def __len__(self):
return 1 << 31
try:
len(X())
except OverflowError:
# 32-bit
if sys.platform == "java":
# Jython always uses 32 bits.
MAXSIZE = int((1 << 31) - 1)
else:
# 64-bit
MAXSIZE = int((1 << 63) - 1)
del X
# It's possible to have sizeof(long) != sizeof(Py_ssize_t).
class X(object):
def __len__(self):
return 1 << 31
try:
len(X())
except OverflowError:
# 32-bit
MAXSIZE = int((1 << 31) - 1)
else:
# 64-bit
MAXSIZE = int((1 << 63) - 1)
del X


def _add_doc(func, doc):
Expand Down Expand Up @@ -113,6 +117,7 @@ class _MovedItems(types.ModuleType):
_moved_attributes = [
MovedAttribute("cStringIO", "cStringIO", "io", "StringIO"),
MovedAttribute("filter", "itertools", "builtins", "ifilter", "filter"),
MovedAttribute("input", "__builtin__", "builtins", "raw_input", "input"),
MovedAttribute("map", "itertools", "builtins", "imap", "map"),
MovedAttribute("reload_module", "__builtin__", "imp", "reload"),
MovedAttribute("reduce", "__builtin__", "functools"),
Expand Down Expand Up @@ -200,22 +205,30 @@ def remove_move(name):
_iteritems = "iteritems"


try:
advance_iterator = next
except NameError:
def advance_iterator(it):
return it.next()
next = advance_iterator


if PY3:
def get_unbound_function(unbound):
return unbound


advance_iterator = next
Iterator = object

def callable(obj):
return any("__call__" in klass.__dict__ for klass in type(obj).__mro__)
else:
def get_unbound_function(unbound):
return unbound.im_func

class Iterator(object):

def advance_iterator(it):
return it.next()
def next(self):
return type(self).__next__(self)

callable = callable
_add_doc(get_unbound_function,
Expand All @@ -230,15 +243,15 @@ def advance_iterator(it):

def iterkeys(d):
"""Return an iterator over the keys of a dictionary."""
return getattr(d, _iterkeys)()
return iter(getattr(d, _iterkeys)())

def itervalues(d):
"""Return an iterator over the values of a dictionary."""
return getattr(d, _itervalues)()
return iter(getattr(d, _itervalues)())

def iteritems(d):
"""Return an iterator over the (key, value) pairs of a dictionary."""
return getattr(d, _iteritems)()
return iter(getattr(d, _iteritems)())


if PY3:
Expand Down