SourceForge logo
SourceForge logo
Menu

matplotlib-checkins — Commit notification. DO NOT POST to this list, just subscribe to it.

You can subscribe to this list here.

2007 Jan
Feb
Mar
Apr
May
Jun
Jul
(115)
Aug
(120)
Sep
(137)
Oct
(170)
Nov
(461)
Dec
(263)
2008 Jan
(120)
Feb
(74)
Mar
(35)
Apr
(74)
May
(245)
Jun
(356)
Jul
(240)
Aug
(115)
Sep
(78)
Oct
(225)
Nov
(98)
Dec
(271)
2009 Jan
(132)
Feb
(84)
Mar
(74)
Apr
(56)
May
(90)
Jun
(79)
Jul
(83)
Aug
(296)
Sep
(214)
Oct
(76)
Nov
(82)
Dec
(66)
2010 Jan
(46)
Feb
(58)
Mar
(51)
Apr
(77)
May
(58)
Jun
(126)
Jul
(128)
Aug
(64)
Sep
(50)
Oct
(44)
Nov
(48)
Dec
(54)
2011 Jan
(68)
Feb
(52)
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
(1)
2018 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S


1
(10)
2
(6)
3
4
(10)
5
(5)
6
(5)
7
(6)
8
(2)
9
(5)
10
(7)
11
(5)
12
(8)
13
(5)
14
(7)
15
(3)
16
(1)
17
(1)
18
19
(1)
20
(6)
21
(6)
22
(3)
23
(3)
24
(7)
25
26
(5)
27
(1)
28
(3)
29
(2)
30
(3)



Showing 5 results of 5

From: <ef...@us...> - 2010年06月06日 22:44:24
Revision: 8390
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8390&view=rev
Author: efiring
Date: 2010年06月06日 22:44:18 +0000 (2010年6月06日)
Log Message:
-----------
[2841525] wx backend: fix classic toolbar; Figure.clf: add kwarg to keep axobservers
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
 trunk/matplotlib/lib/matplotlib/figure.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py	2010年06月06日 20:52:36 UTC (rev 8389)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py	2010年06月06日 22:44:18 UTC (rev 8390)
@@ -861,7 +861,7 @@
 simply asks for image width and margin for printing. """
 
 dmsg = """Width of output figure in inches.
-The current aspect ration will be kept."""
+The current aspect ratio will be kept."""
 
 dlg = wx.Dialog(self, -1, 'Page Setup for Printing' , (-1,-1))
 df = dlg.GetFont()
@@ -1546,8 +1546,11 @@
 return self.toolbar
 
 def Destroy(self, *args, **kwargs):
- self.canvas.mpl_disconnect(self.toolbar._idDrag)
- # Rationale for line above: see issue 2941338.
+ try:
+ self.canvas.mpl_disconnect(self.toolbar._idDrag)
+ # Rationale for line above: see issue 2941338.
+ except AttributeError:
+ pass # classic toolbar lacks the attribute
 wx.Frame.Destroy(self, *args, **kwargs)
 if self.toolbar is not None:
 self.toolbar.Destroy()
@@ -1707,6 +1710,8 @@
 else:
 new = True
 self._menu.Check(evt.GetId(), new)
+ # Lines above would be deleted based on svn tracker ID 2841525;
+ # not clear whether this matters or not.
 self._toolbar.set_active(self.getActiveAxes())
 evt.Skip()
 
@@ -1720,7 +1725,11 @@
 self._menu.Append(menuId, "Axis %d" % i, "Select axis %d" % i, True)
 self._menu.Check(menuId, True)
 bind(self, wx.EVT_MENU, self._onMenuItemSelected, id=menuId)
- self._toolbar.set_active(range(len(self._axisId)))
+ elif maxAxis < len(self._axisId):
+ for menuId in self._axisId[maxAxis:]:
+ self._menu.Delete(menuId)
+ self._axisId = self._axisId[:maxAxis]
+ self._toolbar.set_active(range(maxAxis))
 
 def getActiveAxes(self):
 """Return a list of the selected axes."""
@@ -2080,7 +2089,8 @@
 
 def update(self):
 """
- Update the toolbar menu - called when (e.g.) a new subplot or axes are added
+ Update the toolbar menu - called when (e.g.) a new subplot
+ or axes are added
 """
 DEBUG_MSG("update()", 1, self)
 self._axes = self.canvas.figure.get_axes()
Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py	2010年06月06日 20:52:36 UTC (rev 8389)
+++ trunk/matplotlib/lib/matplotlib/figure.py	2010年06月06日 22:44:18 UTC (rev 8390)
@@ -691,9 +691,12 @@
 self.sca(a)
 return a
 
- def clf(self):
+ def clf(self, keep_observers=False):
 """
- Clear the figure
+ Clear the figure.
+
+ Set *keep_observers* to True if, for example,
+ a gui widget is tracking the axes in the figure.
 """
 self.suppressComposite = None
 self.callbacks = cbook.CallbackRegistry(('dpi_changed', ))
@@ -713,7 +716,8 @@
 self.texts=[]
 self.images = []
 self.legends = []
- self._axobservers = []
+ if not keep_observers:
+ self._axobservers = []
 
 def clear(self):
 """
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2010年06月06日 20:52:44
Revision: 8389
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8389&view=rev
Author: efiring
Date: 2010年06月06日 20:52:36 +0000 (2010年6月06日)
Log Message:
-----------
[3009273] update pytz to 2010h
Modified Paths:
--------------
 trunk/matplotlib/lib/pytz/__init__.py
 trunk/matplotlib/lib/pytz/tzfile.py
 trunk/matplotlib/lib/pytz/tzinfo.py
 trunk/matplotlib/lib/pytz/zoneinfo/Africa/Cairo
 trunk/matplotlib/lib/pytz/zoneinfo/Africa/Casablanca
 trunk/matplotlib/lib/pytz/zoneinfo/Africa/Tunis
 trunk/matplotlib/lib/pytz/zoneinfo/America/Argentina/Buenos_Aires
 trunk/matplotlib/lib/pytz/zoneinfo/America/Argentina/Catamarca
 trunk/matplotlib/lib/pytz/zoneinfo/America/Argentina/ComodRivadavia
 trunk/matplotlib/lib/pytz/zoneinfo/America/Argentina/Cordoba
 trunk/matplotlib/lib/pytz/zoneinfo/America/Argentina/Jujuy
 trunk/matplotlib/lib/pytz/zoneinfo/America/Argentina/La_Rioja
 trunk/matplotlib/lib/pytz/zoneinfo/America/Argentina/Mendoza
 trunk/matplotlib/lib/pytz/zoneinfo/America/Argentina/Rio_Gallegos
 trunk/matplotlib/lib/pytz/zoneinfo/America/Argentina/San_Juan
 trunk/matplotlib/lib/pytz/zoneinfo/America/Argentina/San_Luis
 trunk/matplotlib/lib/pytz/zoneinfo/America/Argentina/Tucuman
 trunk/matplotlib/lib/pytz/zoneinfo/America/Argentina/Ushuaia
 trunk/matplotlib/lib/pytz/zoneinfo/America/Asuncion
 trunk/matplotlib/lib/pytz/zoneinfo/America/Buenos_Aires
 trunk/matplotlib/lib/pytz/zoneinfo/America/Campo_Grande
 trunk/matplotlib/lib/pytz/zoneinfo/America/Catamarca
 trunk/matplotlib/lib/pytz/zoneinfo/America/Cordoba
 trunk/matplotlib/lib/pytz/zoneinfo/America/Cuiaba
 trunk/matplotlib/lib/pytz/zoneinfo/America/Eirunepe
 trunk/matplotlib/lib/pytz/zoneinfo/America/Ensenada
 trunk/matplotlib/lib/pytz/zoneinfo/America/Havana
 trunk/matplotlib/lib/pytz/zoneinfo/America/Jujuy
 trunk/matplotlib/lib/pytz/zoneinfo/America/Mendoza
 trunk/matplotlib/lib/pytz/zoneinfo/America/Porto_Acre
 trunk/matplotlib/lib/pytz/zoneinfo/America/Resolute
 trunk/matplotlib/lib/pytz/zoneinfo/America/Rio_Branco
 trunk/matplotlib/lib/pytz/zoneinfo/America/Rosario
 trunk/matplotlib/lib/pytz/zoneinfo/America/Santiago
 trunk/matplotlib/lib/pytz/zoneinfo/America/Sao_Paulo
 trunk/matplotlib/lib/pytz/zoneinfo/America/Tijuana
 trunk/matplotlib/lib/pytz/zoneinfo/Antarctica/Casey
 trunk/matplotlib/lib/pytz/zoneinfo/Antarctica/Davis
 trunk/matplotlib/lib/pytz/zoneinfo/Antarctica/Mawson
 trunk/matplotlib/lib/pytz/zoneinfo/Asia/Amman
 trunk/matplotlib/lib/pytz/zoneinfo/Asia/Anadyr
 trunk/matplotlib/lib/pytz/zoneinfo/Asia/Dacca
 trunk/matplotlib/lib/pytz/zoneinfo/Asia/Damascus
 trunk/matplotlib/lib/pytz/zoneinfo/Asia/Dhaka
 trunk/matplotlib/lib/pytz/zoneinfo/Asia/Gaza
 trunk/matplotlib/lib/pytz/zoneinfo/Asia/Hong_Kong
 trunk/matplotlib/lib/pytz/zoneinfo/Asia/Kamchatka
 trunk/matplotlib/lib/pytz/zoneinfo/Asia/Karachi
 trunk/matplotlib/lib/pytz/zoneinfo/Brazil/Acre
 trunk/matplotlib/lib/pytz/zoneinfo/Brazil/East
 trunk/matplotlib/lib/pytz/zoneinfo/CET
 trunk/matplotlib/lib/pytz/zoneinfo/Chile/Continental
 trunk/matplotlib/lib/pytz/zoneinfo/Chile/EasterIsland
 trunk/matplotlib/lib/pytz/zoneinfo/Cuba
 trunk/matplotlib/lib/pytz/zoneinfo/Egypt
 trunk/matplotlib/lib/pytz/zoneinfo/Europe/Belgrade
 trunk/matplotlib/lib/pytz/zoneinfo/Europe/Berlin
 trunk/matplotlib/lib/pytz/zoneinfo/Europe/Budapest
 trunk/matplotlib/lib/pytz/zoneinfo/Europe/Ljubljana
 trunk/matplotlib/lib/pytz/zoneinfo/Europe/Podgorica
 trunk/matplotlib/lib/pytz/zoneinfo/Europe/Samara
 trunk/matplotlib/lib/pytz/zoneinfo/Europe/Sarajevo
 trunk/matplotlib/lib/pytz/zoneinfo/Europe/Skopje
 trunk/matplotlib/lib/pytz/zoneinfo/Europe/Sofia
 trunk/matplotlib/lib/pytz/zoneinfo/Europe/Zagreb
 trunk/matplotlib/lib/pytz/zoneinfo/Europe/Zurich
 trunk/matplotlib/lib/pytz/zoneinfo/Hongkong
 trunk/matplotlib/lib/pytz/zoneinfo/Indian/Mauritius
 trunk/matplotlib/lib/pytz/zoneinfo/MET
 trunk/matplotlib/lib/pytz/zoneinfo/Mexico/BajaNorte
 trunk/matplotlib/lib/pytz/zoneinfo/Pacific/Apia
 trunk/matplotlib/lib/pytz/zoneinfo/Pacific/Easter
 trunk/matplotlib/lib/pytz/zoneinfo/Pacific/Fiji
 trunk/matplotlib/lib/pytz/zoneinfo/iso3166.tab
 trunk/matplotlib/lib/pytz/zoneinfo/zone.tab
Added Paths:
-----------
 trunk/matplotlib/lib/pytz/CHANGES.txt
 trunk/matplotlib/lib/pytz/LICENSE.txt
 trunk/matplotlib/lib/pytz/README.txt
 trunk/matplotlib/lib/pytz/tests/
 trunk/matplotlib/lib/pytz/tests/test_docs.py
 trunk/matplotlib/lib/pytz/tests/test_tzinfo.py
 trunk/matplotlib/lib/pytz/zoneinfo/America/Argentina/Salta
 trunk/matplotlib/lib/pytz/zoneinfo/America/Matamoros
 trunk/matplotlib/lib/pytz/zoneinfo/America/Ojinaga
 trunk/matplotlib/lib/pytz/zoneinfo/America/Santa_Isabel
 trunk/matplotlib/lib/pytz/zoneinfo/America/Santarem
Added: trunk/matplotlib/lib/pytz/CHANGES.txt
===================================================================
--- trunk/matplotlib/lib/pytz/CHANGES.txt	 (rev 0)
+++ trunk/matplotlib/lib/pytz/CHANGES.txt	2010年06月06日 20:52:36 UTC (rev 8389)
@@ -0,0 +1,50 @@
+2004年07月25日
+ 
+ - Improved localtime handling, and added a localize() method enabling
+ correct creation of local times.
+
+2005年02月16日
+
+ - Made available under the Zope Public Licence 2.1 (ZPL) and checked
+ into the Zope3 project. pytz may now be used and redistributed
+ under either the original MIT license or the ZPL 2.1.
+
+2005年05月13日
+
+ - Move UTC into the top level pytz module and provide special
+ case pickle support for this singleton.
+
+2005年08月14日
+
+ - Ensure all tzinfo instances are efficiently picklable.
+
+2005年12月31日
+
+ - Add fixed offset timezone classes required by Zope 3
+ - Generate and distribute a PO template file listing all timezone
+ names. Translations are not yet available.
+
+2007年03月03日
+
+ - Import work by James Henstridge, making pytz load timezone
+ information from zic compiled binaries at runtime rather than
+ processing them into Python classes.
+
+2007年03月26日
+
+ - Update database to version 2007d
+ - Fix windows incompatibilities, working around limitations on that
+ platform.
+ - Fix 2.3 incompatibilities. Installation now requires distutils.
+ - Passing an invalid timezone name to timezone() now raises an
+ UnknownTimezoneError, which is a KeyError subclass for backwards
+ compatibility.
+
+2007年03月27日
+
+ - Ensure API can accept Unicode strings (Bug #96957)
+
+2009年09月29日
+
+ - Fix test_zdump tests and bugs the fixed tests picked up, including
+ the fix for Bug #427444.
Added: trunk/matplotlib/lib/pytz/LICENSE.txt
===================================================================
--- trunk/matplotlib/lib/pytz/LICENSE.txt	 (rev 0)
+++ trunk/matplotlib/lib/pytz/LICENSE.txt	2010年06月06日 20:52:36 UTC (rev 8389)
@@ -0,0 +1,19 @@
+Copyright (c) 2003-2009 Stuart Bishop <st...@st...>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
Added: trunk/matplotlib/lib/pytz/README.txt
===================================================================
--- trunk/matplotlib/lib/pytz/README.txt	 (rev 0)
+++ trunk/matplotlib/lib/pytz/README.txt	2010年06月06日 20:52:36 UTC (rev 8389)
@@ -0,0 +1,543 @@
+pytz - World Timezone Definitions for Python
+============================================
+
+:Author: Stuart Bishop <st...@st...>
+
+Introduction
+~~~~~~~~~~~~
+
+pytz brings the Olson tz database into Python. This library allows
+accurate and cross platform timezone calculations using Python 2.3
+or higher. It also solves the issue of ambiguous times at the end
+of daylight savings, which you can read more about in the Python
+Library Reference (``datetime.tzinfo``).
+
+Amost all of the Olson timezones are supported.
+
+Note that this library differs from the documented Python API for
+tzinfo implementations; if you want to create local wallclock
+times you need to use the ``localize()`` method documented in this
+document. In addition, if you perform date arithmetic on local
+times that cross DST boundaries, the results may be in an incorrect
+timezone (ie. subtract 1 minute from 2002年10月27日 1:00 EST and you get
+2002年10月27日 0:59 EST instead of the correct 2002年10月27日 1:59 EDT). A
+``normalize()`` method is provided to correct this. Unfortunatly these
+issues cannot be resolved without modifying the Python datetime
+implementation.
+
+
+Installation
+~~~~~~~~~~~~
+
+This package can either be installed from a .egg file using setuptools,
+or from the tarball using the standard Python distutils.
+
+If you are installing from a tarball, run the following command as an
+administrative user::
+
+ python setup.py install
+
+If you are installing using setuptools, you don't even need to download
+anything as the latest version will be downloaded for you
+from the Python package index::
+
+ easy_install --upgrade pytz
+
+If you already have the .egg file, you can use that too::
+
+ easy_install pytz-2008g-py2.6.egg
+
+
+Example & Usage
+~~~~~~~~~~~~~~~
+
+Localized times and date arithmetic
+-----------------------------------
+
+>>> from datetime import datetime, timedelta
+>>> from pytz import timezone
+>>> import pytz
+>>> utc = pytz.utc
+>>> utc.zone
+'UTC'
+>>> eastern = timezone('US/Eastern')
+>>> eastern.zone
+'US/Eastern'
+>>> amsterdam = timezone('Europe/Amsterdam')
+>>> fmt = '%Y-%m-%d %H:%M:%S %Z%z'
+
+This library only supports two ways of building a localized time. The
+first is to use the ``localize()`` method provided by the pytz library.
+This is used to localize a naive datetime (datetime with no timezone
+information):
+
+>>> loc_dt = eastern.localize(datetime(2002, 10, 27, 6, 0, 0))
+>>> print loc_dt.strftime(fmt)
+2002年10月27日 06:00:00 EST-0500
+
+The second way of building a localized time is by converting an existing
+localized time using the standard ``astimezone()`` method:
+
+>>> ams_dt = loc_dt.astimezone(amsterdam)
+>>> ams_dt.strftime(fmt)
+'2002-10-27 12:00:00 CET+0100'
+
+Unfortunately using the tzinfo argument of the standard datetime
+constructors ''does not work'' with pytz for many timezones.
+
+>>> datetime(2002, 10, 27, 12, 0, 0, tzinfo=amsterdam).strftime(fmt)
+'2002-10-27 12:00:00 AMT+0020'
+
+It is safe for timezones without daylight savings trasitions though, such
+as UTC:
+
+>>> datetime(2002, 10, 27, 12, 0, 0, tzinfo=pytz.utc).strftime(fmt)
+'2002-10-27 12:00:00 UTC+0000'
+
+The preferred way of dealing with times is to always work in UTC,
+converting to localtime only when generating output to be read
+by humans.
+
+>>> utc_dt = datetime(2002, 10, 27, 6, 0, 0, tzinfo=utc)
+>>> loc_dt = utc_dt.astimezone(eastern)
+>>> loc_dt.strftime(fmt)
+'2002-10-27 01:00:00 EST-0500'
+
+This library also allows you to do date arithmetic using local
+times, although it is more complicated than working in UTC as you
+need to use the ``normalize()`` method to handle daylight savings time
+and other timezone transitions. In this example, ``loc_dt`` is set
+to the instant when daylight savings time ends in the US/Eastern
+timezone.
+
+>>> before = loc_dt - timedelta(minutes=10)
+>>> before.strftime(fmt)
+'2002-10-27 00:50:00 EST-0500'
+>>> eastern.normalize(before).strftime(fmt)
+'2002-10-27 01:50:00 EDT-0400'
+>>> after = eastern.normalize(before + timedelta(minutes=20))
+>>> after.strftime(fmt)
+'2002-10-27 01:10:00 EST-0500'
+
+Creating localtimes is also tricky, and the reason why working with
+local times is not recommended. Unfortunately, you cannot just pass
+a ``tzinfo`` argument when constructing a datetime (see the next
+section for more details)
+
+>>> dt = datetime(2002, 10, 27, 1, 30, 0)
+>>> dt1 = eastern.localize(dt, is_dst=True)
+>>> dt1.strftime(fmt)
+'2002-10-27 01:30:00 EDT-0400'
+>>> dt2 = eastern.localize(dt, is_dst=False)
+>>> dt2.strftime(fmt)
+'2002-10-27 01:30:00 EST-0500'
+
+Converting between timezones also needs special attention. This also
+needs to use the ``normalize()`` method to ensure the conversion is
+correct.
+
+>>> utc_dt = utc.localize(datetime.utcfromtimestamp(1143408899))
+>>> utc_dt.strftime(fmt)
+'2006-03-26 21:34:59 UTC+0000'
+>>> au_tz = timezone('Australia/Sydney')
+>>> au_dt = au_tz.normalize(utc_dt.astimezone(au_tz))
+>>> au_dt.strftime(fmt)
+'2006-03-27 08:34:59 EST+1100'
+>>> utc_dt2 = utc.normalize(au_dt.astimezone(utc))
+>>> utc_dt2.strftime(fmt)
+'2006-03-26 21:34:59 UTC+0000'
+
+You can take shortcuts when dealing with the UTC side of timezone
+conversions. ``normalize()`` and ``localize()`` are not really
+necessary when there are no daylight savings time transitions to
+deal with.
+
+>>> utc_dt = datetime.utcfromtimestamp(1143408899).replace(tzinfo=utc)
+>>> utc_dt.strftime(fmt)
+'2006-03-26 21:34:59 UTC+0000'
+>>> au_tz = timezone('Australia/Sydney')
+>>> au_dt = au_tz.normalize(utc_dt.astimezone(au_tz))
+>>> au_dt.strftime(fmt)
+'2006-03-27 08:34:59 EST+1100'
+>>> utc_dt2 = au_dt.astimezone(utc)
+>>> utc_dt2.strftime(fmt)
+'2006-03-26 21:34:59 UTC+0000'
+
+
+``tzinfo`` API
+--------------
+
+The ``tzinfo`` instances returned by the ``timezone()`` function have
+been extended to cope with ambiguous times by adding an ``is_dst``
+parameter to the ``utcoffset()``, ``dst()`` && ``tzname()`` methods.
+
+>>> tz = timezone('America/St_Johns')
+
+>>> normal = datetime(2009, 9, 1)
+>>> ambiguous = datetime(2009, 10, 31, 23, 30)
+
+the ``is_dst`` parameter is ignormed for most timestamps, but
+is used to resolve the ambiguity during ambiguous periods caused
+to DST transitions.
+
+>>> tz.utcoffset(normal, is_dst=True)
+datetime.timedelta(-1, 77400)
+>>> tz.dst(normal, is_dst=True)
+datetime.timedelta(0, 3600)
+>>> tz.tzname(normal, is_dst=True)
+'NDT'
+
+>>> tz.utcoffset(ambiguous, is_dst=True)
+datetime.timedelta(-1, 77400)
+>>> tz.dst(ambiguous, is_dst=True)
+datetime.timedelta(0, 3600)
+>>> tz.tzname(ambiguous, is_dst=True)
+'NDT'
+
+>>> tz.utcoffset(normal, is_dst=False)
+datetime.timedelta(-1, 77400)
+>>> tz.dst(normal, is_dst=False)
+datetime.timedelta(0, 3600)
+>>> tz.tzname(normal, is_dst=False)
+'NDT'
+
+>>> tz.utcoffset(ambiguous, is_dst=False)
+datetime.timedelta(-1, 73800)
+>>> tz.dst(ambiguous, is_dst=False)
+datetime.timedelta(0)
+>>> tz.tzname(ambiguous, is_dst=False)
+'NST'
+
+If ``is_dst`` is not specified, ambiguous timestamps will raise
+an ``AmbiguousTimeError`` exception.
+
+>>> tz.utcoffset(normal)
+datetime.timedelta(-1, 77400)
+>>> tz.dst(normal)
+datetime.timedelta(0, 3600)
+>>> tz.tzname(normal)
+'NDT'
+
+>>> tz.utcoffset(ambiguous)
+Traceback (most recent call last):
+[...]
+AmbiguousTimeError: 2009年10月31日 23:30:00
+>>> tz.dst(ambiguous)
+Traceback (most recent call last):
+[...]
+AmbiguousTimeError: 2009年10月31日 23:30:00
+>>> tz.tzname(ambiguous)
+Traceback (most recent call last):
+[...]
+AmbiguousTimeError: 2009年10月31日 23:30:00
+
+
+Problems with Localtime
+~~~~~~~~~~~~~~~~~~~~~~~
+
+The major problem we have to deal with is that certain datetimes
+may occur twice in a year. For example, in the US/Eastern timezone
+on the last Sunday morning in October, the following sequence
+happens:
+
+ - 01:00 EDT occurs
+ - 1 hour later, instead of 2:00am the clock is turned back 1 hour
+ and 01:00 happens again (this time 01:00 EST)
+
+In fact, every instant between 01:00 and 02:00 occurs twice. This means
+that if you try and create a time in the 'US/Eastern' timezone using
+the standard datetime syntax, there is no way to specify if you meant
+before of after the end-of-daylight-savings-time transition.
+
+>>> loc_dt = datetime(2002, 10, 27, 1, 30, 00, tzinfo=eastern)
+>>> loc_dt.strftime(fmt)
+'2002-10-27 01:30:00 EST-0500'
+
+As you can see, the system has chosen one for you and there is a 50%
+chance of it being out by one hour. For some applications, this does
+not matter. However, if you are trying to schedule meetings with people
+in different timezones or analyze log files it is not acceptable. 
+
+The best and simplest solution is to stick with using UTC. The pytz
+package encourages using UTC for internal timezone representation by
+including a special UTC implementation based on the standard Python
+reference implementation in the Python documentation. This timezone
+unpickles to be the same instance, and pickles to a relatively small
+size. The UTC implementation can be obtained as pytz.utc, pytz.UTC,
+or pytz.timezone('UTC').
+
+>>> import pickle, pytz
+>>> dt = datetime(2005, 3, 1, 14, 13, 21, tzinfo=utc)
+>>> naive = dt.replace(tzinfo=None)
+>>> p = pickle.dumps(dt, 1)
+>>> naive_p = pickle.dumps(naive, 1)
+>>> len(p), len(naive_p), len(p) - len(naive_p)
+(60, 43, 17)
+>>> new = pickle.loads(p)
+>>> new == dt
+True
+>>> new is dt
+False
+>>> new.tzinfo is dt.tzinfo
+True
+>>> pytz.utc is pytz.UTC is pytz.timezone('UTC')
+True
+
+Note that this instance is not the same instance (or implementation) as
+other timezones with the same meaning (GMT, Greenwich, Universal, etc.).
+
+>>> utc is pytz.timezone('GMT')
+False
+
+If you insist on working with local times, this library provides a
+facility for constructing them unambiguously:
+
+>>> loc_dt = datetime(2002, 10, 27, 1, 30, 00)
+>>> est_dt = eastern.localize(loc_dt, is_dst=True)
+>>> edt_dt = eastern.localize(loc_dt, is_dst=False)
+>>> print est_dt.strftime(fmt), '/', edt_dt.strftime(fmt)
+2002年10月27日 01:30:00 EDT-0400 / 2002年10月27日 01:30:00 EST-0500
+
+If you pass None as the is_dst flag to localize(), pytz will refuse to
+guess and raise exceptions if you try to build ambiguous or non-existent
+times.
+
+For example, 1:30am on 27th Oct 2002 happened twice in the US/Eastern
+timezone when the clocks where put back at the end of Daylight Savings
+Time:
+
+>>> eastern.localize(datetime(2002, 10, 27, 1, 30, 00), is_dst=None)
+Traceback (most recent call last):
+...
+AmbiguousTimeError: 2002年10月27日 01:30:00
+
+Similarly, 2:30am on 7th April 2002 never happened at all in the
+US/Eastern timezone, as the clocks where put forward at 2:00am skipping
+the entire hour:
+
+>>> eastern.localize(datetime(2002, 4, 7, 2, 30, 00), is_dst=None)
+Traceback (most recent call last):
+...
+NonExistentTimeError: 2002年04月07日 02:30:00
+
+Both of these exceptions share a common base class to make error handling
+easier:
+
+>>> isinstance(pytz.AmbiguousTimeError(), pytz.InvalidTimeError)
+True
+>>> isinstance(pytz.NonExistentTimeError(), pytz.InvalidTimeError)
+True
+
+Although ``localize()`` handles many cases, it is still not possible
+to handle all. In cases where countries change their timezone definitions,
+cases like the end-of-daylight-savings-time occur with no way of resolving
+the ambiguity. For example, in 1915 Warsaw switched from Warsaw time to
+Central European time. So at the stroke of midnight on August 5th 1915
+the clocks were wound back 24 minutes creating an ambiguous time period
+that cannot be specified without referring to the timezone abbreviation
+or the actual UTC offset. In this case midnight happened twice, neither
+time during a daylight savings time period:
+
+>>> warsaw = pytz.timezone('Europe/Warsaw')
+>>> loc_dt1 = warsaw.localize(datetime(1915, 8, 4, 23, 59, 59), is_dst=False)
+>>> loc_dt1.strftime(fmt)
+'1915-08-04 23:59:59 WMT+0124'
+>>> loc_dt2 = warsaw.localize(datetime(1915, 8, 5, 00, 00, 00), is_dst=False)
+>>> loc_dt2.strftime(fmt)
+'1915-08-05 00:00:00 CET+0100'
+>>> str(loc_dt2 - loc_dt1)
+'0:24:01'
+
+The only way of creating a time during the missing 24 minutes is
+converting from another timezone - because neither of the timezones
+involved where in daylight savings mode the API simply provides no way
+to express it:
+
+>>> utc_dt = datetime(1915, 8, 4, 22, 36, tzinfo=pytz.utc)
+>>> utc_dt.astimezone(warsaw).strftime(fmt)
+'1915-08-04 23:36:00 CET+0100'
+
+The standard Python way of handling all these ambiguities is not to
+handle them, such as demonstrated in this example using the US/Eastern
+timezone definition from the Python documentation (Note that this
+implementation only works for dates between 1987 and 2006 - it is
+included for tests only!):
+
+>>> from pytz.reference import Eastern # pytz.reference only for tests
+>>> dt = datetime(2002, 10, 27, 0, 30, tzinfo=Eastern)
+>>> str(dt)
+'2002-10-27 00:30:00-04:00'
+>>> str(dt + timedelta(hours=1))
+'2002-10-27 01:30:00-05:00'
+>>> str(dt + timedelta(hours=2))
+'2002-10-27 02:30:00-05:00'
+>>> str(dt + timedelta(hours=3))
+'2002-10-27 03:30:00-05:00'
+
+Notice the first two results? At first glance you might think they are
+correct, but taking the UTC offset into account you find that they are
+actually two hours appart instead of the 1 hour we asked for.
+
+>>> from pytz.reference import UTC # pytz.reference only for tests
+>>> str(dt.astimezone(UTC))
+'2002-10-27 04:30:00+00:00'
+>>> str((dt + timedelta(hours=1)).astimezone(UTC))
+'2002-10-27 06:30:00+00:00'
+
+
+Country Information
+~~~~~~~~~~~~~~~~~~~
+
+A mechanism is provided to access the timezones commonly in use
+for a particular country, looked up using the ISO 3166 country code.
+It returns a list of strings that can be used to retrieve the relevant
+tzinfo instance using ``pytz.timezone()``:
+
+>>> pytz.country_timezones['nz']
+['Pacific/Auckland', 'Pacific/Chatham']
+
+The Olson database comes with a ISO 3166 country code to English country
+name mapping that pytz exposes as a dictionary:
+
+>>> pytz.country_names['nz']
+'New Zealand'
+
+
+What is UTC
+~~~~~~~~~~~
+
+'UTC' is Universal Time, also known as Greenwich Mean Time or GMT
+in the United Kingdom. All other timezones are given as offsets from
+UTC. No daylight savings time occurs in UTC, making it a useful timezone
+to perform date arithmetic without worrying about the confusion and
+ambiguities caused by daylight savings time transitions, your country
+changing its timezone, or mobile computers that move roam through
+multiple timezones.
+
+
+Helpers
+~~~~~~~
+
+There are two lists of timezones provided.
+
+``all_timezones`` is the exhaustive list of the timezone names that can
+be used.
+
+>>> from pytz import all_timezones
+>>> len(all_timezones) >= 500
+True
+>>> 'Etc/Greenwich' in all_timezones
+True
+
+``common_timezones`` is a list of useful, current timezones. It doesn't
+contain deprecated zones or historical zones, except for a few I've
+deemed in common usage, such as US/Eastern (open a bug report if you
+think other timezones are deserving of being included here). It is also
+a sequence of strings.
+
+>>> from pytz import common_timezones
+>>> len(common_timezones) < len(all_timezones)
+True
+>>> 'Etc/Greenwich' in common_timezones
+False
+>>> 'Australia/Melbourne' in common_timezones
+True
+>>> 'US/Eastern' in common_timezones
+True
+>>> 'Canada/Eastern' in common_timezones
+True
+>>> 'US/Pacific-New' in all_timezones
+True
+>>> 'US/Pacific-New' in common_timezones
+False
+
+Both ``common_timezones`` and ``all_timezones`` are alphabetically
+sorted:
+
+>>> common_timezones_dupe = common_timezones[:]
+>>> common_timezones_dupe.sort()
+>>> common_timezones == common_timezones_dupe
+True
+>>> all_timezones_dupe = all_timezones[:]
+>>> all_timezones_dupe.sort()
+>>> all_timezones == all_timezones_dupe
+True
+
+``all_timezones`` and ``common_timezones`` are also available as sets.
+
+>>> from pytz import all_timezones_set, common_timezones_set
+>>> 'US/Eastern' in all_timezones_set
+True
+>>> 'US/Eastern' in common_timezones_set
+True
+>>> 'Australia/Victoria' in common_timezones_set
+False
+
+You can also retrieve lists of timezones used by particular countries
+using the ``country_timezones()`` function. It requires an ISO-3166
+two letter country code.
+
+>>> from pytz import country_timezones
+>>> country_timezones('ch')
+['Europe/Zurich']
+>>> country_timezones('CH')
+['Europe/Zurich']
+
+
+License
+~~~~~~~
+
+MIT license.
+
+This code is also available as part of Zope 3 under the Zope Public
+License, Version 2.1 (ZPL).
+
+I'm happy to relicense this code if necessary for inclusion in other
+open source projects.
+
+
+Latest Versions
+~~~~~~~~~~~~~~~
+
+This package will be updated after releases of the Olson timezone
+database. The latest version can be downloaded from the `Python Package
+Index <http://pypi.python.org/pypi/pytz/>`_. The code that is used
+to generate this distribution is hosted on launchpad.net and available
+using the `Bazaar version control system <http://bazaar-vcs.org>`_
+using::
+
+ bzr branch lp:pytz
+
+
+Bugs, Feature Requests & Patches
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Bugs can be reported using `Launchpad <https://bugs.launchpad.net/pytz>`_.
+
+
+Issues & Limitations
+~~~~~~~~~~~~~~~~~~~~
+
+- Offsets from UTC are rounded to the nearest whole minute, so timezones
+ such as Europe/Amsterdam pre 1937 will be up to 30 seconds out. This
+ is a limitation of the Python datetime library.
+
+- If you think a timezone definition is incorrect, I probably can't fix
+ it. pytz is a direct translation of the Olson timezone database, and
+ changes to the timezone definitions need to be made to this source.
+ If you find errors they should be reported to the time zone mailing
+ list, linked from http://www.twinsun.com/tz/tz-link.htm
+
+
+Further Reading
+~~~~~~~~~~~~~~~
+
+More info than you want to know about timezones:
+http://www.twinsun.com/tz/tz-link.htm
+
+
+Contact
+~~~~~~~
+
+Stuart Bishop <st...@st...>
+
Modified: trunk/matplotlib/lib/pytz/__init__.py
===================================================================
--- trunk/matplotlib/lib/pytz/__init__.py	2010年06月06日 20:34:09 UTC (rev 8388)
+++ trunk/matplotlib/lib/pytz/__init__.py	2010年06月06日 20:52:36 UTC (rev 8389)
@@ -8,29 +8,33 @@
 on how to use these modules.
 '''
 
-# The Olson database has historically been updated about 4 times a year
-OLSON_VERSION = '2008c'
+# The Olson database is updated several times a year.
+OLSON_VERSION = '2010h'
 VERSION = OLSON_VERSION
+# Version format for a patch release - only one so far.
 #VERSION = OLSON_VERSION + '.2'
 __version__ = OLSON_VERSION
 
 OLSEN_VERSION = OLSON_VERSION # Old releases had this misspelling
 
 __all__ = [
- 'timezone', 'utc', 'country_timezones',
- 'AmbiguousTimeError', 'UnknownTimeZoneError',
+ 'timezone', 'utc', 'country_timezones', 'country_names',
+ 'AmbiguousTimeError', 'InvalidTimeError',
+ 'NonExistentTimeError', 'UnknownTimeZoneError',
 'all_timezones', 'all_timezones_set',
 'common_timezones', 'common_timezones_set',
 ]
 
 import sys, datetime, os.path, gettext
+from UserDict import DictMixin
 
 try:
 from pkg_resources import resource_stream
 except ImportError:
 resource_stream = None
 
-from tzinfo import AmbiguousTimeError, unpickler
+from tzinfo import AmbiguousTimeError, InvalidTimeError, NonExistentTimeError
+from tzinfo import unpickler
 from tzfile import build_tzinfo
 
 # Use 2.3 sets module implementation if set builtin is not available
@@ -43,20 +47,32 @@
 def open_resource(name):
 """Open a resource from the zoneinfo subdir for reading.
 
- Uses the pkg_resources module if available.
+ Uses the pkg_resources module if available and no standard file
+ found at the calculated location.
 """
- if resource_stream is not None:
+ name_parts = name.lstrip('/').split('/')
+ for part in name_parts:
+ if part == os.path.pardir or os.path.sep in part:
+ raise ValueError('Bad path segment: %r' % part)
+ filename = os.path.join(os.path.dirname(__file__),
+ 'zoneinfo', *name_parts)
+ if not os.path.exists(filename) and resource_stream is not None:
+ # http://bugs.launchpad.net/bugs/383171 - we avoid using this
+ # unless absolutely necessary to help when a broken version of
+ # pkg_resources is installed.
 return resource_stream(__name__, 'zoneinfo/' + name)
- else:
- name_parts = name.lstrip('/').split('/')
- for part in name_parts:
- if part == os.path.pardir or os.path.sep in part:
- raise ValueError('Bad path segment: %r' % part)
- filename = os.path.join(os.path.dirname(__file__),
- 'zoneinfo', *name_parts)
- return open(filename, 'rb')
- 
+ return open(filename, 'rb')
 
+
+def resource_exists(name):
+ """Return true if the given resource exists"""
+ try:
+ open_resource(name)
+ return True
+ except IOError:
+ return False
+
+
 # Enable this when we get some translations?
 # We want an i18n API that is useful to programs using Python's gettext
 # module, as well as the Zope3 i18n package. Perhaps we should just provide
@@ -92,7 +108,7 @@
 
 def timezone(zone):
 r''' Return a datetime.tzinfo implementation for the given timezone 
- 
+
 >>> from datetime import datetime, timedelta
 >>> utc = timezone('UTC')
 >>> eastern = timezone('US/Eastern')
@@ -139,7 +155,7 @@
 _tzinfo_cache[zone] = build_tzinfo(zone, open_resource(zone))
 else:
 raise UnknownTimeZoneError(zone)
- 
+
 return _tzinfo_cache[zone]
 
 
@@ -154,7 +170,7 @@
 
 class UTC(datetime.tzinfo):
 """UTC
- 
+
 Identical to the reference UTC implementation given in Python docs except
 that it unpickles using the single module global instance defined beneath
 this class declaration.
@@ -164,6 +180,10 @@
 """
 zone = "UTC"
 
+ _utcoffset = ZERO
+ _dst = ZERO
+ _tzname = zone
+
 def utcoffset(self, dt):
 return ZERO
 
@@ -172,7 +192,7 @@
 
 def dst(self, dt):
 return ZERO
- 
+
 def __reduce__(self):
 return _UTC, ()
 
@@ -200,14 +220,14 @@
 
 def _UTC():
 """Factory function for utc unpickling.
- 
+
 Makes sure that unpickling a utc instance always returns the same 
 module global.
- 
+
 These examples belong in the UTC class above, but it is obscured; or in
 the README.txt, but we are not depending on Python 2.4 so integrating
 the README.txt examples with the unit tests is not trivial.
- 
+
 >>> import datetime, pickle
 >>> dt = datetime.datetime(2005, 3, 1, 14, 13, 21, tzinfo=utc)
 >>> naive = dt.replace(tzinfo=None)
@@ -240,38 +260,85 @@
 return unpickler(*args)
 _p.__safe_for_unpickling__ = True
 
-_country_timezones_cache = {}
 
-def country_timezones(iso3166_code):
- """Return a list of timezones used in a particular country.
+class _LazyDict(DictMixin):
+ """Dictionary populated on first use."""
+ data = None
+ def __getitem__(self, key):
+ if self.data is None:
+ self._fill()
+ return self.data[key.upper()]
 
+ def keys(self):
+ if self.data is None:
+ self._fill()
+ return self.data.keys()
+
+
+class _CountryTimezoneDict(_LazyDict):
+ """Map ISO 3166 country code to a list of timezone names commonly used
+ in that country.
+
 iso3166_code is the two letter code used to identify the country.
 
- >>> country_timezones('ch')
+ >>> country_timezones['ch']
 ['Europe/Zurich']
- >>> country_timezones('CH')
+ >>> country_timezones['CH']
 ['Europe/Zurich']
- >>> country_timezones(u'ch')
+ >>> country_timezones[u'ch']
 ['Europe/Zurich']
- >>> country_timezones('XXX')
+ >>> country_timezones['XXX']
 Traceback (most recent call last):
 ...
 KeyError: 'XXX'
+
+ Previously, this information was exposed as a function rather than a
+ dictionary. This is still supported::
+
+ >>> country_timezones('nz')
+ ['Pacific/Auckland', 'Pacific/Chatham']
 """
- iso3166_code = iso3166_code.upper()
- if not _country_timezones_cache:
+ def __call__(self, iso3166_code):
+ """Backwards compatibility."""
+ return self[iso3166_code]
+
+ def _fill(self):
+ data = {}
 zone_tab = open_resource('zone.tab')
 for line in zone_tab:
 if line.startswith('#'):
 continue
 code, coordinates, zone = line.split(None, 4)[:3]
+ if zone not in all_timezones_set:
+ continue
 try:
- _country_timezones_cache[code].append(zone)
+ data[code].append(zone)
 except KeyError:
- _country_timezones_cache[code] = [zone]
- return _country_timezones_cache[iso3166_code]
+ data[code] = [zone]
+ self.data = data
 
+country_timezones = _CountryTimezoneDict()
 
+
+class _CountryNameDict(_LazyDict):
+ '''Dictionary proving ISO3166 code -> English name.
+
+ >>> country_names['au']
+ 'Australia'
+ '''
+ def _fill(self):
+ data = {}
+ zone_tab = open_resource('iso3166.tab')
+ for line in zone_tab.readlines():
+ if line.startswith('#'):
+ continue
+ code, name = line.split(None, 1)
+ data[code] = name.strip()
+ self.data = data
+
+country_names = _CountryNameDict()
+
+
 # Time-zone info based solely on fixed offsets
 
 class _FixedOffset(datetime.tzinfo):
@@ -292,7 +359,7 @@
 
 def dst(self, dt):
 return None
- 
+
 def tzname(self, dt):
 return None
 
@@ -314,7 +381,7 @@
 
 def FixedOffset(offset, _tzinfos = {}):
 """return a fixed-offset timezone based off a number of minutes.
- 
+
 >>> one = FixedOffset(-330)
 >>> one
 pytz.FixedOffset(-330)
@@ -326,7 +393,7 @@
 pytz.FixedOffset(1380)
 >>> two.utcoffset(datetime.datetime.now())
 datetime.timedelta(0, 82800)
- 
+
 The datetime.timedelta must be between the range of -1 and 1 day,
 non-inclusive.
 
@@ -347,7 +414,7 @@
 
 There should always be only one instance of a FixedOffset per timedelta.
 This should be true for multiple creation calls.
- 
+
 >>> FixedOffset(-330) is one
 True
 >>> FixedOffset(1380) is two
@@ -386,7 +453,7 @@
 if __name__ == '__main__':
 _test()
 
-common_timezones = \
+all_timezones = \
 ['Africa/Abidjan',
 'Africa/Accra',
 'Africa/Addis_Ababa',
@@ -445,6 +512,19 @@
 'America/Anguilla',
 'America/Antigua',
 'America/Araguaina',
+ 'America/Argentina/Buenos_Aires',
+ 'America/Argentina/Catamarca',
+ 'America/Argentina/ComodRivadavia',
+ 'America/Argentina/Cordoba',
+ 'America/Argentina/Jujuy',
+ 'America/Argentina/La_Rioja',
+ 'America/Argentina/Mendoza',
+ 'America/Argentina/Rio_Gallegos',
+ 'America/Argentina/Salta',
+ 'America/Argentina/San_Juan',
+ 'America/Argentina/San_Luis',
+ 'America/Argentina/Tucuman',
+ 'America/Argentina/Ushuaia',
 'America/Aruba',
 'America/Asuncion',
 'America/Atikokan',
@@ -496,12 +576,22 @@
 'America/Halifax',
 'America/Havana',
 'America/Hermosillo',
+ 'America/Indiana/Indianapolis',
+ 'America/Indiana/Knox',
+ 'America/Indiana/Marengo',
+ 'America/Indiana/Petersburg',
+ 'America/Indiana/Tell_City',
+ 'America/Indiana/Vevay',
+ 'America/Indiana/Vincennes',
+ 'America/Indiana/Winamac',
 'America/Indianapolis',
 'America/Inuvik',
 'America/Iqaluit',
 'America/Jamaica',
 'America/Jujuy',
 'America/Juneau',
+ 'America/Kentucky/Louisville',
+ 'America/Kentucky/Monticello',
 'America/Knox_IN',
 'America/La_Paz',
 'America/Lima',
@@ -512,6 +602,7 @@
 'America/Manaus',
 'America/Marigot',
 'America/Martinique',
+ 'America/Matamoros',
 'America/Mazatlan',
 'America/Mendoza',
 'America/Menominee',
@@ -528,6 +619,9 @@
 'America/Nipigon',
 'America/Nome',
 'America/Noronha',
+ 'America/North_Dakota/Center',
+ 'America/North_Dakota/New_Salem',
+ 'America/Ojinaga',
 'America/Panama',
 'America/Pangnirtung',
 'America/Paramaribo',
@@ -544,6 +638,8 @@
 'America/Resolute',
 'America/Rio_Branco',
 'America/Rosario',
+ 'America/Santa_Isabel',
+ 'America/Santarem',
 'America/Santiago',
 'America/Santo_Domingo',
 'America/Sao_Paulo',
@@ -571,6 +667,7 @@
 'Antarctica/Casey',
 'Antarctica/Davis',
 'Antarctica/DumontDUrville',
+ 'Antarctica/Macquarie',
 'Antarctica/Mawson',
 'Antarctica/McMurdo',
 'Antarctica/Palmer',
@@ -619,6 +716,7 @@
 'Asia/Kamchatka',
 'Asia/Karachi',
 'Asia/Kashgar',
+ 'Asia/Kathmandu',
 'Asia/Katmandu',
 'Asia/Kolkata',
 'Asia/Krasnoyarsk',
@@ -632,6 +730,7 @@
 'Asia/Manila',
 'Asia/Muscat',
 'Asia/Nicosia',
+ 'Asia/Novokuznetsk',
 'Asia/Novosibirsk',
 'Asia/Omsk',
 'Asia/Oral',
@@ -704,6 +803,8 @@
 'Brazil/DeNoronha',
 'Brazil/East',
 'Brazil/West',
+ 'CET',
+ 'CST6CDT',
 'Canada/Atlantic',
 'Canada/Central',
 'Canada/East-Saskatchewan',
@@ -715,6 +816,47 @@
 'Canada/Yukon',
 'Chile/Continental',
 'Chile/EasterIsland',
+ 'Cuba',
+ 'EET',
+ 'EST',
+ 'EST5EDT',
+ 'Egypt',
+ 'Eire',
+ 'Etc/GMT',
+ 'Etc/GMT+0',
+ 'Etc/GMT+1',
+ 'Etc/GMT+10',
+ 'Etc/GMT+11',
+ 'Etc/GMT+12',
+ 'Etc/GMT+2',
+ 'Etc/GMT+3',
+ 'Etc/GMT+4',
+ 'Etc/GMT+5',
+ 'Etc/GMT+6',
+ 'Etc/GMT+7',
+ 'Etc/GMT+8',
+ 'Etc/GMT+9',
+ 'Etc/GMT-0',
+ 'Etc/GMT-1',
+ 'Etc/GMT-10',
+ 'Etc/GMT-11',
+ 'Etc/GMT-12',
+ 'Etc/GMT-13',
+ 'Etc/GMT-14',
+ 'Etc/GMT-2',
+ 'Etc/GMT-3',
+ 'Etc/GMT-4',
+ 'Etc/GMT-5',
+ 'Etc/GMT-6',
+ 'Etc/GMT-7',
+ 'Etc/GMT-8',
+ 'Etc/GMT-9',
+ 'Etc/GMT0',
+ 'Etc/Greenwich',
+ 'Etc/UCT',
+ 'Etc/UTC',
+ 'Etc/Universal',
+ 'Etc/Zulu',
 'Europe/Amsterdam',
 'Europe/Andorra',
 'Europe/Athens',
@@ -773,7 +915,16 @@
 'Europe/Zagreb',
 'Europe/Zaporozhye',
 'Europe/Zurich',
+ 'GB',
+ 'GB-Eire',
 'GMT',
+ 'GMT+0',
+ 'GMT-0',
+ 'GMT0',
+ 'Greenwich',
+ 'HST',
+ 'Hongkong',
+ 'Iceland',
 'Indian/Antananarivo',
 'Indian/Chagos',
 'Indian/Christmas',
@@ -785,9 +936,23 @@
 'Indian/Mauritius',
 'Indian/Mayotte',
 'Indian/Reunion',
+ 'Iran',
+ 'Israel',
+ 'Jamaica',
+ 'Japan',
+ 'Kwajalein',
+ 'Libya',
+ 'MET',
+ 'MST',
+ 'MST7MDT',
 'Mexico/BajaNorte',
 'Mexico/BajaSur',
 'Mexico/General',
+ 'NZ',
+ 'NZ-CHAT',
+ 'Navajo',
+ 'PRC',
+ 'PST8PDT',
 'Pacific/Apia',
 'Pacific/Auckland',
 'Pacific/Chatham',
@@ -828,6 +993,13 @@
 'Pacific/Wake',
 'Pacific/Wallis',
 'Pacific/Yap',
+ 'Poland',
+ 'Portugal',
+ 'ROC',
+ 'ROK',
+ 'Singapore',
+ 'Turkey',
+ 'UCT',
 'US/Alaska',
 'US/Aleutian',
 'US/Arizona',
@@ -841,16 +1013,21 @@
 'US/Pacific',
 'US/Pacific-New',
 'US/Samoa',
- 'UTC']
-common_timezones_set = set(common_timezones)
-
-all_timezones = \
+ 'UTC',
+ 'Universal',
+ 'W-SU',
+ 'WET',
+ 'Zulu']
+all_timezones = [
+ tz for tz in all_timezones if resource_exists(tz)]
+ 
+all_timezones_set = set(all_timezones)
+common_timezones = \
 ['Africa/Abidjan',
 'Africa/Accra',
 'Africa/Addis_Ababa',
 'Africa/Algiers',
 'Africa/Asmara',
- 'Africa/Asmera',
 'Africa/Bamako',
 'Africa/Bangui',
 'Africa/Banjul',
@@ -894,7 +1071,6 @@
 'Africa/Ouagadougou',
 'Africa/Porto-Novo',
 'Africa/Sao_Tome',
- 'Africa/Timbuktu',
 'Africa/Tripoli',
 'Africa/Tunis',
 'Africa/Windhoek',
@@ -905,12 +1081,12 @@
 'America/Araguaina',
 'America/Argentina/Buenos_Aires',
 'America/Argentina/Catamarca',
- 'America/Argentina/ComodRivadavia',
 'America/Argentina/Cordoba',
 'America/Argentina/Jujuy',
 'America/Argentina/La_Rioja',
 'America/Argentina/Mendoza',
 'America/Argentina/Rio_Gallegos',
+ 'America/Argentina/Salta',
 'America/Argentina/San_Juan',
 'America/Argentina/San_Luis',
 'America/Argentina/Tucuman',
@@ -918,7 +1094,6 @@
 'America/Aruba',
 'America/Asuncion',
 'America/Atikokan',
- 'America/Atka',
 'America/Bahia',
 'America/Barbados',
 'America/Belem',
@@ -927,18 +1102,14 @@
 'America/Boa_Vista',
 'America/Bogota',
 'America/Boise',
- 'America/Buenos_Aires',
 'America/Cambridge_Bay',
 'America/Campo_Grande',
 'America/Cancun',
 'America/Caracas',
- 'America/Catamarca',
 'America/Cayenne',
 'America/Cayman',
 'America/Chicago',
 'America/Chihuahua',
- 'America/Coral_Harbour',
- 'America/Cordoba',
 'America/Costa_Rica',
 'America/Cuiaba',
 'America/Curacao',
@@ -951,8 +1122,6 @@
 'America/Edmonton',
 'America/Eirunepe',
 'America/El_Salvador',
- 'America/Ensenada',
- 'America/Fort_Wayne',
 'America/Fortaleza',
 'America/Glace_Bay',
 'America/Godthab',
@@ -974,26 +1143,21 @@
 'America/Indiana/Vevay',
 'America/Indiana/Vincennes',
 'America/Indiana/Winamac',
- 'America/Indianapolis',
 'America/Inuvik',
 'America/Iqaluit',
 'America/Jamaica',
- 'America/Jujuy',
 'America/Juneau',
 'America/Kentucky/Louisville',
 'America/Kentucky/Monticello',
- 'America/Knox_IN',
 'America/La_Paz',
 'America/Lima',
 'America/Los_Angeles',
- 'America/Louisville',
 'America/Maceio',
 'America/Managua',
 'America/Manaus',
- 'America/Marigot',
 'America/Martinique',
+ 'America/Matamoros',
 'America/Mazatlan',
- 'America/Mendoza',
 'America/Menominee',
 'America/Merida',
 'America/Mexico_City',
@@ -1010,13 +1174,13 @@
 'America/Noronha',
 'America/North_Dakota/Center',
 'America/North_Dakota/New_Salem',
+ 'America/Ojinaga',
 'America/Panama',
 'America/Pangnirtung',
 'America/Paramaribo',
 'America/Phoenix',
 'America/Port-au-Prince',
 'America/Port_of_Spain',
- 'America/Porto_Acre',
 'America/Porto_Velho',
 'America/Puerto_Rico',
 'America/Rainy_River',
@@ -1025,13 +1189,12 @@
 'America/Regina',
 'America/Resolute',
 'America/Rio_Branco',
- 'America/Rosario',
+ 'America/Santa_Isabel',
+ 'America/Santarem',
 'America/Santiago',
 'America/Santo_Domingo',
 'America/Sao_Paulo',
 'America/Scoresbysund',
- 'America/Shiprock',
- 'America/St_Barthelemy',
 'America/St_Johns',
 'America/St_Kitts',
 'America/St_Lucia',
@@ -1045,7 +1208,6 @@
 'America/Toronto',
 'America/Tortola',
 'America/Vancouver',
- 'America/Virgin',
 'America/Whitehorse',
 'America/Winnipeg',
 'America/Yakutat',
@@ -1053,14 +1215,13 @@
 'Antarctica/Casey',
 'Antarctica/Davis',
 'Antarctica/DumontDUrville',
+ 'Antarctica/Macquarie',
 'Antarctica/Mawson',
 'Antarctica/McMurdo',
 'Antarctica/Palmer',
 'Antarctica/Rothera',
- 'Antarctica/South_Pole',
 'Antarctica/Syowa',
 'Antarctica/Vostok',
- 'Arctic/Longyearbyen',
 'Asia/Aden',
 'Asia/Almaty',
 'Asia/Amman',
@@ -1068,7 +1229,6 @@
 'Asia/Aqtau',
 'Asia/Aqtobe',
 'Asia/Ashgabat',
- 'Asia/Ashkhabad',
 'Asia/Baghdad',
 'Asia/Bahrain',
 'Asia/Baku',
@@ -1076,12 +1236,9 @@
 'Asia/Beirut',
 'Asia/Bishkek',
 'Asia/Brunei',
- 'Asia/Calcutta',
 'Asia/Choibalsan',
 'Asia/Chongqing',
- 'Asia/Chungking',
 'Asia/Colombo',
- 'Asia/Dacca',
 'Asia/Damascus',
 'Asia/Dhaka',
 'Asia/Dili',
@@ -1093,7 +1250,6 @@
 'Asia/Hong_Kong',
 'Asia/Hovd',
 'Asia/Irkutsk',
- 'Asia/Istanbul',
 'Asia/Jakarta',
 'Asia/Jayapura',
 'Asia/Jerusalem',
@@ -1101,19 +1257,19 @@
 'Asia/Kamchatka',
 'Asia/Karachi',
 'Asia/Kashgar',
- 'Asia/Katmandu',
+ 'Asia/Kathmandu',
 'Asia/Kolkata',
 'Asia/Krasnoyarsk',
 'Asia/Kuala_Lumpur',
 'Asia/Kuching',
 'Asia/Kuwait',
- 'Asia/Macao',
 'Asia/Macau',
 'Asia/Magadan',
 'Asia/Makassar',
 'Asia/Manila',
 'Asia/Muscat',
 'Asia/Nicosia',
+ 'Asia/Novokuznetsk',
 'Asia/Novosibirsk',
 'Asia/Omsk',
 'Asia/Oral',
@@ -1124,7 +1280,6 @@
 'Asia/Qyzylorda',
 'Asia/Rangoon',
 'Asia/Riyadh',
- 'Asia/Saigon',
 'Asia/Sakhalin',
 'Asia/Samarkand',
 'Asia/Seoul',
@@ -1134,13 +1289,9 @@
 'Asia/Tashkent',
 'Asia/Tbilisi',
 'Asia/Tehran',
- 'Asia/Tel_Aviv',
- 'Asia/Thimbu',
 'Asia/Thimphu',
 'Asia/Tokyo',
- 'Asia/Ujung_Pandang',
 'Asia/Ulaanbaatar',
- 'Asia/Ulan_Bator',
 'Asia/Urumqi',
 'Asia/Vientiane',
 'Asia/Vladivostok',
@@ -1151,102 +1302,35 @@
 'Atlantic/Bermuda',
 'Atlantic/Canary',
 'Atlantic/Cape_Verde',
- 'Atlantic/Faeroe',
 'Atlantic/Faroe',
- 'Atlantic/Jan_Mayen',
 'Atlantic/Madeira',
 'Atlantic/Reykjavik',
 'Atlantic/South_Georgia',
 'Atlantic/St_Helena',
 'Atlantic/Stanley',
- 'Australia/ACT',
 'Australia/Adelaide',
 'Australia/Brisbane',
 'Australia/Broken_Hill',
- 'Australia/Canberra',
 'Australia/Currie',
 'Australia/Darwin',
 'Australia/Eucla',
 'Australia/Hobart',
- 'Australia/LHI',
 'Australia/Lindeman',
 'Australia/Lord_Howe',
 'Australia/Melbourne',
- 'Australia/NSW',
- 'Australia/North',
 'Australia/Perth',
- 'Australia/Queensland',
- 'Australia/South',
 'Australia/Sydney',
- 'Australia/Tasmania',
- 'Australia/Victoria',
- 'Australia/West',
- 'Australia/Yancowinna',
- 'Brazil/Acre',
- 'Brazil/DeNoronha',
- 'Brazil/East',
- 'Brazil/West',
- 'CET',
- 'CST6CDT',
 'Canada/Atlantic',
 'Canada/Central',
- 'Canada/East-Saskatchewan',
 'Canada/Eastern',
 'Canada/Mountain',
 'Canada/Newfoundland',
 'Canada/Pacific',
- 'Canada/Saskatchewan',
- 'Canada/Yukon',
- 'Chile/Continental',
- 'Chile/EasterIsland',
- 'Cuba',
- 'EET',
- 'EST',
- 'EST5EDT',
- 'Egypt',
- 'Eire',
- 'Etc/GMT',
- 'Etc/GMT+0',
- 'Etc/GMT+1',
- 'Etc/GMT+10',
- 'Etc/GMT+11',
- 'Etc/GMT+12',
- 'Etc/GMT+2',
- 'Etc/GMT+3',
- 'Etc/GMT+4',
- 'Etc/GMT+5',
- 'Etc/GMT+6',
- 'Etc/GMT+7',
- 'Etc/GMT+8',
- 'Etc/GMT+9',
- 'Etc/GMT-0',
- 'Etc/GMT-1',
- 'Etc/GMT-10',
- 'Etc/GMT-11',
- 'Etc/GMT-12',
- 'Etc/GMT-13',
- 'Etc/GMT-14',
- 'Etc/GMT-2',
- 'Etc/GMT-3',
- 'Etc/GMT-4',
- 'Etc/GMT-5',
- 'Etc/GMT-6',
- 'Etc/GMT-7',
- 'Etc/GMT-8',
- 'Etc/GMT-9',
- 'Etc/GMT0',
- 'Etc/Greenwich',
- 'Etc/UCT',
- 'Etc/UTC',
- 'Etc/Universal',
- 'Etc/Zulu',
 'Europe/Amsterdam',
 'Europe/Andorra',
 'Europe/Athens',
- 'Europe/Belfast',
 'Europe/Belgrade',
 'Europe/Berlin',
- 'Europe/Bratislava',
 'Europe/Brussels',
 'Europe/Bucharest',
 'Europe/Budapest',
@@ -1254,60 +1338,38 @@
 'Europe/Copenhagen',
 'Europe/Dublin',
 'Europe/Gibraltar',
- 'Europe/Guernsey',
 'Europe/Helsinki',
- 'Europe/Isle_of_Man',
 'Europe/Istanbul',
- 'Europe/Jersey',
 'Europe/Kaliningrad',
 'Europe/Kiev',
 'Europe/Lisbon',
- 'Europe/Ljubljana',
 'Europe/London',
 'Europe/Luxembourg',
 'Europe/Madrid',
 'Europe/Malta',
- 'Europe/Mariehamn',
 'Europe/Minsk',
 'Europe/Monaco',
 'Europe/Moscow',
- 'Europe/Nicosia',
 'Europe/Oslo',
 'Europe/Paris',
- 'Europe/Podgorica',
 'Europe/Prague',
 'Europe/Riga',
 'Europe/Rome',
 'Europe/Samara',
- 'Europe/San_Marino',
- 'Europe/Sarajevo',
 'Europe/Simferopol',
- 'Europe/Skopje',
 'Europe/Sofia',
 'Europe/Stockholm',
 'Europe/Tallinn',
 'Europe/Tirane',
- 'Europe/Tiraspol',
 'Europe/Uzhgorod',
 'Europe/Vaduz',
- 'Europe/Vatican',
 'Europe/Vienna',
 'Europe/Vilnius',
 'Europe/Volgograd',
 'Europe/Warsaw',
- 'Europe/Zagreb',
 'Europe/Zaporozhye',
 'Europe/Zurich',
- 'GB',
- 'GB-Eire',
 'GMT',
- 'GMT+0',
- 'GMT-0',
- 'GMT0',
- 'Greenwich',
- 'HST',
- 'Hongkong',
- 'Iceland',
 'Indian/Antananarivo',
 'Indian/Chagos',
 'Indian/Christmas',
@@ -1319,23 +1381,6 @@
 'Indian/Mauritius',
 'Indian/Mayotte',
 'Indian/Reunion',
- 'Iran',
- 'Israel',
- 'Jamaica',
- 'Japan',
- 'Kwajalein',
- 'Libya',
- 'MET',
- 'MST',
- 'MST7MDT',
- 'Mexico/BajaNorte',
- 'Mexico/BajaSur',
- 'Mexico/General',
- 'NZ',
- 'NZ-CHAT',
- 'Navajo',
- 'PRC',
- 'PST8PDT',
 'Pacific/Apia',
 'Pacific/Auckland',
 'Pacific/Chatham',
@@ -1368,38 +1413,21 @@
 'Pacific/Port_Moresby',
 'Pacific/Rarotonga',
 'Pacific/Saipan',
- 'Pacific/Samoa',
 'Pacific/Tahiti',
 'Pacific/Tarawa',
 'Pacific/Tongatapu',
 'Pacific/Truk',
 'Pacific/Wake',
 'Pacific/Wallis',
- 'Pacific/Yap',
- 'Poland',
- 'Portugal',
- 'ROC',
- 'ROK',
- 'Singapore',
- 'Turkey',
- 'UCT',
 'US/Alaska',
- 'US/Aleutian',
 'US/Arizona',
 'US/Central',
- 'US/East-Indiana',
 'US/Eastern',
 'US/Hawaii',
- 'US/Indiana-Starke',
- 'US/Michigan',
 'US/Mountain',
 'US/Pacific',
- 'US/Pacific-New',
- 'US/Samoa',
- 'UTC',
- 'Universal',
- 'W-SU',
- 'WET',
- 'Zulu',
- 'posixrules']
-all_timezones_set = set(all_timezones)
+ 'UTC']
+common_timezones = [
+ tz for tz in common_timezones if tz in all_timezones]
+ 
+common_timezones_set = set(common_timezones)
Added: trunk/matplotlib/lib/pytz/tests/test_docs.py
===================================================================
--- trunk/matplotlib/lib/pytz/tests/test_docs.py	 (rev 0)
+++ trunk/matplotlib/lib/pytz/tests/test_docs.py	2010年06月06日 20:52:36 UTC (rev 8389)
@@ -0,0 +1,35 @@
+# -*- coding: ascii -*-
+
+import unittest, os, os.path, sys
+from doctest import DocTestSuite
+
+# We test the documentation this way instead of using DocFileSuite so
+# we can run the tests under Python 2.3
+def test_README():
+ pass
+
+this_dir = os.path.dirname(__file__)
+locs = [
+ os.path.join(this_dir, os.pardir, 'README.txt'),
+ os.path.join(this_dir, os.pardir, os.pardir, 'README.txt'),
+ ]
+for loc in locs:
+ if os.path.exists(loc):
+ test_README.__doc__ = open(loc).read()
+ break
+if test_README.__doc__ is None:
+ raise RuntimeError('README.txt not found')
+
+
+def test_suite():
+ "For the Z3 test runner"
+ return DocTestSuite()
+
+
+if __name__ == '__main__':
+ sys.path.insert(0, os.path.abspath(os.path.join(
+ this_dir, os.pardir, os.pardir
+ )))
+ unittest.main(defaultTest='test_suite')
+
+
Added: trunk/matplotlib/lib/pytz/tests/test_tzinfo.py
===================================================================
--- trunk/matplotlib/lib/pytz/tests/test_tzinfo.py	 (rev 0)
+++ trunk/matplotlib/lib/pytz/tests/test_tzinfo.py	2010年06月06日 20:52:36 UTC (rev 8389)
@@ -0,0 +1,656 @@
+# -*- coding: ascii -*-
+
+import sys, os, os.path
+import unittest, doctest
+import cPickle as pickle
+from datetime import datetime, time, timedelta, tzinfo
+
+if __name__ == '__main__':
+ # Only munge path if invoked as a script. Testrunners should have setup
+ # the paths already
+ sys.path.insert(0, os.path.abspath(os.path.join(os.pardir, os.pardir)))
+
+import pytz
+from pytz import reference
+from pytz.tzinfo import StaticTzInfo
+
+# I test for expected version to ensure the correct version of pytz is
+# actually being tested.
+EXPECTED_VERSION='2010h'
+
+fmt = '%Y-%m-%d %H:%M:%S %Z%z'
+
+NOTIME = timedelta(0)
+
+# GMT is a tzinfo.StaticTzInfo--the class we primarily want to test--while
+# UTC is reference implementation. They both have the same timezone meaning.
+UTC = pytz.timezone('UTC')
+GMT = pytz.timezone('GMT')
+assert isinstance(GMT, StaticTzInfo), 'GMT is no longer a StaticTzInfo'
+
+
+def prettydt(dt):
+ """datetime as a string using a known format.
+
+ We don't use strftime as it doesn't handle years earlier than 1900
+ per http://bugs.python.org/issue1777412
+ """
+ if dt.utcoffset() >= timedelta(0):
+ offset = '+%s' % (dt.utcoffset(),)
+ else:
+ offset = '-%s' % (-1 * dt.utcoffset(),)
+ return '%04d-%02d-%02d %02d:%02d:%02d %s %s' % (
+ dt.year, dt.month, dt.day,
+ dt.hour, dt.minute, dt.second,
+ dt.tzname(), offset)
+
+class BasicTest(unittest.TestCase):
+
+ def testVersion(self):
+ # Ensuring the correct version of pytz has been loaded
+ self.failUnlessEqual(EXPECTED_VERSION, pytz.__version__,
+ 'Incorrect pytz version loaded. Import path is stuffed '
+ 'or this test needs updating. (Wanted %s, got %s)'
+ % (EXPECTED_VERSION, pytz.__version__)
+ )
+
+ def testGMT(self):
+ now = datetime.now(tz=GMT)
+ self.failUnless(now.utcoffset() == NOTIME)
+ self.failUnless(now.dst() == NOTIME)
+ self.failUnless(now.timetuple() == now.utctimetuple())
+ self.failUnless(now==now.replace(tzinfo=UTC))
+
+ def testReferenceUTC(self):
+ now = datetime.now(tz=UTC)
+ self.failUnless(now.utcoffset() == NOTIME)
+ self.failUnless(now.dst() == NOTIME)
+ self.failUnless(now.timetuple() == now.utctimetuple())
+
+ def testUnknownOffsets(self):
+ # This tzinfo behavior is required to make
+ # datetime.time.{utcoffset, dst, tzname} work as documented.
+
+ dst_tz = pytz.timezone('US/Eastern')
+
+ # This information is not known when we don't have a date,
+ # so return None per API.
+ self.failUnless(dst_tz.utcoffset(None) is None)
+ self.failUnless(dst_tz.dst(None) is None)
+ # We don't know the abbreviation, but this is still a valid
+ # tzname per the Python documentation.
+ self.failUnlessEqual(dst_tz.tzname(None), 'US/Eastern')
+
+
+class PicklingTest(unittest.TestCase):
+
+ def _roundtrip_tzinfo(self, tz):
+ p = pickle.dumps(tz)
+ unpickled_tz = pickle.loads(p)
+ self.failUnless(tz is unpickled_tz, '%s did not roundtrip' % tz.zone)
+
+ def _roundtrip_datetime(self, dt):
+ # Ensure that the tzinfo attached to a datetime instance
+ # is identical to the one returned. This is important for
+ # DST timezones, as some state is stored in the tzinfo.
+ tz = dt.tzinfo
+ p = pickle.dumps(dt)
+ unpickled_dt = pickle.loads(p)
+ unpickled_tz = unpickled_dt.tzinfo
+ self.failUnless(tz is unpickled_tz, '%s did not roundtrip' % tz.zone)
+
+ def testDst(self):
+ tz = pytz.timezone('Europe/Amsterdam')
+ dt = datetime(2004, 2, 1, 0, 0, 0)
+
+ for localized_tz in tz._tzinfos.values():
+ self._roundtrip_tzinfo(localized_tz)
+ self._roundtrip_datetime(dt.replace(tzinfo=localized_tz))
+
+ def testRoundtrip(self):
+ dt = datetime(2004, 2, 1, 0, 0, 0)
+ for zone in pytz.all_timezones:
+ tz = pytz.timezone(zone)
+ self._roundtrip_tzinfo(tz)
+
+ def testDatabaseFixes(self):
+ # Hack the pickle to make it refer to a timezone abbreviation
+ # that does not match anything. The unpickler should be able
+ # to repair this case
+ tz = pytz.timezone('Australia/Melbourne')
+ p = pickle.dumps(tz)
+ tzname = tz._tzname
+ hacked_p = p.replace(tzname, '???')
+ self.failIfEqual(p, hacked_p)
+ unpickled_tz = pickle.loads(hacked_p)
+ self.failUnless(tz is unpickled_tz)
+
+ # Simulate a database correction. In this case, the incorrect
+ # data will continue to be used.
+ p = pickle.dumps(tz)
+ new_utcoffset = tz._utcoffset.seconds + 42
+ hacked_p = p.replace(str(tz._utcoffset.seconds), str(new_utcoffset))
+ self.failIfEqual(p, hacked_p)
+ unpickled_tz = pickle.loads(hacked_p)
+ self.failUnlessEqual(unpickled_tz._utcoffset.seconds, new_utcoffset)
+ self.failUnless(tz is not unpickled_tz)
+
+ def testOldPickles(self):
+ # Ensure that applications serializing pytz instances as pickles
+ # have no troubles upgrading to a new pytz release. These pickles
+ # where created with pytz2006j
+ east1 = pickle.loads(
+ "cpytz\n_p\np1\n(S'US/Eastern'\np2\nI-18000\n"
+ "I0\nS'EST'\np3\ntRp4\n."
+ )
+ east2 = pytz.timezone('US/Eastern')
+ self.failUnless(east1 is east2)
+
+ # Confirm changes in name munging between 2006j and 2007c cause
+ # no problems.
+ pap1 = pickle.loads(
+ "cpytz\n_p\np1\n(S'America/Port_minus_au_minus_Prince'"
+ "\np2\nI-17340\nI0\nS'PPMT'\np3\ntRp4\n."
+ )
+ pap2 = pytz.timezone('America/Port-au-Prince')
+ self.failUnless(pap1 is pap2)
+
+ gmt1 = pickle.loads("cpytz\n_p\np1\n(S'Etc/GMT_plus_10'\np2\ntRp3\n.")
+ gmt2 = pytz.timezone('Etc/GMT+10')
+ self.failUnless(gmt1 is gmt2)
+
+
+class USEasternDSTStartTestCase(unittest.TestCase):
+ tzinfo = pytz.timezone('US/Eastern')
+
+ # 24 hours before DST changeover
+ transition_time = datetime(2002, 4, 7, 7, 0, 0, tzinfo=UTC)
+
+ # Increase for 'flexible' DST transitions due to 1 minute granularity
+ # of Python's datetime library
+ instant = timedelta(seconds=1)
+
+ # before transition
+ before = {
+ 'tzname': 'EST',
+ 'utcoffset': timedelta(hours = -5),
+ 'dst': timedelta(hours = 0),
+ }
+
+ # after transition
+ after = {
+ 'tzname': 'EDT',
+ 'utcoffset': timedelta(hours = -4),
+ 'dst': timedelta(hours = 1),
+ }
+
+ def _test_tzname(self, utc_dt, wanted):
+ tzname = wanted['tzname']
+ dt = utc_dt.astimezone(self.tzinfo)
+ self.failUnlessEqual(dt.tzname(), tzname,
+ 'Expected %s as tzname for %s. Got %s' % (
+ tzname, str(utc_dt), dt.tzname()
+ )
+ )
+
+ def _test_utcoffset(self, utc_dt, wanted):
+ utcoffset = wanted['utcoffset']
+ dt = utc_dt.astimezone(self.tzinfo)
+ self.failUnlessEqual(
+ dt.utcoffset(), wanted['utcoffset'],
+ 'Expected %s as utcoffset for %s. Got %s' % (
+ utcoffset, utc_dt, dt.utcoffset()
+ )
+ )
+
+ def _test_dst(self, utc_dt, wanted):
+ dst = wanted['dst']
+ dt = utc_dt.astimezone(self.tzinfo)
+ self.failUnlessEqual(dt.dst(),dst,
+ 'Expected %s as dst for %s. Got %s' % (
+ dst, utc_dt, dt.dst()
+ )
+ )
+
+ def test_arithmetic(self):
+ utc_dt = self.transition_time
+
+ for days in range(-420, 720, 20):
+ delta = timedelta(days=days)
+
+ # Make sure we can get back where we started
+ dt = utc_dt.astimezone(self.tzinfo)
+ dt2 = dt + delta
+ dt2 = dt2 - delta
+ self.failUnlessEqual(dt, dt2)
+
+ # Make sure arithmetic crossing DST boundaries ends
+ # up in the correct timezone after normalization
+ utc_plus_delta = (utc_dt + delta).astimezone(self.tzinfo)
+ local_plus_delta = self.tzinfo.normalize(dt + delta)
+ self.failUnlessEqual(
+ prettydt(utc_plus_delta),
+ prettydt(local_plus_delta),
+ 'Incorrect result for delta==%d days. Wanted %r. Got %r'%(
+ days,
+ prettydt(utc_plus_delta),
+ prettydt(local_plus_delta),
+ )
+ )
+
+ def _test_all(self, utc_dt, wanted):
+ self._test_utcoffset(utc_dt, wanted)
+ self._test_tzname(utc_dt, wanted)
+ self._test_dst(utc_dt, wanted)
+
+ def testDayBefore(self):
+ self._test_all(
+ self.transition_time - timedelta(days=1), self.before
+ )
+
+ def testTwoHoursBefore(self):
+ self._test_all(
+ self.transition_time - timedelta(hours=2), self.before
+ )
+
+ def testHourBefore(self):
+ self._test_all(
+ self.transition_time - timedelta(hours=1), self.before
+ )
+
+ def testInstantBefore(self):
+ self._test_all(
+ self.transition_time - self.instant, self.before
+ )
+
+ def testTransition(self):
+ self._test_all(
+ self.transition_time, self.after
+ )
+
+ def testInstantAfter(self):
+ self._test_all(
+ self.transition_time + self.instant, self.after
+ )
+
+ def testHourAfter(self):
+ self._test_all(
+ self.transition_time + timedelta(hours=1), self.after
+ )
+
+ def testTwoHoursAfter(self):
+ self._test_all(
+ self.transition_time + timedelta(hours=1), self.after
+ )
+
+ def testDayAfter(self):
+ self._test_all(
+ self.transition_time + timedelta(days=1), self.after
+ )
+
+
+class USEasternDSTEndTestCase(USEasternDSTStartTestCase):
+ tzinfo = pytz.timezone('US/Eastern')
+ transition_time = datetime(2002, 10, 27, 6, 0, 0, tzinfo=UTC)
+ before = {
+ ...
 
[truncated message content]
From: <ef...@us...> - 2010年06月06日 20:34:17
Revision: 8388
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8388&view=rev
Author: efiring
Date: 2010年06月06日 20:34:09 +0000 (2010年6月06日)
Log Message:
-----------
[3009273] and [2875065] update dateutil to 1.5
Modified Paths:
--------------
 trunk/matplotlib/lib/dateutil/NEWS
 trunk/matplotlib/lib/dateutil/__init__.py
 trunk/matplotlib/lib/dateutil/easter.py
 trunk/matplotlib/lib/dateutil/parser.py
 trunk/matplotlib/lib/dateutil/relativedelta.py
 trunk/matplotlib/lib/dateutil/rrule.py
 trunk/matplotlib/lib/dateutil/tz.py
Added Paths:
-----------
 trunk/matplotlib/lib/dateutil/zoneinfo/zoneinfo-2010g.tar.gz
Removed Paths:
-------------
 trunk/matplotlib/lib/dateutil/zoneinfo/zoneinfo-2008e.tar.gz
Modified: trunk/matplotlib/lib/dateutil/NEWS
===================================================================
--- trunk/matplotlib/lib/dateutil/NEWS	2010年06月06日 18:58:43 UTC (rev 8387)
+++ trunk/matplotlib/lib/dateutil/NEWS	2010年06月06日 20:34:09 UTC (rev 8388)
@@ -1,3 +1,19 @@
+
+Version 1.5
+-----------
+
+- As reported by Mathieu Bridon, rrules were matching the bysecond rules
+ incorrectly against byminute in some circumstances when the SECONDLY
+ frequency was in use, due to a copy & paste bug. The problem has been
+ unittested and corrected.
+
+- Adam Ryan reported a problem in the relativedelta implementation which
+ affected the yearday parameter in the month of January specifically.
+ This has been unittested and fixed.
+
+- Updated timezone information.
+
+
 Version 1.4.1
 -------------
 
Modified: trunk/matplotlib/lib/dateutil/__init__.py
===================================================================
--- trunk/matplotlib/lib/dateutil/__init__.py	2010年06月06日 18:58:43 UTC (rev 8387)
+++ trunk/matplotlib/lib/dateutil/__init__.py	2010年06月06日 20:34:09 UTC (rev 8388)
@@ -1,9 +1,9 @@
 """
-Copyright (c) 2003-2005 Gustavo Niemeyer <gu...@ni...>
+Copyright (c) 2003-2010 Gustavo Niemeyer <gu...@ni...>
 
 This module offers extensions to the standard python 2.3+
 datetime module.
 """
 __author__ = "Gustavo Niemeyer <gu...@ni...>"
 __license__ = "PSF License"
-__version__ = "1.2-mpl"
+__version__ = "1.5"
Modified: trunk/matplotlib/lib/dateutil/easter.py
===================================================================
--- trunk/matplotlib/lib/dateutil/easter.py	2010年06月06日 18:58:43 UTC (rev 8387)
+++ trunk/matplotlib/lib/dateutil/easter.py	2010年06月06日 20:34:09 UTC (rev 8388)
@@ -1,5 +1,5 @@
 """
-Copyright (c) 2003-2005 Gustavo Niemeyer <gu...@ni...>
+Copyright (c) 2003-2007 Gustavo Niemeyer <gu...@ni...>
 
 This module offers extensions to the standard python 2.3+
 datetime module.
@@ -70,23 +70,23 @@
 if method < 3:
 # Old method
 i = (19*g+15)%30
- j = (y+y/4+i)%7
+ j = (y+y//4+i)%7
 if method == 2:
 # Extra dates to convert Julian to Gregorian date
 e = 10
 if y > 1600:
- e = e+y/100-16-(y/100-16)/4
+ e = e+y//100-16-(y//100-16)//4
 else:
 # New method
- c = y/100
- h = (c-c/4-(8*c+13)/25+19*g+15)%30
- i = h-(h/28)*(1-(h/28)*(29/(h+1))*((21-g)/11))
- j = (y+y/4+i+2-c+c/4)%7
+ c = y//100
+ h = (c-c//4-(8*c+13)//25+19*g+15)%30
+ i = h-(h//28)*(1-(h//28)*(29//(h+1))*((21-g)//11))
+ j = (y+y//4+i+2-c+c//4)%7
 
 # p can be from -6 to 56 corresponding to dates 22 March to 23 May
 # (later dates apply to method 2, although 23 May never actually occurs)
 p = i-j+e
- d = 1+(p+27+(p+6)/40)%31
- m = 3+(p+26)/30
- return datetime.date(y,m,d)
+ d = 1+(p+27+(p+6)//40)%31
+ m = 3+(p+26)//30
+ return datetime.date(int(y),int(m),int(d))
 
Modified: trunk/matplotlib/lib/dateutil/parser.py
===================================================================
--- trunk/matplotlib/lib/dateutil/parser.py	2010年06月06日 18:58:43 UTC (rev 8387)
+++ trunk/matplotlib/lib/dateutil/parser.py	2010年06月06日 20:34:09 UTC (rev 8388)
@@ -1,6 +1,6 @@
 # -*- coding:iso-8859-1 -*-
 """
-Copyright (c) 2003-2005 Gustavo Niemeyer <gu...@ni...>
+Copyright (c) 2003-2007 Gustavo Niemeyer <gu...@ni...>
 
 This module offers extensions to the standard python 2.3+
 datetime module.
@@ -8,17 +8,24 @@
 __author__ = "Gustavo Niemeyer <gu...@ni...>"
 __license__ = "PSF License"
 
-import os.path
+import datetime
 import string
+import time
 import sys
-import time
+import os
 
-import datetime
+try:
+ from cStringIO import StringIO
+except ImportError:
+ from StringIO import StringIO
+
 import relativedelta
 import tz
 
+
 __all__ = ["parse", "parserinfo"]
 
+
 # Some pointers:
 #
 # http://www.cl.cam.ac.uk/~mgk25/iso-time.html
@@ -28,12 +35,9 @@
 # http://search.cpan.org/author/MUIR/Time-modules-2003.0211/lib/Time/ParseDate.pm
 # http://stein.cshl.org/jade/distrib/docs/java.text.SimpleDateFormat.html
 
-try:
- from cStringIO import StringIO
-except ImportError:
- from StringIO import StringIO
 
-class _timelex:
+class _timelex(object):
+
 def __init__(self, instream):
 if isinstance(instream, basestring):
 instream = StringIO(instream)
@@ -139,6 +143,7 @@
 return list(cls(s))
 split = classmethod(split)
 
+
 class _resultbase(object):
 
 def __init__(self):
@@ -156,8 +161,9 @@
 def __repr__(self):
 return self._repr(self.__class__.__name__)
 
-class parserinfo:
 
+class parserinfo(object):
+
 # m from a.m/p.m, t from ISO T separator
 JUMP = [" ", ".", ",", ";", "-", "/", "'",
 "at", "on", "and", "ad", "m", "t", "of",
@@ -204,7 +210,7 @@
 self.yearfirst = yearfirst
 
 self._year = time.localtime().tm_year
- self._century = self._year/100*100
+ self._century = self._year//100*100
 
 def _convert(self, lst):
 dct = {}
@@ -281,15 +287,10 @@
 return True
 
 
-class parser:
+class parser(object):
 
- def __init__(self, info=parserinfo):
- if issubclass(info, parserinfo):
- self.info = parserinfo()
- elif isinstance(info, parserinfo):
- self.info = info
- else:
- raise TypeError, "Unsupported parserinfo type"
+ def __init__(self, info=None):
+ self.info = info or parserinfo()
 
 def parse(self, timestr, default=None,
 ignoretz=False, tzinfos=None,
@@ -360,9 +361,11 @@
 
 # Check if it's a number
 try:
- value = float(l[i])
+ value_repr = l[i]
+ value = float(value_repr)
 except ValueError:
 value = None
+
 if value is not None:
 # Token is a number
 len_li = len(l[i])
@@ -386,10 +389,7 @@
 # 19990101T235959[.59]
 res.hour = int(s[:2])
 res.minute = int(s[2:4])
- value = float(s[4:])
- res.second = int(value)
- if value%1:
- res.microsecond = int(1000000*(value%1))
+ res.second, res.microsecond = _parsems(s[4:])
 elif len_li == 8:
 # YYYYMMDD
 s = l[i-1]
@@ -423,15 +423,15 @@
 if value%1:
 res.second = int(60*(value%1))
 elif idx == 2:
- res.second = int(value)
- if value%1:
- res.microsecond = int(1000000*(value%1))
+ res.second, res.microsecond = \
+ _parsems(value_repr)
 i += 1
 if i >= len_l or idx == 2:
 break
 # 12h00
 try:
- value = float(l[i])
+ value_repr = l[i]
+ value = float(value_repr)
 except ValueError:
 break
 else:
@@ -451,10 +451,7 @@
 res.second = int(60*(value%1))
 i += 1
 if i < len_l and l[i] == ':':
- value = float(l[i+1])
- res.second = int(value)
- if value%1:
- res.microsecond = int(1000000*(value%1))
+ res.second, res.microsecond = _parsems(l[i+1])
 i += 2
 elif i < len_l and l[i] in ('-', '/', '.'):
 sep = l[i]
@@ -699,8 +696,9 @@
 else:
 return DEFAULTPARSER.parse(timestr, **kwargs)
 
-class _tzparser:
 
+class _tzparser(object):
+
 class _result(_resultbase):
 
 __slots__ = ["stdabbr", "stdoffset", "dstabbr", "dstoffset",
@@ -743,6 +741,8 @@
 if (i < len_l and
 (l[i] in ('+', '-') or l[i][0] in "0123456789")):
 if l[i] in ('+', '-'):
+ # Yes, that's right. See the TZ variable
+ # documentation.
 signal = (1,-1)[l[i] == '+']
 i += 1
 else:
@@ -865,11 +865,22 @@
 
 except (IndexError, ValueError, AssertionError):
 return None
-
+ 
 return res
 
+
 DEFAULTTZPARSER = _tzparser()
 def _parsetz(tzstr):
 return DEFAULTTZPARSER.parse(tzstr)
 
+
+def _parsems(value):
+ """Parse a I[.F] seconds value into (seconds, microseconds)."""
+ if "." not in value:
+ return int(value), 0
+ else:
+ i, f = value.split(".")
+ return int(i), int(f.ljust(6, "0")[:6])
+
+
 # vim:ts=4:sw=4:et
Modified: trunk/matplotlib/lib/dateutil/relativedelta.py
===================================================================
--- trunk/matplotlib/lib/dateutil/relativedelta.py	2010年06月06日 18:58:43 UTC (rev 8387)
+++ trunk/matplotlib/lib/dateutil/relativedelta.py	2010年06月06日 20:34:09 UTC (rev 8388)
@@ -1,5 +1,5 @@
 """
-Copyright (c) 2003-2005 Gustavo Niemeyer <gu...@ni...>
+Copyright (c) 2003-2010 Gustavo Niemeyer <gu...@ni...>
 
 This module offers extensions to the standard python 2.3+
 datetime module.
@@ -190,7 +190,7 @@
 if yday <= ydays:
 self.month = idx+1
 if idx == 0:
- self.day = ydays
+ self.day = yday
 else:
 self.day = yday-ydayidx[idx-1]
 break
@@ -201,27 +201,27 @@
 
 def _fix(self):
 if abs(self.microseconds) > 999999:
- s = self.microseconds/abs(self.microseconds)
+ s = self.microseconds//abs(self.microseconds)
 div, mod = divmod(self.microseconds*s, 1000000)
 self.microseconds = mod*s
 self.seconds += div*s
 if abs(self.seconds) > 59:
- s = self.seconds/abs(self.seconds)
+ s = self.seconds//abs(self.seconds)
 div, mod = divmod(self.seconds*s, 60)
 self.seconds = mod*s
 self.minutes += div*s
 if abs(self.minutes) > 59:
- s = self.minutes/abs(self.minutes)
+ s = self.minutes//abs(self.minutes)
 div, mod = divmod(self.minutes*s, 60)
 self.minutes = mod*s
 self.hours += div*s
 if abs(self.hours) > 23:
- s = self.hours/abs(self.hours)
+ s = self.hours//abs(self.hours)
 div, mod = divmod(self.hours*s, 24)
 self.hours = mod*s
 self.days += div*s
 if abs(self.months) > 11:
- s = self.months/abs(self.months)
+ s = self.months//abs(self.months)
 div, mod = divmod(self.months*s, 12)
 self.months = mod*s
 self.years += div*s
@@ -235,7 +235,7 @@
 def _set_months(self, months):
 self.months = months
 if abs(self.months) > 11:
- s = self.months/abs(self.months)
+ s = self.months//abs(self.months)
 div, mod = divmod(self.months*s, 12)
 self.months = mod*s
 self.years = div*s
Modified: trunk/matplotlib/lib/dateutil/rrule.py
===================================================================
--- trunk/matplotlib/lib/dateutil/rrule.py	2010年06月06日 18:58:43 UTC (rev 8387)
+++ trunk/matplotlib/lib/dateutil/rrule.py	2010年06月06日 20:34:09 UTC (rev 8388)
@@ -1,5 +1,5 @@
 """
-Copyright (c) 2003-2005 Gustavo Niemeyer <gu...@ni...>
+Copyright (c) 2003-2010 Gustavo Niemeyer <gu...@ni...>
 
 This module offers extensions to the standard python 2.3+
 datetime module.
@@ -439,7 +439,7 @@
 (freq >= MINUTELY and
 self._byminute and minute not in self._byminute) or
 (freq >= SECONDLY and
- self._bysecond and minute not in self._bysecond)):
+ self._bysecond and second not in self._bysecond)):
 timeset = ()
 else:
 timeset = gettimeset(hour, minute, second)
Modified: trunk/matplotlib/lib/dateutil/tz.py
===================================================================
--- trunk/matplotlib/lib/dateutil/tz.py	2010年06月06日 18:58:43 UTC (rev 8387)
+++ trunk/matplotlib/lib/dateutil/tz.py	2010年06月06日 20:34:09 UTC (rev 8388)
@@ -1,5 +1,5 @@
 """
-Copyright (c) 2003-2005 Gustavo Niemeyer <gu...@ni...>
+Copyright (c) 2003-2007 Gustavo Niemeyer <gu...@ni...>
 
 This module offers extensions to the standard python 2.3+
 datetime module.
@@ -438,7 +438,7 @@
 
 # The documentation says that utcoffset()-dst() must
 # be constant for every dt.
- return self._find_ttinfo(dt, laststd=1).delta-tti.delta
+ return tti.delta-self._find_ttinfo(dt, laststd=1).delta
 
 # An alternative for that would be:
 #
@@ -492,12 +492,12 @@
 self._dst_offset = self._std_offset+datetime.timedelta(hours=+1)
 else:
 self._dst_offset = ZERO
- if start is None:
+ if dstabbr and start is None:
 self._start_delta = relativedelta.relativedelta(
 hours=+2, month=4, day=1, weekday=relativedelta.SU(+1))
 else:
 self._start_delta = start
- if end is None:
+ if dstabbr and end is None:
 self._end_delta = relativedelta.relativedelta(
 hours=+1, month=10, day=31, weekday=relativedelta.SU(-1))
 else:
@@ -524,7 +524,7 @@
 def _isdst(self, dt):
 if not self._start_delta:
 return False
- year = datetime.date(dt.year,1,1)
+ year = datetime.datetime(dt.year,1,1)
 start = year+self._start_delta
 end = year+self._end_delta
 dt = dt.replace(tzinfo=None)
@@ -563,6 +563,11 @@
 if res is None:
 raise ValueError, "unknown string format"
 
+ # Here we break the compatibility with the TZ variable handling.
+ # GMT-3 actually *means* the timezone -3.
+ if res.stdabbr in ("GMT", "UTC"):
+ res.stdoffset *= -1
+
 # We must initialize it first, since _delta() needs
 # _std_offset and _dst_offset set. Use False in start/end
 # to avoid building it two times.
@@ -570,9 +575,13 @@
 res.dstabbr, res.dstoffset,
 start=False, end=False)
 
- self._start_delta = self._delta(res.start)
- if self._start_delta:
- self._end_delta = self._delta(res.end, isend=1)
+ if not res.dstabbr:
+ self._start_delta = None
+ self._end_delta = None
+ else:
+ self._start_delta = self._delta(res.start)
+ if self._start_delta:
+ self._end_delta = self._delta(res.end, isend=1)
 
 def _delta(self, x, isend=0):
 kwargs = {}
@@ -753,6 +762,8 @@
 else:
 i += 1
 
+ tzid = None
+ comps = []
 invtz = False
 comptype = None
 for line in lines:
Deleted: trunk/matplotlib/lib/dateutil/zoneinfo/zoneinfo-2008e.tar.gz
===================================================================
(Binary files differ)
Added: trunk/matplotlib/lib/dateutil/zoneinfo/zoneinfo-2010g.tar.gz
===================================================================
(Binary files differ)
Property changes on: trunk/matplotlib/lib/dateutil/zoneinfo/zoneinfo-2010g.tar.gz
___________________________________________________________________
Added: svn:mime-type
 + application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <ef...@us...> - 2010年06月06日 18:58:49
Revision: 8387
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8387&view=rev
Author: efiring
Date: 2010年06月06日 18:58:43 +0000 (2010年6月06日)
Log Message:
-----------
[2745233] clarify first example in the documentation
Modified Paths:
--------------
 trunk/matplotlib/doc/_templates/index.html
Modified: trunk/matplotlib/doc/_templates/index.html
===================================================================
--- trunk/matplotlib/doc/_templates/index.html	2010年06月06日 04:18:53 UTC (rev 8386)
+++ trunk/matplotlib/doc/_templates/index.html	2010年06月06日 18:58:43 UTC (rev 8387)
@@ -24,14 +24,14 @@
 alt="screenshots"/></a></p>
 
 
- <p>For example, to generate 10,000 gaussian random numbers and make a
- histogram plot binning the data into 100 bins, you simply need to
+ <p>For example, using "ipython -pylab" to provide an interactive
+ environment, to generate 10,000 gaussian random numbers and plot a
+ histogram with 100 bins, you simply need to
 type</p>
 
 <pre>
- >>> from pylab import randn, hist
- >>> x = randn(10000)
- >>> hist(x, 100)</pre>
+ x = randn(10000)
+ hist(x, 100)</pre>
 
 <p>For the power user, you have full control of line styles, font
 properties, axes properties, etc, via an object oriented interface
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <lee...@us...> - 2010年06月06日 04:18:59
Revision: 8386
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8386&view=rev
Author: leejjoon
Date: 2010年06月06日 04:18:53 +0000 (2010年6月06日)
Log Message:
-----------
Image in non-linear coordinates correctly have their coners at its extents
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/image.py
Modified: trunk/matplotlib/lib/matplotlib/image.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/image.py	2010年06月05日 18:32:11 UTC (rev 8385)
+++ trunk/matplotlib/lib/matplotlib/image.py	2010年06月06日 04:18:53 UTC (rev 8386)
@@ -135,7 +135,7 @@
 raise RuntimeError('The make_image method must be overridden.')
 
 
- def _get_unsampled_image(self, A, image_extents, viewlim):
+ def _get_unsampled_image(self, A, image_extents, viewlim, noslice=False):
 """
 convert numpy array A with given extents ([x1, x2, y1, y2] in
 data coordinate) into the Image, given the vielim (should be a
@@ -150,7 +150,7 @@
 sx = dxintv/viewlim.width
 sy = dyintv/viewlim.height
 numrows, numcols = A.shape[:2]
- if sx > 2:
+ if noslice is False and sx > 2:
 x0 = (viewlim.x0-xmin)/dxintv * numcols
 ix0 = max(0, int(x0 - self._filterrad))
 x1 = (viewlim.x1-xmin)/dxintv * numcols
@@ -164,7 +164,7 @@
 else:
 xslice = slice(0, numcols)
 
- if sy > 2:
+ if noslice is False and sy > 2:
 y0 = (viewlim.y0-ymin)/dyintv * numrows
 iy0 = max(0, int(y0 - self._filterrad))
 y1 = (viewlim.y1-ymin)/dyintv * numrows
@@ -246,8 +246,11 @@
 draw unsampled image. The renderer should support a draw_image method
 with scale parameter.
 """
+
+
 im, xmin, ymin, dxintv, dyintv, sx, sy = \
- self._get_unsampled_image(self._A, self.get_extent(), self.axes.viewLim)
+ self._get_unsampled_image(self._A, self.get_extent(),
+ self.axes.viewLim, noslice=True)
 
 if im is None: return # I'm not if this check is required. -JJL
 
@@ -264,18 +267,23 @@
 im._url = self.get_url()
 
 trans = self.get_transform() #axes.transData
- xy = trans.transform_non_affine([(xmin, ymin),
- (xmin+dxintv, ymin+dyintv)])
+ xy = trans.transform_non_affine(np.array([(xmin, ymin),
+ (xmin+dxintv, ymin+dyintv)]))
 xx1, yy1 = xy[0]
 xx2, yy2 = xy[1]
 
 if self._image_skew_coordinate:
 # skew the image when required.
+ x_llc, x_trc, y_llc, y_trc = self.get_extent()
 x_lrc, y_lrc = self._image_skew_coordinate
- xy = trans.transform_non_affine([(x_lrc, y_lrc)])
- xx3, yy3 = xy[0]
+ xy = trans.transform_non_affine(np.array([(x_llc, y_llc),
+ (x_trc, y_trc),
+ (x_lrc, y_lrc)]))
+ _xx1, _yy1 = xy[0]
+ _xx2, _yy2 = xy[1]
+ _xx3, _yy3 = xy[2]
 
- tr_rotate_skew = self._get_rotate_and_skew_transform(xx1, yy1, xx2, yy2, xx3, yy3)
+ tr_rotate_skew = self._get_rotate_and_skew_transform(_xx1, _yy1, _xx2, _yy2, _xx3, _yy3)
 tr = tr_rotate_skew+trans.get_affine()
 else:
 tr = trans.get_affine()
@@ -509,8 +517,21 @@
 if self._A is None:
 raise RuntimeError('You must first set the image array or the image attribute')
 
+ # image is created in the canvas coordinate.
+ x1, x2, y1, y2 = self.get_extent()
+ trans = self.get_transform()
+ xy = trans.transform(np.array([(x1, y1),
+ (x2, y2),
+ ]))
+ _x1, _y1 = xy[0]
+ _x2, _y2 = xy[1]
+
+ transformed_viewLim = mtransforms.TransformedBbox(self.axes.viewLim,
+ trans)
+
 im, xmin, ymin, dxintv, dyintv, sx, sy = \
- self._get_unsampled_image(self._A, self.get_extent(), self.axes.viewLim)
+ self._get_unsampled_image(self._A, [_x1, _x2, _y1, _y2],
+ transformed_viewLim)
 
 fc = self.axes.patch.get_facecolor()
 bg = mcolors.colorConverter.to_rgba(fc, 0)
@@ -526,8 +547,8 @@
 im.set_resample(self._resample)
 
 # the viewport translation
- tx = (xmin-self.axes.viewLim.x0)/dxintv * numcols
- ty = (ymin-self.axes.viewLim.y0)/dyintv * numrows
+ tx = (xmin-transformed_viewLim.x0)/dxintv * numcols
+ ty = (ymin-transformed_viewLim.y0)/dyintv * numrows
 
 l, b, r, t = self.axes.bbox.extents
 widthDisplay = (round(r*magnification) + 0.5) - (round(l*magnification) - 0.5)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing 5 results of 5

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /