From: <ry...@us...> - 2009-08-31 17:42:47
|
Revision: 7619 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7619&view=rev Author: ryanmay Date: 2009-08-31 17:42:37 +0000 (Mon, 31 Aug 2009) Log Message: ----------- Merged revisions 7616-7618 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_99_maint ........ r7616 | ryanmay | 2009-08-31 12:27:12 -0500 (Mon, 31 Aug 2009) | 1 line Update barb_demo.py with an example using masked arrays. ........ r7617 | ryanmay | 2009-08-31 12:29:41 -0500 (Mon, 31 Aug 2009) | 1 line Pull _parse_args out of Quiver and Barbs classes, as we have multiple, diverging copies of the same code. Now the shared code will actually be shared. ........ r7618 | ryanmay | 2009-08-31 12:34:50 -0500 (Mon, 31 Aug 2009) | 1 line Use atleast_1d instead of asanyarray. This allows passing in scalars to quiver/barbs. ........ Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/barb_demo.py trunk/matplotlib/lib/matplotlib/quiver.py Property Changed: ---------------- trunk/matplotlib/ trunk/matplotlib/doc/pyplots/README trunk/matplotlib/doc/sphinxext/gen_gallery.py trunk/matplotlib/doc/sphinxext/gen_rst.py trunk/matplotlib/examples/misc/multiprocess.py trunk/matplotlib/examples/mplot3d/contour3d_demo.py trunk/matplotlib/examples/mplot3d/contourf3d_demo.py trunk/matplotlib/examples/mplot3d/polys3d_demo.py trunk/matplotlib/examples/mplot3d/scatter3d_demo.py trunk/matplotlib/examples/mplot3d/surface3d_demo.py trunk/matplotlib/examples/mplot3d/wire3d_demo.py trunk/matplotlib/lib/matplotlib/sphinxext/mathmpl.py trunk/matplotlib/lib/matplotlib/sphinxext/only_directives.py trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/mathtex:1-7263 /branches/v0_98_5_maint:1-7253 /branches/v0_99_maint:1-7607 + /branches/mathtex:1-7263 /branches/v0_98_5_maint:1-7253 /branches/v0_99_maint:1-7618 Modified: svn:mergeinfo - /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584 + /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 Property changes on: trunk/matplotlib/doc/pyplots/README ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/pyplots/README:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584 + /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/pyplots/README:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/sphinxext/gen_gallery.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584 + /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/sphinxext/gen_gallery.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 Property changes on: trunk/matplotlib/doc/sphinxext/gen_rst.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/sphinxext/gen_rst.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584 + /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/sphinxext/gen_rst.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 Property changes on: trunk/matplotlib/examples/misc/multiprocess.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/examples/misc/log.py:5753-5771 /branches/v0_98_5_maint/examples/misc/log.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/misc/multiprocess.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584 + /branches/v0_91_maint/examples/misc/log.py:5753-5771 /branches/v0_98_5_maint/examples/misc/log.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/misc/multiprocess.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 Property changes on: trunk/matplotlib/examples/mplot3d/contour3d_demo.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/examples/mplot3d/contour.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/contour.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/contour3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584 + /branches/v0_91_maint/examples/mplot3d/contour.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/contour.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/contour3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 Property changes on: trunk/matplotlib/examples/mplot3d/contourf3d_demo.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/examples/mplot3d/contourf.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/contourf.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/contourf3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584 + /branches/v0_91_maint/examples/mplot3d/contourf.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/contourf.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/contourf3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 Property changes on: trunk/matplotlib/examples/mplot3d/polys3d_demo.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/examples/mplot3d/polys.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/polys.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/polys3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584 + /branches/v0_91_maint/examples/mplot3d/polys.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/polys.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/polys3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 Property changes on: trunk/matplotlib/examples/mplot3d/scatter3d_demo.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/examples/mplot3d/scatter.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/scatter.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/scatter3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584 + /branches/v0_91_maint/examples/mplot3d/scatter.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/scatter.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/scatter3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 Property changes on: trunk/matplotlib/examples/mplot3d/surface3d_demo.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/examples/mplot3d/surface.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/surface.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/surface3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584 + /branches/v0_91_maint/examples/mplot3d/surface.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/surface.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/surface3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 Property changes on: trunk/matplotlib/examples/mplot3d/wire3d_demo.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/examples/mplot3d/wire.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/wire.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/wire3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584 + /branches/v0_91_maint/examples/mplot3d/wire.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/wire.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/wire3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 Modified: trunk/matplotlib/examples/pylab_examples/barb_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/barb_demo.py 2009-08-31 17:34:50 UTC (rev 7618) +++ trunk/matplotlib/examples/pylab_examples/barb_demo.py 2009-08-31 17:42:37 UTC (rev 7619) @@ -28,7 +28,7 @@ ax.barbs(data['x'], data['y'], data['u'], data['v'], length=8, pivot='middle') #Showing colormapping with uniform grid. Fill the circle for an empty barb, -#don't round the values, and change some of the size parameters +#don't round the values, and change some of the size parameters ax = plt.subplot(2,2,3) ax.barbs(X, Y, U, V, np.sqrt(U*U + V*V), fill_empty=True, rounding=False, sizes=dict(emptybarb=0.25, spacing=0.2, height=0.3)) @@ -39,4 +39,15 @@ barbcolor=['b','g'], barb_increments=dict(half=10, full=20, flag=100), flip_barb=True) +#Masked arrays are also supported +masked_u = np.ma.masked_array(data['u']) +masked_u[4] = 1000 #Bad value that should not be plotted when masked +masked_u[4] = np.ma.masked + +#Identical plot to panel 2 in the first figure, but with the point at +#(0.5, 0.25) missing (masked) +fig2 = plt.figure() +ax = fig2.add_subplot(1, 1, 1) +ax.barbs(data['x'], data['y'], masked_u, data['v'], length=8, pivot='middle') + plt.show() Modified: trunk/matplotlib/lib/matplotlib/quiver.py =================================================================== --- trunk/matplotlib/lib/matplotlib/quiver.py 2009-08-31 17:34:50 UTC (rev 7618) +++ trunk/matplotlib/lib/matplotlib/quiver.py 2009-08-31 17:42:37 UTC (rev 7619) @@ -325,6 +325,33 @@ quiverkey_doc = _quiverkey_doc +# This is a helper function that parses out the various combination of +# arguments for doing colored vector plots. Pulling it out here +# allows both Quiver and Barbs to use it +def _parse_args(*args): + X, Y, U, V, C = [None]*5 + args = list(args) + + # The use of atleast_1d allows for handling scalar arguments while also + # keeping masked arrays + if len(args) == 3 or len(args) == 5: + C = np.atleast_1d(args.pop(-1)) + V = np.atleast_1d(args.pop(-1)) + U = np.atleast_1d(args.pop(-1)) + if U.ndim == 1: + nr, nc = 1, U.shape[0] + else: + nr, nc = U.shape + if len(args) == 2: # remaining after removing U,V,C + X, Y = [np.array(a).ravel() for a in args] + if len(X) == nc and len(Y) == nr: + X, Y = [a.ravel() for a in np.meshgrid(X, Y)] + else: + indexgrid = np.meshgrid(np.arange(nc), np.arange(nr)) + X, Y = [np.ravel(a) for a in indexgrid] + return X, Y, U, V, C + + class Quiver(collections.PolyCollection): """ Specialized PolyCollection for arrows. @@ -351,7 +378,7 @@ by the following pylab interface documentation: %s""" self.ax = ax - X, Y, U, V, C = self._parse_args(*args) + X, Y, U, V, C = _parse_args(*args) self.X = X self.Y = Y self.XY = np.hstack((X[:,np.newaxis], Y[:,np.newaxis])) @@ -390,26 +417,6 @@ self.ax.figure.callbacks.connect('dpi_changed', on_dpi_change) - def _parse_args(self, *args): - X, Y, U, V, C = [None]*5 - args = list(args) - if len(args) == 3 or len(args) == 5: - C = np.asanyarray(args.pop(-1)) - V = np.asanyarray(args.pop(-1)) - U = np.asanyarray(args.pop(-1)) - if U.ndim == 1: - nr, nc = 1, U.shape[0] - else: - nr, nc = U.shape - if len(args) == 2: # remaining after removing U,V,C - X, Y = [np.array(a).ravel() for a in args] - if len(X) == nc and len(Y) == nr: - X, Y = [a.ravel() for a in np.meshgrid(X, Y)] - else: - indexgrid = np.meshgrid(np.arange(nc), np.arange(nr)) - X, Y = [np.ravel(a) for a in indexgrid] - return X, Y, U, V, C - def _init(self): """initialization delayed until first draw; allow time for axes setup. @@ -762,7 +769,7 @@ kw['facecolors'] = flagcolor #Parse out the data arrays from the various configurations supported - x, y, u, v, c = self._parse_args(*args) + x, y, u, v, c = _parse_args(*args) self.x = x self.y = y xy = np.hstack((x[:,np.newaxis], y[:,np.newaxis])) @@ -942,28 +949,6 @@ return barb_list - #Taken shamelessly from Quiver - def _parse_args(self, *args): - X, Y, U, V, C = [None]*5 - args = list(args) - if len(args) == 3 or len(args) == 5: - C = ma.masked_invalid(args.pop(-1), copy=False).ravel() - V = ma.masked_invalid(args.pop(-1), copy=False) - U = ma.masked_invalid(args.pop(-1), copy=False) - nn = np.shape(U) - nc = nn[0] - nr = 1 - if len(nn) > 1: - nr = nn[1] - if len(args) == 2: # remaining after removing U,V,C - X, Y = [np.array(a).ravel() for a in args] - if len(X) == nc and len(Y) == nr: - X, Y = [a.ravel() for a in np.meshgrid(X, Y)] - else: - indexgrid = np.meshgrid(np.arange(nc), np.arange(nr)) - X, Y = [np.ravel(a) for a in indexgrid] - return X, Y, U, V, C - def set_UVC(self, U, V, C=None): self.u = ma.masked_invalid(U, copy=False).ravel() self.v = ma.masked_invalid(V, copy=False).ravel() Property changes on: trunk/matplotlib/lib/matplotlib/sphinxext/mathmpl.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/sphinxext/mathmpl.py:5753-5771 /branches/v0_98_5_maint/lib/matplotlib/sphinxext/mathmpl.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/lib/matplotlib/sphinxext/mathmpl.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584 + /branches/v0_91_maint/doc/sphinxext/mathmpl.py:5753-5771 /branches/v0_98_5_maint/lib/matplotlib/sphinxext/mathmpl.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/lib/matplotlib/sphinxext/mathmpl.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 Property changes on: trunk/matplotlib/lib/matplotlib/sphinxext/only_directives.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/sphinxext/only_directives.py:5753-5771 /branches/v0_98_5_maint/lib/matplotlib/sphinxext/only_directives.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/lib/matplotlib/sphinxext/only_directives.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584 + /branches/v0_91_maint/doc/sphinxext/only_directives.py:5753-5771 /branches/v0_98_5_maint/lib/matplotlib/sphinxext/only_directives.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/lib/matplotlib/sphinxext/only_directives.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 Property changes on: trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/sphinxext/plot_directive.py:5753-5771 /branches/v0_98_5_maint/lib/matplotlib/sphinxext/plot_directive.py:6920-6925,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584 + /branches/v0_91_maint/doc/sphinxext/plot_directive.py:5753-5771 /branches/v0_98_5_maint/lib/matplotlib/sphinxext/plot_directive.py:6920-6925,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2009-08-31 20:10:45
|
Revision: 7621 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7621&view=rev Author: mdboom Date: 2009-08-31 20:10:35 +0000 (Mon, 31 Aug 2009) Log Message: ----------- Add "draw_gouraud_triangles" (note the 's') backend method. Add initial support in Pdf backend (working in xpdf and evince, but not in acroread, strangely). Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backend_bases.py trunk/matplotlib/lib/matplotlib/backends/backend_agg.py trunk/matplotlib/lib/matplotlib/backends/backend_mixed.py trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py trunk/matplotlib/lib/matplotlib/collections.py trunk/matplotlib/src/_backend_agg.cpp trunk/matplotlib/src/_backend_agg.h Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2009-08-31 19:50:13 UTC (rev 7620) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2009-08-31 20:10:35 UTC (rev 7621) @@ -170,10 +170,31 @@ """ Draw a Gouraud-shaded triangle. - EXPERIMENTAL + *points* is a 3x2 array of (x, y) points for the triangle. + + *colors* is a 3x4 array of RGBA colors for each point of the + triangle. + + *transform* is an affine transform to apply to the points. """ raise NotImplementedError + def draw_gouraud_triangles(self, gc, triangles_array, colors_array, + transform): + """ + Draws a series of Gouraud triangles. + + *points* is a Nx3x2 array of (x, y) points for the trianglex. + + *colors* is a Nx3x4 array of RGBA colors for each point of the + triangles. + + *transform* is an affine transform to apply to the points. + """ + transform = transform.frozen() + for tri, col in zip(triangles_array, colors_array): + self.draw_gouraud_triangle(gc, tri, col, transform) + def _iter_collection_raw_paths(self, master_transform, paths, all_transforms): """ @@ -410,7 +431,7 @@ def start_rasterizing(self): """ - Used in MixedModeRenderer. Switch to the raster renderer. + Used in MixedModeRenderer. Switch to the raster renderer. """ pass @@ -425,7 +446,7 @@ def start_filter(self): """ Used in AggRenderer. Switch to a temporary renderer for image - filtering effects. + filtering effects. """ pass Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2009-08-31 19:50:13 UTC (rev 7620) +++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2009-08-31 20:10:35 UTC (rev 7621) @@ -80,6 +80,7 @@ self.draw_path_collection = self._renderer.draw_path_collection self.draw_quad_mesh = self._renderer.draw_quad_mesh self.draw_gouraud_triangle = self._renderer.draw_gouraud_triangle + self.draw_gouraud_triangles = self._renderer.draw_gouraud_triangles self.draw_image = self._renderer.draw_image self.copy_from_bbox = self._renderer.copy_from_bbox self.tostring_rgba_minimized = self._renderer.tostring_rgba_minimized Modified: trunk/matplotlib/lib/matplotlib/backends/backend_mixed.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_mixed.py 2009-08-31 19:50:13 UTC (rev 7620) +++ trunk/matplotlib/lib/matplotlib/backends/backend_mixed.py 2009-08-31 20:10:35 UTC (rev 7621) @@ -58,7 +58,8 @@ finalize flipy get_canvas_width_height get_image_magnification get_texmanager get_text_width_height_descent new_gc open_group option_image_nocomposite points_to_pixels strip_math - start_filter stop_filter + start_filter stop_filter draw_gouraud_triangle + draw_gouraud_triangles """.split() def _set_current_renderer(self, renderer): self._renderer = renderer Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2009-08-31 19:50:13 UTC (rev 7620) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2009-08-31 20:10:35 UTC (rev 7621) @@ -17,6 +17,7 @@ from cStringIO import StringIO from datetime import datetime from math import ceil, cos, floor, pi, sin +import struct try: set except NameError: @@ -268,7 +269,7 @@ gsave='q', grestore='Q', textpos='Td', selectfont='Tf', textmatrix='Tm', show='Tj', showkern='TJ', - setlinewidth='w', clip='W') + setlinewidth='w', clip='W', shading='sh') Op = Bunch(**dict([(name, Operator(value)) for name, value in _pdfops.items()])) @@ -377,6 +378,7 @@ self.fontObject = self.reserveObject('fonts') self.alphaStateObject = self.reserveObject('extended graphics states') self.hatchObject = self.reserveObject('tiling patterns') + self.gouraudObject = self.reserveObject('Gouraud triangles') self.XObjectObject = self.reserveObject('external objects') self.resourceObject = self.reserveObject('resources') @@ -403,6 +405,7 @@ self.nextAlphaState = 1 self.hatchPatterns = {} self.nextHatch = 1 + self.gouraudTriangles = [] self.images = {} self.nextImage = 1 @@ -421,6 +424,7 @@ 'XObject': self.XObjectObject, 'ExtGState': self.alphaStateObject, 'Pattern': self.hatchObject, + 'Shading': self.gouraudObject, 'ProcSet': procsets } self.writeObject(self.resourceObject, resources) @@ -452,6 +456,7 @@ dict([(val[0], val[1]) for val in self.alphaStates.values()])) self.writeHatches() + self.writeGouraudTriangles() xobjects = dict(self.images.values()) for tup in self.markers.values(): xobjects[tup[0]] = tup[1] @@ -1050,6 +1055,44 @@ self.endStream() self.writeObject(self.hatchObject, hatchDict) + def addGouraudTriangles(self, points, colors): + name = Name('GT%d' % len(self.gouraudTriangles)) + self.gouraudTriangles.append((name, points, colors)) + return name + + def writeGouraudTriangles(self): + gouraudDict = dict() + for name, points, colors in self.gouraudTriangles: + ob = self.reserveObject('Gouraud triangle') + gouraudDict[name] = ob + shape = points.shape + flat_points = points.reshape((shape[0] * shape[1], 2)) + points_min = npy.min(flat_points, axis=0) - (1 << 8) + points_max = npy.max(flat_points, axis=0) + (1 << 8) + factor = float(0xffffffff) / (points_max - points_min) + adjpoints = npy.array((points - points_min) * factor, dtype=npy.uint32) + adjcolors = npy.array(colors * 255.0, dtype=npy.uint8) + + self.beginStream( + ob.id, None, + { 'ShadingType': 4, + 'BitsPerCoordinate': 32, + 'BitsPerComponent': 8, + 'BitsPerFlag': 8, + 'ColorSpace': Name('DeviceRGB'), + 'AntiAlias': 1, + 'Decode': [points_min[0], points_max[0], + points_min[1], points_max[1], + 0, 1, 0, 1, 0, 1] + }) + + for tpoints, tcolors in zip(adjpoints, adjcolors): + for p, c in zip(tpoints, tcolors): + values = [int(x) for x in [0] + list(p) + list(c[:3])] + self.write(struct.pack('>BLLBBB', *values)) + self.endStream() + self.writeObject(self.gouraudObject, gouraudDict) + def imageObject(self, image): """Return name of an image XObject representing the given image.""" @@ -1326,6 +1369,18 @@ lastx, lasty = x, y output(Op.grestore) + def draw_gouraud_triangle(self, gc, points, colors, trans): + self.draw_gouraud_triangles(gc, points.reshape((1, 3, 2)), + colors.reshape((1, 3, 4)), trans) + + def draw_gouraud_triangles(self, gc, points, colors, trans): + shape = points.shape + points = points.reshape((shape[0] * shape[1], 2)) + tpoints = trans.transform(points) + tpoints = tpoints.reshape(shape) + name = self.file.addGouraudTriangles(tpoints, colors) + self.file.output(name, Op.shading) + def _setup_textpos(self, x, y, descent, angle, oldx=0, oldy=0, olddescent=0, oldangle=0): if angle == oldangle == 0: self.file.output(x - oldx, (y + descent) - (oldy + olddescent), Op.textpos) Modified: trunk/matplotlib/lib/matplotlib/collections.py =================================================================== --- trunk/matplotlib/lib/matplotlib/collections.py 2009-08-31 19:50:13 UTC (rev 7620) +++ trunk/matplotlib/lib/matplotlib/collections.py 2009-08-31 20:10:35 UTC (rev 7621) @@ -1217,8 +1217,7 @@ triangles, colors = self.convert_mesh_to_triangles( self._meshWidth, self._meshHeight, coordinates) check = {} - for tri, col in zip(triangles, colors): - renderer.draw_gouraud_triangle(gc, tri, col, transform.frozen()) + renderer.draw_gouraud_triangles(gc, triangles, colors, transform.frozen()) else: renderer.draw_quad_mesh( gc, transform.frozen(), self._meshWidth, self._meshHeight, Modified: trunk/matplotlib/src/_backend_agg.cpp =================================================================== --- trunk/matplotlib/src/_backend_agg.cpp 2009-08-31 19:50:13 UTC (rev 7620) +++ trunk/matplotlib/src/_backend_agg.cpp 2009-08-31 20:10:35 UTC (rev 7621) @@ -1455,21 +1455,14 @@ return Py::Object(); } -Py::Object -RendererAgg::draw_gouraud_triangle(const Py::Tuple& args) { - _VERBOSE("RendererAgg::draw_quad_mesh"); - args.verify_length(4); +void +RendererAgg::_draw_gouraud_triangle(const GCAgg& gc, + const double* points, const double* colors, agg::trans_affine trans) { typedef agg::rgba8 color_t; typedef agg::span_gouraud_rgba<color_t> span_gen_t; typedef agg::span_allocator<color_t> span_alloc_t; - //segments, trans, clipbox, colors, linewidths, antialiaseds - GCAgg gc(args[0], dpi); - Py::Object points_obj = args[1]; - Py::Object colors_obj = args[2]; - agg::trans_affine trans = py_to_agg_transformation_matrix(args[3].ptr()); - theRasterizer.reset_clipping(); rendererBase.reset_clipping(true); set_clipbox(gc.cliprect, theRasterizer); @@ -1477,6 +1470,43 @@ trans *= agg::trans_affine_scaling(1.0, -1.0); trans *= agg::trans_affine_translation(0.0, (double)height); + double tpoints[6]; + + for (int i = 0; i < 6; i += 2) { + tpoints[i] = points[i]; + tpoints[i+1] = points[i+1]; + trans.transform(&tpoints[i], &tpoints[i+1]); + } + + span_alloc_t span_alloc; + span_gen_t span_gen; + + span_gen.colors( + agg::rgba(colors[0], colors[1], colors[2], colors[3]), + agg::rgba(colors[4], colors[5], colors[6], colors[7]), + agg::rgba(colors[8], colors[9], colors[10], colors[11])); + span_gen.triangle( + tpoints[0], tpoints[1], + tpoints[2], tpoints[3], + tpoints[4], tpoints[5], + 0.5); + + theRasterizer.add_path(span_gen); + agg::render_scanlines_aa( + theRasterizer, slineP8, rendererBase, span_alloc, span_gen); +} + +Py::Object +RendererAgg::draw_gouraud_triangle(const Py::Tuple& args) { + _VERBOSE("RendererAgg::draw_gouraud_triangle"); + args.verify_length(4); + + //segments, trans, clipbox, colors, linewidths, antialiaseds + GCAgg gc(args[0], dpi); + Py::Object points_obj = args[1]; + Py::Object colors_obj = args[2]; + agg::trans_affine trans = py_to_agg_transformation_matrix(args[3].ptr()); + PyArrayObject* points = (PyArrayObject*)PyArray_ContiguousFromAny (points_obj.ptr(), PyArray_DOUBLE, 2, 2); if (!points || @@ -1490,32 +1520,57 @@ throw Py::ValueError("colors must be a 3x4 numpy array"); try { - double* opoints = (double*)PyArray_DATA(points); - double* c = (double*)PyArray_DATA(colors); - double tpoints[6]; + _draw_gouraud_triangle( + gc, (double*)PyArray_DATA(points), (double*)PyArray_DATA(colors), trans); + } catch (...) { + Py_DECREF(points); + Py_DECREF(colors); - for (int i = 0; i < 6; i += 2) { - tpoints[i] = opoints[i]; - tpoints[i+1] = opoints[i+1]; - trans.transform(&tpoints[i], &tpoints[i+1]); - } + throw; + } - span_alloc_t span_alloc; - span_gen_t span_gen; + Py_DECREF(points); + Py_DECREF(colors); - span_gen.colors( - agg::rgba(c[0], c[1], c[2], c[3]), - agg::rgba(c[4], c[5], c[6], c[7]), - agg::rgba(c[8], c[9], c[10], c[11])); - span_gen.triangle( - tpoints[0], tpoints[1], - tpoints[2], tpoints[3], - tpoints[4], tpoints[5], - 0.5); + return Py::Object(); +} - theRasterizer.add_path(span_gen); - agg::render_scanlines_aa( - theRasterizer, slineP8, rendererBase, span_alloc, span_gen); +Py::Object +RendererAgg::draw_gouraud_triangles(const Py::Tuple& args) { + _VERBOSE("RendererAgg::draw_gouraud_triangles"); + args.verify_length(4); + + typedef agg::rgba8 color_t; + typedef agg::span_gouraud_rgba<color_t> span_gen_t; + typedef agg::span_allocator<color_t> span_alloc_t; + + //segments, trans, clipbox, colors, linewidths, antialiaseds + GCAgg gc(args[0], dpi); + Py::Object points_obj = args[1]; + Py::Object colors_obj = args[2]; + agg::trans_affine trans = py_to_agg_transformation_matrix(args[3].ptr()); + + PyArrayObject* points = (PyArrayObject*)PyArray_ContiguousFromAny + (points_obj.ptr(), PyArray_DOUBLE, 3, 3); + if (!points || + PyArray_DIM(points, 1) != 3 || PyArray_DIM(points, 2) != 2) + throw Py::ValueError("points must be a Nx3x2 numpy array"); + + PyArrayObject* colors = (PyArrayObject*)PyArray_ContiguousFromAny + (colors_obj.ptr(), PyArray_DOUBLE, 3, 3); + if (!colors || + PyArray_DIM(colors, 1) != 3 || PyArray_DIM(colors, 2) != 4) + throw Py::ValueError("colors must be a Nx3x4 numpy array"); + + if (PyArray_DIM(points, 0) != PyArray_DIM(colors, 0)) { + throw Py::ValueError("points and colors arrays must be the same length"); + } + + try { + for (int i = 0; i < PyArray_DIM(points, 0); ++i) { + _draw_gouraud_triangle( + gc, (double*)PyArray_GETPTR1(points, i), (double*)PyArray_GETPTR1(colors, i), trans); + } } catch (...) { Py_DECREF(points); Py_DECREF(colors); @@ -1870,6 +1925,8 @@ "draw_quad_mesh(gc, master_transform, meshWidth, meshHeight, coordinates, offsets, offsetTrans, facecolors, antialiaseds, showedges)\n"); add_varargs_method("draw_gouraud_triangle", &RendererAgg::draw_gouraud_triangle, "draw_gouraud_triangle(gc, points, colors, master_transform)\n"); + add_varargs_method("draw_gouraud_triangles", &RendererAgg::draw_gouraud_triangles, + "draw_gouraud_triangles(gc, points, colors, master_transform)\n"); add_varargs_method("draw_markers", &RendererAgg::draw_markers, "draw_markers(gc, marker_path, marker_trans, path, rgbFace)\n"); add_varargs_method("draw_text_image", &RendererAgg::draw_text_image, Modified: trunk/matplotlib/src/_backend_agg.h =================================================================== --- trunk/matplotlib/src/_backend_agg.h 2009-08-31 19:50:13 UTC (rev 7620) +++ trunk/matplotlib/src/_backend_agg.h 2009-08-31 20:10:35 UTC (rev 7621) @@ -165,6 +165,7 @@ Py::Object draw_path_collection(const Py::Tuple & args); Py::Object draw_quad_mesh(const Py::Tuple& args); Py::Object draw_gouraud_triangle(const Py::Tuple& args); + Py::Object draw_gouraud_triangles(const Py::Tuple& args); Py::Object write_rgba(const Py::Tuple & args); Py::Object tostring_rgb(const Py::Tuple & args); @@ -241,6 +242,11 @@ const Py::SeqBase<Py::Object>& linestyles_obj, const Py::SeqBase<Py::Int>& antialiaseds); + void + _draw_gouraud_triangle( + const GCAgg& gc, + const double* points, const double* colors, agg::trans_affine trans); + private: void create_alpha_buffers(); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lee...@us...> - 2009-09-04 04:12:27
|
Revision: 7634 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7634&view=rev Author: leejjoon Date: 2009-09-04 04:12:16 +0000 (Fri, 04 Sep 2009) Log Message: ----------- Merged revisions 7633 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_99_maint ........ r7633 | leejjoon | 2009-09-03 23:35:25 -0400 (Thu, 03 Sep 2009) | 1 line fix a bug in axes_grid.inset_locator.inset_axes ........ Modified Paths: -------------- trunk/matplotlib/lib/mpl_toolkits/axes_grid/inset_locator.py Property Changed: ---------------- trunk/matplotlib/ trunk/matplotlib/doc/pyplots/README trunk/matplotlib/doc/sphinxext/gen_gallery.py trunk/matplotlib/doc/sphinxext/gen_rst.py trunk/matplotlib/examples/misc/multiprocess.py trunk/matplotlib/examples/mplot3d/contour3d_demo.py trunk/matplotlib/examples/mplot3d/contourf3d_demo.py trunk/matplotlib/examples/mplot3d/polys3d_demo.py trunk/matplotlib/examples/mplot3d/scatter3d_demo.py trunk/matplotlib/examples/mplot3d/surface3d_demo.py trunk/matplotlib/examples/mplot3d/wire3d_demo.py trunk/matplotlib/lib/matplotlib/sphinxext/mathmpl.py trunk/matplotlib/lib/matplotlib/sphinxext/only_directives.py trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/mathtex:1-7263 /branches/v0_98_5_maint:1-7253 /branches/v0_99_maint:1-7618 + /branches/mathtex:1-7263 /branches/v0_99_maint:1-7633 /branches/v0_98_5_maint:1-7253 Modified: svn:mergeinfo - /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 + /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 Property changes on: trunk/matplotlib/doc/pyplots/README ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/pyplots/README:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 + /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/pyplots/README:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/sphinxext/gen_gallery.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 + /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/sphinxext/gen_gallery.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 Property changes on: trunk/matplotlib/doc/sphinxext/gen_rst.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/sphinxext/gen_rst.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 + /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/sphinxext/gen_rst.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 Property changes on: trunk/matplotlib/examples/misc/multiprocess.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/examples/misc/log.py:5753-5771 /branches/v0_98_5_maint/examples/misc/log.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/misc/multiprocess.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 + /branches/v0_91_maint/examples/misc/log.py:5753-5771 /branches/v0_98_5_maint/examples/misc/log.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/misc/multiprocess.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 Property changes on: trunk/matplotlib/examples/mplot3d/contour3d_demo.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/examples/mplot3d/contour.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/contour.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/contour3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 + /branches/v0_91_maint/examples/mplot3d/contour.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/contour.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/contour3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 Property changes on: trunk/matplotlib/examples/mplot3d/contourf3d_demo.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/examples/mplot3d/contourf.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/contourf.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/contourf3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 + /branches/v0_91_maint/examples/mplot3d/contourf.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/contourf.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/contourf3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 Property changes on: trunk/matplotlib/examples/mplot3d/polys3d_demo.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/examples/mplot3d/polys.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/polys.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/polys3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 + /branches/v0_91_maint/examples/mplot3d/polys.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/polys.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/polys3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 Property changes on: trunk/matplotlib/examples/mplot3d/scatter3d_demo.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/examples/mplot3d/scatter.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/scatter.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/scatter3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 + /branches/v0_91_maint/examples/mplot3d/scatter.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/scatter.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/scatter3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 Property changes on: trunk/matplotlib/examples/mplot3d/surface3d_demo.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/examples/mplot3d/surface.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/surface.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/surface3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 + /branches/v0_91_maint/examples/mplot3d/surface.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/surface.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/surface3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 Property changes on: trunk/matplotlib/examples/mplot3d/wire3d_demo.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/examples/mplot3d/wire.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/wire.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/wire3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 + /branches/v0_91_maint/examples/mplot3d/wire.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/wire.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/wire3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 Property changes on: trunk/matplotlib/lib/matplotlib/sphinxext/mathmpl.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/sphinxext/mathmpl.py:5753-5771 /branches/v0_98_5_maint/lib/matplotlib/sphinxext/mathmpl.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/lib/matplotlib/sphinxext/mathmpl.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 + /branches/v0_91_maint/doc/sphinxext/mathmpl.py:5753-5771 /branches/v0_98_5_maint/lib/matplotlib/sphinxext/mathmpl.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/lib/matplotlib/sphinxext/mathmpl.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 Property changes on: trunk/matplotlib/lib/matplotlib/sphinxext/only_directives.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/sphinxext/only_directives.py:5753-5771 /branches/v0_98_5_maint/lib/matplotlib/sphinxext/only_directives.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/lib/matplotlib/sphinxext/only_directives.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 + /branches/v0_91_maint/doc/sphinxext/only_directives.py:5753-5771 /branches/v0_98_5_maint/lib/matplotlib/sphinxext/only_directives.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/lib/matplotlib/sphinxext/only_directives.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 Property changes on: trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/sphinxext/plot_directive.py:5753-5771 /branches/v0_98_5_maint/lib/matplotlib/sphinxext/plot_directive.py:6920-6925,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618 + /branches/v0_91_maint/doc/sphinxext/plot_directive.py:5753-5771 /branches/v0_98_5_maint/lib/matplotlib/sphinxext/plot_directive.py:6920-6925,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 Modified: trunk/matplotlib/lib/mpl_toolkits/axes_grid/inset_locator.py =================================================================== --- trunk/matplotlib/lib/mpl_toolkits/axes_grid/inset_locator.py 2009-09-04 03:35:25 UTC (rev 7633) +++ trunk/matplotlib/lib/mpl_toolkits/axes_grid/inset_locator.py 2009-09-04 04:12:16 UTC (rev 7634) @@ -271,10 +271,10 @@ axes_class = Axes if axes_kwargs is None: - inset_axes = Axes(parent_axes.figure, parent_axes.get_position()) + inset_axes = axes_class(parent_axes.figure, parent_axes.get_position()) else: - inset_axes = Axes(parent_axes.figure, parent_axes.get_position(), - **axes_kwargs) + inset_axes = axes_class(parent_axes.figure, parent_axes.get_position(), + **axes_kwargs) axes_locator = AnchoredSizeLocator(parent_axes.bbox, width, height, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lee...@us...> - 2009-09-04 19:11:12
|
Revision: 7635 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7635&view=rev Author: leejjoon Date: 2009-09-04 19:11:00 +0000 (Fri, 04 Sep 2009) Log Message: ----------- textpath support mathtext and tex Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/examples/pylab_examples/demo_text_path.py trunk/matplotlib/lib/matplotlib/mathtext.py trunk/matplotlib/lib/matplotlib/text.py trunk/matplotlib/src/ft2font.cpp trunk/matplotlib/src/ft2font.h Added Paths: ----------- trunk/matplotlib/lib/matplotlib/textpath.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2009-09-04 04:12:16 UTC (rev 7634) +++ trunk/matplotlib/CHANGELOG 2009-09-04 19:11:00 UTC (rev 7635) @@ -1,3 +1,6 @@ +2009-09-04 Make the textpath class as a separate moduel + (textpath.py). Add support for mathtext and tex.- JJL + 2009-09-01 Added support for Gouraud interpolated triangles. pcolormesh now accepts shading='gouraud' as an option. - MGD Modified: trunk/matplotlib/examples/pylab_examples/demo_text_path.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/demo_text_path.py 2009-09-04 04:12:16 UTC (rev 7634) +++ trunk/matplotlib/examples/pylab_examples/demo_text_path.py 2009-09-04 19:11:00 UTC (rev 7635) @@ -76,23 +76,52 @@ # make anchored offset box ao = AnchoredOffsetbox(loc=2, child=offsetbox, frameon=True, borderpad=0.2) - ax.add_artist(ao) + # another text + from matplotlib.patches import PathPatch + text_path = TextPath((0, 0), r"\mbox{textpath supports mathtext \& \TeX}", + size=20, usetex=True) + p1 = PathPatch(text_path, ec="w", lw=3, fc="w", alpha=0.9, + transform=IdentityTransform()) + p2 = PathPatch(text_path, ec="none", fc="k", + transform=IdentityTransform()) + offsetbox2 = AuxTransformBox(IdentityTransform()) + offsetbox2.add_artist(p1) + offsetbox2.add_artist(p2) + ab = AnnotationBbox(offsetbox2, (0.95, 0.05), + xycoords='axes fraction', + boxcoords="offset points", + box_alignment=(1.,0.), + frameon=False + ) + ax.add_artist(ab) + + ax.imshow([[0,1,2],[1,2,3]], cmap=plt.cm.gist_gray_r, + interpolation="bilinear", + aspect="auto") + + + # EXAMPLE 2 ax = plt.subplot(212) arr = np.arange(256).reshape(1,256)/256. - text_path = TextPath((0, 0), "TextPath", size=70) + usetex = plt.rcParams["text.usetex"] + if usetex: + s = r"$\displaystyle\left[\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}\right]$!" + else: + s = r"$\left[\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}\right]$!" + text_path = TextPath((0, 0), s, size=40, usetex=usetex) text_patch = PathClippedImagePatch(text_path, arr, ec="none", transform=IdentityTransform()) - shadow1 = mpatches.Shadow(text_patch, 3, -2, props=dict(fc="none", ec="0.6", lw=3)) - shadow2 = mpatches.Shadow(text_patch, 3, -2, props=dict(fc="0.3", ec="none")) + shadow1 = mpatches.Shadow(text_patch, 1, -1, props=dict(fc="none", ec="0.6", lw=3)) + shadow2 = mpatches.Shadow(text_patch, 1, -1, props=dict(fc="0.3", ec="none")) # make offset box Modified: trunk/matplotlib/lib/matplotlib/mathtext.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mathtext.py 2009-09-04 04:12:16 UTC (rev 7634) +++ trunk/matplotlib/lib/matplotlib/mathtext.py 2009-09-04 19:11:00 UTC (rev 7635) @@ -336,6 +336,34 @@ svg_elements, self.fonts_object.get_used_characters()) +class MathtextBackendPath(MathtextBackend): + """ + Store information to write a mathtext rendering to the Cairo + backend. + """ + + def __init__(self): + self.glyphs = [] + self.rects = [] + + def render_glyph(self, ox, oy, info): + oy = self.height - oy + info.offset + thetext = unichr(info.num) + self.glyphs.append( + (info.font, info.fontsize, thetext, ox, oy)) + + def render_rect_filled(self, x1, y1, x2, y2): + self.rects.append( + (x1, self.height-y2 , x2 - x1, y2 - y1)) + + def get_results(self, box): + ship(0, -self.depth, box) + return (self.width, + self.height + self.depth, + self.depth, + self.glyphs, + self.rects) + class MathtextBackendCairo(MathtextBackend): """ Store information to write a mathtext rendering to the Cairo @@ -2751,6 +2779,7 @@ 'ps' : MathtextBackendPs, 'pdf' : MathtextBackendPdf, 'svg' : MathtextBackendSvg, + 'path' : MathtextBackendPath, 'cairo' : MathtextBackendCairo, 'macosx': MathtextBackendAgg, } Modified: trunk/matplotlib/lib/matplotlib/text.py =================================================================== --- trunk/matplotlib/lib/matplotlib/text.py 2009-09-04 04:12:16 UTC (rev 7634) +++ trunk/matplotlib/lib/matplotlib/text.py 2009-09-04 19:11:00 UTC (rev 7635) @@ -1770,173 +1770,4 @@ docstring.interpd.update(Annotation=Annotation.__init__.__doc__) -class TextPath(Path): - """ - Create a path from the text. - """ - - # TODO : math text is currently not supported, but it would not be easy. - - FONT_SCALE = 100. - - def __init__(self, xy, s, size=None, prop=None, - _interpolation_steps=1, - *kl, **kwargs): - """ - Create a path from the text. No support for TeX yet. Note that - it simply is a path, not an artist. You need to use the - PathPatch (or other artists) to draw this path onto the - canvas. - - xy : position of the text. - s : text - size : font size - prop : font property - """ - - - if prop is None: - prop = FontProperties() - - if size is None: - size = prop.get_size_in_points() - - - self._xy = xy - self.set_size(size) - - self._cached_vertices = None - - self._vertices, self._codes = self.text_get_vertices_codes(prop, s) - - self.should_simplify = False - self.simplify_threshold = rcParams['path.simplify_threshold'] - self.has_nonfinite = False - self._interpolation_steps = _interpolation_steps - - - def set_size(self, size): - """ - set the size of the text - """ - self._size = size - self._invalid = True - - def get_size(self): - """ - get the size of the text - """ - return self._size - - def _get_vertices(self): - """ - Return the cached path after updating it if necessary. - """ - self._revalidate_path() - return self._cached_vertices - - def _get_codes(self): - """ - Return the codes - """ - return self._codes - - vertices = property(_get_vertices) - codes = property(_get_codes) - - def _revalidate_path(self): - """ - update the path if necessary. - - The path for the text is initially create with the font size - of FONT_SCALE, and this path is rescaled to other size when - necessary. - - """ - if self._invalid or \ - (self._cached_vertices is None): - tr = Affine2D().scale(self._size/self.FONT_SCALE, - self._size/self.FONT_SCALE).translate(*self._xy) - self._cached_vertices = tr.transform(self._vertices) - self._invalid = False - - - def glyph_char_path(self, glyph, currx=0.): - """ - convert the glyph to vertices and codes. Mostly copied from - backend_svg.py. - """ - verts, codes = [], [] - for step in glyph.path: - if step[0] == 0: # MOVE_TO - verts.append((step[1], step[2])) - codes.append(Path.MOVETO) - elif step[0] == 1: # LINE_TO - verts.append((step[1], step[2])) - codes.append(Path.LINETO) - elif step[0] == 2: # CURVE3 - verts.extend([(step[1], step[2]), - (step[3], step[4])]) - codes.extend([Path.CURVE3, Path.CURVE3]) - elif step[0] == 3: # CURVE4 - verts.extend([(step[1], step[2]), - (step[3], step[4]), - (step[5], step[6])]) - codes.extend([Path.CURVE4, Path.CURVE4, Path.CURVE4]) - elif step[0] == 4: # ENDPOLY - verts.append((0, 0,)) - codes.append(Path.CLOSEPOLY) - - verts = [(x+currx, y) for (x,y) in verts] - - return verts, codes - - - def text_get_vertices_codes(self, prop, s): - """ - convert the string *s* to vertices and codes using the - provided font property *prop*. Mostly copied from - backend_svg.py. - """ - - fname = font_manager.findfont(prop) - font = FT2Font(str(fname)) - - font.set_size(self.FONT_SCALE, 72) - - cmap = font.get_charmap() - lastgind = None - - currx = 0 - - verts, codes = [], [] - - - # I'm not sure if I get kernings right. Needs to be verified. -JJL - - for c in s: - - ccode = ord(c) - gind = cmap.get(ccode) - if gind is None: - ccode = ord('?') - gind = 0 - glyph = font.load_char(ccode, flags=LOAD_NO_HINTING) - - - if lastgind is not None: - kern = font.get_kerning(lastgind, gind, KERNING_DEFAULT) - else: - kern = 0 - currx += (kern / 64.0) #/ (self.FONT_SCALE) - - verts1, codes1 = self.glyph_char_path(glyph, currx) - verts.extend(verts1) - codes.extend(codes1) - - - currx += (glyph.linearHoriAdvance / 65536.0) #/ (self.FONT_SCALE) - lastgind = gind - - return verts, codes - +from matplotlib.textpath import TextPath Added: trunk/matplotlib/lib/matplotlib/textpath.py =================================================================== --- trunk/matplotlib/lib/matplotlib/textpath.py (rev 0) +++ trunk/matplotlib/lib/matplotlib/textpath.py 2009-09-04 19:11:00 UTC (rev 7635) @@ -0,0 +1,463 @@ +# -*- coding: utf-8 -*- + +import urllib +from matplotlib.path import Path +import matplotlib.font_manager as font_manager + +from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, LOAD_NO_HINTING, LOAD_TARGET_LIGHT + +from matplotlib.mathtext import MathTextParser + +import matplotlib.dviread as dviread +from matplotlib.texmanager import TexManager + +import numpy as np + +class TextToPath(object): + """ + A class that convert a given text to a path using ttf fonts. + """ + + FONT_SCALE = 50. + DPI = 72 + + def __init__(self): + """ + Initialization + """ + self.mathtext_parser = MathTextParser('path') + self.tex_font_map = None + + from matplotlib.cbook import maxdict + self._ps_fontd = maxdict(50) + + + def _get_font(self, prop): + """ + find a ttf font. + """ + fname = font_manager.findfont(prop) + font = FT2Font(str(fname)) + font.set_size(self.FONT_SCALE, self.DPI) + + return font + + + def _get_char_id(self, font, ccode): + """ + Return a unique id for the given font and character-code set. + """ + ps_name = font.get_sfnt()[(1,0,0,6)] + char_id = urllib.quote('%s-%d' % (ps_name, ccode)) + return char_id + + def _get_char_id_ps(self, font, ccode): + """ + Return a unique id for the given font and character-code set (for tex). + """ + ps_name = font.get_ps_font_info()[2] + char_id = urllib.quote('%s-%d' % (ps_name, ccode)) + return char_id + + + def glyph_to_path(self, glyph, currx=0.): + """ + convert the ft2font glyph to vertices and codes. + """ + #Mostly copied from backend_svg.py. + + verts, codes = [], [] + for step in glyph.path: + if step[0] == 0: # MOVE_TO + verts.append((step[1], step[2])) + codes.append(Path.MOVETO) + elif step[0] == 1: # LINE_TO + verts.append((step[1], step[2])) + codes.append(Path.LINETO) + elif step[0] == 2: # CURVE3 + verts.extend([(step[1], step[2]), + (step[3], step[4])]) + codes.extend([Path.CURVE3, Path.CURVE3]) + elif step[0] == 3: # CURVE4 + verts.extend([(step[1], step[2]), + (step[3], step[4]), + (step[5], step[6])]) + codes.extend([Path.CURVE4, Path.CURVE4, Path.CURVE4]) + elif step[0] == 4: # ENDPOLY + verts.append((0, 0,)) + codes.append(Path.CLOSEPOLY) + + verts = [(x+currx, y) for (x,y) in verts] + return verts, codes + + + def get_text_path(self, prop, s, ismath=False, usetex=False): + """ + convert text *s* to path (a tuple of vertices and codes for matplotlib.math.Path). + + *prop* + font property + + *s* + text to be converted + + *usetex* + If True, use matplotlib usetex mode. + + *ismath* + If True, use mathtext parser. Effective only if usetex == False. + + + """ + if usetex==False: + if ismath == False: + font = self._get_font(prop) + glyph_info, glyph_map, rects = self.get_glyphs_with_font(font, s) + else: + glyph_info, glyph_map, rects = self.get_glyphs_mathtext(prop, s) + else: + glyph_info, glyph_map, rects = self.get_glyphs_tex(prop, s) + + verts, codes = [], [] + + for glyph_id, xposition, yposition, scale in glyph_info: + verts1, codes1 = glyph_map[glyph_id] + if verts1: + verts1 = np.array(verts1)*scale + [xposition, yposition] + verts.extend(verts1) + codes.extend(codes1) + + for verts1, codes1 in rects: + verts.extend(verts1) + codes.extend(codes1) + + return verts, codes + + + def get_glyphs_with_font(self, font, s, glyph_map=None): + """ + convert the string *s* to vertices and codes using the + provided ttf font. + """ + + # Mostly copied from backend_svg.py. + + cmap = font.get_charmap() + lastgind = None + + currx = 0 + xpositions = [] + glyph_ids = [] + + if glyph_map is None: + glyph_map = dict() + + # I'm not sure if I get kernings right. Needs to be verified. -JJL + + for c in s: + + + ccode = ord(c) + gind = cmap.get(ccode) + if gind is None: + ccode = ord('?') + gind = 0 + + if lastgind is not None: + kern = font.get_kerning(lastgind, gind, KERNING_DEFAULT) + else: + kern = 0 + + + glyph = font.load_char(ccode, flags=LOAD_NO_HINTING) + horiz_advance = (glyph.linearHoriAdvance / 65536.0) + + char_id = self._get_char_id(font, ccode) + if not char_id in glyph_map: + glyph_map[char_id] = self.glyph_to_path(glyph) + + currx += (kern / 64.0) + + xpositions.append(currx) + glyph_ids.append(char_id) + + currx += horiz_advance + + lastgind = gind + + ypositions = [0] * len(xpositions) + sizes = [1.] * len(xpositions) + + rects = [] + + return zip(glyph_ids, xpositions, ypositions, sizes), glyph_map, rects + + + + + def get_glyphs_mathtext(self, prop, s): + """ + convert the string *s* to vertices and codes by parsing it with mathtext. + """ + + prop = prop.copy() + prop.set_size(self.FONT_SCALE) + + width, height, descent, glyphs, rects = self.mathtext_parser.parse( + s, self.DPI, prop) + + + glyph_map = dict() + + xpositions = [] + ypositions = [] + glyph_ids = [] + sizes = [] + + currx, curry = 0, 0 + for font, fontsize, s, ox, oy in glyphs: + + ccode = ord(s) + char_id = self._get_char_id(font, ccode) + if not char_id in glyph_map: + font.clear() + font.set_size(self.FONT_SCALE, self.DPI) + glyph = font.load_char(ccode, flags=LOAD_NO_HINTING) + glyph_map[char_id] = self.glyph_to_path(glyph) + + xpositions.append(ox) + ypositions.append(oy) + glyph_ids.append(char_id) + size = fontsize / self.FONT_SCALE + sizes.append(size) + + myrects = [] + for ox, oy, w, h in rects: + vert1=[(ox, oy), (ox, oy+h), (ox+w, oy+h), (ox+w, oy), (ox, oy), (0,0)] + code1 = [Path.MOVETO, + Path.LINETO, Path.LINETO, Path.LINETO, Path.LINETO, + Path.CLOSEPOLY] + myrects.append((vert1, code1)) + + + return zip(glyph_ids, xpositions, ypositions, sizes), glyph_map, myrects + + + + def get_glyphs_tex(self, prop, s): + """ + convert the string *s* to vertices and codes using matplotlib's usetex mode. + """ + + # codes are modstly borrowed from pdf backend. + + texmanager = TexManager() + + if self.tex_font_map is None: + self.tex_font_map = dviread.PsfontsMap(dviread.find_tex_file('pdftex.map')) + + fontsize = prop.get_size_in_points() + if hasattr(texmanager, "get_dvi"): # + dvifilelike = texmanager.get_dvi(s, self.FONT_SCALE) + dvi = dviread.DviFromFileLike(dvifilelike, self.DPI) + else: + dvifile = texmanager.make_dvi(s, self.FONT_SCALE) + dvi = dviread.Dvi(dvifile, self.DPI) + page = iter(dvi).next() + dvi.close() + + glyph_ids, xpositions, ypositions, sizes = [], [], [], [] + glyph_map = dict() + + # Gather font information and do some setup for combining + # characters into strings. + #oldfont, seq = None, [] + for x1, y1, dvifont, glyph, width in page.text: + font_and_encoding = self._ps_fontd.get(dvifont.texname) + + if font_and_encoding is None: + font_bunch = self.tex_font_map[dvifont.texname] + font = FT2Font(font_bunch.filename) + if font_bunch.encoding: + enc = dviread.Encoding(font_bunch.encoding) + else: + enc = None + self._ps_fontd[dvifont.texname] = font, enc + + else: + font, enc = font_and_encoding + + ft2font_flag = LOAD_TARGET_LIGHT + if enc: + ng = font.get_name_index(enc.encoding[glyph]) + else: + ng = glyph + + char_id = self._get_char_id_ps(font, ng) + + if not char_id in glyph_map: + font.clear() + font.set_size(self.FONT_SCALE, self.DPI) + + if ng == 0: + # While 0 is a valid index (e.g., "-", "\Gamma"), + # font.load_glyph(0) does not seem to work. This + # may not be a general solution. + glyph0 = font.load_glyph(128, flags=ft2font_flag) + else: + glyph0 = font.load_glyph(ng, flags=ft2font_flag) + + glyph_map[char_id] = self.glyph_to_path(glyph0) + + glyph_ids.append(char_id) + xpositions.append(x1) + ypositions.append(y1) + sizes.append(dvifont.size/self.FONT_SCALE) + + myrects = [] + + for ox, oy, h, w in page.boxes: + vert1=[(ox, oy), (ox+w, oy), (ox+w, oy+h), (ox, oy+h), (ox, oy), (0,0)] + code1 = [Path.MOVETO, + Path.LINETO, Path.LINETO, Path.LINETO, Path.LINETO, + Path.CLOSEPOLY] + myrects.append((vert1, code1)) + + + return zip(glyph_ids, xpositions, ypositions, sizes), glyph_map, myrects + + + + + + +from matplotlib.font_manager import FontProperties +from matplotlib import rcParams +from matplotlib.transforms import Affine2D + +text_to_path = TextToPath() + +class TextPath(Path): + """ + Create a path from the text. + """ + + def __init__(self, xy, s, size=None, prop=None, + _interpolation_steps=1, usetex=False, + *kl, **kwargs): + """ + Create a path from the text. No support for TeX yet. Note that + it simply is a path, not an artist. You need to use the + PathPatch (or other artists) to draw this path onto the + canvas. + + xy : position of the text. + s : text + size : font size + prop : font property + """ + + + if prop is None: + prop = FontProperties() + + if size is None: + size = prop.get_size_in_points() + + + self._xy = xy + self.set_size(size) + + self._cached_vertices = None + + self._vertices, self._codes = self.text_get_vertices_codes(prop, s, usetex=usetex) + + self.should_simplify = False + self.simplify_threshold = rcParams['path.simplify_threshold'] + self.has_nonfinite = False + self._interpolation_steps = _interpolation_steps + + + def set_size(self, size): + """ + set the size of the text + """ + self._size = size + self._invalid = True + + def get_size(self): + """ + get the size of the text + """ + return self._size + + def _get_vertices(self): + """ + Return the cached path after updating it if necessary. + """ + self._revalidate_path() + return self._cached_vertices + + def _get_codes(self): + """ + Return the codes + """ + return self._codes + + vertices = property(_get_vertices) + codes = property(_get_codes) + + def _revalidate_path(self): + """ + update the path if necessary. + + The path for the text is initially create with the font size + of FONT_SCALE, and this path is rescaled to other size when + necessary. + + """ + if self._invalid or \ + (self._cached_vertices is None): + tr = Affine2D().scale(self._size/text_to_path.FONT_SCALE, + self._size/text_to_path.FONT_SCALE).translate(*self._xy) + self._cached_vertices = tr.transform(self._vertices) + self._invalid = False + + + def is_math_text(self, s): + """ + Returns True if the given string *s* contains any mathtext. + """ + # copied from Text.is_math_text -JJL + + # Did we find an even number of non-escaped dollar signs? + # If so, treat is as math text. + dollar_count = s.count(r'$') - s.count(r'\$') + even_dollars = (dollar_count > 0 and dollar_count % 2 == 0) + + if rcParams['text.usetex']: + return s, 'TeX' + + if even_dollars: + return s, True + else: + return s.replace(r'\$', '$'), False + + def text_get_vertices_codes(self, prop, s, usetex): + """ + convert the string *s* to vertices and codes using the + provided font property *prop*. Mostly copied from + backend_svg.py. + """ + + if usetex: + verts, codes = text_to_path.get_text_path(prop, s, usetex=True) + else: + clean_line, ismath = self.is_math_text(s) + verts, codes = text_to_path.get_text_path(prop, clean_line, ismath=ismath) + + return verts, codes + + + + Modified: trunk/matplotlib/src/ft2font.cpp =================================================================== --- trunk/matplotlib/src/ft2font.cpp 2009-09-04 04:12:16 UTC (rev 7634) +++ trunk/matplotlib/src/ft2font.cpp 2009-09-04 19:11:00 UTC (rev 7635) @@ -1105,6 +1105,51 @@ return Py::asObject(gm); } + +char FT2Font::load_glyph__doc__[] = +"load_glyph(glyphindex, flags=LOAD_FORCE_AUTOHINT)\n" +"\n" +"Load character with glyphindex in current fontfile and set glyph.\n" +"The flags argument can be a bitwise-or of the LOAD_XXX constants.\n" +"Return value is a Glyph object, with attributes\n" +" width # glyph width\n" +" height # glyph height\n" +" bbox # the glyph bbox (xmin, ymin, xmax, ymax)\n" +" horiBearingX # left side bearing in horizontal layouts\n" +" horiBearingY # top side bearing in horizontal layouts\n" +" horiAdvance # advance width for horizontal layout\n" +" vertBearingX # left side bearing in vertical layouts\n" +" vertBearingY # top side bearing in vertical layouts\n" +" vertAdvance # advance height for vertical layout\n" +; +Py::Object +FT2Font::load_glyph(const Py::Tuple & args, const Py::Dict & kwargs) { + _VERBOSE("FT2Font::load_glyph"); + //load a char using the unsigned long charcode + + args.verify_length(1); + long glyph_index = Py::Long(args[0]), flags = Py::Long(FT_LOAD_FORCE_AUTOHINT); + if (kwargs.hasKey("flags")) + flags = Py::Long(kwargs["flags"]); + + int error = FT_Load_Glyph( face, glyph_index, flags ); + + if (error) + throw Py::RuntimeError(Printf("Could not load glyph index %d", glyph_index).str()); + + FT_Glyph thisGlyph; + error = FT_Get_Glyph( face->glyph, &thisGlyph ); + + if (error) + throw Py::RuntimeError(Printf("Could not get glyph for glyph index %d", glyph_index).str()); + + size_t num = glyphs.size(); //the index into the glyphs list + glyphs.push_back(thisGlyph); + Glyph* gm = new Glyph(face, thisGlyph, num); + return Py::asObject(gm); +} + + char FT2Font::get_width_height__doc__[] = "w, h = get_width_height()\n" "\n" @@ -1782,6 +1827,8 @@ FT2Font::get_num_glyphs__doc__); add_keyword_method("load_char", &FT2Font::load_char, FT2Font::load_char__doc__); + add_keyword_method("load_glyph", &FT2Font::load_glyph, + FT2Font::load_glyph__doc__); add_keyword_method("set_text", &FT2Font::set_text, FT2Font::set_text__doc__); add_varargs_method("set_size", &FT2Font::set_size, Modified: trunk/matplotlib/src/ft2font.h =================================================================== --- trunk/matplotlib/src/ft2font.h 2009-09-04 04:12:16 UTC (rev 7634) +++ trunk/matplotlib/src/ft2font.h 2009-09-04 19:11:00 UTC (rev 7635) @@ -99,6 +99,7 @@ Py::Object get_kerning(const Py::Tuple & args); Py::Object get_num_glyphs(const Py::Tuple & args); Py::Object load_char(const Py::Tuple & args, const Py::Dict & kws); + Py::Object load_glyph(const Py::Tuple & args, const Py::Dict & kws); Py::Object get_width_height(const Py::Tuple & args); Py::Object get_descent(const Py::Tuple & args); Py::Object draw_rect_filled(const Py::Tuple & args); @@ -140,6 +141,7 @@ static char get_glyph__doc__ []; static char get_num_glyphs__doc__ []; static char load_char__doc__ []; + static char load_glyph__doc__ []; static char get_width_height__doc__ []; static char get_descent__doc__ []; static char get_kerning__doc__ []; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <lee...@us...> - 2009-09-04 20:20:14
|
Revision: 7636 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7636&view=rev Author: leejjoon Date: 2009-09-04 20:20:06 +0000 (Fri, 04 Sep 2009) Log Message: ----------- textpath.py: import texmanager only when required Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/demo_text_path.py trunk/matplotlib/lib/matplotlib/textpath.py Modified: trunk/matplotlib/examples/pylab_examples/demo_text_path.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/demo_text_path.py 2009-09-04 19:11:00 UTC (rev 7635) +++ trunk/matplotlib/examples/pylab_examples/demo_text_path.py 2009-09-04 20:20:06 UTC (rev 7636) @@ -54,6 +54,8 @@ if 1: + usetex = plt.rcParams["text.usetex"] + fig = plt.figure(1) # EXAMPLE 1 @@ -80,8 +82,14 @@ # another text from matplotlib.patches import PathPatch - text_path = TextPath((0, 0), r"\mbox{textpath supports mathtext \& \TeX}", - size=20, usetex=True) + if usetex: + r = r"\mbox{textpath supports mathtext \& \TeX}" + else: + r = r"textpath supports mathtext & TeX" + + text_path = TextPath((0, 0), r, + size=20, usetex=usetex) + p1 = PathPatch(text_path, ec="w", lw=3, fc="w", alpha=0.9, transform=IdentityTransform()) p2 = PathPatch(text_path, ec="none", fc="k", @@ -111,7 +119,6 @@ arr = np.arange(256).reshape(1,256)/256. - usetex = plt.rcParams["text.usetex"] if usetex: s = r"$\displaystyle\left[\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}\right]$!" else: Modified: trunk/matplotlib/lib/matplotlib/textpath.py =================================================================== --- trunk/matplotlib/lib/matplotlib/textpath.py 2009-09-04 19:11:00 UTC (rev 7635) +++ trunk/matplotlib/lib/matplotlib/textpath.py 2009-09-04 20:20:06 UTC (rev 7636) @@ -9,7 +9,6 @@ from matplotlib.mathtext import MathTextParser import matplotlib.dviread as dviread -from matplotlib.texmanager import TexManager import numpy as np @@ -31,6 +30,7 @@ from matplotlib.cbook import maxdict self._ps_fontd = maxdict(50) + self._texmanager = None def _get_font(self, prop): """ @@ -243,7 +243,16 @@ return zip(glyph_ids, xpositions, ypositions, sizes), glyph_map, myrects + def get_texmanager(self): + """ + return the :class:`matplotlib.texmanager.TexManager` instance + """ + if self._texmanager is None: + from matplotlib.texmanager import TexManager + self._texmanager = TexManager() + return self._texmanager + def get_glyphs_tex(self, prop, s): """ convert the string *s* to vertices and codes using matplotlib's usetex mode. @@ -251,7 +260,7 @@ # codes are modstly borrowed from pdf backend. - texmanager = TexManager() + texmanager = self.get_texmanager() if self.tex_font_map is None: self.tex_font_map = dviread.PsfontsMap(dviread.find_tex_file('pdftex.map')) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <as...@us...> - 2009-09-06 01:43:10
|
Revision: 7646 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7646&view=rev Author: astraw Date: 2009-09-06 01:43:05 +0000 (Sun, 06 Sep 2009) Log Message: ----------- testing: move image comparison functions into matplotlib.testing Modified Paths: -------------- trunk/matplotlib/test/mplTest/MplTestCase.py Added Paths: ----------- trunk/matplotlib/lib/matplotlib/testing/compare.py Removed Paths: ------------- trunk/matplotlib/test/mplTest/compare.py Copied: trunk/matplotlib/lib/matplotlib/testing/compare.py (from rev 7645, trunk/matplotlib/test/mplTest/compare.py) =================================================================== --- trunk/matplotlib/lib/matplotlib/testing/compare.py (rev 0) +++ trunk/matplotlib/lib/matplotlib/testing/compare.py 2009-09-06 01:43:05 UTC (rev 7646) @@ -0,0 +1,138 @@ +#======================================================================= +""" A set of utilities for comparing results. +""" +#======================================================================= + +import math +import operator +import os +import numpy as np + +#======================================================================= + +__all__ = [ + 'compareFloat', + 'compareImages', + ] + +#----------------------------------------------------------------------- +def compareFloat( expected, actual, relTol = None, absTol = None ): + """Fail if the floating point values are not close enough, with + the givem message. + + You can specify a relative tolerance, absolute tolerance, or both. + """ + if relTol is None and absTol is None: + exMsg = "You haven't specified a 'relTol' relative tolerance " + exMsg += "or a 'absTol' absolute tolerance function argument. " + exMsg += "You must specify one." + raise ValueError, exMsg + + msg = "" + + if absTol is not None: + absDiff = abs( expected - actual ) + if absTol < absDiff: + expectedStr = str( expected ) + actualStr = str( actual ) + absDiffStr = str( absDiff ) + absTolStr = str( absTol ) + + msg += "\n" + msg += " Expected: " + expectedStr + "\n" + msg += " Actual: " + actualStr + "\n" + msg += " Abs Diff: " + absDiffStr + "\n" + msg += " Abs Tol: " + absTolStr + "\n" + + if relTol is not None: + # The relative difference of the two values. If the expected value is + # zero, then return the absolute value of the difference. + relDiff = abs( expected - actual ) + if expected: + relDiff = relDiff / abs( expected ) + + if relTol < relDiff: + + # The relative difference is a ratio, so it's always unitless. + relDiffStr = str( relDiff ) + relTolStr = str( relTol ) + + expectedStr = str( expected ) + actualStr = str( actual ) + + msg += "\n" + msg += " Expected: " + expectedStr + "\n" + msg += " Actual: " + actualStr + "\n" + msg += " Rel Diff: " + relDiffStr + "\n" + msg += " Rel Tol: " + relTolStr + "\n" + + if msg: + return msg + else: + return None + +#----------------------------------------------------------------------- +def compareImages( expected, actual, tol ): + '''Compare two image files - not the greatest, but fast and good enough. + + = EXAMPLE + + # img1 = "./baseline/plot.png" + # img2 = "./output/plot.png" + # + # compareImage( img1, img2, 0.001 ): + + = INPUT VARIABLES + - expected The filename of the expected image. + - actual The filename of the actual image. + - tol The tolerance (a unitless float). This is used to + determinte the 'fuzziness' to use when comparing images. + ''' + + try: + from PIL import Image, ImageOps, ImageFilter + except ImportError, e: + msg = "Image Comparison requires the Python Imaging Library to " \ + "be installed. To run tests without using PIL, then use " \ + "the '--without-tag=PIL' command-line option.\n" \ + "Importing PIL failed with the following error:\n%s" % e + return msg + + # open the image files and remove the alpha channel (if it exists) + expectedImage = Image.open( expected ).convert("RGB") + actualImage = Image.open( actual ).convert("RGB") + + # normalize the images + expectedImage = ImageOps.autocontrast( expectedImage, 2 ) + actualImage = ImageOps.autocontrast( actualImage, 2 ) + + # compare the resulting image histogram functions + h1 = expectedImage.histogram() + h2 = actualImage.histogram() + rms = math.sqrt( reduce(operator.add, map(lambda a,b: (a-b)**2, h1, h2)) / len(h1) ) + + if ( (rms / 10000.0) <= tol ): + return None + else: + diff_image = os.path.join(os.path.dirname(actual), + 'failed-diff-'+os.path.basename(actual)) + saveDiffImage( expected, actual, diff_image ) + + msg = " Error: Image files did not match.\n" \ + " RMS Value: " + str( rms / 10000.0 ) + "\n" \ + " Expected:\n " + str( expected ) + "\n" \ + " Actual:\n " + str( actual ) + "\n" \ + " Difference:\n " + str( diff_image ) + "\n" \ + " Tolerance: " + str( tol ) + "\n" + return msg + +def saveDiffImage( expected, actual, output ): + from PIL import Image + expectedImage = np.array(Image.open( expected ).convert("RGB")).astype(np.float) + actualImage = np.array(Image.open( actual ).convert("RGB")).astype(np.float) + absDiffImage = abs(expectedImage-actualImage) + # expand differences in luminance domain + absDiffImage *= 10 + save_image_np = absDiffImage.astype(np.uint8) + save_image = Image.fromarray(save_image_np) + save_image.save(output) Modified: trunk/matplotlib/test/mplTest/MplTestCase.py =================================================================== --- trunk/matplotlib/test/mplTest/MplTestCase.py 2009-09-06 01:42:52 UTC (rev 7645) +++ trunk/matplotlib/test/mplTest/MplTestCase.py 2009-09-06 01:43:05 UTC (rev 7646) @@ -6,7 +6,7 @@ import os.path import unittest -import compare +import matplotlib.testing.compare as compare import path_utils #======================================================================= Deleted: trunk/matplotlib/test/mplTest/compare.py =================================================================== --- trunk/matplotlib/test/mplTest/compare.py 2009-09-06 01:42:52 UTC (rev 7645) +++ trunk/matplotlib/test/mplTest/compare.py 2009-09-06 01:43:05 UTC (rev 7646) @@ -1,138 +0,0 @@ -#======================================================================= -""" A set of utilities for comparing results. -""" -#======================================================================= - -import math -import operator -import os -import numpy as np - -#======================================================================= - -__all__ = [ - 'compareFloat', - 'compareImages', - ] - -#----------------------------------------------------------------------- -def compareFloat( expected, actual, relTol = None, absTol = None ): - """Fail if the floating point values are not close enough, with - the givem message. - - You can specify a relative tolerance, absolute tolerance, or both. - """ - if relTol is None and absTol is None: - exMsg = "You haven't specified a 'relTol' relative tolerance " - exMsg += "or a 'absTol' absolute tolerance function argument. " - exMsg += "You must specify one." - raise ValueError, exMsg - - msg = "" - - if absTol is not None: - absDiff = abs( expected - actual ) - if absTol < absDiff: - expectedStr = str( expected ) - actualStr = str( actual ) - absDiffStr = str( absDiff ) - absTolStr = str( absTol ) - - msg += "\n" - msg += " Expected: " + expectedStr + "\n" - msg += " Actual: " + actualStr + "\n" - msg += " Abs Diff: " + absDiffStr + "\n" - msg += " Abs Tol: " + absTolStr + "\n" - - if relTol is not None: - # The relative difference of the two values. If the expected value is - # zero, then return the absolute value of the difference. - relDiff = abs( expected - actual ) - if expected: - relDiff = relDiff / abs( expected ) - - if relTol < relDiff: - - # The relative difference is a ratio, so it's always unitless. - relDiffStr = str( relDiff ) - relTolStr = str( relTol ) - - expectedStr = str( expected ) - actualStr = str( actual ) - - msg += "\n" - msg += " Expected: " + expectedStr + "\n" - msg += " Actual: " + actualStr + "\n" - msg += " Rel Diff: " + relDiffStr + "\n" - msg += " Rel Tol: " + relTolStr + "\n" - - if msg: - return msg - else: - return None - -#----------------------------------------------------------------------- -def compareImages( expected, actual, tol ): - '''Compare two image files - not the greatest, but fast and good enough. - - = EXAMPLE - - # img1 = "./baseline/plot.png" - # img2 = "./output/plot.png" - # - # compareImage( img1, img2, 0.001 ): - - = INPUT VARIABLES - - expected The filename of the expected image. - - actual The filename of the actual image. - - tol The tolerance (a unitless float). This is used to - determinte the 'fuzziness' to use when comparing images. - ''' - - try: - from PIL import Image, ImageOps, ImageFilter - except ImportError, e: - msg = "Image Comparison requires the Python Imaging Library to " \ - "be installed. To run tests without using PIL, then use " \ - "the '--without-tag=PIL' command-line option.\n" \ - "Importing PIL failed with the following error:\n%s" % e - return msg - - # open the image files and remove the alpha channel (if it exists) - expectedImage = Image.open( expected ).convert("RGB") - actualImage = Image.open( actual ).convert("RGB") - - # normalize the images - expectedImage = ImageOps.autocontrast( expectedImage, 2 ) - actualImage = ImageOps.autocontrast( actualImage, 2 ) - - # compare the resulting image histogram functions - h1 = expectedImage.histogram() - h2 = actualImage.histogram() - rms = math.sqrt( reduce(operator.add, map(lambda a,b: (a-b)**2, h1, h2)) / len(h1) ) - - if ( (rms / 10000.0) <= tol ): - return None - else: - diff_image = os.path.join(os.path.dirname(actual), - 'failed-diff-'+os.path.basename(actual)) - saveDiffImage( expected, actual, diff_image ) - - msg = " Error: Image files did not match.\n" \ - " RMS Value: " + str( rms / 10000.0 ) + "\n" \ - " Expected:\n " + str( expected ) + "\n" \ - " Actual:\n " + str( actual ) + "\n" \ - " Difference:\n " + str( diff_image ) + "\n" \ - " Tolerance: " + str( tol ) + "\n" - return msg - -def saveDiffImage( expected, actual, output ): - from PIL import Image - expectedImage = np.array(Image.open( expected ).convert("RGB")).astype(np.float) - actualImage = np.array(Image.open( actual ).convert("RGB")).astype(np.float) - absDiffImage = abs(expectedImage-actualImage) - # expand differences in luminance domain - absDiffImage *= 10 - save_image_np = absDiffImage.astype(np.uint8) - save_image = Image.fromarray(save_image_np) - save_image.save(output) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <as...@us...> - 2009-09-06 01:43:26
|
Revision: 7647 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7647&view=rev Author: astraw Date: 2009-09-06 01:43:18 +0000 (Sun, 06 Sep 2009) Log Message: ----------- testing: add new, simplified testing infrastructure Modified Paths: -------------- trunk/matplotlib/setup.py trunk/matplotlib/test/run-mpl-test.py Added Paths: ----------- trunk/matplotlib/lib/matplotlib/tests/ trunk/matplotlib/lib/matplotlib/tests/__init__.py trunk/matplotlib/lib/matplotlib/tests/test_basic.py trunk/matplotlib/lib/matplotlib/tests/test_transforms.py Added: trunk/matplotlib/lib/matplotlib/tests/test_basic.py =================================================================== --- trunk/matplotlib/lib/matplotlib/tests/test_basic.py (rev 0) +++ trunk/matplotlib/lib/matplotlib/tests/test_basic.py 2009-09-06 01:43:18 UTC (rev 7647) @@ -0,0 +1,11 @@ +from nose.tools import assert_equal +from matplotlib.testing.decorators import knownfailureif + +def test_simple(): + '''very simple example test''' + assert_equal(1+1,2) + +@knownfailureif(True) +def test_simple_fail(): + '''very simple example test that should fail''' + assert_equal(1+1,3) Added: trunk/matplotlib/lib/matplotlib/tests/test_transforms.py =================================================================== --- trunk/matplotlib/lib/matplotlib/tests/test_transforms.py (rev 0) +++ trunk/matplotlib/lib/matplotlib/tests/test_transforms.py 2009-09-06 01:43:18 UTC (rev 7647) @@ -0,0 +1,40 @@ +from nose.tools import assert_equal +from numpy.testing import assert_almost_equal +from matplotlib.transforms import Affine2D +import numpy as np + +def test_Affine2D_from_values(): + points = [ [0,0], + [10,20], + [-1,0], + ] + + t = Affine2D.from_values(1,0,0,0,0,0) + actual = t.transform(points) + expected = np.array( [[0,0],[10,0],[-1,0]] ) + assert_almost_equal(actual,expected) + + t = Affine2D.from_values(0,2,0,0,0,0) + actual = t.transform(points) + expected = np.array( [[0,0],[0,20],[0,-2]] ) + assert_almost_equal(actual,expected) + + t = Affine2D.from_values(0,0,3,0,0,0) + actual = t.transform(points) + expected = np.array( [[0,0],[60,0],[0,0]] ) + assert_almost_equal(actual,expected) + + t = Affine2D.from_values(0,0,0,4,0,0) + actual = t.transform(points) + expected = np.array( [[0,0],[0,80],[0,0]] ) + assert_almost_equal(actual,expected) + + t = Affine2D.from_values(0,0,0,0,5,0) + actual = t.transform(points) + expected = np.array( [[5,0],[5,0],[5,0]] ) + assert_almost_equal(actual,expected) + + t = Affine2D.from_values(0,0,0,0,0,6) + actual = t.transform(points) + expected = np.array( [[0,6],[0,6],[0,6]] ) + assert_almost_equal(actual,expected) Modified: trunk/matplotlib/setup.py =================================================================== --- trunk/matplotlib/setup.py 2009-09-06 01:43:05 UTC (rev 7646) +++ trunk/matplotlib/setup.py 2009-09-06 01:43:18 UTC (rev 7647) @@ -51,6 +51,7 @@ 'matplotlib.backends', 'matplotlib.projections', 'matplotlib.testing', + 'matplotlib.tests', # 'matplotlib.toolkits', 'mpl_toolkits', 'mpl_toolkits.mplot3d', Modified: trunk/matplotlib/test/run-mpl-test.py =================================================================== --- trunk/matplotlib/test/run-mpl-test.py 2009-09-06 01:43:05 UTC (rev 7646) +++ trunk/matplotlib/test/run-mpl-test.py 2009-09-06 01:43:18 UTC (rev 7647) @@ -90,6 +90,9 @@ sys.exit( 0 ) ### Run nose +args.append('.') +args.append('matplotlib.tests.test_basic') +args.append('matplotlib.tests.test_transforms') success = nose.run( argv = args, plugins = [ MplNosePlugin(), KnownFailure() ] ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <as...@us...> - 2009-09-06 01:43:39
|
Revision: 7648 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7648&view=rev Author: astraw Date: 2009-09-06 01:43:29 +0000 (Sun, 06 Sep 2009) Log Message: ----------- testing: initial spine test (test for SF#2852168) Modified Paths: -------------- trunk/matplotlib/test/run-mpl-test.py Added Paths: ----------- trunk/matplotlib/lib/matplotlib/tests/test_spines.py Added: trunk/matplotlib/lib/matplotlib/tests/test_spines.py =================================================================== --- trunk/matplotlib/lib/matplotlib/tests/test_spines.py (rev 0) +++ trunk/matplotlib/lib/matplotlib/tests/test_spines.py 2009-09-06 01:43:29 UTC (rev 7648) @@ -0,0 +1,22 @@ +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=['spines_axes_positions.png']) +def test_spines_axes_positions(): + # SF bug 2852168 + fig = plt.figure() + x = np.linspace(0,2*np.pi,100) + y = 2*np.sin(x) + ax = fig.add_subplot(1,1,1) + ax.set_title('centered spines') + ax.plot(x,y) + ax.spines['right'].set_position(('axes',0.1)) + ax.yaxis.set_ticks_position('right') + ax.spines['top'].set_position(('axes',0.25)) + ax.xaxis.set_ticks_position('top') + ax.spines['left'].set_color('none') + ax.spines['bottom'].set_color('none') + fig.savefig('spines_axes_positions.png') Modified: trunk/matplotlib/test/run-mpl-test.py =================================================================== --- trunk/matplotlib/test/run-mpl-test.py 2009-09-06 01:43:18 UTC (rev 7647) +++ trunk/matplotlib/test/run-mpl-test.py 2009-09-06 01:43:29 UTC (rev 7648) @@ -93,6 +93,7 @@ args.append('.') args.append('matplotlib.tests.test_basic') args.append('matplotlib.tests.test_transforms') +args.append('matplotlib.tests.test_spines') success = nose.run( argv = args, plugins = [ MplNosePlugin(), KnownFailure() ] ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <as...@us...> - 2009-09-06 01:43:48
|
Revision: 7649 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7649&view=rev Author: astraw Date: 2009-09-06 01:43:40 +0000 (Sun, 06 Sep 2009) Log Message: ----------- testing: convert function names to MPL coding standard Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/testing/compare.py trunk/matplotlib/test/mplTest/MplTestCase.py Modified: trunk/matplotlib/lib/matplotlib/testing/compare.py =================================================================== --- trunk/matplotlib/lib/matplotlib/testing/compare.py 2009-09-06 01:43:29 UTC (rev 7648) +++ trunk/matplotlib/lib/matplotlib/testing/compare.py 2009-09-06 01:43:40 UTC (rev 7649) @@ -11,12 +11,12 @@ #======================================================================= __all__ = [ - 'compareFloat', - 'compareImages', + 'compare_float', + 'compare_images', ] #----------------------------------------------------------------------- -def compareFloat( expected, actual, relTol = None, absTol = None ): +def compare_float( expected, actual, relTol = None, absTol = None ): """Fail if the floating point values are not close enough, with the givem message. @@ -72,7 +72,7 @@ return None #----------------------------------------------------------------------- -def compareImages( expected, actual, tol ): +def compare_images( expected, actual, tol ): '''Compare two image files - not the greatest, but fast and good enough. = EXAMPLE @@ -80,7 +80,7 @@ # img1 = "./baseline/plot.png" # img2 = "./output/plot.png" # - # compareImage( img1, img2, 0.001 ): + # compare_images( img1, img2, 0.001 ): = INPUT VARIABLES - expected The filename of the expected image. @@ -116,7 +116,7 @@ else: diff_image = os.path.join(os.path.dirname(actual), 'failed-diff-'+os.path.basename(actual)) - saveDiffImage( expected, actual, diff_image ) + save_diff_image( expected, actual, diff_image ) msg = " Error: Image files did not match.\n" \ " RMS Value: " + str( rms / 10000.0 ) + "\n" \ @@ -126,7 +126,7 @@ " Tolerance: " + str( tol ) + "\n" return msg -def saveDiffImage( expected, actual, output ): +def save_diff_image( expected, actual, output ): from PIL import Image expectedImage = np.array(Image.open( expected ).convert("RGB")).astype(np.float) actualImage = np.array(Image.open( actual ).convert("RGB")).astype(np.float) Modified: trunk/matplotlib/test/mplTest/MplTestCase.py =================================================================== --- trunk/matplotlib/test/mplTest/MplTestCase.py 2009-09-06 01:43:29 UTC (rev 7648) +++ trunk/matplotlib/test/mplTest/MplTestCase.py 2009-09-06 01:43:40 UTC (rev 7649) @@ -51,7 +51,7 @@ baselineImage = self.baseFile( basename ) - errorMessage = compare.compareImages( baselineImage, actualImage, tol ) + errorMessage = compare.compare_images( baselineImage, actualImage, tol ) if errorMessage: self.fail( msg + "\n" + errorMessage ) @@ -108,7 +108,7 @@ You can specify a relative tolerance, absolute tolerance, or both. """ - errorMessage = compare.compareFloat( expected, actual, relTol, absTol ) + errorMessage = compare.compare_float( expected, actual, relTol, absTol ) if errorMessage: self.fail( msg + "\n" + errorMessage ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <as...@us...> - 2009-09-06 03:39:58
|
Revision: 7653 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7653&view=rev Author: astraw Date: 2009-09-06 03:39:42 +0000 (Sun, 06 Sep 2009) Log Message: ----------- testing: collect new image results on failed image comparisons Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/testing/compare.py trunk/matplotlib/test/_buildbot_test_postmortem.py Modified: trunk/matplotlib/lib/matplotlib/testing/compare.py =================================================================== --- trunk/matplotlib/lib/matplotlib/testing/compare.py 2009-09-06 01:44:09 UTC (rev 7652) +++ trunk/matplotlib/lib/matplotlib/testing/compare.py 2009-09-06 03:39:42 UTC (rev 7653) @@ -7,6 +7,7 @@ import operator import os import numpy as np +import shutil #======================================================================= @@ -121,6 +122,7 @@ save_diff_image( expected, actual, diff_image ) if in_decorator: + shutil.copyfile( expected, 'expected-'+os.path.basename(actual)) results = dict( rms = rms, expected = str(expected), Modified: trunk/matplotlib/test/_buildbot_test_postmortem.py =================================================================== --- trunk/matplotlib/test/_buildbot_test_postmortem.py 2009-09-06 01:44:09 UTC (rev 7652) +++ trunk/matplotlib/test/_buildbot_test_postmortem.py 2009-09-06 03:39:42 UTC (rev 7653) @@ -9,9 +9,10 @@ roots = ['test_matplotlib','test_plots'] savedresults_dir = 'saved-results' baseline_dir = 'baseline' -basename = 'failed-diff-' +expected_basename = 'expected-' +diff_basename = 'failed-diff-' target_dir = os.path.abspath('status_images') -nbase = len(basename) +nbase = len(diff_basename) def listFiles(root, patterns='*', recurse=1, return_folders=0): """ @@ -76,7 +77,31 @@ if os.path.exists(target_dir): shutil.rmtree(target_dir) os.makedirs( target_dir ) # prevent buildbot DirectoryUpload failure + + # new matplotlib.testing infrastructure + os.chdir('test') + for fname in glob.glob('*.png'): + absdiff_fname = diff_basename + fname + expected_fname = expected_basename + fname + if not os.path.exists(absdiff_fname): + continue + if not os.path.exists(expected_fname): + continue + print fname + print absdiff_fname + + teststr = os.path.splitext(fname)[0] + this_targetdir = os.path.join(target_dir,teststr) + os.makedirs( this_targetdir ) + shutil.copy( expected_fname, + os.path.join(this_targetdir,'baseline.png') ) + shutil.copy( fname, + os.path.join(this_targetdir,'actual.png') ) + shutil.copy( absdiff_fname, + os.path.join(this_targetdir,'absdiff.png') ) + + # old mplTest infrastructure for fpath in get_recursive_filelist(roots): # only images if not fpath.endswith('.png'): continue @@ -87,7 +112,7 @@ root = pieces[0] testclass = pieces[2] fname = pieces[3] - if not fname.startswith(basename): + if not fname.startswith(diff_basename): # only failed images continue origname = fname[nbase:] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <as...@us...> - 2009-09-06 05:06:03
|
Revision: 7654 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7654&view=rev Author: astraw Date: 2009-09-06 05:05:57 +0000 (Sun, 06 Sep 2009) Log Message: ----------- docs: describe how to write tests Modified Paths: -------------- trunk/matplotlib/doc/devel/coding_guide.rst trunk/matplotlib/lib/matplotlib/testing/decorators.py Modified: trunk/matplotlib/doc/devel/coding_guide.rst =================================================================== --- trunk/matplotlib/doc/devel/coding_guide.rst 2009-09-06 03:39:42 UTC (rev 7653) +++ trunk/matplotlib/doc/devel/coding_guide.rst 2009-09-06 05:05:57 UTC (rev 7654) @@ -561,9 +561,8 @@ -.. _license-discussion: +.. _sample-data: - Writing examples ================ @@ -602,6 +601,9 @@ print 'datafile', datafile +.. _license-discussion: + + Licenses ======== @@ -669,4 +671,113 @@ extensions for scientific computing: ipython, numpy, scipy, the enthought tool suite and python itself are all distributed under BSD compatible licenses. -> \ No newline at end of file + +Testing +======= + +Matplotlib has a testing infrastructure based on nose_, making it easy +to write new tests. The tests are in :mod:`matplotlib.tests`, and +customizations to the nose testing infrastructure are in +:mod:`matplotlib.testing`. (There is other old testing cruft around, +please ignore it while we consolidate our testing to these locations.) + +.. _nose: http://somethingaboutorange.com/mrl/projects/nose/ + + +Writing a simple test +--------------------- + +Many elements of Matplotlib can be tested using standard tests. For +example, here is a test from :mod:`matplotlib.tests.test_basic`:: + + from nose.tools import assert_equal + + def test_simple(): + '''very simple example test''' + assert_equal(1+1,2) + +Nose determines which functions are tests by searching for functions +beginning with "test" in their name. + +Writing an image comparison test +-------------------------------- + +Writing an image based test is only slightly more difficult than a +simple test. The main consideration is that you must specify the +"baseline", or expected, images in the +:func:`~matplotlib.testing.decorators.image_comparison` decorator. For +example, this test generates a single image and automatically tests +it:: + + 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=['spines_axes_positions.png']) + def test_spines_axes_positions(): + # SF bug 2852168 + fig = plt.figure() + x = np.linspace(0,2*np.pi,100) + y = 2*np.sin(x) + ax = fig.add_subplot(1,1,1) + ax.set_title('centered spines') + ax.plot(x,y) + ax.spines['right'].set_position(('axes',0.1)) + ax.yaxis.set_ticks_position('right') + ax.spines['top'].set_position(('axes',0.25)) + ax.xaxis.set_ticks_position('top') + ax.spines['left'].set_color('none') + ax.spines['bottom'].set_color('none') + fig.savefig('spines_axes_positions.png') + +The mechanism for comparing images is extremely simple -- it compares +an image saved in the current directory with one from the Matplotlib +sample_data repository. The correspondence is done by matching +filenames, so ensure that: + + * The filename given to :meth:`~matplotlib.figure.Figure.savefig` is + exactly the same as the filename given to + :func:`~matplotlib.testing.decorators.image_comparison` in the + ``baseline_images`` argument. + + * The correct image gets added to the sample_data respository with + the name ``test_baseline_<IMAGE_FILENAME.png>``. (See + :ref:`sample-data` above for a description of how to add files to + the sample_data repository.) + + +Known failing tests +------------------- + +If you're writing a test, you may mark it as a known failing test with +the :func:`~matplotlib.testing.decorators.knownfailureif` +decorator. This allows the test to be added to the test suite and run +on the buildbots without causing undue alarm. For example, although +the following test will fail, it is an expected failure:: + + from nose.tools import assert_equal + from matplotlib.testing.decorators import knownfailureif + + @knownfailureif(True) + def test_simple_fail(): + '''very simple example test that should fail''' + assert_equal(1+1,3) + +Note that the first argument to the +:func:`~matplotlib.testing.decorators.knownfailureif` decorator is a +fail condition, which can be a value such as True, False, or +'indeterminate', or may be a dynamically evaluated expression. + +Creating a new module in matplotlib.tests +----------------------------------------- + +Let's say you've added a new module named +``matplotlib.tests.test_whizbang_features``. For the buildbot slave +machines to know to run a test, nose must look in that module. To add +a module to the list searched, add the line:: + + args.append('matplotlib.tests.test_whizbang_features') + +into :file:`test/run-mpl-test.py`. Modified: trunk/matplotlib/lib/matplotlib/testing/decorators.py =================================================================== --- trunk/matplotlib/lib/matplotlib/testing/decorators.py 2009-09-06 03:39:42 UTC (rev 7653) +++ trunk/matplotlib/lib/matplotlib/testing/decorators.py 2009-09-06 05:05:57 UTC (rev 7654) @@ -6,6 +6,14 @@ from matplotlib.testing.compare import compare_images def knownfailureif(fail_condition, msg=None): + """ + + Assume a will fail if *fail_condition* is True. *fail_condition* + may also be False or the string 'indeterminate'. + + *msg* is the error message displayed for the test. + + """ # based on numpy.testing.dec.knownfailureif if msg is None: msg = 'Test known to fail' @@ -29,6 +37,13 @@ return known_fail_decorator def image_comparison(baseline_images=None, tol=1e-3): + """ + compare images generated by the test with those specified in + *baseline_images*, which must correspond within tolerance *tol*, + else an ImageComparisonFailure exception will be raised. + + """ + if baseline_images is None: raise ValueError('baseline_images must be specified') def compare_images_decorator(func): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2009-09-06 07:12:06
|
Revision: 7656 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7656&view=rev Author: jouni Date: 2009-09-06 07:11:57 +0000 (Sun, 06 Sep 2009) Log Message: ----------- Merged revisions 7638 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_99_maint ........ r7638 | astraw | 2009-09-06 02:20:45 +0300 (Su, 06 Syy 2009) | 4 lines spines: fix 'axes' position bug (closes SF#2852168) Thanks to Jason Grout for reporting this. ........ Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/spines.py Property Changed: ---------------- trunk/matplotlib/ trunk/matplotlib/doc/pyplots/README trunk/matplotlib/doc/sphinxext/gen_gallery.py trunk/matplotlib/doc/sphinxext/gen_rst.py trunk/matplotlib/examples/misc/multiprocess.py trunk/matplotlib/examples/mplot3d/contour3d_demo.py trunk/matplotlib/examples/mplot3d/contourf3d_demo.py trunk/matplotlib/examples/mplot3d/polys3d_demo.py trunk/matplotlib/examples/mplot3d/scatter3d_demo.py trunk/matplotlib/examples/mplot3d/surface3d_demo.py trunk/matplotlib/examples/mplot3d/wire3d_demo.py trunk/matplotlib/lib/matplotlib/sphinxext/mathmpl.py trunk/matplotlib/lib/matplotlib/sphinxext/only_directives.py trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/mathtex:1-7263 /branches/v0_99_maint:1-7633 /branches/v0_98_5_maint:1-7253 + /branches/v0_99_maint:1-7633,7638 /branches/mathtex:1-7263 /branches/v0_98_5_maint:1-7253 Modified: svn:mergeinfo - /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 + /branches/v0_91_maint:5753-5771 /branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633,7638 Property changes on: trunk/matplotlib/doc/pyplots/README ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/pyplots/README:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 + /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/pyplots/README:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633,7638 Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/sphinxext/gen_gallery.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 + /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/sphinxext/gen_gallery.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633,7638 Property changes on: trunk/matplotlib/doc/sphinxext/gen_rst.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/sphinxext/gen_rst.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 + /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771 /branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/doc/sphinxext/gen_rst.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633,7638 Property changes on: trunk/matplotlib/examples/misc/multiprocess.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/examples/misc/log.py:5753-5771 /branches/v0_98_5_maint/examples/misc/log.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/misc/multiprocess.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 + /branches/v0_91_maint/examples/misc/log.py:5753-5771 /branches/v0_98_5_maint/examples/misc/log.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/misc/multiprocess.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633,7638 Property changes on: trunk/matplotlib/examples/mplot3d/contour3d_demo.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/examples/mplot3d/contour.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/contour.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/contour3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 + /branches/v0_91_maint/examples/mplot3d/contour.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/contour.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/contour3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633,7638 Property changes on: trunk/matplotlib/examples/mplot3d/contourf3d_demo.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/examples/mplot3d/contourf.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/contourf.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/contourf3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 + /branches/v0_91_maint/examples/mplot3d/contourf.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/contourf.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/contourf3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633,7638 Property changes on: trunk/matplotlib/examples/mplot3d/polys3d_demo.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/examples/mplot3d/polys.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/polys.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/polys3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 + /branches/v0_91_maint/examples/mplot3d/polys.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/polys.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/polys3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633,7638 Property changes on: trunk/matplotlib/examples/mplot3d/scatter3d_demo.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/examples/mplot3d/scatter.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/scatter.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/scatter3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 + /branches/v0_91_maint/examples/mplot3d/scatter.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/scatter.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/scatter3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633,7638 Property changes on: trunk/matplotlib/examples/mplot3d/surface3d_demo.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/examples/mplot3d/surface.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/surface.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/surface3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 + /branches/v0_91_maint/examples/mplot3d/surface.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/surface.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/surface3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633,7638 Property changes on: trunk/matplotlib/examples/mplot3d/wire3d_demo.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/examples/mplot3d/wire.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/wire.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/wire3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 + /branches/v0_91_maint/examples/mplot3d/wire.py:5753-5771 /branches/v0_98_5_maint/examples/mplot3d/wire.py:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827,6850,6854,6856,6859,6861-6873,6883-6884,6886,6890-6891,6906-6909,6911-6912,6915-6916,6918,6920-6925,6927-6928,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080 /branches/v0_99_maint/examples/mplot3d/wire3d_demo.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633,7638 Property changes on: trunk/matplotlib/lib/matplotlib/sphinxext/mathmpl.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/sphinxext/mathmpl.py:5753-5771 /branches/v0_98_5_maint/lib/matplotlib/sphinxext/mathmpl.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/lib/matplotlib/sphinxext/mathmpl.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 + /branches/v0_91_maint/doc/sphinxext/mathmpl.py:5753-5771 /branches/v0_98_5_maint/lib/matplotlib/sphinxext/mathmpl.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/lib/matplotlib/sphinxext/mathmpl.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633,7638 Property changes on: trunk/matplotlib/lib/matplotlib/sphinxext/only_directives.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/sphinxext/only_directives.py:5753-5771 /branches/v0_98_5_maint/lib/matplotlib/sphinxext/only_directives.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/lib/matplotlib/sphinxext/only_directives.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 + /branches/v0_91_maint/doc/sphinxext/only_directives.py:5753-5771 /branches/v0_98_5_maint/lib/matplotlib/sphinxext/only_directives.py:6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/lib/matplotlib/sphinxext/only_directives.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633,7638 Property changes on: trunk/matplotlib/lib/matplotlib/sphinxext/plot_directive.py ___________________________________________________________________ Modified: svn:mergeinfo - /branches/v0_91_maint/doc/sphinxext/plot_directive.py:5753-5771 /branches/v0_98_5_maint/lib/matplotlib/sphinxext/plot_directive.py:6920-6925,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633 + /branches/v0_91_maint/doc/sphinxext/plot_directive.py:5753-5771 /branches/v0_98_5_maint/lib/matplotlib/sphinxext/plot_directive.py:6920-6925,6934,6941,6946,6948,6950,6952,6960,6972,6984-6985,6990,6995,6997-7001,7014,7016,7018,7024-7025,7033,7035,7042,7072,7080,7176,7209-7211,7227,7245 /branches/v0_99_maint/lib/matplotlib/sphinxext/plot_directive.py:7338,7393,7395-7404,7407-7424,7428-7433,7442-7444,7446,7475-7482,7484,7486,7489-7523,7567,7569,7582-7584,7616-7618,7633,7638 Modified: trunk/matplotlib/lib/matplotlib/spines.py =================================================================== --- trunk/matplotlib/lib/matplotlib/spines.py 2009-09-06 05:19:47 UTC (rev 7655) +++ trunk/matplotlib/lib/matplotlib/spines.py 2009-09-06 07:11:57 UTC (rev 7656) @@ -172,10 +172,14 @@ elif position_type=='axes': if self.spine_type in ('left','right'): self._spine_transform = ('pre', - mtransforms.Affine2D().translate(amount, 0.0)) + mtransforms.Affine2D.from_values( + # keep y unchanged, fix x at amount + 0,0,0,1,amount,0)) elif self.spine_type in ('bottom','top'): self._spine_transform = ('pre', - mtransforms.Affine2D().translate(0.0, amount)) + mtransforms.Affine2D.from_values( + # keep x unchanged, fix y at amount + 1,0,0,0,0,amount)) else: warnings.warn('unknown spine type "%s": no spine ' 'offset performed'%self.spine_type) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <as...@us...> - 2009-09-06 20:13:18
|
Revision: 7659 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7659&view=rev Author: astraw Date: 2009-09-06 20:13:06 +0000 (Sun, 06 Sep 2009) Log Message: ----------- testing: add matplotlib.test() function to run tests Modified Paths: -------------- trunk/matplotlib/doc/devel/coding_guide.rst trunk/matplotlib/lib/matplotlib/__init__.py trunk/matplotlib/test/run-mpl-test.py Modified: trunk/matplotlib/doc/devel/coding_guide.rst =================================================================== --- trunk/matplotlib/doc/devel/coding_guide.rst 2009-09-06 19:29:45 UTC (rev 7658) +++ trunk/matplotlib/doc/devel/coding_guide.rst 2009-09-06 20:13:06 UTC (rev 7659) @@ -774,10 +774,6 @@ ----------------------------------------- Let's say you've added a new module named -``matplotlib.tests.test_whizbang_features``. For the buildbot slave -machines to know to run a test, nose must look in that module. To add -a module to the list searched, add the line:: - - args.append('matplotlib.tests.test_whizbang_features') - -into :file:`test/run-mpl-test.py`. +``matplotlib.tests.test_whizbang_features``. To add this module to +the list of default tests, append its name to ``default_test_modules`` +in :file:`lib/matplotlib/__init__.py`. Modified: trunk/matplotlib/lib/matplotlib/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/__init__.py 2009-09-06 19:29:45 UTC (rev 7658) +++ trunk/matplotlib/lib/matplotlib/__init__.py 2009-09-06 20:13:06 UTC (rev 7659) @@ -876,7 +876,33 @@ pass # we don't want to assume all -d flags are backends, eg -debug +default_test_modules = [ + 'matplotlib.tests.test_basic', + 'matplotlib.tests.test_transforms', + 'matplotlib.tests.test_spines', + ] +def test(verbosity=0): + """run the matplotlib test suite""" + import nose + import nose.plugins.builtin + from testing.noseclasses import KnownFailure + from nose.plugins.manager import PluginManager + + plugins = [] + plugins.append( KnownFailure() ) + plugins.extend( [plugin() for plugin in nose.plugins.builtin.plugins] ) + + manager = PluginManager(plugins=plugins) + config = nose.config.Config(verbosity=verbosity, plugins=manager) + + success = nose.run( defaultTest=default_test_modules, + config=config, + ) + return success + +test.__test__ = False # nose: this function is not a test + verbose.report('matplotlib version %s'%__version__) verbose.report('verbose.level %s'%verbose.level) verbose.report('interactive is %s'%rcParams['interactive']) Modified: trunk/matplotlib/test/run-mpl-test.py =================================================================== --- trunk/matplotlib/test/run-mpl-test.py 2009-09-06 19:29:45 UTC (rev 7658) +++ trunk/matplotlib/test/run-mpl-test.py 2009-09-06 20:13:06 UTC (rev 7659) @@ -44,6 +44,7 @@ import nose from mplTest import MplNosePlugin, path_utils +import matplotlib from matplotlib.testing.noseclasses import KnownFailure if '--clean' in args: @@ -91,9 +92,8 @@ ### Run nose args.append('.') -args.append('matplotlib.tests.test_basic') -args.append('matplotlib.tests.test_transforms') -args.append('matplotlib.tests.test_spines') +args.extend( matplotlib.default_test_modules ) + success = nose.run( argv = args, plugins = [ MplNosePlugin(), KnownFailure() ] ) 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 (Sun, 06 Sep 2009) 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:47:02
|
Revision: 7667 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7667&view=rev Author: astraw Date: 2009-09-06 22:46:52 +0000 (Sun, 06 Sep 2009) 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:47:20
|
Revision: 7668 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7668&view=rev Author: astraw Date: 2009-09-06 22:47:08 +0000 (Sun, 06 Sep 2009) 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 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 (Sun, 06 Sep 2009) 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 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 (Sun, 06 Sep 2009) 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:28:40
|
Revision: 7671 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7671&view=rev Author: astraw Date: 2009-09-06 23:28:28 +0000 (Sun, 06 Sep 2009) 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. |
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 (Mon, 07 Sep 2009) 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:02:12
|
Revision: 7683 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7683&view=rev Author: astraw Date: 2009-09-07 20:02:06 +0000 (Mon, 07 Sep 2009) 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:02:30
|
Revision: 7684 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7684&view=rev Author: astraw Date: 2009-09-07 20:02:22 +0000 (Mon, 07 Sep 2009) 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:46
|
Revision: 7685 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7685&view=rev Author: astraw Date: 2009-09-07 20:02:39 +0000 (Mon, 07 Sep 2009) 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:03:05
|
Revision: 7686 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7686&view=rev Author: astraw Date: 2009-09-07 20:02:56 +0000 (Mon, 07 Sep 2009) Log Message: ----------- test conversion: move old-style test to new-style test Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/tests/test_axes.py Added Paths: ----------- trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/polar_coords.png Removed Paths: ------------- trunk/matplotlib/test/test_plots/TestAnnotation.py trunk/matplotlib/test/test_plots/baseline/TestAnnotation/polar_coords.png Copied: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/polar_coords.png (from rev 7685, trunk/matplotlib/test/test_plots/baseline/TestAnnotation/polar_coords.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:39 UTC (rev 7685) +++ trunk/matplotlib/lib/matplotlib/tests/test_axes.py 2009-09-07 20:02:56 UTC (rev 7686) @@ -94,3 +94,37 @@ ) fig.savefig( 'polar_axes' ) + + #-------------------------------------------------------------------- +@image_comparison(baseline_images=['polar_coords']) +def test_polar_coord_annotations(): + """Polar Coordinate Annotations""" + + # You can also use polar notation on a catesian axes. Here the + # native coordinate system ('data') is cartesian, so you need to + # specify the xycoords and textcoords as 'polar' if you want to + # use (theta, radius) + from matplotlib.patches import Ellipse + el = Ellipse((0,0), 10, 20, facecolor='r', alpha=0.5) + + fig = pylab.figure() + ax = fig.add_subplot( 111, aspect='equal' ) + + ax.add_artist( el ) + el.set_clip_box( ax.bbox ) + + ax.annotate('the top', + xy=(np.pi/2., 10.), # theta, radius + xytext=(np.pi/3, 20.), # theta, radius + xycoords='polar', + textcoords='polar', + arrowprops=dict(facecolor='black', shrink=0.05), + horizontalalignment='left', + verticalalignment='bottom', + clip_on=True, # clip to the axes bounding box + ) + + ax.set_xlim( -20, 20 ) + ax.set_ylim( -20, 20 ) + fig.savefig( 'polar_coords' ) + Deleted: trunk/matplotlib/test/test_plots/TestAnnotation.py =================================================================== --- trunk/matplotlib/test/test_plots/TestAnnotation.py 2009-09-07 20:02:39 UTC (rev 7685) +++ trunk/matplotlib/test/test_plots/TestAnnotation.py 2009-09-07 20:02:56 UTC (rev 7686) @@ -1,78 +0,0 @@ -#======================================================================= -"""The Annotation unite-test class implementation.""" -#======================================================================= - -from mplTest import * - -#======================================================================= -# Add import modules below. -import matplotlib -matplotlib.use( "Agg", warn = False ) - -from matplotlib.pyplot import figure -from matplotlib.patches import Ellipse -import numpy as npy -# -#======================================================================= - -#======================================================================= -class TestAnnotation( MplTestCase ): - """Annotation 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 - # 'units', # uses units in the test - 'PIL', # uses PIL for image comparison - ] - - #-------------------------------------------------------------------- - def setUp( self ): - """Setup any data needed for the unit test.""" - pass - - #-------------------------------------------------------------------- - def tearDown( self ): - """Clean-up any generated files here.""" - pass - - #-------------------------------------------------------------------- - def testPolarCoordAnnotations( self ): - """Polar Coordinate Annotations""" - - # You can also use polar notation on a catesian axes. Here the - # native coordinate system ('data') is cartesian, so you need to - # specify the xycoords and textcoords as 'polar' if you want to - # use (theta, radius) - - el = Ellipse((0,0), 10, 20, facecolor='r', alpha=0.5) - - fname = self.outFile( "polar_coords.png" ) - - fig = figure() - ax = fig.add_subplot( 111, aspect='equal' ) - - ax.add_artist( el ) - el.set_clip_box( ax.bbox ) - - ax.annotate('the top', - xy=(npy.pi/2., 10.), # theta, radius - xytext=(npy.pi/3, 20.), # theta, radius - xycoords='polar', - textcoords='polar', - arrowprops=dict(facecolor='black', shrink=0.05), - horizontalalignment='left', - verticalalignment='bottom', - clip_on=True, # clip to the axes bounding box - ) - - ax.set_xlim( -20, 20 ) - ax.set_ylim( -20, 20 ) - fig.savefig( fname ) - self.checkImage( fname ) - Deleted: trunk/matplotlib/test/test_plots/baseline/TestAnnotation/polar_coords.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:03:23
|
Revision: 7687 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7687&view=rev Author: astraw Date: 2009-09-07 20:03:12 +0000 (Mon, 07 Sep 2009) Log Message: ----------- test conversion: move old-style test to new-style test Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/tests/test_axes.py Added Paths: ----------- trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/fill_units.png Removed Paths: ------------- trunk/matplotlib/test/test_plots/TestFill.py trunk/matplotlib/test/test_plots/baseline/TestFill/fill_units.png Copied: trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/fill_units.png (from rev 7686, trunk/matplotlib/test/test_plots/baseline/TestFill/fill_units.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:56 UTC (rev 7686) +++ trunk/matplotlib/lib/matplotlib/tests/test_axes.py 2009-09-07 20:03:12 UTC (rev 7687) @@ -128,3 +128,45 @@ ax.set_ylim( -20, 20 ) fig.savefig( 'polar_coords' ) +@image_comparison(baseline_images=['fill_units']) +def test_fill_units(): + """Test the fill method with unitized-data.""" + from datetime import datetime + import matplotlib.testing.jpl_units as units + units.register() + + # generate some data + t = units.Epoch( "ET", dt=datetime(2009, 4, 27) ) + value = 10.0 * units.deg + day = units.Duration( "ET", 24.0 * 60.0 * 60.0 ) + + fig = pylab.figure() + + # Top-Left + ax1 = fig.add_subplot( 221 ) + ax1.plot( [t], [value], yunits='deg', color='red' ) + ax1.fill( [733525.0, 733525.0, 733526.0, 733526.0], + [0.0, 0.0, 90.0, 0.0], 'b' ) + + # Top-Right + ax2 = fig.add_subplot( 222 ) + ax2.plot( [t], [value], yunits='deg', color='red' ) + ax2.fill( [t, t, t+day, t+day], + [0.0, 0.0, 90.0, 0.0], 'b' ) + + # Bottom-Left + ax3 = fig.add_subplot( 223 ) + ax3.plot( [t], [value], yunits='deg', color='red' ) + ax1.fill( [733525.0, 733525.0, 733526.0, 733526.0], + [0*units.deg, 0*units.deg, 90*units.deg, 0*units.deg], 'b' ) + + # Bottom-Right + ax4 = fig.add_subplot( 224 ) + ax4.plot( [t], [value], yunits='deg', color='red' ) + ax4.fill( [t, t, t+day, t+day], + [0*units.deg, 0*units.deg, 90*units.deg, 0*units.deg], + facecolor="blue" ) + + fig.autofmt_xdate() + fig.savefig( 'fill_units' ) + Deleted: trunk/matplotlib/test/test_plots/TestFill.py =================================================================== --- trunk/matplotlib/test/test_plots/TestFill.py 2009-09-07 20:02:56 UTC (rev 7686) +++ trunk/matplotlib/test/test_plots/TestFill.py 2009-09-07 20:03:12 UTC (rev 7687) @@ -1,87 +0,0 @@ -#======================================================================= -"""The Fill 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 -# -#======================================================================= - -#======================================================================= -class TestFill( MplTestCase ): - """Test the various axes fill 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_fill_units( self ): - """Test the fill method with unitized-data.""" - - fname = self.outFile( "fill_units.png" ) - - # generate some data - t = units.Epoch( "ET", dt=datetime(2009, 4, 27) ) - value = 10.0 * units.deg - day = units.Duration( "ET", 24.0 * 60.0 * 60.0 ) - - fig = pylab.figure() - - # Top-Left - ax1 = fig.add_subplot( 221 ) - ax1.plot( [t], [value], yunits='deg', color='red' ) - ax1.fill( [733525.0, 733525.0, 733526.0, 733526.0], - [0.0, 0.0, 90.0, 0.0], 'b' ) - - # Top-Right - ax2 = fig.add_subplot( 222 ) - ax2.plot( [t], [value], yunits='deg', color='red' ) - ax2.fill( [t, t, t+day, t+day], - [0.0, 0.0, 90.0, 0.0], 'b' ) - - # Bottom-Left - ax3 = fig.add_subplot( 223 ) - ax3.plot( [t], [value], yunits='deg', color='red' ) - ax1.fill( [733525.0, 733525.0, 733526.0, 733526.0], - [0*units.deg, 0*units.deg, 90*units.deg, 0*units.deg], 'b' ) - - # Bottom-Right - ax4 = fig.add_subplot( 224 ) - ax4.plot( [t], [value], yunits='deg', color='red' ) - ax4.fill( [t, t, t+day, t+day], - [0*units.deg, 0*units.deg, 90*units.deg, 0*units.deg], - facecolor="blue" ) - - fig.autofmt_xdate() - fig.savefig( fname ) - self.checkImage( fname ) - - #-------------------------------------------------------------------- - Deleted: trunk/matplotlib/test/test_plots/baseline/TestFill/fill_units.png =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |