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
(5)
2
(4)
3
(2)
4
(4)
5
(2)
6
(32)
7
(34)
8
(19)
9
(6)
10
(7)
11
(14)
12
(1)
13
(2)
14
(8)
15
(5)
16
(5)
17
(8)
18
(8)
19
(6)
20
(9)
21
(12)
22
(1)
23
(2)
24
(8)
25
(2)
26
(1)
27
(2)
28
(3)
29
30
(2)



Showing results of 214

<< < 1 .. 5 6 7 8 9 > >> (Page 7 of 9)
From: <as...@us...> - 2009年09月07日 20:02:46
Revision: 7685
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7685&view=rev
Author: astraw
Date: 2009年09月07日 20:02:39 +0000 (2009年9月07日)
Log Message:
-----------
test conversion: move old-style test to new-style test
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/tests/test_axes.py
 trunk/matplotlib/test/test_plots/TestAnnotation.py
Added Paths:
-----------
 trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/polar_axes.png
Removed Paths:
-------------
 trunk/matplotlib/test/test_plots/baseline/TestAnnotation/polar_axes.png
Copied: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/polar_axes.png (from rev 7684, trunk/matplotlib/test/test_plots/baseline/TestAnnotation/polar_axes.png)
===================================================================
(Binary files differ)
Modified: trunk/matplotlib/lib/matplotlib/tests/test_axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_axes.py	2009年09月07日 20:02:22 UTC (rev 7684)
+++ trunk/matplotlib/lib/matplotlib/tests/test_axes.py	2009年09月07日 20:02:39 UTC (rev 7685)
@@ -58,3 +58,39 @@
 xytext=(3, 3), textcoords='offset points' )
 
 fig.savefig( 'offset_points' )
+
+@image_comparison(baseline_images=['polar_axes'])
+def test_polar_annotations():
+ """Polar Plot Annotations"""
+
+ # you can specify the xypoint and the xytext in different
+ # positions and coordinate systems, and optionally turn on a
+ # connecting line and mark the point with a marker. Annotations
+ # work on polar axes too. In the example below, the xy point is
+ # in native coordinates (xycoords defaults to 'data'). For a
+ # polar axes, this is in (theta, radius) space. The text in this
+ # example is placed in the fractional figure coordinate system.
+ # Text keyword args like horizontal and vertical alignment are
+ # respected
+
+ # Setup some data
+ r = np.arange(0.0, 1.0, 0.001 )
+ theta = 2.0 * 2.0 * np.pi * r
+
+ fig = pylab.figure()
+ ax = fig.add_subplot( 111, polar=True )
+ line, = ax.plot( theta, r, color='#ee8d18', lw=3 )
+
+ ind = 800
+ thisr, thistheta = r[ind], theta[ind]
+ ax.plot([thistheta], [thisr], 'o')
+ ax.annotate('a polar annotation',
+ xy=(thistheta, thisr), # theta, radius
+ xytext=(0.05, 0.05), # fraction, fraction
+ textcoords='figure fraction',
+ arrowprops=dict(facecolor='black', shrink=0.05),
+ horizontalalignment='left',
+ verticalalignment='bottom',
+ )
+
+ fig.savefig( 'polar_axes' )
Modified: trunk/matplotlib/test/test_plots/TestAnnotation.py
===================================================================
--- trunk/matplotlib/test/test_plots/TestAnnotation.py	2009年09月07日 20:02:22 UTC (rev 7684)
+++ trunk/matplotlib/test/test_plots/TestAnnotation.py	2009年09月07日 20:02:39 UTC (rev 7685)
@@ -42,45 +42,6 @@
 pass
 
 #--------------------------------------------------------------------
- def testPolarAnnotations( self ):
- """Polar Plot Annotations"""
-
- # you can specify the xypoint and the xytext in different
- # positions and coordinate systems, and optionally turn on a
- # connecting line and mark the point with a marker. Annotations
- # work on polar axes too. In the example below, the xy point is
- # in native coordinates (xycoords defaults to 'data'). For a
- # polar axes, this is in (theta, radius) space. The text in this
- # example is placed in the fractional figure coordinate system.
- # Text keyword args like horizontal and vertical alignment are
- # respected
-
- # Setup some data
- r = npy.arange(0.0, 1.0, 0.001 )
- theta = 2.0 * 2.0 * npy.pi * r
-
- fname = self.outFile( "polar_axes.png" )
-
- fig = figure()
- ax = fig.add_subplot( 111, polar=True )
- line, = ax.plot( theta, r, color='#ee8d18', lw=3 )
-
- ind = 800
- thisr, thistheta = r[ind], theta[ind]
- ax.plot([thistheta], [thisr], 'o')
- ax.annotate('a polar annotation',
- xy=(thistheta, thisr), # theta, radius
- xytext=(0.05, 0.05), # fraction, fraction
- textcoords='figure fraction',
- arrowprops=dict(facecolor='black', shrink=0.05),
- horizontalalignment='left',
- verticalalignment='bottom',
- )
-
- fig.savefig( fname )
- self.checkImage( fname )
-
- #--------------------------------------------------------------------
 def testPolarCoordAnnotations( self ):
 """Polar Coordinate Annotations"""
 
Deleted: trunk/matplotlib/test/test_plots/baseline/TestAnnotation/polar_axes.png
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <as...@us...> - 2009年09月07日 20:02:30
Revision: 7684
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7684&view=rev
Author: astraw
Date: 2009年09月07日 20:02:22 +0000 (2009年9月07日)
Log Message:
-----------
test conversion: move old-style test to new-style test
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/tests/test_axes.py
 trunk/matplotlib/test/test_plots/TestAnnotation.py
Added Paths:
-----------
 trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/offset_points.png
Removed Paths:
-------------
 trunk/matplotlib/test/test_plots/baseline/TestAnnotation/offset_points.png
Copied: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/offset_points.png (from rev 7683, trunk/matplotlib/test/test_plots/baseline/TestAnnotation/offset_points.png)
===================================================================
(Binary files differ)
Modified: trunk/matplotlib/lib/matplotlib/tests/test_axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_axes.py	2009年09月07日 20:02:06 UTC (rev 7683)
+++ trunk/matplotlib/lib/matplotlib/tests/test_axes.py	2009年09月07日 20:02:22 UTC (rev 7684)
@@ -41,3 +41,20 @@
 ax.set_xlabel( "x-label 005" )
 ax.autoscale_view()
 fig.savefig( 'formatter_ticker_005' )
+
+@image_comparison(baseline_images=['offset_points'])
+def test_basic_annotate():
+ # Setup some data
+ t = np.arange( 0.0, 5.0, 0.01 )
+ s = np.cos( 2.0*np.pi * t )
+
+ # Offset Points
+
+ fig = pylab.figure()
+ ax = fig.add_subplot( 111, autoscale_on=False, xlim=(-1,5), ylim=(-3,5) )
+ line, = ax.plot( t, s, lw=3, color='purple' )
+
+ ax.annotate( 'local max', xy=(3, 1), xycoords='data',
+ xytext=(3, 3), textcoords='offset points' )
+
+ fig.savefig( 'offset_points' )
Modified: trunk/matplotlib/test/test_plots/TestAnnotation.py
===================================================================
--- trunk/matplotlib/test/test_plots/TestAnnotation.py	2009年09月07日 20:02:06 UTC (rev 7683)
+++ trunk/matplotlib/test/test_plots/TestAnnotation.py	2009年09月07日 20:02:22 UTC (rev 7684)
@@ -42,27 +42,6 @@
 pass
 
 #--------------------------------------------------------------------
- def testBasicAnnotate( self ):
- """Basic Annotations"""
-
- # Setup some data
- t = npy.arange( 0.0, 5.0, 0.01 )
- s = npy.cos( 2.0*npy.pi * t )
-
- # Offset Points
- fname = self.outFile( "offset_points.png" )
-
- fig = figure()
- ax = fig.add_subplot( 111, autoscale_on=False, xlim=(-1,5), ylim=(-3,5) )
- line, = ax.plot( t, s, lw=3, color='purple' )
-
- ax.annotate( 'local max', xy=(3, 1), xycoords='data',
- xytext=(3, 3), textcoords='offset points' )
-
- fig.savefig( fname )
- self.checkImage( fname )
-
- #--------------------------------------------------------------------
 def testPolarAnnotations( self ):
 """Polar Plot Annotations"""
 
Deleted: trunk/matplotlib/test/test_plots/baseline/TestAnnotation/offset_points.png
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <as...@us...> - 2009年09月07日 20:02:12
Revision: 7683
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7683&view=rev
Author: astraw
Date: 2009年09月07日 20:02:06 +0000 (2009年9月07日)
Log Message:
-----------
test conversion: move old-style test to new-style test
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/tests/test_dates.py
Added Paths:
-----------
 trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_dates/DateFormatter_fractionalSeconds.png
Removed Paths:
-------------
 trunk/matplotlib/test/test_matplotlib/TestTickers.py
 trunk/matplotlib/test/test_matplotlib/baseline/TestTickers/DateFormatter_fractionalSeconds.png
Copied: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_dates/DateFormatter_fractionalSeconds.png (from rev 7682, trunk/matplotlib/test/test_matplotlib/baseline/TestTickers/DateFormatter_fractionalSeconds.png)
===================================================================
(Binary files differ)
Modified: trunk/matplotlib/lib/matplotlib/tests/test_dates.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_dates.py	2009年09月07日 20:01:49 UTC (rev 7682)
+++ trunk/matplotlib/lib/matplotlib/tests/test_dates.py	2009年09月07日 20:02:06 UTC (rev 7683)
@@ -113,6 +113,35 @@
 
 fig.savefig( 'RRuleLocator_bounds' )
 
+@image_comparison(baseline_images=['DateFormatter_fractionalSeconds'])
+def test_DateFormatter():
+ """Test DateFormatter"""
+ import pylab
+ from datetime import datetime
+ import matplotlib.testing.jpl_units as units
+ units.register()
+
+ # Lets make sure that DateFormatter will allow us to have tick marks
+ # at intervals of fractional seconds.
+
+ t0 = datetime( 2001, 1, 1, 0, 0, 0 )
+ tf = datetime( 2001, 1, 1, 0, 0, 1 )
+
+ fig = pylab.figure()
+ ax = pylab.subplot( 111 )
+ ax.set_autoscale_on( True )
+ ax.plot( [t0, tf], [0.0, 1.0], marker='o' )
+
+ # rrule = mpldates.rrulewrapper( dateutil.rrule.YEARLY, interval=500 )
+ # locator = mpldates.RRuleLocator( rrule )
+ # ax.xaxis.set_major_locator( locator )
+ # ax.xaxis.set_major_formatter( mpldates.AutoDateFormatter(locator) )
+
+ ax.autoscale_view()
+ fig.autofmt_xdate()
+
+ fig.savefig( 'DateFormatter_fractionalSeconds' )
+
 if __name__=='__main__':
 import nose
 nose.runmodule(argv=['-s','--with-doctest'], exit=False)
Deleted: trunk/matplotlib/test/test_matplotlib/TestTickers.py
===================================================================
--- trunk/matplotlib/test/test_matplotlib/TestTickers.py	2009年09月07日 20:01:49 UTC (rev 7682)
+++ trunk/matplotlib/test/test_matplotlib/TestTickers.py	2009年09月07日 20:02:06 UTC (rev 7683)
@@ -1,75 +0,0 @@
-#=======================================================================
-"""The Tickers unit-test class implementation."""
-#=======================================================================
-
-from mplTest import *
-
-#=======================================================================
-# Add import modules below.
-import matplotlib
-matplotlib.use( "Agg", warn = False )
-
-import pylab
-import numpy as npy
-from datetime import datetime
-
-import dateutil
-import matplotlib.dates as mpldates
-import matplotlib.ticker as ticker
-#
-#=======================================================================
-
-#=======================================================================
-class TestTickers( MplTestCase ):
- """Test the various axes non-plotting methods."""
-
- # Uncomment any appropriate tags
- tags = [
- # 'gui', # requires the creation of a gui window
- 'agg', # uses agg in the backend
- 'agg-only', # uses only agg in the backend
- # 'wx', # uses wx in the backend
- # 'qt', # uses qt in the backend
- # 'ps', # uses the postscript backend
- # 'units', # uses units in the test
- 'PIL', # uses PIL for image comparison
- ]
-
- #--------------------------------------------------------------------
- def setUp( self ):
- """Setup any data needed for the unit test."""
- units.register()
-
- #--------------------------------------------------------------------
- def tearDown( self ):
- """Clean-up any generated files here."""
- pass
-
- #--------------------------------------------------------------------
- def test_DateFormatter( self ):
- """Test DateFormatter"""
-
- # Lets make sure that DateFormatter will allow us to have tick marks
- # at intervals of fractional seconds.
- fname = self.outFile( "DateFormatter_fractionalSeconds.png" )
-
- t0 = datetime( 2001, 1, 1, 0, 0, 0 )
- tf = datetime( 2001, 1, 1, 0, 0, 1 )
-
- fig = pylab.figure()
- ax = pylab.subplot( 111 )
- ax.set_autoscale_on( True )
- ax.plot( [t0, tf], [0.0, 1.0], marker='o' )
-
- # rrule = mpldates.rrulewrapper( dateutil.rrule.YEARLY, interval=500 )
- # locator = mpldates.RRuleLocator( rrule )
- # ax.xaxis.set_major_locator( locator )
- # ax.xaxis.set_major_formatter( mpldates.AutoDateFormatter(locator) )
-
- ax.autoscale_view()
- fig.autofmt_xdate()
-
- fig.savefig( fname )
- self.checkImage( fname )
-
- #--------------------------------------------------------------------
Deleted: trunk/matplotlib/test/test_matplotlib/baseline/TestTickers/DateFormatter_fractionalSeconds.png
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <as...@us...> - 2009年09月07日 20:01:59
Revision: 7682
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7682&view=rev
Author: astraw
Date: 2009年09月07日 20:01:49 +0000 (2009年9月07日)
Log Message:
-----------
test conversion: move old-style test to new-style test
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/tests/test_dates.py
 trunk/matplotlib/test/test_matplotlib/TestTickers.py
Added Paths:
-----------
 trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_dates/RRuleLocator_bounds.png
Removed Paths:
-------------
 trunk/matplotlib/test/test_matplotlib/baseline/TestTickers/RRuleLocator_bounds.png
Copied: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_dates/RRuleLocator_bounds.png (from rev 7681, trunk/matplotlib/test/test_matplotlib/baseline/TestTickers/RRuleLocator_bounds.png)
===================================================================
(Binary files differ)
Modified: trunk/matplotlib/lib/matplotlib/tests/test_dates.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_dates.py	2009年09月07日 20:01:33 UTC (rev 7681)
+++ trunk/matplotlib/lib/matplotlib/tests/test_dates.py	2009年09月07日 20:01:49 UTC (rev 7682)
@@ -83,6 +83,36 @@
 ax.xaxis.set_major_locator(DayLocator())
 assert_raises(RuntimeError, fig.savefig, 'junk.png')
 
+@image_comparison(baseline_images=['RRuleLocator_bounds'])
+def test_RRuleLocator():
+ import pylab
+ import matplotlib.dates as mpldates
+ import matplotlib.testing.jpl_units as units
+ from datetime import datetime
+ import dateutil
+ units.register()
+
+ # This will cause the RRuleLocator to go out of bounds when it tries
+ # to add padding to the limits, so we make sure it caps at the correct
+ # boundary values.
+ t0 = datetime( 1000, 1, 1 )
+ tf = datetime( 6000, 1, 1 )
+
+ fig = pylab.figure()
+ ax = pylab.subplot( 111 )
+ ax.set_autoscale_on( True )
+ ax.plot( [t0, tf], [0.0, 1.0], marker='o' )
+
+ rrule = mpldates.rrulewrapper( dateutil.rrule.YEARLY, interval=500 )
+ locator = mpldates.RRuleLocator( rrule )
+ ax.xaxis.set_major_locator( locator )
+ ax.xaxis.set_major_formatter( mpldates.AutoDateFormatter(locator) )
+
+ ax.autoscale_view()
+ fig.autofmt_xdate()
+
+ fig.savefig( 'RRuleLocator_bounds' )
+
 if __name__=='__main__':
 import nose
 nose.runmodule(argv=['-s','--with-doctest'], exit=False)
Modified: trunk/matplotlib/test/test_matplotlib/TestTickers.py
===================================================================
--- trunk/matplotlib/test/test_matplotlib/TestTickers.py	2009年09月07日 20:01:33 UTC (rev 7681)
+++ trunk/matplotlib/test/test_matplotlib/TestTickers.py	2009年09月07日 20:01:49 UTC (rev 7682)
@@ -46,33 +46,6 @@
 pass
 
 #--------------------------------------------------------------------
- def test_RRuleLocator( self ):
- """Test RRuleLocator"""
- fname = self.outFile( "RRuleLocator_bounds.png" )
-
- # This will cause the RRuleLocator to go out of bounds when it tries
- # to add padding to the limits, so we make sure it caps at the correct
- # boundary values.
- t0 = datetime( 1000, 1, 1 )
- tf = datetime( 6000, 1, 1 )
-
- fig = pylab.figure()
- ax = pylab.subplot( 111 )
- ax.set_autoscale_on( True )
- ax.plot( [t0, tf], [0.0, 1.0], marker='o' )
-
- rrule = mpldates.rrulewrapper( dateutil.rrule.YEARLY, interval=500 )
- locator = mpldates.RRuleLocator( rrule )
- ax.xaxis.set_major_locator( locator )
- ax.xaxis.set_major_formatter( mpldates.AutoDateFormatter(locator) )
-
- ax.autoscale_view()
- fig.autofmt_xdate()
-
- fig.savefig( fname )
- self.checkImage( fname )
-
- #--------------------------------------------------------------------
 def test_DateFormatter( self ):
 """Test DateFormatter"""
 
Deleted: trunk/matplotlib/test/test_matplotlib/baseline/TestTickers/RRuleLocator_bounds.png
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <as...@us...> - 2009年09月07日 20:01:40
Revision: 7681
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7681&view=rev
Author: astraw
Date: 2009年09月07日 20:01:33 +0000 (2009年9月07日)
Log Message:
-----------
test conversion: remove template for old-style tests
Removed Paths:
-------------
 trunk/matplotlib/test/mplTest/TestTEMPLATE.py
Deleted: trunk/matplotlib/test/mplTest/TestTEMPLATE.py
===================================================================
--- trunk/matplotlib/test/mplTest/TestTEMPLATE.py	2009年09月07日 20:01:25 UTC (rev 7680)
+++ trunk/matplotlib/test/mplTest/TestTEMPLATE.py	2009年09月07日 20:01:33 UTC (rev 7681)
@@ -1,62 +0,0 @@
-#=======================================================================
-"""The UNITTEST unit-test class implementation."""
-#=======================================================================
-
-from mplTest import *
-
-#=======================================================================
-# Add import modules below.
-import matplotlib
-matplotlib.use( "Agg", warn = False )
-
-import pylab
-import numpy as npy
-#
-#=======================================================================
-
-#=======================================================================
-class TestUNITTEST( MplTestCase ):
- """UNITTEST unit test class."""
-
- # Uncomment any appropriate tags
- tags = [
- # 'gui', # requires the creation of a gui window
- # 'agg', # uses agg in the backend
- # 'agg-only', # uses only agg in the backend
- # 'wx', # uses wx in the backend
- # 'qt', # uses qt in the backend
- # 'ps', # uses the postscript backend
- # 'pdf', # uses the PDF backend
- # 'units', # uses units in the test
- # 'PIL', # uses PIL for image comparison
- ]
-
- #--------------------------------------------------------------------
- def setUp( self ):
- """Setup any data needed for the unit test."""
- #TODO: Put set-up code here
- pass
-
- #--------------------------------------------------------------------
- def tearDown( self ):
- """Clean-up any generated files here."""
- #TODO: Put clean-up code here
- pass
-
- #--------------------------------------------------------------------
- def test_case_001( self ):
- """TODO: A very brief description of the test case."""
- #TODO: Put test-case code here
-
- fname = self.outFile( "test_case_001a" )
- fout = open( fname, 'w' )
- fout.write( "A UNITTEST.test_case_001 output file.\n" )
- fout.close()
-
- fname = self.outFile( "test_case_001b" )
- fout = open( fname, 'w' )
- fout.write( "Another UNITTEST.test_case_001 output file.\n" )
- fout.close()
-
- pass
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <as...@us...> - 2009年09月07日 20:01:34
Revision: 7680
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7680&view=rev
Author: astraw
Date: 2009年09月07日 20:01:25 +0000 (2009年9月07日)
Log Message:
-----------
testing: use all builtin nose plugins in old test runner script
Modified Paths:
--------------
 trunk/matplotlib/test/run-mpl-test.py
Modified: trunk/matplotlib/test/run-mpl-test.py
===================================================================
--- trunk/matplotlib/test/run-mpl-test.py	2009年09月07日 20:01:17 UTC (rev 7679)
+++ trunk/matplotlib/test/run-mpl-test.py	2009年09月07日 20:01:25 UTC (rev 7680)
@@ -43,6 +43,7 @@
 os.chdir( working )
 
 import nose
+import nose.plugins.builtin
 from mplTest import MplNosePlugin, path_utils
 import matplotlib
 from matplotlib.testing.noseclasses import KnownFailure
@@ -94,8 +95,12 @@
 args.append('.')
 args.extend( matplotlib.default_test_modules )
 
+plugins = [plugin() for plugin in nose.plugins.builtin.plugins]
+plugins.extend( [ MplNosePlugin(), KnownFailure() ])
+
 success = nose.run( argv = args,
- plugins = [ MplNosePlugin(), KnownFailure() ] )
+ plugins = plugins,
+ )
 
 ### do other stuff here
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7679
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7679&view=rev
Author: astraw
Date: 2009年09月07日 20:01:17 +0000 (2009年9月07日)
Log Message:
-----------
testing: remove duplicate code
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/tests/test_axes.py
Modified: trunk/matplotlib/lib/matplotlib/tests/test_axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_axes.py	2009年09月07日 19:19:23 UTC (rev 7678)
+++ trunk/matplotlib/lib/matplotlib/tests/test_axes.py	2009年09月07日 20:01:17 UTC (rev 7679)
@@ -13,23 +13,8 @@
 def test_formatter_ticker():
 """Test Some formatter and ticker issues."""
 import matplotlib.testing.jpl_units as units
- def register_units():
- """Register the unit conversion classes with matplotlib."""
- import matplotlib.units as munits
- import matplotlib.testing.jpl_units as jpl_units
- from matplotlib.testing.jpl_units.Duration import Duration
- from matplotlib.testing.jpl_units.Epoch import Epoch
- from matplotlib.testing.jpl_units.UnitDbl import UnitDbl
+ units.register()
 
- from matplotlib.testing.jpl_units.StrConverter import StrConverter
- from matplotlib.testing.jpl_units.EpochConverter import EpochConverter
- from matplotlib.testing.jpl_units.UnitDblConverter import UnitDblConverter
-
- munits.registry[ str ] = StrConverter()
- munits.registry[ Epoch ] = EpochConverter()
- munits.registry[ UnitDbl ] = UnitDblConverter()
- register_units()
-
 # This essentially test to see if user specified labels get overwritten
 # by the auto labeler functionality of the axes.
 xdata = [ x*units.sec for x in range(10) ]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2009年09月07日 19:19:32
Revision: 7678
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7678&view=rev
Author: jdh2358
Date: 2009年09月07日 19:19:23 +0000 (2009年9月07日)
Log Message:
-----------
fix test_dates to chek for RuntimeError on identical date lim test
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/axes.py
 trunk/matplotlib/lib/matplotlib/tests/test_dates.py
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py	2009年09月07日 18:50:11 UTC (rev 7677)
+++ trunk/matplotlib/lib/matplotlib/axes.py	2009年09月07日 19:19:23 UTC (rev 7678)
@@ -2033,6 +2033,8 @@
 if xmin is None: xmin = old_xmin
 if xmax is None: xmax = old_xmax
 
+ if xmin==xmax:
+ warnings.warn('Attempting to set identical xmin==xmax results in singular transformations; automatically expanding. xmin=%s, xmax=%s'%(xmin, xmax))
 xmin, xmax = mtransforms.nonsingular(xmin, xmax, increasing=False)
 xmin, xmax = self.xaxis.limit_range_for_scale(xmin, xmax)
 
@@ -2205,6 +2207,9 @@
 if ymin is None: ymin = old_ymin
 if ymax is None: ymax = old_ymax
 
+ if ymin==ymax:
+ warnings.warn('Attempting to set identical ymin==ymax results in singular transformations; automatically expanding. ymin=%s, ymax=%s'%(ymin, ymax))
+
 ymin, ymax = mtransforms.nonsingular(ymin, ymax, increasing=False)
 ymin, ymax = self.yaxis.limit_range_for_scale(ymin, ymax)
 self.viewLim.intervaly = (ymin, ymax)
Modified: trunk/matplotlib/lib/matplotlib/tests/test_dates.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_dates.py	2009年09月07日 18:50:11 UTC (rev 7677)
+++ trunk/matplotlib/lib/matplotlib/tests/test_dates.py	2009年09月07日 19:19:23 UTC (rev 7678)
@@ -2,6 +2,7 @@
 import numpy as np
 from matplotlib.testing.decorators import image_comparison, knownfailureif
 import matplotlib.pyplot as plt
+from nose.tools import assert_raises
 
 @image_comparison(baseline_images=['date_empty'])
 def test_date_empty():
@@ -66,13 +67,12 @@
 fig.autofmt_xdate()
 fig.savefig('date_axvline')
 
-# we want to test that this method raises a RuntimeError -- what is
-# the rightway to do this in the current framework
-@knownfailureif(True)
-#@image_comparison(baseline_images=['date_xlim_empty'])
-def test_set_xlim_and_unexpected_handling():
+def test_too_many_date_ticks():
 # Attempt to test SF 2715172, see
 # https://sourceforge.net/tracker/?func=detail&aid=2715172&group_id=80706&atid=560720
+ # setting equal datetimes triggers and expander call in
+ # transforms.nonsingular which results in too many ticks in the
+ # DayLocator. This should trigger a Locator.MAXTICKS RuntimeError
 t0 = datetime.datetime(2000, 1, 20)
 tf = datetime.datetime(2000, 1, 20)
 fig = plt.figure()
@@ -81,13 +81,7 @@
 ax.plot([],[])
 from matplotlib.dates import DayLocator, DateFormatter, HourLocator
 ax.xaxis.set_major_locator(DayLocator())
- ax.xaxis.set_major_formatter(DateFormatter("%m/%d/%y, %I:%M%p"))
- ax.xaxis.set_minor_locator(HourLocator())
- if 0:
- # this seems to cause an ininite loop.
- from nose.plugins.skip import SkipTest
- raise SkipTest('avoiding never-ending drawing')
- fig.savefig('date_xlim_empty')
+ assert_raises(RuntimeError, fig.savefig, 'junk.png')
 
 if __name__=='__main__':
 import nose
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2009年09月07日 18:50:18
Revision: 7677
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7677&view=rev
Author: jdh2358
Date: 2009年09月07日 18:50:11 +0000 (2009年9月07日)
Log Message:
-----------
use the max tick limit for all tick locators
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/dates.py
 trunk/matplotlib/lib/matplotlib/ticker.py
Modified: trunk/matplotlib/lib/matplotlib/dates.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/dates.py	2009年09月07日 18:42:41 UTC (rev 7676)
+++ trunk/matplotlib/lib/matplotlib/dates.py	2009年09月07日 18:50:11 UTC (rev 7677)
@@ -522,9 +522,7 @@
 
 self.rule.set(dtstart=start, until=stop)
 dates = self.rule.between(dmin, dmax, True)
- if len(dates)>=ticker.Locator.MAXTICKS:
- raise RuntimeError('RRuleLocator attempting to generate %d ticks from %s to %s: exceeds matplotlib.ticker.Locator.MAXTICKS'%(len(dates), dates[0], dates[-1]))
- return date2num(dates)
+ return self.raise_if_exceeds(date2num(dates))
 
 def _get_unit(self):
 """
Modified: trunk/matplotlib/lib/matplotlib/ticker.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/ticker.py	2009年09月07日 18:42:41 UTC (rev 7676)
+++ trunk/matplotlib/lib/matplotlib/ticker.py	2009年09月07日 18:50:11 UTC (rev 7677)
@@ -669,6 +669,13 @@
 'Return the locations of the ticks'
 raise NotImplementedError('Derived must override')
 
+ def raise_if_exceeds(self, locs):
+ 'raise a RuntimeError if Locator attempts to create more than MAXTICKS locs'
+ if len(locs)>=self.MAXTICKS:
+ raise RuntimeError('Locator attempting to generate %d ticks from %s to %s: exceeds Locator.MAXTICKS'%(len(locs), locs[0], locs[-1]))
+ 
+ return locs
+
 def view_limits(self, vmin, vmax):
 """
 select a scale for the range from vmin to vmax
@@ -728,7 +735,8 @@
 def __call__(self):
 'Return the locations of the ticks'
 dmin, dmax = self.axis.get_data_interval()
- return np.arange(dmin + self.offset, dmax+1, self._base)
+ return self.raise_if_exceeds(
+ np.arange(dmin + self.offset, dmax+1, self._base))
 
 
 class FixedLocator(Locator):
@@ -758,7 +766,7 @@
 ticks1 = self.locs[i::step]
 if np.absolute(ticks1).min() < np.absolute(ticks).min():
 ticks = ticks1
- return ticks
+ return self.raise_if_exceeds(ticks)
 
 
 
@@ -812,7 +820,7 @@
 if self.numticks==0: return []
 ticklocs = np.linspace(vmin, vmax, self.numticks)
 
- return ticklocs
+ return self.raise_if_exceeds(ticklocs)
 
 
 def _set_numticks(self):
@@ -900,7 +908,7 @@
 base = self._base.get_base()
 n = (vmax - vmin + 0.001*base)//base
 locs = vmin + np.arange(n+1) * base
- return locs
+ return self.raise_if_exceeds(locs)
 
 def view_limits(self, dmin, dmax):
 """
@@ -1010,7 +1018,7 @@
 locs = locs[:-1]
 elif prune=='both':
 locs = locs[1:-1]
- return locs
+ return self.raise_if_exceeds(locs)
 
 def view_limits(self, dmin, dmax):
 if self._symmetric:
@@ -1106,7 +1114,7 @@
 else:
 ticklocs = b**decades
 
- return np.array(ticklocs)
+ return self.raise_if_exceeds(np.array(ticklocs))
 
 def view_limits(self, vmin, vmax):
 'Try to choose the view limits intelligently'
@@ -1177,7 +1185,7 @@
 ticklocs.extend(subs * (np.sign(decade) * b ** np.abs(decade)))
 else:
 ticklocs = np.sign(decades) * b ** np.abs(decades)
- return np.array(ticklocs)
+ return self.raise_if_exceeds(np.array(ticklocs))
 
 def view_limits(self, vmin, vmax):
 'Try to choose the view limits intelligently'
@@ -1241,7 +1249,7 @@
 if vmin > vmax:
 vmin,vmax = vmax,vmin
 
- return locs[(vmin < locs) & (locs < vmax)]
+ return self.raise_if_exceeds(locs[(vmin < locs) & (locs < vmax)])
 
 
 class OldAutoLocator(Locator):
@@ -1256,7 +1264,7 @@
 def __call__(self):
 'Return the locations of the ticks'
 self.refresh()
- return self._locator()
+ return self.raise_if_exceeds(self._locator())
 
 def refresh(self):
 'refresh internal information based on current lim'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2009年09月07日 18:42:49
Revision: 7676
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7676&view=rev
Author: jdh2358
Date: 2009年09月07日 18:42:41 +0000 (2009年9月07日)
Log Message:
-----------
raise if num ticks exceeds some threshold to address sf bug 2715172
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/dates.py
 trunk/matplotlib/lib/matplotlib/tests/test_dates.py
 trunk/matplotlib/lib/matplotlib/ticker.py
 trunk/matplotlib/lib/matplotlib/transforms.py
Modified: trunk/matplotlib/lib/matplotlib/dates.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/dates.py	2009年09月07日 17:18:44 UTC (rev 7675)
+++ trunk/matplotlib/lib/matplotlib/dates.py	2009年09月07日 18:42:41 UTC (rev 7676)
@@ -522,6 +522,8 @@
 
 self.rule.set(dtstart=start, until=stop)
 dates = self.rule.between(dmin, dmax, True)
+ if len(dates)>=ticker.Locator.MAXTICKS:
+ raise RuntimeError('RRuleLocator attempting to generate %d ticks from %s to %s: exceeds matplotlib.ticker.Locator.MAXTICKS'%(len(dates), dates[0], dates[-1]))
 return date2num(dates)
 
 def _get_unit(self):
Modified: trunk/matplotlib/lib/matplotlib/tests/test_dates.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_dates.py	2009年09月07日 17:18:44 UTC (rev 7675)
+++ trunk/matplotlib/lib/matplotlib/tests/test_dates.py	2009年09月07日 18:42:41 UTC (rev 7676)
@@ -1,6 +1,6 @@
 import datetime
 import numpy as np
-from matplotlib.testing.decorators import image_comparison
+from matplotlib.testing.decorators import image_comparison, knownfailureif
 import matplotlib.pyplot as plt
 
 @image_comparison(baseline_images=['date_empty'])
@@ -66,7 +66,10 @@
 fig.autofmt_xdate()
 fig.savefig('date_axvline')
 
-@image_comparison(baseline_images=['date_xlim_empty'])
+# we want to test that this method raises a RuntimeError -- what is
+# the rightway to do this in the current framework
+@knownfailureif(True)
+#@image_comparison(baseline_images=['date_xlim_empty'])
 def test_set_xlim_and_unexpected_handling():
 # Attempt to test SF 2715172, see
 # https://sourceforge.net/tracker/?func=detail&aid=2715172&group_id=80706&atid=560720
@@ -80,7 +83,7 @@
 ax.xaxis.set_major_locator(DayLocator())
 ax.xaxis.set_major_formatter(DateFormatter("%m/%d/%y, %I:%M%p"))
 ax.xaxis.set_minor_locator(HourLocator())
- if 1:
+ if 0:
 # this seems to cause an ininite loop.
 from nose.plugins.skip import SkipTest
 raise SkipTest('avoiding never-ending drawing')
Modified: trunk/matplotlib/lib/matplotlib/ticker.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/ticker.py	2009年09月07日 17:18:44 UTC (rev 7675)
+++ trunk/matplotlib/lib/matplotlib/ticker.py	2009年09月07日 18:42:41 UTC (rev 7676)
@@ -657,7 +657,14 @@
 because the locator stores references to the Axis data and view
 limits
 """
-
+ 
+ # some automatic tick locators can generate so many ticks they
+ # kill the machine when you try and render them, see eg sf bug
+ # report
+ # https://sourceforge.net/tracker/index.php?func=detail&aid=2715172&group_id=80706&atid=560720.
+ # This parameter is set to cause locators to raise an error if too
+ # many ticks are generated
+ MAXTICKS = 1000
 def __call__(self):
 'Return the locations of the ticks'
 raise NotImplementedError('Derived must override')
Modified: trunk/matplotlib/lib/matplotlib/transforms.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/transforms.py	2009年09月07日 17:18:44 UTC (rev 7675)
+++ trunk/matplotlib/lib/matplotlib/transforms.py	2009年09月07日 18:42:41 UTC (rev 7676)
@@ -2266,6 +2266,7 @@
 else:
 vmin -= expander*abs(vmin)
 vmax += expander*abs(vmax)
+
 if swapped and not increasing:
 vmin, vmax = vmax, vmin
 return vmin, vmax
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7675
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7675&view=rev
Author: astraw
Date: 2009年09月07日 17:18:44 +0000 (2009年9月07日)
Log Message:
-----------
testing: add test for bug SF#2715172
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/tests/test_dates.py
Modified: trunk/matplotlib/lib/matplotlib/tests/test_dates.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_dates.py	2009年09月07日 16:57:36 UTC (rev 7674)
+++ trunk/matplotlib/lib/matplotlib/tests/test_dates.py	2009年09月07日 17:18:44 UTC (rev 7675)
@@ -66,6 +66,25 @@
 fig.autofmt_xdate()
 fig.savefig('date_axvline')
 
+@image_comparison(baseline_images=['date_xlim_empty'])
+def test_set_xlim_and_unexpected_handling():
+ # Attempt to test SF 2715172, see
+ # https://sourceforge.net/tracker/?func=detail&aid=2715172&group_id=80706&atid=560720
+ t0 = datetime.datetime(2000, 1, 20)
+ tf = datetime.datetime(2000, 1, 20)
+ fig = plt.figure()
+ ax = fig.add_subplot(1,1,1)
+ ax.set_xlim((t0,tf))
+ ax.plot([],[])
+ from matplotlib.dates import DayLocator, DateFormatter, HourLocator
+ ax.xaxis.set_major_locator(DayLocator())
+ ax.xaxis.set_major_formatter(DateFormatter("%m/%d/%y, %I:%M%p"))
+ ax.xaxis.set_minor_locator(HourLocator())
+ if 1:
+ # this seems to cause an ininite loop.
+ from nose.plugins.skip import SkipTest
+ raise SkipTest('avoiding never-ending drawing')
+ fig.savefig('date_xlim_empty')
 
 if __name__=='__main__':
 import nose
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <as...@us...> - 2009年09月07日 16:57:44
Revision: 7674
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7674&view=rev
Author: astraw
Date: 2009年09月07日 16:57:36 +0000 (2009年9月07日)
Log Message:
-----------
Patch artist: emit warning when kwargs conflict (addresses SF#2848629)
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/patches.py
Modified: trunk/matplotlib/lib/matplotlib/patches.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/patches.py	2009年09月07日 16:32:28 UTC (rev 7673)
+++ trunk/matplotlib/lib/matplotlib/patches.py	2009年09月07日 16:57:36 UTC (rev 7674)
@@ -73,6 +73,13 @@
 if linestyle is None: linestyle = "solid"
 if antialiased is None: antialiased = mpl.rcParams['patch.antialiased']
 
+ if 'color' in kwargs:
+ if (edgecolor is not None or
+ facecolor is not None):
+ import warnings
+ warnings.warn("Setting the 'color' property will override"
+ "the edgecolor or facecolor properties. ")
+
 self.set_edgecolor(edgecolor)
 self.set_facecolor(facecolor)
 self.set_linewidth(linewidth)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <as...@us...> - 2009年09月07日 16:32:37
Revision: 7673
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7673&view=rev
Author: astraw
Date: 2009年09月07日 16:32:28 +0000 (2009年9月07日)
Log Message:
-----------
testing: remove previous test images, preventing upload of removed tests
Modified Paths:
--------------
 trunk/matplotlib/test/_buildbot_mac_sage.sh
 trunk/matplotlib/test/_buildbot_test.py
Modified: trunk/matplotlib/test/_buildbot_mac_sage.sh
===================================================================
--- trunk/matplotlib/test/_buildbot_mac_sage.sh	2009年09月07日 14:09:01 UTC (rev 7672)
+++ trunk/matplotlib/test/_buildbot_mac_sage.sh	2009年09月07日 16:32:28 UTC (rev 7673)
@@ -11,4 +11,6 @@
 make -f make.osx mpl_install
 echo ${PYTHONPATH}
 
-cd test && python run-mpl-test.py --verbose --all --keep-failed
+cd test
+rm -f failed-diff-*.png
+python run-mpl-test.py --verbose --all --keep-failed
Modified: trunk/matplotlib/test/_buildbot_test.py
===================================================================
--- trunk/matplotlib/test/_buildbot_test.py	2009年09月07日 14:09:01 UTC (rev 7672)
+++ trunk/matplotlib/test/_buildbot_test.py	2009年09月07日 16:32:28 UTC (rev 7673)
@@ -1,6 +1,6 @@
 """This script will install matplotlib to a virtual environment to
 faciltate testing."""
-import shutil, os, sys
+import shutil, os, sys, glob
 from subprocess import Popen, PIPE, STDOUT
 
 from _buildbot_util import check_call
@@ -13,5 +13,10 @@
 TARGET_py = os.path.join(TARGET,'bin','python')
 check_call('%s -c "import shutil,matplotlib; x=matplotlib.get_configdir(); shutil.rmtree(x)"'%TARGET_py)
 
+
+previous_test_images = glob.glob(os.path.join('test','failed-diff-*.png'))
+for fname in previous_test_images:
+ os.unlink(fname)
+
 check_call('%s run-mpl-test.py --verbose --all --keep-failed'%TARGET_py,
 cwd='test')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2009年09月07日 14:09:22
Revision: 7672
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7672&view=rev
Author: jdh2358
Date: 2009年09月07日 14:09:01 +0000 (2009年9月07日)
Log Message:
-----------
removed empty datetime example from test_axes; now in test_dates
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/tests/test_axes.py
Removed Paths:
-------------
 trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/empty_datetime.png
Deleted: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/empty_datetime.png
===================================================================
(Binary files differ)
Modified: trunk/matplotlib/lib/matplotlib/tests/test_axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_axes.py	2009年09月06日 23:28:28 UTC (rev 7671)
+++ trunk/matplotlib/lib/matplotlib/tests/test_axes.py	2009年09月07日 14:09:01 UTC (rev 7672)
@@ -4,21 +4,6 @@
 import matplotlib.pyplot as plt
 import pylab
 
-@knownfailureif('indeterminate', "Fails due to SF bug 2850075")
-@image_comparison(baseline_images=['empty_datetime'])
-def test_empty_datetime():
- """Test plotting empty axes with dates along one axis."""
- from datetime import datetime
-
- t0 = datetime(2009, 1, 20)
- tf = datetime(2009, 1, 21)
-
- fig = pylab.figure()
- pylab.axvspan( t0, tf, facecolor="blue", alpha=0.25 )
- fig.autofmt_xdate()
-
- fig.savefig( 'empty_datetime' )
-
 @image_comparison(baseline_images=['formatter_ticker_001',
 'formatter_ticker_002',
 'formatter_ticker_003',
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <as...@us...> - 2009年09月07日 00:25:19
Revision: 7669
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7669&view=rev
Author: astraw
Date: 2009年09月06日 23:08:03 +0000 (2009年9月06日)
Log Message:
-----------
testing: enable test_dates
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/__init__.py
 trunk/matplotlib/lib/matplotlib/tests/test_dates.py
Added Paths:
-----------
 trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_dates/
 trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_dates/date_axhline.png
 trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_dates/date_axhspan.png
 trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_dates/date_axvline.png
 trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_dates/date_axvspan.png
 trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_dates/date_empty.png
Modified: trunk/matplotlib/lib/matplotlib/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/__init__.py	2009年09月06日 22:47:08 UTC (rev 7668)
+++ trunk/matplotlib/lib/matplotlib/__init__.py	2009年09月06日 23:08:03 UTC (rev 7669)
@@ -880,6 +880,7 @@
 'matplotlib.tests.test_basic',
 'matplotlib.tests.test_transforms',
 'matplotlib.tests.test_axes',
+ 'matplotlib.tests.test_dates',
 'matplotlib.tests.test_spines',
 ]
 
Added: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_dates/date_axhline.png
===================================================================
(Binary files differ)
Property changes on: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_dates/date_axhline.png
___________________________________________________________________
Added: svn:mime-type
 + application/octet-stream
Added: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_dates/date_axhspan.png
===================================================================
(Binary files differ)
Property changes on: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_dates/date_axhspan.png
___________________________________________________________________
Added: svn:mime-type
 + application/octet-stream
Added: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_dates/date_axvline.png
===================================================================
(Binary files differ)
Property changes on: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_dates/date_axvline.png
___________________________________________________________________
Added: svn:mime-type
 + application/octet-stream
Added: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_dates/date_axvspan.png
===================================================================
(Binary files differ)
Property changes on: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_dates/date_axvspan.png
___________________________________________________________________
Added: svn:mime-type
 + application/octet-stream
Added: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_dates/date_empty.png
===================================================================
(Binary files differ)
Property changes on: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_dates/date_empty.png
___________________________________________________________________
Added: svn:mime-type
 + application/octet-stream
Modified: trunk/matplotlib/lib/matplotlib/tests/test_dates.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_dates.py	2009年09月06日 22:47:08 UTC (rev 7668)
+++ trunk/matplotlib/lib/matplotlib/tests/test_dates.py	2009年09月06日 23:08:03 UTC (rev 7669)
@@ -1,9 +1,9 @@
-import datetime 
+import datetime
 import numpy as np
 from matplotlib.testing.decorators import image_comparison
 import matplotlib.pyplot as plt
 
-@image_comparison(baseline_images=['date_empty.png'])
+@image_comparison(baseline_images=['date_empty'])
 def test_date_empty():
 # make sure mpl does the right thing when told to plot dates even
 # if no date data has been presented, cf
@@ -11,9 +11,9 @@
 fig = plt.figure()
 ax = fig.add_subplot(1,1,1)
 ax.xaxis_date()
- fig.savefig('date_empty.png')
+ fig.savefig('date_empty')
 
-@image_comparison(baseline_images=['date_axhspan.png'])
+@image_comparison(baseline_images=['date_axhspan'])
 def test_date_axhspan():
 # test ax hspan with date inputs
 t0 = datetime.datetime(2009, 1, 20)
@@ -21,12 +21,12 @@
 fig = plt.figure()
 ax = fig.add_subplot(1,1,1)
 ax.axhspan( t0, tf, facecolor="blue", alpha=0.25 )
- ax.set_ylim(t0-datetime.timedelta(days=5), 
+ ax.set_ylim(t0-datetime.timedelta(days=5),
 tf+datetime.timedelta(days=5))
 fig.subplots_adjust(left=0.25)
- fig.savefig('date_axhspan.png')
+ fig.savefig('date_axhspan')
 
-@image_comparison(baseline_images=['date_axvspan.png'])
+@image_comparison(baseline_images=['date_axvspan'])
 def test_date_axvspan():
 # test ax hspan with date inputs
 t0 = datetime.datetime(2000, 1, 20)
@@ -34,13 +34,13 @@
 fig = plt.figure()
 ax = fig.add_subplot(1,1,1)
 ax.axvspan( t0, tf, facecolor="blue", alpha=0.25 )
- ax.set_xlim(t0-datetime.timedelta(days=720), 
+ ax.set_xlim(t0-datetime.timedelta(days=720),
 tf+datetime.timedelta(days=720))
 fig.autofmt_xdate()
- fig.savefig('date_axvspan.png')
+ fig.savefig('date_axvspan')
 
 
-@image_comparison(baseline_images=['date_axhline.png'])
+@image_comparison(baseline_images=['date_axhline'])
 def test_date_axhline():
 # test ax hline with date inputs
 t0 = datetime.datetime(2009, 1, 20)
@@ -48,12 +48,12 @@
 fig = plt.figure()
 ax = fig.add_subplot(1,1,1)
 ax.axhline( t0, color="blue", lw=3)
- ax.set_ylim(t0-datetime.timedelta(days=5), 
+ ax.set_ylim(t0-datetime.timedelta(days=5),
 tf+datetime.timedelta(days=5))
 fig.subplots_adjust(left=0.25)
- fig.savefig('date_axhline.png')
+ fig.savefig('date_axhline')
 
-@image_comparison(baseline_images=['date_axvline.png'])
+@image_comparison(baseline_images=['date_axvline'])
 def test_date_axvline():
 # test ax hline with date inputs
 t0 = datetime.datetime(2000, 1, 20)
@@ -61,15 +61,12 @@
 fig = plt.figure()
 ax = fig.add_subplot(1,1,1)
 ax.axvline( t0, color="red", lw=3)
- ax.set_xlim(t0-datetime.timedelta(days=5), 
+ ax.set_xlim(t0-datetime.timedelta(days=5),
 tf+datetime.timedelta(days=5))
 fig.autofmt_xdate()
- fig.savefig('date_axvline.png')
+ fig.savefig('date_axvline')
 
 
 if __name__=='__main__':
 import nose
- nose.runmodule(argv=['-s','--with-doctest'], exit=False) 
-
-
-
+ nose.runmodule(argv=['-s','--with-doctest'], exit=False)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <as...@us...> - 2009年09月06日 23:28:40
Revision: 7671
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7671&view=rev
Author: astraw
Date: 2009年09月06日 23:28:28 +0000 (2009年9月06日)
Log Message:
-----------
testing: fixup failing jpl unit test infrastructure
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/testing/jpl_units/Duration.py
 trunk/matplotlib/lib/matplotlib/testing/jpl_units/Epoch.py
 trunk/matplotlib/lib/matplotlib/testing/jpl_units/EpochConverter.py
 trunk/matplotlib/test/mplTest/__init__.py
Modified: trunk/matplotlib/lib/matplotlib/testing/jpl_units/Duration.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/testing/jpl_units/Duration.py	2009年09月06日 23:28:13 UTC (rev 7670)
+++ trunk/matplotlib/lib/matplotlib/testing/jpl_units/Duration.py	2009年09月06日 23:28:28 UTC (rev 7671)
@@ -100,7 +100,7 @@
 - Returns the sum of ourselves and the input Duration.
 """
 # Delay-load due to circular dependencies.
- import mplTest.units as U
+ import matplotlib.testing.jpl_units as U
 
 if isinstance( rhs, U.Epoch ):
 return rhs + self
Modified: trunk/matplotlib/lib/matplotlib/testing/jpl_units/Epoch.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/testing/jpl_units/Epoch.py	2009年09月06日 23:28:13 UTC (rev 7670)
+++ trunk/matplotlib/lib/matplotlib/testing/jpl_units/Epoch.py	2009年09月06日 23:28:28 UTC (rev 7671)
@@ -173,7 +173,7 @@
 Epoch that is the result of subtracting a duration from an epoch.
 """
 # Delay-load due to circular dependencies.
- import mplTest.units as U
+ import matplotlib.testing.jpl_units as U
 
 # Handle Epoch - Duration
 if isinstance( rhs, U.Duration ):
Modified: trunk/matplotlib/lib/matplotlib/testing/jpl_units/EpochConverter.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/testing/jpl_units/EpochConverter.py	2009年09月06日 23:28:13 UTC (rev 7670)
+++ trunk/matplotlib/lib/matplotlib/testing/jpl_units/EpochConverter.py	2009年09月06日 23:28:28 UTC (rev 7671)
@@ -63,7 +63,7 @@
 - Returns the value converted to an Epoch in the sepcified time system.
 """
 # Delay-load due to circular dependencies.
- import mplTest.units as U
+ import matplotlib.testing.jpl_units as U
 
 secPastRef = value * 86400.0 * U.UnitDbl( 1.0, 'sec' )
 return U.Epoch( unit, secPastRef, EpochConverter.jdRef )
@@ -111,7 +111,7 @@
 - Returns the value parameter converted to floats.
 """
 # Delay-load due to circular dependencies.
- import mplTest.units as U
+ import matplotlib.testing.jpl_units as U
 
 isNotEpoch = True
 isDuration = False
Modified: trunk/matplotlib/test/mplTest/__init__.py
===================================================================
--- trunk/matplotlib/test/mplTest/__init__.py	2009年09月06日 23:28:13 UTC (rev 7670)
+++ trunk/matplotlib/test/mplTest/__init__.py	2009年09月06日 23:28:28 UTC (rev 7671)
@@ -10,4 +10,4 @@
 from mplTest.MplNosePlugin import MplNosePlugin
 from mplTest.MplTestCase import MplTestCase
 
-import mplTest.units as units
+import matplotlib.testing.jpl_units as units
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7670
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7670&view=rev
Author: astraw
Date: 2009年09月06日 23:28:13 +0000 (2009年9月06日)
Log Message:
-----------
testing: add missing file
Added Paths:
-----------
 trunk/matplotlib/lib/matplotlib/tests/test_axes.py
Added: trunk/matplotlib/lib/matplotlib/tests/test_axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_axes.py	 (rev 0)
+++ trunk/matplotlib/lib/matplotlib/tests/test_axes.py	2009年09月06日 23:28:13 UTC (rev 7670)
@@ -0,0 +1,73 @@
+import numpy as np
+import matplotlib
+from matplotlib.testing.decorators import image_comparison, knownfailureif
+import matplotlib.pyplot as plt
+import pylab
+
+@knownfailureif('indeterminate', "Fails due to SF bug 2850075")
+@image_comparison(baseline_images=['empty_datetime'])
+def test_empty_datetime():
+ """Test plotting empty axes with dates along one axis."""
+ from datetime import datetime
+
+ t0 = datetime(2009, 1, 20)
+ tf = datetime(2009, 1, 21)
+
+ fig = pylab.figure()
+ pylab.axvspan( t0, tf, facecolor="blue", alpha=0.25 )
+ fig.autofmt_xdate()
+
+ fig.savefig( 'empty_datetime' )
+
+@image_comparison(baseline_images=['formatter_ticker_001',
+ 'formatter_ticker_002',
+ 'formatter_ticker_003',
+ 'formatter_ticker_004',
+ 'formatter_ticker_005',
+ ])
+def test_formatter_ticker():
+ """Test Some formatter and ticker issues."""
+ import matplotlib.testing.jpl_units as units
+ def register_units():
+ """Register the unit conversion classes with matplotlib."""
+ import matplotlib.units as munits
+ import matplotlib.testing.jpl_units as jpl_units
+ from matplotlib.testing.jpl_units.Duration import Duration
+ from matplotlib.testing.jpl_units.Epoch import Epoch
+ from matplotlib.testing.jpl_units.UnitDbl import UnitDbl
+
+ from matplotlib.testing.jpl_units.StrConverter import StrConverter
+ from matplotlib.testing.jpl_units.EpochConverter import EpochConverter
+ from matplotlib.testing.jpl_units.UnitDblConverter import UnitDblConverter
+
+ munits.registry[ str ] = StrConverter()
+ munits.registry[ Epoch ] = EpochConverter()
+ munits.registry[ UnitDbl ] = UnitDblConverter()
+ register_units()
+
+ # This essentially test to see if user specified labels get overwritten
+ # by the auto labeler functionality of the axes.
+ xdata = [ x*units.sec for x in range(10) ]
+ ydata1 = [ (1.5*y - 0.5)*units.km for y in range(10) ]
+ ydata2 = [ (1.75*y - 1.0)*units.km for y in range(10) ]
+
+ fig = pylab.figure()
+ ax = pylab.subplot( 111 )
+ ax.set_xlabel( "x-label 001" )
+ fig.savefig( 'formatter_ticker_001' )
+
+ ax.plot( xdata, ydata1, color='blue', xunits="sec" )
+ fig.savefig( 'formatter_ticker_002' )
+
+ ax.set_xlabel( "x-label 003" )
+ fig.savefig( 'formatter_ticker_003' )
+
+ ax.plot( xdata, ydata2, color='green', xunits="hour" )
+ ax.set_xlabel( "x-label 004" )
+ fig.savefig( 'formatter_ticker_004' )
+
+ # See SF bug 2846058
+ # https://sourceforge.net/tracker/?func=detail&aid=2846058&group_id=80706&atid=560720
+ ax.set_xlabel( "x-label 005" )
+ ax.autoscale_view()
+ fig.savefig( 'formatter_ticker_005' )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <as...@us...> - 2009年09月06日 23:14:57
Revision: 7665
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7665&view=rev
Author: astraw
Date: 2009年09月06日 22:46:00 +0000 (2009年9月06日)
Log Message:
-----------
testing: baseline images now in svn. specify image names without '.png'
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/testing/decorators.py
 trunk/matplotlib/lib/matplotlib/tests/test_spines.py
 trunk/matplotlib/setup.py
Modified: trunk/matplotlib/lib/matplotlib/testing/decorators.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/testing/decorators.py	2009年09月06日 22:45:48 UTC (rev 7664)
+++ trunk/matplotlib/lib/matplotlib/testing/decorators.py	2009年09月06日 22:46:00 UTC (rev 7665)
@@ -1,8 +1,8 @@
 from matplotlib.testing.noseclasses import KnownFailureTest, \
 KnownFailureDidNotFailTest, ImageComparisonFailure
-import sys
+import os, sys
 import nose
-from matplotlib.cbook import get_sample_data
+import matplotlib.tests
 from matplotlib.testing.compare import compare_images
 
 def knownfailureif(fail_condition, msg=None):
@@ -36,7 +36,7 @@
 return nose.tools.make_decorator(f)(failer)
 return known_fail_decorator
 
-def image_comparison(baseline_images=None, tol=1e-3):
+def image_comparison(baseline_images=None):
 """
 compare images generated by the test with those specified in
 *baseline_images*, which must correspond within tolerance *tol*,
@@ -49,10 +49,22 @@
 def compare_images_decorator(func):
 def decorated_compare_images(*args,**kwargs):
 result = func(*args,**kwargs)
+ extension = '.png' # TODO: test more backends
 for fname in baseline_images:
- actual = fname
- expected = get_sample_data('test_baseline_%s'%fname,
- asfileobj=False)
+ actual = fname + extension
+
+ # compute filename for baseline image
+ module_name = func.__module__
+ mods = module_name.split('.')
+ assert mods.pop(0)=='matplotlib'
+ assert mods.pop(0)=='tests'
+ subdir = '/'.join(mods)
+ basedir = os.path.dirname(matplotlib.tests.__file__)
+ baseline_dir = os.path.join(basedir,'baseline_images',subdir)
+ expected = os.path.join(baseline_dir,fname) + extension
+
+ # compare the images
+ tol=1e-3 # default tolerance
 err = compare_images( expected, actual, tol,
 in_decorator=True )
 if err:
Modified: trunk/matplotlib/lib/matplotlib/tests/test_spines.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_spines.py	2009年09月06日 22:45:48 UTC (rev 7664)
+++ trunk/matplotlib/lib/matplotlib/tests/test_spines.py	2009年09月06日 22:46:00 UTC (rev 7665)
@@ -3,7 +3,7 @@
 from matplotlib.testing.decorators import image_comparison
 import matplotlib.pyplot as plt
 
-@image_comparison(baseline_images=['spines_axes_positions.png'])
+@image_comparison(baseline_images=['spines_axes_positions'])
 def test_spines_axes_positions():
 # SF bug 2852168
 fig = plt.figure()
@@ -18,4 +18,4 @@
 ax.xaxis.set_ticks_position('top')
 ax.spines['left'].set_color('none')
 ax.spines['bottom'].set_color('none')
- fig.savefig('spines_axes_positions.png')
+ fig.savefig('spines_axes_positions')
Modified: trunk/matplotlib/setup.py
===================================================================
--- trunk/matplotlib/setup.py	2009年09月06日 22:45:48 UTC (rev 7664)
+++ trunk/matplotlib/setup.py	2009年09月06日 22:46:00 UTC (rev 7665)
@@ -101,6 +101,18 @@
 'backends/Matplotlib.nib/*',
 ]}
 
+if 1:
+ # TODO: exclude these when making release?
+ baseline_images = glob.glob(os.path.join('lib','matplotlib','tests',
+ 'baseline_images','*','*'))
+ def chop_package(fname):
+ badstr = os.path.join('lib','matplotlib','')
+ assert fname.startswith(badstr)
+ result = fname[ len(badstr): ]
+ return result
+ baseline_images = [chop_package(f) for f in baseline_images]
+ package_data['matplotlib'].extend(baseline_images)
+
 if not check_for_numpy():
 sys.exit(1)
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <as...@us...> - 2009年09月06日 23:14:46
Revision: 7664
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7664&view=rev
Author: astraw
Date: 2009年09月06日 22:45:48 +0000 (2009年9月06日)
Log Message:
-----------
testing: set backend to Agg only once
Modified Paths:
--------------
 trunk/matplotlib/doc/devel/coding_guide.rst
 trunk/matplotlib/lib/matplotlib/__init__.py
 trunk/matplotlib/lib/matplotlib/tests/test_spines.py
Modified: trunk/matplotlib/doc/devel/coding_guide.rst
===================================================================
--- trunk/matplotlib/doc/devel/coding_guide.rst	2009年09月06日 22:32:05 UTC (rev 7663)
+++ trunk/matplotlib/doc/devel/coding_guide.rst	2009年09月06日 22:45:48 UTC (rev 7664)
@@ -719,7 +719,6 @@
 
 import numpy as np
 import matplotlib
- matplotlib.use('Agg')
 from matplotlib.testing.decorators import image_comparison
 import matplotlib.pyplot as plt
 
Modified: trunk/matplotlib/lib/matplotlib/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/__init__.py	2009年09月06日 22:32:05 UTC (rev 7663)
+++ trunk/matplotlib/lib/matplotlib/__init__.py	2009年09月06日 22:45:48 UTC (rev 7664)
@@ -888,7 +888,7 @@
 import nose.plugins.builtin
 from testing.noseclasses import KnownFailure
 from nose.plugins.manager import PluginManager
-
+ use('Agg') # use Agg backend for these tests
 plugins = []
 plugins.append( KnownFailure() )
 plugins.extend( [plugin() for plugin in nose.plugins.builtin.plugins] )
Modified: trunk/matplotlib/lib/matplotlib/tests/test_spines.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_spines.py	2009年09月06日 22:32:05 UTC (rev 7663)
+++ trunk/matplotlib/lib/matplotlib/tests/test_spines.py	2009年09月06日 22:45:48 UTC (rev 7664)
@@ -1,6 +1,5 @@
 import numpy as np
 import matplotlib
-matplotlib.use('Agg')
 from matplotlib.testing.decorators import image_comparison
 import matplotlib.pyplot as plt
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <as...@us...> - 2009年09月06日 22:47:20
Revision: 7668
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7668&view=rev
Author: astraw
Date: 2009年09月06日 22:47:08 +0000 (2009年9月06日)
Log Message:
-----------
testing: convert some JPL units tests to simple nose tests
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/__init__.py
 trunk/matplotlib/lib/matplotlib/testing/jpl_units/UnitDblConverter.py
 trunk/matplotlib/lib/matplotlib/testing/jpl_units/__init__.py
 trunk/matplotlib/setup.py
Removed Paths:
-------------
 trunk/matplotlib/test/test_matplotlib/TestAxes.py
Modified: trunk/matplotlib/lib/matplotlib/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/__init__.py	2009年09月06日 22:46:52 UTC (rev 7667)
+++ trunk/matplotlib/lib/matplotlib/__init__.py	2009年09月06日 22:47:08 UTC (rev 7668)
@@ -879,6 +879,7 @@
 default_test_modules = [
 'matplotlib.tests.test_basic',
 'matplotlib.tests.test_transforms',
+ 'matplotlib.tests.test_axes',
 'matplotlib.tests.test_spines',
 ]
 
Modified: trunk/matplotlib/lib/matplotlib/testing/jpl_units/UnitDblConverter.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/testing/jpl_units/UnitDblConverter.py	2009年09月06日 22:46:52 UTC (rev 7667)
+++ trunk/matplotlib/lib/matplotlib/testing/jpl_units/UnitDblConverter.py	2009年09月06日 22:47:08 UTC (rev 7668)
@@ -66,7 +66,7 @@
 label information.
 """
 # Delay-load due to circular dependencies.
- import mplTest.units as U
+ import matplotlib.testing.jpl_units as U
 
 # Check to see if the value used for units is a string unit value
 # or an actual instance of a UnitDbl so that we can use the unit
@@ -105,7 +105,7 @@
 - Returns the value parameter converted to floats.
 """
 # Delay-load due to circular dependencies.
- import mplTest.units as U
+ import matplotlib.testing.jpl_units as U
 
 isNotUnitDbl = True
 
Modified: trunk/matplotlib/lib/matplotlib/testing/jpl_units/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/testing/jpl_units/__init__.py	2009年09月06日 22:46:52 UTC (rev 7667)
+++ trunk/matplotlib/lib/matplotlib/testing/jpl_units/__init__.py	2009年09月06日 22:47:08 UTC (rev 7668)
@@ -30,15 +30,15 @@
 """
 
 #=======================================================================
-from mplTest.units.Duration import Duration
-from mplTest.units.Epoch import Epoch
-from mplTest.units.UnitDbl import UnitDbl
+from Duration import Duration
+from Epoch import Epoch
+from UnitDbl import UnitDbl
 
-from mplTest.units.StrConverter import StrConverter
-from mplTest.units.EpochConverter import EpochConverter
-from mplTest.units.UnitDblConverter import UnitDblConverter
+from StrConverter import StrConverter
+from EpochConverter import EpochConverter
+from UnitDblConverter import UnitDblConverter
 
-from mplTest.units.UnitDblFormatter import UnitDblFormatter
+from UnitDblFormatter import UnitDblFormatter
 
 #=======================================================================
 
Modified: trunk/matplotlib/setup.py
===================================================================
--- trunk/matplotlib/setup.py	2009年09月06日 22:46:52 UTC (rev 7667)
+++ trunk/matplotlib/setup.py	2009年09月06日 22:47:08 UTC (rev 7668)
@@ -51,6 +51,7 @@
 'matplotlib.backends',
 'matplotlib.projections',
 'matplotlib.testing',
+ 'matplotlib.testing.jpl_units',
 'matplotlib.tests',
 # 'matplotlib.toolkits',
 'mpl_toolkits',
Deleted: trunk/matplotlib/test/test_matplotlib/TestAxes.py
===================================================================
--- trunk/matplotlib/test/test_matplotlib/TestAxes.py	2009年09月06日 22:46:52 UTC (rev 7667)
+++ trunk/matplotlib/test/test_matplotlib/TestAxes.py	2009年09月06日 22:47:08 UTC (rev 7668)
@@ -1,102 +0,0 @@
-#=======================================================================
-"""The Axes unit-test class implementation."""
-#=======================================================================
-
-from mplTest import MplTestCase, units
-from matplotlib.testing.decorators import knownfailureif
-
-#=======================================================================
-# Add import modules below.
-import matplotlib
-matplotlib.use( "Agg", warn = False )
-
-import pylab
-import numpy as npy
-from datetime import datetime
-#
-#=======================================================================
-
-#=======================================================================
-class TestAxes( MplTestCase ):
- """Test the various axes non-plotting methods."""
-
- # Uncomment any appropriate tags
- tags = [
- # 'gui', # requires the creation of a gui window
- 'agg', # uses agg in the backend
- 'agg-only', # uses only agg in the backend
- # 'wx', # uses wx in the backend
- # 'qt', # uses qt in the backend
- # 'ps', # uses the postscript backend
- # 'units', # uses units in the test
- 'PIL', # uses PIL for image comparison
- ]
-
- #--------------------------------------------------------------------
- def setUp( self ):
- """Setup any data needed for the unit test."""
- units.register()
-
- #--------------------------------------------------------------------
- def tearDown( self ):
- """Clean-up any generated files here."""
- pass
-
- #--------------------------------------------------------------------
- @knownfailureif('indeterminate', "Fails due to SF bug 2850075")
- def test_empty_datetime( self ):
- """Test plotting empty axes with dates along one axis."""
- fname = self.outFile( "empty_datetime.png" )
-
- t0 = datetime(2009, 1, 20)
- tf = datetime(2009, 1, 21)
-
- fig = pylab.figure()
- pylab.axvspan( t0, tf, facecolor="blue", alpha=0.25 )
- fig.autofmt_xdate()
-
- fig.savefig( fname )
- self.checkImage( fname )
-
- #--------------------------------------------------------------------
- def test_formatter_ticker( self ):
- """Test Some formatter and ticker issues."""
-
- # This essentially test to see if user specified labels get overwritten
- # by the auto labeler functionality of the axes.
- xdata = [ x*units.sec for x in range(10) ]
- ydata1 = [ (1.5*y - 0.5)*units.km for y in range(10) ]
- ydata2 = [ (1.75*y - 1.0)*units.km for y in range(10) ]
-
- fname = self.outFile( "formatter_ticker_001.png" )
- fig = pylab.figure()
- ax = pylab.subplot( 111 )
- ax.set_xlabel( "x-label 001" )
- fig.savefig( fname )
- self.checkImage( fname )
-
- fname = self.outFile( "formatter_ticker_002.png" )
- ax.plot( xdata, ydata1, color='blue', xunits="sec" )
- fig.savefig( fname )
- self.checkImage( fname )
-
- fname = self.outFile( "formatter_ticker_003.png" )
- ax.set_xlabel( "x-label 003" )
- fig.savefig( fname )
- self.checkImage( fname )
-
- fname = self.outFile( "formatter_ticker_004.png" )
- ax.plot( xdata, ydata2, color='green', xunits="hour" )
- ax.set_xlabel( "x-label 004" )
- fig.savefig( fname )
- self.checkImage( fname )
-
- # See SF bug 2846058
- # https://sourceforge.net/tracker/?func=detail&aid=2846058&group_id=80706&atid=560720
- fname = self.outFile( "formatter_ticker_005.png" )
- ax.set_xlabel( "x-label 005" )
- ax.autoscale_view()
- fig.savefig( fname )
- self.checkImage( fname )
-
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <as...@us...> - 2009年09月06日 22:47:02
Revision: 7667
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7667&view=rev
Author: astraw
Date: 2009年09月06日 22:46:52 +0000 (2009年9月06日)
Log Message:
-----------
testing: move baseline images
Added Paths:
-----------
 trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/
 trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/empty_datetime.png
 trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/formatter_ticker_001.png
 trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/formatter_ticker_002.png
 trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/formatter_ticker_003.png
 trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/formatter_ticker_004.png
 trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/formatter_ticker_005.png
Removed Paths:
-------------
 trunk/matplotlib/test/test_matplotlib/baseline/TestAxes/default_datetime.png
 trunk/matplotlib/test/test_matplotlib/baseline/TestAxes/empty_datetime.png
 trunk/matplotlib/test/test_matplotlib/baseline/TestAxes/formatter_ticker_001.png
 trunk/matplotlib/test/test_matplotlib/baseline/TestAxes/formatter_ticker_002.png
 trunk/matplotlib/test/test_matplotlib/baseline/TestAxes/formatter_ticker_003.png
 trunk/matplotlib/test/test_matplotlib/baseline/TestAxes/formatter_ticker_004.png
 trunk/matplotlib/test/test_matplotlib/baseline/TestAxes/formatter_ticker_005.png
Copied: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/empty_datetime.png (from rev 7666, trunk/matplotlib/test/test_matplotlib/baseline/TestAxes/empty_datetime.png)
===================================================================
(Binary files differ)
Copied: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/formatter_ticker_001.png (from rev 7666, trunk/matplotlib/test/test_matplotlib/baseline/TestAxes/formatter_ticker_001.png)
===================================================================
(Binary files differ)
Copied: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/formatter_ticker_002.png (from rev 7666, trunk/matplotlib/test/test_matplotlib/baseline/TestAxes/formatter_ticker_002.png)
===================================================================
(Binary files differ)
Copied: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/formatter_ticker_003.png (from rev 7666, trunk/matplotlib/test/test_matplotlib/baseline/TestAxes/formatter_ticker_003.png)
===================================================================
(Binary files differ)
Copied: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/formatter_ticker_004.png (from rev 7666, trunk/matplotlib/test/test_matplotlib/baseline/TestAxes/formatter_ticker_004.png)
===================================================================
(Binary files differ)
Copied: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/formatter_ticker_005.png (from rev 7666, trunk/matplotlib/test/test_matplotlib/baseline/TestAxes/formatter_ticker_005.png)
===================================================================
(Binary files differ)
Deleted: trunk/matplotlib/test/test_matplotlib/baseline/TestAxes/default_datetime.png
===================================================================
(Binary files differ)
Deleted: trunk/matplotlib/test/test_matplotlib/baseline/TestAxes/empty_datetime.png
===================================================================
(Binary files differ)
Deleted: trunk/matplotlib/test/test_matplotlib/baseline/TestAxes/formatter_ticker_001.png
===================================================================
(Binary files differ)
Deleted: trunk/matplotlib/test/test_matplotlib/baseline/TestAxes/formatter_ticker_002.png
===================================================================
(Binary files differ)
Deleted: trunk/matplotlib/test/test_matplotlib/baseline/TestAxes/formatter_ticker_003.png
===================================================================
(Binary files differ)
Deleted: trunk/matplotlib/test/test_matplotlib/baseline/TestAxes/formatter_ticker_004.png
===================================================================
(Binary files differ)
Deleted: trunk/matplotlib/test/test_matplotlib/baseline/TestAxes/formatter_ticker_005.png
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <as...@us...> - 2009年09月06日 22:46:41
Revision: 7666
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7666&view=rev
Author: astraw
Date: 2009年09月06日 22:46:27 +0000 (2009年9月06日)
Log Message:
-----------
testing: move test/mplTest/units to lib/matplotlib/testing/jpl_units
Added Paths:
-----------
 trunk/matplotlib/lib/matplotlib/testing/jpl_units/
 trunk/matplotlib/lib/matplotlib/testing/jpl_units/Duration.py
 trunk/matplotlib/lib/matplotlib/testing/jpl_units/Epoch.py
 trunk/matplotlib/lib/matplotlib/testing/jpl_units/EpochConverter.py
 trunk/matplotlib/lib/matplotlib/testing/jpl_units/StrConverter.py
 trunk/matplotlib/lib/matplotlib/testing/jpl_units/UnitDbl.py
 trunk/matplotlib/lib/matplotlib/testing/jpl_units/UnitDblConverter.py
 trunk/matplotlib/lib/matplotlib/testing/jpl_units/UnitDblFormatter.py
 trunk/matplotlib/lib/matplotlib/testing/jpl_units/__init__.py
Removed Paths:
-------------
 trunk/matplotlib/test/mplTest/units/Duration.py
 trunk/matplotlib/test/mplTest/units/Epoch.py
 trunk/matplotlib/test/mplTest/units/EpochConverter.py
 trunk/matplotlib/test/mplTest/units/StrConverter.py
 trunk/matplotlib/test/mplTest/units/UnitDbl.py
 trunk/matplotlib/test/mplTest/units/UnitDblConverter.py
 trunk/matplotlib/test/mplTest/units/UnitDblFormatter.py
 trunk/matplotlib/test/mplTest/units/__init__.py
Copied: trunk/matplotlib/lib/matplotlib/testing/jpl_units/Duration.py (from rev 7665, trunk/matplotlib/test/mplTest/units/Duration.py)
===================================================================
--- trunk/matplotlib/lib/matplotlib/testing/jpl_units/Duration.py	 (rev 0)
+++ trunk/matplotlib/lib/matplotlib/testing/jpl_units/Duration.py	2009年09月06日 22:46:27 UTC (rev 7666)
@@ -0,0 +1,203 @@
+#===========================================================================
+#
+# Duration
+#
+#===========================================================================
+
+"""Duration module."""
+
+#===========================================================================
+# Place all imports after here.
+#
+#
+# Place all imports before here.
+#===========================================================================
+
+#===========================================================================
+class Duration:
+ """Class Duration in development.
+ """
+ allowed = [ "ET", "UTC" ]
+ 
+ #-----------------------------------------------------------------------
+ def __init__( self, frame, seconds ):
+ """Create a new Duration object.
+ 
+ = ERROR CONDITIONS
+ - If the input frame is not in the allowed list, an error is thrown.
+
+ = INPUT VARIABLES
+ - frame The frame of the duration. Must be 'ET' or 'UTC'
+ - seconds The number of seconds in the Duration.
+ """
+ if frame not in self.allowed:
+ msg = "Input frame '%s' is not one of the supported frames of %s" \
+ % ( frame, str( self.allowed ) )
+ raise ValueError( msg )
+
+ self._frame = frame
+ self._seconds = seconds
+
+ #-----------------------------------------------------------------------
+ def frame( self ):
+ """Return the frame the duration is in."""
+ return self._frame
+
+ #-----------------------------------------------------------------------
+ def __abs__( self ):
+ """Return the absolute value of the duration."""
+ return Duration( self._frame, abs( self._seconds ) )
+ 
+ #-----------------------------------------------------------------------
+ def __neg__( self ):
+ """Return the negative value of this Duration."""
+ return Duration( self._frame, -self._seconds )
+ 
+ #-----------------------------------------------------------------------
+ def seconds( self ):
+ """Return the number of seconds in the Duration."""
+ return self._seconds
+
+ #-----------------------------------------------------------------------
+ def __nonzero__( self ):
+ """Compare two Durations.
+
+ = INPUT VARIABLES
+ - rhs The Duration to compare against.
+
+ = RETURN VALUE
+ - Returns -1 if self < rhs, 0 if self == rhs, +1 if self > rhs.
+ """
+ return self._seconds != 0
+ 
+ #-----------------------------------------------------------------------
+ def __cmp__( self, rhs ):
+ """Compare two Durations.
+
+ = ERROR CONDITIONS
+ - If the input rhs is not in the same frame, an error is thrown.
+
+ = INPUT VARIABLES
+ - rhs The Duration to compare against.
+
+ = RETURN VALUE
+ - Returns -1 if self < rhs, 0 if self == rhs, +1 if self > rhs.
+ """
+ self.checkSameFrame( rhs, "compare" )
+ return cmp( self._seconds, rhs._seconds )
+ 
+ #-----------------------------------------------------------------------
+ def __add__( self, rhs ):
+ """Add two Durations.
+
+ = ERROR CONDITIONS
+ - If the input rhs is not in the same frame, an error is thrown.
+
+ = INPUT VARIABLES
+ - rhs The Duration to add.
+
+ = RETURN VALUE
+ - Returns the sum of ourselves and the input Duration.
+ """
+ # Delay-load due to circular dependencies.
+ import mplTest.units as U
+
+ if isinstance( rhs, U.Epoch ):
+ return rhs + self
+ 
+ self.checkSameFrame( rhs, "add" )
+ return Duration( self._frame, self._seconds + rhs._seconds )
+ 
+ #-----------------------------------------------------------------------
+ def __sub__( self, rhs ):
+ """Subtract two Durations.
+
+ = ERROR CONDITIONS
+ - If the input rhs is not in the same frame, an error is thrown.
+
+ = INPUT VARIABLES
+ - rhs The Duration to subtract.
+
+ = RETURN VALUE
+ - Returns the difference of ourselves and the input Duration.
+ """
+ self.checkSameFrame( rhs, "sub" )
+ return Duration( self._frame, self._seconds - rhs._seconds )
+ 
+ #-----------------------------------------------------------------------
+ def __mul__( self, rhs ):
+ """Scale a UnitDbl by a value.
+
+ = INPUT VARIABLES
+ - rhs The scalar to multiply by.
+
+ = RETURN VALUE
+ - Returns the scaled Duration.
+ """
+ return Duration( self._frame, self._seconds * float( rhs ) )
+ 
+ #-----------------------------------------------------------------------
+ def __rmul__( self, lhs ):
+ """Scale a Duration by a value.
+
+ = INPUT VARIABLES
+ - lhs The scalar to multiply by.
+
+ = RETURN VALUE
+ - Returns the scaled Duration.
+ """
+ return Duration( self._frame, self._seconds * float( lhs ) )
+ 
+ #-----------------------------------------------------------------------
+ def __div__( self, rhs ):
+ """Divide a Duration by a value.
+
+ = INPUT VARIABLES
+ - rhs The scalar to divide by.
+
+ = RETURN VALUE
+ - Returns the scaled Duration.
+ """
+ return Duration( self._frame, self._seconds / float( rhs ) )
+ 
+ #-----------------------------------------------------------------------
+ def __rdiv__( self, rhs ):
+ """Divide a Duration by a value.
+
+ = INPUT VARIABLES
+ - rhs The scalar to divide by.
+
+ = RETURN VALUE
+ - Returns the scaled Duration.
+ """
+ return Duration( self._frame, float( rhs ) / self._seconds )
+ 
+ #-----------------------------------------------------------------------
+ def __str__( self ):
+ """Print the Duration."""
+ return "%g %s" % ( self._seconds, self._frame )
+ 
+ #-----------------------------------------------------------------------
+ def __repr__( self ):
+ """Print the Duration."""
+ return "Duration( '%s', %g )" % ( self._frame, self._seconds )
+ 
+ #-----------------------------------------------------------------------
+ def checkSameFrame( self, rhs, func ):
+ """Check to see if frames are the same.
+
+ = ERROR CONDITIONS
+ - If the frame of the rhs Duration is not the same as our frame,
+ an error is thrown.
+
+ = INPUT VARIABLES
+ - rhs The Duration to check for the same frame
+ - func The name of the function doing the check.
+ """
+ if self._frame != rhs._frame:
+ msg = "Cannot %s Duration's with different frames.\n" \
+ "LHS: %s\n" \
+ "RHS: %s" % ( func, self._frame, rhs._frame )
+ raise ValueError( msg )
+ 
+#===========================================================================
Copied: trunk/matplotlib/lib/matplotlib/testing/jpl_units/Epoch.py (from rev 7665, trunk/matplotlib/test/mplTest/units/Epoch.py)
===================================================================
--- trunk/matplotlib/lib/matplotlib/testing/jpl_units/Epoch.py	 (rev 0)
+++ trunk/matplotlib/lib/matplotlib/testing/jpl_units/Epoch.py	2009年09月06日 22:46:27 UTC (rev 7666)
@@ -0,0 +1,232 @@
+#===========================================================================
+#
+# Epoch
+#
+#===========================================================================
+
+"""Epoch module."""
+
+#===========================================================================
+# Place all imports after here.
+#
+import math
+import datetime as DT
+from matplotlib.dates import date2num
+#
+# Place all imports before here.
+#===========================================================================
+
+#===========================================================================
+class Epoch:
+ # Frame conversion offsets in seconds
+ # t(TO) = t(FROM) + allowed[ FROM ][ TO ]
+ allowed = {
+ "ET" : {
+ "UTC" : +64.1839,
+ },
+ "UTC" : {
+ "ET" : -64.1839,
+ },
+ }
+
+ #-----------------------------------------------------------------------
+ def __init__( self, frame, sec=None, jd=None, daynum=None, dt=None ):
+ """Create a new Epoch object.
+
+ Build an epoch 1 of 2 ways:
+
+ Using seconds past a Julian date:
+ # Epoch( 'ET', sec=1e8, jd=2451545 )
+
+ or using a matplotlib day number
+ # Epoch( 'ET', daynum=730119.5 )
+ 
+ 
+ = ERROR CONDITIONS
+ - If the input units are not in the allowed list, an error is thrown.
+
+ = INPUT VARIABLES
+ - frame The frame of the epoch. Must be 'ET' or 'UTC'
+ - sec The number of seconds past the input JD.
+ - jd The Julian date of the epoch.
+ - daynum The matplotlib day number of the epoch.
+ - dt A python datetime instance.
+ """
+ if ( ( sec is None and jd is not None ) or
+ ( sec is not None and jd is None ) or
+ ( daynum is not None and ( sec is not None or jd is not None ) ) or
+ ( daynum is None and dt is None and ( sec is None or jd is None ) ) or
+ ( daynum is not None and dt is not None ) or
+ ( dt is not None and ( sec is not None or jd is not None ) ) or
+ ( (dt is not None) and not isinstance(dt, DT.datetime) ) ):
+ msg = "Invalid inputs. Must enter sec and jd together, " \
+ "daynum by itself, or dt (must be a python datetime).\n" \
+ "Sec = %s\nJD = %s\ndnum= %s\ndt = %s" \
+ % ( str( sec ), str( jd ), str( daynum ), str( dt ) )
+ raise ValueError( msg )
+ 
+ if frame not in self.allowed:
+ msg = "Input frame '%s' is not one of the supported frames of %s" \
+ % ( frame, str( self.allowed.keys() ) )
+ raise ValueError( msg )
+
+ self._frame = frame
+
+ if dt is not None:
+ daynum = date2num( dt )
+
+ if daynum is not None:
+ # 1-JAN-0001 in JD = 1721425.5
+ jd = float( daynum ) + 1721425.5
+ self._jd = math.floor( jd )
+ self._seconds = ( jd - self._jd ) * 86400.0
+ 
+ else:
+ self._seconds = float( sec )
+ self._jd = float( jd )
+
+ # Resolve seconds down to [ 0, 86400 )
+ deltaDays = int( math.floor( self._seconds / 86400.0 ) )
+ self._jd += deltaDays
+ self._seconds -= deltaDays * 86400.0
+
+ #-----------------------------------------------------------------------
+ def convert( self, frame ):
+ if self._frame == frame:
+ return self
+
+ offset = self.allowed[ self._frame ][ frame ]
+
+ return Epoch( frame, self._seconds + offset, self._jd )
+
+ #-----------------------------------------------------------------------
+ def frame( self ):
+ return self._frame
+
+ #-----------------------------------------------------------------------
+ def julianDate( self, frame ):
+ t = self
+ if frame != self._frame:
+ t = self.convert( frame )
+
+ return t._jd + t._seconds / 86400.0
+ 
+ #-----------------------------------------------------------------------
+ def secondsPast( self, frame, jd ):
+ t = self
+ if frame != self._frame:
+ t = self.convert( frame )
+ 
+ delta = t._jd - jd
+ return t._seconds + delta * 86400
+
+ #-----------------------------------------------------------------------
+ def __cmp__( self, rhs ):
+ """Compare two Epoch's.
+
+ = INPUT VARIABLES
+ - rhs The Epoch to compare against.
+
+ = RETURN VALUE
+ - Returns -1 if self < rhs, 0 if self == rhs, +1 if self > rhs.
+ """
+ t = self
+ if self._frame != rhs._frame:
+ t = self.convert( rhs._frame )
+
+ if t._jd != rhs._jd:
+ return cmp( t._jd, rhs._jd )
+
+ return cmp( t._seconds, rhs._seconds )
+ 
+ #-----------------------------------------------------------------------
+ def __add__( self, rhs ):
+ """Add a duration to an Epoch.
+
+ = INPUT VARIABLES
+ - rhs The Epoch to subtract.
+
+ = RETURN VALUE
+ - Returns the difference of ourselves and the input Epoch.
+ """
+ t = self
+ if self._frame != rhs.frame():
+ t = self.convert( rhs._frame )
+
+ sec = t._seconds + rhs.seconds()
+
+ return Epoch( t._frame, sec, t._jd )
+ 
+ #-----------------------------------------------------------------------
+ def __sub__( self, rhs ):
+ """Subtract two Epoch's or a Duration from an Epoch.
+
+ Valid:
+ Duration = Epoch - Epoch
+ Epoch = Epoch - Duration
+
+ = INPUT VARIABLES
+ - rhs The Epoch to subtract.
+
+ = RETURN VALUE
+ - Returns either the duration between to Epoch's or the a new
+ Epoch that is the result of subtracting a duration from an epoch.
+ """
+ # Delay-load due to circular dependencies.
+ import mplTest.units as U
+
+ # Handle Epoch - Duration
+ if isinstance( rhs, U.Duration ):
+ return self + -rhs
+ 
+ t = self
+ if self._frame != rhs._frame:
+ t = self.convert( rhs._frame )
+
+ days = t._jd - rhs._jd
+ sec = t._seconds - rhs._seconds
+
+ return U.Duration( rhs._frame, days*86400 + sec )
+ 
+ #-----------------------------------------------------------------------
+ def __str__( self ):
+ """Print the Epoch."""
+ return "%22.15e %s" % ( self.julianDate( self._frame ), self._frame )
+ 
+ #-----------------------------------------------------------------------
+ def __repr__( self ):
+ """Print the Epoch."""
+ return str( self )
+ 
+ #-----------------------------------------------------------------------
+ def range( start, stop, step ):
+ """Generate a range of Epoch objects.
+
+ Similar to the Python range() method. Returns the range [
+ start, stop ) at the requested step. Each element will be a
+ Epoch object.
+ 
+ = INPUT VARIABLES
+ - start The starting value of the range. 
+ - stop The stop value of the range. 
+ - step Step to use. 
+ 
+ = RETURN VALUE
+ - Returns a list contianing the requested Epoch values.
+ """
+ elems = []
+
+ i = 0
+ while True:
+ d = start + i * step
+ if d >= stop:
+ break
+
+ elems.append( d )
+ i += 1
+
+ return elems
+
+ range = staticmethod( range )
+
+#===========================================================================
Copied: trunk/matplotlib/lib/matplotlib/testing/jpl_units/EpochConverter.py (from rev 7665, trunk/matplotlib/test/mplTest/units/EpochConverter.py)
===================================================================
--- trunk/matplotlib/lib/matplotlib/testing/jpl_units/EpochConverter.py	 (rev 0)
+++ trunk/matplotlib/lib/matplotlib/testing/jpl_units/EpochConverter.py	2009年09月06日 22:46:27 UTC (rev 7666)
@@ -0,0 +1,160 @@
+#===========================================================================
+#
+# EpochConverter
+#
+#===========================================================================
+
+"""EpochConverter module containing class EpochConverter."""
+
+#===========================================================================
+# Place all imports after here.
+#
+import matplotlib.units as units
+import matplotlib.dates as date_ticker
+from matplotlib.cbook import iterable
+#
+# Place all imports before here.
+#===========================================================================
+
+__all__ = [ 'EpochConverter' ]
+
+#===========================================================================
+class EpochConverter( units.ConversionInterface ):
+ """: A matplotlib converter class. Provides matplotlib conversion
+ functionality for Monte Epoch and Duration classes.
+ """
+
+ # julian date reference for "Jan 1, 0001" minus 1 day because
+ # matplotlib really wants "Jan 0, 0001"
+ jdRef = 1721425.5 - 1
+
+ #------------------------------------------------------------------------
+ @staticmethod
+ def axisinfo( unit, axis ):
+ """: Returns information on how to handle an axis that has Epoch data.
+
+ = INPUT VARIABLES
+ - unit The units to use for a axis with Epoch data.
+
+ = RETURN VALUE
+ - Returns a matplotlib AxisInfo data structure that contains
+ minor/major formatters, major/minor locators, and default
+ label information.
+ """
+
+ majloc = date_ticker.AutoDateLocator()
+ majfmt = date_ticker.AutoDateFormatter( majloc )
+
+ return units.AxisInfo( majloc = majloc,
+ majfmt = majfmt,
+ label = unit )
+
+ #------------------------------------------------------------------------
+ @staticmethod
+ def float2epoch( value, unit ):
+ """: Convert a matplotlib floating-point date into an Epoch of the
+ specified units.
+
+ = INPUT VARIABLES
+ - value The matplotlib floating-point date.
+ - unit The unit system to use for the Epoch.
+
+ = RETURN VALUE
+ - Returns the value converted to an Epoch in the sepcified time system.
+ """
+ # Delay-load due to circular dependencies.
+ import mplTest.units as U
+
+ secPastRef = value * 86400.0 * U.UnitDbl( 1.0, 'sec' )
+ return U.Epoch( unit, secPastRef, EpochConverter.jdRef )
+
+ #------------------------------------------------------------------------
+ @staticmethod
+ def epoch2float( value, unit ):
+ """: Convert an Epoch value to a float suitible for plotting as a
+ python datetime object.
+
+ = INPUT VARIABLES
+ - value An Epoch or list of Epochs that need to be converted.
+ - unit The units to use for an axis with Epoch data.
+
+ = RETURN VALUE
+ - Returns the value parameter converted to floats.
+ """
+ return value.julianDate( unit ) - EpochConverter.jdRef
+
+ #------------------------------------------------------------------------
+ @staticmethod
+ def duration2float( value ):
+ """: Convert a Duration value to a float suitible for plotting as a
+ python datetime object.
+
+ = INPUT VARIABLES
+ - value A Duration or list of Durations that need to be converted.
+
+ = RETURN VALUE
+ - Returns the value parameter converted to floats.
+ """
+ return value.days()
+
+ #------------------------------------------------------------------------
+ @staticmethod
+ def convert( value, unit, axis ):
+ """: Convert value using unit to a float. If value is a sequence, return
+ the converted sequence.
+
+ = INPUT VARIABLES
+ - value The value or list of values that need to be converted.
+ - unit The units to use for an axis with Epoch data.
+
+ = RETURN VALUE
+ - Returns the value parameter converted to floats.
+ """
+ # Delay-load due to circular dependencies.
+ import mplTest.units as U
+
+ isNotEpoch = True
+ isDuration = False
+
+ if ( iterable(value) and not isinstance(value, str) ):
+ if ( len(value) == 0 ):
+ return []
+ else:
+ return [ EpochConverter.convert( x, unit, axis ) for x in value ]
+
+ if ( isinstance(value, U.Epoch) ):
+ isNotEpoch = False
+ elif ( isinstance(value, U.Duration) ):
+ isDuration = True
+
+ if ( isNotEpoch and not isDuration and
+ units.ConversionInterface.is_numlike( value ) ):
+ return value
+
+ if ( unit == None ):
+ unit = EpochConverter.default_units( value, axis )
+
+ if ( isDuration ):
+ return EpochConverter.duration2float( value )
+ else:
+ return EpochConverter.epoch2float( value, unit )
+
+ #------------------------------------------------------------------------
+ @staticmethod
+ def default_units( value, axis ):
+ """: Return the default unit for value, or None.
+
+ = INPUT VARIABLES
+ - value The value or list of values that need units.
+
+ = RETURN VALUE
+ - Returns the default units to use for value.
+ """
+ frame = None
+ if ( iterable(value) and not isinstance(value, str) ):
+ return EpochConverter.default_units( value[0], axis )
+ else:
+ frame = value.frame()
+
+ return frame
+
Copied: trunk/matplotlib/lib/matplotlib/testing/jpl_units/StrConverter.py (from rev 7665, trunk/matplotlib/test/mplTest/units/StrConverter.py)
===================================================================
--- trunk/matplotlib/lib/matplotlib/testing/jpl_units/StrConverter.py	 (rev 0)
+++ trunk/matplotlib/lib/matplotlib/testing/jpl_units/StrConverter.py	2009年09月06日 22:46:27 UTC (rev 7666)
@@ -0,0 +1,158 @@
+#===========================================================================
+#
+# StrConverter
+#
+#===========================================================================
+
+"""StrConverter module containing class StrConverter."""
+
+#===========================================================================
+# Place all imports after here.
+#
+import matplotlib.units as units
+from matplotlib.cbook import iterable
+
+# Place all imports before here.
+#===========================================================================
+
+__all__ = [ 'StrConverter' ]
+
+#===========================================================================
+class StrConverter( units.ConversionInterface ):
+ """: A matplotlib converter class. Provides matplotlib conversion
+ functionality for string data values.
+
+ Valid units for string are:
+ - 'indexed' : Values are indexed as they are specified for plotting.
+ - 'sorted' : Values are sorted alphanumerically.
+ - 'inverted' : Values are inverted so that the first value is on top.
+ - 'sorted-inverted' : A combination of 'sorted' and 'inverted'
+ """
+
+ #------------------------------------------------------------------------
+ @staticmethod
+ def axisinfo( unit, axis ):
+ """: Returns information on how to handle an axis that has string data.
+
+ = INPUT VARIABLES
+ - axis The axis using this converter.
+ - unit The units to use for a axis with string data.
+
+ = RETURN VALUE
+ - Returns a matplotlib AxisInfo data structure that contains
+ minor/major formatters, major/minor locators, and default
+ label information.
+ """
+
+ return None
+
+ #------------------------------------------------------------------------
+ @staticmethod
+ def convert( value, unit, axis ):
+ """: Convert value using unit to a float. If value is a sequence, return
+ the converted sequence.
+
+ = INPUT VARIABLES
+ - axis The axis using this converter.
+ - value The value or list of values that need to be converted.
+ - unit The units to use for a axis with Epoch data.
+
+ = RETURN VALUE
+ - Returns the value parameter converted to floats.
+ """
+
+ if ( units.ConversionInterface.is_numlike( value ) ):
+ return value
+
+ if ( value == [] ):
+ return []
+
+ # we delay loading to make matplotlib happy
+ ax = axis.axes
+ if axis is ax.get_xaxis():
+ isXAxis = True
+ else:
+ isXAxis = False
+
+ axis.get_major_ticks()
+ ticks = axis.get_ticklocs()
+ labels = axis.get_ticklabels()
+
+ labels = [ l.get_text() for l in labels if l.get_text() ]
+
+ if ( not labels ):
+ ticks = [] 
+ labels = []
+
+
+ if ( not iterable( value ) ):
+ value = [ value ]
+
+ newValues = []
+ for v in value:
+ if ( (v not in labels) and (v not in newValues) ):
+ newValues.append( v )
+
+ for v in newValues:
+ if ( labels ):
+ labels.append( v )
+ else:
+ labels = [ v ]
+
+ #DISABLED: This is disabled because matplotlib bar plots do not
+ #DISABLED: recalculate the unit conversion of the data values
+ #DISABLED: this is due to design and is not really a bug.
+ #DISABLED: If this gets changed, then we can activate the following
+ #DISABLED: block of code. Note that this works for line plots.
+ #DISABLED if ( unit ):
+ #DISABLED if ( unit.find( "sorted" ) > -1 ):
+ #DISABLED labels.sort()
+ #DISABLED if ( unit.find( "inverted" ) > -1 ):
+ #DISABLED labels = labels[ ::-1 ]
+
+ # add padding (so they do not appear on the axes themselves)
+ labels = [ '' ] + labels + [ '' ]
+ ticks = range( len(labels) )
+ ticks[0] = 0.5
+ ticks[-1] = ticks[-1] - 0.5
+
+ axis.set_ticks( ticks )
+ axis.set_ticklabels( labels )
+ # we have to do the following lines to make ax.autoscale_view work
+ loc = axis.get_major_locator()
+ loc.set_bounds( ticks[0], ticks[-1] )
+
+ if ( isXAxis ):
+ ax.set_xlim( ticks[0], ticks[-1] )
+ else:
+ ax.set_ylim( ticks[0], ticks[-1] )
+
+ result = []
+ for v in value:
+ # If v is not in labels then something went wrong with adding new
+ # labels to the list of old labels.
+ errmsg = "This is due to a logic error in the StrConverter class. "
+ errmsg += "Please report this error and its message in bugzilla."
+ assert ( v in labels ), errmsg
+ result.append( ticks[ labels.index(v) ] )
+
+ ax.viewLim.ignore(-1)
+ return result
+
+ #------------------------------------------------------------------------
+ @staticmethod
+ def default_units( value, axis ):
+ """: Return the default unit for value, or None.
+
+ = INPUT VARIABLES
+ - axis The axis using this converter.
+ - value The value or list of values that need units.
+
+ = RETURN VALUE
+ - Returns the default units to use for value.
+ Return the default unit for value, or None.
+ """
+
+ # The default behavior for string indexing.
+ return "indexed"
+
Copied: trunk/matplotlib/lib/matplotlib/testing/jpl_units/UnitDbl.py (from rev 7665, trunk/matplotlib/test/mplTest/units/UnitDbl.py)
===================================================================
--- trunk/matplotlib/lib/matplotlib/testing/jpl_units/UnitDbl.py	 (rev 0)
+++ trunk/matplotlib/lib/matplotlib/testing/jpl_units/UnitDbl.py	2009年09月06日 22:46:27 UTC (rev 7666)
@@ -0,0 +1,287 @@
+#===========================================================================
+#
+# UnitDbl
+#
+#===========================================================================
+
+"""UnitDbl module."""
+
+#===========================================================================
+# Place all imports after here.
+#
+
+#
+# Place all imports before here.
+#===========================================================================
+
+
+#===========================================================================
+class UnitDbl:
+ """Class UnitDbl in development.
+ """
+ #-----------------------------------------------------------------------
+ # Unit conversion table. Small subset of the full one but enough
+ # to test the required functions. First field is a scale factor to
+ # convert the input units to the units of the second field. Only
+ # units in this table are allowed.
+ allowed = {
+ "m" : ( 0.001, "km" ),
+ "km" : ( 1, "km" ),
+ "mile" : ( 1.609344, "km" ),
+ 
+ "rad" : ( 1, "rad" ),
+ "deg" : ( 1.745329251994330e-02, "rad" ),
+
+ "sec" : ( 1, "sec" ),
+ "min" : ( 60.0, "sec" ),
+ "hour" : ( 3600, "sec" ),
+ }
+
+ _types = {
+ "km" : "distance",
+ "rad" : "angle",
+ "sec" : "time",
+ }
+
+ #-----------------------------------------------------------------------
+ def __init__( self, value, units ):
+ """Create a new UnitDbl object.
+ 
+ Units are internally converted to km, rad, and sec. The only
+ valid inputs for units are [ m, km, mile, rad, deg, sec, min, hour ].
+
+ The field UnitDbl.value will contain the converted value. Use
+ the convert() method to get a specific type of units back.
+ 
+ = ERROR CONDITIONS
+ - If the input units are not in the allowed list, an error is thrown.
+
+ = INPUT VARIABLES
+ - value The numeric value of the UnitDbl.
+ - units The string name of the units the value is in.
+ """
+ self.checkUnits( units )
+
+ data = self.allowed[ units ]
+ self._value = float( value * data[0] )
+ self._units = data[1]
+
+ #-----------------------------------------------------------------------
+ def convert( self, units ):
+ """Convert the UnitDbl to a specific set of units.
+
+ = ERROR CONDITIONS
+ - If the input units are not in the allowed list, an error is thrown.
+
+ = INPUT VARIABLES
+ - units The string name of the units to convert to.
+
+ = RETURN VALUE
+ - Returns the value of the UnitDbl in the requested units as a floating
+ point number.
+ """
+ if self._units == units:
+ return self._value
+ 
+ self.checkUnits( units )
+
+ data = self.allowed[ units ]
+ if self._units != data[1]:
+ msg = "Error trying to convert to different units.\n" \
+ " Invalid conversion requested.\n" \
+ " UnitDbl: %s\n" \
+ " Units: %s\n" % ( str( self ), units )
+ raise ValueError( msg )
+ 
+ return self._value / data[0]
+
+ #-----------------------------------------------------------------------
+ def __abs__( self ):
+ """Return the absolute value of this UnitDbl."""
+ return UnitDbl( abs( self._value ), self._units )
+ 
+ #-----------------------------------------------------------------------
+ def __neg__( self ):
+ """Return the negative value of this UnitDbl."""
+ return UnitDbl( -self._value, self._units )
+ 
+ #-----------------------------------------------------------------------
+ def __nonzero__( self ):
+ """Test a UnitDbl for a non-zero value.
+
+ = RETURN VALUE
+ - Returns true if the value is non-zero.
+ """
+ return self._value.__nonzero__()
+
+ #-----------------------------------------------------------------------
+ def __cmp__( self, rhs ):
+ """Compare two UnitDbl's.
+
+ = ERROR CONDITIONS
+ - If the input rhs units are not the same as our units,
+ an error is thrown.
+
+ = INPUT VARIABLES
+ - rhs The UnitDbl to compare against.
+
+ = RETURN VALUE
+ - Returns -1 if self < rhs, 0 if self == rhs, +1 if self > rhs.
+ """
+ self.checkSameUnits( rhs, "compare" )
+ return cmp( self._value, rhs._value )
+ 
+ #-----------------------------------------------------------------------
+ def __add__( self, rhs ):
+ """Add two UnitDbl's.
+
+ = ERROR CONDITIONS
+ - If the input rhs units are not the same as our units,
+ an error is thrown.
+
+ = INPUT VARIABLES
+ - rhs The UnitDbl to add.
+
+ = RETURN VALUE
+ - Returns the sum of ourselves and the input UnitDbl.
+ """
+ self.checkSameUnits( rhs, "add" )
+ return UnitDbl( self._value + rhs._value, self._units )
+ 
+ #-----------------------------------------------------------------------
+ def __sub__( self, rhs ):
+ """Subtract two UnitDbl's.
+
+ = ERROR CONDITIONS
+ - If the input rhs units are not the same as our units,
+ an error is thrown.
+
+ = INPUT VARIABLES
+ - rhs The UnitDbl to subtract.
+
+ = RETURN VALUE
+ - Returns the difference of ourselves and the input UnitDbl.
+ """
+ self.checkSameUnits( rhs, "subtract" )
+ return UnitDbl( self._value - rhs._value, self._units )
+ 
+ #-----------------------------------------------------------------------
+ def __mul__( self, rhs ):
+ """Scale a UnitDbl by a value.
+
+ = INPUT VARIABLES
+ - rhs The scalar to multiply by.
+
+ = RETURN VALUE
+ - Returns the scaled UnitDbl.
+ """
+ return UnitDbl( self._value * rhs, self._units )
+ 
+ #-----------------------------------------------------------------------
+ def __rmul__( self, lhs ):
+ """Scale a UnitDbl by a value.
+
+ = INPUT VARIABLES
+ - lhs The scalar to multiply by.
+
+ = RETURN VALUE
+ - Returns the scaled UnitDbl.
+ """
+ return UnitDbl( self._value * lhs, self._units )
+ 
+ #-----------------------------------------------------------------------
+ def __div__( self, rhs ):
+ """Divide a UnitDbl by a value.
+
+ = INPUT VARIABLES
+ - rhs The scalar to divide by.
+
+ = RETURN VALUE
+ - Returns the scaled UnitDbl.
+ """
+ return UnitDbl( self._value / rhs, self._units )
+ 
+ #-----------------------------------------------------------------------
+ def __str__( self ):
+ """Print the UnitDbl."""
+ return "%g *%s" % ( self._value, self._units )
+ 
+ #-----------------------------------------------------------------------
+ def __repr__( self ):
+ """Print the UnitDbl."""
+ return "UnitDbl( %g, '%s' )" % ( self._value, self._units )
+
+ #-----------------------------------------------------------------------
+ def type( self ):
+ """Return the type of UnitDbl data."""
+ return self._types[ self._units ]
+
+ #-----------------------------------------------------------------------
+ def range( start, stop, step=None ):
+ """Generate a range of UnitDbl objects.
+
+ Similar to the Python range() method. Returns the range [
+ start, stop ) at the requested step. Each element will be a
+ UnitDbl object.
+ 
+ = INPUT VARIABLES
+ - start The starting value of the range. 
+ - stop The stop value of the range. 
+ - step Optional step to use. If set to None, then a UnitDbl of
+ value 1 w/ the units of the start is used.
+ 
+ = RETURN VALUE
+ - Returns a list contianing the requested UnitDbl values.
+ """
+ if step is None:
+ step = UnitDbl( 1, start._units )
+ 
+ elems = []
+
+ i = 0
+ while True:
+ d = start + i * step
+ if d >= stop:
+ break
+
+ elems.append( d )
+ i += 1
+
+ return elems
+
+ range = staticmethod( range )
+
+ #-----------------------------------------------------------------------
+ def checkUnits( self, units ):
+ """Check to see if some units are valid.
+
+ = ERROR CONDITIONS
+ - If the input units are not in the allowed list, an error is thrown.
+
+ = INPUT VARIABLES
+ - units The string name of the units to check.
+ """
+ if units not in self.allowed.keys():
+ msg = "Input units '%s' are not one of the supported types of %s" \
+ % ( units, str( self.allowed.keys() ) )
+ raise ValueError( msg )
+
+ #-----------------------------------------------------------------------
+ def checkSameUnits( self, rhs, func ):
+ """Check to see if units are the same.
+
+ = ERROR CONDITIONS
+ - If the units of the rhs UnitDbl are not the same as our units,
+ an error is thrown.
+
+ = INPUT VARIABLES
+ - rhs The UnitDbl to check for the same units
+ - func The name of the function doing the check.
+ """
+ if self._units != rhs._units:
+ msg = "Cannot %s units of different types.\n" \
+ "LHS: %s\n" \
+ "RHS: %s" % ( func, self._units, rhs._units )
+ raise ValueError( msg )
+ 
+#===========================================================================
Copied: trunk/matplotlib/lib/matplotlib/testing/jpl_units/UnitDblConverter.py (from rev 7665, trunk/matplotlib/test/mplTest/units/UnitDblConverter.py)
===================================================================
--- trunk/matplotlib/lib/matplotlib/testing/jpl_units/UnitDblConverter.py	 (rev 0)
+++ trunk/matplotlib/lib/matplotlib/testing/jpl_units/UnitDblConverter.py	2009年09月06日 22:46:27 UTC (rev 7666)
@@ -0,0 +1,159 @@
+#===========================================================================
+#
+# UnitDblConverter
+#
+#===========================================================================
+
+"""UnitDblConverter module containing class UnitDblConverter."""
+
+#===========================================================================
+# Place all imports after here.
+#
+import numpy as np
+import matplotlib.units as units
+import matplotlib.ticker as ticker
+import matplotlib.projections.polar as polar
+from matplotlib.cbook import iterable
+#
+# Place all imports before here.
+#===========================================================================
+
+__all__ = [ 'UnitDblConverter' ]
+
+#===========================================================================
+
+# A special function for use with the matplotlib FuncFormatter class
+# for formatting axes with radian units.
+# This was copied from matplotlib example code.
+def rad_fn(x, pos = None ):
+ """Radian function formatter."""
+ n = int((x / np.pi) * 2.0 + 0.25)
+ if n == 0:
+ return str(x)
+ elif n == 1:
+ return r'$\pi/2$'
+ elif n == 2:
+ return r'$\pi$'
+ elif n % 2 == 0:
+ return r'$%s\pi$' % (n/2,)
+ else:
+ return r'$%s\pi/2$' % (n,)
+
+#===========================================================================
+class UnitDblConverter( units.ConversionInterface ):
+ """: A matplotlib converter class. Provides matplotlib conversion
+ functionality for the Monte UnitDbl class.
+ """
+
+ # default for plotting
+ defaults = {
+ "distance" : 'km',
+ "angle" : 'deg',
+ "time" : 'sec',
+ }
+
+ #------------------------------------------------------------------------
+ @staticmethod
+ def axisinfo( unit, axis ):
+ """: Returns information on how to handle an axis that has Epoch data.
+
+ = INPUT VARIABLES
+ - unit The units to use for a axis with Epoch data.
+
+ = RETURN VALUE
+ - Returns a matplotlib AxisInfo data structure that contains
+ minor/major formatters, major/minor locators, and default
+ label information.
+ """
+ # Delay-load due to circular dependencies.
+ import mplTest.units as U
+
+ # Check to see if the value used for units is a string unit value
+ # or an actual instance of a UnitDbl so that we can use the unit
+ # value for the default axis label value.
+ if ( unit ):
+ if ( isinstance( unit, str ) ):
+ label = unit
+ else:
+ label = unit.label()
+ else:
+ label = None
+
+ if ( label == "rad" ):
+ # If the axis units are in radians, then use a special function for
+ # applying format control.
+ majfmt = ticker.FuncFormatter( rad_fn )
+ elif ( label == "deg" ) and isinstance( axis.axes, polar.PolarAxes ):
+ # If we want degrees for a polar plot, use the PolarPlotFormatter
+ majfmt = polar.PolarAxes.ThetaFormatter()
+ else:
+ majfmt = U.UnitDblFormatter( useOffset = False )
+
+ return units.AxisInfo( majfmt = majfmt, label = label )
+
+ #------------------------------------------------------------------------
+ @staticmethod
+ def convert( value, unit, axis ):
+ """: Convert value using unit to a float. If value is a sequence, return
+ the converted sequence.
+
+ = INPUT VARIABLES
+ - value The value or list of values that need to be converted.
+ - unit The units to use for a axis with Epoch data.
+
+ = RETURN VALUE
+ - Returns the value parameter converted to floats.
+ """
+ # Delay-load due to circular dependencies.
+ import mplTest.units as U
+
+ isNotUnitDbl = True
+
+ if ( iterable(value) and not isinstance(value, str) ):
+ if ( len(value) == 0 ):
+ return []
+ else:
+ return [ UnitDblConverter.convert( x, unit, axis ) for x in value ]
+
+ # We need to check to see if the incoming value is actually a UnitDbl and
+ # set a flag. If we get an empty list, then just return an empty list.
+ if ( isinstance(value, U.UnitDbl) ):
+ isNotUnitDbl = False
+
+ # If the incoming value behaves like a number, but is not a UnitDbl,
+ # then just return it because we don't know how to convert it
+ # (or it is already converted)
+ if ( isNotUnitDbl and units.ConversionInterface.is_numlike( value ) ):
+ return value
+
+ # If no units were specified, then get the default units to use.
+ if ( unit == None ):
+ unit = UnitDblConverter.default_units( value, axis )
+
+ # Convert the incoming UnitDbl value/values to float/floats
+ if isinstance( axis.axes, polar.PolarAxes ) and (value.type() == "angle"):
+ # Guarantee that units are radians for polar plots.
+ return value.convert( "rad" )
+
+ return value.convert( unit )
+
+ #------------------------------------------------------------------------
+ @staticmethod
+ def default_units( value, axis ):
+ """: Return the default unit for value, or None.
+
+ = INPUT VARIABLES
+ - value The value or list of values that need units.
+
+ = RETURN VALUE
+ - Returns the default units to use for value.
+ Return the default unit for value, or None.
+ """
+
+ # Determine the default units based on the user preferences set for
+ # default units when printing a UnitDbl.
+ if ( iterable(value) and not isinstance(value, str) ):
+ return UnitDblConverter.default_units( value[0], axis )
+ else:
+ return UnitDblConverter.defaults[ value.type() ]
+
Copied: trunk/matplotlib/lib/matplotlib/testing/jpl_units/UnitDblFormatter.py (from rev 7665, trunk/matplotlib/test/mplTest/units/UnitDblFormatter.py)
===================================================================
--- trunk/matplotlib/lib/matplotlib/testing/jpl_units/UnitDblFormatter.py	 (rev 0)
+++ trunk/matplotlib/lib/matplotlib/testing/jpl_units/UnitDblFormatter.py	2009年09月06日 22:46:27 UTC (rev 7666)
@@ -0,0 +1,41 @@
+#===========================================================================
+#
+# UnitDblFormatter
+#
+#===========================================================================
+
+"""UnitDblFormatter module containing class UnitDblFormatter."""
+
+#===========================================================================
+# Place all imports after here.
+#
+import matplotlib.ticker as ticker
+#
+# Place all imports before here.
+#===========================================================================
+
+__all__ = [ 'UnitDblFormatter' ]
+
+#===========================================================================
+class UnitDblFormatter( ticker.ScalarFormatter ):
+ """The formatter for UnitDbl data types. This allows for formatting
+ with the unit string.
+ """
+ def __init__( self, *args, **kwargs ):
+ 'The arguments are identical to matplotlib.ticker.ScalarFormatter.'
+ ticker.ScalarFormatter.__init__( self, *args, **kwargs )
+
+ def __call__( self, x, pos = None ):
+ 'Return the format for tick val x at position pos'
+ if len(self.locs) == 0:
+ return ''
+ else:
+ return str(x)
+
+ def format_data_short( self, value ):
+ "Return the value formatted in 'short' format."
+ return str(value)
+
+ def format_data( self, value ):
+ "Return the value formatted into a string."
+ return str(value)
Copied: trunk/matplotlib/lib/matplotlib/testing/jpl_units/__init__.py (from rev 7665, trunk/matplotlib/test/mplTest/units/__init__.py)
===================================================================
--- trunk/matplotlib/lib/matplotlib/testing/jpl_units/__init__.py	 (rev 0)
+++ trunk/matplotlib/lib/matplotlib/testing/jpl_units/__init__.py	2009年09月06日 22:46:27 UTC (rev 7666)
@@ -0,0 +1,82 @@
+#=======================================================================
+"""
+This is a sample set of units for use with testing unit conversion
+of matplotlib routines. These are used because they use very strict
+enforcement of unitized data which will test the entire spectrum of how
+unitized data might be used (it is not always meaningful to convert to
+a float without specific units given). 
+
+UnitDbl is essentially a unitized floating point number. It has a
+minimal set of supported units (enough for testing purposes). All
+of the mathematical operation are provided to fully test any behaviour
+that might occur with unitized data. Remeber that unitized data has
+rules as to how it can be applied to one another (a value of distance
+cannot be added to a value of time). Thus we need to guard against any
+accidental "default" conversion that will strip away the meaning of the
+data and render it neutered.
+
+Epoch is different than a UnitDbl of time. Time is something that can be
+measured where an Epoch is a specific moment in time. Epochs are typically
+referenced as an offset from some predetermined epoch.
+
+A difference of two epochs is a Duration. The distinction between a
+Duration and a UnitDbl of time is made because an Epoch can have different
+frames (or units). In the case of our test Epoch class the two allowed
+frames are 'UTC' and 'ET' (Note that these are rough estimates provided for
+testing purposes and should not be used in production code where accuracy
+of time frames is desired). As such a Duration also has a frame of
+reference and therefore needs to be called out as different that a simple
+measurement of time since a delta-t in one frame may not be the same in another.
+"""
+
+#=======================================================================
+from mplTest.units.Duration import Duration
+from mplTest.units.Epoch import Epoch
+from mplTest.units.UnitDbl import UnitDbl
+
+from mplTest.units.StrConverter import StrConverter
+from mplTest.units.EpochConverter import EpochConverter
+from mplTest.units.UnitDblConverter import UnitDblConverter
+
+from mplTest.units.UnitDblFormatter import UnitDblFormatter
+
+#=======================================================================
+
+__version__ = "1.0"
+
+__all__ = [
+ 'register',
+ 'Duration',
+ 'Epoch',
+ 'UnitDbl',
+ 'UnitDblFormatter',
+ ]
+
+#=======================================================================
+def register():
+ """Register the unit conversion classes with matplotlib."""
+ import matplotlib.units as mplU
+
+ mplU.registry[ str ] = StrConverter()
+ mplU.registry[ Epoch ] = EpochConverter()
+ mplU.registry[ UnitDbl ] = UnitDblConverter()
+
+#=======================================================================
+# Some default unit instances
+
+# Distances
+m = UnitDbl( 1.0, "m" )
+km = UnitDbl( 1.0, "km" )
+mile = UnitDbl( 1.0, "mile" )
+
+# Angles
+deg = UnitDbl( 1.0, "deg" )
+rad = UnitDbl( 1.0, "rad" )
+
+# Time
+sec = UnitDbl( 1.0, "sec" )
+min = UnitDbl( 1.0, "min" )
+hr = UnitDbl( 1.0, "hour" )
+day = UnitDbl( 24.0, "hour" )
+sec = UnitDbl( 1.0, "sec" )
+
Deleted: trunk/matplotlib/test/mplTest/units/Duration.py
===================================================================
--- trunk/matplotlib/test/mplTest/units/Duration.py	2009年09月06日 22:46:00 UTC (rev 7665)
+++ trunk/matplotlib/test/mplTest/units/Duration.py	2009年09月06日 22:46:27 UTC (rev 7666)
@@ -1,203 +0,0 @@
-#===========================================================================
-#
-# Duration
-#
-#===========================================================================
-
-"""Duration module."""
-
-#===========================================================================
-# Place all imports after here.
-#
-#
-# Place all imports before here.
-#===========================================================================
-
-#===========================================================================
-class Duration:
- """Class Duration in development.
- """
- allowed = [ "ET", "UTC" ]
- 
- #-----------------------------------------------------------------------
- def __init__( self, frame, seconds ):
- """Create a new Duration object.
- 
- = ERROR CONDITIONS
- - If the input frame is not in the allowed list, an error is thrown.
-
- = INPUT VARIABLES
- - frame The frame of the duration. Must be 'ET' or 'UTC'
- - seconds The number of seconds in the Duration.
- """
- if frame not in self.allowed:
- msg = "Input frame '%s' is not one of the supported frames of %s" \
- % ( frame, str( self.allowed ) )
- raise ValueError( msg )
-
- self._frame = frame
- self._seconds = seconds
-
- #-----------------------------------------------------------------------
- def frame( self ):
- """Return the frame the duration is in."""
- return self._frame
-
- #-----------------------------------------------------------------------
- def __abs__( self ):
- """Return the absolute value of the duration."""
- return Duration( self._frame, abs( self._seconds ) )
- 
- #-----------------------------------------------------------------------
- def __neg__( self ):
- """Return the negative value of this Duration."""
- return Duration( self._frame, -self._seconds )
- 
- #-----------------------------------------------------------------------
- def seconds( self ):
- """Return the number of seconds in the Duration."""
- return self._seconds
-
- #-----------------------------------------------------------------------
- def __nonzero__( self ):
- """Compare two Durations.
-
- = INPUT VARIABLES
- - rhs The Duration to compare against.
-
- = RETURN VALUE
- - Returns -1 if self < rhs, 0 if self == rhs, +1 if self > rhs.
- """
- return self._seconds != 0
- 
- #-----------------------------------------------------------------------
- def __cmp__( self, rhs ):
- """Compare two Durations.
-
- = ERROR CONDITIONS
- - If the input rhs is not in the same frame, an error is thrown.
-
- = INPUT VARIABLES
- - rhs The Duration to compare against.
-
- = RETURN VALUE
- - Returns -1 if self < rhs, 0 if self == rhs, +1 if self > rhs.
- """
- self.checkSameFrame( rhs, "compare" )
- return cmp( self._seconds, rhs._seconds )
- 
- #-----------------------------------------------------------------------
- def __add__( self, rhs ):
- """Add two Durations.
-
- = ERROR CONDITIONS
- - If the input rhs is not in the same frame, an error is thrown.
-
- = INPUT VARIABLES
- - rhs The Duration to add.
-
- = RETURN VALUE
- - Returns the sum of ourselves and the input Duration.
- """
- # Delay-load due to circular dependencies.
- import mplTest.units as U
-
- if isinstance( rhs, U.Epoch ):
- return rhs + self
- 
- self.checkSameFrame( rhs, "add" )
- return Duration( self._frame, self._seconds + rhs._seconds )
- 
- #-----------------------------------------------------------------------
- def __sub__( self, rhs ):
- """Subtract two Durations.
-
- = ERROR CONDITIONS
- - If the input rhs is not in the same frame, an error is thrown.
-
- = INPUT VARIABLES
- - rhs The Duration to subtract.
-
- = RETURN VALUE
- - Returns the difference of ourselves and the input Duration.
- """
- self.checkSameFrame( rhs, "sub" )
- return Duration( self._frame, self._seconds - rhs._seconds )
- 
- #-----------------------------------------------------------------------
- def __mul__( self, rhs ):
- """Scale a UnitDbl by a value.
-
- = INPUT VARIABLES
- - rhs The scalar to multiply by.
-
- = RETURN VALUE
- - Returns the scaled Duration.
- """
- return Duration( self._frame, self._seconds * float( rhs ) )
- 
- #-----------------------------------------------------------------------
- def __rmul__( self, lhs ):
- """Scale a Duration by a value.
-
- = INPUT VARIABLES
- - lhs The scalar to multiply by.
-
- = RETURN VALUE
- - Returns the scaled Duration.
- """
- return Duration( self._frame, self._seconds * float( lhs ) )
- 
- #-----------------------------------------------------------------------
- def __div__( self, rhs ):
- """Divide a Duration by a value.
-
- = INPUT VARIABLES
- - rhs The scalar to divide by.
-
- = RETURN VALUE
- - Returns the scaled Duration.
- """
- return Duration( self._frame, self._seconds / float( rhs ) )
- 
- #-----------------------------------------------------------------------
- def __rdiv__( self, rhs ):
- """Divide a Duration by a value.
-
- = INPUT VARIABLES
- - rhs The scalar to divide by.
-
- = RETURN VALUE
- - Returns the scaled Duration.
- """
- return Duration( self._frame, float( rhs ) / self._seconds )
- 
- #-----------------------------------------------------------------------
- def __str__( self ):
- """Print the Duration."""
- return "%g %s" % ( self._seconds, self._frame )
- 
- #-----------------------------------------------------------------------
- def __repr__( self ):
- """Print the Duration."""
- return "Duration( '%s', %g )" % ( self._frame, self._seconds )
- 
- #-----------------------------------------------------------------------
- def checkSameFrame( self, rhs, func ):
- """Check to see if frames are the same.
-
- = ERROR CONDITIONS
- - If the frame of the rhs Duration is not the same as our frame,
- an error is thrown.
-
- = INPUT VARIABLES
- - rhs The Duration to check for the same frame
- - func The name of the function doing the check.
- """
- if self._frame != rhs._frame:
- msg = "Cannot %s Duration's with different frames.\n" \
- "LHS: %s\n" \
- "RHS: %s" % ( func, self._frame, rhs._frame )
- raise ValueError( msg )
- 
-#===========================================================================
Deleted: trunk/matplotlib/test/mplTest/units/Epoch.py
===================================================================
--- trunk/matplotlib/test/mplTest/units/Epoch.py	2009年09月06日 22:46:00 UTC (rev 7665)
+++ trunk/matplotlib/test/mplTest/units/Epoch.py	2009年09月06日 22:46:27 UTC (rev 7666)
@@ -1,232 +0,0 @@
-#===========================================================================
-#
-# Epoch
-#
-#===========================================================================
-
-"""Epoch module."""
-
-#===========================================================================
-# Place all imports after here.
-#
-import math
-import datetime as DT
-from matplotlib.dates import date2num
-#
-# Place all imports before here.
-#===========================================================================
-
-#===========================================================================
-class Epoch:
- # Frame conversion offsets in seconds
- # t(TO) = t(FROM) + allowed[ FROM ][ TO ]
- allowed = {
- "ET" : {
- "UTC" : +64.1839,
- },
- "UTC" : {
- "ET" : -64.1839,
- },
- }
-
- #-----------------------------------------------------------------------
- def __init__( self, frame, sec=None, jd=None, daynum=None, dt=None ):
- """Create a new Epoch object.
-
- Build an epoch 1 of 2 ways:
-
- Using seconds past a Julian date:
- # Epoch( 'ET', sec=1e8, jd=2451545 )
-
- or using a matplotlib day number
- # Epoch( 'ET', daynum=730119.5 )
- 
- 
- = ERROR CONDITIONS
- - If the input units are not in the allowed list, an error is thrown.
-
- = INPUT VARIABLES
- - frame The frame of the epoch. Must be 'ET' or 'UTC'
- - sec The number of seconds past the input JD.
- - jd The Julian date of the epoch.
- - daynum The matplotlib day number of the epoch.
- - dt A python datetime instance.
- """
- if ( ( sec is None and jd is not None ) or
- ( sec is not None and jd is None ) or
- ( daynum is not None and ( sec is not None or jd is not None ) ) or
- ( daynum is None and dt is None and ( sec is None or jd is None ) ) or
- ( daynum is not None and dt is not None ) or
- ( dt is not None and ( sec is not None or jd is not None ) ) or
- ( (dt is not None) and not isinstance(dt, DT.datetime) ) ):
- msg = "Invalid inputs. Must enter sec and jd together, " \
- "daynum by itself, or dt (must be a python datetime).\n" \
- "Sec = %s\nJD = %s\ndnum= %s\ndt = %s" \
- % ( str( sec ), str( jd ), str( daynum ), str( dt ) )
- raise ValueError( msg )
- 
- if frame not in self.allowed:
- msg = "Input frame '%s' is not one of the supported frames of %s" \
- % ( frame, str( self.allowed.keys() ) )
- raise ValueError( msg )
-
- self._frame = frame
-
- if dt is not None:
- daynum = date2num( dt )
-
- if daynum is not None:
- # 1-JAN-0001 in JD = 1721425.5
- jd = float( daynum ) + 1721425.5
- self._jd = math.floor( jd )
- self._seconds = ( jd - self._jd ) * 86400.0
- 
- else:
- self._seconds = float( sec )
- self._jd = float( jd )
-
- # Resolve seconds down to [ 0, 86400 )
- deltaDays = int( math.floor( self._seconds / 86400.0 ) )
- self._jd += deltaDays
- self._seconds -= deltaDays * 86400.0
-
- #-----------------------------------------------------------------------
- def convert( self, frame ):
- if self._frame == frame:
- return self
-
- offset = self.allowed[ self._frame ][ frame ]
-
- return Epoch( frame, self._seconds + of...
 
[truncated message content]
From: <as...@us...> - 2009年09月06日 22:32:20
Revision: 7663
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7663&view=rev
Author: astraw
Date: 2009年09月06日 22:32:05 +0000 (2009年9月06日)
Log Message:
-----------
testing: move baseline image
Added Paths:
-----------
 trunk/matplotlib/lib/matplotlib/tests/baseline_images/
 trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_spines/
 trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_spines/spines_axes_positions.png
Removed Paths:
-------------
 trunk/sample_data/test_baseline_spines_axes_positions.png
Copied: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_spines/spines_axes_positions.png (from rev 7640, trunk/sample_data/test_baseline_spines_axes_positions.png)
===================================================================
(Binary files differ)
Property changes on: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_spines/spines_axes_positions.png
___________________________________________________________________
Added: svn:mime-type
 + application/octet-stream
Added: svn:mergeinfo
 + 
Deleted: trunk/sample_data/test_baseline_spines_axes_positions.png
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 7662
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7662&view=rev
Author: jdh2358
Date: 2009年09月06日 21:55:38 +0000 (2009年9月06日)
Log Message:
-----------
fix the test_date images
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/tests/test_dates.py
Modified: trunk/matplotlib/lib/matplotlib/tests/test_dates.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_dates.py	2009年09月06日 21:16:27 UTC (rev 7661)
+++ trunk/matplotlib/lib/matplotlib/tests/test_dates.py	2009年09月06日 21:55:38 UTC (rev 7662)
@@ -1,19 +1,17 @@
 import datetime 
 import numpy as np
-import matplotlib
-matplotlib.use('Agg')
 from matplotlib.testing.decorators import image_comparison
 import matplotlib.pyplot as plt
 
-@image_comparison(baseline_images=['empty_datetime.png'])
-def test_empty_datetime():
+@image_comparison(baseline_images=['date_empty.png'])
+def test_date_empty():
 # make sure mpl does the right thing when told to plot dates even
 # if no date data has been presented, cf
 # http://sourceforge.net/tracker/?func=detail&aid=2850075&group_id=80706&atid=560720
 fig = plt.figure()
 ax = fig.add_subplot(1,1,1)
 ax.xaxis_date()
- fig.savefig('empty_datetime.png')
+ fig.savefig('date_empty.png')
 
 @image_comparison(baseline_images=['date_axhspan.png'])
 def test_date_axhspan():
@@ -23,9 +21,9 @@
 fig = plt.figure()
 ax = fig.add_subplot(1,1,1)
 ax.axhspan( t0, tf, facecolor="blue", alpha=0.25 )
- ax.set_xlim(t0-datetime.timedelta(days=5), 
+ ax.set_ylim(t0-datetime.timedelta(days=5), 
 tf+datetime.timedelta(days=5))
- fig.autofmt_xdate()
+ fig.subplots_adjust(left=0.25)
 fig.savefig('date_axhspan.png')
 
 @image_comparison(baseline_images=['date_axvspan.png'])
@@ -36,8 +34,8 @@
 fig = plt.figure()
 ax = fig.add_subplot(1,1,1)
 ax.axvspan( t0, tf, facecolor="blue", alpha=0.25 )
- ax.set_xlim(t0-datetime.timedelta(days=5), 
- tf+datetime.timedelta(days=5))
+ ax.set_xlim(t0-datetime.timedelta(days=720), 
+ tf+datetime.timedelta(days=720))
 fig.autofmt_xdate()
 fig.savefig('date_axvspan.png')
 
@@ -49,20 +47,20 @@
 tf = datetime.datetime(2009, 1, 31)
 fig = plt.figure()
 ax = fig.add_subplot(1,1,1)
- ax.axhline( t0, tf, facecolor="blue", lw=3)
- ax.set_xlim(t0-datetime.timedelta(days=5), 
+ ax.axhline( t0, color="blue", lw=3)
+ ax.set_ylim(t0-datetime.timedelta(days=5), 
 tf+datetime.timedelta(days=5))
- fig.autofmt_xdate()
+ fig.subplots_adjust(left=0.25)
 fig.savefig('date_axhline.png')
 
 @image_comparison(baseline_images=['date_axvline.png'])
 def test_date_axvline():
 # test ax hline with date inputs
 t0 = datetime.datetime(2000, 1, 20)
- tf = datetime.datetime(2010, 1, 21)
+ tf = datetime.datetime(2000, 1, 21)
 fig = plt.figure()
 ax = fig.add_subplot(1,1,1)
- ax.axvline( t0, tf, facecolor="blue", lw=3)
+ ax.axvline( t0, color="red", lw=3)
 ax.set_xlim(t0-datetime.timedelta(days=5), 
 tf+datetime.timedelta(days=5))
 fig.autofmt_xdate()
@@ -74,3 +72,4 @@
 nose.runmodule(argv=['-s','--with-doctest'], exit=False) 
 
 
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
From: <jd...@us...> - 2009年09月06日 21:16:40
Revision: 7661
 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7661&view=rev
Author: jdh2358
Date: 2009年09月06日 21:16:27 +0000 (2009年9月06日)
Log Message:
-----------
fix to empty datetime bug; add datetime tests
Modified Paths:
--------------
 trunk/matplotlib/lib/matplotlib/axes.py
 trunk/matplotlib/lib/matplotlib/axis.py
 trunk/matplotlib/lib/matplotlib/dates.py
 trunk/matplotlib/lib/matplotlib/transforms.py
 trunk/matplotlib/lib/matplotlib/units.py
Added Paths:
-----------
 trunk/matplotlib/lib/matplotlib/tests/test_dates.py
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py	2009年09月06日 20:13:36 UTC (rev 7660)
+++ trunk/matplotlib/lib/matplotlib/axes.py	2009年09月06日 21:16:27 UTC (rev 7661)
@@ -2299,74 +2299,19 @@
 
 *tz* is the time zone to use in labeling dates. Defaults to rc value.
 """
+ # should be enough to inform the unit conversion interface
+ # dates are comng in
+ self.xaxis.update_units(datetime.date(2009,1,1))
 
- xmin, xmax = self.dataLim.intervalx
- if xmin==0.:
- # no data has been added - let's set the default datalim.
- # We should probably use a better proxy for the datalim
- # have been updated than the ignore setting
- dmax = today = datetime.date.today()
- dmin = today-datetime.timedelta(days=10)
- self._process_unit_info(xdata=(dmin, dmax))
- dmin, dmax = self.convert_xunits([dmin, dmax])
- self.viewLim.intervalx = dmin, dmax
- self.dataLim.intervalx = dmin, dmax
-
- locator = self.xaxis.get_major_locator()
- if not isinstance(locator, mdates.DateLocator):
- locator = mdates.AutoDateLocator(tz)
- self.xaxis.set_major_locator(locator)
-
- # the autolocator uses the viewlim to pick the right date
- # locator, but it may not have correct viewlim before an
- # autoscale. If the viewlim is still zero..1, set it to the
- # datalim and the autoscaler will update it on request
- if self.viewLim.intervalx[0]==0.:
- self.viewLim.intervalx = tuple(self.dataLim.intervalx)
- locator.refresh()
-
- formatter = self.xaxis.get_major_formatter()
- if not isinstance(formatter, mdates.DateFormatter):
- formatter = mdates.AutoDateFormatter(locator, tz)
- self.xaxis.set_major_formatter(formatter)
-
 def yaxis_date(self, tz=None):
 """Sets up y-axis ticks and labels that treat the y data as dates.
 
 *tz* is the time zone to use in labeling dates. Defaults to rc value.
 """
- ymin, ymax = self.dataLim.intervaly
- if ymin==0.:
- # no data has been added - let's set the default datalim.
- # We should probably use a better proxy for the datalim
- # have been updated than the ignore setting
- dmax = today = datetime.date.today()
- dmin = today-datetime.timedelta(days=10)
- self._process_unit_info(ydata=(dmin, dmax))
+ # should be enough to inform the unit conversion interface
+ # dates are comng in
+ self.yaxis.update_units(datetime.date(2009,1,1))
 
- dmin, dmax = self.convert_yunits([dmin, dmax])
- self.viewLim.intervaly = dmin, dmax
- self.dataLim.intervaly = dmin, dmax
-
-
- locator = self.yaxis.get_major_locator()
- if not isinstance(locator, mdates.DateLocator):
- locator = mdates.AutoDateLocator(tz)
- self.yaxis.set_major_locator(locator)
-
- # the autolocator uses the viewlim to pick the right date
- # locator, but it may not have correct viewlim before an
- # autoscale. If the viewlim is still zero..1, set it to the
- # datalim and the autoscaler will update it on request
- if self.viewLim.intervaly[0]==0.:
- self.viewLim.intervaly = tuple(self.dataLim.intervaly)
- locator.refresh()
-
- formatter = self.xaxis.get_major_formatter()
- if not isinstance(formatter, mdates.DateFormatter):
- formatter = mdates.AutoDateFormatter(locator, tz)
- self.yaxis.set_major_formatter(formatter)
-
 def format_xdata(self, x):
 """
 Return *x* string formatted. This function will use the attribute
Modified: trunk/matplotlib/lib/matplotlib/axis.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axis.py	2009年09月06日 20:13:36 UTC (rev 7660)
+++ trunk/matplotlib/lib/matplotlib/axis.py	2009年09月06日 21:16:27 UTC (rev 7661)
@@ -666,6 +666,19 @@
 'Set the axis data limits'
 raise NotImplementedError('Derived must override')
 
+ def set_default_intervals(self):
+ 'set the default limits for the axis data and view interval if they are not mutated'
+
+ # this is mainly in support of custom object plotting. For
+ # example, if someone passes in a datetime object, we do not
+ # know automagically how to set the default min/max of the
+ # data and view limits. The unit conversion AxisInfo
+ # interface provides a hook for custom types to register
+ # default limits through the AxisInfo.default_limits
+ # attribute, and the derived code below will check for that
+ # and use it if is available (else just use 0..1)
+ pass
+
 def _set_artist_props(self, a):
 if a is None: return
 a.set_figure(self.figure)
@@ -1010,6 +1023,7 @@
 self.set_label_text(info.label)
 self.isDefault_label = True
 
+ self.set_default_intervals()
 
 def have_units(self):
 return self.converter is not None or self.units is not None
@@ -1420,6 +1434,25 @@
 self.axes.dataLim.intervalx = min(vmin, Vmin), max(vmax, Vmax)
 
 
+ def set_default_intervals(self):
+ 'set the default limits for the axis interval if they are not mutated'
+ xmin, xmax = 0., 1.
+ dataMutated = self.axes.dataLim.mutatedx()
+ viewMutated = self.axes.viewLim.mutatedx()
+ if not dataMutated or not viewMutated:
+ if self.converter is not None:
+ info = self.converter.axisinfo(self.units, self)
+ if info.default_limits is not None: 
+ valmin, valmax = info.default_limits
+ xmin = self.converter.convert(valmin, self.units, self)
+ xmax = self.converter.convert(valmax, self.units, self)
+ if not dataMutated:
+ self.axes.dataLim.intervalx = xmin, xmax
+ if not viewMutated:
+ self.axes.viewLim.intervalx = xmin, xmax
+
+ 
+
 class YAxis(Axis):
 __name__ = 'yaxis'
 axis_name = 'y'
@@ -1665,3 +1698,22 @@
 else:
 Vmin, Vmax = self.get_data_interval()
 self.axes.dataLim.intervaly = min(vmin, Vmin), max(vmax, Vmax)
+
+ def set_default_intervals(self):
+ 'set the default limits for the axis interval if they are not mutated'
+ ymin, ymax = 0., 1.
+ dataMutated = self.axes.dataLim.mutatedy()
+ viewMutated = self.axes.viewLim.mutatedy()
+ if not dataMutated or not viewMutated:
+ if self.converter is not None:
+ info = self.converter.axisinfo(self.units, self)
+ if info.default_limits is not None: 
+ valmin, valmax = info.default_limits
+ ymin = self.converter.convert(valmin, self.units, self)
+ ymax = self.converter.convert(valmax, self.units, self)
+ if not dataMutated:
+ self.axes.dataLim.intervaly = ymin, ymax
+ if not viewMutated:
+ self.axes.viewLim.intervaly = ymin, ymax
+
+ 
Modified: trunk/matplotlib/lib/matplotlib/dates.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/dates.py	2009年09月06日 20:13:36 UTC (rev 7660)
+++ trunk/matplotlib/lib/matplotlib/dates.py	2009年09月06日 21:16:27 UTC (rev 7661)
@@ -1062,42 +1062,15 @@
 def axisinfo(unit, axis):
 'return the unit AxisInfo'
 # make sure that the axis does not start at 0
- if axis:
- ax = axis.axes
 
- if axis is ax.get_xaxis():
- xmin, xmax = ax.dataLim.intervalx
- if xmin==0.:
- # no data has been added - let's set the default datalim.
- # We should probably use a better proxy for the datalim
- # have been updated than the ignore setting
- dmax = today = datetime.date.today()
- dmin = today-datetime.timedelta(days=10)
-
- ax._process_unit_info(xdata=(dmin, dmax))
- dmin, dmax = ax.convert_xunits([dmin, dmax])
-
- ax.viewLim.intervalx = dmin, dmax
- ax.dataLim.intervalx = dmin, dmax
- elif axis is ax.get_yaxis():
- ymin, ymax = ax.dataLim.intervaly
- if ymin==0.:
- # no data has been added - let's set the default datalim.
- # We should probably use a better proxy for the datalim
- # have been updated than the ignore setting
- dmax = today = datetime.date.today()
- dmin = today-datetime.timedelta(days=10)
-
- ax._process_unit_info(ydata=(dmin, dmax))
- dmin, dmax = ax.convert_yunits([dmin, dmax])
-
- ax.viewLim.intervaly = dmin, dmax
- ax.dataLim.intervaly = dmin, dmax
-
 majloc = AutoDateLocator(tz=unit)
 majfmt = AutoDateFormatter(majloc, tz=unit)
- return units.AxisInfo( majloc=majloc, majfmt=majfmt, label='' )
+ datemin = datetime.date(2000, 1, 1) 
+ datemax = datetime.date(2010, 1, 1) 
 
+ return units.AxisInfo( majloc=majloc, majfmt=majfmt, label='', 
+ default_limits=(datemin, datemax))
+
 @staticmethod
 def convert(value, unit, axis):
 if units.ConversionInterface.is_numlike(value): return value
Added: trunk/matplotlib/lib/matplotlib/tests/test_dates.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_dates.py	 (rev 0)
+++ trunk/matplotlib/lib/matplotlib/tests/test_dates.py	2009年09月06日 21:16:27 UTC (rev 7661)
@@ -0,0 +1,76 @@
+import datetime 
+import numpy as np
+import matplotlib
+matplotlib.use('Agg')
+from matplotlib.testing.decorators import image_comparison
+import matplotlib.pyplot as plt
+
+@image_comparison(baseline_images=['empty_datetime.png'])
+def test_empty_datetime():
+ # make sure mpl does the right thing when told to plot dates even
+ # if no date data has been presented, cf
+ # http://sourceforge.net/tracker/?func=detail&aid=2850075&group_id=80706&atid=560720
+ fig = plt.figure()
+ ax = fig.add_subplot(1,1,1)
+ ax.xaxis_date()
+ fig.savefig('empty_datetime.png')
+
+@image_comparison(baseline_images=['date_axhspan.png'])
+def test_date_axhspan():
+ # test ax hspan with date inputs
+ t0 = datetime.datetime(2009, 1, 20)
+ tf = datetime.datetime(2009, 1, 21)
+ fig = plt.figure()
+ ax = fig.add_subplot(1,1,1)
+ ax.axhspan( t0, tf, facecolor="blue", alpha=0.25 )
+ ax.set_xlim(t0-datetime.timedelta(days=5), 
+ tf+datetime.timedelta(days=5))
+ fig.autofmt_xdate()
+ fig.savefig('date_axhspan.png')
+
+@image_comparison(baseline_images=['date_axvspan.png'])
+def test_date_axvspan():
+ # test ax hspan with date inputs
+ t0 = datetime.datetime(2000, 1, 20)
+ tf = datetime.datetime(2010, 1, 21)
+ fig = plt.figure()
+ ax = fig.add_subplot(1,1,1)
+ ax.axvspan( t0, tf, facecolor="blue", alpha=0.25 )
+ ax.set_xlim(t0-datetime.timedelta(days=5), 
+ tf+datetime.timedelta(days=5))
+ fig.autofmt_xdate()
+ fig.savefig('date_axvspan.png')
+
+
+@image_comparison(baseline_images=['date_axhline.png'])
+def test_date_axhline():
+ # test ax hline with date inputs
+ t0 = datetime.datetime(2009, 1, 20)
+ tf = datetime.datetime(2009, 1, 31)
+ fig = plt.figure()
+ ax = fig.add_subplot(1,1,1)
+ ax.axhline( t0, tf, facecolor="blue", lw=3)
+ ax.set_xlim(t0-datetime.timedelta(days=5), 
+ tf+datetime.timedelta(days=5))
+ fig.autofmt_xdate()
+ fig.savefig('date_axhline.png')
+
+@image_comparison(baseline_images=['date_axvline.png'])
+def test_date_axvline():
+ # test ax hline with date inputs
+ t0 = datetime.datetime(2000, 1, 20)
+ tf = datetime.datetime(2010, 1, 21)
+ fig = plt.figure()
+ ax = fig.add_subplot(1,1,1)
+ ax.axvline( t0, tf, facecolor="blue", lw=3)
+ ax.set_xlim(t0-datetime.timedelta(days=5), 
+ tf+datetime.timedelta(days=5))
+ fig.autofmt_xdate()
+ fig.savefig('date_axvline.png')
+
+
+if __name__=='__main__':
+ import nose
+ nose.runmodule(argv=['-s','--with-doctest'], exit=False) 
+
+
Modified: trunk/matplotlib/lib/matplotlib/transforms.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/transforms.py	2009年09月06日 20:13:36 UTC (rev 7660)
+++ trunk/matplotlib/lib/matplotlib/transforms.py	2009年09月06日 21:16:27 UTC (rev 7661)
@@ -711,7 +711,10 @@
 self._points = np.asarray(points, np.float_)
 self._minpos = np.array([0.0000001, 0.0000001])
 self._ignore = True
-
+ # it is helpful in some contexts to know if the bbox is a
+ # default or has been mutated; we store the orig points to
+ # support the mutated methods
+ self._points_orig = self._points.copy()
 if DEBUG:
 ___init__ = __init__
 def __init__(self, points):
@@ -939,7 +942,22 @@
 self._points = other.get_points()
 self.invalidate()
 
+ def mutated(self):
+ 'return whether the bbox has changed since init'
+ return self.mutatedx() or self.mutatedy()
 
+ def mutatedx(self):
+ 'return whether the x-limits have changed since init'
+ return (self._points[0,0]!=self._points_orig[0,0] or
+ self._points[1,0]!=self._points_orig[1,0])
+ def mutatedy(self):
+ 'return whether the y-limits have changed since init'
+ return (self._points[0,1]!=self._points_orig[0,1] or
+ self._points[1,1]!=self._points_orig[1,1])
+
+
+ 
+
 class TransformedBbox(BboxBase):
 """
 A :class:`Bbox` that is automatically transformed by a given
Modified: trunk/matplotlib/lib/matplotlib/units.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/units.py	2009年09月06日 20:13:36 UTC (rev 7660)
+++ trunk/matplotlib/lib/matplotlib/units.py	2009年09月06日 21:16:27 UTC (rev 7661)
@@ -46,14 +46,15 @@
 from matplotlib.cbook import iterable, is_numlike, is_string_like
 
 class AxisInfo:
- 'information to support default axis labeling and tick labeling'
+ 'information to support default axis labeling and tick labeling, and default limits'
 def __init__(self, majloc=None, minloc=None,
- majfmt=None, minfmt=None, label=None):
+ majfmt=None, minfmt=None, label=None, 
+ default_limits=None):
 """
 majloc and minloc: TickLocators for the major and minor ticks
 majfmt and minfmt: TickFormatters for the major and minor ticks
 label: the default axis label
-
+ default_limits: the default min, max of the axis if no data is present
 If any of the above are None, the axis will simply use the default
 """
 self.majloc = majloc
@@ -61,6 +62,7 @@
 self.majfmt = majfmt
 self.minfmt = minfmt
 self.label = label
+ self.default_limits = default_limits
 
 
 class ConversionInterface:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Showing results of 214

<< < 1 .. 5 6 7 8 9 > >> (Page 7 of 9)
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 によって変換されたページ (->オリジナル) /