You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(115) |
Aug
(120) |
Sep
(137) |
Oct
(170) |
Nov
(461) |
Dec
(263) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(120) |
Feb
(74) |
Mar
(35) |
Apr
(74) |
May
(245) |
Jun
(356) |
Jul
(240) |
Aug
(115) |
Sep
(78) |
Oct
(225) |
Nov
(98) |
Dec
(271) |
| 2009 |
Jan
(132) |
Feb
(84) |
Mar
(74) |
Apr
(56) |
May
(90) |
Jun
(79) |
Jul
(83) |
Aug
(296) |
Sep
(214) |
Oct
(76) |
Nov
(82) |
Dec
(66) |
| 2010 |
Jan
(46) |
Feb
(58) |
Mar
(51) |
Apr
(77) |
May
(58) |
Jun
(126) |
Jul
(128) |
Aug
(64) |
Sep
(50) |
Oct
(44) |
Nov
(48) |
Dec
(54) |
| 2011 |
Jan
(68) |
Feb
(52) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <jd...@us...> - 2008-10-21 14:53:10
|
Revision: 6287
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6287&view=rev
Author: jdh2358
Date: 2008-10-21 14:52:59 +0000 (Tue, 21 Oct 2008)
Log Message:
-----------
cleaned up output of mathmpl and plot directive; added thumbnail gallery
Modified Paths:
--------------
trunk/matplotlib/doc/_templates/index.html
trunk/matplotlib/doc/_templates/layout.html
trunk/matplotlib/doc/conf.py
trunk/matplotlib/doc/devel/coding_guide.rst
trunk/matplotlib/doc/examples/gen_rst.py
trunk/matplotlib/doc/faq/environment_variables_faq.rst
trunk/matplotlib/doc/faq/installing_faq.rst
trunk/matplotlib/doc/make.py
trunk/matplotlib/doc/sphinxext/mathmpl.py
trunk/matplotlib/doc/sphinxext/plot_directive.py
trunk/matplotlib/doc/users/screenshots.rst
trunk/matplotlib/doc/users/usetex.rst
trunk/matplotlib/examples/pylab_examples/polar_demo.py
trunk/matplotlib/lib/matplotlib/cbook.py
trunk/matplotlib/lib/matplotlib/image.py
Added Paths:
-----------
trunk/matplotlib/doc/_templates/gallery.html
trunk/matplotlib/doc/_templates/gen_gallery.py
Added: trunk/matplotlib/doc/_templates/gallery.html
===================================================================
--- trunk/matplotlib/doc/_templates/gallery.html (rev 0)
+++ trunk/matplotlib/doc/_templates/gallery.html 2008-10-21 14:52:59 UTC (rev 6287)
@@ -0,0 +1,498 @@
+{% extends "layout.html" %}
+{% set title = "Thumbnail gallery" %}
+
+
+{% block body %}
+
+<h3>Click on any image to see full size image and source code</h3>
+<br>
+
+<a href="examples/api/barchart_demo.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/barchart_demo.png" border="0" alt="barchart_demo"/></a>
+
+<a href="examples/api/bbox_intersect.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/bbox_intersect.png" border="0" alt="bbox_intersect"/></a>
+
+<a href="examples/api/collections_demo.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/collections_demo.png" border="0" alt="collections_demo"/></a>
+
+<a href="examples/api/color_cycle.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/color_cycle.png" border="0" alt="color_cycle"/></a>
+
+<a href="examples/api/colorbar_only.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/colorbar_only.png" border="0" alt="colorbar_only"/></a>
+
+<a href="examples/api/custom_projection_example.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/custom_projection_example.png" border="0" alt="custom_projection_example"/></a>
+
+<a href="examples/api/custom_scale_example.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/custom_scale_example.png" border="0" alt="custom_scale_example"/></a>
+
+<a href="examples/api/date_demo.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/date_demo.png" border="0" alt="date_demo"/></a>
+
+<a href="examples/api/date_index_formatter.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/date_index_formatter.png" border="0" alt="date_index_formatter"/></a>
+
+<a href="examples/api/date_index_formatter.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/date_index_formatter_01.png" border="0" alt="date_index_formatter"/></a>
+
+<a href="examples/api/donut_demo.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/donut_demo.png" border="0" alt="donut_demo"/></a>
+
+<a href="examples/api/histogram_demo.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/histogram_demo.png" border="0" alt="histogram_demo"/></a>
+
+<a href="examples/api/image_zcoord.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/image_zcoord.png" border="0" alt="image_zcoord"/></a>
+
+<a href="examples/api/legend_demo.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/legend_demo.png" border="0" alt="legend_demo"/></a>
+
+<a href="examples/api/line_with_text.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/line_with_text.png" border="0" alt="line_with_text"/></a>
+
+<a href="examples/api/logo2.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/logo2.png" border="0" alt="logo2"/></a>
+
+<a href="examples/api/mathtext_asarray.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/mathtext_asarray.png" border="0" alt="mathtext_asarray"/></a>
+
+<a href="examples/api/patch_collection.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/patch_collection.png" border="0" alt="patch_collection"/></a>
+
+<a href="examples/api/path_patch_demo.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/path_patch_demo.png" border="0" alt="path_patch_demo"/></a>
+
+<a href="examples/api/quad_bezier.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/quad_bezier.png" border="0" alt="quad_bezier"/></a>
+
+<a href="examples/api/scatter_piecharts.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/scatter_piecharts.png" border="0" alt="scatter_piecharts"/></a>
+
+<a href="examples/api/two_scales.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/two_scales.png" border="0" alt="two_scales"/></a>
+
+<a href="examples/api/watermark_image.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/watermark_image.png" border="0" alt="watermark_image"/></a>
+
+<a href="examples/api/watermark_text.html"><img src="_static/plot_directive/mpl_examples/api/thumbnails/watermark_text.png" border="0" alt="watermark_text"/></a>
+
+<a href="examples/pylab_examples/accented_text.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/accented_text.png" border="0" alt="accented_text"/></a>
+
+<a href="examples/pylab_examples/agg_buffer_to_array.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/agg_buffer_to_array.png" border="0" alt="agg_buffer_to_array"/></a>
+
+<a href="examples/pylab_examples/agg_buffer_to_array.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/agg_buffer_to_array_01.png" border="0" alt="agg_buffer_to_array"/></a>
+
+<a href="examples/pylab_examples/alignment_test.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/alignment_test.png" border="0" alt="alignment_test"/></a>
+
+<a href="examples/pylab_examples/annotation_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/annotation_demo.png" border="0" alt="annotation_demo"/></a>
+
+<a href="examples/pylab_examples/annotation_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/annotation_demo_01.png" border="0" alt="annotation_demo"/></a>
+
+<a href="examples/pylab_examples/annotation_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/annotation_demo_02.png" border="0" alt="annotation_demo"/></a>
+
+<a href="examples/pylab_examples/anscombe.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/anscombe.png" border="0" alt="anscombe"/></a>
+
+<a href="examples/pylab_examples/arctest.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/arctest.png" border="0" alt="arctest"/></a>
+
+<a href="examples/pylab_examples/arrow_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/arrow_demo.png" border="0" alt="arrow_demo"/></a>
+
+<a href="examples/pylab_examples/axes_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/axes_demo.png" border="0" alt="axes_demo"/></a>
+
+<a href="examples/pylab_examples/axes_props.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/axes_props.png" border="0" alt="axes_props"/></a>
+
+<a href="examples/pylab_examples/axhspan_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/axhspan_demo.png" border="0" alt="axhspan_demo"/></a>
+
+<a href="examples/pylab_examples/axis_equal_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/axis_equal_demo.png" border="0" alt="axis_equal_demo"/></a>
+
+<a href="examples/pylab_examples/bar_stacked.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/bar_stacked.png" border="0" alt="bar_stacked"/></a>
+
+<a href="examples/pylab_examples/barb_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/barb_demo.png" border="0" alt="barb_demo"/></a>
+
+<a href="examples/pylab_examples/barchart_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/barchart_demo.png" border="0" alt="barchart_demo"/></a>
+
+<a href="examples/pylab_examples/barcode_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/barcode_demo.png" border="0" alt="barcode_demo"/></a>
+
+<a href="examples/pylab_examples/barh_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/barh_demo.png" border="0" alt="barh_demo"/></a>
+
+<a href="examples/pylab_examples/barh_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/barh_demo_01.png" border="0" alt="barh_demo"/></a>
+
+<a href="examples/pylab_examples/boxplot_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/boxplot_demo.png" border="0" alt="boxplot_demo"/></a>
+
+<a href="examples/pylab_examples/boxplot_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/boxplot_demo_01.png" border="0" alt="boxplot_demo"/></a>
+
+<a href="examples/pylab_examples/boxplot_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/boxplot_demo_02.png" border="0" alt="boxplot_demo"/></a>
+
+<a href="examples/pylab_examples/boxplot_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/boxplot_demo_03.png" border="0" alt="boxplot_demo"/></a>
+
+<a href="examples/pylab_examples/boxplot_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/boxplot_demo_04.png" border="0" alt="boxplot_demo"/></a>
+
+<a href="examples/pylab_examples/boxplot_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/boxplot_demo_05.png" border="0" alt="boxplot_demo"/></a>
+
+<a href="examples/pylab_examples/boxplot_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/boxplot_demo_06.png" border="0" alt="boxplot_demo"/></a>
+
+<a href="examples/pylab_examples/break.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/break.png" border="0" alt="break"/></a>
+
+<a href="examples/pylab_examples/broken_barh.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/broken_barh.png" border="0" alt="broken_barh"/></a>
+
+<a href="examples/pylab_examples/clippedline.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/clippedline.png" border="0" alt="clippedline"/></a>
+
+<a href="examples/pylab_examples/cohere_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/cohere_demo.png" border="0" alt="cohere_demo"/></a>
+
+<a href="examples/pylab_examples/color_by_yvalue.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/color_by_yvalue.png" border="0" alt="color_by_yvalue"/></a>
+
+<a href="examples/pylab_examples/color_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/color_demo.png" border="0" alt="color_demo"/></a>
+
+<a href="examples/pylab_examples/contour_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/contour_demo.png" border="0" alt="contour_demo"/></a>
+
+<a href="examples/pylab_examples/contour_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/contour_demo_01.png" border="0" alt="contour_demo"/></a>
+
+<a href="examples/pylab_examples/contour_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/contour_demo_02.png" border="0" alt="contour_demo"/></a>
+
+<a href="examples/pylab_examples/contour_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/contour_demo_03.png" border="0" alt="contour_demo"/></a>
+
+<a href="examples/pylab_examples/contour_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/contour_demo_04.png" border="0" alt="contour_demo"/></a>
+
+<a href="examples/pylab_examples/contour_image.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/contour_image.png" border="0" alt="contour_image"/></a>
+
+<a href="examples/pylab_examples/contour_label_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/contour_label_demo.png" border="0" alt="contour_label_demo"/></a>
+
+<a href="examples/pylab_examples/contour_label_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/contour_label_demo_01.png" border="0" alt="contour_label_demo"/></a>
+
+<a href="examples/pylab_examples/contourf_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/contourf_demo.png" border="0" alt="contourf_demo"/></a>
+
+<a href="examples/pylab_examples/contourf_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/contourf_demo_01.png" border="0" alt="contourf_demo"/></a>
+
+<a href="examples/pylab_examples/contourf_log.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/contourf_log.png" border="0" alt="contourf_log"/></a>
+
+<a href="examples/pylab_examples/coords_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/coords_demo.png" border="0" alt="coords_demo"/></a>
+
+<a href="examples/pylab_examples/coords_report.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/coords_report.png" border="0" alt="coords_report"/></a>
+
+<a href="examples/pylab_examples/csd_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/csd_demo.png" border="0" alt="csd_demo"/></a>
+
+<a href="examples/pylab_examples/custom_figure_class.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/custom_figure_class.png" border="0" alt="custom_figure_class"/></a>
+
+<a href="examples/pylab_examples/custom_ticker1.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/custom_ticker1.png" border="0" alt="custom_ticker1"/></a>
+
+<a href="examples/pylab_examples/customize_rc.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/customize_rc.png" border="0" alt="customize_rc"/></a>
+
+<a href="examples/pylab_examples/dannys_example.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/dannys_example.png" border="0" alt="dannys_example"/></a>
+
+<a href="examples/pylab_examples/dash_control.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/dash_control.png" border="0" alt="dash_control"/></a>
+
+<a href="examples/pylab_examples/dashpointlabel.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/dashpointlabel.png" border="0" alt="dashpointlabel"/></a>
+
+<a href="examples/pylab_examples/date_demo1.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/date_demo1.png" border="0" alt="date_demo1"/></a>
+
+<a href="examples/pylab_examples/date_demo2.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/date_demo2.png" border="0" alt="date_demo2"/></a>
+
+<a href="examples/pylab_examples/date_demo_convert.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/date_demo_convert.png" border="0" alt="date_demo_convert"/></a>
+
+<a href="examples/pylab_examples/date_demo_rrule.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/date_demo_rrule.png" border="0" alt="date_demo_rrule"/></a>
+
+<a href="examples/pylab_examples/date_index_formatter.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/date_index_formatter.png" border="0" alt="date_index_formatter"/></a>
+
+<a href="examples/pylab_examples/dolphin.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/dolphin.png" border="0" alt="dolphin"/></a>
+
+<a href="examples/pylab_examples/ellipse_collection.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/ellipse_collection.png" border="0" alt="ellipse_collection"/></a>
+
+<a href="examples/pylab_examples/ellipse_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/ellipse_demo.png" border="0" alt="ellipse_demo"/></a>
+
+<a href="examples/pylab_examples/ellipse_rotated.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/ellipse_rotated.png" border="0" alt="ellipse_rotated"/></a>
+
+<a href="examples/pylab_examples/equal_aspect_ratio.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/equal_aspect_ratio.png" border="0" alt="equal_aspect_ratio"/></a>
+
+<a href="examples/pylab_examples/errorbar_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/errorbar_demo.png" border="0" alt="errorbar_demo"/></a>
+
+<a href="examples/pylab_examples/errorbar_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/errorbar_demo_01.png" border="0" alt="errorbar_demo"/></a>
+
+<a href="examples/pylab_examples/errorbar_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/errorbar_demo_02.png" border="0" alt="errorbar_demo"/></a>
+
+<a href="examples/pylab_examples/errorbar_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/errorbar_demo_03.png" border="0" alt="errorbar_demo"/></a>
+
+<a href="examples/pylab_examples/errorbar_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/errorbar_demo_04.png" border="0" alt="errorbar_demo"/></a>
+
+<a href="examples/pylab_examples/errorbar_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/errorbar_demo_05.png" border="0" alt="errorbar_demo"/></a>
+
+<a href="examples/pylab_examples/errorbar_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/errorbar_demo_06.png" border="0" alt="errorbar_demo"/></a>
+
+<a href="examples/pylab_examples/errorbar_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/errorbar_demo_07.png" border="0" alt="errorbar_demo"/></a>
+
+<a href="examples/pylab_examples/errorbar_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/errorbar_demo_08.png" border="0" alt="errorbar_demo"/></a>
+
+<a href="examples/pylab_examples/errorbar_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/errorbar_demo_09.png" border="0" alt="errorbar_demo"/></a>
+
+<a href="examples/pylab_examples/errorbar_limits.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/errorbar_limits.png" border="0" alt="errorbar_limits"/></a>
+
+<a href="examples/pylab_examples/errorbar_limits.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/errorbar_limits_01.png" border="0" alt="errorbar_limits"/></a>
+
+<a href="examples/pylab_examples/fancybox_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/fancybox_demo.png" border="0" alt="fancybox_demo"/></a>
+
+<a href="examples/pylab_examples/fancytextbox_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/fancytextbox_demo.png" border="0" alt="fancytextbox_demo"/></a>
+
+<a href="examples/pylab_examples/figimage_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/figimage_demo.png" border="0" alt="figimage_demo"/></a>
+
+<a href="examples/pylab_examples/figlegend_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/figlegend_demo.png" border="0" alt="figlegend_demo"/></a>
+
+<a href="examples/pylab_examples/figure_title.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/figure_title.png" border="0" alt="figure_title"/></a>
+
+<a href="examples/pylab_examples/fill_between.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/fill_between.png" border="0" alt="fill_between"/></a>
+
+<a href="examples/pylab_examples/fill_between_posneg.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/fill_between_posneg.png" border="0" alt="fill_between_posneg"/></a>
+
+<a href="examples/pylab_examples/fill_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/fill_demo.png" border="0" alt="fill_demo"/></a>
+
+<a href="examples/pylab_examples/fill_demo2.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/fill_demo2.png" border="0" alt="fill_demo2"/></a>
+
+<a href="examples/pylab_examples/fill_spiral.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/fill_spiral.png" border="0" alt="fill_spiral"/></a>
+
+<a href="examples/pylab_examples/finance_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/finance_demo.png" border="0" alt="finance_demo"/></a>
+
+<a href="examples/pylab_examples/finance_work2.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/finance_work2.png" border="0" alt="finance_work2"/></a>
+
+<a href="examples/pylab_examples/findobj_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/findobj_demo.png" border="0" alt="findobj_demo"/></a>
+
+<a href="examples/pylab_examples/fonts_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/fonts_demo.png" border="0" alt="fonts_demo"/></a>
+
+<a href="examples/pylab_examples/fonts_demo_kw.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/fonts_demo_kw.png" border="0" alt="fonts_demo_kw"/></a>
+
+<a href="examples/pylab_examples/ganged_plots.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/ganged_plots.png" border="0" alt="ganged_plots"/></a>
+
+<a href="examples/pylab_examples/geo_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/geo_demo.png" border="0" alt="geo_demo"/></a>
+
+<a href="examples/pylab_examples/gradient_bar.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/gradient_bar.png" border="0" alt="gradient_bar"/></a>
+
+<a href="examples/pylab_examples/griddata_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/griddata_demo.png" border="0" alt="griddata_demo"/></a>
+
+<a href="examples/pylab_examples/hatch_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/hatch_demo.png" border="0" alt="hatch_demo"/></a>
+
+<a href="examples/pylab_examples/hexbin_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/hexbin_demo.png" border="0" alt="hexbin_demo"/></a>
+
+<a href="examples/pylab_examples/hexbin_demo2.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/hexbin_demo2.png" border="0" alt="hexbin_demo2"/></a>
+
+<a href="examples/pylab_examples/hist_colormapped.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/hist_colormapped.png" border="0" alt="hist_colormapped"/></a>
+
+<a href="examples/pylab_examples/histogram_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/histogram_demo.png" border="0" alt="histogram_demo"/></a>
+
+<a href="examples/pylab_examples/histogram_demo_extended.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/histogram_demo_extended.png" border="0" alt="histogram_demo_extended"/></a>
+
+<a href="examples/pylab_examples/histogram_demo_extended.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/histogram_demo_extended_01.png" border="0" alt="histogram_demo_extended"/></a>
+
+<a href="examples/pylab_examples/histogram_demo_extended.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/histogram_demo_extended_02.png" border="0" alt="histogram_demo_extended"/></a>
+
+<a href="examples/pylab_examples/histogram_demo_extended.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/histogram_demo_extended_03.png" border="0" alt="histogram_demo_extended"/></a>
+
+<a href="examples/pylab_examples/histogram_demo_extended.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/histogram_demo_extended_04.png" border="0" alt="histogram_demo_extended"/></a>
+
+<a href="examples/pylab_examples/histogram_demo_extended.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/histogram_demo_extended_05.png" border="0" alt="histogram_demo_extended"/></a>
+
+<a href="examples/pylab_examples/hline_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/hline_demo.png" border="0" alt="hline_demo"/></a>
+
+<a href="examples/pylab_examples/image_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/image_demo.png" border="0" alt="image_demo"/></a>
+
+<a href="examples/pylab_examples/image_demo2.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/image_demo2.png" border="0" alt="image_demo2"/></a>
+
+<a href="examples/pylab_examples/image_demo3.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/image_demo3.png" border="0" alt="image_demo3"/></a>
+
+<a href="examples/pylab_examples/image_interp.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/image_interp.png" border="0" alt="image_interp"/></a>
+
+<a href="examples/pylab_examples/image_interp.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/image_interp_01.png" border="0" alt="image_interp"/></a>
+
+<a href="examples/pylab_examples/image_interp.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/image_interp_02.png" border="0" alt="image_interp"/></a>
+
+<a href="examples/pylab_examples/image_masked.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/image_masked.png" border="0" alt="image_masked"/></a>
+
+<a href="examples/pylab_examples/image_nonuniform.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/image_nonuniform.png" border="0" alt="image_nonuniform"/></a>
+
+<a href="examples/pylab_examples/image_origin.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/image_origin.png" border="0" alt="image_origin"/></a>
+
+<a href="examples/pylab_examples/image_slices_viewer.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/image_slices_viewer.png" border="0" alt="image_slices_viewer"/></a>
+
+<a href="examples/pylab_examples/integral_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/integral_demo.png" border="0" alt="integral_demo"/></a>
+
+<a href="examples/pylab_examples/interp_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/interp_demo.png" border="0" alt="interp_demo"/></a>
+
+<a href="examples/pylab_examples/invert_axes.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/invert_axes.png" border="0" alt="invert_axes"/></a>
+
+<a href="examples/pylab_examples/layer_images.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/layer_images.png" border="0" alt="layer_images"/></a>
+
+<a href="examples/pylab_examples/legend_auto.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/legend_auto.png" border="0" alt="legend_auto"/></a>
+
+<a href="examples/pylab_examples/legend_auto.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/legend_auto_01.png" border="0" alt="legend_auto"/></a>
+
+<a href="examples/pylab_examples/legend_auto.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/legend_auto_02.png" border="0" alt="legend_auto"/></a>
+
+<a href="examples/pylab_examples/legend_auto.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/legend_auto_03.png" border="0" alt="legend_auto"/></a>
+
+<a href="examples/pylab_examples/legend_auto.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/legend_auto_04.png" border="0" alt="legend_auto"/></a>
+
+<a href="examples/pylab_examples/legend_auto.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/legend_auto_05.png" border="0" alt="legend_auto"/></a>
+
+<a href="examples/pylab_examples/legend_auto.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/legend_auto_06.png" border="0" alt="legend_auto"/></a>
+
+<a href="examples/pylab_examples/legend_auto.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/legend_auto_07.png" border="0" alt="legend_auto"/></a>
+
+<a href="examples/pylab_examples/legend_auto.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/legend_auto_08.png" border="0" alt="legend_auto"/></a>
+
+<a href="examples/pylab_examples/legend_auto.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/legend_auto_09.png" border="0" alt="legend_auto"/></a>
+
+<a href="examples/pylab_examples/legend_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/legend_demo.png" border="0" alt="legend_demo"/></a>
+
+<a href="examples/pylab_examples/legend_demo2.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/legend_demo2.png" border="0" alt="legend_demo2"/></a>
+
+<a href="examples/pylab_examples/legend_scatter.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/legend_scatter.png" border="0" alt="legend_scatter"/></a>
+
+<a href="examples/pylab_examples/line_collection.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/line_collection.png" border="0" alt="line_collection"/></a>
+
+<a href="examples/pylab_examples/line_collection2.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/line_collection2.png" border="0" alt="line_collection2"/></a>
+
+<a href="examples/pylab_examples/line_styles.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/line_styles.png" border="0" alt="line_styles"/></a>
+
+<a href="examples/pylab_examples/load_converter.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/load_converter.png" border="0" alt="load_converter"/></a>
+
+<a href="examples/pylab_examples/loadrec.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/loadrec.png" border="0" alt="loadrec"/></a>
+
+<a href="examples/pylab_examples/log_bar.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/log_bar.png" border="0" alt="log_bar"/></a>
+
+<a href="examples/pylab_examples/log_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/log_demo.png" border="0" alt="log_demo"/></a>
+
+<a href="examples/pylab_examples/log_test.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/log_test.png" border="0" alt="log_test"/></a>
+
+<a href="examples/pylab_examples/logo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/logo.png" border="0" alt="logo"/></a>
+
+<a href="examples/pylab_examples/major_minor_demo1.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/major_minor_demo1.png" border="0" alt="major_minor_demo1"/></a>
+
+<a href="examples/pylab_examples/major_minor_demo2.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/major_minor_demo2.png" border="0" alt="major_minor_demo2"/></a>
+
+<a href="examples/pylab_examples/manual_axis.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/manual_axis.png" border="0" alt="manual_axis"/></a>
+
+<a href="examples/pylab_examples/masked_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/masked_demo.png" border="0" alt="masked_demo"/></a>
+
+<a href="examples/pylab_examples/mathtext_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/mathtext_demo.png" border="0" alt="mathtext_demo"/></a>
+
+<a href="examples/pylab_examples/matshow.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/matshow.png" border="0" alt="matshow"/></a>
+
+<a href="examples/pylab_examples/matshow.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/matshow_01.png" border="0" alt="matshow"/></a>
+
+<a href="examples/pylab_examples/matshow.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/matshow_04.png" border="0" alt="matshow"/></a>
+
+<a href="examples/pylab_examples/mri_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/mri_demo.png" border="0" alt="mri_demo"/></a>
+
+<a href="examples/pylab_examples/mri_with_eeg.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/mri_with_eeg.png" border="0" alt="mri_with_eeg"/></a>
+
+<a href="examples/pylab_examples/multi_image.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/multi_image.png" border="0" alt="multi_image"/></a>
+
+<a href="examples/pylab_examples/multiline.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/multiline.png" border="0" alt="multiline"/></a>
+
+<a href="examples/pylab_examples/multiple_figs_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/multiple_figs_demo.png" border="0" alt="multiple_figs_demo"/></a>
+
+<a href="examples/pylab_examples/multiple_figs_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/multiple_figs_demo_01.png" border="0" alt="multiple_figs_demo"/></a>
+
+<a href="examples/pylab_examples/nan_test.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/nan_test.png" border="0" alt="nan_test"/></a>
+
+<a href="examples/pylab_examples/newscalarformatter_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/newscalarformatter_demo.png" border="0" alt="newscalarformatter_demo"/></a>
+
+<a href="examples/pylab_examples/newscalarformatter_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/newscalarformatter_demo_01.png" border="0" alt="newscalarformatter_demo"/></a>
+
+<a href="examples/pylab_examples/newscalarformatter_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/newscalarformatter_demo_02.png" border="0" alt="newscalarformatter_demo"/></a>
+
+<a href="examples/pylab_examples/newscalarformatter_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/newscalarformatter_demo_03.png" border="0" alt="newscalarformatter_demo"/></a>
+
+<a href="examples/pylab_examples/pcolor_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/pcolor_demo.png" border="0" alt="pcolor_demo"/></a>
+
+<a href="examples/pylab_examples/pcolor_demo2.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/pcolor_demo2.png" border="0" alt="pcolor_demo2"/></a>
+
+<a href="examples/pylab_examples/pcolor_log.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/pcolor_log.png" border="0" alt="pcolor_log"/></a>
+
+<a href="examples/pylab_examples/pcolor_small.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/pcolor_small.png" border="0" alt="pcolor_small"/></a>
+
+<a href="examples/pylab_examples/pie_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/pie_demo.png" border="0" alt="pie_demo"/></a>
+
+<a href="examples/pylab_examples/plotfile_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/plotfile_demo.png" border="0" alt="plotfile_demo"/></a>
+
+<a href="examples/pylab_examples/plotfile_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/plotfile_demo_01.png" border="0" alt="plotfile_demo"/></a>
+
+<a href="examples/pylab_examples/plotfile_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/plotfile_demo_02.png" border="0" alt="plotfile_demo"/></a>
+
+<a href="examples/pylab_examples/plotfile_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/plotfile_demo_03.png" border="0" alt="plotfile_demo"/></a>
+
+<a href="examples/pylab_examples/plotfile_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/plotfile_demo_04.png" border="0" alt="plotfile_demo"/></a>
+
+<a href="examples/pylab_examples/polar_bar.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/polar_bar.png" border="0" alt="polar_bar"/></a>
+
+<a href="examples/pylab_examples/polar_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/polar_demo.png" border="0" alt="polar_demo"/></a>
+
+<a href="examples/pylab_examples/polar_legend.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/polar_legend.png" border="0" alt="polar_legend"/></a>
+
+<a href="examples/pylab_examples/polar_scatter.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/polar_scatter.png" border="0" alt="polar_scatter"/></a>
+
+<a href="examples/pylab_examples/poormans_contour.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/poormans_contour.png" border="0" alt="poormans_contour"/></a>
+
+<a href="examples/pylab_examples/psd_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/psd_demo.png" border="0" alt="psd_demo"/></a>
+
+<a href="examples/pylab_examples/pythonic_matplotlib.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/pythonic_matplotlib.png" border="0" alt="pythonic_matplotlib"/></a>
+
+<a href="examples/pylab_examples/quadmesh_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/quadmesh_demo.png" border="0" alt="quadmesh_demo"/></a>
+
+<a href="examples/pylab_examples/quiver_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/quiver_demo.png" border="0" alt="quiver_demo"/></a>
+
+<a href="examples/pylab_examples/quiver_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/quiver_demo_01.png" border="0" alt="quiver_demo"/></a>
+
+<a href="examples/pylab_examples/quiver_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/quiver_demo_02.png" border="0" alt="quiver_demo"/></a>
+
+<a href="examples/pylab_examples/quiver_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/quiver_demo_03.png" border="0" alt="quiver_demo"/></a>
+
+<a href="examples/pylab_examples/quiver_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/quiver_demo_04.png" border="0" alt="quiver_demo"/></a>
+
+<a href="examples/pylab_examples/quiver_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/quiver_demo_05.png" border="0" alt="quiver_demo"/></a>
+
+<a href="examples/pylab_examples/scatter_custom_symbol.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/scatter_custom_symbol.png" border="0" alt="scatter_custom_symbol"/></a>
+
+<a href="examples/pylab_examples/scatter_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/scatter_demo.png" border="0" alt="scatter_demo"/></a>
+
+<a href="examples/pylab_examples/scatter_demo2.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/scatter_demo2.png" border="0" alt="scatter_demo2"/></a>
+
+<a href="examples/pylab_examples/scatter_masked.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/scatter_masked.png" border="0" alt="scatter_masked"/></a>
+
+<a href="examples/pylab_examples/scatter_star_poly.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/scatter_star_poly.png" border="0" alt="scatter_star_poly"/></a>
+
+<a href="examples/pylab_examples/set_and_get.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/set_and_get.png" border="0" alt="set_and_get"/></a>
+
+<a href="examples/pylab_examples/shared_axis_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/shared_axis_demo.png" border="0" alt="shared_axis_demo"/></a>
+
+<a href="examples/pylab_examples/simple_plot.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/simple_plot.png" border="0" alt="simple_plot"/></a>
+
+<a href="examples/pylab_examples/simplification_clipping_test.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/simplification_clipping_test.png" border="0" alt="simplification_clipping_test"/></a>
+
+<a href="examples/pylab_examples/specgram_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/specgram_demo.png" border="0" alt="specgram_demo"/></a>
+
+<a href="examples/pylab_examples/spy_demos.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/spy_demos.png" border="0" alt="spy_demos"/></a>
+
+<a href="examples/pylab_examples/stem_plot.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/stem_plot.png" border="0" alt="stem_plot"/></a>
+
+<a href="examples/pylab_examples/step_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/step_demo.png" border="0" alt="step_demo"/></a>
+
+<a href="examples/pylab_examples/stix_fonts_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/stix_fonts_demo.png" border="0" alt="stix_fonts_demo"/></a>
+
+<a href="examples/pylab_examples/subplot_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/subplot_demo.png" border="0" alt="subplot_demo"/></a>
+
+<a href="examples/pylab_examples/subplot_toolbar.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/subplot_toolbar.png" border="0" alt="subplot_toolbar"/></a>
+
+<a href="examples/pylab_examples/subplot_toolbar.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/subplot_toolbar_01.png" border="0" alt="subplot_toolbar"/></a>
+
+<a href="examples/pylab_examples/subplots_adjust.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/subplots_adjust.png" border="0" alt="subplots_adjust"/></a>
+
+<a href="examples/pylab_examples/symlog_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/symlog_demo.png" border="0" alt="symlog_demo"/></a>
+
+<a href="examples/pylab_examples/table_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/table_demo.png" border="0" alt="table_demo"/></a>
+
+<a href="examples/pylab_examples/tex_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/tex_demo.png" border="0" alt="tex_demo"/></a>
+
+<a href="examples/pylab_examples/text_handles.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/text_handles.png" border="0" alt="text_handles"/></a>
+
+<a href="examples/pylab_examples/text_rotation.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/text_rotation.png" border="0" alt="text_rotation"/></a>
+
+<a href="examples/pylab_examples/text_themes.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/text_themes.png" border="0" alt="text_themes"/></a>
+
+<a href="examples/pylab_examples/to_numeric.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/to_numeric.png" border="0" alt="to_numeric"/></a>
+
+<a href="examples/pylab_examples/toggle_images.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/toggle_images.png" border="0" alt="toggle_images"/></a>
+
+<a href="examples/pylab_examples/transoffset.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/transoffset.png" border="0" alt="transoffset"/></a>
+
+<a href="examples/pylab_examples/unicode_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/unicode_demo.png" border="0" alt="unicode_demo"/></a>
+
+<a href="examples/pylab_examples/usetex_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/usetex_demo.png" border="0" alt="usetex_demo"/></a>
+
+<a href="examples/pylab_examples/vertical_ticklabels.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/vertical_ticklabels.png" border="0" alt="vertical_ticklabels"/></a>
+
+<a href="examples/pylab_examples/vline_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/vline_demo.png" border="0" alt="vline_demo"/></a>
+
+<a href="examples/pylab_examples/xcorr_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/xcorr_demo.png" border="0" alt="xcorr_demo"/></a>
+
+<a href="examples/pylab_examples/zorder_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/zorder_demo.png" border="0" alt="zorder_demo"/></a>
+
+<a href="examples/pylab_examples/zorder_demo.html"><img src="_static/plot_directive/mpl_examples/pylab_examples/thumbnails/zorder_demo_01.png" border="0" alt="zorder_demo"/></a>
+
+<a href="examples/widgets/slider_demo.html"><img src="_static/plot_directive/mpl_examples/widgets/thumbnails/slider_demo.png" border="0" alt="slider_demo"/></a>
+
+{% endblock %}
Added: trunk/matplotlib/doc/_templates/gen_gallery.py
===================================================================
--- trunk/matplotlib/doc/_templates/gen_gallery.py (rev 0)
+++ trunk/matplotlib/doc/_templates/gen_gallery.py 2008-10-21 14:52:59 UTC (rev 6287)
@@ -0,0 +1,91 @@
+# generate a thumbnail gallery of examples
+template = """\
+{%% extends "layout.html" %%}
+{%% set title = "Thumbnail gallery" %%}
+
+
+{%% block body %%}
+
+<h3>Click on any image to see full size image and source code</h3>
+<br>
+
+%s
+{%% endblock %%}
+"""
+
+import os, glob, re
+
+multiimage = re.compile('(.*)_\d\d')
+
+pwd = os.getcwd()
+os.chdir('..')
+
+rootdir = '_static/plot_directive/mpl_examples'
+
+# images we want to skip for the gallery because they are an unusual
+# size that doesn't layout well in a table, or because they may be
+# redundant with other images or uninteresting
+skips = set([
+ 'mathtext_examples',
+ 'matshow_02',
+ 'matshow_03',
+ 'matplotlib_icon',
+ ])
+data = []
+for subdir in ('api', 'pylab_examples', 'widgets'):
+ thisdir = os.path.join(rootdir,subdir)
+ if not os.path.exists(thisdir):
+ raise RuntimeError('Cannot find %s'%thisdir)
+ thumbdir = os.path.join(thisdir, 'thumbnails')
+ if not os.path.exists(thumbdir):
+ raise RuntimeError('Cannot find thumbnail dir %s'%thumbdir)
+ #print thumbdir
+
+ # we search for pdfs here because there is one pdf for each
+ # successful image build (2 pngs since one is high res) and the
+ # mapping between py files and images is 1->many
+ for pdffile in sorted(glob.glob(os.path.join(thisdir, '*.pdf'))):
+ basepath, filename = os.path.split(pdffile)
+ basename, ext = os.path.splitext(filename)
+ print 'generating', subdir, basename
+
+ if basename in skips:
+ print ' skipping', basename
+ continue
+ pngfile = os.path.join(thisdir, '%s.png'%basename)
+ thumbfile = os.path.join(thumbdir, '%s.png'%basename)
+ if not os.path.exists(pngfile):
+ pngfile = None
+ if not os.path.exists(thumbfile):
+ thumbfile = None
+
+ m = multiimage.match(basename)
+ if m is None:
+ pyfile = '%s.py'%basename
+ else:
+ basename = m.group(1)
+ pyfile = '%s.py'%basename
+
+ print ' ', pyfile, filename, basename, ext
+
+ print ' ', pyfile, pngfile, thumbfile
+ data.append((subdir, thisdir, pyfile, basename, pngfile, thumbfile))
+
+link_template = """\
+<a href="%s"><img src="%s" border="0" alt="%s"/></a>
+"""
+
+
+rows = []
+for (subdir, thisdir, pyfile, basename, pngfile, thumbfile) in data:
+ if thumbfile is not None:
+ link = 'examples/%s/%s.html'%(subdir, basename)
+ rows.append(link_template%(link, thumbfile, basename))
+
+
+
+os.chdir(pwd)
+fh = file('gallery.html', 'w')
+fh.write(template%'\n'.join(rows))
+fh.close()
+
Modified: trunk/matplotlib/doc/_templates/index.html
===================================================================
--- trunk/matplotlib/doc/_templates/index.html 2008-10-21 14:36:53 UTC (rev 6286)
+++ trunk/matplotlib/doc/_templates/index.html 2008-10-21 14:52:59 UTC (rev 6287)
@@ -15,9 +15,9 @@
<p>matplotlib tries to make easy things easy and hard things possible.
You can generate plots, histograms, power spectra, bar charts,
- errorcharts, scatterplots, etc, with just a few lines of code.
- For a sampling, see the <a href="{{ pathto('users/screenshots') }}">screenshots</a> and
-<a href="examples/index.html">examples</a></p>
+ errorcharts, scatterplots, etc, with just a few lines of code.
+ For a sampling, see the <a href="{{ pathto('users/screenshots') }}">screenshots</a>, <a href="{{ pathto('gallery') }}">thumbnail gallery</a>, and
+<a href="examples/index.html">examples</a> directory</p>
<p align="center"><a href="{{ pathto('users/screenshots') }}"><img align="middle"
src="{{ pathto('_static/logo_sidebar_horiz.png', 1) }}" border="0"
@@ -35,7 +35,7 @@
<p>For the power user, you have full control of line styles, font
properties, axes properties, etc, via an object oriented interface
- or via a handle graphics interface familiar to Matlab® users.
+ or via a handle graphics interface familiar to Matlab® users.
The plotting functions in the <a href="api/pyplot_api.html">pyplot</a>
interface have a high degree of Matlab® compatibility.</p>
Modified: trunk/matplotlib/doc/_templates/layout.html
===================================================================
--- trunk/matplotlib/doc/_templates/layout.html 2008-10-21 14:36:53 UTC (rev 6286)
+++ trunk/matplotlib/doc/_templates/layout.html 2008-10-21 14:52:59 UTC (rev 6287)
@@ -3,6 +3,7 @@
{% block rootrellink %}
<li><a href="{{ pathto('index') }}">matplotlib home</a>| </li>
<li><a href="{{ pathto('search') }}">search</a>| </li>
+ <li><a href="{{ pathto('gallery') }}">gallery</a>| </li>
<li><a href="{{ pathto('contents') }}">documentation </a> »</li>
{% endblock %}
Modified: trunk/matplotlib/doc/conf.py
===================================================================
--- trunk/matplotlib/doc/conf.py 2008-10-21 14:36:53 UTC (rev 6286)
+++ trunk/matplotlib/doc/conf.py 2008-10-21 14:52:59 UTC (rev 6287)
@@ -123,7 +123,7 @@
# Additional templates that should be rendered to pages, maps page names to
# template names.
-html_additional_pages = {'index': 'index.html'}
+html_additional_pages = {'index': 'index.html', 'gallery':'gallery.html'}
# If false, no module index is generated.
#html_use_modindex = True
Modified: trunk/matplotlib/doc/devel/coding_guide.rst
===================================================================
--- trunk/matplotlib/doc/devel/coding_guide.rst 2008-10-21 14:36:53 UTC (rev 6286)
+++ trunk/matplotlib/doc/devel/coding_guide.rst 2008-10-21 14:52:59 UTC (rev 6287)
@@ -352,7 +352,35 @@
"single entry point" requirement above -- see the
``artist.kwdocd['Patch']`` setting in :mod:`matplotlib.patches`.
+.. _custom_backend:
+Developing a new backend
+========================
+
+If you are working on a custom backend, the *backend* setting in
+:file:`matplotlibrc` (:ref:`customizing-matplotlib`) supports an
+external backend via the ``module`` directive. if
+:file:`my_backend.py` is a matplotlib backend in your
+:envvar:`PYTHONPATH`, you can set use it on one of several ways
+
+* in matplotlibrc::
+
+ backend : module://my_backend
+
+* with the use directive is your script::
+
+ import matplotlib
+ matplotlib.use('module://my_backend')
+
+* from the command shell with the -d flag::
+
+ > python simple_plot.py -d module://my_backend
+
+
+
+
+
+
.. _license-discussion:
Licenses
Modified: trunk/matplotlib/doc/examples/gen_rst.py
===================================================================
--- trunk/matplotlib/doc/examples/gen_rst.py 2008-10-21 14:36:53 UTC (rev 6286)
+++ trunk/matplotlib/doc/examples/gen_rst.py 2008-10-21 14:52:59 UTC (rev 6287)
@@ -3,8 +3,6 @@
"""
import os, glob
-import matplotlib.cbook as cbook
-
import os
import re
import sys
@@ -75,9 +73,11 @@
subdirIndexFile = os.path.join(subdir, 'index.rst')
fhsubdirIndex = file(subdirIndexFile, 'w')
- fhindex.write(' %s\n'%subdirIndexFile)
+ fhindex.write(' %s\n\n'%subdirIndexFile)
+ #thumbdir = '../_static/plot_directive/mpl_examples/%s/thumbnails/'%subdir
+ #for thumbname in glob.glob(os.path.join(thumbdir,'*.png')):
+ # fhindex.write(' %s\n'%thumbname)
-
fhsubdirIndex.write("""\
.. _%s-examples-index:
@@ -101,15 +101,23 @@
data = datad[subdir]
data.sort()
- for fullname, fname, contents in data:
+
+ #parts = os.path.split(static_dir)
+ #thumb_dir = ('../'*(len(parts)-1)) + os.path.join(static_dir, 'thumbnails')
+
+ for fullpath, fname, contents in data:
+ basename, ext = os.path.splitext(fname)
static_file = os.path.join(static_dir, fname)
- basename, ext = os.path.splitext(fname)
+ #thumbfile = os.path.join(thumb_dir, '%s.png'%basename)
+ #print ' static_dir=%s, basename=%s, fullpath=%s, fname=%s, thumb_dir=%s, thumbfile=%s'%(static_dir, basename, fullpath, fname, thumb_dir, thumbfile)
+
rstfile = '%s.rst'%basename
outfile = os.path.join(subdir, rstfile)
+
fhsubdirIndex.write(' %s\n'%rstfile)
- if (not out_of_date(fullname, static_file) and
- not out_of_date(fullname, outfile)):
+ if (not out_of_date(fullpath, static_file) and
+ not out_of_date(fullpath, outfile)):
continue
print ' %s'%fname
@@ -121,7 +129,9 @@
fh = file(outfile, 'w')
fh.write('.. _%s-%s:\n\n'%(subdir, basename))
title = '%s example code: %s'%(subdir, fname)
+ #title = '<img src=%s> %s example code: %s'%(thumbfile, subdir, fname)
+
fh.write(title + '\n')
fh.write('='*len(title) + '\n\n')
@@ -131,7 +141,7 @@
not noplot_regex.search(contents))
if do_plot:
- fh.write("\n\n.. plot:: %s\n\n::\n\n" % fullname[3:])
+ fh.write("\n\n.. plot:: %s\n\n::\n\n" % fullpath[3:])
else:
linkname = os.path.join('..', '..', '_static', 'examples', subdir, fname)
fh.write("[`source code <%s>`_]\n\n::\n\n" % linkname)
Modified: trunk/matplotlib/doc/faq/environment_variables_faq.rst
===================================================================
--- trunk/matplotlib/doc/faq/environment_variables_faq.rst 2008-10-21 14:36:53 UTC (rev 6286)
+++ trunk/matplotlib/doc/faq/environment_variables_faq.rst 2008-10-21 14:52:59 UTC (rev 6287)
@@ -1,4 +1,4 @@
-.. _environment-variables:
+.. _environment-variablesg:
*********************
Environment Variables
Modified: trunk/matplotlib/doc/faq/installing_faq.rst
===================================================================
--- trunk/matplotlib/doc/faq/installing_faq.rst 2008-10-21 14:36:53 UTC (rev 6286)
+++ trunk/matplotlib/doc/faq/installing_faq.rst 2008-10-21 14:52:59 UTC (rev 6287)
@@ -98,7 +98,7 @@
Checking out the main source::
- svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk matplotlib
+ svn co https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/matplotlib matplotlib
and build and install as usual with::
Modified: trunk/matplotlib/doc/make.py
===================================================================
--- trunk/matplotlib/doc/make.py 2008-10-21 14:36:53 UTC (rev 6286)
+++ trunk/matplotlib/doc/make.py 2008-10-21 14:52:59 UTC (rev 6287)
@@ -17,7 +17,7 @@
def sf():
'push a copy to the sf site'
os.system('cd build/html; rsync -avz . jdh2358,mat...@we...:/home/groups/m/ma/matplotlib/htdocs/ -essh --cvs-exclude')
- # we are now doing this in the doc/examples build
+ # we are now doing this in the doc/examples build
#os.system('cd ~/mpl/examples; svn-clean; cd ..; rsync -avz examples jdh2358,mat...@we...:/home/groups/m/ma/matplotlib/htdocs/ -essh --cvs-exclude --delete')
def sfpdf():
@@ -29,8 +29,15 @@
def examples():
'make the rest examples'
+
os.system('cd examples; svn-clean; python gen_rst.py')
+ #pass
+def gallery():
+ 'make the thumbnail gallery'
+ os.system('cd _templates; python gen_gallery.py')
+
+
def html():
check_build()
if not os.path.exists('examples/index.rst'):
@@ -44,6 +51,10 @@
shutil.rmtree(figures_dest_path)
shutil.copytree('pyplots', figures_dest_path)
+ # rebuild the gallery
+ gallery()
+ print 'Just rebuilt gallery, you may need to make html again'
+
def latex():
check_build()
#figs()
@@ -77,15 +88,17 @@
latex()
-funcd = {'figs':figs,
- 'html':html,
- 'latex':latex,
- 'clean':clean,
- 'sf':sf,
- 'sfpdf':sfpdf,
- 'examples':examples,
- 'all':all,
- }
+funcd = {
+ 'figs' : figs,
+ 'html' : html,
+ 'latex' : latex,
+ 'clean' : clean,
+ 'sf' : sf,
+ 'sfpdf' : sfpdf,
+ 'examples' : examples,
+ 'gallery' : gallery,
+ 'all' : all,
+ }
if len(sys.argv)>1:
Modified: trunk/matplotlib/doc/sphinxext/mathmpl.py
===================================================================
--- trunk/matplotlib/doc/sphinxext/mathmpl.py 2008-10-21 14:36:53 UTC (rev 6286)
+++ trunk/matplotlib/doc/sphinxext/mathmpl.py 2008-10-21 14:52:59 UTC (rev 6287)
@@ -114,10 +114,14 @@
inline = isinstance(node.parent, nodes.TextElement)
latex = node['latex']
name = 'math-%s' % md5(latex).hexdigest()[-10:]
- dest = '_static/%s.png' % name
+
+ destdir = os.path.join('_static', 'mathmpl')
+ if not os.path.exists(destdir):
+ os.makedirs(destdir)
+ dest = os.path.join(destdir, '%s.png' % name)
depth = latex2png(latex, dest, node['fontset'])
- path = '_static'
+ path = destdir
count = source.split('/doc/')[-1].count('/')
for i in range(count):
if os.path.exists(path): break
Modified: trunk/matplotlib/doc/sphinxext/plot_directive.py
===================================================================
--- trunk/matplotlib/doc/sphinxext/plot_directive.py 2008-10-21 14:36:53 UTC (rev 6286)
+++ trunk/matplotlib/doc/sphinxext/plot_directive.py 2008-10-21 14:52:59 UTC (rev 6287)
@@ -27,6 +27,7 @@
import matplotlib.cbook as cbook
matplotlib.use('Agg')
import matplotlib.pyplot as plt
+import matplotlib.image as image
from matplotlib import _pylab_helpers
def runfile(fullpath):
@@ -58,15 +59,15 @@
template = """
.. htmlonly::
- [`source code <%(destdir)s/%(basename)s.py>`__,
- `png <%(destdir)s/%(outname)s.hires.png>`__,
- `pdf <%(destdir)s/%(outname)s.pdf>`__]
+ [`source code <%(linkdir)s/%(basename)s.py>`__,
+ `png <%(linkdir)s/%(outname)s.hires.png>`__,
+ `pdf <%(linkdir)s/%(outname)s.pdf>`__]
- .. image:: %(destdir)s/%(outname)s.png
+ .. image:: %(linkdir)s/%(outname)s.png
%(options)s
.. latexonly::
- .. image:: %(destdir)s/%(outname)s.pdf
+ .. image:: %(linkdir)s/%(outname)s.pdf
%(options)s
"""
@@ -74,7 +75,7 @@
exception_template = """
.. htmlonly::
- [`source code <%(destdir)s/%(basename)s.py>`__]
+ [`source code <%(linkdir)s/%(basename)s.py>`__]
Exception occurred rendering plot.
@@ -95,7 +96,9 @@
"""
fullpath = str(fullpath) # todo, why is unicode breaking this
- formats = [('png',...
[truncated message content] |
|
From: <jd...@us...> - 2008-10-21 14:37:02
|
Revision: 6286
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6286&view=rev
Author: jdh2358
Date: 2008-10-21 14:36:53 +0000 (Tue, 21 Oct 2008)
Log Message:
-----------
fixed rcsetup to respect external module backends
Modified Paths:
--------------
trunk/matplotlib/examples/misc/image_thumbnail.py
trunk/matplotlib/lib/matplotlib/image.py
trunk/matplotlib/lib/matplotlib/rcsetup.py
Modified: trunk/matplotlib/examples/misc/image_thumbnail.py
===================================================================
--- trunk/matplotlib/examples/misc/image_thumbnail.py 2008-10-20 20:54:24 UTC (rev 6285)
+++ trunk/matplotlib/examples/misc/image_thumbnail.py 2008-10-21 14:36:53 UTC (rev 6286)
@@ -13,7 +13,7 @@
print 'Usage: python %s IMAGEDIR'%__file__
raise SystemExit
indir = sys.argv[1]
-if not os.path.exists(indir):
+if not os.path.isdir(indir):
print 'Could not find input directory "%s"'%indir
raise SystemExit
Modified: trunk/matplotlib/lib/matplotlib/image.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/image.py 2008-10-20 20:54:24 UTC (rev 6285)
+++ trunk/matplotlib/lib/matplotlib/image.py 2008-10-21 14:36:53 UTC (rev 6286)
@@ -846,22 +846,17 @@
else:
if extension=='png':
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
- from matplotlib.figure import Figure
elif extension=='pdf':
from matplotlib.backends.backend_pdf import FigureCanvasPDF as FigureCanvas
- from matplotlib.figure import Figure
elif extension=='svg':
from matplotlib.backends.backend_svg import FigureCanvasSVG as FigureCanvas
- from matplotlib.figure import Figure
else:
raise ValueError("Can only handle extension 'png', 'svg' or 'pdf'")
+ from matplotlib.figure import Figure
fig = Figure(figsize=(width, height), dpi=dpi)
canvas = FigureCanvas(fig)
-
-
-
ax = fig.add_axes([0,0,1,1], aspect='auto', frameon=False, xticks=[], yticks=[])
basename, ext = os.path.splitext(basename)
Modified: trunk/matplotlib/lib/matplotlib/rcsetup.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/rcsetup.py 2008-10-20 20:54:24 UTC (rev 6285)
+++ trunk/matplotlib/lib/matplotlib/rcsetup.py 2008-10-21 14:36:53 UTC (rev 6286)
@@ -100,7 +100,11 @@
raise ValueError('Supported Postscript/PDF font types are %s' % fonttypes.values())
return fonttype
-validate_backend = ValidateInStrings('backend', all_backends, ignorecase=True)
+#validate_backend = ValidateInStrings('backend', all_backends, ignorecase=True)
+_validate_standard_backends = ValidateInStrings('backend', all_backends, ignorecase=True)
+def validate_backend(s):
+ if s.startswith('module://'): return s
+ else: return _validate_standard_backends(s)
validate_numerix = ValidateInStrings('numerix',[
'Numeric','numarray','numpy',
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-10-20 20:54:33
|
Revision: 6285
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6285&view=rev
Author: jdh2358
Date: 2008-10-20 20:54:24 +0000 (Mon, 20 Oct 2008)
Log Message:
-----------
added image thumbnail example
Added Paths:
-----------
trunk/matplotlib/examples/misc/image_thumbnail.py
Added: trunk/matplotlib/examples/misc/image_thumbnail.py
===================================================================
--- trunk/matplotlib/examples/misc/image_thumbnail.py (rev 0)
+++ trunk/matplotlib/examples/misc/image_thumbnail.py 2008-10-20 20:54:24 UTC (rev 6285)
@@ -0,0 +1,29 @@
+"""
+You can use matplotlib to generate thumbnails from existing images.
+matplotlib natively supports PNG files on the input side, and other
+image types transparently if your have PIL installed
+"""
+
+# build thumbnails of all images in a directory
+import sys, os, glob
+import matplotlib.image as image
+
+
+if len(sys.argv)!=2:
+ print 'Usage: python %s IMAGEDIR'%__file__
+ raise SystemExit
+indir = sys.argv[1]
+if not os.path.exists(indir):
+ print 'Could not find input directory "%s"'%indir
+ raise SystemExit
+
+outdir = 'thumbs'
+if not os.path.exists(outdir):
+ os.makedirs(outdir)
+
+for fname in glob.glob(os.path.join(indir, '*.png')):
+ basedir, basename = os.path.split(fname)
+ outfile = os.path.join(outdir, basename)
+ fig = image.thumbnail(fname, outfile, scale=0.15)
+ print 'saved thumbnail of %s to %s'%(fname, outfile)
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-10-20 16:20:03
|
Revision: 6284
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6284&view=rev
Author: jdh2358
Date: 2008-10-20 16:19:51 +0000 (Mon, 20 Oct 2008)
Log Message:
-----------
Applied Lee's backend wx patch
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-10-20 14:16:05 UTC (rev 6283)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008-10-20 16:19:51 UTC (rev 6284)
@@ -96,6 +96,7 @@
import sys, os, os.path, math, StringIO, weakref, warnings
+import numpy as npy
# Debugging settings here...
# Debug level set here. If the debug level is less than 5, information
@@ -333,6 +334,23 @@
gfx_ctx.StrokePath(wxpath)
gc.unselect()
+ def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None):
+ if bbox != None:
+ l,b,w,h = bbox.bounds
+ else:
+ l=0
+ b=0,
+ w=self.width
+ h=self.height
+ rows, cols, image_str = im.as_rgba_str()
+ image_array = npy.fromstring(image_str, npy.uint8)
+ image_array.shape = rows, cols, 4
+ bitmap = wx.BitmapFromBufferRGBA(cols,rows,image_array)
+ gc = self.get_gc()
+ gc.select()
+ gc.gfx_ctx.DrawBitmap(bitmap,int(l),int(b),int(w),int(h))
+ gc.unselect()
+
def draw_text(self, gc, x, y, s, prop, angle, ismath):
"""
Render the matplotlib.text.Text instance
@@ -482,7 +500,7 @@
"""
if sys.platform=='win32':
- self.SelectObject(self.bitmap)
+ self.dc.SelectObject(self.bitmap)
self.IsSelected = True
def unselect(self):
@@ -490,7 +508,7 @@
Select a Null bitmasp into this wxDC instance
"""
if sys.platform=='win32':
- self.SelectObject(wx.NullBitmap)
+ self.dc.SelectObject(wx.NullBitmap)
self.IsSelected = False
def set_foreground(self, fg, isRGB=None):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-10-20 14:16:11
|
Revision: 6283
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6283&view=rev
Author: mdboom
Date: 2008-10-20 14:16:05 +0000 (Mon, 20 Oct 2008)
Log Message:
-----------
[ 2173204 ] implot leaves environment unstable after bad image data
Report errors about invalid data sooner when using imshow.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/image.py
Modified: trunk/matplotlib/lib/matplotlib/image.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/image.py 2008-10-20 14:09:30 UTC (rev 6282)
+++ trunk/matplotlib/lib/matplotlib/image.py 2008-10-20 14:16:05 UTC (rev 6283)
@@ -285,6 +285,13 @@
else:
self._A = np.asarray(A) # assume array
+ if self._A.dtype != np.uint8 and not np.can_cast(self._A.dtype, np.float):
+ raise TypeError("Image data can not convert to float")
+
+ if (self._A.ndim not in (2, 3) or
+ (self._A.ndim == 3 and self._A.shape[-1] not in (3, 4))):
+ raise TypeError("Invalid dimensions for image data")
+
self._imcache =None
self._rgbacache = None
self._oldxslice = None
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-10-20 14:09:38
|
Revision: 6282
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6282&view=rev
Author: jdh2358
Date: 2008-10-20 14:09:30 +0000 (Mon, 20 Oct 2008)
Log Message:
-----------
added image.thumbnail function
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/doc/_static/logo_sidebar_horiz.png
trunk/matplotlib/examples/tests/backend_driver.py
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/image.py
trunk/matplotlib/matplotlibrc.template
trunk/matplotlib/setupext.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-10-20 09:04:54 UTC (rev 6281)
+++ trunk/matplotlib/CHANGELOG 2008-10-20 14:09:30 UTC (rev 6282)
@@ -1,3 +1,7 @@
+2008-10-20 Added image thumbnail generating function
+ matplotlib.image.thumbnail. See
+ examples/misc/image_thumbnail.py - JDH
+
2008-10-20 Applied scatleg patch based on ideas and work by Erik
Tollerud and Jae-Joon Lee. - MM
Modified: trunk/matplotlib/doc/_static/logo_sidebar_horiz.png
===================================================================
(Binary files differ)
Modified: trunk/matplotlib/examples/tests/backend_driver.py
===================================================================
--- trunk/matplotlib/examples/tests/backend_driver.py 2008-10-20 09:04:54 UTC (rev 6281)
+++ trunk/matplotlib/examples/tests/backend_driver.py 2008-10-20 14:09:30 UTC (rev 6282)
@@ -28,7 +28,7 @@
'alignment_test.py',
'arctest.py',
'arrow_demo.py',
- 'auto_layout.py',
+ #'auto_layout.py',
'axes_demo.py',
'axhspan_demo.py',
'bar_stacked.py',
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-10-20 09:04:54 UTC (rev 6281)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-10-20 14:09:30 UTC (rev 6282)
@@ -5453,11 +5453,13 @@
If *None*, default to rc ``image.aspect`` value.
*interpolation*:
- Acceptable values are *None*, 'nearest', 'bilinear', 'bicubic',
- 'spline16', 'spline36', 'hanning', 'hamming', 'hermite', 'kaiser',
- 'quadric', 'catrom', 'gaussian', 'bessel', 'mitchell', 'sinc',
- 'lanczos', 'blackman'
+ Acceptable values are *None*, 'nearest', 'bilinear',
+ 'bicubic', 'spline16', 'spline36', 'hanning', 'hamming',
+ 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian',
+ 'bessel', 'mitchell', 'sinc', 'lanczos',
+
+
If *interpolation* is *None*, default to rc
``image.interpolation``. See also the *filternorm* and
*filterrad* parameters
Modified: trunk/matplotlib/lib/matplotlib/image.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/image.py 2008-10-20 09:04:54 UTC (rev 6281)
+++ trunk/matplotlib/lib/matplotlib/image.py 2008-10-20 14:09:30 UTC (rev 6282)
@@ -319,10 +319,9 @@
"""
Return the interpolation method the image uses when resizing.
- One of
-
- 'bicubic', 'bilinear', 'blackman100', 'blackman256', 'blackman64',
- 'nearest', 'sinc144', 'sinc256', 'sinc64', 'spline16', 'spline36'
+ One of 'nearest', 'bilinear', 'bicubic', 'spline16', 'spline36', 'hanning',
+ 'hamming', 'hermite', 'kaiser', 'quadric', 'catrom', 'gaussian',
+ 'bessel', 'mitchell', 'sinc', 'lanczos',
"""
return self._interpolation
@@ -330,9 +329,11 @@
"""
Set the interpolation method the image uses when resizing.
- ACCEPTS: ['bicubic' | 'bilinear' | 'blackman100' | 'blackman256' |
- 'blackman64', 'nearest' | 'sinc144' | 'sinc256' | 'sinc64' |
- 'spline16' | 'spline36']
+ ACCEPTS: ['nearest' | 'bilinear' | 'bicubic' | 'spline16' |
+ 'spline36' | 'hanning' | 'hamming' | 'hermite' | 'kaiser' |
+ 'quadric' | 'catrom' | 'gaussian' | 'bessel' | 'mitchell' |
+ 'sinc' | 'lanczos' | ]
+
"""
if s is None: s = rcParams['image.interpolation']
s = s.lower()
@@ -764,3 +765,100 @@
x = toarray(im)
x.shape = im.size[1], im.size[0], 4
return x
+
+def thumbnail(fname, scale=0.1, interpolation='bilinear', prefix='thumb_',
+ outdir=None, preview=False, extension='png'):
+ """
+ make a thumbnail of image in fname with output filename
+ [OUTDIR]/[PREFIX][BASENAME].EXTENSION where BASENAME is the
+ filename part of fname without the directory ar extension
+
+ *fname* the image file -- must be PNG or PIL readable if you
+ have `PIL <http://www.pythonware.com/products/pil/>`_ installed
+
+ *scale*
+ the scale factor for the thumbnail
+
+ *interpolation*
+ the interpolation scheme used in the resampling
+
+ *prefix*
+ the PREFIX of the output file name
+
+ *outdir*
+ the OUTDIR of the output filenamet - by default same as directory the source image lives in
+
+ *extension*
+ the EXTENSION for the output filename, one of 'png', 'pdf' or 'ps'
+
+ *preview*
+ if True, the default backend (presumably a user interface
+ backend) will be used which will cause a figure to be raised
+ if :func:`~matplotlib.pyplot.show` is called. If it is False,
+ a pure image backend will be used depending on the extension,
+ 'png'->FigureCanvasAgg, 'pdf'->FigureCanvasPDF,
+ 'svg'->FigureCanvasSVG
+
+
+ See examples/misc/image_thumbnail.py.
+
+ .. htmlonly::
+
+ :ref:`misc-image_thumbnail`
+
+ Return value is the output filename of the thumbnail
+
+ """
+
+ basedir, basename = os.path.split(fname)
+ if outdir is None:
+ if not basedir:
+ basedir = os.curdir
+ outdir = basedir
+
+ if not os.path.exists(outdir) or not os.path.isdir(outdir):
+ raise IOError('output directory "%s" must be a directory'%outdir)
+
+ im = imread(fname)
+ rows, cols, depth = im.shape
+
+ # this doesn't really matter, it will cancel in the end, but we
+ # need it for the mpl API
+ dpi = 100
+
+
+ height = float(rows)/dpi*scale
+ width = float(cols)/dpi*scale
+
+ extension = extension.lower()
+
+ if preview:
+ # let the UI backend do everything
+ import matplotlib.pyplot as plt
+ fig = plt.figure(figsize=(width, height), dpi=dpi)
+ else:
+ if extension=='png':
+ from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
+ from matplotlib.figure import Figure
+ elif extension=='pdf':
+ from matplotlib.backends.backend_pdf import FigureCanvasPDF as FigureCanvas
+ from matplotlib.figure import Figure
+ elif extension=='svg':
+ from matplotlib.backends.backend_svg import FigureCanvasSVG as FigureCanvas
+ from matplotlib.figure import Figure
+ else:
+ raise ValueError("Can only handle extension 'png', 'svg' or 'pdf'")
+
+ fig = Figure(figsize=(width, height), dpi=dpi)
+ canvas = FigureCanvas(fig)
+
+
+
+
+ ax = fig.add_axes([0,0,1,1], aspect='auto', frameon=False, xticks=[], yticks=[])
+
+ basename, ext = os.path.splitext(basename)
+ ax.imshow(im, aspect='auto', resample=True, interpolation='bilinear')
+ outfile = os.path.join(outdir, '%s%s.%s'%(prefix, basename, extension))
+ fig.savefig(outfile, dpi=dpi)
+ return outfile
Modified: trunk/matplotlib/matplotlibrc.template
===================================================================
--- trunk/matplotlib/matplotlibrc.template 2008-10-20 09:04:54 UTC (rev 6281)
+++ trunk/matplotlib/matplotlibrc.template 2008-10-20 14:09:30 UTC (rev 6282)
@@ -265,8 +265,8 @@
#image.cmap : jet # gray | jet etc...
#image.lut : 256 # the size of the colormap lookup table
#image.origin : upper # lower | upper
+#image.resample : False
-
### CONTOUR PLOTS
#contour.negative_linestyle : dashed # dashed | solid
Modified: trunk/matplotlib/setupext.py
===================================================================
--- trunk/matplotlib/setupext.py 2008-10-20 09:04:54 UTC (rev 6281)
+++ trunk/matplotlib/setupext.py 2008-10-20 14:09:30 UTC (rev 6282)
@@ -942,6 +942,7 @@
try:
tcl_lib = tcl_vars.get("default", "TCL_LIB_SPEC")[1:-1].split()[0][2:]
tcl_inc = tcl_vars.get("default", "TCL_INCLUDE_SPEC")[3:-1]
+
tk_lib = tk_vars.get("default", "TK_LIB_SPEC")[1:-1].split()[0][2:]
if tk_vars.has_option("default", "TK_INCLUDE_SPEC"):
# On Ubuntu 8.04
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mme...@us...> - 2008-10-20 09:09:14
|
Revision: 6281
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6281&view=rev
Author: mmetz_bn
Date: 2008-10-20 09:04:54 +0000 (Mon, 20 Oct 2008)
Log Message:
-----------
fix legend prop bug; yoffset not a prop
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/legend.py
Modified: trunk/matplotlib/lib/matplotlib/legend.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/legend.py 2008-10-20 07:52:58 UTC (rev 6280)
+++ trunk/matplotlib/lib/matplotlib/legend.py 2008-10-20 09:04:54 UTC (rev 6281)
@@ -119,9 +119,9 @@
Artist.__init__(self)
proplist=[numpoints, pad, borderpad, markerscale, labelsep,
- handlelen, handletextsep, axespad, shadow, scatteryoffsets]
+ handlelen, handletextsep, axespad, shadow]
propnames=['numpoints', 'pad', 'borderpad', 'markerscale', 'labelsep',
- 'handlelen', 'handletextsep', 'axespad', 'shadow', 'scatteryoffsets']
+ 'handlelen', 'handletextsep', 'axespad', 'shadow']
for name, value in safezip(propnames,proplist):
if value is None:
value=rcParams["legend."+name]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mme...@us...> - 2008-10-20 07:53:09
|
Revision: 6280
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6280&view=rev
Author: mmetz_bn
Date: 2008-10-20 07:52:58 +0000 (Mon, 20 Oct 2008)
Log Message:
-----------
Applied scatleg patch
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/collections.py
trunk/matplotlib/lib/matplotlib/legend.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-10-19 20:35:21 UTC (rev 6279)
+++ trunk/matplotlib/CHANGELOG 2008-10-20 07:52:58 UTC (rev 6280)
@@ -1,3 +1,6 @@
+2008-10-20 Applied scatleg patch based on ideas and work by Erik
+ Tollerud and Jae-Joon Lee. - MM
+
2008-10-11 Fixed bug in pdf backend: if you pass a file object for
output instead of a filename, e.g. in a wep app, we now
flush the object at the end. - JKS
Modified: trunk/matplotlib/lib/matplotlib/collections.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/collections.py 2008-10-19 20:35:21 UTC (rev 6279)
+++ trunk/matplotlib/lib/matplotlib/collections.py 2008-10-20 07:52:58 UTC (rev 6280)
@@ -148,6 +148,12 @@
result = result.inverse_transformed(transData)
return result
+ def get_window_extent(self, renderer):
+ bbox = self.get_datalim(transforms.IdentityTransform())
+ #TODO:check to ensure that this does not fail for
+ #cases other than scatter plot legend
+ return bbox
+
def _prepare_points(self):
"""Point prep for drawing and hit testing"""
@@ -417,7 +423,19 @@
else:
self._edgecolors = self.to_rgba(self._A, self._alpha)
+ def update_from(self, other):
+ 'copy properties from other to self'
+ artist.Artist.update_from(self, other)
+ self._antialiaseds = other._antialiaseds
+ self._edgecolors_original = other._edgecolors_original
+ self._edgecolors = other._edgecolors
+ self._facecolors_original = other._facecolors_original
+ self._facecolors = other._facecolors
+ self._linewidths = other._linewidths
+ self._linestyles = other._linestyles
+ self._pickradius = other._pickradius
+
# these are not available for the object inspector until after the
# class is built so we define an initial set here for the init
# function and they will be overridden after object defn
@@ -690,6 +708,7 @@
"""
Collection.__init__(self,**kwargs)
self._sizes = sizes
+ self._numsides = numsides
self._paths = [self._path_generator(numsides)]
self._rotation = rotation
self.set_transform(transforms.IdentityTransform())
@@ -706,7 +725,16 @@
def get_paths(self):
return self._paths
+ def get_numsides(self):
+ return self._numsides
+ def get_rotation(self):
+ return self._rotation
+
+ def get_sizes(self):
+ return self._sizes
+
+
class StarPolygonCollection(RegularPolyCollection):
"""
Draw a collection of regular stars with *numsides* points."""
Modified: trunk/matplotlib/lib/matplotlib/legend.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/legend.py 2008-10-19 20:35:21 UTC (rev 6279)
+++ trunk/matplotlib/lib/matplotlib/legend.py 2008-10-20 07:52:58 UTC (rev 6280)
@@ -92,8 +92,8 @@
handlelen = None, # the length of the legend lines
handletextsep = None, # the space between the legend line and legend text
axespad = None, # the border between the axes and legend edge
-
- shadow = None
+ shadow = None,
+ scatteryoffsets=None,
):
"""
parent # the artist that contains the legend
@@ -105,6 +105,7 @@
pad = 0.2 # the fractional whitespace inside the legend border
markerscale = 0.6 # the relative size of legend markers vs. original
shadow # if True, draw a shadow behind legend
+ scatteryoffsets # a list of yoffsets for scatter symbols in legend
The following dimensions are in axes coords
labelsep = 0.005 # the vertical space between the legend entries
@@ -117,8 +118,10 @@
Artist.__init__(self)
- proplist=[numpoints, pad, borderpad, markerscale, labelsep, handlelen, handletextsep, axespad, shadow]
- propnames=['numpoints', 'pad', 'borderpad', 'markerscale', 'labelsep', 'handlelen', 'handletextsep', 'axespad', 'shadow']
+ proplist=[numpoints, pad, borderpad, markerscale, labelsep,
+ handlelen, handletextsep, axespad, shadow, scatteryoffsets]
+ propnames=['numpoints', 'pad', 'borderpad', 'markerscale', 'labelsep',
+ 'handlelen', 'handletextsep', 'axespad', 'shadow', 'scatteryoffsets']
for name, value in safezip(propnames,proplist):
if value is None:
value=rcParams["legend."+name]
@@ -134,6 +137,14 @@
self.prop=prop
self.fontsize = self.prop.get_size_in_points()
+ # introduce y-offset for handles of the scatter plot
+ if scatteryoffsets is None:
+ self._scatteryoffsets = np.array([4./8., 5./8., 3./8.])
+ else:
+ self._scatteryoffsets = np.asarray(scatteryoffsets)
+ reps = int(self.numpoints / len(self._scatteryoffsets)) + 1
+ self._scatteryoffsets = np.tile(self._scatteryoffsets, reps)[:self.numpoints]
+
if isinstance(parent,Axes):
self.isaxes = True
self.set_figure(parent.figure)
@@ -306,15 +317,26 @@
ret.append(legline)
elif isinstance(handle, RegularPolyCollection):
- if self.numpoints == 1:
- xdata = np.array([left])
- p = Rectangle(xy=(min(xdata), y-3/4*HEIGHT),
- width = self.handlelen, height=HEIGHT/2,
- )
- p.set_facecolor(handle._facecolors[0])
- if handle._edgecolors != 'none' and len(handle._edgecolors):
- p.set_edgecolor(handle._edgecolors[0])
- self._set_artist_props(p)
+ # the ydata values set here have no effects as it will
+ # be updated in the _update_positions() method.
+ ydata = (y-HEIGHT/2)*np.ones(np.asarray(xdata_marker).shape, float)
+
+ size_max, size_min = max(handle.get_sizes()),\
+ min(handle.get_sizes())
+ # we may need to scale these sizes by "markerscale"
+ # attribute. But other handle types does not seem
+ # to care about this attribute and it is currently ignored.
+ sizes = [.5*(size_max+size_min), size_max,
+ size_min]
+
+ p = type(handle)(handle.get_numsides(),
+ rotation=handle.get_rotation(),
+ sizes=sizes,
+ offsets=zip(xdata_marker,ydata),
+ transOffset=self.get_transform())
+
+ p.update_from(handle)
+ p.set_figure(self.figure)
p.set_clip_box(None)
p.set_clip_path(None)
ret.append(p)
@@ -532,6 +554,10 @@
elif isinstance(handle, Rectangle):
handle.set_y(y+1/4*h)
handle.set_height(h/2)
+ elif isinstance(handle,RegularPolyCollection):
+ offsets = handle.get_offsets()
+ offsets[:,1] = y+h*self._scatteryoffsets
+ handle.set_offsets(offsets)
# Set the data for the legend patch
bbox = self._get_handle_text_bbox(renderer)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-10-19 20:35:31
|
Revision: 6279
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6279&view=rev
Author: jdh2358
Date: 2008-10-19 20:35:21 +0000 (Sun, 19 Oct 2008)
Log Message:
-----------
fixed np clip bug and some other cleanup
Modified Paths:
--------------
trunk/matplotlib/doc/_templates/indexsidebar.html
trunk/matplotlib/doc/examples/gen_rst.py
Modified: trunk/matplotlib/doc/_templates/indexsidebar.html
===================================================================
--- trunk/matplotlib/doc/_templates/indexsidebar.html 2008-10-19 19:52:38 UTC (rev 6278)
+++ trunk/matplotlib/doc/_templates/indexsidebar.html 2008-10-19 20:35:21 UTC (rev 6279)
@@ -11,6 +11,9 @@
and mapping toolkit
<a href="http://matplotlib.sf.net/basemap/doc/html">basemap</a>.</p>
+<p>Please <a href=https://sourceforge.net/my/donations.php>donate</a>
+to support matplotlib development</p>
+
<h3>Need help?</h3>
<p>Check the <a href="{{ pathto('users/index') }}">user</a> guide,
Modified: trunk/matplotlib/doc/examples/gen_rst.py
===================================================================
--- trunk/matplotlib/doc/examples/gen_rst.py 2008-10-19 19:52:38 UTC (rev 6278)
+++ trunk/matplotlib/doc/examples/gen_rst.py 2008-10-19 20:35:21 UTC (rev 6279)
@@ -15,6 +15,11 @@
"""
Returns True if derivative is out-of-date wrt original,
both of which are full file paths.
+
+ TODO: this check isn't adequate in some cases. Eg, if we discover
+ a bug when building the examples, the original and erivederived
+ will be unchanged but we still want to fource a rebuild. We can
+ manually remove from _static, but we may need another solution
"""
return (not os.path.exists(derived) or
os.stat(derived).st_mtime < os.stat(original).st_mtime)
@@ -135,7 +140,7 @@
contents = '\n'.join([' %s'%row.rstrip() for row in contents.split('\n')])
fh.write(contents)
- fh.write('\n\nKeyword: codex (see :ref:`how-to-search-examples`)')
+ fh.write('\n\nKeywords: codex (see :ref:`how-to-search-examples`), python, matplotlib, pylab')
fh.close()
fhsubdirIndex.close()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-10-19 19:52:50
|
Revision: 6278
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6278&view=rev
Author: jdh2358
Date: 2008-10-19 19:52:38 +0000 (Sun, 19 Oct 2008)
Log Message:
-----------
fixed np clip bug and some other cleanup
Modified Paths:
--------------
trunk/matplotlib/doc/sphinxext/plot_directive.py
trunk/matplotlib/examples/animation/simple_anim_tkagg.py
trunk/matplotlib/examples/pylab_examples/masked_demo.py
trunk/matplotlib/lib/matplotlib/colors.py
Modified: trunk/matplotlib/doc/sphinxext/plot_directive.py
===================================================================
--- trunk/matplotlib/doc/sphinxext/plot_directive.py 2008-10-19 09:35:03 UTC (rev 6277)
+++ trunk/matplotlib/doc/sphinxext/plot_directive.py 2008-10-19 19:52:38 UTC (rev 6278)
@@ -24,7 +24,7 @@
align = Image.align
import matplotlib
-
+import matplotlib.cbook as cbook
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from matplotlib import _pylab_helpers
@@ -148,7 +148,8 @@
try:
runfile(fullpath)
except:
- warnings.warn("Exception running plot %s" % fullpath)
+ s = cbook.exception_to_str("Exception running plot %s" % fullpath)
+ warnings.warn(s)
return 0
fig_managers = _pylab_helpers.Gcf.get_all_fig_managers()
@@ -162,7 +163,8 @@
try:
figman.canvas.figure.savefig(outpath, dpi=dpi)
except:
- warnings.warn("Exception running plot %s" % fullpath)
+ s = cbook.exception_to_str("Exception running plot %s" % fullpath)
+ warnings.warn(s)
return 0
return len(fig_managers)
@@ -171,7 +173,7 @@
reference = directives.uri(arguments[0])
basedir, fname = os.path.split(reference)
basename, ext = os.path.splitext(fname)
-
+ #print 'plotdir', reference, basename, ext
destdir = ('../' * reference.count('/')) + 'pyplots'
num_figs = makefig(reference, 'pyplots')
Modified: trunk/matplotlib/examples/animation/simple_anim_tkagg.py
===================================================================
--- trunk/matplotlib/examples/animation/simple_anim_tkagg.py 2008-10-19 09:35:03 UTC (rev 6277)
+++ trunk/matplotlib/examples/animation/simple_anim_tkagg.py 2008-10-19 19:52:38 UTC (rev 6278)
@@ -2,6 +2,8 @@
"""
A simple example of an animated plot in tkagg
"""
+import time
+import numpy as np
import matplotlib
matplotlib.use('TkAgg') # do this before importing pylab
Modified: trunk/matplotlib/examples/pylab_examples/masked_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/masked_demo.py 2008-10-19 09:35:03 UTC (rev 6277)
+++ trunk/matplotlib/examples/pylab_examples/masked_demo.py 2008-10-19 19:52:38 UTC (rev 6278)
@@ -1,4 +1,4 @@
-#!/bin/env python
+#!/usr/bin/env python
'''
Plot lines with points masked out.
Modified: trunk/matplotlib/lib/matplotlib/colors.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/colors.py 2008-10-19 09:35:03 UTC (rev 6277)
+++ trunk/matplotlib/lib/matplotlib/colors.py 2008-10-19 19:52:38 UTC (rev 6278)
@@ -38,6 +38,11 @@
from numpy import ma
import matplotlib.cbook as cbook
+parts = np.__version__.split('.')
+NP_MAJOR, NP_MINOR = map(int, parts[:2])
+# true if clip supports the out kwarg
+NP_CLIP_OUT = NP_MAJOR>=1 and NP_MINOR>=2
+
cnames = {
'aliceblue' : '#F0F8FF',
'antiquewhite' : '#FAEBD7',
@@ -457,7 +462,11 @@
np.putmask(xa, xa==1.0, 0.9999999) #Treat 1.0 as slightly less than 1.
# The following clip is fast, and prevents possible
# conversion of large positive values to negative integers.
- np.clip(xa * self.N, -1, self.N, out=xa)
+
+ if NP_CLIP_OUT:
+ np.clip(xa * self.N, -1, self.N, out=xa)
+ else:
+ xa = np.clip(xa * self.N, -1, self.N)
xa = xa.astype(int)
# Set the over-range indices before the under-range;
# otherwise the under-range values get converted to over-range.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fer...@us...> - 2008-10-19 10:22:13
|
Revision: 6274
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6274&view=rev
Author: fer_perez
Date: 2008-10-19 09:03:25 +0000 (Sun, 19 Oct 2008)
Log Message:
-----------
py4science doc cleanup
Removed Paths:
-------------
trunk/py4science/doc/skel
Deleted: trunk/py4science/doc/skel
===================================================================
--- trunk/py4science/doc/skel 2008-10-19 09:01:48 UTC (rev 6273)
+++ trunk/py4science/doc/skel 2008-10-19 09:03:25 UTC (rev 6274)
@@ -1 +0,0 @@
-link ../examples/skel
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fer...@us...> - 2008-10-19 10:22:09
|
Revision: 6272
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6272&view=rev
Author: fer_perez
Date: 2008-10-19 08:37:47 +0000 (Sun, 19 Oct 2008)
Log Message:
-----------
py4science: Add a few remainig docs.
Added Paths:
-----------
trunk/py4science/doc/workflow_notes.txt
trunk/py4science/intro_talk/0712_ncar_intro.lyx
trunk/py4science/intro_talk/0810_berkeley_intro.lyx
trunk/py4science/intro_talk/fig/vision_beam_pattern.png
Added: trunk/py4science/doc/workflow_notes.txt
===================================================================
--- trunk/py4science/doc/workflow_notes.txt (rev 0)
+++ trunk/py4science/doc/workflow_notes.txt 2008-10-19 08:37:47 UTC (rev 6272)
@@ -0,0 +1,66 @@
+=================
+ Python workflow
+=================
+
+ipython. Saving and reloading files, interactive use of variables, %run,
+%debug, %xmode verbose.
+
+* Workflow, guided by a simple examples and students typing along. Will show
+ basics of everyday workflow as we cover the core concepts.
+
+ * A very quick overview of the language.
+
+ * Basic scalar types: strings and numbers (int, float, complex).
+
+ * Basic collections: lists and dicts (mention tuples and sets).
+
+ * Quick review of control flow: if, for, range, while, break, continue.
+
+ * Defining functions. Arguments and docstrings.
+
+ * Reusing your code: every script is a module, '__main__' (notes on module
+ loading and reloading)
+
+ * Exceptions: a core concept in Python, you really can't use the language
+ without them.
+
+ * Debugging your programs:
+ * Ye olde print statement.
+ * %debug in ipython.
+ * %run -d in ipython.
+ * winpdb - a free, cross-platform GUI debugger.
+
+ * Testing your code: reproducible research from the start. Making a habit
+ out of having auto-validated code.
+
+ * Quicksort together.
+
+
+Getting help:
+ - pydoc (-g, -p)
+
+ - The standard docs (bookmark them)
+
+ - ipython ?/??, help(), the tab key. numpy.*cos*? search.
+
+ - The open source process: mailing lists, wikis, svn. Python
+ cookbook. Participate!
+
+Basic setup:
+ - ipython
+
+ - matplotlib (latex, etc).
+
+ - Modules: import/reload, PYTHONPATH.
+
+- Urllib Yahoo finance demo.
+
+ToDo: Add numerical error measure of trapezoid rule.
+
+ToDo Add in workflow comparison with scipy's integration. compare timing and
+ eror.
+
+ToDo: write cheat-sheet.
+
+- Urllib Yahoo finance demo: examples/stock_demo.py
+
Added: trunk/py4science/intro_talk/0712_ncar_intro.lyx
===================================================================
--- trunk/py4science/intro_talk/0712_ncar_intro.lyx (rev 0)
+++ trunk/py4science/intro_talk/0712_ncar_intro.lyx 2008-10-19 08:37:47 UTC (rev 6272)
@@ -0,0 +1,2400 @@
+#LyX 1.5.1 created this file. For more info see http://www.lyx.org/
+\lyxformat 276
+\begin_document
+\begin_header
+\textclass beamer
+\begin_preamble
+% Include only certain frames - this speeds up compilation
+% The frames to be included need to be labeled, by using ERT
+% as [label=LABELNAME] (no backslashes or {})
+%\includeonlyframes{currentt}
+
+% To make a printable handout (one page per frame), pass
+% the handout option to the doc class (Layout menu)
+
+% For good fonts in PDFs, use pslatex fonts (Layout menu)
+
+% Colors and symbols
+\usepackage{latexsym}
+\usepackage{color}
+
+% Display covered items in transparent form (as opposed
+% to not showing them at all)
+\newcommand{\coveredinvisible}{
+ \setbeamercovered{invisible}
+}
+\newcommand{\coveredvisible}{
+ \setbeamercovered{highly dynamic}
+}
+
+% Choose default setting here:
+\coveredvisible
+
+\newcommand{\ps}{\vspace{-4mm} }
+
+% Theme configuration. I've basically built a custom theme out of
+% Warsaw, adding infoline and changing the nav. symbol bar
+
+% Warning: the commands below are order-sensitive!
+
+% load the infolines theme, b/c I want the headline Warsaw
+% uses (split), but the footline from infolines.
+% In the document body, these will be deactivated for the title and
+% turned on later
+\useoutertheme{infolines}
+% Main theme
+\usetheme{Warsaw}
+% Adjust the color for the center (title) box to be that of
+% infolines, which Warsaw changes
+\setbeamercolor*{title in head/foot}{parent=palette secondary}
+
+% Define a minimal set of navigation symbols
+\defbeamertemplate*{navigation symbols}{minmal}
+{%
+ \hbox{%
+ \hbox{\insertframenavigationsymbol}
+ \hbox{\insertdocnavigationsymbol}
+ \hbox{\insertbackfindforwardnavigationsymbol}%
+ }%
+}
+% activate the minimal navbar
+\setbeamertemplate{navigation symbols}[minimal]
+
+%%%%% HACK %%%%%
+% I started getting errors because LyX is emmitting a color 'none'
+% call, which confuses xcolor. I'm defining 'none' to be black here.
+\definecolor{none}{cmyk}{0,0,0,1}
+%%%%% /HACK %%%%%
+\end_preamble
+\options compress
+\language english
+\inputencoding auto
+\font_roman times
+\font_sans helvet
+\font_typewriter courier
+\font_default_family default
+\font_sc false
+\font_osf false
+\font_sf_scale 100
+\font_tt_scale 100
+\graphics default
+\paperfontsize default
+\spacing single
+\papersize default
+\use_geometry false
+\use_amsmath 2
+\use_esint 0
+\cite_engine basic
+\use_bibtopic false
+\paperorientation landscape
+\secnumdepth 2
+\tocdepth 2
+\paragraph_separation indent
+\defskip medskip
+\quotes_language english
+\papercolumns 1
+\papersides 1
+\paperpagestyle default
+\tracking_changes false
+\output_changes false
+\author ""
+\author ""
+\end_header
+
+\begin_body
+
+\begin_layout Standard
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+Some things to fix in a future version:
+\end_layout
+
+\begin_layout Standard
+- trim a bit of time
+\end_layout
+
+\begin_layout Standard
+- add more about ipython and my own python work, reduce that of others
+\end_layout
+
+\begin_layout Standard
+- add a final python pros/cons, esp.
+ the cons part.
+ It will make things more balanced.
+\end_layout
+
+\begin_layout Standard
+- the PDE part repeats a bit the 'python benefits' which were already pounded
+ on.
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+% disable the bottom bar for the title and outline pages
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\begin_layout Standard
+
+
+\backslash
+setbeamertemplate{footline}{}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+vspace*{-5mm}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Title
+Python in Scientific Computing
+\begin_inset OptArg
+status open
+
+\begin_layout Standard
+Python & Scientific Computing
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subtitle
+An Introduction
+\end_layout
+
+\begin_layout Author
+Fernando\InsetSpace ~
+Pérez
+\newline
+
+\family typewriter
+\size scriptsize
+<Fer...@co...>
+\family default
+\size default
+
+\newline
+John Hunter
+\newline
+
+\family typewriter
+\size scriptsize
+<jd...@gm...>
+\family default
+\size default
+
+\begin_inset OptArg
+status open
+
+\begin_layout Standard
+FP/JDH
+\begin_inset Note Note
+status collapsed
+
+\begin_layout Standard
+This is used by the 'split' footline theme on the left side of the page
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+vspace{5mm}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Institute
+Applied Mathematics, U.
+ of Colorado at Boulder
+\newline
+Tradelink
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+- Use the
+\backslash
+inst command only if there are several affiliations.
+\end_layout
+
+\begin_layout Standard
+- Keep it simple, no one is interested in your street address.
+\end_layout
+
+\end_inset
+
+
+\begin_inset OptArg
+status open
+
+\begin_layout Standard
+CU\InsetSpace ~
+Boulder/Tradelink
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+optional, but mostly needed
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+vspace{5mm}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Date
+NCAR, Boulder
+\newline
+Dec 7, 2007
+\begin_inset OptArg
+status open
+
+\begin_layout Standard
+NCAR, 12/7/07
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+If you have a file called "institution-logo-filename.xxx", where xxx is a
+ graphic format that can be processed by latex or pdflatex, resp., then you
+ can add a logo by uncommenting the following:
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+%
+\backslash
+pgfdeclareimage[height=0.5cm]{institution-logo}{institution-logo-filename}
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\begin_layout Standard
+
+%
+\backslash
+logo{
+\backslash
+pgfuseimage{institution-logo}}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+The following causes the table of contents to be shown at the beginning
+ of every Section.
+ Delete this, if you do not want it.
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+AtBeginSection[]{
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\begin_layout Standard
+
+
+\backslash
+frame<beamer>{
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\begin_layout Standard
+
+
+\backslash
+frametitle{Outline}
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\begin_layout Standard
+
+
+\backslash
+tableofcontents[currentsection]
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\begin_layout Standard
+
+}
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\begin_layout Standard
+
+}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+If you wish to uncover everything in a step-wise fashion, uncomment the
+ following command:
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+%
+\backslash
+beamerdefaultoverlayspecification{<+->}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+% reactivate the footline
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\begin_layout Standard
+
+
+\backslash
+setbeamertemplate{footline}[infolines theme]
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginFrame
+Outline
+\end_layout
+
+\begin_layout Standard
+\begin_inset LatexCommand tableofcontents
+
+\end_inset
+
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+[pausesections]
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Section
+Scientific Computing
+\begin_inset OptArg
+status open
+
+\begin_layout Standard
+SciComp
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Traditional approaches
+\begin_inset OptArg
+status open
+
+\begin_layout Standard
+Status quo
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginFrame
+FORTRAN, C and C++
+\end_layout
+
+\begin_layout Itemize
+Tools optimized for CPUs, not humans.
+\end_layout
+
+\begin_layout Itemize
+Low-level:
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+Primitive data types (no good strings, sets, hash tables,
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+ldots
+\end_layout
+
+\end_inset
+
+).
+\end_layout
+
+\begin_layout Itemize
+Manual memory management: bugs, bugs, bugs.
+ Hard ones.
+\end_layout
+
+\begin_layout Itemize
+Slow edit/compile/test cycle.
+\end_layout
+
+\end_deeper
+\begin_layout Itemize
+Clumsy access to visualization, quick profiling, text processing,
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+ldots
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+No interactive facilities - scientific work is inherently exploratory.
+\end_layout
+
+\begin_layout Pause
+
+\end_layout
+
+\begin_layout Standard
+
+\series bold
+\color blue
+However!
+\end_layout
+
+\begin_layout Itemize
+They deliver excellent performance.
+\end_layout
+
+\begin_layout Itemize
+Millions of LOC in proven scientific codes.
+
+\end_layout
+
+\begin_layout Itemize
+We need to
+\emph on
+\color blue
+work with these tools
+\emph default
+\color inherit
+, not replace them!
+\end_layout
+
+\begin_layout BeginFrame
+Higher level tools in the last decade
+\end_layout
+
+\begin_layout Itemize
+Mathematica and Maple: a unique niche we won't address today.
+\end_layout
+
+\begin_layout Itemize
+IDL and Matlab: extremely popular, for good reasons.
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+Great interactivity, visualization, and extensive libraries.
+\end_layout
+
+\begin_layout Itemize
+Unpleasant languages for large-scale programs and non-numerical tasks.
+\end_layout
+
+\begin_layout Itemize
+Expensive/proprietary: lock-in.
+\end_layout
+
+\begin_layout Itemize
+Often considered `prototyping' tools: this leads to a lot of code rewriting.
+\end_layout
+
+\end_deeper
+\begin_layout Itemize
+A common approach (I've been there): mix and match multiple tools:
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+FORTRAN, C, C++ programs ...
+\end_layout
+
+\begin_layout Itemize
+driven by Bash/awk/sed/Perl scripts ...
+\end_layout
+
+\begin_layout Itemize
+which feed them input and take their outputs ...
+\end_layout
+
+\begin_layout Itemize
+and pass them to Gnuplot, Grace, OpenDX, etc.
+\end_layout
+
+\end_deeper
+\begin_layout Itemize
+Many different syntaxes:
+\color none
+
+\color red
+huge context switching overhead!
+\end_layout
+
+\begin_layout Subsection
+Python?
+\begin_inset OptArg
+status open
+
+\begin_layout Standard
+Python
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginFrame
+Python in this context
+\end_layout
+
+\begin_layout Itemize
+
+\color blue
+Free
+\color none
+ (BSD license), highly portable (Linux, OSX, Solaris, Windows, ...).
+\end_layout
+
+\begin_layout Itemize
+
+\color blue
+Interactive
+\color none
+ interpreter provided.
+\end_layout
+
+\begin_layout Itemize
+Extremely readable syntax (
+\color blue
+
+\begin_inset Quotes eld
+\end_inset
+
+executable pseudo-code
+\begin_inset Quotes erd
+\end_inset
+
+
+\color none
+).
+\end_layout
+
+\begin_layout Itemize
+
+\color blue
+Simple
+\color none
+: non-professional programmers can become (and remain) proficient with a
+ very small effort (c.f.
+ C++).
+\end_layout
+
+\begin_layout Itemize
+Clean object oriented model, but
+\color none
+
+\color blue
+not mandatory
+\color none
+.
+\end_layout
+
+\begin_layout Itemize
+Rich built-in types: lists, sets, dictionaries (hash tables), strings, ...
+\end_layout
+
+\begin_layout Itemize
+Very comprehensive standard library (
+\color blue
+batteries included
+\color none
+)
+\end_layout
+
+\begin_layout Itemize
+Standard libraries for IDL/Matlab-like arrays (NumPy)
+\end_layout
+
+\begin_layout Itemize
+Easy to wrap existing C, C++ and FORTRAN codes.
+\end_layout
+
+\begin_layout Section
+Interlude: Python in the real world
+\begin_inset OptArg
+status collapsed
+
+\begin_layout Standard
+Examples
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+EEG analysis for epilepsy
+\begin_inset OptArg
+status open
+
+\begin_layout Standard
+EEG
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginPlainFrame
+Data analysis for epilepsy surgery
+\end_layout
+
+\begin_layout FrameSubtitle
+Isolating the origin of drug-resistant epileptic seizures which require
+ surgery.
+\end_layout
+
+\begin_layout Standard
+John Hunter, Department of Pediatric Neurology, University of Chicago.
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/mpl_brain1.png
+ lyxscale 50
+ width 80text%
+ keepAspectRatio
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginPlainFrame
+Electrode location in 3D, combined with MRI data
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/mpl_brain3.png
+ lyxscale 50
+ width 90text%
+ keepAspectRatio
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginPlainFrame
+Correlation analysis of seizure data
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/mpl_brain4.png
+ lyxscale 50
+ width 90text%
+ keepAspectRatio
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginPlainFrame
+Final location of epileptic foci for surgery
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/mpl_brain5.png
+ lyxscale 50
+ width 90text%
+ keepAspectRatio
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Multiwavelets for PDEs
+\begin_inset OptArg
+status open
+
+\begin_layout Standard
+PDEs
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginFrame
+Adaptive, multiwavelet algorithms for integral operators
+\end_layout
+
+\begin_layout Standard
+Gregory Beylkin, Vani Cheruvu, Fernando Perez.
+ Applied Math, U.
+ of Colorado at Boulder.
+\end_layout
+
+\begin_layout Itemize
+Fast application of integral kernels.
+ (Partial Differential Equations)
+\end_layout
+
+\begin_layout Itemize
+Implementation went from 1 to 3 dimensions directly (
+\emph on
+extremely
+\emph default
+ unusual).
+\end_layout
+
+\begin_layout Itemize
+Very complex algorithm that goes beyond pure numerics.
+\end_layout
+
+\begin_layout Itemize
+Very good performance, thanks to NumPy, F2PY and weave.
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/rho_2d_surf.png
+ lyxscale 80
+ width 35text%
+
+\end_inset
+
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+hspace{1cm}
+\end_layout
+
+\end_inset
+
+
+\begin_inset Graphics
+ filename fig/rho_2d_skel.eps
+ lyxscale 80
+ width 25text%
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+JPL: Mars mission data visualization
+\begin_inset OptArg
+status collapsed
+
+\begin_layout Standard
+JPL - Mars
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginPlainFrame
+JPL: Mars mission trajectory design and nav data
+\end_layout
+
+\begin_layout FrameSubtitle
+Ted Drain and Lynn Craig, Jet Propulsion Laboratory (NASA/Caltech)
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+\size footnotesize
+From: Name Elided <nam...@jp...>
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+\size footnotesize
+Date: Oct 2, 2007 7:15 PM
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+\size footnotesize
+Subject: Fwd: matplotlib bug numbers
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+\size footnotesize
+To: John Hunter <jd...@gm...>
+\end_layout
+
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+vspace{5mm}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+\size tiny
+One of my lead developers mentioned that they had sent a bug to you about
+ the annotations feature of MatPlotLib.
+ Would you be able to let me know what the timeline is to resolve that bug?
+ The reason is that the feature is needed for the Phoenix project and their
+ arrival at Mars will be in March sometime, but they are doing their testing
+ in the coming few months.
+ This annotation feature is used on reports that present the analysis of
+ the trajectory to the navigation team and it shows up on our schedule.
+ It would really help me to know approximately when it could be resolved.
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+\size tiny
+B-plane plots are used to show the trajectory of a spacecraft with respect
+ to the target body (specifically perpendicular to the incoming asymptote
+ of the spacecraft trajectory) and we plot them with the y-axis inverted.
+ The plot is used heavily in flight operations so it is important to our
+ customers.
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+\size tiny
+In addition, we have what is called a thundering heard plot where many different
+ trajectory solutions (determined from different measurement sources) are
+ plotted together.
+ The annotations are import there so we can see which plot corresponds to
+ each source of data.
+ I hope it helps to know how your code will be used in spacecraft navigation.
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+\size tiny
+Thanks for all your efforts.
+\end_layout
+
+\begin_layout BeginPlainFrame
+JPL: Mars mission data visualization
+\end_layout
+
+\begin_layout Standard
+Expected communication power levels between an orbiting spacecraft and a
+ lander as it goes through the atmosphere:
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/jpl_lander_comm_power.png
+ lyxscale 25
+ width 90text%
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginPlainFrame
+JPL: Mars mission data visualization (2)
+\end_layout
+
+\begin_layout Standard
+Summary of the current navigation team activities and modelling (data used,
+ event times etc):
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+vspace{-3mm}
+\end_layout
+
+\end_inset
+
+
+\begin_inset Graphics
+ filename fig/jpl_nav_summary.png
+ lyxscale 50
+ width 90text%
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+PMV: structural bioinformatics
+\begin_inset OptArg
+status collapsed
+
+\begin_layout Standard
+PMV
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginPlainFrame
+PMV: the Python Molecule Viewer
+\end_layout
+
+\begin_layout FrameSubtitle
+Michel F.
+ Sanner, Molecular Biology Department, The Scripps Research Institute.
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/pmv.png
+ lyxscale 50
+ width 100text%
+ keepAspectRatio
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+MayaVi: customizable data visualization
+\begin_inset OptArg
+status open
+
+\begin_layout Standard
+MayaVi
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginFrame
+MayaVi: sophisticated data visualization
+\end_layout
+
+\begin_layout Itemize
+Free, easy to use scientific data visualizer.
+\end_layout
+
+\begin_layout Itemize
+Heavy lifting of OpenGL-based rendering: VTK (a C++ library).
+\end_layout
+
+\begin_layout Itemize
+A very good example of how to properly use Python:
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+MayaVi is a standalone GUI program...
+\end_layout
+
+\begin_layout Itemize
+but also a Python library callable by any other Python program.
+\end_layout
+
+\begin_layout Itemize
+Python: very easy to modify, even by adding at runtime user-defined modules
+ which populate the GUI automatically.
+\end_layout
+
+\begin_layout Itemize
+C++: excellent rendering performance, fully hardware-accelerated OpenGL.
+\end_layout
+
+\end_deeper
+\begin_layout Pause
+
+\end_layout
+
+\begin_layout Standard
+
+\series bold
+\color blue
+The punchline:
+\series default
+\color none
+ fully programmable visualization, with builtin access to all kinds of numerical
+ (and other) libraries from within the viz tool.
+\end_layout
+
+\begin_layout BeginPlainFrame
+FluidLab: a MayaVi based CFD visualization tool
+\end_layout
+
+\begin_layout Standard
+K.
+ Julien, P.
+ Schmitt (now NCAR), B.
+ Barrow, F.
+ Pérez (App.
+ Math, CU).
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/Fluidlab5.png
+ lyxscale 50
+ width 90text%
+ keepAspectRatio
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginPlainFrame
+Volumetric rendering with FluidLab
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/Fluidlab6.png
+ lyxscale 50
+ width 90text%
+ keepAspectRatio
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+SAGE: System for Algebra and Geometry Experimentation
+\begin_inset OptArg
+status collapsed
+
+\begin_layout Standard
+SAGE
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginPlainFrame
+SAGE: open source mathematics
+\end_layout
+
+\begin_layout FrameSubtitle
+Winner of the 2007 Trophés du Libre, scientific software category
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/sage_notebook-medium.jpg
+ lyxscale 50
+ width 90text%
+ keepAspectRatio
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+IPython
+\end_layout
+
+\begin_layout BeginFrame
+IPython
+\end_layout
+
+\begin_layout FrameSubtitle
+Extensible interactive environment with parallel computing support
+\end_layout
+
+\begin_layout Enumerate
+
+\color blue
+A better Python shell
+\color none
+: object introspection, system access, 'magic' command system for adding
+ functionality when working interactively,
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+ldots
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Enumerate
+
+\color blue
+An embeddable interpreter
+\color none
+: useful for debugging and for mixing batch-processing with interactive
+ work.
+\end_layout
+
+\begin_layout Enumerate
+
+\color blue
+A flexible component
+\color none
+: you can use it as the base environment for other systems with Python as
+ the underlying language.
+ It is very configurable in this direction.
+\end_layout
+
+\begin_layout Enumerate
+
+\color blue
+A system for interactive control of distributed/parallel computing systems.
+
+\color none
+
+\end_layout
+
+\begin_layout Enumerate
+
+\color blue
+An interactive component
+\color none
+ we can plug into GUIs, browser-based shells, etc.
+\end_layout
+
+\begin_layout BeginPlainFrame
+IPython: IDL-like interactive use
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/pylab-screen.png
+ lyxscale 30
+ width 90text%
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginPlainFrame
+IPython: interactive control of VTK visualizations
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/mlab-screen-black.png
+ lyxscale 50
+ width 90text%
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginFrame
+IPython's future
+\end_layout
+
+\begin_layout FrameSubtitle
+A 2-process kernel on the network
+\end_layout
+
+\begin_layout Standard
+Work with Brian Granger (Tech-X, Boulder) and Benjamin Ragan-Kelley (U.
+ C.
+ Berkeley physics).
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/kernel2p.png
+ lyxscale 50
+ width 80text%
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginFrame
+Distributed/parallel computing
+\end_layout
+
+\begin_layout Itemize
+Think of Python as 'the CPU'
+\end_layout
+
+\begin_layout Itemize
+But these souped-up kernels let you talk to it conveniently.
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/ipython_parallel.png
+ lyxscale 50
+ width 80text%
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+PyNGL
+\end_layout
+
+\begin_layout BeginPlainFrame
+PyNGL - Python interface to NCAR's NCL
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+import
+\family default
+\color none
+
+\family typewriter
+\color blue
+numpy
+\color none
+, Ngl, Nio
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+dirc = Ngl.pynglpath("data")
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+cfile = Nio.open_file(dirc + "/cdf/seam.nc")
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+lon =
+\family default
+\color none
+
+\family typewriter
+\color blue
+numpy
+\color none
+.ravel(cfile.variables["lon2d"][:,:])
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+lat =
+\family default
+\color none
+
+\family typewriter
+\color blue
+numpy
+\color none
+.ravel(cfile.variables["lat2d"][:,:])
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+ps =
+\family default
+\color none
+
+\family typewriter
+\color blue
+numpy
+\color none
+.ravel(cfile.variables["ps"][0,:,:])/100.
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+rlist = Ngl.Resources()
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+rlist.wkColorMap = "BlAqGrYeOrReVi200"
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+wks_type = "ps"
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+wks = Ngl.open_wks(wks_type,"seam",rlist)
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+resources = Ngl.Resources()
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+resources.sfXArray = lon
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+resources.sfYArray = lat
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+map = Ngl.contour_map(wks,ps,resources)
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+Ngl.end()
+\end_layout
+
+\begin_layout BeginFrame
+PyNGL
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/ncar-world-seam.3.png
+ lyxscale 50
+ width 90text%
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection*
+Others
+\end_layout
+
+\begin_layout BeginFrame
+A few other projects
+\end_layout
+
+\begin_layout FrameSubtitle
+Python is becoming very popular in many different scientific areas
+\end_layout
+
+\begin_layout Itemize
+
+\color blue
+PyDAP:
+\color none
+ Python implementation of the OpenDAP protocols (client
+\series bold
+and
+\series default
+ server).
+\end_layout
+
+\begin_layout Itemize
+
+\color blue
+PyTables:
+\color none
+ HDF-5 read-write support with excellent performance.
+\end_layout
+
+\begin_layout Itemize
+
+\color blue
+PyTrilinos:
+\color none
+ Python interface to Sandia's Trilinos parallel solvers.
+ Coupled with IPython, they can be used interactively.
+\end_layout
+
+\begin_layout Itemize
+
+\color blue
+PyRAF:
+\color none
+ Hubble Space Telescope interface to IRAF, a standard in astronomical image
+ processing.
+
+\end_layout
+
+\begin_layout Itemize
+
+\color blue
+VPython:
+\color none
+ easy, real-time 3D programming (Carnegie Mellon, used for an introductory
+ mechanics course).
+\end_layout
+
+\begin_layout Itemize
+
+\color blue
+Galaxy:
+\color none
+ integrated access to multiple tools in genomics research.
+
+\color blue
+Very impressive
+\color none
+.
+\end_layout
+
+\begin_layout Section
+Development in Python
+\begin_inset OptArg
+status collapsed
+
+\begin_layout Standard
+Development\InsetSpace ~
+Model
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginPlainFrame
+Python compared to IDL, Matlab, etc.
+\end_layout
+
+\begin_layout ExampleBlock
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+<+->{Pros}
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout ExampleBlock
+A general programming language:
+\series bold
+this is a feature
+\series default
+!
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+Free, open source, extremely portable: from the OLPC or a cellphone (Nokia)
+ to a supercomputer.
+\end_layout
+
+\begin_layout Itemize
+Networking, text processing, XML parsing, databases, etc
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+ldots
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+Integrated support for testing (
+\family typewriter
+unittest
+\family default
+,
+\family typewriter
+doctest
+\family default
+)
+\end_layout
+
+\begin_layout Itemize
+Automatic API documentation tools (
+\family typewriter
+epydoc, doxygen
+\family default
+).
+\end_layout
+
+\begin_layout Itemize
+Supports all major GUI toolkits.
+\end_layout
+
+\begin_layout Itemize
+Extremely expressive for complex algorithms.
+\end_layout
+
+\end_deeper
+\begin_layout Separator
+
+\end_layout
+
+\begin_layout AlertBlock
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+<+->{There are still rough edges!}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+Installation, deployment: harder than needed (but improving).
+\end_layout
+
+\begin_layout Itemize
+No good, single-point of entry integrated help system.
+\end_layout
+
+\begin_layout Itemize
+Lots of good documentation, but scattered all over.
+\end_layout
+
+\begin_layout Itemize
+Funding agency support for infrastructure work is difficult to get.
+\end_layout
+
+\end_deeper
+\begin_layout BeginFrame
+A different model of development
+\end_layout
+
+\begin_layout FrameSubtitle
+
+\emph on
+\color red
+Global optimization is the root of all evil
+\end_layout
+
+\begin_layout Itemize
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+<+->
+\end_layout
+
+\end_inset
+
+Never write `
+\family typewriter
+main()
+\family default
+' in C anymore:
+\color none
+
+\color red
+you are optimizing globally!
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+Prototype the code in Python.
+\end_layout
+
+\begin_layout Itemize
+Wrap existing libraries for Python access and reuse them (Numeric, LAPACK,
+ VTK, ...)
+\end_layout
+
+\begin_layout Itemize
+Identify remaining hot spots via
+\color none
+
+\color blue
+profiling
+\color none
+.
+\end_layout
+
+\begin_layout Itemize
+Rewrite
+\color none
+
+\color blue
+only
+\color none
+ the code for those hot spots in C/C++/FORTRAN.
+\end_layout
+
+\end_deeper
+\begin_layout Itemize
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+<+->
+\end_layout
+
+\end_inset
+
+The resulting code will be production-ready:
+\color none
+
+\color blue
+no throw-away codes
+\color none
+.
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+Make your code available as a library for
+\color none
+
+\color blue
+interactive use
+\color none
+.
+\end_layout
+
+\begin_layout Itemize
+Integrate plotting, visualization, logging, ..., into your objects.
+\end_layout
+
+\end_deeper
+\begin_layout Itemize
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+<+->
+\end_layout
+
+\end_inset
+
+
+\color blue
+Apply this to existing codes
+\color none
+
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+Break them into a library core and control layers.
+\end_layout
+
+\begin_layout Itemize
+Wrap the libraries and expose them to Python.
+\end_layout
+
+\begin_layout Itemize
+Write all new control as quick, light Python scripts.
+\end_layout
+
+\end_deeper
+\begin_layout Section*
+Wrapup
+\end_layout
+
+\begin_layout BeginFrame
+Summary
+\end_layout
+
+\begin_layout Itemize
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+<+->
+\end_layout
+
+\end_inset
+
+
+\color blue
+Python
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+An excellent language for scientific computing development.
+\end_layout
+
+\begin_layout Itemize
+Scales from interactive exploration to full-blown production codes.
+\end_layout
+
+\begin_layout Itemize
+Accessible to scientists who are not professional programmers.
+\end_layout
+
+\end_deeper
+\begin_layout Standard
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+vskip0pt plus.5fill
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+<+->
+\end_layout
+
+\end_inset
+
+
+\color red
+Outlook
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+NumPy, SciPy, matplotlib, IPython, MayaVi, Sage, etc
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+ldots
+\end_layout
+
+\end_inset
+
+:
+\series bold
+all
+\series default
+are moving forward and improving.
+\end_layout
+
+\begin_layout Itemize
+Major DOE, NSF, NiH projects are adopting it as a core technology.
+\end_layout
+
+\begin_layout Itemize
+Yearly conference at Caltech (August) growing.
+\end_layout
+
+\begin_layout Itemize
+These projects are all Open Source: if you find a flaw, a bug, or a missing
+ feature,
+\color none
+
+\emph on
+\color blue
+jump on board!
+\end_layout
+
+\begin_layout Itemize
+There are still many rough edges to which various projects can contribute.
+\end_layout
+
+\end_deeper
+\begin_layout BeginPlainFrame
+Thank you! Questions?
+\end_layout
+
+\begin_layout FrameSubtitle
+Credit: http://xkcd.com/353
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+vspace{-5mm}
+\end_layout
+
+\end_inset
+
+
+\begin_inset Graphics
+ filename fig/xkcd_python.png
+ lyxscale 50
+ height 85pheight%
+ BoundingBox -4bp -4bp 518bp 588bp
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginPlainFrame
+
+\end_layout
+
+\begin_layout Standard
+\align center
+
+\series bold
+\size largest
+\color blue
+We're done here!
+\end_layout
+
+\begin_layout EndFrame
+
+\end_layout
+
+\begin_layout Section*
+\start_of_appendix
+\begin_inset Note Note
+status collapsed
+
+\begin_layout Standard
+All of the following is optional and typically not needed.
+\end_layout
+
+\end_inset
+
+Appendix
+\end_layout
+
+\begin_layout Subsection*
+URLs
+\end_layout
+
+\begin_layout BeginFrame
+Some useful URLs
+\end_layout
+
+\begin_layout Itemize
+A collection of links on Python and Scientific Computing:
+\color blue
+
+\newline
+
+\begin_inset LatexCommand htmlurl
+target "http://amath.colorado.edu/faculty/fperez/python/scicomp"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+SciPy:
+\color none
+
+\color blue
+
+\begin_inset LatexCommand htmlurl
+target "http://www.scipy.org"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+IPython, an improved interactive shell
+\color blue
+:
+\newline
+
+\begin_inset LatexCommand htmlurl
+target "http://ipython.scipy.org"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+Matplotlib, 2d plotting with Matlab syntax
+\color blue
+:
+\newline
+
+\begin_inset LatexCommand htmlurl
+target "http://matplotlib.sourceforge.net"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+MayaVi, 3d data visualization:
+\color blue
+
+\newline
+
+\begin_inset LatexCommand htmlurl
+target "http://mayavi.sourceforge.net"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+PyX, programmatic PostScript generation (with
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+LaTeX
+\end_layout
+
+\end_inset
+
+ support)
+\color blue
+:
+\newline
+
+\begin_inset LatexCommand htmlurl
+target "http://pyx.sourceforge.net"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+F2Py (FORTRAN):
+\color none
+
+\color blue
+
+\begin_inset LatexCommand htmlurl
+target "http://cens.ioc.ee/projects/f2py2e"
+
+\end_inset
+
+
+\color none
+
+\end_layout
+
+\begin_layout Itemize
+SWIG (C/C++ for Python):
+\color none
+
+\color blue
+
+\begin_inset LatexCommand htmlurl
+target "http://swig.org"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginFrame
+URLs for projects mentioned earlier
+\end_layout
+
+\begin_layout Itemize
+VPython, real-time 3D:
+\color none
+
+\color blue
+
+\begin_inset LatexCommand htmlurl
+target "http://vpython.org"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+UCSF Chimera - interactive molecular graphics
+\color blue
+:
+\newline
+
+\begin_inset LatexCommand htmlurl
+target "http://www.cgl.ucsf.edu/chimera"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+PyRAF - Hubble Space Telescope interface to IRAF
+\color blue
+:
+\newline
+
+\begin_inset LatexCommand htmlurl
+target "http://www.stsci.edu/resources/software_hardware/pyraf"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+BioPython -
+\color none
+
+\color blue
+
+\begin_inset LatexCommand htmlurl
+target "http://biopython.org"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+VisionEgg - vision research experiments (OpenGL):
+\color blue
+
+\newline
+
+\begin_inset LatexCommand htmlurl
+target "http://www.visionegg.org"
+
+\end_inset
+
+
+\color none
+
+\end_layout
+
+\begin_layout Itemize
+Natural Language Toolkit:
+\newline
+
+\color blue
+
+\begin_inset LatexCommand htmlurl
+target "http://nltk.sourceforge.net"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+Neural Integrator - visual programming for neural networks:
+\newline
+
+\color blue
+
+\begin_inset LatexCommand htmlurl
+target "http://starship.python.net/crew/seehof/NeuralPython.html"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+Orange - component-based data mining:
+\newline
+
+\color blue
+
+\begin_inset LatexCommand htmlurl
+target "http://www.ailab.si/orange"
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout EndFrame
+
+\end_layout
+
+\end_body
+\end_document
Added: trunk/py4science/intro_talk/0810_berkeley_intro.lyx
===================================================================
--- trunk/py4science/intro_talk/0810_berkeley_intro.lyx (rev 0)
+++ trunk/py4science/intro_talk/0810_berkeley_intro.lyx 2008-10-19 08:37:47 UTC (rev 6272)
@@ -0,0 +1,2274 @@
+#LyX 1.5.5 created this file. For more info see http://www.lyx.org/
+\lyxformat 276
+\begin_document
+\begin_header
+\textclass beamer
+\begin_preamble
+% Include only certain frames - this speeds up compilation
+% The frames to be included need to be labeled, by using ERT
+% as [label=LABELNAME] (no backslashes or {})
+%\includeonlyframes{currentt}
+
+% To make a printable handout (one page per frame), pass
+% the handout option to the doc class (Layout menu)
+
+% For good fonts in PDFs, use pslatex fonts (Layout menu)
+
+% Colors and symbols
+\usepackage{latexsym}
+\usepackage{color}
+
+% Display covered items in transparent form (as opposed
+% to not showing them at all)
+\newcommand{\coveredinvisible}{
+ \setbeamercovered{invisible}
+}
+\newcommand{\coveredvisible}{
+ \setbeamercovered{highly dynamic}
+}
+
+% Choose default setting here:
+\coveredvisible
+
+\newcommand{\ps}{\vspace{-4mm} }
+
+% Theme configuration. I've basically built a custom theme out of
+% Warsaw, adding infoline and changing the nav. symbol bar
+
+% Warning: the commands below are order-sensitive!
+
+% load the infolines theme, b/c I want the headline Warsaw
+% uses (split), but the footline from infolines.
+% In the document body, these will be deactivated for the title and
+% turned on later
+\useoutertheme{infolines}
+% Main theme
+\usetheme{Warsaw}
+% Adjust the color for the center (title) box to be that of
+% infolines, which Warsaw changes
+\setbeamercolor*{title in head/foot}{parent=palette secondary}
+
+% Define a minimal set of navigation symbols
+\defbeamertemplate*{navigation symbols}{minmal}
+{%
+ \hbox{%
+ \hbox{\insertframenavigationsymbol}
+ \hbox{\insertdocnavigationsymbol}
+ \hbox{\insertbackfindforwardnavigationsymbol}%
+ }%
+}
+% activate the minimal navbar
+\setbeamertemplate{navigation symbols}[minimal]
+
+%%%%% HACK %%%%%
+% I started getting errors because LyX is emmitting a color 'none'
+% call, which confuses xcolor. I'm defining 'none' to be black here.
+\definecolor{none}{cmyk}{0,0,0,1}
+%%%%% /HACK %%%%%
+\end_preamble
+\options compress
+\language english
+\inputencoding auto
+\font_roman times
+\font_sans helvet
+\font_typewriter courier
+\font_default_family default
+\font_sc false
+\font_osf false
+\font_sf_scale 100
+\font_tt_scale 100
+\graphics default
+\paperfontsize default
+\spacing single
+\papersize default
+\use_geometry false
+\use_amsmath 2
+\use_esint 0
+\cite_engine basic
+\use_bibtopic false
+\paperorientation landscape
+\secnumdepth 2
+\tocdepth 2
+\paragraph_separation indent
+\defskip medskip
+\quotes_language english
+\papercolumns 1
+\papersides 1
+\paperpagestyle default
+\tracking_changes false
+\output_changes false
+\author ""
+\author ""
+\end_header
+
+\begin_body
+
+\begin_layout Standard
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+Some things to fix in a future version:
+\end_layout
+
+\begin_layout Standard
+- trim a bit of time
+\end_layout
+
+\begin_layout Standard
+- add more about ipython and my own python work, reduce that of others
+\end_layout
+
+\begin_layout Standard
+- add a final python pros/cons, esp.
+ the cons part.
+ It will make things more balanced.
+\end_layout
+
+\begin_layout Standard
+- the PDE part repeats a bit the 'python benefits' which were already pounded
+ on.
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+% disable the bottom bar for the title and outline pages
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\begin_layout Standard
+
+
+\backslash
+setbeamertemplate{footline}{}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+vspace*{-5mm}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Title
+Python in Scientific Computing
+\begin_inset OptArg
+status open
+
+\begin_layout Standard
+Python & Scientific Computing
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subtitle
+An Overview
+\end_layout
+
+\begin_layout Author
+Fernando\InsetSpace ~
+Pérez
+\newline
+
+\family typewriter
+\size scriptsize
+<Fer...@be...>
+\family default
+\size default
+
+\begin_inset OptArg
+status open
+
+\begin_layout Standard
+FP
+\begin_inset Note Note
+status collapsed
+
+\begin_layout Standard
+This is used by the 'split' footline theme on the left side of the page
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+vspace{5mm}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Institute
+Neuroscience/BIC, U.C Berkeley
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+- Use the
+\backslash
+inst command only if there are several affiliations.
+\end_layout
+
+\begin_layout Standard
+- Keep it simple, no one is interested in your street address.
+\end_layout
+
+\end_inset
+
+
+\begin_inset OptArg
+status open
+
+\begin_layout Standard
+UCB
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+optional, but mostly needed
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\end_inset
+
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+vspace{5mm}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Date
+UC Berkeley
+\newline
+Oct 9, 2008
+\begin_inset OptArg
+status open
+
+\begin_layout Standard
+UCB, 10/09/08
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+If you have a file called "institution-logo-filename.xxx", where xxx is a
+ graphic format that can be processed by latex or pdflatex, resp., then you
+ can add a logo by uncommenting the following:
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+%
+\backslash
+pgfdeclareimage[height=0.5cm]{institution-logo}{institution-logo-filename}
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\begin_layout Standard
+
+%
+\backslash
+logo{
+\backslash
+pgfuseimage{institution-logo}}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+The following causes the table of contents to be shown at the beginning
+ of every Section.
+ Delete this, if you do not want it.
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+AtBeginSection[]{
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\begin_layout Standard
+
+
+\backslash
+frame<beamer>{
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\begin_layout Standard
+
+
+\backslash
+frametitle{Outline}
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\begin_layout Standard
+
+
+\backslash
+tableofcontents[currentsection]
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\begin_layout Standard
+
+}
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\begin_layout Standard
+
+}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset Note Note
+status open
+
+\begin_layout Standard
+If you wish to uncover everything in a step-wise fashion, uncomment the
+ following command:
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+%
+\backslash
+beamerdefaultoverlayspecification{<+->}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+% reactivate the footline
+\end_layout
+
+\begin_layout Standard
+
+\end_layout
+
+\begin_layout Standard
+
+
+\backslash
+setbeamertemplate{footline}[infolines theme]
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginFrame
+Outline
+\end_layout
+
+\begin_layout Standard
+\begin_inset LatexCommand tableofcontents
+
+\end_inset
+
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+[pausesections]
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Section
+Scientific Computing
+\begin_inset OptArg
+status open
+
+\begin_layout Standard
+SciComp
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Existing tools
+\end_layout
+
+\begin_layout BeginFrame
+Pure Fortran, C and C++
+\end_layout
+
+\begin_layout Itemize
+Tools optimized for the CPU, not the developer.
+\end_layout
+
+\begin_layout Itemize
+Low-level (data types and libraries).
+\end_layout
+
+\begin_layout Itemize
+Difficult access to visualization, quick profiling, text processing,
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+ldots
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Itemize
+No interactive facilities.
+\end_layout
+
+\begin_layout Pause
+
+\end_layout
+
+\begin_layout Standard
+
+\series bold
+\color blue
+However!
+\end_layout
+
+\begin_layout Itemize
+They deliver excellent performance.
+\end_layout
+
+\begin_layout Itemize
+Millions of LOC in proven scientific codes.
+
+\end_layout
+
+\begin_layout Itemize
+We need to
+\emph on
+\color blue
+work with these tools
+\emph default
+\color inherit
+, not replace them!
+\end_layout
+
+\begin_layout BeginFrame
+Complementary high level tools
+\end_layout
+
+\begin_layout Itemize
+Mathematica, Maple, Matlab, IDL: extremely popular, for good reasons.
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+Interactivity, visualization, extensive libraries.
+\end_layout
+
+\begin_layout Itemize
+Unpleasant for large-scale programs and non-mathematical tasks.
+\end_layout
+
+\begin_layout Itemize
+Expensive, proprietary: lock-in.
+\end_layout
+
+\end_deeper
+\begin_layout Pause
+
+\end_layout
+
+\begin_layout Itemize
+Another common approach: the `command pipeline'
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+FORTRAN, C, C++ programs ...
+\end_layout
+
+\begin_layout Itemize
+driven by Bash/awk/sed/Perl scripts ...
+\end_layout
+
+\begin_layout Itemize
+which feed them input and send the output ...
+\end_layout
+
+\begin_layout Itemize
+to visualization/analysis programs.
+\end_layout
+
+\end_deeper
+\begin_layout Subsection
+Python?
+\begin_inset OptArg
+status open
+
+\begin_layout Standard
+Python
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginFrame
+Python in this context
+\end_layout
+
+\begin_layout Itemize
+
+\color blue
+Free
+\color none
+ (BSD license), highly portable (Linux, OSX, Windows, lots...).
+\end_layout
+
+\begin_layout Itemize
+
+\color blue
+Interactive
+\color none
+ interpreter provided.
+\end_layout
+
+\begin_layout Itemize
+Extremely readable syntax (
+\color blue
+
+\begin_inset Quotes eld
+\end_inset
+
+executable pseudo-code
+\begin_inset Quotes erd
+\end_inset
+
+
+\color none
+).
+\end_layout
+
+\begin_layout Itemize
+
+\color blue
+Simple
+\color none
+: non-professional programmers can use it effectively.
+\end_layout
+
+\begin_layout Itemize
+Clean object oriented model, but
+\color none
+
+\color blue
+not mandatory
+\color none
+.
+\end_layout
+
+\begin_layout Itemize
+Rich built-in types: lists, sets, dictionaries (hash tables), strings, ...
+\end_layout
+
+\begin_layout Itemize
+Very comprehensive standard library (
+\color blue
+batteries included
+\color none
+)
+\end_layout
+
+\begin_layout Itemize
+Standard libraries for IDL/Matlab-like arrays (NumPy)
+\end_layout
+
+\begin_layout Itemize
+Easy to wrap existing C, C++ and FORTRAN codes.
+\end_layout
+
+\begin_layout Section
+Interlude: Python in the real world
+\begin_inset OptArg
+status collapsed
+
+\begin_layout Standard
+Examples
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+EEG analysis for epilepsy
+\begin_inset OptArg
+status open
+
+\begin_layout Standard
+EEG
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginPlainFrame
+Data analysis for epilepsy surgery
+\end_layout
+
+\begin_layout FrameSubtitle
+Isolating the origin of drug-resistant epileptic seizures which require
+ surgery.
+\end_layout
+
+\begin_layout Standard
+John Hunter, Department of Pediatric Neurology, University of Chicago.
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/mpl_brain1.png
+ lyxscale 50
+ width 80text%
+ keepAspectRatio
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginPlainFrame
+Electrode location in 3D, combined with MRI data
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/mpl_brain3.png
+ lyxscale 50
+ width 90text%
+ keepAspectRatio
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginPlainFrame
+Correlation analysis of seizure data
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/mpl_brain4.png
+ lyxscale 50
+ width 90text%
+ keepAspectRatio
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginPlainFrame
+Final location of epileptic foci for surgery
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/mpl_brain5.png
+ lyxscale 50
+ width 90text%
+ keepAspectRatio
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+Multiwavelets for PDEs
+\begin_inset OptArg
+status open
+
+\begin_layout Standard
+PDEs
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginFrame
+Adaptive, multiwavelet algorithms for integral operators
+\end_layout
+
+\begin_layout Standard
+Gregory Beylkin, Vani Cheruvu, Fernando Perez.
+ Applied Math, U.
+ of Colorado at Boulder.
+\end_layout
+
+\begin_layout Itemize
+Fast application of integral kernels.
+ (Partial Differential Equations)
+\end_layout
+
+\begin_layout Itemize
+Implementation went from 1 to 3 dimensions directly (
+\emph on
+extremely
+\emph default
+ unusual).
+\end_layout
+
+\begin_layout Itemize
+Very complex algorithm that goes beyond pure numerics.
+\end_layout
+
+\begin_layout Itemize
+Very good performance, thanks to NumPy, F2PY and weave.
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/rho_2d_surf.png
+ lyxscale 80
+ width 35text%
+
+\end_inset
+
+
+\begin_inset ERT
+status collapsed
+
+\begin_layout Standard
+
+
+\backslash
+hspace{1cm}
+\end_layout
+
+\end_inset
+
+
+\begin_inset Graphics
+ filename fig/rho_2d_skel.eps
+ lyxscale 80
+ width 25text%
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+JPL: Mars mission data visualization
+\begin_inset OptArg
+status collapsed
+
+\begin_layout Standard
+JPL - Mars
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginPlainFrame
+JPL: Mars mission trajectory design and nav data
+\end_layout
+
+\begin_layout FrameSubtitle
+Ted Drain and Lynn Craig, Jet Propulsion Laboratory (NASA/Caltech)
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+\size footnotesize
+From: Name Elided <nam...@jp...>
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+\size footnotesize
+Date: Oct 2, 2007 7:15 PM
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+\size footnotesize
+Subject: Fwd: matplotlib bug numbers
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+\size footnotesize
+To: John Hunter <jd...@gm...>
+\end_layout
+
+\begin_layout Standard
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+vspace{5mm}
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+\size tiny
+One of my lead developers mentioned that they had sent a bug to you about
+ the annotations feature of MatPlotLib.
+ Would you be able to let me know what the timeline is to resolve that bug?
+ The reason is that
+\series bold
+\color red
+the feature is needed for the Phoenix project and their arrival at Mars
+ will be in March sometime
+\series default
+\color inherit
+, but they are doing their testing in the coming few months.
+ This annotation feature is used on reports that present the analysis of
+ the trajectory to the navigation team and it shows up on our schedule.
+
+\series bold
+\color red
+It would really help me to know approximately when it could be resolved.
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+\size tiny
+B-plane plots are used to show the trajectory of a spacecraft with respect
+ to the target body (specifically perpendicular to the incoming asymptote
+ of the spacecraft trajectory) and we plot them with the y-axis inverted.
+ The plot is used heavily in flight operations so it is important to our
+ customers.
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+\size tiny
+In addition, we have what is called a thundering heard plot where many different
+ trajectory solutions (determined from different measurement sources) are
+ plotted together.
+ The annotations are import there so we can see which plot corresponds to
+ each source of data.
+ I hope it helps to know how your code will be used in spacecraft navigation.
+\end_layout
+
+\begin_layout Standard
+
+\family typewriter
+\size tiny
+Thanks for all your efforts.
+\end_layout
+
+\begin_layout BeginPlainFrame
+JPL: Mars mission data visualization
+\end_layout
+
+\begin_layout Standard
+Expected communication power levels between an orbiting spacecraft and a
+ lander as it goes through the atmosphere:
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/jpl_lander_comm_power.png
+ lyxscale 25
+ width 90text%
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginPlainFrame
+JPL: Mars mission data visualization (2)
+\end_layout
+
+\begin_layout Standard
+Summary of the current navigation team activities and modelling (data used,
+ event times etc):
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset ERT
+status open
+
+\begin_layout Standard
+
+
+\backslash
+vspace{-3mm}
+\end_layout
+
+\end_inset
+
+
+\begin_inset Graphics
+ filename fig/jpl_nav_summary.png
+ lyxscale 50
+ width 90text%
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+PMV: structural bioinformatics
+\begin_inset OptArg
+status collapsed
+
+\begin_layout Standard
+PMV
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginPlainFrame
+PMV: the Python Molecule Viewer
+\end_layout
+
+\begin_layout FrameSubtitle
+Michel F.
+ Sanner, Molecular Biology Department, The Scripps Research Institute.
+\end_layout
+
+\begin_layout Standard
+\align center
+\begin_inset Graphics
+ filename fig/pmv.png
+ lyxscale 50
+ width 100text%
+ keepAspectRatio
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout Subsection
+MayaVi: customizable data visualization
+\begin_inset OptArg
+status open
+
+\begin_layout Standard
+MayaVi
+\end_layout
+
+\end_inset
+
+
+\end_layout
+
+\begin_layout BeginFrame
+MayaVi: sophisticated data visualization
+\end_layout
+
+\begin_layout Itemize
+Free, easy to use scientific data visualizer.
+\end_layout
+
+\begin_layout Itemize
+Heavy lifting of OpenGL-based rendering: VTK (a C++ library).
+\end_layout
+
+\begin_layout Itemize
+A very good example of how to properly use Python:
+\end_layout
+
+\begin_deeper
+\begin_layout Itemize
+MayaVi is a standalone GUI program...
+\end_layout
+
+\begin_la...
[truncated message content] |
|
From: <fer...@us...> - 2008-10-19 09:35:09
|
Revision: 6277
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6277&view=rev
Author: fer_perez
Date: 2008-10-19 09:35:03 +0000 (Sun, 19 Oct 2008)
Log Message:
-----------
Add doc links for use during workshops
Added Paths:
-----------
trunk/py4science/doc/doc_links.rst
Added: trunk/py4science/doc/doc_links.rst
===================================================================
--- trunk/py4science/doc/doc_links.rst (rev 0)
+++ trunk/py4science/doc/doc_links.rst 2008-10-19 09:35:03 UTC (rev 6277)
@@ -0,0 +1,33 @@
+============================
+ Useful documentation links
+============================
+
+* Official `Python documentation <http://docs.python.org>`_.
+
+* `IPython manual <http://ipython.scipy.org/doc/manual/html>`_.
+
+* The `introductory Numpy guide <http://mentat.za.net/numpy/intro/intro.html>`_.
+
+* The `Numpy reference guide <http://mentat.za.net/numpy/refguide/>`_.
+
+* The `matplotlib user guide <http://matplotlib.sourceforge.net>`_.
+
+* The `SciPy documentation page <http://www.scipy.org/Documentation>`_. Some
+ highlights:
+
+ * `Numpy Functions by Category
+ <http://www.scipy.org/Numpy_Functions_by_Category>`_
+
+ * `NumPy for Matlab Users <http://www.scipy.org/NumPy_for_Matlab_Users>`_
+
+ * `Numpy Example List <http://www.scipy.org/Numpy_Example_List_With_Doc>`_
+
+ * `Interactive data analysis Tutorial <http://www.scipy.org/wikis/topical_software/Tutorial>`_.
+
+
+Other links
+===========
+
+* The location for the `Py4Science repository
+ <https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/trunk/py4science>`_.
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fer...@us...> - 2008-10-19 09:15:57
|
Revision: 6276
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6276&view=rev
Author: fer_perez
Date: 2008-10-19 09:11:30 +0000 (Sun, 19 Oct 2008)
Log Message:
-----------
Workbook updates.
Modified Paths:
--------------
trunk/py4science/workbook/bessel.tex
trunk/py4science/workbook/fft_imdenoise.tex
trunk/py4science/workbook/qsort.tex
trunk/py4science/workbook/quad_newton.tex
trunk/py4science/workbook/trapezoid.tex
trunk/py4science/workbook/update_problems.py
trunk/py4science/workbook/wallis_pi.tex
Added Paths:
-----------
trunk/py4science/examples/mkprob.py
Removed Paths:
-------------
trunk/py4science/examples/mkskel.py
Copied: trunk/py4science/examples/mkprob.py (from rev 6270, trunk/py4science/examples/mkskel.py)
===================================================================
--- trunk/py4science/examples/mkprob.py (rev 0)
+++ trunk/py4science/examples/mkprob.py 2008-10-19 09:11:30 UTC (rev 6276)
@@ -0,0 +1,325 @@
+#!/usr/bin/env python
+"""Make skeletons out of Python scripts.
+
+Usage:
+
+ mkprob.py [--test] file1.py file2.py ....
+
+If --test is given, the test suite is run instead.
+
+For each input filename f.py, a pair of output files is generated, f_soln.py
+and f_skel.py.
+
+Source markup is very simple. The tests in the file show precisely how it
+works, but in summary:
+
+- Pure comment lines with the special marker (#@) are left in the skeleton
+ (only the marker is stripped, but they remain as valid comments). These are
+ typically used for hints.
+
+- Code lines terminated with the marker are:
+
+ - In the skeleton, replaced by a NotImplementedError call. Consecutive lines
+ are replaced by a single call.
+
+ - In the solution, kept as is but the marker is removed.
+"""
+
+from __future__ import with_statement
+
+#-----------------------------------------------------------------------------
+# Stdlib imports
+import os
+import re
+import shutil
+import sys
+
+# Third-party imports
+import nose
+
+# Constants
+MARKER = '#@'
+DEL_RE = re.compile(r'''^((\s*)(.*?))\s*%s\s*$''' % MARKER)
+HINT_RE = re.compile(r'''^(?P<space>\s*)%s\s+(?P<hint>.*)$''' % MARKER)
+
+
+#-----------------------------------------------------------------------------
+# Main code begins
+
+def src2soln(src):
+ """Remove markers from input source, leaving all else intact.
+
+ Inputs:
+ src : sequence of lines (file-like objects work out of the box)
+ """
+
+ out = []
+ addline = out.append
+ for line in src:
+ # Check for lines to delete and with hints
+ mdel = DEL_RE.match(line)
+ mhint = HINT_RE.match(line)
+
+ # All hints are unconditionally removed
+ if mhint is None:
+ if mdel:
+ # if marker is matched in code, strip it and leave the code
+ line = mdel.group(1)+'\n'
+ addline(line)
+
+ return ''.join(out)
+
+
+def src2skel(src):
+ """Remove markers from input source, replacing marked lines.
+
+ Marked lines are replaced with "raise NotImplementedError" calls that
+ summarize the total number of deleted lines.
+
+ Inputs:
+ src : sequence of lines (file-like objects work out of the box)
+ """
+
+ def flush_buffers(normal_lines,del_lines=0):
+ """Local function to reuse some common code"""
+
+ if state_cur == normal:
+ # add the normal lines
+ out.extend(normal_lines)
+ normal_lines[:] = []
+ else:
+ # Add the summary of 'raise' lines
+
+ # flush counter of code (disabled, we report static summary)
+ #msg = '1 line' if del_lines==1 else ('%s lines' % del_lines)
+ #exc = exc_tpl % msg
+ exc = exc_tpl
+
+ # Use the last value of 'space'
+ line = '%s%s' % (spaces[0],exc)
+ out.append(line)
+ del_lines = 0
+ spaces[:] = []
+
+ return del_lines
+
+ # used to report actual # of lines removed - disabled
+ #exc_tpl = "raise NotImplementedError('%s missing')\n"
+ exc_tpl = "raise NotImplementedError('insert missing code here')\n"
+
+ # states for state machine and other initialization
+ normal,delete = 0,1
+ state_cur = normal
+ del_lines = 0 # counter, in case we want to report # of deletions
+ spaces = []
+ normal_lines = []
+ out = []
+
+ # To remove multiple consecutive lines of input marked for deletion, we
+ # need a small state machine.
+ for line in src:
+ # Check for lines to delete and with hints
+ mdel = DEL_RE.match(line)
+ mhint = HINT_RE.match(line)
+
+ if mhint:
+ state_new = normal
+ hint = mhint.group('space')+'# ' + mhint.group('hint') +'\n'
+ normal_lines.append(hint)
+ else:
+ if mdel is None:
+ state_new = normal
+ normal_lines.append(line)
+ else:
+ state_new = delete
+ del_lines += 1
+ spaces.append(mdel.group(2))
+
+ # Flush output only when there's a change of state
+ if state_new != state_cur:
+ del_lines = flush_buffers(normal_lines,del_lines)
+
+ # Update state machine
+ state_cur = state_new
+
+ # Final buffer flush is unconditional
+ flush_buffers(normal_lines)
+
+ return ''.join(out)
+
+
+def transform_file(fpath,fname_skel,fname_soln):
+ """Run the cleanup routines for a given input, creating skel and soln.
+ """
+
+ # get the mode of the input so that we can create the output files with the
+ # same mode
+ fmode = os.stat(fpath).st_mode
+
+ with open(fpath) as infile:
+ # Generate the skeleton
+ skel = src2skel(infile)
+ with open(fname_skel,'w') as fskel:
+ fskel.write(skel)
+ os.chmod(fname_skel,fmode)
+
+ # Reset the input file pointer and generate the solution
+ infile.seek(0)
+ soln = src2soln(infile)
+ with open(fname_soln,'w') as fsoln:
+ fsoln.write(soln)
+ os.chmod(fname_soln,fmode)
+
+#-----------------------------------------------------------------------------
+# Main execution routines
+
+def copyforce(src,dest):
+ """Forceful file link/copy that overwrites destination files."""
+ try:
+ copy = os.link
+ except AttributeError:
+ copy = shutil.copy
+ if os.path.isfile(dest):
+ os.remove(dest)
+ copy(src,dest)
+
+
+def mvforce(src,dest):
+ """Forceful file copy that overwrites destination files."""
+ if os.path.isfile(dest):
+ os.remove(dest)
+ shutil.move(src,dest)
+
+
+def main(argv=None):
+ """Main entry point as a command line script for normal execution"""
+
+ if argv is None:
+ argv = sys.argv
+
+ # If there are subdirs called skel and soln, we populate them by moving the
+ # generated files there, otherwise they're left in the current dir.
+ skel_dir = 'skel'
+ soln_dir = 'soln'
+ has_skel_dir = os.path.isdir(skel_dir)
+ has_soln_dir = os.path.isdir(soln_dir)
+
+ # First, check that all files are present and abort immediately if any of
+ # them isn't there.
+ for fpath in argv[1:]:
+ if not os.path.isfile(fpath):
+ raise OSError("file %r not found" % fpath)
+
+ # If all files are there, then go ahead and process them unconditionally
+ for fpath in argv[1:]:
+ basename, ext = os.path.splitext(fpath)
+ fname_skel = basename + '_skel' + ext
+ fname_soln = basename + '_soln' + ext
+ transform_file(fpath,fname_skel,fname_soln)
+ # Move files over to final dirs if present
+ if has_skel_dir:
+ mvforce(fname_skel,os.path.join(skel_dir,fname_skel))
+ if has_soln_dir:
+ mvforce(fname_soln,os.path.join(soln_dir,fname_soln))
+
+#-----------------------------------------------------------------------------
+# Tests
+
+def str_match(s1,s2):
+ """Check that two strings are equal ignoring trailing whitespace."""
+ #print '***S1\n',s1,'\n***S2\n',s2 # dbg
+ nose.tools.assert_equal(s1.rstrip(),s2.rstrip())
+
+
+def test_simple():
+ src = """
+ first line
+ del line #@
+ second line
+ """
+ srclines = src.splitlines(True)
+
+ clean = """
+ first line
+ raise NotImplementedError('insert missing code here')
+ second line
+ """
+
+ cleaned = src2skel(srclines)
+ yield str_match,cleaned,clean
+
+ clean = """
+ first line
+ del line
+ second line
+ """
+ cleaned = src2soln(src.splitlines(True))
+ yield str_match,cleaned,clean
+
+
+def test_multi():
+ src = """
+ first line
+ #@ Hint: remember that
+ #@ idea we discussed before...
+ del line #@
+ del line2 #@
+ del line3 #@
+ second line:
+ del line4 #@
+ del line5 #@
+ third line
+
+ some indented code: #@
+ with more... #@
+ """
+ srclines = src.splitlines(True)
+
+ clean = """
+ first line
+ # Hint: remember that
+ # idea we discussed before...
+ raise NotImplementedError('insert missing code here')
+ second line:
+ raise NotImplementedError('insert missing code here')
+ third line
+
+ raise NotImplementedError('insert missing code here')
+ """
+ cleaned = src2skel(srclines)
+ yield str_match,cleaned,clean
+
+ clean = """
+ first line
+ del line
+ del line2
+ del line3
+ second line:
+ del line4
+ del line5
+ third line
+
+ some indented code:
+ with more...
+ """
+ cleaned = src2soln(srclines)
+ yield str_match,cleaned,clean
+
+
+@nose.tools.nottest
+def test():
+ """Simple self-contained test runner."""
+ nose.runmodule(__name__,exit=False,
+ argv=['--doctests',
+ #'-s',
+ #'--pdb-failures',
+ ])
+
+#-----------------------------------------------------------------------------
+# Execution from the command line.
+
+if __name__ == "__main__":
+ if '--test' in sys.argv:
+ test()
+ else:
+ main(sys.argv)
Property changes on: trunk/py4science/examples/mkprob.py
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mergeinfo
+
Deleted: trunk/py4science/examples/mkskel.py
===================================================================
--- trunk/py4science/examples/mkskel.py 2008-10-19 09:04:27 UTC (rev 6275)
+++ trunk/py4science/examples/mkskel.py 2008-10-19 09:11:30 UTC (rev 6276)
@@ -1,325 +0,0 @@
-#!/usr/bin/env python
-"""Make skeletons out of Python scripts.
-
-Usage:
-
- mkskel [--test] file1.py file2.py ....
-
-If --test is given, the test suite is run instead.
-
-For each input filename f.py, a pair of output files is generated, f_soln.py
-and f_skel.py.
-
-Source markup is very simple. The tests in the file show precisely how it
-works, but in summary:
-
-- Pure comment lines with the special marker (#@) are left in the skeleton
- (only the marker is stripped, but they remain as valid comments). These are
- typically used for hints.
-
-- Code lines terminated with the marker are:
-
- - In the skeleton, replaced by a NotImplementedError call. Consecutive lines
- are replaced by a single call.
-
- - In the solution, kept as is but the marker is removed.
-"""
-
-from __future__ import with_statement
-
-#-----------------------------------------------------------------------------
-# Stdlib imports
-import os
-import re
-import shutil
-import sys
-
-# Third-party imports
-import nose
-
-# Constants
-MARKER = '#@'
-DEL_RE = re.compile(r'''^((\s*)(.*?))\s*%s\s*$''' % MARKER)
-HINT_RE = re.compile(r'''^(?P<space>\s*)%s\s+(?P<hint>.*)$''' % MARKER)
-
-
-#-----------------------------------------------------------------------------
-# Main code begins
-
-def src2soln(src):
- """Remove markers from input source, leaving all else intact.
-
- Inputs:
- src : sequence of lines (file-like objects work out of the box)
- """
-
- out = []
- addline = out.append
- for line in src:
- # Check for lines to delete and with hints
- mdel = DEL_RE.match(line)
- mhint = HINT_RE.match(line)
-
- # All hints are unconditionally removed
- if mhint is None:
- if mdel:
- # if marker is matched in code, strip it and leave the code
- line = mdel.group(1)+'\n'
- addline(line)
-
- return ''.join(out)
-
-
-def src2skel(src):
- """Remove markers from input source, replacing marked lines.
-
- Marked lines are replaced with "raise NotImplementedError" calls that
- summarize the total number of deleted lines.
-
- Inputs:
- src : sequence of lines (file-like objects work out of the box)
- """
-
- def flush_buffers(normal_lines,del_lines=0):
- """Local function to reuse some common code"""
-
- if state_cur == normal:
- # add the normal lines
- out.extend(normal_lines)
- normal_lines[:] = []
- else:
- # Add the summary of 'raise' lines
-
- # flush counter of code (disabled, we report static summary)
- #msg = '1 line' if del_lines==1 else ('%s lines' % del_lines)
- #exc = exc_tpl % msg
- exc = exc_tpl
-
- # Use the last value of 'space'
- line = '%s%s' % (spaces[0],exc)
- out.append(line)
- del_lines = 0
- spaces[:] = []
-
- return del_lines
-
- # used to report actual # of lines removed - disabled
- #exc_tpl = "raise NotImplementedError('%s missing')\n"
- exc_tpl = "raise NotImplementedError('insert missing code here')\n"
-
- # states for state machine and other initialization
- normal,delete = 0,1
- state_cur = normal
- del_lines = 0 # counter, in case we want to report # of deletions
- spaces = []
- normal_lines = []
- out = []
-
- # To remove multiple consecutive lines of input marked for deletion, we
- # need a small state machine.
- for line in src:
- # Check for lines to delete and with hints
- mdel = DEL_RE.match(line)
- mhint = HINT_RE.match(line)
-
- if mhint:
- state_new = normal
- hint = mhint.group('space')+'# ' + mhint.group('hint') +'\n'
- normal_lines.append(hint)
- else:
- if mdel is None:
- state_new = normal
- normal_lines.append(line)
- else:
- state_new = delete
- del_lines += 1
- spaces.append(mdel.group(2))
-
- # Flush output only when there's a change of state
- if state_new != state_cur:
- del_lines = flush_buffers(normal_lines,del_lines)
-
- # Update state machine
- state_cur = state_new
-
- # Final buffer flush is unconditional
- flush_buffers(normal_lines)
-
- return ''.join(out)
-
-
-def transform_file(fpath,fname_skel,fname_soln):
- """Run the cleanup routines for a given input, creating skel and soln.
- """
-
- # get the mode of the input so that we can create the output files with the
- # same mode
- fmode = os.stat(fpath).st_mode
-
- with open(fpath) as infile:
- # Generate the skeleton
- skel = src2skel(infile)
- with open(fname_skel,'w') as fskel:
- fskel.write(skel)
- os.chmod(fname_skel,fmode)
-
- # Reset the input file pointer and generate the solution
- infile.seek(0)
- soln = src2soln(infile)
- with open(fname_soln,'w') as fsoln:
- fsoln.write(soln)
- os.chmod(fname_soln,fmode)
-
-#-----------------------------------------------------------------------------
-# Main execution routines
-
-def copyforce(src,dest):
- """Forceful file link/copy that overwrites destination files."""
- try:
- copy = os.link
- except AttributeError:
- copy = shutil.copy
- if os.path.isfile(dest):
- os.remove(dest)
- copy(src,dest)
-
-
-def mvforce(src,dest):
- """Forceful file copy that overwrites destination files."""
- if os.path.isfile(dest):
- os.remove(dest)
- shutil.move(src,dest)
-
-
-def main(argv=None):
- """Main entry point as a command line script for normal execution"""
-
- if argv is None:
- argv = sys.argv
-
- # If there are subdirs called skel and soln, we populate them by moving the
- # generated files there, otherwise they're left in the current dir.
- skel_dir = 'skel'
- soln_dir = 'soln'
- has_skel_dir = os.path.isdir(skel_dir)
- has_soln_dir = os.path.isdir(soln_dir)
-
- # First, check that all files are present and abort immediately if any of
- # them isn't there.
- for fpath in argv[1:]:
- if not os.path.isfile(fpath):
- raise OSError("file %r not found" % fpath)
-
- # If all files are there, then go ahead and process them unconditionally
- for fpath in argv[1:]:
- basename, ext = os.path.splitext(fpath)
- fname_skel = basename + '_skel' + ext
- fname_soln = basename + '_soln' + ext
- transform_file(fpath,fname_skel,fname_soln)
- # Move files over to final dirs if present
- if has_skel_dir:
- mvforce(fname_skel,os.path.join(skel_dir,fname_skel))
- if has_soln_dir:
- mvforce(fname_soln,os.path.join(soln_dir,fname_soln))
-
-#-----------------------------------------------------------------------------
-# Tests
-
-def str_match(s1,s2):
- """Check that two strings are equal ignoring trailing whitespace."""
- #print '***S1\n',s1,'\n***S2\n',s2 # dbg
- nose.tools.assert_equal(s1.rstrip(),s2.rstrip())
-
-
-def test_simple():
- src = """
- first line
- del line #@
- second line
- """
- srclines = src.splitlines(True)
-
- clean = """
- first line
- raise NotImplementedError('insert missing code here')
- second line
- """
-
- cleaned = src2skel(srclines)
- yield str_match,cleaned,clean
-
- clean = """
- first line
- del line
- second line
- """
- cleaned = src2soln(src.splitlines(True))
- yield str_match,cleaned,clean
-
-
-def test_multi():
- src = """
- first line
- #@ Hint: remember that
- #@ idea we discussed before...
- del line #@
- del line2 #@
- del line3 #@
- second line:
- del line4 #@
- del line5 #@
- third line
-
- some indented code: #@
- with more... #@
- """
- srclines = src.splitlines(True)
-
- clean = """
- first line
- # Hint: remember that
- # idea we discussed before...
- raise NotImplementedError('insert missing code here')
- second line:
- raise NotImplementedError('insert missing code here')
- third line
-
- raise NotImplementedError('insert missing code here')
- """
- cleaned = src2skel(srclines)
- yield str_match,cleaned,clean
-
- clean = """
- first line
- del line
- del line2
- del line3
- second line:
- del line4
- del line5
- third line
-
- some indented code:
- with more...
- """
- cleaned = src2soln(srclines)
- yield str_match,cleaned,clean
-
-
-@nose.tools.nottest
-def test():
- """Simple self-contained test runner."""
- nose.runmodule(__name__,exit=False,
- argv=['--doctests',
- #'-s',
- #'--pdb-failures',
- ])
-
-#-----------------------------------------------------------------------------
-# Execution from the command line.
-
-if __name__ == "__main__":
- if '--test' in sys.argv:
- test()
- else:
- main(sys.argv)
Modified: trunk/py4science/workbook/bessel.tex
===================================================================
--- trunk/py4science/workbook/bessel.tex 2008-10-19 09:04:27 UTC (rev 6275)
+++ trunk/py4science/workbook/bessel.tex 2008-10-19 09:11:30 UTC (rev 6276)
@@ -1,6 +1,10 @@
\section{Bessel functions}
\label{sec:bessel}
+\textbf{Illustrates}: Special functions library, array manipulations
+to check recursion relation.
+
+
In this exercise, you will verify a few simple relations involving the Bessel
functions of the first kind. The important relations to keep in mind are the
asymptotic form of $J_n(x)$ for $x>>n$:
Modified: trunk/py4science/workbook/fft_imdenoise.tex
===================================================================
--- trunk/py4science/workbook/fft_imdenoise.tex 2008-10-19 09:04:27 UTC (rev 6275)
+++ trunk/py4science/workbook/fft_imdenoise.tex 2008-10-19 09:11:30 UTC (rev 6276)
@@ -1,6 +1,9 @@
\section{FFT Image Denoising}
\label{sec:fft_imdenoise}
+\textbf{Illustrates}: 2-d image denoising, use of the scipy FFT library,
+array manipulations, image plotting.
+
Convolution of an input with with a linear filter in the termporal or spatial
domain is equivalent to multiplication by the fourier transforms of the input
and the filter in the spectral domain. This provides a conceptually simple way
Modified: trunk/py4science/workbook/qsort.tex
===================================================================
--- trunk/py4science/workbook/qsort.tex 2008-10-19 09:04:27 UTC (rev 6275)
+++ trunk/py4science/workbook/qsort.tex 2008-10-19 09:11:30 UTC (rev 6276)
@@ -1,6 +1,7 @@
-
\section{Sorting quickly with QuickSort }
+\textbf{Illustrates}: lists, recursion.
+
Quicksort is one of the best known, and probably the simplest, fast
algorithm for sorting $n$ items. It is fast in the sense that it
requires on average $\mathcal{O}(n\log n)$ comparisons instead of
Modified: trunk/py4science/workbook/quad_newton.tex
===================================================================
--- trunk/py4science/workbook/quad_newton.tex 2008-10-19 09:04:27 UTC (rev 6275)
+++ trunk/py4science/workbook/quad_newton.tex 2008-10-19 09:11:30 UTC (rev 6276)
@@ -1,6 +1,9 @@
\section{Newton's method}
\label{sec:quad_newton}
+\textbf{Illustrates:} functions as first class objects, use of the
+scipy libraries.
+
Consider the problem of solving for $t$ in
\begin{equation}
\int_{o}^{t}f(s)ds=u
Modified: trunk/py4science/workbook/trapezoid.tex
===================================================================
--- trunk/py4science/workbook/trapezoid.tex 2008-10-19 09:04:27 UTC (rev 6275)
+++ trunk/py4science/workbook/trapezoid.tex 2008-10-19 09:11:30 UTC (rev 6276)
@@ -1,6 +1,9 @@
\section{Trapezoidal rule}
\label{sec:trapezoid}
+\textbf{Illustrates}: basic array slicing, functions as first class
+objects.
+
In this exercise, you are tasked with implementing the simple trapezoid
rule formula for numerical integration. If we want to compute the
definite integral \begin{equation}
Modified: trunk/py4science/workbook/update_problems.py
===================================================================
--- trunk/py4science/workbook/update_problems.py 2008-10-19 09:04:27 UTC (rev 6275)
+++ trunk/py4science/workbook/update_problems.py 2008-10-19 09:11:30 UTC (rev 6276)
@@ -10,10 +10,11 @@
from IPython.genutils import target_outdated
# Constants
-SRC_DIR = '../examples'
-UPDATE = './mkskel.py'
-PROBLEMS_DIR = 'problems'
+SRC_DIR = '../examples' # source dir for the examples
+UPDATE = './mkprob.py' # executable to make problems (in SRC_DIR)
+PROBLEMS_DIR = 'problems' # directory for problem output (in this dir)
+
if __name__ == '__main__':
problems = [f for f in os.listdir(PROBLEMS_DIR) if f.endswith('.py')]
Modified: trunk/py4science/workbook/wallis_pi.tex
===================================================================
--- trunk/py4science/workbook/wallis_pi.tex 2008-10-19 09:04:27 UTC (rev 6275)
+++ trunk/py4science/workbook/wallis_pi.tex 2008-10-19 09:11:30 UTC (rev 6276)
@@ -1,6 +1,7 @@
-
\section{Wallis' slow road to $\pi$}
+\textbf{Illustrates}: arbitrary size integers, simple function definitions.
+
Wallis' formula is an infinite product that converges (slowly) to
$\pi$:\begin{equation}
\pi=\prod_{i=1}^{\infty}\frac{4i^{2}}{4i^{2}-1}.\end{equation}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fer...@us...> - 2008-10-19 09:08:54
|
Revision: 6275
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6275&view=rev
Author: fer_perez
Date: 2008-10-19 09:04:27 +0000 (Sun, 19 Oct 2008)
Log Message:
-----------
py4science doc cleanup - more stale docs
Removed Paths:
-------------
trunk/py4science/doc/intro_python_scicomp.pdf
Deleted: trunk/py4science/doc/intro_python_scicomp.pdf
===================================================================
--- trunk/py4science/doc/intro_python_scicomp.pdf 2008-10-19 09:03:25 UTC (rev 6274)
+++ trunk/py4science/doc/intro_python_scicomp.pdf 2008-10-19 09:04:27 UTC (rev 6275)
@@ -1,78172 +0,0 @@
-%PDF-1.4
-9 0 obj
-<< /S /GoTo /D (Outline0.1) >>
-endobj
-12 0 obj
-(Scientific Computing)
-endobj
-13 0 obj
-<< /S /GoTo /D (Outline0.1.1.6) >>
-endobj
-16 0 obj
-(Traditional approaches)
-endobj
-17 0 obj
-<< /S /GoTo /D (Outline0.1.2.22) >>
-endobj
-20 0 obj
-(Python?)
-endobj
-21 0 obj
-<< /S /GoTo /D (Outline0.2) >>
-endobj
-24 0 obj
-(Interlude: Python in the real world)
-endobj
-25 0 obj
-<< /S /GoTo /D (Outline0.2.1.34) >>
-endobj
-28 0 obj
-(EEG analysis for epilepsy)
-endobj
-29 0 obj
-<< /S /GoTo /D (Outline0.2.2.39) >>
-endobj
-32 0 obj
-(Multiwavelets)
-endobj
-33 0 obj
-<< /S /GoTo /D (Outline0.2.3.40) >>
-endobj
-36 0 obj
-(PMV: molecular structures)
-endobj
-37 0 obj
-<< /S /GoTo /D (Outline0.2.4.43) >>
-endobj
-40 0 obj
-(MayaVi: customizable data visualization)
-endobj
-41 0 obj
-<< /S /GoTo /D (Outline0.2.5.54) >>
-endobj
-44 0 obj
-(SAGE: System for Algebra and Geometry Experimentation)
-endobj
-45 0 obj
-<< /S /GoTo /D (Outline0.2.6.55) >>
-endobj
-48 0 obj
-(IPython)
-endobj
-49 0 obj
-<< /S /GoTo /D (Outline0.2.7.61) >>
-endobj
-52 0 obj
-(PyNGL)
-endobj
-53 0 obj
-<< /S /GoTo /D (Outline0.2.8.63) >>
-endobj
-56 0 obj
-endobj
-57 0 obj
-<< /S /GoTo /D (Outline0.3) >>
-endobj
-60 0 obj
-(Python and Scientific Computing)
-endobj
-61 0 obj
-<< /S /GoTo /D (Outline0.3.1.65) >>
-endobj
-64 0 obj
-(Basic features)
-endobj
-65 0 obj
-<< /S /GoTo /D (Outline0.3.2.68) >>
-endobj
-68 0 obj
-(Development in Python)
-endobj
-69 0 obj
-<< /S /GoTo /D (Outline0.4) >>
-endobj
-72 0 obj
-(Wrapup)
-endobj
-73 0 obj
-<< /S /GoTo /D (Outline1) >>
-endobj
-76 0 obj
-(Appendix)
-endobj
-77 0 obj
-<< /S /GoTo /D (Outline1.5) >>
-endobj
-80 0 obj
-(Appendix)
-endobj
-81 0 obj
-<< /S /GoTo /D (Outline1.5.1.75) >>
-endobj
-84 0 obj
-(Python overview)
-endobj
-85 0 obj
-<< /S /GoTo /D [86 0 R /Fit ] >>
-endobj
-92 0 obj <<
-/Length 1772
-/Filter /FlateDecode
->>
-stream
-x\xDA\xCDY\xDFO7~\xBF\xBFbA\xEA:\xFF\xB6TU%i\x88\xA9UTyh\xFA\x80\x8E\x83 q\\xA5\xED_\xDF\xCF\xF6\xDA\xDB[ \x8D\xD4
-\x81׳3\xE3o<\xE3\xF1\xCCB
-\xC75\x9E9r\xD4\xC3I\xA9\x9B\xF9rƛ+\xBCz3\xA3\x8E\xA5\xEDx\xDA1\xA6\xCA|\xD60\xE7\x8D4\x829\xA9l#\xAC`$5\xEBEsY\xF4\x95\xD7|L\xD1\xCE\xEA\xBB\xDA&\xA4\xB6\xA5y\xD31\xEF\x85H1Ѥ_۬\xAF\x9A\xFE\xF4}\x95\x95J2\xF2N\xC3p噗J\x8C\x9Eqf\xF6)\xEE}\xD2{\xF6\xE4?\xC3Y\xB8#,\x87Q:\xA6\xAC\x8D\xCC\xD5\xD7[̆\x985އ\x88QF
-\xE3\x84\xD7t\x9CK\xD6(\xEF\xFBN#\xA6\xBCRA\xFE\xBE\x99\xED06#\xDA@\x92\xC1\xA8/M1\xCC[\xE9\xDE"\x99tV\xCAF\x80\x81\xB8\xB1h\x99\xE3\x9C;\x90Fj\x96\x85"\x99\xC0(\x9B\x9Ba\x83Gc$,\xA6<\x88S7s̄I\xE6^f\x82b\x98cY\xF0\x8B\xF0Hz\x8CD\x81\x99\x8B\xFE"\x95t\xDA\xCCN\x82\x81.\xFF\xC0\xB4\xB8\x83
-v\xA6g\xE5 |
|
From: <fer...@us...> - 2008-10-19 09:04:32
|
Revision: 6273
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6273&view=rev
Author: fer_perez
Date: 2008-10-19 09:01:48 +0000 (Sun, 19 Oct 2008)
Log Message:
-----------
Cleanup - remove stale docs
Removed Paths:
-------------
trunk/py4science/doc/fp_notes.lyx
trunk/py4science/doc/workbook.pdf
Deleted: trunk/py4science/doc/fp_notes.lyx
===================================================================
--- trunk/py4science/doc/fp_notes.lyx 2008-10-19 08:37:47 UTC (rev 6272)
+++ trunk/py4science/doc/fp_notes.lyx 2008-10-19 09:01:48 UTC (rev 6273)
@@ -1,562 +0,0 @@
-#LyX 1.4.3 created this file. For more info see http://www.lyx.org/
-\lyxformat 245
-\begin_document
-\begin_header
-\textclass article
-\begin_preamble
-\usepackage{color}
-
-% A few colors to replace the defaults for certain link types
-\definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
-\definecolor{darkorange}{rgb}{.71,0.21,0.01}
-\definecolor{darkred}{rgb}{.52,0.08,0.01}
-\definecolor{darkgreen}{rgb}{.12,.54,.11}
-
-% Use and configure listings package for nicely formatted code
-\usepackage{listings}
-\lstset{
- language=Python,
- basicstyle=\small\ttfamily,
- commentstyle=\ttfamily\color{blue},
- stringstyle=\ttfamily\color{darkorange},
- showstringspaces=false,
- breaklines=true,
- postbreak = \space\dots
-}
-
-\usepackage[%pdftex, % needed for pdflatex
- breaklinks=true, % so long urls are correctly broken across lines
- colorlinks=true,
- urlcolor=blue,
- linkcolor=darkred,
- citecolor=darkgreen,
- ]{hyperref}
-
-\usepackage{html}
-
-% This helps prevent overly long lines that stretch beyond the margins
-\sloppy
-
-% Define a \codelist command which either uses listings for latex, or
-% plain verbatim for html (since latex2html doesn't understand the
-% listings package).
-\usepackage{verbatim}
-\newcommand{\codelist}[1] {
-\latex{\lstinputlisting{#1}}
-\html{\verbatiminput{#1}}
-}
-\end_preamble
-\language english
-\inputencoding auto
-\fontscheme default
-\graphics default
-\paperfontsize default
-\spacing single
-\papersize default
-\use_geometry true
-\use_amsmath 1
-\cite_engine basic
-\use_bibtopic false
-\paperorientation portrait
-\leftmargin 1in
-\topmargin 1in
-\rightmargin 1in
-\bottommargin 1in
-\secnumdepth 3
-\tocdepth 3
-\paragraph_separation skip
-\defskip medskip
-\quotes_language english
-\papercolumns 1
-\papersides 1
-\paperpagestyle default
-\tracking_changes false
-\output_changes false
-\end_header
-
-\begin_body
-
-\begin_layout Title
-Python Workshop Problems
-\end_layout
-
-\begin_layout Standard
-\begin_inset LatexCommand \tableofcontents{}
-
-\end_inset
-
-
-\end_layout
-
-\begin_layout Section
-Quicksort
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-Illustrates
-\series default
-: lists, recursion.
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-Task
-\series default
-: implement the quicksort algorithm.
-\end_layout
-
-\begin_layout Subsubsection*
-Code skeleton
-\end_layout
-
-\begin_layout Standard
-\begin_inset ERT
-status open
-
-\begin_layout Standard
-
-
-\backslash
-codelist{skel/qsort_skel.py}
-\end_layout
-
-\end_inset
-
-
-\end_layout
-
-\begin_layout Section
-Wallis'
-\begin_inset Formula $\pi$
-\end_inset
-
-
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-Illustrates
-\series default
-: arbitrary size integers, simple function definitions.
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-Task
-\series default
-: define a simple function that implements the (slowly converging) Wallis
- infinite product approximation to
-\begin_inset Formula $\pi$
-\end_inset
-
-:
-\begin_inset Formula \[
-\pi(n)=2\prod_{i=1}^{n}\frac{4i^{2}}{4i^{2}-1}\]
-
-\end_inset
-
-
-\end_layout
-
-\begin_layout Subsubsection*
-Code skeleton
-\end_layout
-
-\begin_layout Standard
-\begin_inset ERT
-status open
-
-\begin_layout Standard
-
-
-\backslash
-codelist{skel/wallis_pi_skel.py}
-\end_layout
-
-\end_inset
-
-
-\end_layout
-
-\begin_layout Section
-Trapezoid rule
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-Illustrates
-\series default
-: basic array slicing, functions as first class objects.
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-Task
-\series default
-: define a trapezoid rule integrator:
-\begin_inset Formula \[
-I=\int_{a}^{b}f(x)dx\approx\frac{1}{2}\sum_{i=1}^{N}(x_{i}-x_{i-1})(y_{i}+y_{i-1})\]
-
-\end_inset
-
-where
-\begin_inset Formula $y_{i}=f(x_{i})$
-\end_inset
-
-,
-\begin_inset Formula $x_{o}=a$
-\end_inset
-
-,
-\begin_inset Formula $x_{N}=b$
-\end_inset
-
-.
-
-\end_layout
-
-\begin_layout Standard
-Consider both the case where the input is given as a pair of arrays
-\begin_inset Formula $(x,y)$
-\end_inset
-
- and where the input is
-\begin_inset Formula $(f,a,b,N)$
-\end_inset
-
-.
- Write two separate functions.
-\end_layout
-
-\begin_layout Subsubsection*
-Code skeleton
-\end_layout
-
-\begin_layout Standard
-\begin_inset ERT
-status open
-
-\begin_layout Standard
-
-
-\backslash
-codelist{skel/trapezoid_skel.py}
-\end_layout
-
-\end_inset
-
-
-\end_layout
-
-\begin_layout Section
-Numerical integration and root finding
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-Illustrates:
-\series default
- functions as first class objects, use of the scipy libraries.
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-Task:
-\series default
- Find
-\begin_inset Formula $t$
-\end_inset
-
- such that
-\begin_inset Formula \[
-\int_{0}^{t}f(s)\, ds=u\]
-
-\end_inset
-
-for a known, monotonically increasing
-\begin_inset Formula $f(s)$
-\end_inset
-
- and a fixed
-\begin_inset Formula $u$
-\end_inset
-
-.
- The example below uses
-\begin_inset Formula $f(s)=s\cdot\sin^{2}(s)$
-\end_inset
-
- and
-\begin_inset Formula $u=1/4.$
-\end_inset
-
-
-\end_layout
-
-\begin_layout Subsubsection*
-Code skeleton
-\end_layout
-
-\begin_layout Standard
-\begin_inset ERT
-status open
-
-\begin_layout Standard
-
-
-\backslash
-codelist{skel/quad_newton_skel.py}
-\end_layout
-
-\end_inset
-
-
-\end_layout
-
-\begin_layout Section
-Wrapping Fortran codes
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-Illustrates
-\series default
-: wrapping existing Fortran libraries, improving the call interface of Fortran
- codes.
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-Task
-\series default
-: write a Fortran subroutine
-\family typewriter
-cumsum(x,y,n)
-\family default
- that computes the cumulative sums of entries of
-\begin_inset Formula $x$
-\end_inset
-
- and stores them in
-\begin_inset Formula $y$
-\end_inset
-
-:
-\begin_inset Formula \[
-y_{j}=\sum_{i=1}^{j}x_{i},\; j=1,\ldots,n.\]
-
-\end_inset
-
-
-\end_layout
-
-\begin_layout Subsubsection*
-Code skeleton
-\end_layout
-
-\begin_layout Standard
-The following skeleton contains a wrapper of another Fortran routine, a
- simple Fibonacci number calculation, to illustrate the f2py syntax.
- A Makefile and a test file are included as well.
-\end_layout
-
-\begin_layout Standard
-\begin_inset ERT
-status open
-
-\begin_layout Standard
-
-
-\backslash
-codelist{skel/fortran_wrap/fib3.f}
-\end_layout
-
-\end_inset
-
-
-\end_layout
-
-\begin_layout Section
-Univariate polynomials, root finding
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-Illustrates
-\series default
-: poly1d objects, convolutions, plotting.
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-Task
-\series default
-:
-\end_layout
-
-\begin_layout Subsubsection*
-Code skeletonq
-\end_layout
-
-\begin_layout Standard
-\begin_inset ERT
-status open
-
-\begin_layout Standard
-
-
-\backslash
-codelist{skel/polyroots1d_skel.py}
-\end_layout
-
-\end_inset
-
-
-\end_layout
-
-\begin_layout Section
-Image processing and the FFT
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-Illustrates
-\series default
-: 2-d image denoising, use of the scipy FFT library, array manipulations,
- image plotting.
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-Task
-\series default
-:
-\end_layout
-
-\begin_layout Subsubsection*
-Code skeleton
-\end_layout
-
-\begin_layout Standard
-\begin_inset ERT
-status open
-
-\begin_layout Standard
-
-
-\backslash
-codelist{skel/fft_imdenoise_skel.py}
-\end_layout
-
-\end_inset
-
-
-\end_layout
-
-\begin_layout Section
-Bessel functions
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-Illustrates
-\series default
-: Special functions library, array manipulations to check recursion relation.
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-Task
-\series default
-:
-\end_layout
-
-\begin_layout Subsection*
-Code skeleton
-\end_layout
-
-\begin_layout Standard
-MISSING
-\end_layout
-
-\begin_layout Section
-Monte Carlo integration
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-Illustrates
-\series default
-: random number generation.
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-Task
-\series default
-: compute an approximation to
-\begin_inset Formula $\pi$
-\end_inset
-
- via Monte Carlo integration.
-\end_layout
-
-\begin_layout Subsection*
-Code skeleton
-\end_layout
-
-\begin_layout Standard
-MISSING
-\end_layout
-
-\begin_layout Section
-Speed optimizations using
-\family typewriter
-weave
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-Illustrates
-\series default
-: weave.blitz, weave.inline.
-\end_layout
-
-\begin_layout Standard
-
-\series bold
-Task
-\series default
-: ...
-\end_layout
-
-\begin_layout Subsection*
-Code skeleton
-\end_layout
-
-\begin_layout Standard
-MISSING
-\end_layout
-
-\end_body
-\end_document
Deleted: trunk/py4science/doc/workbook.pdf
===================================================================
--- trunk/py4science/doc/workbook.pdf 2008-10-19 08:37:47 UTC (rev 6272)
+++ trunk/py4science/doc/workbook.pdf 2008-10-19 09:01:48 UTC (rev 6273)
@@ -1,20267 +0,0 @@
-%PDF-1.4
-5 0 obj
-<< /S /GoTo /D (chapter.1) >>
-endobj
-8 0 obj
-(Chapter 1. Introduction)
-endobj
-9 0 obj
-<< /S /GoTo /D (chapter.2) >>
-endobj
-12 0 obj
-(Chapter 2. Simple non-numerical problems)
-endobj
-13 0 obj
-<< /S /GoTo /D (section.2.1) >>
-endobj
-16 0 obj
-(1. Sorting quickly with QuickSort )
-endobj
-17 0 obj
-<< /S /GoTo /D (section.2.2) >>
-endobj
-20 0 obj
-(2. Dictionaries for counting words)
-endobj
-21 0 obj
-<< /S /GoTo /D (chapter.3) >>
-endobj
-24 0 obj
-(Chapter 3. Working with files, the internet, and numpy arrays)
-endobj
-25 0 obj
-<< /S /GoTo /D (section.3.1) >>
-endobj
-28 0 obj
-(1. Loading and saving ASCII data)
-endobj
-29 0 obj
-<< /S /GoTo /D (section.3.2) >>
-endobj
-32 0 obj
-(2. Working with CSV files)
-endobj
-33 0 obj
-<< /S /GoTo /D (section.3.3) >>
-endobj
-36 0 obj
-(3. Loading and saving binary data)
-endobj
-37 0 obj
-<< /S /GoTo /D (chapter.4) >>
-endobj
-40 0 obj
-(Chapter 4. Elementary Numerics)
-endobj
-41 0 obj
-<< /S /GoTo /D (section.4.1) >>
-endobj
-44 0 obj
-(1. Wallis' slow road to )
-endobj
-45 0 obj
-<< /S /GoTo /D (section.4.2) >>
-endobj
-48 0 obj
-(2. Trapezoidal rule)
-endobj
-49 0 obj
-<< /S /GoTo /D (section.4.3) >>
-endobj
-52 0 obj
-(3. Newton's method)
-endobj
-53 0 obj
-<< /S /GoTo /D (chapter.5) >>
-endobj
-56 0 obj
-(Chapter 5. Linear algebra)
-endobj
-57 0 obj
-<< /S /GoTo /D (section.5.1) >>
-endobj
-60 0 obj
-(1. Glass Moir\351 Patterns)
-endobj
-61 0 obj
-<< /S /GoTo /D (chapter.6) >>
-endobj
-64 0 obj
-(Chapter 6. Signal processing)
-endobj
-65 0 obj
-<< /S /GoTo /D (section.6.1) >>
-endobj
-68 0 obj
-(1. Convolution)
-endobj
-69 0 obj
-<< /S /GoTo /D (section.6.2) >>
-endobj
-72 0 obj
-(2. FFT Image Denoising)
-endobj
-73 0 obj
-<< /S /GoTo /D (chapter.7) >>
-endobj
-76 0 obj
-(Chapter 7. Statistics)
-endobj
-77 0 obj
-<< /S /GoTo /D (section.7.1) >>
-endobj
-80 0 obj
-(1. Descriptive statistics)
-endobj
-81 0 obj
-<< /S /GoTo /D (section.7.2) >>
-endobj
-84 0 obj
-(2. Statistical distributions)
-endobj
-85 0 obj
-<< /S /GoTo /D [86 0 R /Fit ] >>
-endobj
-88 0 obj <<
-/Length 321
-/Filter /FlateDecode
->>
-stream
-xڍQ;O\xC30\xDE\xF3+<\xDAC\x9F_\x8F\xBC
-\xEAT\xA9\x91(CHB\x95:(jU\xC1\xAF\xC7NhU$dɖ}\xDF\xE3>22\xAF\xC1I\xA9i
-\xDE\xB1z\x97I\xB6\x8E\xB5\x870F \xEF]\xBC\xFCQ\xCD-\xA0\xBD/X~)rSfW3m\xD0\xC6)V\xBE1%%(\xEB
-\xE6PC\xA1#\xA3l\x9E\xF9b\xA8\xEA}WW\xEF"\xF8\xB2\xEE\xDA \xB4\xE4{\x81\xBC9\xF2\x95ԦNE\xC7o\xFB]z\xF98\x9C\x8Ba-^\xCA9#\x85hY\xAEPI\x95\xBB0I.>2Q6}\xE1\xB9R愞\xFA\xB8\x9E\xC0O\xC2+\xDE\xDB\xD7xE\xDE\xC7]\xF2~\x9BX1\x8E\xB9\x8C\x93+ "\x9Bb\x83&r\xA3ʼ\xDF$W$~\xE9,\xF8c\xF4=\xA1߷\xC3\xE4\x8E`1~\xC3/\xFB\x99 \xCF\xDB!T\xA1\xE9'\x81\x85P\xC4W\xDA\xE2\xD0~\x8D<\xAE\xB0\xB1k\xE3\xC18RSס\xDA\xE3DX\x8A\x942F\xAAD=&Rv_\x9E'u\x9A\xB55 \xFFߣ\xFEko~\x9Bendstream
-endobj
-86 0 obj <<
-/Type /Page
-/Contents 88 0 R
-/Resources 87 0 R
-/MediaBox [0 0 612 792]
-/Parent 97 0 R
->> endobj
-89 0 obj <<
-/D [86 0 R /XYZ 93.6002 733.9477 null]
->> endobj
-90 0 obj <<
-/D [86 0 R /XYZ 93.6002 720 null]
->> endobj
-87 0 obj <<
-/Font << /F35 93 0 R /F34 96 0 R >>
-/ProcSet [ /PDF /Text ]
->> endobj
-100 0 obj <<
-/Length 92
-/Filter /FlateDecode
->>
-stream
-xڍ\x8D1\x800\xF7\xBE"h7iӼ\x80\x87t`\xE2\xFF+Ab@\x82y\xB1\xE5\x93
-\x92(\x94\x87H#W\xE50wZGڳ\xDB
-nƚ\xB1G\x8Cmmp։\xCB\xE5Ğԛg\xC3\xECTG\xEF.\xF8y;"5endstream
-endobj
-99 0 obj <<
-/Type /Page
-/Contents 100 0 R
-/Resources 98 0 R
-/MediaBox [0 0 612 792]
-/Parent 97 0 R
->> endobj
-101 0 obj <<
-/D [99 0 R /XYZ 93.6002 733.9477 null]
->> endobj
-98 0 obj <<
-/ProcSet [ /PDF ]
->> endobj
-104 0 obj <<
-/Length 1520
-/Filter /FlateDecode
->>
-stream
-xڝY\xDBn\xDC6}\xF7W\xE8-Z\xA0\xCB\xF2N\xC0E\xB4\xB5\xD1>4}\x90w7k!{q\xB5r\x8C\xF4\xEB;\xA4Hi\xB4\xBA\xA1\x82\x81ؒ\xA93Gg\x86C\x86%~Xbє\xF2\xC4A\xAC4&\xD9oh\xB2\x87gnX\xC0H.\x89\xB1V\xC3\xC5\xC0ӵb\xD6f\xC9O\xF2\xE3\xC3\xCD\xF7\xEF\x85J\x98$Bj\x9E<|N\xB8Q\x84Y\x93%ZP"\x84\xBB\xB9\xFD+}{>\xADM\xABKw\xCD_\x97\xD5\xDF?ݼ{h\xDEy*\xAB\x89Ԃ\xBBWO w\xFFP\x96\x94\xFB\xA4{\xE3w\xC41_\xE3\xF1\x9E"S\x89%Vs\xED\xF6\xDE\xE2 >\xE5ϫ5K\xAB]\xB9Z!RFVkkmzwZq\x93V%\xF0=\xAF\xD6<K\xB7/\xB7\xA9
-w\xE7t\xA7fg\xDDzj6\xA8\xAA\x8A "A\xCD.W5\xAA\x9B\xD1D\x89l\xB1l\xED\xF0 \xD5hP4D\xBBww\x9D@G\xFF\xFC\xE0>\xBBC\xC8\xF4\x92\xC1\x9D\xB5W\xF5\xE5\xB8sN\xDBb\x93\xEA9\x9E\xCB\xF3\xE3awtz\xE1\x99!L |
|
From: <fer...@us...> - 2008-10-19 08:35:19
|
Revision: 6271
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6271&view=rev
Author: fer_perez
Date: 2008-10-19 08:30:58 +0000 (Sun, 19 Oct 2008)
Log Message:
-----------
Update more examples. Also removed some figures that can be
auto-generated and don't need to clutter the repo.
Added Paths:
-----------
trunk/py4science/examples/iterators.py
trunk/py4science/examples/iterators_example.py
trunk/py4science/examples/numpy_wrap/f2py/example3/test_example.py
trunk/py4science/examples/numpy_wrap/f2py/example3/test_fib.py
trunk/py4science/examples/numpytemps.py
trunk/py4science/examples/recarray/
trunk/py4science/examples/recarray/recarr_simple.py
trunk/py4science/examples/recarray/recarr_simple_data.txt
trunk/py4science/examples/soln/
trunk/py4science/examples/txt_data_load.py
trunk/py4science/examples/txt_data_sample.txt
Removed Paths:
-------------
trunk/py4science/examples/numpy-blitz_1000.png
trunk/py4science/examples/numpy-blitz_300.png
trunk/py4science/examples/numpy-blitz_500.png
trunk/py4science/examples/weave_blitz_comp.png
Added: trunk/py4science/examples/iterators.py
===================================================================
--- trunk/py4science/examples/iterators.py (rev 0)
+++ trunk/py4science/examples/iterators.py 2008-10-19 08:30:58 UTC (rev 6271)
@@ -0,0 +1,82 @@
+import numpy as np
+from scipy.weave import inline
+from numpy.testing import assert_array_almost_equal, assert_almost_equal
+
+def prodsum(a, b, axis=None):
+ assert a.shape == b.shape, "cannot take prodsum of different size arrays"
+ nd = len(a.shape)
+ if axis is not None:
+ caxis = axis if axis >=0 else nd + axis
+ assert caxis < nd, "cannot perform operation in this axis: %d"%axis
+ dims = list(a.shape)
+ dims.pop(axis)
+ c = np.zeros(tuple(dims), np.float64)
+ else:
+ caxis = -1
+ c = np.array([0.0])
+
+ xtra = \
+"""
+double prodsum(double *d1, double *d2, int stride, int size)
+{
+ double sum = 0.0;
+
+ while(size--) {
+ sum += (*d1) * (*d2);
+ d1 += stride;
+ d2 += stride;
+ }
+ return sum;
+}
+"""
+
+ code = \
+"""
+double *d1, *d2, *d3;
+int sumall = caxis < 0 ? 1 : 0;
+PyArrayIterObject *itr1, *itr2, *itr3;
+
+itr1 = (PyArrayIterObject *) PyArray_IterAllButAxis(py_a, &caxis);
+itr2 = (PyArrayIterObject *) PyArray_IterAllButAxis(py_b, &caxis);
+if (!sumall) itr3 = (PyArrayIterObject *) PyArray_IterNew(py_c);
+
+//...... more definitions here
+
+// make use of auto defined arrays, be careful to use "axis" AFTER
+// creating iterators, in case it gets chosen for you
+int stride = Sa[caxis]/sizeof(double);
+int size = Na[caxis];
+while( PyArray_ITER_NOTDONE(itr1) ) {
+
+ //...... iter loop here
+ d1 = (double *) itr1->dataptr;
+ d2 = (double *) itr2->dataptr;
+ if(sumall) {
+ d3 = c;
+ } else {
+ d3 = (double *) itr3->dataptr;
+ PyArray_ITER_NEXT(itr3);
+ }
+ *d3 += prodsum(d1, d2, stride, size);
+ PyArray_ITER_NEXT(itr1);
+ PyArray_ITER_NEXT(itr2);
+}
+"""
+ inline(code, ['a', 'b', 'c', 'caxis'], compiler='gcc',
+ support_code=xtra)
+ return c[0] if axis is None else c
+
+
+def tests():
+ a = np.random.rand(4,2,9)
+ b = np.ones_like(a)
+
+ assert_almost_equal(prodsum(a,b), a.sum())
+ assert_array_almost_equal(prodsum(a,b,axis=-1), a.sum(axis=-1))
+ assert_array_almost_equal(prodsum(a[:2,:,1::2], b[:2,:,1::2], axis=0),
+ a[:2,:,1::2].sum(axis=0))
+ assert_array_almost_equal(prodsum(a[:,:,::-1], b[:,:,::-1], axis=-1),
+ a[:,:,::-1].sum(axis=-1))
+
+if __name__ == '__main__':
+ tests()
Added: trunk/py4science/examples/iterators_example.py
===================================================================
--- trunk/py4science/examples/iterators_example.py (rev 0)
+++ trunk/py4science/examples/iterators_example.py 2008-10-19 08:30:58 UTC (rev 6271)
@@ -0,0 +1,229 @@
+#!/usr/bin/env python
+"""Blitz conversion is terrific, but sometimes you don't have fixed array sizes
+in your problem. Fortunately numpy iterators still make writing inline weave
+code very, very simple."""
+
+import sys
+
+import numpy as np
+from numpy.testing.utils import jiffies
+
+from matplotlib import pyplot as plt
+
+from scipy.weave import inline, converters, blitz
+
+# A little timing utility taken from the old scipy.testing
+def measure(code_str,times=1):
+ """ Return elapsed time for executing code_str in the
+ namespace of the caller for given times.
+ """
+ frame = sys._getframe(1)
+ locs,globs = frame.f_locals,frame.f_globals
+ code = compile(code_str,'<Timing code>','exec')
+ i = 0
+ elapsed = jiffies()
+ while i<times:
+ i += 1
+ exec code in globs,locs
+ elapsed = jiffies() - elapsed
+ return 0.01*elapsed
+
+
+def multi_iter_example():
+ # This is a very simple example of multi dimensional iterators, and
+ # their power to "broadcast" arrays of compatible shapes. It shows that
+ # the very same code that is entirely ignorant of dimensionality can
+ # achieve completely different computations based on the rules of
+ # broadcasting.
+
+ # it is important to know that the weave array conversion of "a"
+ # gives you access in C++ to:
+ # py_a -- PyObject *
+ # a_array -- PyArrayObject *
+ # a -- py_array->data cast to the proper data type
+
+ a = np.ones((4,4), np.float64)
+ # for the sake of driving home the "dynamic code" approach...
+ dtype2ctype = {
+ np.dtype(np.float64): 'double',
+ np.dtype(np.float32): 'float',
+ np.dtype(np.int32): 'int',
+ np.dtype(np.int16): 'short',
+ }
+ dt = dtype2ctype.get(a.dtype)
+
+ # this code does a = a*b inplace, broadcasting b to fit the shape of a
+ code = \
+"""
+%s *p1, *p2;
+PyObject *itr;
+itr = PyArray_MultiIterNew(2, a_array, b_array);
+while(PyArray_MultiIter_NOTDONE(itr)) {
+ p1 = (%s *) PyArray_MultiIter_DATA(itr, 0);
+ p2 = (%s *) PyArray_MultiIter_DATA(itr, 1);
+ *p1 = (*p1) * (*p2);
+ PyArray_MultiIter_NEXT(itr);
+}
+""" % (dt, dt, dt)
+
+ b = np.arange(4, dtype=a.dtype)
+ print '\n A B '
+ print a, b
+ # this reshaping is redundant, it would be the default broadcast
+ b.shape = (1,4)
+ inline(code, ['a', 'b'])
+ print "\ninline version of a*b,"
+ print a
+ a = np.ones((4,4), np.float64)
+ b.shape = (4,1)
+ inline(code, ['a', 'b'])
+ print "\ninline version of a*b[:,None],"
+ print a
+
+def data_casting_test():
+ # In my MR application, raw data is stored as a file with one or more
+ # (block-hdr, block-data) pairs. Block data is one or more
+ # rows of Npt complex samples in big-endian integer pairs (real, imag).
+ #
+ # At the block level, I encounter three different raw data layouts--
+ # 1) one plane, or slice: Y rows by 2*Npt samples
+ # 2) one volume: Z slices * Y rows by 2*Npt samples
+ # 3) one row sliced across the z-axis: Z slices by 2*Npt samples
+ #
+ # The task is to tease out one volume at a time from any given layout,
+ # and cast the integer precision data into a complex64 array.
+ # Given that contiguity is not guaranteed, and the number of dimensions
+ # can vary, Numpy iterators are useful to provide a single code that can
+ # carry out the conversion.
+ #
+ # Other solutions include:
+ # 1) working entirely with the string data from file.read() with string
+ # manipulations (simulated below).
+ # 2) letting numpy handle automatic byteorder/dtype conversion
+
+ nsl, nline, npt = (20,64,64)
+ hdr_dt = np.dtype('>V28')
+ # example 1: a block is one slice of complex samples in short integer pairs
+ blk_dt1 = np.dtype(('>i2', nline*npt*2))
+ dat_dt = np.dtype({'names': ['hdr', 'data'], 'formats': [hdr_dt, blk_dt1]})
+ # create an empty volume-- nsl contiguous blocks
+ vol = np.empty((nsl,), dat_dt)
+ t = time_casting(vol[:]['data'])
+ plt.plot(100*t/t.max(), 'b--', label='vol=20 contiguous blocks')
+ plt.plot(100*t/t.max(), 'bo')
+ # example 2: a block is one entire volume
+ blk_dt2 = np.dtype(('>i2', nsl*nline*npt*2))
+ dat_dt = np.dtype({'names': ['hdr', 'data'], 'formats': [hdr_dt, blk_dt2]})
+ # create an empty volume-- 1 block
+ vol = np.empty((1,), dat_dt)
+ t = time_casting(vol[0]['data'])
+ plt.plot(100*t/t.max(), 'g--', label='vol=1 contiguous block')
+ plt.plot(100*t/t.max(), 'go')
+ # example 3: a block slices across the z dimension, long integer precision
+ # ALSO--a given volume is sliced discontiguously
+ blk_dt3 = np.dtype(('>i4', nsl*npt*2))
+ dat_dt = np.dtype({'names': ['hdr', 'data'], 'formats': [hdr_dt, blk_dt3]})
+ # a real data set has volumes interleaved, so create two volumes here
+ vols = np.empty((2*nline,), dat_dt)
+ # and work on casting the first volume
+ t = time_casting(vols[0::2]['data'])
+ plt.plot(100*t/t.max(), 'r--', label='vol=64 discontiguous blocks')
+ plt.plot(100*t/t.max(), 'ro')
+ plt.xticks([0,1,2], ('strings', 'numpy auto', 'inline'))
+ plt.gca().set_xlim((-0.25, 2.25))
+ plt.gca().set_ylim((0, 110))
+ plt.gca().set_ylabel(r"% of slowest time")
+ plt.legend(loc=8)
+ plt.title('Casting raw file data to an MR volume')
+ plt.show()
+
+
+def time_casting(int_data):
+ nblk = 1 if len(int_data.shape) < 2 else int_data.shape[0]
+ bias = (np.random.rand(nblk) + \
+ 1j*np.random.rand(nblk)).astype(np.complex64)
+ dstr = int_data.tostring()
+ dt = np.int16 if int_data.dtype.itemsize == 2 else np.int32
+ fshape = list(int_data.shape)
+ fshape[-1] = fshape[-1]/2
+ float_data = np.empty(fshape, np.complex64)
+ # method 1: string conversion
+ float_data.shape = (np.product(fshape),)
+ tstr = measure("float_data[:] = complex_fromstring(dstr, dt)", times=25)
+ float_data.shape = fshape
+ print "to-/from- string: ", tstr, "shape=",float_data.shape
+
+ # method 2: numpy dtype magic
+ sl = [None, slice(None)] if len(fshape)<2 else [slice(None)]*len(fshape)
+ # need to loop since int_data need not be contiguous
+ tnpy = measure("""
+for fline, iline, b in zip(float_data[sl], int_data[sl], bias):
+ cast_to_complex_npy(fline, iline, bias=b)""", times=25)
+ print"numpy automagic: ", tnpy
+
+ # method 3: plain inline brute force!
+ twv = measure("cast_to_complex(float_data, int_data, bias=bias)",
+ times=25)
+ print"inline casting: ", twv
+ return np.array([tstr, tnpy, twv], np.float64)
+
+def complex_fromstring(data, numtype):
+ if sys.byteorder == "little":
+ return np.fromstring(
+ np.fromstring(data,numtype).byteswap().astype(np.float32).tostring(),
+ np.complex64)
+ else:
+ return np.fromstring(
+ np.fromstring(data,numtype).astype(np.float32).tostring(),
+ np.complex64)
+
+def cast_to_complex(cplx_float, cplx_integer, bias=None):
+ if cplx_integer.dtype.itemsize == 4:
+ replacements = tuple(["l", "long", "SWAPLONG", "l"]*2)
+ else:
+ replacements = tuple(["s", "short", "SWAPSHORT", "s"]*2)
+ if sys.byteorder == "big":
+ replacements[-2] = replacements[-6] = "NOP"
+
+ cast_code = """
+ #define SWAPSHORT(x) ((short) ((x >> 8) | (x << 8)) )
+ #define SWAPLONG(x) ((long) ((x >> 24) | (x << 24) | ((x & 0x00ff0000) >> 8) | ((x & 0x0000ff00) << 8)) )
+ #define NOP(x) x
+
+ unsigned short *s;
+ unsigned long *l;
+ float repart, impart;
+ PyObject *itr;
+ itr = PyArray_IterNew(py_cplx_integer);
+ while(PyArray_ITER_NOTDONE(itr)) {
+
+ // get real part
+ %s = (unsigned %s *) PyArray_ITER_DATA(itr);
+ repart = %s(*%s);
+ PyArray_ITER_NEXT(itr);
+ // get imag part
+ %s = (unsigned %s *) PyArray_ITER_DATA(itr);
+ impart = %s(*%s);
+ PyArray_ITER_NEXT(itr);
+ *(cplx_float++) = std::complex<float>(repart, impart);
+
+ }
+ """ % replacements
+
+ inline(cast_code, ['cplx_float', 'cplx_integer'])
+ if bias is not None:
+ if len(cplx_float.shape) > 1:
+ bsl = [slice(None)]*(len(cplx_float.shape)-1) + [None]
+ else:
+ bsl = slice(None)
+ np.subtract(cplx_float, bias[bsl], cplx_float)
+
+def cast_to_complex_npy(cplx_float, cplx_integer, bias=None):
+ cplx_float.real[:] = cplx_integer[0::2]
+ cplx_float.imag[:] = cplx_integer[1::2]
+ if bias is not None:
+ np.subtract(cplx_float, bias, cplx_float)
+
+if __name__=="__main__":
+ data_casting_test()
+ multi_iter_example()
Property changes on: trunk/py4science/examples/iterators_example.py
___________________________________________________________________
Added: svn:executable
+ *
Deleted: trunk/py4science/examples/numpy-blitz_1000.png
===================================================================
(Binary files differ)
Deleted: trunk/py4science/examples/numpy-blitz_300.png
===================================================================
(Binary files differ)
Deleted: trunk/py4science/examples/numpy-blitz_500.png
===================================================================
(Binary files differ)
Added: trunk/py4science/examples/numpy_wrap/f2py/example3/test_example.py
===================================================================
--- trunk/py4science/examples/numpy_wrap/f2py/example3/test_example.py (rev 0)
+++ trunk/py4science/examples/numpy_wrap/f2py/example3/test_example.py 2008-10-19 08:30:58 UTC (rev 6271)
@@ -0,0 +1,9 @@
+import example
+import numpy
+
+x = numpy.arange(10.)
+
+yf = example.cumsum(x)
+yn = numpy.cumsum(x)
+
+numpy.testing.assert_array_almost_equal(yf, yn)
Added: trunk/py4science/examples/numpy_wrap/f2py/example3/test_fib.py
===================================================================
--- trunk/py4science/examples/numpy_wrap/f2py/example3/test_fib.py (rev 0)
+++ trunk/py4science/examples/numpy_wrap/f2py/example3/test_fib.py 2008-10-19 08:30:58 UTC (rev 6271)
@@ -0,0 +1,13 @@
+import numpy as N
+
+import example
+
+n = 10
+fn = example.fib(n)
+
+print 'Fibonacci numbers:'
+print fn
+
+# Check validity
+assert N.alltrue(fn[2:]== fn[1:-1]+fn[:-2]), "Fibonacci mismatch"
+
Added: trunk/py4science/examples/numpytemps.py
===================================================================
--- trunk/py4science/examples/numpytemps.py (rev 0)
+++ trunk/py4science/examples/numpytemps.py 2008-10-19 08:30:58 UTC (rev 6271)
@@ -0,0 +1,85 @@
+#!/usr/bin/env python
+"""Demonstration of temporaries in Numpy.
+"""
+
+import numpy as np
+import numpy.testing as nptest
+
+import nose
+
+# convenience global names
+from numpy import (pi, sin, cos, add, subtract, multiply, power)
+
+def test1():
+ """Verify an expression using temporaries.
+ """
+ x = np.linspace(0,2*pi,100)
+
+ # We compute a simple mathematical expression using algebra and functions
+ # of x. This uses a lot of temporaries that are implicitly created. In
+ # total, the variable count is:
+ # sin(x): 1
+ # sin(2*x): 2
+ # 4.5*cos(3*x**2): 4
+ # The final temporaries for each term are added and the result stored as y,
+ # which is also created. So we have 1 array for the result and 7 temps.
+ y = sin(x) + sin(2*x) - 4.5*cos(3*x**2)
+
+ # Now we do it again, but here, we control the temporary creation
+ # ourselves. We use the output argument of all numpy functional forms of
+ # the operators.
+
+ # Initialize the array that will hold the output, empty
+ z = np.empty_like(x)
+ # This version in total uses 1 array for the result and one temporary.
+ tmp = np.empty_like(x)
+
+ # Now, we compute each term of the expression above. Each time, we either
+ # store the output back into the temporary or we accumulate it in z.
+
+ # sin(x)
+ sin(x,z)
+
+ # + sin(2*x)
+ add(z,sin(multiply(2,x,tmp),tmp),z)
+
+ # - 4.5*cos(3*x**2)
+ power(x,2,tmp)
+ multiply(3,tmp,tmp)
+ cos(tmp,tmp)
+ multiply(4.5,tmp,tmp)
+ subtract(z,tmp,z)
+
+ # Verify that the two forms match to 13 digits
+ nptest.assert_almost_equal(y,z,13)
+
+
+def test2():
+ """Compute the same expression, using in-place operations
+ """
+ x = np.linspace(0,2*pi,100)
+
+ y = sin(x) + sin(2*x) - 4.5*cos(3*x**2)
+
+ # This version of the code uses more in-place operators, which make it a
+ # bit more readable and still avoid temporaries
+ tmp = np.empty_like(x)
+
+ # sin(x)
+ z = sin(x)
+
+ # + sin(2*x)
+ z += sin(multiply(2,x,tmp),tmp)
+
+ # - 4.5*cos(3*x**2)
+ power(x,2,tmp)
+ tmp *= 3
+ cos(tmp,tmp)
+ tmp *= 4.5
+ z -= tmp
+
+ # Verify that the two forms match to 13 digits
+ nptest.assert_almost_equal(y,z,13)
+
+if __name__ == '__main__':
+ nose.runmodule(exit=False)
Property changes on: trunk/py4science/examples/numpytemps.py
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/py4science/examples/recarray/recarr_simple.py
===================================================================
--- trunk/py4science/examples/recarray/recarr_simple.py (rev 0)
+++ trunk/py4science/examples/recarray/recarr_simple.py 2008-10-19 08:30:58 UTC (rev 6271)
@@ -0,0 +1,43 @@
+"""Utility module to load measurements into Numpy record arrays.
+
+Loading measurement files with the format:
+
+#Station Lat Long Elev
+BIRA 26.4840 87.2670 0.0120
+BUNG 27.8771 85.8909 1.1910
+etc...
+"""
+
+import numpy as np
+import pylab as plt
+
+# Simple example of usage
+
+# Data descriptor to make a proper array.
+dt = [('station','S4'),('lat',np.float32),('lon',np.float32),
+ ('elev',np.float32)]
+# This is an alternate and fully equivalent form:
+dt = dict(names = ('station','lat','lon','elev'),
+ formats = ('S4',np.float32,np.float32,np.float32) )
+
+# For more on dtypes, see:
+# http://mentat.za.net/numpy/refguide/arrays.recarray.xhtml
+import math
+
+def tlog(s):
+ return np.float32(math.log(float(s)))
+
+tab = np.loadtxt('HIMNTstations2.txt',dt,
+ converters={1:tlog})
+
+print 'Stations:',tab['station']
+print 'Elevations:',tab['elev']
+print 'First station:',tab[0]
+print 'Mean latitude:',tab['lat'].mean()
+
+plt.figure()
+plt.scatter(tab['lat'],tab['lon'],30*tab['elev'],
+ c=tab['elev'],
+ cmap=plt.cm.bone,
+ )
+plt.show()
Added: trunk/py4science/examples/recarray/recarr_simple_data.txt
===================================================================
--- trunk/py4science/examples/recarray/recarr_simple_data.txt (rev 0)
+++ trunk/py4science/examples/recarray/recarr_simple_data.txt 2008-10-19 08:30:58 UTC (rev 6271)
@@ -0,0 +1,29 @@
+BIRA 26.4840 87.2670 0.0120
+BUNG 27.8771 85.8909 1.1910
+GAIG 26.8380 86.6318 0.1660
+HILE 27.0482 87.3242 2.0880
+ILAM 26.9102 87.9227 1.1810
+JIRI 27.6342 86.2303 1.8660
+NAMC 27.8027 86.7146 3.5230
+PHAP 27.5150 86.5842 2.4880
+PHID 27.1501 87.7645 1.1760
+RUMJ 27.3038 86.5482 1.3190
+SIND 27.2107 85.9088 0.4650
+THAK 27.5996 85.5566 1.5510
+TUML 27.3208 87.1950 0.3600
+LAZE 29.1403 87.5922 4.0110
+SAJA 28.9093 88.0209 4.3510
+ONRN 29.3020 87.2440 4.3500
+SSAN 29.4238 86.7290 4.5850
+SAGA 29.3292 85.2321 4.5240
+DINX 28.6646 87.1157 4.3740
+RBSH 28.1955 86.8280 5.1000
+NAIL 28.6597 86.4126 4.3780
+MNBU 28.7558 86.1610 4.5000
+NLMU 28.1548 85.9777 3.8890
+YALA 28.4043 86.1133 4.4340
+XIXI 28.7409 85.6904 4.6600
+RC14 29.4972 86.4373 4.7560
+MAZA 28.6713 87.8553 4.3670
+JANA 26.7106 85.9242 0.0770
+SUKT 27.7057 85.7611 0.7450
Added: trunk/py4science/examples/txt_data_load.py
===================================================================
--- trunk/py4science/examples/txt_data_load.py (rev 0)
+++ trunk/py4science/examples/txt_data_load.py 2008-10-19 08:30:58 UTC (rev 6271)
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+"""Read files from Maribeth's format into arrays."""
+
+# Needed modules from the standard library
+import re
+import sys
+
+# Third party modules
+import numpy as N
+
+# Code begins
+def mwread(fname):
+ """Read mw file and return dict with arrays.
+
+ The input data is assumed to be in a file whose format is:
+
+ r:
+ 0.250029, 0.249549, 0.25019, 0.250232
+
+ A:
+ 0.399973, 0.199979, 0.200005, 0.200014
+ 0.199992, 0.400235, 0.200033, 0.200102
+
+ B:
+ 0.428502, 0.142868, 0.142897, 0.142838
+ 0.142884, 0.57165, 0.143053, 0.285911
+
+ The output is a dict whose keys are the letter labels ('r','A','B', etc)
+ and whose values are one-dimensional NumPy arrays with the numbers, in
+ double precision.
+
+ :Parameters:
+ fname : string
+ Name of the input file."""
+
+ fobj = open(fname)
+
+ # Regular expression to match array labels
+ label_re = re.compile('^([a-zA-Z])+:')
+
+ # Initialize output dict
+ dct = {}
+ # Start the state machine in 'scan' mode and switch to data reading mode
+ # ('read') whenever we find what looks like a label.
+ mode = 'scan'
+ for line in fobj:
+ if mode == 'scan':
+ match = label_re.match(line)
+ if match:
+ # Switch modes
+ mode = 'read'
+ # Prepare state for read mode
+ name = match.group(1)
+ data = []
+ elif mode == 'read':
+ if line.isspace():
+ # Pure whitespace lines force a mode switch back to
+ # scanning for variables
+ mode = 'scan'
+ # Store the data that we'd been accumulating for the
+ # current array
+ dct[name] = N.array(data,float)
+ else:
+ # Read data, assume line contains comma-separated strings
+ # of numbers
+ data.extend([float(n) for n in line.split(',')])
+
+ # Cleanup before exiting
+ fobj.close()
+
+ return dct
+
+
+# If run as a script
+if __name__ == '__main__':
+ # This allows calling it from the command line with the name of the file to
+ # read as an argument
+ try:
+ fname = sys.argv[1]
+ except IndexError:
+ print 'First argument must be filename to read'
+ sys.exit(1)
+
+ data = mwread(fname)
+ print 'Data dict:'
+ for k,val in data.iteritems():
+ print '%s:' % k
+ print val
+ print
+
+ # Now, load the names from the data dict as top-level variables (use
+ # specially named counters just in case the file declares something common
+ # like 'k'):
+ for _k,_val in data.iteritems():
+ exec '%s = _val' % _k
+
+ print "Now, you can use either the top-level dict 'data', or the variables:"
+ print data.keys()
Property changes on: trunk/py4science/examples/txt_data_load.py
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/py4science/examples/txt_data_sample.txt
===================================================================
--- trunk/py4science/examples/txt_data_sample.txt (rev 0)
+++ trunk/py4science/examples/txt_data_sample.txt 2008-10-19 08:30:58 UTC (rev 6271)
@@ -0,0 +1,21 @@
+r:
+ 0.250029, 0.249549, 0.25019, 0.250232
+
+A:
+ 0.399973, 0.199979, 0.200005, 0.200014
+ 0.199992, 0.400235, 0.200033, 0.200102
+ 0.2, 0.199919, 0.399979, 0.199954
+ 0.200035, 0.199867, 0.199984, 0.39993
+
+B:
+ 0.428502, 0.142868, 0.142897, 0.142838
+ 0.142884, 0.57165, 0.143053, 0.285911
+ 0.285747, 0.142757, 0.71391, 0.142854
+ 0.142867, 0.142725, 0.000140224, 0.428397
+
+C:
+ 0.666707, 0.166664, 0.166626, 0.16662
+ 0.166638, 0.500328, 0.166752, 0.166883
+ 0.166654, 0.166609, 0.333309, 0.166638
+1.49295e-07, 0.166399, 0.333314, 0.499859
+
Deleted: trunk/py4science/examples/weave_blitz_comp.png
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fer...@us...> - 2008-10-19 07:53:56
|
Revision: 6270
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6270&view=rev
Author: fer_perez
Date: 2008-10-19 07:53:47 +0000 (Sun, 19 Oct 2008)
Log Message:
-----------
Cleanup and updates to many examples.
Added new tool to create skeletons and solutions from a single source
script.
Modified Paths:
--------------
trunk/py4science/examples/bessel.py
trunk/py4science/examples/butter_filter.py
trunk/py4science/examples/fft_imdenoise.py
trunk/py4science/examples/filtilt_demo.py
trunk/py4science/examples/fitting.py
trunk/py4science/examples/montecarlo_pi.py
trunk/py4science/examples/qsort.py
trunk/py4science/examples/quad_newton.py
trunk/py4science/examples/recarray_demo.py
trunk/py4science/examples/trapezoid.py
Added Paths:
-----------
trunk/py4science/examples/mkskel.py
trunk/py4science/examples/skel/fortran_wrap/test_example.py
trunk/py4science/examples/skel/fortran_wrap/test_fib.py
Modified: trunk/py4science/examples/bessel.py
===================================================================
--- trunk/py4science/examples/bessel.py 2008-10-19 07:48:51 UTC (rev 6269)
+++ trunk/py4science/examples/bessel.py 2008-10-19 07:53:47 UTC (rev 6270)
@@ -1,45 +1,46 @@
#!/usr/bin/env python
"""Plot some Bessel functions of integer order, using Scipy and pylab"""
-import scipy.special
+from scipy import special
-import numpy as N
-import scipy as S
-import pylab as P
+import numpy as np
+import matplotlib.pyplot as plt
-# shorthand
-special = S.special
-
def jn_asym(n,x):
"""Asymptotic form of jn(x) for x>>n"""
+
+ #@ The asymptotic formula is:
+ #@ j_n(x) ~ sqrt(2.0/pi/x)*cos(x-(n*pi/2.0+pi/4.0))
- return S.sqrt(2.0/S.pi/x)*S.cos(x-(n*S.pi/2.0+S.pi/4.0))
+ return np.sqrt(2.0/np.pi/x)*np.cos(x-(n*np.pi/2.0+np.pi/4.0)) #@
# build a range of values to plot in
-x = N.linspace(0,30,400)
+x = np.linspace(0,30,400)
# Start by plotting the well-known j0 and j1
-P.figure()
-P.plot(x,special.j0(x),label='$J_0$')
-P.plot(x,special.j1(x),label='$J_1$')
+plt.figure()
+plt.plot(x,special.j0(x),label='$J_0$') #@
+plt.plot(x,special.j1(x),label='$J_1$') #@
# Show a higher-order Bessel function
n = 5
-P.plot(x,special.jn(n,x),label='$J_%s$' % n)
+plt.plot(x,special.jn(n,x),label='$J_%s$' % n)
# and compute its asymptotic form (valid for x>>n, where n is the order). We
-# must first find the valid range of x where at least x>n:
-x_asym = S.compress(x>n,x)
-P.plot(x_asym,jn_asym(n,x_asym),label='$J_%s$ (asymptotic)' % n)
+# must first find the valid range of x where at least x>n.
+#@ Find where x>n and evaluate the asymptotic relation only there
+x_asym = x[x>n] #@
+plt.plot(x_asym,jn_asym(n,x_asym),label='$J_%s$ (asymptotic)' % n) #@
# Finish off the plot
-P.legend()
-P.title('Bessel Functions')
+plt.legend()
+plt.title('Bessel Functions')
# horizontal line at 0 to show x-axis, but after the legend
-P.axhline(0)
+plt.axhline(0)
-# EXERCISE: redo the above, for the asymptotic range 0<x<<n. The asymptotic
-# form in this regime is
+# Extra credit: redo the above, for the asymptotic range 0<x<<n. The
+# asymptotic form in this regime is:
+#
# J(n,x) = (1/gamma(n+1))(x/2)^n
# Now, let's verify numerically the recursion relation
@@ -47,17 +48,25 @@
jn = special.jn # just a shorthand
# Be careful to check only for x!=0, to avoid divisions by zero
-xp = S.compress(x>0.0,x) # positive x
+#@ xp contains the positive values of x
+xp = x[x>0.0] #@
# construct both sides of the recursion relation, these should be equal
+#@ Define j_np1 to hold j_(n+1) evaluated at the points xp
j_np1 = jn(n+1,xp)
+#@ Define j_np1_rec to express j_(n+1) via a recursion relation, at points xp
j_np1_rec = (2.0*n/xp)*jn(n,xp)-jn(n-1,xp)
# Now make a nice error plot of the difference, in a new figure
-P.figure()
-P.semilogy(xp,abs(j_np1-j_np1_rec),'r+-')
-P.title('Error in recursion for $J_%s$' % n)
-P.grid()
+plt.figure()
+#@ We now plot the difference between the two formulas above. Note that to
+#@ properly display the errors, we want to use a logarithmic y scale. Search
+#@ the matplotlib docs for the proper calls.
+plt.semilogy(xp,abs(j_np1-j_np1_rec),'r+-') #@
+
+plt.title('Error in recursion for $J_%s$' % n)
+plt.grid()
+
# Don't forget a show() call at the end of the script
-P.show()
+plt.show()
Modified: trunk/py4science/examples/butter_filter.py
===================================================================
--- trunk/py4science/examples/butter_filter.py 2008-10-19 07:48:51 UTC (rev 6269)
+++ trunk/py4science/examples/butter_filter.py 2008-10-19 07:53:47 UTC (rev 6270)
@@ -1,13 +1,13 @@
-import numpy as n
+import numpy as np
import scipy.signal as signal
-from pylab import figure, show
+from matplotlib.pyplot import figure, show
dt = 0.01
-t = n.arange(0, 2, dt)
-s = n.sin(2*n.pi*t)
+t = np.arange(0, 2, dt)
+s = np.sin(2*np.pi*t)
# sine corrupted wih gaussian white noise
-sn = s + 0.1*n.random.randn(len(s)) # noisy sine
+sn = s + 0.1*np.random.randn(len(s)) # noisy sine
# the nyquist frequency 1/(2dt) is the maximum frequency in a sampled
# signal
Modified: trunk/py4science/examples/fft_imdenoise.py
===================================================================
--- trunk/py4science/examples/fft_imdenoise.py 2008-10-19 07:48:51 UTC (rev 6269)
+++ trunk/py4science/examples/fft_imdenoise.py 2008-10-19 07:53:47 UTC (rev 6270)
@@ -1,62 +1,86 @@
#!/usr/bin/env python
-"""Image denoising example using 2-dimensional FFT."""
+"""Simple image denoising example using 2-dimensional FFT."""
import sys
import numpy as np
from matplotlib import pyplot as plt
-def mag_phase(F):
- """Return magnitude and phase components of spectrum F."""
-
- return (np.absolute(F), np.angle(F))
-
def plot_spectrum(F, amplify=1000):
"""Normalise, amplify and plot an amplitude spectrum."""
- M, Phase = mag_phase(F)
- M *= amplify/M.max()
- M[M > 1] = 1
- print M.shape, M.dtype
- plt.imshow(M, plt.cm.Blues)
+ # Note: the problem here is that we have a spectrum whose histogram is
+ # *very* sharply peaked at small values. To get a meaningful display, a
+ # simple strategy to improve the display quality consists of simply
+ # amplifying the values in the array and then clipping.
+ # Compute the magnitude of the input F (call it mag). Then, rescale mag by
+ # amplify/maximum_of_mag. Numpy arrays can be scaled in-place with ARR *=
+ # number. For the max of an array, look for its max method.
+ mag = abs(F) #@
+ mag *= amplify/mag.max() #@
+
+ # Next, clip all values larger than one to one. You can set all elements
+ # of an array which satisfy a given condition with array indexing syntax:
+ # ARR[ARR<VALUE] = NEWVALUE, for example.
+ mag[mag > 1] = 1 #@
+ # Display: this one already works, if you did everything right with mag
+ plt.imshow(mag, plt.cm.Blues)
+
if __name__ == '__main__':
try:
# Read in original image, convert to floating point for further
# manipulation; imread returns a MxNx4 RGBA image. Since the image is
- # grayscale, just extrac the 1st channel
- im = plt.imread('data/moonlanding.png').astype(float)[:,:,0]
+ # grayscale, just extract the 1st channel
+ #@ Hints:
+ #@ - use plt.imread() to load the file
+ #@ - convert to a float array with the .astype() method
+ #@ - extract all rows, all columns, 0-th plane to get the first
+ #@ channel
+ #@ - the resulting array should have 2 dimensions only
+ im = plt.imread('data/moonlanding.png').astype(float)[:,:,0] #@
+ print "Image shape:",im.shape
except:
print "Could not open image."
sys.exit(-1)
# Compute the 2d FFT of the input image
- F = np.fft.fft2(im)
+ #@ Hint: Look for a 2-d FFT in np.fft.
+ #@ Note: call this variable 'F', which is the name we'll be using below.
+ F = np.fft.fft2(im) #@
- # Now, make a copy of the original spectrum and truncate coefficients.
+ # In the lines following, we'll make a copy of the original spectrum and
+ # truncate coefficients. NO immediate code is to be written right here.
+
+ # Define the fraction of coefficients (in each direction) we keep
keep_fraction = 0.1
# Call ff a copy of the original transform. Numpy arrays have a copy
# method for this purpose.
- ff = F.copy()
+ ff = F.copy() #@
- # Set r and c to be the number of rows and columns of the array.
- r,c = ff.shape
+ # Set r and c to be the number of rows and columns of the array.
+ #@ Hint: use the array's shape attribute.
+ r,c = ff.shape #@
# Set to zero all rows with indices between r*keep_fraction and
# r*(1-keep_fraction):
- ff[r*keep_fraction:r*(1-keep_fraction)] = 0
+ ff[r*keep_fraction:r*(1-keep_fraction)] = 0 #@
# Similarly with the columns:
- ff[:, c*keep_fraction:c*(1-keep_fraction)] = 0
+ ff[:, c*keep_fraction:c*(1-keep_fraction)] = 0 #@
# Reconstruct the denoised image from the filtered spectrum, keep only the
- # real part for display
- im_new = np.fft.ifft2(ff).real
-
+ # real part for display.
+ #@ Hint: There's an inverse 2d fft in the np.fft module as well (don't
+ #@ forget that you only want the real part).
+ #@ Call the result im_new,
+ im_new = np.fft.ifft2(ff).real #@
+
# Show the results
+ #@ The code below already works, if you did everything above right.
plt.figure()
plt.subplot(221)
@@ -75,9 +99,6 @@
plt.title('Reconstructed Image')
plt.imshow(im_new, plt.cm.gray)
- plt.savefig('fft_imdenoise.png', dpi=150)
- plt.savefig('fft_imdenoise.eps')
-
# Adjust the spacing between subplots for readability
plt.subplots_adjust(hspace=0.32)
plt.show()
Modified: trunk/py4science/examples/filtilt_demo.py
===================================================================
--- trunk/py4science/examples/filtilt_demo.py 2008-10-19 07:48:51 UTC (rev 6269)
+++ trunk/py4science/examples/filtilt_demo.py 2008-10-19 07:53:47 UTC (rev 6270)
@@ -7,10 +7,11 @@
order. The function also computes the initial filter parameters in
order to provide a more stable response (via lfilter_zi). The
following code has been tested with Python 2.4.4 and Scipy 0.5.1.
+"""
-"""
-from numpy import vstack, hstack, eye, ones, zeros, linalg, \
-newaxis, r_, flipud, convolve, matrix, array
+from numpy import (vstack, hstack, eye, ones, zeros, linalg,
+ newaxis, r_, flipud, convolve, matrix, array)
+
from scipy.signal import lfilter
def lfilter_zi(b,a):
@@ -38,19 +39,18 @@
return array(zi_return)
-
-
def filtfilt(b,a,x):
#For now only accepting 1d arrays
ntaps=max(len(a),len(b))
edge=ntaps*3
if x.ndim != 1:
- raise ValueError, "Filiflit is only accepting 1 dimension arrays."
+ raise ValueError("Filiflit is only accepting 1 dimension arrays.")
- #x must be bigger than edge
+ # x must be bigger than edge
if x.size < edge:
- raise ValueError, "Input vector needs to be bigger than 3 * max(len(a),len(b)."
+ e="Input vector needs to be bigger than 3 * max(len(a),len(b)."
+ raise ValueError(e)
if len(a) < ntaps:
a=r_[a,zeros(len(b)-len(a))]
Modified: trunk/py4science/examples/fitting.py
===================================================================
--- trunk/py4science/examples/fitting.py 2008-10-19 07:48:51 UTC (rev 6269)
+++ trunk/py4science/examples/fitting.py 2008-10-19 07:53:47 UTC (rev 6270)
@@ -7,10 +7,11 @@
from scipy.optimize import leastsq
from scipy.interpolate import splrep,splev
-import numpy as N
-import scipy as S
-import pylab as P
+import numpy as np
+import matplotlib as mpl
+import matplotlib.pyplot as plt
+
def func(pars):
a, alpha, k = pars
return a*exp(alpha*x_vals) + k
@@ -35,7 +36,7 @@
print 'Least-squares fit to the data'
print 'true', pars_true
print 'best', best
-print '|err|_l2 =',P.l2norm(pars_true-best)
+print '|err|_l2 =',np.linalg.norm(pars_true-best)
# scipy's splrep uses FITPACK's curfit (B-spline interpolation)
print
@@ -48,27 +49,27 @@
def plot_polyfit(x,y,n,fignum=None):
""" """
if fignum is None:
- fignum = P.figure().number
- P.plot(x,y,label='Data')
+ fignum = plt.figure().number
+ plt.plot(x,y,label='Data')
- fit_coefs = N.polyfit(x,y,n)
- fit_val = N.polyval(fit_coefs,x)
- P.plot(x,fit_val,label='Polynomial fit, $n=%d$' % n)
- P.legend()
+ fit_coefs = np.polyfit(x,y,n)
+ fit_val = np.polyval(fit_coefs,x)
+ plt.plot(x,fit_val,label='Polynomial fit, $n=%d$' % n)
+ plt.legend()
return fignum
# Now use pylab to plot
-P.figure()
-P.plot(x_vals,y_noisy,label='Noisy data')
-P.plot(x_vals,func(best),lw=2,label='Least-squares fit')
-P.legend()
-P.figure()
-P.plot(x_vals,y_noisy,label='Noisy data')
-P.plot(x_vals,smooth,lw=2,label='Spline-smoothing')
-P.legend()
+plt.figure()
+plt.plot(x_vals,y_noisy,label='Noisy data')
+plt.plot(x_vals,func(best),lw=2,label='Least-squares fit')
+plt.legend()
+plt.figure()
+plt.plot(x_vals,y_noisy,label='Noisy data')
+plt.plot(x_vals,smooth,lw=2,label='Spline-smoothing')
+plt.legend()
fignum = plot_polyfit(x_vals,y_noisy,1)
plot_polyfit(x_vals,y_noisy,2,fignum)
plot_polyfit(x_vals,y_noisy,3,fignum)
-P.show()
+plt.show()
Added: trunk/py4science/examples/mkskel.py
===================================================================
--- trunk/py4science/examples/mkskel.py (rev 0)
+++ trunk/py4science/examples/mkskel.py 2008-10-19 07:53:47 UTC (rev 6270)
@@ -0,0 +1,325 @@
+#!/usr/bin/env python
+"""Make skeletons out of Python scripts.
+
+Usage:
+
+ mkskel [--test] file1.py file2.py ....
+
+If --test is given, the test suite is run instead.
+
+For each input filename f.py, a pair of output files is generated, f_soln.py
+and f_skel.py.
+
+Source markup is very simple. The tests in the file show precisely how it
+works, but in summary:
+
+- Pure comment lines with the special marker (#@) are left in the skeleton
+ (only the marker is stripped, but they remain as valid comments). These are
+ typically used for hints.
+
+- Code lines terminated with the marker are:
+
+ - In the skeleton, replaced by a NotImplementedError call. Consecutive lines
+ are replaced by a single call.
+
+ - In the solution, kept as is but the marker is removed.
+"""
+
+from __future__ import with_statement
+
+#-----------------------------------------------------------------------------
+# Stdlib imports
+import os
+import re
+import shutil
+import sys
+
+# Third-party imports
+import nose
+
+# Constants
+MARKER = '#@'
+DEL_RE = re.compile(r'''^((\s*)(.*?))\s*%s\s*$''' % MARKER)
+HINT_RE = re.compile(r'''^(?P<space>\s*)%s\s+(?P<hint>.*)$''' % MARKER)
+
+
+#-----------------------------------------------------------------------------
+# Main code begins
+
+def src2soln(src):
+ """Remove markers from input source, leaving all else intact.
+
+ Inputs:
+ src : sequence of lines (file-like objects work out of the box)
+ """
+
+ out = []
+ addline = out.append
+ for line in src:
+ # Check for lines to delete and with hints
+ mdel = DEL_RE.match(line)
+ mhint = HINT_RE.match(line)
+
+ # All hints are unconditionally removed
+ if mhint is None:
+ if mdel:
+ # if marker is matched in code, strip it and leave the code
+ line = mdel.group(1)+'\n'
+ addline(line)
+
+ return ''.join(out)
+
+
+def src2skel(src):
+ """Remove markers from input source, replacing marked lines.
+
+ Marked lines are replaced with "raise NotImplementedError" calls that
+ summarize the total number of deleted lines.
+
+ Inputs:
+ src : sequence of lines (file-like objects work out of the box)
+ """
+
+ def flush_buffers(normal_lines,del_lines=0):
+ """Local function to reuse some common code"""
+
+ if state_cur == normal:
+ # add the normal lines
+ out.extend(normal_lines)
+ normal_lines[:] = []
+ else:
+ # Add the summary of 'raise' lines
+
+ # flush counter of code (disabled, we report static summary)
+ #msg = '1 line' if del_lines==1 else ('%s lines' % del_lines)
+ #exc = exc_tpl % msg
+ exc = exc_tpl
+
+ # Use the last value of 'space'
+ line = '%s%s' % (spaces[0],exc)
+ out.append(line)
+ del_lines = 0
+ spaces[:] = []
+
+ return del_lines
+
+ # used to report actual # of lines removed - disabled
+ #exc_tpl = "raise NotImplementedError('%s missing')\n"
+ exc_tpl = "raise NotImplementedError('insert missing code here')\n"
+
+ # states for state machine and other initialization
+ normal,delete = 0,1
+ state_cur = normal
+ del_lines = 0 # counter, in case we want to report # of deletions
+ spaces = []
+ normal_lines = []
+ out = []
+
+ # To remove multiple consecutive lines of input marked for deletion, we
+ # need a small state machine.
+ for line in src:
+ # Check for lines to delete and with hints
+ mdel = DEL_RE.match(line)
+ mhint = HINT_RE.match(line)
+
+ if mhint:
+ state_new = normal
+ hint = mhint.group('space')+'# ' + mhint.group('hint') +'\n'
+ normal_lines.append(hint)
+ else:
+ if mdel is None:
+ state_new = normal
+ normal_lines.append(line)
+ else:
+ state_new = delete
+ del_lines += 1
+ spaces.append(mdel.group(2))
+
+ # Flush output only when there's a change of state
+ if state_new != state_cur:
+ del_lines = flush_buffers(normal_lines,del_lines)
+
+ # Update state machine
+ state_cur = state_new
+
+ # Final buffer flush is unconditional
+ flush_buffers(normal_lines)
+
+ return ''.join(out)
+
+
+def transform_file(fpath,fname_skel,fname_soln):
+ """Run the cleanup routines for a given input, creating skel and soln.
+ """
+
+ # get the mode of the input so that we can create the output files with the
+ # same mode
+ fmode = os.stat(fpath).st_mode
+
+ with open(fpath) as infile:
+ # Generate the skeleton
+ skel = src2skel(infile)
+ with open(fname_skel,'w') as fskel:
+ fskel.write(skel)
+ os.chmod(fname_skel,fmode)
+
+ # Reset the input file pointer and generate the solution
+ infile.seek(0)
+ soln = src2soln(infile)
+ with open(fname_soln,'w') as fsoln:
+ fsoln.write(soln)
+ os.chmod(fname_soln,fmode)
+
+#-----------------------------------------------------------------------------
+# Main execution routines
+
+def copyforce(src,dest):
+ """Forceful file link/copy that overwrites destination files."""
+ try:
+ copy = os.link
+ except AttributeError:
+ copy = shutil.copy
+ if os.path.isfile(dest):
+ os.remove(dest)
+ copy(src,dest)
+
+
+def mvforce(src,dest):
+ """Forceful file copy that overwrites destination files."""
+ if os.path.isfile(dest):
+ os.remove(dest)
+ shutil.move(src,dest)
+
+
+def main(argv=None):
+ """Main entry point as a command line script for normal execution"""
+
+ if argv is None:
+ argv = sys.argv
+
+ # If there are subdirs called skel and soln, we populate them by moving the
+ # generated files there, otherwise they're left in the current dir.
+ skel_dir = 'skel'
+ soln_dir = 'soln'
+ has_skel_dir = os.path.isdir(skel_dir)
+ has_soln_dir = os.path.isdir(soln_dir)
+
+ # First, check that all files are present and abort immediately if any of
+ # them isn't there.
+ for fpath in argv[1:]:
+ if not os.path.isfile(fpath):
+ raise OSError("file %r not found" % fpath)
+
+ # If all files are there, then go ahead and process them unconditionally
+ for fpath in argv[1:]:
+ basename, ext = os.path.splitext(fpath)
+ fname_skel = basename + '_skel' + ext
+ fname_soln = basename + '_soln' + ext
+ transform_file(fpath,fname_skel,fname_soln)
+ # Move files over to final dirs if present
+ if has_skel_dir:
+ mvforce(fname_skel,os.path.join(skel_dir,fname_skel))
+ if has_soln_dir:
+ mvforce(fname_soln,os.path.join(soln_dir,fname_soln))
+
+#-----------------------------------------------------------------------------
+# Tests
+
+def str_match(s1,s2):
+ """Check that two strings are equal ignoring trailing whitespace."""
+ #print '***S1\n',s1,'\n***S2\n',s2 # dbg
+ nose.tools.assert_equal(s1.rstrip(),s2.rstrip())
+
+
+def test_simple():
+ src = """
+ first line
+ del line #@
+ second line
+ """
+ srclines = src.splitlines(True)
+
+ clean = """
+ first line
+ raise NotImplementedError('insert missing code here')
+ second line
+ """
+
+ cleaned = src2skel(srclines)
+ yield str_match,cleaned,clean
+
+ clean = """
+ first line
+ del line
+ second line
+ """
+ cleaned = src2soln(src.splitlines(True))
+ yield str_match,cleaned,clean
+
+
+def test_multi():
+ src = """
+ first line
+ #@ Hint: remember that
+ #@ idea we discussed before...
+ del line #@
+ del line2 #@
+ del line3 #@
+ second line:
+ del line4 #@
+ del line5 #@
+ third line
+
+ some indented code: #@
+ with more... #@
+ """
+ srclines = src.splitlines(True)
+
+ clean = """
+ first line
+ # Hint: remember that
+ # idea we discussed before...
+ raise NotImplementedError('insert missing code here')
+ second line:
+ raise NotImplementedError('insert missing code here')
+ third line
+
+ raise NotImplementedError('insert missing code here')
+ """
+ cleaned = src2skel(srclines)
+ yield str_match,cleaned,clean
+
+ clean = """
+ first line
+ del line
+ del line2
+ del line3
+ second line:
+ del line4
+ del line5
+ third line
+
+ some indented code:
+ with more...
+ """
+ cleaned = src2soln(srclines)
+ yield str_match,cleaned,clean
+
+
+@nose.tools.nottest
+def test():
+ """Simple self-contained test runner."""
+ nose.runmodule(__name__,exit=False,
+ argv=['--doctests',
+ #'-s',
+ #'--pdb-failures',
+ ])
+
+#-----------------------------------------------------------------------------
+# Execution from the command line.
+
+if __name__ == "__main__":
+ if '--test' in sys.argv:
+ test()
+ else:
+ main(sys.argv)
Property changes on: trunk/py4science/examples/mkskel.py
___________________________________________________________________
Added: svn:executable
+ *
Modified: trunk/py4science/examples/montecarlo_pi.py
===================================================================
--- trunk/py4science/examples/montecarlo_pi.py 2008-10-19 07:48:51 UTC (rev 6269)
+++ trunk/py4science/examples/montecarlo_pi.py 2008-10-19 07:53:47 UTC (rev 6270)
@@ -15,7 +15,7 @@
import math
import random
-import numpy as N
+import numpy as np
from scipy import weave
from scipy.weave import inline,converters
@@ -110,7 +110,7 @@
print 'pi - weave :',v2()
# make a simple 10x10 array
- a = N.arange(100)
+ a = np.arange(100)
a.shape = 10,10
# Print it using our printer
Modified: trunk/py4science/examples/qsort.py
===================================================================
--- trunk/py4science/examples/qsort.py 2008-10-19 07:48:51 UTC (rev 6269)
+++ trunk/py4science/examples/qsort.py 2008-10-19 07:53:47 UTC (rev 6270)
@@ -1,29 +1,60 @@
-"""
-Simple quicksort implementation.
+"""Simple quicksort implementation.
-See http://en.wikipedia.org/wiki/Quicksort for algorithm, pseudocode
-and C implementation for comparison
+From http://en.wikipedia.org/wiki/Quicksort we have this pseudocode (see also
+the C implementation for comparison).
+
+Note: what follows is NOT python code, it's meant to only illustrate the
+algorithm for you. Below you'll need to actually implement it in real Python.
+You may be surprised at how close a working Python implementation can be to
+this pseudocode.
+
+
+function quicksort(array)
+ var list less, greater
+ if length(array) <= 1
+ return array
+ select and remove a pivot value pivot from array
+ for each x in array
+ if x <= pivot then append x to less
+ else append x to greater
+ return concatenate(quicksort(less), pivot, quicksort(greater))
"""
def qsort(lst):
- """Return a sorted copy of the input list."""
+ """Return a sorted copy of the input list.
- if len(lst) <= 1:
- return lst
+ Input:
- # Select pivot and apply recursively
- pivot, rest = lst[0],lst[1:]
- less_than = [ lt for lt in rest if lt < pivot ]
- greater_equal = [ ge for ge in rest if ge >= pivot ]
-
- return qsort(less_than) + [pivot] + qsort(greater_equal)
+ lst : a list of elements which can be compared.
+ Examples:
+ >>> qsort([])
+ []
+
+ >>> qsort([3,2,5])
+ [2, 3, 5]
+ """
+
+ #@ Hint: remember that all recursive functions need an exit condition
+ if len(lst) <= 1: #@
+ return lst #@
+
+ #@ Select pivot and apply recursively
+ pivot, rest = lst[0],lst[1:] #@
+ less_than = [ lt for lt in rest if lt < pivot ] #@
+ greater_equal = [ ge for ge in rest if ge >= pivot ] #@
+
+ #@ Upon return, make sure to properly concatenate the output lists
+ return qsort(less_than) + [pivot] + qsort(greater_equal) #@
+
+
#-----------------------------------------------------------------------------
# Tests
#-----------------------------------------------------------------------------
import random
+import nose
import nose, nose.tools as nt
def test_sorted():
Modified: trunk/py4science/examples/quad_newton.py
===================================================================
--- trunk/py4science/examples/quad_newton.py 2008-10-19 07:48:51 UTC (rev 6269)
+++ trunk/py4science/examples/quad_newton.py 2008-10-19 07:53:47 UTC (rev 6270)
@@ -4,35 +4,35 @@
from math import sin
-import scipy, scipy.integrate, scipy.optimize
+from scipy.integrate import quad
+from scipy.optimize import newton
-quad = scipy.integrate.quad
-newton = scipy.optimize.newton
-
# test input function
def f(t):
- return t*(sin(t))**2
+ #@ f(t): t * sin^2(t)
+ return t*(sin(t))**2 #@
-# exact \int_0^t f(s) ds - u
def g(t):
+ "Exact form for g by integrating f(t)"
u = 0.25
return .25*(t**2-t*sin(2*t)+(sin(t))**2)-u
-# now let's construct g(t) via numerical integration
def gn(t):
+ "g(t) obtained by numerical integration"
u = 0.25
- return quad(f,0.0,t)[0] - u
+ #@ Hint: use quad, see its return value carefully.
+ return quad(f,0.0,t)[0] - u #@
# main
tguess = 10.0
print '"Exact" solution (knowing the analytical form of the integral)'
-t0 = newton(g,tguess,f)
+t0 = newton(g,tguess,f) #@
print "t0, g(t0) =",t0,g(t0)
print
print "Solution using the numerical integration technique"
-t1 = newton(gn,tguess,f)
+t1 = newton(gn,tguess,f) #@
print "t1, g(t1) =",t1,g(t1)
print
Modified: trunk/py4science/examples/recarray_demo.py
===================================================================
--- trunk/py4science/examples/recarray_demo.py 2008-10-19 07:48:51 UTC (rev 6269)
+++ trunk/py4science/examples/recarray_demo.py 2008-10-19 07:53:47 UTC (rev 6270)
@@ -1,67 +1,53 @@
"""
parse and load ge.csv into a record array
"""
-import time, datetime, csv
-import dateutil.parser
-import numpy
-if 0:
- # create a csv reader to parse the file
- fh = file('data/ge.csv')
- reader = csv.reader(fh)
- header = reader.next()
+import datetime
- # iterate over the remaining rows and convert the data to date
- # objects, ints, or floats as approriate
- rows = []
- for date, open, high, low, close, volume, adjclose in reader:
- date = dateutil.parser.parse(date).date()
- volume = int(volume)
- open, high, low, close, adjclose = map(float, (
- open, high, low, close, adjclose))
- rows.append((date, open, high, low, close, volume, adjclose))
+import numpy as np
- fh.close()
+import matplotlib
+from matplotlib import pyplot as plt
- # this is how you can use the function matplotlib.mlab.load to do the same
- #rows = load('data/ge.csv', skiprows=1, converters={0:datestr2num}, delimiter=',')
+# Disable latex support just in case, so we can rotate text
+matplotlib.rcParams['text.usetex'] = False
- r = numpy.rec.fromrecords(rows, names='date,open,high,low,close,volume,adjclose')
+# Load a data file into a record array using the matplotlib csv2rec utility
+r = matplotlib.mlab.csv2rec('data/ge.csv')
+r.sort() #sort by date, the first column
# compute the average approximate dollars traded over the last 10 days
# hint: closing price * volume trades approx equals dollars trades
recent = r[-10:]
-dollars = numpy.mean(recent.close * recent.volume)
-print '$%1.2fM'%(dollars/1e6)
+dollars = np.mean(recent.close * recent.volume)
+print 'Total traded over last 10 days: $%1.2fM'%(dollars/1e6)
-# plot the adjusted closing price vs time since 2003 - hint, you must
-# use date2num to convert the date to a float for mpl. Make two axes,
-# one for price and one for volume. Use a bar chart for volume
-import matplotlib
-matplotlib.rcParams['usetex'] = False
-from matplotlib.dates import date2num
-import pylab
-mask = r.date>datetime.date(2003,1,1)
-date = date2num(r.date[mask])
-price = r.adjclose[mask]
+# plot the adjusted closing price vs time since 2003. Make two axes, one for
+# price and one for volume. Use a bar chart for volume
+
+# Record arrays are like 'mini-spreadsheets'
+mask = r.date > datetime.date(2003,1,1)
+date = r.date[mask]
+price = r.adj_close[mask]
volume = r.volume[mask]
-fig = pylab.figure()
+# Plotting
+fig = plt.figure()
fig.subplots_adjust(hspace=0)
ax1 = fig.add_subplot(211)
-ax1.plot(date, price, '-');
-ax1.xaxis_date()
+ax1.plot(date, price, '-')
+
ax1.grid()
for label in ax1.get_xticklabels():
label.set_visible(False)
ax2 = fig.add_subplot(212, sharex=ax1)
ax2.bar(date, volume);
-ax2.xaxis_date()
+
ax2.grid()
for label in ax2.get_xticklabels():
label.set_rotation(30)
label.set_horizontalalignment('right')
-
-pylab.show()
+fig.autofmt_xdate()
+plt.show()
Added: trunk/py4science/examples/skel/fortran_wrap/test_example.py
===================================================================
--- trunk/py4science/examples/skel/fortran_wrap/test_example.py (rev 0)
+++ trunk/py4science/examples/skel/fortran_wrap/test_example.py 2008-10-19 07:53:47 UTC (rev 6270)
@@ -0,0 +1,9 @@
+import example
+import numpy
+
+x = numpy.arange(10.)
+
+yf = example.cumsum(x)
+yn = numpy.cumsum(x)
+
+numpy.testing.assert_array_almost_equal(yf, yn)
Added: trunk/py4science/examples/skel/fortran_wrap/test_fib.py
===================================================================
--- trunk/py4science/examples/skel/fortran_wrap/test_fib.py (rev 0)
+++ trunk/py4science/examples/skel/fortran_wrap/test_fib.py 2008-10-19 07:53:47 UTC (rev 6270)
@@ -0,0 +1,13 @@
+import numpy as N
+
+import example
+
+n = 10
+fn = example.fib(n)
+
+print 'Fibonacci numbers:'
+print fn
+
+# Check validity
+assert N.alltrue(fn[2:]== fn[1:-1]+fn[:-2]), "Fibonacci mismatch"
+
Modified: trunk/py4science/examples/trapezoid.py
===================================================================
--- trunk/py4science/examples/trapezoid.py 2008-10-19 07:48:51 UTC (rev 6269)
+++ trunk/py4science/examples/trapezoid.py 2008-10-19 07:53:47 UTC (rev 6270)
@@ -7,7 +7,8 @@
"""Simple trapezoid integrator for sequence-based innput.
Inputs:
- - x,y: arrays of the same length.
+ - x,y: arrays of the same length (and more than one element). If the two
+ inputs have different lengths, a ValueError exception is raised.
Output:
- The result of applying the trapezoid rule to the input, assuming that
@@ -15,14 +16,20 @@
Minimally modified from matplotlib.mlab."""
- # Sanity checks
- if len(x)!=len(y):
- raise ValueError('x and y must have the same length')
- if len(x)<2:
- raise ValueError('x and y must have > 1 element')
+ # Sanity checks.
+ #@
+ #@ Hint: if the two inputs have mismatched lengths or less than 2
+ #@ elements, we raise ValueError with an explanatory message.
+ if len(x) != len(y): #@
+ raise ValueError('x and y must have the same length') #@
+ if len(x) < 2: #@
+ raise ValueError('x and y must have > 1 element') #@
# Efficient application of trapezoid rule via numpy
- return 0.5*((x[1:]-x[:-1])*(y[1:]+y[:-1])).sum()
+ #@
+ #@ Hint: think of using numpy slicing to compute the moving difference in
+ #@ the basic trapezoid formula.
+ return 0.5*((x[1:]-x[:-1])*(y[1:]+y[:-1])).sum() #@
def trapzf(f,a,b,npts=100):
"""Simple trapezoid-based integrator.
@@ -39,15 +46,25 @@
Output:
- The value of the trapezoid-rule approximation to the integral."""
- # Generate an equally spaced grid to sample the function at
- x = np.linspace(a,b,npts)
+ #@ Hint: you will need to apply the function f to easch element of the
+ #@ vector x. What are several ways to do this? Can you profile them to see
+ #@ what differences in timings result for long vectors x?
+
+ # Generate an equally spaced grid to sample the function.
+ x = np.linspace(a,b,npts)#@
+
# For an equispaced grid, the x spacing can just be read off from the first
# two points and factored out of the summation.
- dx = x[1]-x[0]
+ dx = x[1]-x[0]#@
+
# Sample the input function at all values of x
- y = np.array(map(f,x))
+ #@
+ #@ Hint: you need to make an array out of the evaluations, and the python
+ #@ builtin 'map' function can come in handy.
+ y = np.array(map(f,x))#@
+
# Compute the trapezoid rule sum for the final result
- return 0.5*dx*(y[1:]+y[:-1]).sum()
+ return 0.5*dx*(y[1:]+y[:-1]).sum()#@
#-----------------------------------------------------------------------------
@@ -56,20 +73,25 @@
import nose, nose.tools as nt
import numpy.testing as nptest
+# A simple function for testing
def square(x): return x**2
def test_err():
+ """Test that mismatched inputs raise a ValueError exception."""
nt.assert_raises(ValueError,trapz,range(2),range(3))
def test_call():
+ "Test a direct call with equally spaced samples. "
x = np.linspace(0,1,100)
y = np.array(map(square,x))
nptest.assert_almost_equal(trapz(x,y),1./3,4)
def test_square():
+ "Test integrating the square() function."
nptest.assert_almost_equal(trapzf(square,0,1),1./3,4)
def test_square2():
+ "Another test integrating the square() function."
nptest.assert_almost_equal(trapzf(square,0,3,350),9.0,4)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fer...@us...> - 2008-10-19 07:49:08
|
Revision: 6269
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6269&view=rev
Author: fer_perez
Date: 2008-10-19 07:48:51 +0000 (Sun, 19 Oct 2008)
Log Message:
-----------
Updated skeletons.
Modified Paths:
--------------
trunk/py4science/examples/skel/basemap1_skel.py
trunk/py4science/examples/skel/basemap2_skel.py
trunk/py4science/examples/skel/basemap3_skel.py
trunk/py4science/examples/skel/basemap4_skel.py
trunk/py4science/examples/skel/basemap5_skel.py
trunk/py4science/examples/skel/convolution_demo_skel.py
trunk/py4science/examples/skel/fft_imdenoise_skel.py
trunk/py4science/examples/skel/fitting_skel.py
trunk/py4science/examples/skel/glass_dots1_skel.py
trunk/py4science/examples/skel/lotka_volterra_skel.py
trunk/py4science/examples/skel/noisy_sine_skel.py
trunk/py4science/examples/skel/qsort_skel.py
trunk/py4science/examples/skel/quad_newton_skel.py
trunk/py4science/examples/skel/stats_descriptives_skel.py
trunk/py4science/examples/skel/stats_distributions_skel.py
trunk/py4science/examples/skel/stock_records_skel.py
trunk/py4science/examples/skel/trapezoid_skel.py
trunk/py4science/examples/skel/wallis_pi_skel.py
trunk/py4science/examples/skel/wordfreqs_skel.py
Modified: trunk/py4science/examples/skel/basemap1_skel.py
===================================================================
--- trunk/py4science/examples/skel/basemap1_skel.py 2008-10-19 07:38:45 UTC (rev 6268)
+++ trunk/py4science/examples/skel/basemap1_skel.py 2008-10-19 07:48:51 UTC (rev 6269)
@@ -1,13 +1,11 @@
-import pylab, numpy
-from matplotlib.toolkits.basemap import Basemap
+from mpl_toolkits.basemap import Basemap
+import matplotlib.pyplot as plt
# create map by specifying lat/lon values at corners.
-projection = 'lcc' # map projection
-resolution = XX # resolution of boundaries ('c','l','i',or 'h')
-lon_0=XX # longitude of origin of map projection domain (degrees).
-lat_0=XX # standard parallel/latitude of origin of map projection domain.
-llcrnrlat, llcrnrlon = XX, XX # lat/lon of lower left corner of map (degrees)
-urcrnrlat, urcrnrlon = XX, XX # lat/lon of upper right corner of map
-m = Basemap(lon_0=lon_0,lat_0=lat_0,\
+resolution = 'l'; projection = 'lcc'
+lat_0 = 60; lon_0 = -50
+llcrnrlat, llcrnrlon = 8, -92
+urcrnrlat, urcrnrlon = 39, 63
+m = Basemap(lat_0=lat_0,lon_0=lon_0,\
llcrnrlat=llcrnrlat,llcrnrlon=llcrnrlon,\
urcrnrlat=urcrnrlat,urcrnrlon=urcrnrlon,\
resolution=resolution,projection=projection)
@@ -20,5 +18,5 @@
# draw states and countries.
m.drawcountries()
m.drawstates()
-pylab.title('map region specified using corner lat/lon values')
-pylab.show()
+plt.title('map region specified using corner lat/lon values')
+plt.show()
Modified: trunk/py4science/examples/skel/basemap2_skel.py
===================================================================
--- trunk/py4science/examples/skel/basemap2_skel.py 2008-10-19 07:38:45 UTC (rev 6268)
+++ trunk/py4science/examples/skel/basemap2_skel.py 2008-10-19 07:48:51 UTC (rev 6269)
@@ -1,13 +1,9 @@
-import pylab, numpy
-from matplotlib.toolkits.basemap import Basemap, supported_projections
+from mpl_toolkits.basemap import Basemap
+import matplotlib.pyplot as plt
# create map by specifying width and height in km.
-projection = XX # map projection ('lcc','stere','laea','aea' etc)
- # 'print supported_projections' gives a list
-resolution = XX # resolution of boundaries ('c','l','i',or 'h')
-lon_0= XX # longitude of origin of map projection domain (degrees).
-lat_0= XX # standard parallel/latitude of origin of map projection domain.
-width = XX # width of map projecton domain in km.
-height = XX # height of map projection domain in km.
+resolution = 'l'; projection = 'lcc'
+lon_0 = -50; lat_0 = 60
+width = 12000000; height = 0.75*width
m = Basemap(lon_0=lon_0,lat_0=lat_0,\
width=width,height=height,\
resolution=resolution,projection=projection)
@@ -16,5 +12,5 @@
m.fillcontinents(color='coral',lake_color='aqua')
m.drawcountries()
m.drawstates()
-pylab.title('map region specified using width and height')
-pylab.show()
+plt.title('map region specified using width and height')
+plt.show()
Modified: trunk/py4science/examples/skel/basemap3_skel.py
===================================================================
--- trunk/py4science/examples/skel/basemap3_skel.py 2008-10-19 07:38:45 UTC (rev 6268)
+++ trunk/py4science/examples/skel/basemap3_skel.py 2008-10-19 07:48:51 UTC (rev 6269)
@@ -1,34 +1,36 @@
-import pylab, numpy
-from matplotlib.toolkits.basemap import Basemap
+from mpl_toolkits.basemap import Basemap
+import matplotlib.pyplot as plt
# create map by specifying width and height in km.
-resolution = 'l'; projection='lcc'
-lon_0 = -50; lat_0 = 60.
+resolution = 'l'; projection = 'lcc'
+lon_0 = -50; lat_0 = 60
width = 12000000; height = 0.75*width
-m = Basemap(lon_0=lon_0,lat_0=lat_0,width=width,height=height,\
+m = Basemap(lon_0=lon_0,lat_0=lat_0,width=width,height=height,
resolution=resolution,projection=projection)
-# lat/lon and name of location 1.
-lat1 = XX; lon1 = XX; name = XX
-# ditto for location 2.
-lat2 = XX; lon2 = XX; name2 = XX
+# nylat, nylon are lat/lon of New York
+nylat = 40.78
+nylon = -73.98
+# lonlat, lonlon are lat/lon of London.
+lonlat = 51.53
+lonlon = 0.08
# convert these points to map projection coordinates
# (using __call__ method of Basemap instance)
-x1, y1 = m(lon1, lat1)
-x2, y2 = m(lon2, lat2)
+ny_x, ny_y = m(nylon, nylat)
+lon_x, lon_y = m(lonlon, lonlat)
# plot black dots at the two points.
# make sure dots are drawn on top of other plot elements (zorder=10)
-m.scatter([x1,x2],[y1,y2],25,color='k',marker='o',zorder=10)
+m.scatter([ny_x,lon_x],[ny_y,lon_y],25,color='k',marker='o',zorder=10)
# connect the dots along a great circle.
-m.drawgreatcircle(lon1,lat1,lon2,lat2,linewidth=2,color='k')
+m.drawgreatcircle(nylon,nylat,lonlon,lonlat,linewidth=2,color='k')
# put the names of the cities to the left of each dot, offset
# by a little. Use a bold font.
-pylab.text(x1-100000,y1+100000,name1,fontsize=12,\
+plt.text(ny_x-100000,ny_y+100000,'New York',fontsize=12,\
color='k',horizontalalignment='right',fontweight='bold')
-pylab.text(x2-100000,y2+100000,name2,fontsize=12,\
+plt.text(lon_x-100000,lon_y+100000,'London',fontsize=12,\
color='k',horizontalalignment='right',fontweight='bold')
m.drawcoastlines(linewidth=0.5)
m.drawmapboundary(fill_color='aqua')
m.fillcontinents(color='coral',lake_color='aqua')
m.drawcountries()
m.drawstates()
-pylab.title(name1+' to '+name2+' Great Circle')
-pylab.show()
+plt.title('NY to London Great Circle')
+plt.show()
Modified: trunk/py4science/examples/skel/basemap4_skel.py
===================================================================
--- trunk/py4science/examples/skel/basemap4_skel.py 2008-10-19 07:38:45 UTC (rev 6268)
+++ trunk/py4science/examples/skel/basemap4_skel.py 2008-10-19 07:48:51 UTC (rev 6269)
@@ -1,28 +1,25 @@
-import pylab, numpy
-from matplotlib.toolkits.basemap import Basemap
+from mpl_toolkits.basemap import Basemap
+import matplotlib.pyplot as plt
+import numpy as np
# create map by specifying width and height in km.
-resolution = 'l'; projection='lcc'
-lon_0 = -50; lat_0 = 60.
-width = 12000000; height = 0.75*width
-m = Basemap(lon_0=lon_0,lat_0=lat_0,width=width,height=height,\
+resolution = 'l'
+lon_0 = -50
+lat_0 = 60
+projection = 'lcc'
+width = 12000000
+height = 0.75*width
+m = Basemap(lon_0=lon_0,lat_0=lat_0,width=width,height=height,
resolution=resolution,projection=projection)
m.drawcoastlines(linewidth=0.5)
m.drawmapboundary(fill_color='aqua')
m.fillcontinents(color='coral',lake_color='aqua')
m.drawcountries()
m.drawstates()
-# draw and label parallels.
-# labels is list of 4 values (default [0,0,0,0]) that control whether
-# parallels are labelled where they intersect the left, right, top or
-# bottom of the plot. For example labels=[1,0,0,1] will cause parallels
-# to be labelled where they intersect the left and bottom of the plot,
-# but not the right and top.
-labels = XX
-parallels = XX # a sequence of latitudes values
-m.drawparallels(parallels,labels=labels)
-# draw and label meridians.
-labels = XX
-meridians = XX # a sequence of longitude values
-m.drawmeridians(meridians,labels=labels)
-pylab.title('labelled meridians and parallels',y=1.075)
-pylab.show()
+# label meridians where they intersect the left, right and bottom
+# of the plot frame.
+m.drawmeridians(np.arange(-180,181,20),labels=[1,1,0,1])
+# label parallels where they intersect the left, right and top
+# of the plot frame.
+m.drawparallels(np.arange(-80,81,20),labels=[1,1,1,0])
+plt.title('labelled meridians and parallels',y=1.075)
+plt.show()
Modified: trunk/py4science/examples/skel/basemap5_skel.py
===================================================================
--- trunk/py4science/examples/skel/basemap5_skel.py 2008-10-19 07:38:45 UTC (rev 6268)
+++ trunk/py4science/examples/skel/basemap5_skel.py 2008-10-19 07:48:51 UTC (rev 6269)
@@ -1,37 +1,27 @@
-from matplotlib.toolkits.basemap import Basemap, NetCDFFile, cm
-import pylab, numpy
+from mpl_toolkits.basemap import Basemap, NetCDFFile
+import matplotlib.pyplot as plt
+import numpy as np
# read in netCDF sea-surface temperature data
# can be a local file, a URL for a remote opendap dataset,
# or (if PyNIO is installed) a GRIB or HDF file.
-# See http://nomads.ncdc.noaa.gov/ for some NOAA OPenDAP datasets.
ncfile = NetCDFFile('data/sst.nc')
-# uncommenting the next line will produce a very similar plot,
-# but will read the data over the web instead of from a local file.
-#ncfile = NetCDFFile('http://nomads.ncdc.noaa.gov:8085/thredds/dodsC/oisst/2007/AVHRR/sst4-navy-eot.20071201.nc')
sst = ncfile.variables['sst'][:]
lats = ncfile.variables['lat'][:]
lons = ncfile.variables['lon'][:]
-# Basemap comes with extra colormaps from Generic Mapping Tools
-# (imported as cm, pylab colormaps in pylab.cm)
-cmap = XX
# create Basemap instance for mollweide projection.
-projection = XX # try moll, robin, sinu or ortho.
# coastlines not used, so resolution set to None to skip
# continent processing (this speeds things up a bit)
-m = Basemap(projection=projection,lon_0=lons.mean(),lat_0=0,resolution=None)
+m = Basemap(projection='moll',lon_0=0,lat_0=0,resolution=None)
# compute map projection coordinates of grid.
-x, y = m(*numpy.meshgrid(lons, lats))
+x, y = m(*np.meshgrid(lons, lats))
# plot with pcolor
-im = m.pcolormesh(x,y,sst,shading='flat',cmap=cmap)
-# or try 100 filled contours.
-#CS = m.contourf(x,y,sst,100,cmap=cmap)
+im = m.pcolormesh(x,y,sst,shading='flat',cmap=plt.cm.gist_ncar)
# draw parallels and meridians, but don't bother labelling them.
-m.drawparallels(numpy.arange(-90.,120.,30.))
-m.drawmeridians(numpy.arange(0.,420.,60.))
+m.drawparallels(np.arange(-90.,120.,30.))
+m.drawmeridians(np.arange(0.,420.,60.))
# draw line around map projection limb.
-# color map region background (missing values will be this color)
-color = XX
-m.drawmapboundary(fill_color=color)
+# color map region background black (missing values will be this color)
+m.drawmapboundary(fill_color='k')
# draw horizontal colorbar.
-pylab.colorbar(orientation='horizontal')
-pylab.show()
+plt.colorbar(orientation='horizontal')
+plt.show()
Modified: trunk/py4science/examples/skel/convolution_demo_skel.py
===================================================================
--- trunk/py4science/examples/skel/convolution_demo_skel.py 2008-10-19 07:38:45 UTC (rev 6268)
+++ trunk/py4science/examples/skel/convolution_demo_skel.py 2008-10-19 07:48:51 UTC (rev 6269)
@@ -27,33 +27,50 @@
# build the time, input, output and response arrays
dt = 0.01
-t = XXX # the time vector from 0..20
+t = npy.arange(0.0, 20.0, dt) # the time vector from 0..20
Nt = len(t)
def impulse_response(t):
'double exponential response function'
- return XXX
+ return (npy.exp(-t) - npy.exp(-5*t))*dt
-x = XXX # gaussian white noise
+x = npy.random.randn(Nt) # gaussian white noise
# evaluate the impulse response function, and numerically convolve it
# with the input x
-r = XXX # evaluate the impulse function
-y = XXX # convolution of x with r
-y = XXX # extract just the length Nt part
+r = impulse_response(t) # evaluate the impulse function
+y = npy.convolve(x, r, mode='full') # convultion of x with r
+y = y[:Nt]
# compute y by applying F^-1[F(x) * F(r)]. The fft assumes the signal
# is periodic, so to avoid edge artificats, pad the fft with zeros up
# to the length of r + x do avoid circular convolution artifacts
-R = XXX # the zero padded FFT of r
-X = XXX # the zero padded FFT of x
-Y = XXX # the product of R and X
+R = npy.fft.fft(r, len(r)+len(x)-1)
+X = npy.fft.fft(x, len(r)+len(x)-1)
+Y = R*X
-# now inverse fft and extract the real part, just the part up to
-# len(x)
-yi = XXX
+# now inverse fft and extract just the part up to len(x)
+yi = npy.fft.ifft(Y)[:len(x)].real
-# plot x vs t, y and yi vs t, and r vs t in three subplots
-XXX
+# plot t vs x, t vs y and yi, and t vs r in three subplots
+fig = figure()
+ax1 = fig.add_subplot(311)
+ax1.plot(t, x)
+ax1.set_ylabel('input x')
+
+ax2 = fig.add_subplot(312)
+ax2.plot(t, y, label='convolve')
+ax2.set_ylabel('output y')
+
+ax3 = fig.add_subplot(313)
+ax3.plot(t, r)
+ax3.set_ylabel('input response')
+ax3.set_xlabel('time (s)')
+
+ax2.plot(t, yi, label='fft')
+ax2.legend(loc='best')
+
+fig.savefig('convolution_demo.png', dpi=150)
+fig.savefig('convolution_demo.eps')
show()
Modified: trunk/py4science/examples/skel/fft_imdenoise_skel.py
===================================================================
--- trunk/py4science/examples/skel/fft_imdenoise_skel.py 2008-10-19 07:38:45 UTC (rev 6268)
+++ trunk/py4science/examples/skel/fft_imdenoise_skel.py 2008-10-19 07:48:51 UTC (rev 6269)
@@ -1,64 +1,84 @@
#!/usr/bin/env python
-"""Image denoising example using 2-dimensional FFT."""
+"""Simple image denoising example using 2-dimensional FFT."""
-XXX = None # a sentinel for missing pieces
+import sys
import numpy as np
from matplotlib import pyplot as plt
-def mag_phase(F):
- """Return magnitude and phase components of spectrum F."""
-
- # XXX Look at the absolute and angle functions in numpy...
-
def plot_spectrum(F, amplify=1000):
"""Normalise, amplify and plot an amplitude spectrum."""
- M = XXX # use mag_phase to get the magnitude...
+ # Note: the problem here is that we have a spectrum whose histogram is
+ # *very* sharply peaked at small values. To get a meaningful display, a
+ # simple strategy to improve the display quality consists of simply
+ # amplifying the values in the array and then clipping.
- # XXX Now, rescale M by amplify/maximum_of_M. Numpy arrays can be scaled
- # in-place with ARR *= number. For the max of an array, look for its max
- # method.
+ # Compute the magnitude of the input F (call it mag). Then, rescale mag by
+ # amplify/maximum_of_mag. Numpy arrays can be scaled in-place with ARR *=
+ # number. For the max of an array, look for its max method.
+ raise NotImplementedError('insert missing code here')
+
+ # Next, clip all values larger than one to one. You can set all elements
+ # of an array which satisfy a given condition with array indexing syntax:
+ # ARR[ARR<VALUE] = NEWVALUE, for example.
+ raise NotImplementedError('insert missing code here')
- # XXX Next, clip all values larger than one to one. You can set all
- # elements of an array which satisfy a given condition with array indexing
- # syntax: ARR[ARR<VALUE] = NEWVALUE, for example.
+ # Display: this one already works, if you did everything right with mag
+ plt.imshow(mag, plt.cm.Blues)
+if __name__ == '__main__':
- # Display: this one already works, if you did everything right with M
- plt.imshow(M, plt.cm.Blues)
+ try:
+ # Read in original image, convert to floating point for further
+ # manipulation; imread returns a MxNx4 RGBA image. Since the image is
+ # grayscale, just extract the 1st channel
+ # Hints:
+ # - use plt.imread() to load the file
+ # - convert to a float array with the .astype() method
+ # - extract all rows, all columns, 0-th plane to get the first
+ # channel
+ # - the resulting array should have 2 dimensions only
+ raise NotImplementedError('insert missing code here')
+ print "Image shape:",im.shape
+ except:
+ print "Could not open image."
+ sys.exit(-1)
+ # Compute the 2d FFT of the input image
+ # Hint: Look for a 2-d FFT in np.fft.
+ # Note: call this variable 'F', which is the name we'll be using below.
+ raise NotImplementedError('insert missing code here')
-if __name__ == '__main__':
+ # In the lines following, we'll make a copy of the original spectrum and
+ # truncate coefficients. NO immediate code is to be written right here.
- im = XXX # make an image array from the file 'moonlanding.png', using the
- # pylab imread() function. You will need to just extract the red
- # channel from the MxNx4 RGBA matrix to represent the grayscale
- # intensities
-
- F = XXX # Compute the 2d FFT of the input image. Look for a 2-d FFT in
- # np.fft.
-
# Define the fraction of coefficients (in each direction) we keep
keep_fraction = 0.1
- # XXX Call ff a copy of the original transform. Numpy arrays have a copy
+ # Call ff a copy of the original transform. Numpy arrays have a copy
# method for this purpose.
+ raise NotImplementedError('insert missing code here')
- # XXX Set r and c to be the number of rows and columns of the array. Look
- # for the shape attribute...
+ # Set r and c to be the number of rows and columns of the array.
+ # Hint: use the array's shape attribute.
+ raise NotImplementedError('insert missing code here')
# Set to zero all rows with indices between r*keep_fraction and
# r*(1-keep_fraction):
+ raise NotImplementedError('insert missing code here')
# Similarly with the columns:
+ raise NotImplementedError('insert missing code here')
-
- # Reconstruct the denoised image from the filtered spectrum. There's an
- # inverse 2d fft in the dft module as well. Call the result im_new
-
- # Show the results.
-
+ # Reconstruct the denoised image from the filtered spectrum, keep only the
+ # real part for display.
+ # Hint: There's an inverse 2d fft in the np.fft module as well (don't
+ # forget that you only want the real part).
+ # Call the result im_new,
+ raise NotImplementedError('insert missing code here')
+
+ # Show the results
# The code below already works, if you did everything above right.
plt.figure()
@@ -78,6 +98,6 @@
plt.title('Reconstructed Image')
plt.imshow(im_new, plt.cm.gray)
- # Adjust the spacing between subplots for readability
+ # Adjust the spacing between subplots for readability
plt.subplots_adjust(hspace=0.32)
plt.show()
Modified: trunk/py4science/examples/skel/fitting_skel.py
===================================================================
--- trunk/py4science/examples/skel/fitting_skel.py 2008-10-19 07:38:45 UTC (rev 6268)
+++ trunk/py4science/examples/skel/fitting_skel.py 2008-10-19 07:48:51 UTC (rev 6269)
@@ -1,16 +1,19 @@
#!/usr/bin/env python
"""Simple data fitting and smoothing example"""
+XXX = None # placeholder for missing pieces
+
from numpy import exp,arange,array,linspace
from numpy.random import normal
from scipy.optimize import leastsq
from scipy.interpolate import splrep,splev
-import numpy as N
-import scipy as S
-import pylab as P
+import numpy as np
+import matplotlib as mpl
+import matplotlib.pyplot as plt
+
def func(pars):
a, alpha, k = pars
return a*exp(alpha*x_vals) + k
@@ -32,17 +35,18 @@
# now solve for the best fit paramters
#XXX - use leastsq() here, call the output 'best' for code below to use
+best = XXX
print 'Least-squares fit to the data'
print 'true', pars_true
print 'best', best
-print '|err|_l2 =',P.l2norm(pars_true-best)
+print '|err|_l2 =',np.linalg.norm(pars_true-best)
# scipy's splrep uses FITPACK's curfit (B-spline interpolation)
print
print 'Spline smoothing of the data'
-sp = # XXX - use splrep()
-smooth = # XXX use splev()
+sp = XXX # use splrep()
+smooth = XXX # use splev()
print 'Spline information (see splrep and splev for details):',sp
@@ -50,23 +54,23 @@
def plot_polyfit(x,y,n,fignum=None):
"""Do a polynomial fit of order n and plot it."""
if fignum is None:
- fignum = P.figure().number
- P.plot(x,y,label='Data')
+ fignum = plt.figure().number
+ plt.plot(x,y,label='Data')
- fit_coefs = # XXX- use N.polyfit here
- fit_val = # XXX - use N.polyval
- P.plot(x,fit_val,label='Polynomial fit, $n=%d$' % n)
- P.legend()
+ fit_coefs = XXX # use np.polyfit here
+ fit_val = XXX # use np.polyval
+ plt.plot(x,fit_val,label='Polynomial fit, $n=%d$' % n)
+ plt.legend()
return fignum
# Now use pylab to plot
-P.figure()
+plt.figure()
# Plot the least-squares fit here...
-P.plot(x_vals,y_noisy,label='Noisy data')
-P.plot(x_vals,func(best),lw=2,label='Least-squares fit')
-P.legend()
+plt.plot(x_vals,y_noisy,label='Noisy data')
+plt.plot(x_vals,func(best),lw=2,label='Least-squares fit')
+plt.legend()
-P.figure()
+plt.figure()
# Plot the splines fit here...
# Plot the polynomials fits with this:
@@ -74,4 +78,4 @@
plot_polyfit(x_vals,y_noisy,2,fignum)
plot_polyfit(x_vals,y_noisy,3,fignum)
-P.show()
+plt.show()
Modified: trunk/py4science/examples/skel/glass_dots1_skel.py
===================================================================
--- trunk/py4science/examples/skel/glass_dots1_skel.py 2008-10-19 07:38:45 UTC (rev 6268)
+++ trunk/py4science/examples/skel/glass_dots1_skel.py 2008-10-19 07:48:51 UTC (rev 6269)
@@ -5,60 +5,84 @@
See L. Glass. 'Moire effect from random dots' Nature 223, 578580 (1969).
"""
-import cmath # provides complex math functions
+import cmath
from numpy import cos, sin, pi, matrix
import numpy as npy
import numpy.linalg as linalg
from pylab import figure, show
+
def myeig(M):
"""
compute eigen values and eigenvectors analytically
+
Solve quadratic:
+
lamba^2 - tau*lambda + Delta = 0
+
where tau = trace(M) and Delta = Determinant(M)
+
+ """
- Return value is lambda1, lambda2
- """
- XXX
+ a,b = M[0,0], M[0,1]
+ c,d = M[1,0], M[1,1]
+ tau = a+d # the trace
+ delta = a*d-b*c # the determinant
+
+ lambda1 = (tau + cmath.sqrt(tau**2 - 4*delta))/2.
+ lambda2 = (tau - cmath.sqrt(tau**2 - 4*delta))/2.
+ return lambda1, lambda2
# 2000 random x,y points in the interval[-0.5 ... 0.5]
-X1 = XXX
+X1 = matrix(npy.random.rand(2,2000)
+ )-0.5
name = 'saddle'
-#sx, sy, angle = XXX
+sx, sy, angle = 1.05, 0.95, 0.
#name = 'center'
-#sx, sy, angle = XXX
+#sx, sy, angle = 1., 1., 2.5
-name = 'spiral' #stable focus
-sx, sy, angle = XXX
+#name= 'stable focus' # spiral
+#sx, sy, angle = 0.95, 0.95, 2.5
-theta = angle * pi/180. # the rotation in radians
+theta = angle * pi/180.
-# the scaling matrix
-# | sx 0 |
-# | 0 sy |
-S = XXX
+S = matrix([[sx, 0],
+ [0, sy]])
-# the rotation matrix
-# | cos(theta) -sin(theta) |
-# | sin(theta) cos(theta) |
-R = XXX
+R = matrix([[cos(theta), -sin(theta)],
+ [sin(theta), cos(theta)],])
-# the transformation is the matrix product of the scaling and rotation
-M = XXX
+M = S*R # rotate then stretch
# compute the eigenvalues using numpy linear algebra
-print 'numpy eigenvalues', XXX
+vals, vecs = linalg.eig(M)
+print 'numpy eigenvalues', vals
# compare with the analytic values from myeig
-print 'analytic eigenvalues', myeig(M)
+avals = myeig(M)
+print 'analytic eigenvalues', avals
-# transform X1 by the matrix M
-X2 = XXX
+# transform X1 by the matrix
+X2 = M*X1
-# plot the original X1 as green dots and the transformed X2 as red
+# plot the original x,y as green dots and the transformed x, y as red
# dots
-XXX
+fig = figure()
+ax = fig.add_subplot(111)
+
+x1 = X1[0].flat
+y1 = X1[1].flat
+x2 = X2[0].flat
+y2 = X2[1].flat
+
+ax = fig.add_subplot(111)
+line1, line2 = ax.plot(x1, y1, 'go', x2, y2, 'ro', markersize=2)
+ax.set_title(name)
+
+
+fig.savefig('glass_dots1.png', dpi=100)
+fig.savefig('glass_dots1.eps', dpi=100)
+show()
Modified: trunk/py4science/examples/skel/lotka_volterra_skel.py
===================================================================
--- trunk/py4science/examples/skel/lotka_volterra_skel.py 2008-10-19 07:38:45 UTC (rev 6268)
+++ trunk/py4science/examples/skel/lotka_volterra_skel.py 2008-10-19 07:48:51 UTC (rev 6269)
@@ -3,19 +3,22 @@
import scipy.integrate as integrate
def dr(r, f):
- 'return delta r'
- XXX
+ return alpha*r - beta*r*f
def df(r, f):
- 'return delta f'
- XXX
+ return gamma*r*f - delta*f
+
def derivs(state, t):
"""
Map the state variable [rabbits, foxes] to the derivitives
[deltar, deltaf] at time t
"""
- XXX
-
+ #print t, state
+ r, f = state # rabbits and foxes
+ deltar = dr(r, f) # change in rabbits
+ deltaf = df(r, f) # change in foxes
+ return deltar, deltaf
+
alpha, delta = 1, .25
beta, gamma = .2, .05
@@ -23,34 +26,53 @@
r0 = 20
f0 = 10
-t = XXX # pick a time vector (think about the time scales!)
-y0 = [r0, f0] # the initial [rabbits, foxes] state vector
-y = XXX # integrate derives over t starting at y0
-r = XXX # extract the rabbits vector
-f = XXX # extract the foxes vector
+t = n.arange(0.0, 100, 0.1)
+y0 = [r0, f0] # the initial [rabbits, foxes] state vector
+y = integrate.odeint(derivs, y0, t)
+r = y[:,0] # extract the rabbits vector
+f = y[:,1] # extract the foxes vector
-# FIGURE 1: rabbits vs time and foxes vs time on the same plot with
-# legend and xlabel, ylabel and title
+p.figure()
+p.plot(t, r, label='rabbits')
+p.plot(t, f, label='foxes')
+p.xlabel('time (years)')
+p.ylabel('population')
+p.title('population trajectories')
+p.grid()
+p.legend()
+p.savefig('lotka_volterra.png', dpi=150)
+p.savefig('lotka_volterra.eps')
-# FIGURE 2: the phase plane
-# plot r vs f and label the x and y axes
-XXX
+p.figure()
+p.plot(r, f, color='red')
+p.xlabel('rabbits')
+p.ylabel('foxes')
+p.title('phase plane')
-# FIGURE 2 continued....
-# use meshgrid to make a grid over R and F
-# with a coarse 1 year sampling. evaluate dR and dF over the 2 s
-# grids and make a quiver plot. See pylab.quiver and matplotlib
-# examples/quiver_demo.py
-XXX
+# make a direction field plot with quiver
+rmax = 1.1 * r.max()
+fmax = 1.1 * f.max()
+R, F = n.meshgrid(n.arange(-1, rmax), n.arange(-1, fmax))
+dR = dr(R, F)
+dF = df(R, F)
+p.quiver(R, F, dR, dF)
-# FIGURE 2 continued... use contour to compute the null clines over
-# dR (the rabbits null cline) and dF (the foxes null cline). You will
-# need to do a finer meshgrid for accurate null clins and pass
-# levels=[0] to contour
-XXX
+R, F = n.meshgrid(n.arange(-1, rmax, .1), n.arange(-1, fmax, .1))
+dR = dr(R, F)
+dF = df(R, F)
+
+p.contour(R, F, dR, levels=[0], linewidths=3, colors='blue')
+p.contour(R, F, dF, levels=[0], linewidths=3, colors='green')
+p.ylabel('foxes')
+p.title('trajectory, direction field and null clines')
+
+p.savefig('lotka_volterra_pplane.png', dpi=150)
+p.savefig('lotka_volterra_pplane.eps')
+
+
p.show()
Modified: trunk/py4science/examples/skel/noisy_sine_skel.py
===================================================================
--- trunk/py4science/examples/skel/noisy_sine_skel.py 2008-10-19 07:38:45 UTC (rev 6268)
+++ trunk/py4science/examples/skel/noisy_sine_skel.py 2008-10-19 07:48:51 UTC (rev 6269)
@@ -5,18 +5,21 @@
f = 10 # 10 Hz frequency
sigma = 0.5 # 0.5 volt standard deviation noise
-# create the t and v arrays; see the scipy commands arange, sin, and randn
-t = XXX # an evenly sampled time array
-v = XXX # a noisy sine wave
+# create the t and v and store them a 2D array X
+t = arange(0.0, 2.0, 0.02) # an evenly sampled time array
+v = a*sin(2*f*pi*t) + sigma*randn(len(t)) # a noisy sine wave
+X = zeros((len(t),2)) # an empty output array
+X[:,0] = t # add t to the first column
+X[:,1] = v # add s to the 2nd column
+p.save('data/noisy_sine.dat', X) # save the output file as ASCII
-# create a 2D array X and put t in the 1st column and v in the 2nd;
-# see the numpy command zeros
-X = XXX
-
-# save the output file as ASCII; see the pylab command save
-XXX
-
-# plot the arrays t vs v and label the x-axis, y-axis and title save
-# the output figure as noisy_sine.png. See the pylab commands plot,
-# xlabel, ylabel, grid, show
-XXX
+# plot the arrays t vs v and label the x-axis, y-axis and title
+# save the output figure as noisy_sine.png
+p.plot(t, v, 'b-')
+p.xlabel('time (s)')
+p.ylabel('volts (V)')
+p.title('A noisy sine wave')
+p.grid()
+p.savefig('noisy_sine.png', dpi=150)
+p.savefig('noisy_sine.eps')
+p.show()
Modified: trunk/py4science/examples/skel/qsort_skel.py
===================================================================
--- trunk/py4science/examples/skel/qsort_skel.py 2008-10-19 07:38:45 UTC (rev 6268)
+++ trunk/py4science/examples/skel/qsort_skel.py 2008-10-19 07:48:51 UTC (rev 6269)
@@ -1,29 +1,58 @@
"""Simple quicksort implementation.
-From http://en.wikipedia.org/wiki/Quicksort:
+From http://en.wikipedia.org/wiki/Quicksort we have this pseudocode (see also
+the C implementation for comparison).
+Note: what follows is NOT python code, it's meant to only illustrate the
+algorithm for you. Below you'll need to actually implement it in real Python.
+You may be surprised at how close a working Python implementation can be to
+this pseudocode.
+
+
function quicksort(array)
var list less, greater
- if length(array) ≤ 1
+ if length(array) <= 1
return array
select and remove a pivot value pivot from array
for each x in array
- if x ≤ pivot then append x to less
+ if x <= pivot then append x to less
else append x to greater
return concatenate(quicksort(less), pivot, quicksort(greater))
"""
def qsort(lst):
- """Return a sorted copy of the input list."""
+ """Return a sorted copy of the input list.
- raise NotImplementedError
+ Input:
+ lst : a list of elements which can be compared.
+
+ Examples:
+
+ >>> qsort([])
+ []
+
+ >>> qsort([3,2,5])
+ [2, 3, 5]
+ """
+
+ # Hint: remember that all recursive functions need an exit condition
+ raise NotImplementedError('insert missing code here')
+
+ # Select pivot and apply recursively
+ raise NotImplementedError('insert missing code here')
+
+ # Upon return, make sure to properly concatenate the output lists
+ raise NotImplementedError('insert missing code here')
+
+
#-----------------------------------------------------------------------------
# Tests
#-----------------------------------------------------------------------------
import random
-import nose.tools as nt
+import nose
+import nose, nose.tools as nt
def test_sorted():
seq = range(10)
@@ -37,9 +66,8 @@
sseq = qsort(rseq)
nt.assert_equal(tseq,sseq)
+# If called from the command line, run all the tests
if __name__ == '__main__':
- # From the command line, run the test suite
- import nose
# This call form is ipython-friendly
nose.runmodule(argv=['-s','--with-doctest'],
exit=False)
Modified: trunk/py4science/examples/skel/quad_newton_skel.py
===================================================================
--- trunk/py4science/examples/skel/quad_newton_skel.py 2008-10-19 07:38:45 UTC (rev 6268)
+++ trunk/py4science/examples/skel/quad_newton_skel.py 2008-10-19 07:48:51 UTC (rev 6269)
@@ -4,23 +4,36 @@
from math import sin
-import scipy, scipy.integrate, scipy.optimize
+from scipy.integrate import quad
+from scipy.optimize import newton
-quad = scipy.integrate.quad
-newton = scipy.optimize.newton
+# test input function
+def f(t):
+ # f(t): t * sin^2(t)
+ raise NotImplementedError('insert missing code here')
-# test input function f(t): t * sin^2(t)
-def f(t): XXX
+def g(t):
+ "Exact form for g by integrating f(t)"
+ u = 0.25
+ return .25*(t**2-t*sin(2*t)+(sin(t))**2)-u
-# Use u=0.25
-def g(t): XXX
+def gn(t):
+ "g(t) obtained by numerical integration"
+ u = 0.25
+ # Hint: use quad, see its return value carefully.
+ raise NotImplementedError('insert missing code here')
# main
tguess = 10.0
-print "Solution using the numerical integration technique"
-t0 = newton(g,tguess,f)
+print '"Exact" solution (knowing the analytical form of the integral)'
+raise NotImplementedError('insert missing code here')
print "t0, g(t0) =",t0,g(t0)
print
+print "Solution using the numerical integration technique"
+raise NotImplementedError('insert missing code here')
+print "t1, g(t1) =",t1,g(t1)
+
+print
print "To six digits, the answer in this case is t==1.06601."
Modified: trunk/py4science/examples/skel/stats_descriptives_skel.py
===================================================================
--- trunk/py4science/examples/skel/stats_descriptives_skel.py 2008-10-19 07:38:45 UTC (rev 6268)
+++ trunk/py4science/examples/skel/stats_descriptives_skel.py 2008-10-19 07:48:51 UTC (rev 6269)
@@ -4,7 +4,6 @@
import numpy
import pylab
-XXX = None
class Descriptives:
"""
@@ -12,16 +11,16 @@
"""
def __init__(self, samples):
self.samples = numpy.asarray(samples)
- self.N = XXX # the number of samples
- self.median = XXX # sample median
- self.min = XXX # sample min
- self.max = XXX # sample max
- self.mean = XXX # sample mean
- self.std = XXX # sample standard deviation
- self.var = XXX # sample variance
- self.skew = XXX # the sample skewness
- self.kurtosis = XXX # the sample kurtosis
- self.range = XXX # the sample range max-min
+ self.N = len(samples)
+ self.median = stats.median(samples)
+ self.min = numpy.amin(samples)
+ self.max = numpy.amax(samples)
+ self.mean = stats.mean(samples)
+ self.std = stats.std(samples)
+ self.var = self.std**2.
+ self.skew = stats.skew(samples)
+ self.kurtosis = stats.kurtosis(samples)
+ self.range = self.max - self.min
def __repr__(self):
"""
@@ -33,11 +32,20 @@
descriptives = (
'N = %d' % self.N,
- XXX # the rest here
- )
+ 'Mean = %1.4f' % self.mean,
+ 'Median = %1.4f' % self.median,
+ 'Min = %1.4f' % self.min,
+ 'Max = %1.4f' % self.max,
+ 'Range = %1.4f' % self.range,
+ 'Std = %1.4f' % self.std,
+ 'Skew = %1.4f' % self.skew,
+ 'Kurtosis = %1.4f' % self.kurtosis,
+ )
return '\n'.join(descriptives)
- def plots(self, figfunc, maxlags=20, Fs=1, detrend=detrend_linear, fmt='bo'):
+ def plots(self, figfunc, maxlags=20, Fs=1, detrend=detrend_linear,
+ fmt='bo', bins=100,
+ ):
"""
plots the time series, histogram, autocorrelation and spectrogram
@@ -56,10 +64,11 @@
maxlags : max number of lags for the autocorr
- detrend : a function used to detrend the data for the
- correlation and spectral functions
+ detrend : a function used to detrend the data for the correlation and spectral functions
fmt : the plot format string
+
+ bins : the bins argument to hist
"""
data = self.samples
@@ -79,12 +88,27 @@
c = C()
N = 5
fig = c.fig = figfunc()
+ fig.subplots_adjust(hspace=0.3)
ax = c.ax1 = fig.add_subplot(N,1,1)
c.plot = ax.plot(data, fmt)
+ ax.set_ylabel('data')
- # XXX the rest of the plot funtions here
+ ax = c.ax2 = fig.add_subplot(N,1,2)
+ c.hist = ax.hist(data, bins)
+ ax.set_ylabel('hist')
-
+ ax = c.ax3 = fig.add_subplot(N,1,3)
+ c.acorr = ax.acorr(data, detrend=detrend, usevlines=True,
+ maxlags=maxlags, normed=True)
+ ax.set_ylabel('acorr')
+
+ ax = c.ax4 = fig.add_subplot(N,1,4)
+ c.psd = ax.psd(data, Fs=Fs, detrend=detrend)
+ ax.set_ylabel('psd')
+
+ ax = c.ax5 = fig.add_subplot(N,1,5)
+ c.specgtram = ax.specgram(data, Fs=Fs, detrend=detrend)
+ ax.set_ylabel('specgram')
return c
@@ -94,15 +118,20 @@
# list of floating point values, one value per line. Note you
# will have to do some extra parsing
data = []
- #fname = 'data/nm560.dat' # tree rings in New Mexico 837-1987
+ fname = 'data/nm560.dat' # tree rings in New Mexico 837-1987
fname = 'data/hsales.dat' # home sales
for line in file(fname):
line = line.strip()
if not line: continue
- # XXX convert to float and add to data here
-
+ vals = line.split()
+ val = vals[0]
+ data.append(float(val))
+
desc = Descriptives(data)
print desc
- c = desc.plots(pylab.figure, Fs=12, fmt='-o')
+ c = desc.plots(pylab.figure, Fs=12, fmt='-')
c.ax1.set_title(fname)
+
+ c.fig.savefig('stats_descriptives.png', dpi=150)
+ c.fig.savefig('stats_descriptives.eps')
pylab.show()
Modified: trunk/py4science/examples/skel/stats_distributions_skel.py
===================================================================
--- trunk/py4science/examples/skel/stats_distributions_skel.py 2008-10-19 07:38:45 UTC (rev 6268)
+++ trunk/py4science/examples/skel/stats_distributions_skel.py 2008-10-19 07:48:51 UTC (rev 6269)
@@ -13,8 +13,8 @@
# a uniform distribution from scipy.stats.uniform and use the "rvs"
# method to generate N uniform random variates
N = 100000
-uniform = XXX # the frozen uniform distribution
-uninse = XXX # the random variates
+uniform = scipy.stats.uniform() # the frozen uniform distribution
+uninse = uniform.rvs(N) # the random variates
# in each time interval, the probability of an emission
rate = 20. # the emission rate in Hz
@@ -22,10 +22,10 @@
t = numpy.arange(N)*dx # the time vector
# the probability of an emission is proportionate to the rate and the interval
-emit_times = XXX
+emit_times = t[uninse < rate*dx]
# the difference in the emission times is the wait time
-wait_times = XXX
+wait_times = numpy.diff(emit_times)
# plot the distribution of waiting times and the expected exponential
# density function lambda exp( lambda wt) where lambda is the rate
@@ -35,26 +35,34 @@
# 1/lambda. Plot all three on the same graph and make a legend.
# Decorate your graphs with an xlabel, ylabel and title
fig = figure()
-ax = fig.add_subplot(111)
-p, bins, patches = XXX # use ax.hist
-l1, = ax.plot(bins, XXX, lw=2, color='red') # the analytic result
-l2, = ax.plot(bins, XXX, # use scipy.stats.expon.pdf
+ax = fig.add_subplot(311)
+p, bins, patches = ax.hist(wait_times, 100, normed=True)
+l1, = ax.plot(bins, rate*numpy.exp(-rate * bins), lw=2, color='red')
+l2, = ax.plot(bins, scipy.stats.expon.pdf(bins, 0, 1./rate),
lw=2, ls='--', color='green')
-ax.set_xlabel('waiting time')
+
ax.set_ylabel('PDF')
-ax.set_title('waiting time density of a %dHz Poisson emitter'%rate)
-ax.legend(XXX, XXX) # create the proper legend
+ax.set_title('waiting time densities of a %dHz Poisson emitter'%rate)
+ax.text(0.05, 0.9, 'one interval', transform=ax.transAxes)
+ax.legend((patches[0], l1, l2), ('simulated', 'analytic', 'scipy.stats.expon'))
-
# plot the distribution of waiting times for two events; the
# distribution of waiting times for N events should equal a N-th order
# gamma distribution (the exponential distribution is a 1st order
# gamma distribution. Use scipy.stats.gamma to compare the fits.
# Hint: you can stride your emission times array to get every 2nd
# emission
-XXX
+wait_times2 = numpy.diff(emit_times[::2])
+ax = fig.add_subplot(312)
+p, bins, patches = ax.hist(wait_times2, 100, normed=True)
+l1, = ax.plot(bins, scipy.stats.gamma.pdf(bins, 2, 0, 1./rate),
+ lw=2, ls='-', color='red')
+ax.set_ylabel('PDF')
+ax.text(0.05, 0.9, 'two intervals', transform=ax.transAxes)
+ax.legend((patches[0], l1), ('simulated', 'scipy.stats.gamma'))
+
# plot the distribution of waiting times for 10 events; again the
# distribution will be a 10th order gamma distribution so plot that
# along with the empirical density. The central limit thm says that
@@ -67,7 +75,24 @@
# get the normal distribution. Note that the scale parameter of the
# normal is the standard deviation which is the square root of the
# variance
-XXX
+expon_mean, expon_var = scipy.stats.expon(0, 1./rate).stats()
+mu, var = 10*expon_mean, 10*expon_var
+sigma = numpy.sqrt(var)
+wait_times10 = numpy.diff(emit_times[::10])
+ax = fig.add_subplot(313)
+p, bins, patches = ax.hist(wait_times10, 100, normed=True)
+l1, = ax.plot(bins, scipy.stats.gamma.pdf(bins, 10, 0, 1./rate),
+ lw=2, ls='-', color='red')
+l2, = ax.plot(bins, scipy.stats.norm.pdf(bins, mu, sigma),
+ lw=2, ls='--', color='green')
+ax.set_xlabel('waiting times')
+ax.set_ylabel('PDF')
+ax.text(0.1, 0.9, 'ten intervals', transform=ax.transAxes)
+ax.legend((patches[0], l1, l2), ('simulated', 'scipy.stats.gamma', 'normal approx'))
+fig.savefig('stats_distributions.png', dpi=150)
+fig.savefig('stats_distributions.eps')
+
+
show()
Modified: trunk/py4science/examples/skel/stock_records_skel.py
===================================================================
--- trunk/py4science/examples/skel/stock_records_skel.py 2008-10-19 07:38:45 UTC (rev 6268)
+++ trunk/py4science/examples/skel/stock_records_skel.py 2008-10-19 07:48:51 UTC (rev 6269)
@@ -22,26 +22,25 @@
system before re-downloading it
"""
fname = '%s.csv'%ticker
- url = XXX # create the url for this ticker
+ url = 'http://ichart.finance.yahoo.com/table.csv?' +\
+ 's=%s&d=9&e=20&f=2007&g=d&a=0&b=29&c=1993&ignore=.csv'%ticker
# the os.path module contains function for checking whether a file
- # exists, and fetch it if not
- XXX
+ # exists
+ if not os.path.exists(fname):
+ urllib.urlretrieve(url, fname)
+ r = mlab.csv2rec(fname)
- # load the CSV file intoo a numpy record array
- r = XXX
-
# note that the CSV file is sorted most recent date first, so you
# will probably want to sort the record array so most recent date
# is last
- XXX
+ r.sort()
return r
-tickers = 'INTC', 'MSFT', 'YHOO', 'GOOG', 'GE', 'WMT', 'AAPL'
+tickers = 'SPY', 'QQQQ', 'INTC', 'MSFT', 'YHOO', 'GOOG', 'GE', 'WMT', 'AAPL'
-# we want to compute returns since 2003, so define the start date as a
-# datetime.datetime instance
-startdate = XXX
+# we want to compute returns since 2003, so define the start date
+startdate = datetime.date(2003,1,1)
# we'll store a list of each return and ticker for analysis later
data = [] # a list of (return, ticker) for each stock
@@ -50,22 +49,24 @@
print 'fetching', ticker
r = fetch_stock(ticker)
- # select the numpy records where r.date>=startdatre use numpy mask
- # indexing to restrict r to just the dates > startdate
- r = XXX
- price = XXX # set price equal to the adjusted close
- returns = XXX # return is the (price-p0)/p0
- XXX # store the data
+ # select the numpy records where r.date>=startdatre
- # plot the returns by date for each stock using pylab.plot, adding
- # a label for the legend
- XXX
+ r = r[r.date>=startdate]
+ price = r.adj_close # set price equal to the adjusted close
+ returns = (price-price[0])/price[0] # return is the (price-p0)/p0
+ data.append((returns[-1], ticker)) # store the data
-# use pylab legend command to build a legend
-XXX
+ # plot the returns by date for each stock
+ p.plot(r.date, returns, label=ticker)
+p.legend(loc='upper left')
+
# now sort the data by returns and print the results for each stock
-XXX
+data.sort()
+for g, ticker in data:
+ print '%s: %1.1f%%'%(ticker, 100*g)
-# show the figures
+
+p.savefig('stock_records.png', dpi=100)
+p.savefig('stock_records.eps')
p.show()
Modified: trunk/py4science/examples/skel/trapezoid_skel.py
===================================================================
--- trunk/py4science/examples/skel/trapezoid_skel.py 2008-10-19 07:38:45 UTC (rev 6268)
+++ trunk/py4science/examples/skel/trapezoid_skel.py 2008-10-19 07:48:51 UTC (rev 6269)
@@ -1,13 +1,14 @@
#!/usr/bin/env python
"""Simple trapezoid-rule integrator."""
-import numpy as N
+import numpy as np
def trapz(x, y):
"""Simple trapezoid integrator for sequence-based innput.
Inputs:
- - x,y: arrays of the same length.
+ - x,y: arrays of the same length (and more than one element). If the two
+ inputs have different lengths, a ValueError exception is raised.
Output:
- The result of applying the trapezoid rule to the input, assuming that
@@ -15,8 +16,17 @@
Minimally modified from matplotlib.mlab."""
- raise NotImplementedError
+ # Sanity checks.
+ #
+ # Hint: if the two inputs have mismatched lengths or less than 2
+ # elements, we raise ValueError with an explanatory message.
+ raise NotImplementedError('insert missing code here')
+ # Efficient application of trapezoid rule via numpy
+ #
+ # Hint: think of using numpy slicing to compute the moving difference in
+ # the basic trapezoid formula.
+ raise NotImplementedError('insert missing code here')
def trapzf(f,a,b,npts=100):
"""Simple trapezoid-based integrator.
@@ -33,33 +43,52 @@
Output:
- The value of the trapezoid-rule approximation to the integral."""
- # you will need to apply the function f to easch element of the
- # vector x. What are several ways to do this? Can you profile
- # them to see what differences in timings result for long vectors
- # x?
- raise NotImplementedError
+ # Hint: you will need to apply the function f to easch element of the
+ # vector x. What are several ways to do this? Can you profile them to see
+ # what differences in timings result for long vectors x?
+ # Generate an equally spaced grid to sample the function.
+ raise NotImplementedError('insert missing code here')
+ # For an equispaced grid, the x spacing can just be read off from the first
+ # two points and factored out of the summation.
+ raise NotImplementedError('insert missing code here')
+
+ # Sample the input function at all values of x
+ #
+ # Hint: you need to make an array out of the evaluations, and the python
+ # builtin 'map' function can come in handy.
+ raise NotImplementedError('insert missing code here')
+
+ # Compute the trapezoid rule sum for the final result
+ raise NotImplementedError('insert missing code here')
+
+
#-----------------------------------------------------------------------------
# Tests
#-----------------------------------------------------------------------------
import nose, nose.tools as nt
import numpy.testing as nptest
+# A simple function for testing
def square(x): return x**2
def test_err():
+ """Test that mismatched inputs raise a ValueError exception."""
nt.assert_raises(ValueError,trapz,range(2),range(3))
def test_call():
+ "Test a direct call with equally spaced samples. "
x = np.linspace(0,1,100)
y = np.array(map(square,x))
nptest.assert_almost_equal(trapz(x,y),1./3,4)
def test_square():
+ "Test integrating the square() function."
nptest.assert_almost_equal(trapzf(square,0,1),1./3,4)
def test_square2():
+ "Another test integrating the square() function."
nptest.assert_almost_equal(trapzf(square,0,3,350),9.0,4)
Modified: trunk/py4science/examples/skel/wallis_pi_skel.py
===================================================================
--- trunk/py4science/examples/skel/wallis_pi_skel.py 2008-10-19 07:38:45 UTC (rev 6268)
+++ trunk/py4science/examples/skel/wallis_pi_skel.py 2008-10-19 07:48:51 UTC (rev 6269)
@@ -6,19 +6,72 @@
# in floating point.
from __future__ import division
-from decimal import Decimal
+def pi(n):
+ """Compute pi using n terms of Wallis' product.
-XXX = None # a sentinel for missing pieces
+ Wallis' formula approximates pi as
-def pi(n):
+ pi(n) = 2 \prod_{i=1}^{n}\frac{4i^2}{4i^2-1}."""
+
+ num = 1
+ den = 1
+ for i in xrange(1,n+1):
+ tmp = 4*i*i
+ num *= tmp
+ den *= tmp-1
+ return 2.0*(num/den)
+
+def part_range(n1,n2,nchunks):
+ """Partition a range specification in nchunks"""
+ size,rem = divmod(n2-n1,nchunks)
+ sizes = [size]*nchunks
+ while rem > 0:
+ for i in range(nchunks):
+ sizes[i] += 1
+ rem -= 1
+ if rem == 0:
+ break
+
+ # The sizes list has the offsets, now we need the actual start,stop pairs
+ ranges = []
+ start=n1
+ for size in sizes:
+ ranges.append((start,start+size))
+ start += size
+ return ranges
+
+def wpi_nd(range_spec):
"""Compute pi using n terms of Wallis' product.
Wallis' formula approximates pi as
pi(n) = 2 \prod_{i=1}^{n}\frac{4i^2}{4i^2-1}."""
- raise NotImplementedError
+ n1,n2 = range_spec
+ num = 1
+ den = 1
+ for i in xrange(n1,n2):
+ tmp = 4*i*i
+ num *= tmp
+ den *= tmp-1
+
+ return num,den
+
+def par_pi(n,num_engines=1):
+ """Compute pi using n terms of Wallis' product.
+
+ Wallis' formula approximates pi as
+
+ pi(n) = 2 \prod_{i=1}^{n}\frac{4i^2}{4i^2-1}.
+
+ Parallel version."""
+
+ num,den = reduce(lambda x,y:(x[0]*y[0],x[1]*y[1]),
+ map(wpi_nd,part_range(1,n+1,num_engines)))
+ return 2.0*(num/den)
+
+
# This part only executes when the code is run as a script, not when it is
# imported as a library
if __name__ == '__main__':
@@ -29,13 +82,12 @@
import numpy as N
# Create a list of points 'nrange' where we'll compute Wallis' formula
- nrange = XXX
-
+ nrange = N.linspace(10,2000,20).astype(int)
# Make an array of such values
- wpi = XXX
+ wpi = N.array(map(pi,nrange))
# Compute the difference against the value of pi in numpy (standard
# 16-digit value)
- diff = XXX
+ diff = abs(wpi-N.pi)
# Make a new figure and build a semilog plot of the difference so we can
# see the quality of the convergence
@@ -45,9 +97,9 @@
P.semilogy(nrange,diff,'-o',mfc='red')
# A bit of labeling and a grid
- P.title(r"Convergence of Wallis' product formula for pi")
+ P.title(r"Convergence of Wallis' product formula for $\pi$")
P.xlabel('Number of terms')
- P.ylabel(r'|Error}|')
+ P.ylabel(r'Absolute Error')
P.grid()
# Display the actual plot
Modified: trunk/py4science/examples/skel/wordfreqs_skel.py
===================================================================
--- trunk/py4science/examples/skel/wordfreqs_skel.py 2008-10-19 07:38:45 UTC (rev 6268)
+++ trunk/py4science/examples/skel/wordfreqs_skel.py 2008-10-19 07:48:51 UTC (rev 6269)
@@ -1,27 +1,27 @@
#!/usr/bin/env python
"""Word frequencies - count word frequencies in a string."""
-XXX = None # a sentinel for missing pieces
-
def word_freq(text):
"""Return a dictionary of word frequencies for the given text."""
- # you need to write this
- return XXX
+ freqs = {}
+ for word in text.split():
+ freqs[word] = freqs.get(word, 0) + 1
+ return freqs
def print_vk(lst):
"""Print a list of value/key pairs nicely formatted in key/value order."""
# Find the longest key: remember, the list has value/key paris, so the key
# is element [1], not [0]
- longest_key = max(map(lambda x: len(x[1]),lst))
+ #longest_key = max(map(lambda x: len(x[1]),lst))
+ longest_key = max([len(word) for count, word in lst])
# Make a format string out of it
fmt = '%'+str(longest_key)+'s -> %s'
# Do actual printing
for v,k in lst:
print fmt % (k,v)
-
def freq_summ(freqs,n=10):
"""Print a simple summary of a word frequencies dictionary.
@@ -29,12 +29,12 @@
- freqs: a dictionary of word frequencies.
Optional inputs:
- - n: the number of items to print"""
+ - n: the number of """
- words,counts = XXX # look at the keys and values methods of dicts
+ words,counts = freqs.keys(),freqs.values()
# Sort by count
-
- items = XXX # think of a list, look at zip() and think of sort()
+ items = zip(counts,words)
+ items.sort()
print 'Number of words:',len(freqs)
print
@@ -44,12 +44,8 @@
print '%d most frequent words:' % n
print_vk(items[-n:])
-
if __name__ == '__main__':
- # You need to read the contents of the file HISTORY.gz and store it in the
- # variable named 'text'. Do NOT unzip it manually, look at the gzip module
- # from the standard library and the read() method of file objects.
- text = XXX
-
+ import gzip
+ text = gzip.open('data/HISTORY.gz').read()
freqs = word_freq(text)
freq_summ(freqs,20)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fer...@us...> - 2008-10-19 07:38:55
|
Revision: 6268
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6268&view=rev
Author: fer_perez
Date: 2008-10-19 07:38:45 +0000 (Sun, 19 Oct 2008)
Log Message:
-----------
py4science: tools cleanup
Added Paths:
-----------
trunk/py4science/tools/workshop_checklist.py
Removed Paths:
-------------
trunk/py4science/classes/workshop_checklist.py
trunk/py4science/tools/course_checklist.py
trunk/py4science/tools/course_checklist_umich.py
Deleted: trunk/py4science/classes/workshop_checklist.py
===================================================================
--- trunk/py4science/classes/workshop_checklist.py 2008-10-19 07:36:39 UTC (rev 6267)
+++ trunk/py4science/classes/workshop_checklist.py 2008-10-19 07:38:45 UTC (rev 6268)
@@ -1,178 +0,0 @@
-#!/usr/bin/env python
-"""Minimal test script to check for modules needed in python workshop.
-
-Execute this code at the command line by typing:
-
-python workshop_checklist.py
-
-If it does NOT say 'OK' at the end, copy the *entire* output of the run and
-send it to the course instructor for help.
-"""
-
-# Standard library imports
-import glob
-import os
-import platform
-import sys
-
-from StringIO import StringIO
-
-# Third-party imports
-import nose
-import nose.tools as nt
-
-##############################################################################
-# Code begins
-
-#-----------------------------------------------------------------------------
-# Generic utility functions
-def sys_info():
- """Summarize some info about the system"""
-
- print '=================='
- print 'System information'
- print '=================='
- print 'os.name :',os.name
- print 'os.uname :',os.uname()
- print 'platform :',sys.platform
- print 'platform+ :',platform.platform()
- print 'prefix :',sys.prefix
- print 'exec_prefix :',sys.exec_prefix
- print 'executable :',sys.executable
- print 'version_info :',sys.version_info
- print 'version :',sys.version
- print '=================='
-
-
-#-----------------------------------------------------------------------------
-# Tests
-
-def check_import(mname):
- "Check that the given name imports correctly"
- exec "import %s as m" % mname
-
- if mname == 'matplotlib':
- m.use('Agg')
- m.rcParams['figure.subplot.top']= 0.85
-
- try:
- vinfo = m.__version__
- except AttributeError:
- vinfo = '*no info*'
-
- print 'MOD: %s, version: %s' % (mname,vinfo)
-
-
-# Test generators are best written without docstrings, because nose can then
-# show the parameters being used.
-def test_imports():
- modules = ['setuptools',
- 'IPython',
- 'numpy','scipy','scipy.weave','scipy.io',
- 'matplotlib','pylab',
- 'nose',
- #'Cython', # disabled for now, not included in EPD Beta2
- ]
-
- for mname in modules:
- yield check_import,mname
-
-
-def test_weave():
- "Simple code compilation and execution via scipy's weave"
- from scipy import weave
-
- weave.inline('int x=1;x++;')
-
- n,m=1,2
- code="""
- int m=%s;
- return_val=m+n;
- """ % m
- val = weave.inline(code,['n'])
- nt.assert_equal(val,m+n)
-
-
-def est_numpy_all():
- "Run the entire numpy test suite"
- import numpy
- numpy.test()
-
-
-# Test generator, don't put a docstring in it
-def test_loadtxt():
- import numpy as np
- import numpy.testing as npt
-
- # Examples taken from the loadtxt docstring
- array = np.array
-
- c = StringIO("0 1\n2 3")
- a1 = np.loadtxt(c)
- a2 = np.array([[ 0., 1.],
- [ 2., 3.]])
- yield npt.assert_array_equal,a1,a2
-
- d = StringIO("M 21 72\nF 35 58")
- a1 = np.loadtxt(d, dtype={'names': ('gender', 'age', 'weight'),
- 'formats': ('S1', 'i4', 'f4')})
-
- a2 = np.array([('M', 21, 72.0), ('F', 35, 58.0)],
- dtype=[('gender', '|S1'), ('age', '<i4'), ('weight', '<f4')])
- yield npt.assert_array_equal,a1,a2
-
- c = StringIO("1,0,2\n3,0,4")
- x,y = np.loadtxt(c, delimiter=',', usecols=(0,2), unpack=True)
- yield npt.assert_array_equal,x,np.array([ 1., 3.])
- yield npt.assert_array_equal,y,np.array([ 2., 4.])
-
-
-def test_plot():
- "Simple plot generation."
- from matplotlib import pyplot as plt
- plt.figure()
- plt.plot([1,2,3])
- plt.xlabel('some numbers')
- plt.savefig('tmp_test_plot.png')
-
-
-def test_plot_math():
- "Plots with math"
- from matplotlib import pyplot as plt
- plt.figure()
- plt.plot([1,2,3],label='data')
- t=(r'And X is $\sum_{i=0}^\infty \gamma_i + \frac{\alpha^{i^2}}{\gamma}'
- r'+ \cos(2 \theta^2)$')
- plt.title(t)
- plt.legend()
- plt.grid()
- plt.savefig('tmp_test_plot_math.png')
-
-
-def cleanup_pngs():
- """Remove temporary pngs made by our plotting tests"""
-
- for f in glob.glob('tmp_test_*.png'):
- try:
- os.remove(f)
- except OSError:
- print '*** Error: could not remove file',f
-
-
-#-----------------------------------------------------------------------------
-# Main routine, executed when this file is run as a script
-#
-if __name__ == '__main__':
- print "Running tests:"
- # This call form is ipython-friendly
- nose.runmodule(argv=[__file__,'-vvs'],
- exit=False)
- print """
-***************************************************************************
- TESTS FINISHED
-***************************************************************************
-
-If the printout above did not finish in 'OK' but instead says 'FAILED', copy
-and send the *entire* output to the instructor for help.
-"""
- sys_info()
Deleted: trunk/py4science/tools/course_checklist.py
===================================================================
--- trunk/py4science/tools/course_checklist.py 2008-10-19 07:36:39 UTC (rev 6267)
+++ trunk/py4science/tools/course_checklist.py 2008-10-19 07:38:45 UTC (rev 6268)
@@ -1,15 +0,0 @@
-#!/usr/bin/env python
-"""Minimal test script to check for modules needed in python course"""
-
-modules = ['numpy','scipy','matplotlib','IPython','mayavi','pyvtk','Image',
- 'visual']
-
-for mname in modules:
- try:
- exec "import %s" % mname
- except ImportError:
- print '*** ERROR: module %s could not be imported.' % mname
- else:
- print '%s: OK' % mname
-
-print 'Also remember to check that SPE is installed.'
Deleted: trunk/py4science/tools/course_checklist_umich.py
===================================================================
--- trunk/py4science/tools/course_checklist_umich.py 2008-10-19 07:36:39 UTC (rev 6267)
+++ trunk/py4science/tools/course_checklist_umich.py 2008-10-19 07:38:45 UTC (rev 6268)
@@ -1,15 +0,0 @@
-#!/usr/bin/env python
-"""Minimal test script to check for modules needed in python course"""
-
-modules = ['numpy','scipy','matplotlib','IPython']
-
-
-for mname in modules:
- try:
- exec "import %s" % mname
- except ImportError:
- print '*** ERROR: module %s could not be imported.' % mname
- else:
- print '%s: OK' % mname
-
-print 'Also remember to check that SPE is installed.'
Copied: trunk/py4science/tools/workshop_checklist.py (from rev 6267, trunk/py4science/classes/workshop_checklist.py)
===================================================================
--- trunk/py4science/tools/workshop_checklist.py (rev 0)
+++ trunk/py4science/tools/workshop_checklist.py 2008-10-19 07:38:45 UTC (rev 6268)
@@ -0,0 +1,178 @@
+#!/usr/bin/env python
+"""Minimal test script to check for modules needed in python workshop.
+
+Execute this code at the command line by typing:
+
+python workshop_checklist.py
+
+If it does NOT say 'OK' at the end, copy the *entire* output of the run and
+send it to the course instructor for help.
+"""
+
+# Standard library imports
+import glob
+import os
+import platform
+import sys
+
+from StringIO import StringIO
+
+# Third-party imports
+import nose
+import nose.tools as nt
+
+##############################################################################
+# Code begins
+
+#-----------------------------------------------------------------------------
+# Generic utility functions
+def sys_info():
+ """Summarize some info about the system"""
+
+ print '=================='
+ print 'System information'
+ print '=================='
+ print 'os.name :',os.name
+ print 'os.uname :',os.uname()
+ print 'platform :',sys.platform
+ print 'platform+ :',platform.platform()
+ print 'prefix :',sys.prefix
+ print 'exec_prefix :',sys.exec_prefix
+ print 'executable :',sys.executable
+ print 'version_info :',sys.version_info
+ print 'version :',sys.version
+ print '=================='
+
+
+#-----------------------------------------------------------------------------
+# Tests
+
+def check_import(mname):
+ "Check that the given name imports correctly"
+ exec "import %s as m" % mname
+
+ if mname == 'matplotlib':
+ m.use('Agg')
+ m.rcParams['figure.subplot.top']= 0.85
+
+ try:
+ vinfo = m.__version__
+ except AttributeError:
+ vinfo = '*no info*'
+
+ print 'MOD: %s, version: %s' % (mname,vinfo)
+
+
+# Test generators are best written without docstrings, because nose can then
+# show the parameters being used.
+def test_imports():
+ modules = ['setuptools',
+ 'IPython',
+ 'numpy','scipy','scipy.weave','scipy.io',
+ 'matplotlib','pylab',
+ 'nose',
+ #'Cython', # disabled for now, not included in EPD Beta2
+ ]
+
+ for mname in modules:
+ yield check_import,mname
+
+
+def test_weave():
+ "Simple code compilation and execution via scipy's weave"
+ from scipy import weave
+
+ weave.inline('int x=1;x++;')
+
+ n,m=1,2
+ code="""
+ int m=%s;
+ return_val=m+n;
+ """ % m
+ val = weave.inline(code,['n'])
+ nt.assert_equal(val,m+n)
+
+
+def est_numpy_all():
+ "Run the entire numpy test suite"
+ import numpy
+ numpy.test()
+
+
+# Test generator, don't put a docstring in it
+def test_loadtxt():
+ import numpy as np
+ import numpy.testing as npt
+
+ # Examples taken from the loadtxt docstring
+ array = np.array
+
+ c = StringIO("0 1\n2 3")
+ a1 = np.loadtxt(c)
+ a2 = np.array([[ 0., 1.],
+ [ 2., 3.]])
+ yield npt.assert_array_equal,a1,a2
+
+ d = StringIO("M 21 72\nF 35 58")
+ a1 = np.loadtxt(d, dtype={'names': ('gender', 'age', 'weight'),
+ 'formats': ('S1', 'i4', 'f4')})
+
+ a2 = np.array([('M', 21, 72.0), ('F', 35, 58.0)],
+ dtype=[('gender', '|S1'), ('age', '<i4'), ('weight', '<f4')])
+ yield npt.assert_array_equal,a1,a2
+
+ c = StringIO("1,0,2\n3,0,4")
+ x,y = np.loadtxt(c, delimiter=',', usecols=(0,2), unpack=True)
+ yield npt.assert_array_equal,x,np.array([ 1., 3.])
+ yield npt.assert_array_equal,y,np.array([ 2., 4.])
+
+
+def test_plot():
+ "Simple plot generation."
+ from matplotlib import pyplot as plt
+ plt.figure()
+ plt.plot([1,2,3])
+ plt.xlabel('some numbers')
+ plt.savefig('tmp_test_plot.png')
+
+
+def test_plot_math():
+ "Plots with math"
+ from matplotlib import pyplot as plt
+ plt.figure()
+ plt.plot([1,2,3],label='data')
+ t=(r'And X is $\sum_{i=0}^\infty \gamma_i + \frac{\alpha^{i^2}}{\gamma}'
+ r'+ \cos(2 \theta^2)$')
+ plt.title(t)
+ plt.legend()
+ plt.grid()
+ plt.savefig('tmp_test_plot_math.png')
+
+
+def cleanup_pngs():
+ """Remove temporary pngs made by our plotting tests"""
+
+ for f in glob.glob('tmp_test_*.png'):
+ try:
+ os.remove(f)
+ except OSError:
+ print '*** Error: could not remove file',f
+
+
+#-----------------------------------------------------------------------------
+# Main routine, executed when this file is run as a script
+#
+if __name__ == '__main__':
+ print "Running tests:"
+ # This call form is ipython-friendly
+ nose.runmodule(argv=[__file__,'-vvs'],
+ exit=False)
+ print """
+***************************************************************************
+ TESTS FINISHED
+***************************************************************************
+
+If the printout above did not finish in 'OK' but instead says 'FAILED', copy
+and send the *entire* output to the instructor for help.
+"""
+ sys_info()
Property changes on: trunk/py4science/tools/workshop_checklist.py
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mergeinfo
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fer...@us...> - 2008-10-19 07:36:49
|
Revision: 6267
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6267&view=rev
Author: fer_perez
Date: 2008-10-19 07:36:39 +0000 (Sun, 19 Oct 2008)
Log Message:
-----------
Cleanup classes dir.
Added Paths:
-----------
trunk/py4science/classes/workshop_checklist.py
Removed Paths:
-------------
trunk/py4science/classes/course_checklist_umich.py
Deleted: trunk/py4science/classes/course_checklist_umich.py
===================================================================
--- trunk/py4science/classes/course_checklist_umich.py 2008-10-19 07:12:21 UTC (rev 6266)
+++ trunk/py4science/classes/course_checklist_umich.py 2008-10-19 07:36:39 UTC (rev 6267)
@@ -1,15 +0,0 @@
-#!/usr/bin/env python
-"""Minimal test script to check for modules needed in python course"""
-
-modules = ['numpy','scipy','matplotlib','IPython']
-
-
-for mname in modules:
- try:
- exec "import %s" % mname
- except ImportError:
- print '*** ERROR: module %s could not be imported.' % mname
- else:
- print '%s: OK' % mname
-
-print 'Also remember to check that SPE is installed.'
Added: trunk/py4science/classes/workshop_checklist.py
===================================================================
--- trunk/py4science/classes/workshop_checklist.py (rev 0)
+++ trunk/py4science/classes/workshop_checklist.py 2008-10-19 07:36:39 UTC (rev 6267)
@@ -0,0 +1,178 @@
+#!/usr/bin/env python
+"""Minimal test script to check for modules needed in python workshop.
+
+Execute this code at the command line by typing:
+
+python workshop_checklist.py
+
+If it does NOT say 'OK' at the end, copy the *entire* output of the run and
+send it to the course instructor for help.
+"""
+
+# Standard library imports
+import glob
+import os
+import platform
+import sys
+
+from StringIO import StringIO
+
+# Third-party imports
+import nose
+import nose.tools as nt
+
+##############################################################################
+# Code begins
+
+#-----------------------------------------------------------------------------
+# Generic utility functions
+def sys_info():
+ """Summarize some info about the system"""
+
+ print '=================='
+ print 'System information'
+ print '=================='
+ print 'os.name :',os.name
+ print 'os.uname :',os.uname()
+ print 'platform :',sys.platform
+ print 'platform+ :',platform.platform()
+ print 'prefix :',sys.prefix
+ print 'exec_prefix :',sys.exec_prefix
+ print 'executable :',sys.executable
+ print 'version_info :',sys.version_info
+ print 'version :',sys.version
+ print '=================='
+
+
+#-----------------------------------------------------------------------------
+# Tests
+
+def check_import(mname):
+ "Check that the given name imports correctly"
+ exec "import %s as m" % mname
+
+ if mname == 'matplotlib':
+ m.use('Agg')
+ m.rcParams['figure.subplot.top']= 0.85
+
+ try:
+ vinfo = m.__version__
+ except AttributeError:
+ vinfo = '*no info*'
+
+ print 'MOD: %s, version: %s' % (mname,vinfo)
+
+
+# Test generators are best written without docstrings, because nose can then
+# show the parameters being used.
+def test_imports():
+ modules = ['setuptools',
+ 'IPython',
+ 'numpy','scipy','scipy.weave','scipy.io',
+ 'matplotlib','pylab',
+ 'nose',
+ #'Cython', # disabled for now, not included in EPD Beta2
+ ]
+
+ for mname in modules:
+ yield check_import,mname
+
+
+def test_weave():
+ "Simple code compilation and execution via scipy's weave"
+ from scipy import weave
+
+ weave.inline('int x=1;x++;')
+
+ n,m=1,2
+ code="""
+ int m=%s;
+ return_val=m+n;
+ """ % m
+ val = weave.inline(code,['n'])
+ nt.assert_equal(val,m+n)
+
+
+def est_numpy_all():
+ "Run the entire numpy test suite"
+ import numpy
+ numpy.test()
+
+
+# Test generator, don't put a docstring in it
+def test_loadtxt():
+ import numpy as np
+ import numpy.testing as npt
+
+ # Examples taken from the loadtxt docstring
+ array = np.array
+
+ c = StringIO("0 1\n2 3")
+ a1 = np.loadtxt(c)
+ a2 = np.array([[ 0., 1.],
+ [ 2., 3.]])
+ yield npt.assert_array_equal,a1,a2
+
+ d = StringIO("M 21 72\nF 35 58")
+ a1 = np.loadtxt(d, dtype={'names': ('gender', 'age', 'weight'),
+ 'formats': ('S1', 'i4', 'f4')})
+
+ a2 = np.array([('M', 21, 72.0), ('F', 35, 58.0)],
+ dtype=[('gender', '|S1'), ('age', '<i4'), ('weight', '<f4')])
+ yield npt.assert_array_equal,a1,a2
+
+ c = StringIO("1,0,2\n3,0,4")
+ x,y = np.loadtxt(c, delimiter=',', usecols=(0,2), unpack=True)
+ yield npt.assert_array_equal,x,np.array([ 1., 3.])
+ yield npt.assert_array_equal,y,np.array([ 2., 4.])
+
+
+def test_plot():
+ "Simple plot generation."
+ from matplotlib import pyplot as plt
+ plt.figure()
+ plt.plot([1,2,3])
+ plt.xlabel('some numbers')
+ plt.savefig('tmp_test_plot.png')
+
+
+def test_plot_math():
+ "Plots with math"
+ from matplotlib import pyplot as plt
+ plt.figure()
+ plt.plot([1,2,3],label='data')
+ t=(r'And X is $\sum_{i=0}^\infty \gamma_i + \frac{\alpha^{i^2}}{\gamma}'
+ r'+ \cos(2 \theta^2)$')
+ plt.title(t)
+ plt.legend()
+ plt.grid()
+ plt.savefig('tmp_test_plot_math.png')
+
+
+def cleanup_pngs():
+ """Remove temporary pngs made by our plotting tests"""
+
+ for f in glob.glob('tmp_test_*.png'):
+ try:
+ os.remove(f)
+ except OSError:
+ print '*** Error: could not remove file',f
+
+
+#-----------------------------------------------------------------------------
+# Main routine, executed when this file is run as a script
+#
+if __name__ == '__main__':
+ print "Running tests:"
+ # This call form is ipython-friendly
+ nose.runmodule(argv=[__file__,'-vvs'],
+ exit=False)
+ print """
+***************************************************************************
+ TESTS FINISHED
+***************************************************************************
+
+If the printout above did not finish in 'OK' but instead says 'FAILED', copy
+and send the *entire* output to the instructor for help.
+"""
+ sys_info()
Property changes on: trunk/py4science/classes/workshop_checklist.py
___________________________________________________________________
Added: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fer...@us...> - 2008-10-19 07:12:30
|
Revision: 6266
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6266&view=rev
Author: fer_perez
Date: 2008-10-19 07:12:21 +0000 (Sun, 19 Oct 2008)
Log Message:
-----------
Minor updates to scipy agenda file
Modified Paths:
--------------
trunk/py4science/classes/0808_scipy_agenda.txt
Modified: trunk/py4science/classes/0808_scipy_agenda.txt
===================================================================
--- trunk/py4science/classes/0808_scipy_agenda.txt 2008-10-19 07:10:58 UTC (rev 6265)
+++ trunk/py4science/classes/0808_scipy_agenda.txt 2008-10-19 07:12:21 UTC (rev 6266)
@@ -99,8 +99,8 @@
* basic plotting with matplotlib (90 min) [Mike]
* basic line/scatter plotting
- * customizing colors, styles
- * legend
+ + customizing colors, styles
+ + legend
* backends - what they are and pros/cons of each
* matplotlibrc
* math text
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fer...@us...> - 2008-10-19 07:11:05
|
Revision: 6265
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6265&view=rev
Author: fer_perez
Date: 2008-10-19 07:10:58 +0000 (Sun, 19 Oct 2008)
Log Message:
-----------
Complete making workbook be pure-tex, self-contained (no more links to
the top-level book dir).
Added Paths:
-----------
trunk/py4science/workbook/examples/
trunk/py4science/workbook/examples/ip_embed-short.py
trunk/py4science/workbook/examples/ip_embed.py
trunk/py4science/workbook/examples/ip_expensive_init.py
trunk/py4science/workbook/examples/ip_simple.py
trunk/py4science/workbook/examples/ip_simple2.py
trunk/py4science/workbook/examples/mpl_agg_oo.py
trunk/py4science/workbook/examples/mpl_pylab.py
trunk/py4science/workbook/examples/mpl_subplot_demo.py
trunk/py4science/workbook/examples/wrap_f2py_setup.py
trunk/py4science/workbook/examples/wrap_weave.py
trunk/py4science/workbook/snippets/
trunk/py4science/workbook/snippets/load_binary.ipy
trunk/py4science/workbook/snippets/load_data.ipy
trunk/py4science/workbook/snippets/mpl_get.ipy
trunk/py4science/workbook/snippets/mpl_plot_line.ipy
trunk/py4science/workbook/snippets/mpl_set.ipy
trunk/py4science/workbook/snippets/mpl_text_set.ipy
trunk/py4science/workbook/snippets/wrap_sub_sig.f
trunk/py4science/workbook/snippets/wrap_sub_sig_f2py.f
Added: trunk/py4science/workbook/examples/ip_embed-short.py
===================================================================
--- trunk/py4science/workbook/examples/ip_embed-short.py (rev 0)
+++ trunk/py4science/workbook/examples/ip_embed-short.py 2008-10-19 07:10:58 UTC (rev 6265)
@@ -0,0 +1,51 @@
+"""Quick code snippets for embedding IPython into other programs.
+
+See example-embed.py for full details, this file has the bare minimum code for
+cut and paste use once you understand how to use the system."""
+
+#---------------------------------------------------------------------------
+# This code loads IPython but modifies a few things if it detects it's running
+# embedded in another IPython session (helps avoid confusion)
+
+try:
+ __IPYTHON__
+except NameError:
+ argv = ['']
+ banner = exit_msg = ''
+else:
+ # Command-line options for IPython (a list like sys.argv)
+ argv = ['-pi1','In <\\#>:','-pi2',' .\\D.:','-po','Out<\\#>:']
+ banner = '*** Nested interpreter ***'
+ exit_msg = '*** Back in main IPython ***'
+
+# First import the embeddable shell class
+from IPython.Shell import IPShellEmbed
+# Now create the IPython shell instance. Put ipshell() anywhere in your code
+# where you want it to open.
+ipshell = IPShellEmbed(argv,banner=banner,exit_msg=exit_msg)
+
+#---------------------------------------------------------------------------
+# This code will load an embeddable IPython shell always with no changes for
+# nested embededings.
+
+from IPython.Shell import IPShellEmbed
+ipshell = IPShellEmbed()
+# Now ipshell() will open IPython anywhere in the code.
+
+#---------------------------------------------------------------------------
+# This code loads an embeddable shell only if NOT running inside
+# IPython. Inside IPython, the embeddable shell variable ipshell is just a
+# dummy function.
+
+try:
+ __IPYTHON__
+except NameError:
+ from IPython.Shell import IPShellEmbed
+ ipshell = IPShellEmbed()
+ # Now ipshell() will open IPython anywhere in the code
+else:
+ # Define a dummy ipshell() so the same code doesn't crash inside an
+ # interactive IPython
+ def ipshell(): pass
+
+#******************* End of file <example-embed-short.py> ********************
Added: trunk/py4science/workbook/examples/ip_embed.py
===================================================================
--- trunk/py4science/workbook/examples/ip_embed.py (rev 0)
+++ trunk/py4science/workbook/examples/ip_embed.py 2008-10-19 07:10:58 UTC (rev 6265)
@@ -0,0 +1,127 @@
+#!/usr/bin/env python
+
+"""An example of how to embed an IPython shell into a running program.
+
+Please see the documentation in the IPython.Shell module for more details.
+
+The accompanying file example-embed-short.py has quick code fragments for
+embedding which you can cut and paste in your code once you understand how
+things work.
+
+The code in this file is deliberately extra-verbose, meant for learning."""
+
+# The basics to get you going:
+
+# IPython sets the __IPYTHON__ variable so you can know if you have nested
+# copies running.
+
+# Try running this code both at the command line and from inside IPython (with
+# %run example-embed.py)
+try:
+ __IPYTHON__
+except NameError:
+ nested = 0
+ args = ['']
+else:
+ print "Running nested copies of IPython."
+ print "The prompts for the nested copy have been modified"
+ nested = 1
+ # what the embedded instance will see as sys.argv:
+ args = ['-pi1','In <\\#>:','-pi2',' .\\D.:','-po','Out<\\#>:','-nosep']
+
+# First import the embeddable shell class
+from IPython.Shell import IPShellEmbed
+
+# Now create an instance of the embeddable shell. The first argument is a
+# string with options exactly as you would type them if you were starting
+# IPython at the system command line. Any parameters you want to define for
+# configuration can thus be specified here.
+ipshell = IPShellEmbed(args,
+ banner = 'Dropping into IPython',
+ exit_msg = 'Leaving Interpreter, back to program.')
+
+# Make a second instance, you can have as many as you want.
+if nested:
+ args[1] = 'In2<\\#>'
+else:
+ args = ['-pi1','In2<\\#>:','-pi2',' .\\D.:','-po','Out<\\#>:','-nosep']
+ipshell2 = IPShellEmbed(args,banner = 'Second IPython instance.')
+
+print '\nHello. This is printed from the main controller program.\n'
+
+# You can then call ipshell() anywhere you need it (with an optional
+# message):
+ipshell('***Called from top level. '
+ 'Hit Ctrl-D to exit interpreter and continue program.')
+
+print '\nBack in caller program, moving along...\n'
+
+#---------------------------------------------------------------------------
+# More details:
+
+# IPShellEmbed instances don't print the standard system banner and
+# messages. The IPython banner (which actually may contain initialization
+# messages) is available as <instance>.IP.BANNER in case you want it.
+
+# IPShellEmbed instances print the following information everytime they
+# start:
+
+# - A global startup banner.
+
+# - A call-specific header string, which you can use to indicate where in the
+# execution flow the shell is starting.
+
+# They also print an exit message every time they exit.
+
+# Both the startup banner and the exit message default to None, and can be set
+# either at the instance constructor or at any other time with the
+# set_banner() and set_exit_msg() methods.
+
+# The shell instance can be also put in 'dummy' mode globally or on a per-call
+# basis. This gives you fine control for debugging without having to change
+# code all over the place.
+
+# The code below illustrates all this.
+
+
+# This is how the global banner and exit_msg can be reset at any point
+ipshell.set_banner('Entering interpreter - New Banner')
+ipshell.set_exit_msg('Leaving interpreter - New exit_msg')
+
+def foo(m):
+ s = 'spam'
+ ipshell('***In foo(). Try @whos, or print s or m:')
+ print 'foo says m = ',m
+
+def bar(n):
+ s = 'eggs'
+ ipshell('***In bar(). Try @whos, or print s or n:')
+ print 'bar says n = ',n
+
+# Some calls to the above functions which will trigger IPython:
+print 'Main program calling foo("eggs")\n'
+foo('eggs')
+
+# The shell can be put in 'dummy' mode where calls to it silently return. This
+# allows you, for example, to globally turn off debugging for a program with a
+# single call.
+ipshell.set_dummy_mode(1)
+print '\nTrying to call IPython which is now "dummy":'
+ipshell()
+print 'Nothing happened...'
+# The global 'dummy' mode can still be overridden for a single call
+print '\nOverriding dummy mode manually:'
+ipshell(dummy=0)
+
+# Reactivate the IPython shell
+ipshell.set_dummy_mode(0)
+
+print 'You can even have multiple embedded instances:'
+ipshell2()
+
+print '\nMain program calling bar("spam")\n'
+bar('spam')
+
+print 'Main program finished. Bye!'
+
+#********************** End of file <example-embed.py> ***********************
Property changes on: trunk/py4science/workbook/examples/ip_embed.py
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/py4science/workbook/examples/ip_expensive_init.py
===================================================================
--- trunk/py4science/workbook/examples/ip_expensive_init.py (rev 0)
+++ trunk/py4science/workbook/examples/ip_expensive_init.py 2008-10-19 07:10:58 UTC (rev 6265)
@@ -0,0 +1,21 @@
+"""Example script with an expensive initialization.
+
+Meant to be used via ipython's %run -i, though it can run standalone."""
+
+# Imagine that bigobject is actually something whose creation is an expensive
+# process, though here we are just going to make it a list of numbers for
+# demonstration's sake. The trick is to trap a test for the existence of this
+# name in a try/except block. If the object exists, we don't recreate it, if
+# it doesn't exist yet (such as the first time the code is run in any given
+# session), we make it.
+
+try:
+ bigobject
+ print "We found bigobject! No need to initialize it."
+except NameError:
+ print "bigobject not found, performing expensive initialization..."
+ bigobject = range(1000)
+
+# And now you can move on with working on bigobject:
+total = sum(bigobject)
+print 'total is:',total
Added: trunk/py4science/workbook/examples/ip_simple.py
===================================================================
--- trunk/py4science/workbook/examples/ip_simple.py (rev 0)
+++ trunk/py4science/workbook/examples/ip_simple.py 2008-10-19 07:10:58 UTC (rev 6265)
@@ -0,0 +1,4 @@
+import sys
+print 'sys.argv is:',sys.argv
+print '__name__ is:',__name__
+x = 1
Added: trunk/py4science/workbook/examples/ip_simple2.py
===================================================================
--- trunk/py4science/workbook/examples/ip_simple2.py (rev 0)
+++ trunk/py4science/workbook/examples/ip_simple2.py 2008-10-19 07:10:58 UTC (rev 6265)
@@ -0,0 +1,3 @@
+"""This simple file prints a variable which is NOT defined here.
+It should be run via IPython's %run with the -i option."""
+print 'x is:',x
Added: trunk/py4science/workbook/examples/mpl_agg_oo.py
===================================================================
--- trunk/py4science/workbook/examples/mpl_agg_oo.py (rev 0)
+++ trunk/py4science/workbook/examples/mpl_agg_oo.py 2008-10-19 07:10:58 UTC (rev 6265)
@@ -0,0 +1,26 @@
+"""
+A pure object oriented example using the agg backend
+"""
+# import the matplotlib backend you want to use and the Figure class
+from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
+from matplotlib.figure import Figure
+
+# the figure is the center of the action, and the canvas is a backend
+# dependent container to hold the figure and make backend specific calls
+fig = Figure()
+canvas = FigureCanvas(fig)
+
+# you can add multiple subplots and axes
+ax = fig.add_subplot(111)
+
+# the simplest plot!
+ax.plot([1,2,3])
+
+# you can decorate your plot with text and grids
+ax.set_title('hi mom')
+ax.grid(True)
+ax.set_xlabel('time')
+ax.set_ylabel('volts')
+
+# and save it to hardcopy
+fig.savefig('../fig/mpl_one_two_three.png')
Added: trunk/py4science/workbook/examples/mpl_pylab.py
===================================================================
--- trunk/py4science/workbook/examples/mpl_pylab.py (rev 0)
+++ trunk/py4science/workbook/examples/mpl_pylab.py 2008-10-19 07:10:58 UTC (rev 6265)
@@ -0,0 +1,8 @@
+from pylab import *
+plot([1,2,3])
+title('hi mom')
+grid(True)
+xlabel('time')
+ylabel('volts')
+savefig('../fig/mpl_one_two_three.png')
+show()
Added: trunk/py4science/workbook/examples/mpl_subplot_demo.py
===================================================================
--- trunk/py4science/workbook/examples/mpl_subplot_demo.py (rev 0)
+++ trunk/py4science/workbook/examples/mpl_subplot_demo.py 2008-10-19 07:10:58 UTC (rev 6265)
@@ -0,0 +1,28 @@
+from pylab import *
+
+def f(t):
+ s1 = cos(2*pi*t)
+ e1 = exp(-t)
+ return multiply(s1,e1)
+
+t1 = arange(0.0, 5.0, 0.1)
+t2 = arange(0.0, 5.0, 0.02)
+t3 = arange(0.0, 2.0, 0.01)
+
+# create and upper subplot and make it current
+subplot(211)
+l1, l2 = plot(t1, f(t1), 'bo', t2, f(t2), 'k--')
+set(l1, markerfacecolor='g')
+grid(True)
+title('A tale of 2 subplots')
+ylabel('Damped oscillation')
+
+# create a lower subplot and make it current
+subplot(212)
+plot(t3, cos(2*pi*t3), 'r.')
+grid(True)
+xlabel('time (s)')
+ylabel('Undamped')
+savefig('../fig/mpl_subplot_demo')
+show()
+
Added: trunk/py4science/workbook/examples/wrap_f2py_setup.py
===================================================================
--- trunk/py4science/workbook/examples/wrap_f2py_setup.py (rev 0)
+++ trunk/py4science/workbook/examples/wrap_f2py_setup.py 2008-10-19 07:10:58 UTC (rev 6265)
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+"""Setup script for F2PY-processed, Fortran based extension modules.
+
+A typical call is:
+
+% ./setup.py install --home=~/usr
+
+This will build and install the generated modules in ~/usr/lib/python.
+
+If called with no args, the script defaults to the above call form (it
+automatically adds the 'install --home=~/usr' options)."""
+
+# Global variables for this extension:
+name = "mwadap_tools" # name of the generated python extension (.so)
+description = "F2PY-wrapped MultiWavelet Tree Toolbox"
+author = "Fast Algorithms Group - CU Boulder"
+author_email = "fp...@co..."
+
+# Necessary sources, _including_ the .pyf interface file
+sources = """
+binary_decomp.f90 binexpandx.f90 bitsequence.f90 constructwv.f90
+display_matrix.f90 findkeypos.f90 findlevel.f90 findnodx.f90 gauleg.f90
+gauleg2.f90 gauleg3.f90 ihpsort.f90 invert_f2cmatrix.f90 keysequence2d.f90
+level_of_nsi.f90 matmult.f90 plegnv.f90 plegvec.f90 r2norm.f90 xykeys.f90
+
+mwadap_tools.pyf""".split()
+
+# Additional libraries required by our extension module (these will be linked
+# in with -l):
+libraries = ['m']
+
+# Set to true (1) to turn on Fortran/C API debugging (very verbose)
+debug_capi = 0
+
+#***************************************************************************
+# Do not modify the code below unless you know what you are doing.
+
+# Required modules
+import sys,os
+from os.path import expanduser,expandvars
+from scipy_distutils.core import setup,Extension
+
+expand_sh = lambda path: expanduser(expandvars(path))
+
+# Additional directories for libraries (besides the compiler's defaults)
+fc_vendor = os.environ.get('FC_VENDOR','Gnu').lower()
+library_dirs = ["~/usr/lib/"+fc_vendor]
+
+# Modify default arguments (if none are supplied) to install in ~/usr
+if len(sys.argv)==1:
+ default_args = 'install --home=~/usr'
+ print '*** Adding default arguments to setup:',default_args
+ sys.argv += default_args.split() # it must be a list
+
+# Additional options specific to f2py:
+f2py_options = []
+if debug_capi:
+ f2py_options.append('--debug-capi')
+
+# Define the extension module(s)
+extension = Extension(name = name,
+ sources = sources,
+ libraries = libraries,
+ library_dirs = map(expand_sh,library_dirs),
+ f2py_options = f2py_options,
+ )
+
+# Call the actual building/installation routine, in usual distutils form.
+setup(name = name,
+ description = description,
+ author = author,
+ author_email = author_email,
+ ext_modules = [extension],
+ )
Property changes on: trunk/py4science/workbook/examples/wrap_f2py_setup.py
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/py4science/workbook/examples/wrap_weave.py
===================================================================
--- trunk/py4science/workbook/examples/wrap_weave.py (rev 0)
+++ trunk/py4science/workbook/examples/wrap_weave.py 2008-10-19 07:10:58 UTC (rev 6265)
@@ -0,0 +1,475 @@
+#!/usr/bin/env python
+"""Simple examples of weave use.
+
+Code meant to be used for learning/testing, not production.
+
+Fernando Perez <fp...@co...>
+March 2002, updated 2003."""
+
+from weave import inline,converters
+from Numeric import *
+
+#-----------------------------------------------------------------------------
+def simple_print(input):
+ """Simple print test.
+
+ Since there's a hard-coded printf %i in here, it will only work for numerical
+ inputs (ints). """
+
+ # note in the printf that newlines must be passed as \\n:
+ code = '''
+ std::cout << "Printing from C++ (using std::cout) : "<<input<<std::endl;
+ printf("And using C syntax (printf) : %i\\n",input);
+ '''
+ inline(code,['input'],
+ verbose=2) # see inline docstring for details
+
+def py_print(input):
+ "Trivial printer, for timing."
+ print "Input:",input
+
+def c_print(input):
+ "Trivial printer, for timing."
+ code = """printf("Input: %i \\n",input);"""
+ inline(code,['input'])
+
+def cpp_print(input):
+ "Trivial printer, for timing."
+ code = """std::cout << "Input: " << input << std::endl;"""
+ inline(code,['input'])
+
+#-----------------------------------------------------------------------------
+# Returning a scalar quantity computed from a Numeric array.
+def trace(mat):
+ """Return the trace of a matrix.
+ """
+ nrow,ncol = mat.shape
+ code = \
+"""
+double tr=0.0;
+
+for(int i=0;i<nrow;++i)
+ tr += mat(i,i);
+return_val = tr;
+"""
+ return inline(code,['mat','nrow','ncol'],
+ type_converters = converters.blitz)
+
+#-----------------------------------------------------------------------------
+# WRONG CODE: trace() version which modifies in-place a python scalar
+# variable. Note that this doesn't work, similarly to how in-place changes in
+# python only work for mutable objects. Below is an example that does work.
+def trace2(mat):
+ """Return the trace of a matrix. WRONG CODE.
+ """
+ nrow,ncol = mat.shape
+ tr = 0.0
+ code = \
+"""
+for(int i=0;i<nrow;++i)
+ tr += mat(i,i);
+"""
+ inline(code,['mat','nrow','ncol','tr'],
+ type_converters = converters.blitz)
+ return tr
+
+#-----------------------------------------------------------------------------
+# Operating in-place in an existing Numeric array. Contrary to trying to modify
+# in-place a scalar, this works correctly.
+def in_place_mult(num,mat):
+ """In-place multiplication of a matrix by a scalar.
+ """
+ nrow,ncol = mat.shape
+ code = \
+"""
+for(int i=0;i<nrow;++i)
+ for(int j=0;j<ncol;++j)
+ mat(i,j) *= num;
+
+"""
+ inline(code,['num','mat','nrow','ncol'],
+ type_converters = converters.blitz)
+
+#-----------------------------------------------------------------------------
+# Pure Python version for checking.
+def cross_product(a,b):
+ """Cross product of two 3-d vectors.
+ """
+ cross = [0]*3
+ cross[0] = a[1]*b[2]-a[2]*b[1]
+ cross[1] = a[2]*b[0]-a[0]*b[2]
+ cross[2] = a[0]*b[1]-a[1]*b[0]
+ return array(cross)
+
+#-----------------------------------------------------------------------------
+# Here we return a list from the C code. This is probably *much* slower than
+# the python version, it's meant as an illustration and not as production
+# code.
+def cross_productC(a,b):
+ """Cross product of two 3-d vectors.
+ """
+ # py::tuple or py::list both work equally well in this case.
+ code = \
+"""
+py::tuple cross(3);
+
+cross[0] = a(1)*b(2)-a(2)*b(1);
+cross[1] = a(2)*b(0)-a(0)*b(2);
+cross[2] = a(0)*b(1)-a(1)*b(0);
+return_val = cross;
+"""
+ return array(inline(code,['a','b'],
+ type_converters = converters.blitz))
+
+#-----------------------------------------------------------------------------
+# C version which accesses a pre-allocated NumPy vector. Note: when using
+# blitz, index access is done with (,,), not [][][]. In fact, [] indexing
+# fails silently. See this and the next version for a comparison.
+def cross_productC2(a,b):
+ """Cross product of two 3-d vectors.
+ """
+
+ cross = zeros(3,a.typecode())
+ code = \
+"""
+cross(0) = a(1)*b(2)-a(2)*b(1);
+cross(1) = a(2)*b(0)-a(0)*b(2);
+cross(2) = a(0)*b(1)-a(1)*b(0);
+"""
+ inline(code,['a','b','cross'],
+ type_converters = converters.blitz)
+ return cross
+
+#-----------------------------------------------------------------------------
+# Just like the previous case, but now we don't use the blitz converters.
+# Weave automagically does the type conversions for us.
+def cross_productC3(a,b):
+ """Cross product of two 3-d vectors.
+ """
+
+ cross = zeros(3,a.typecode())
+ code = \
+"""
+cross[0] = a[1]*b[2]-a[2]*b[1];
+cross[1] = a[2]*b[0]-a[0]*b[2];
+cross[2] = a[0]*b[1]-a[1]*b[0];
+"""
+ inline(code,['a','b','cross'])
+
+ return cross
+
+#-----------------------------------------------------------------------------
+def dot_product(a,b):
+ """Dot product of two vectors.
+
+ Implemented in a funny (ridiculous) way to use support_code.
+
+ I want to see if we can call another function from inside our own
+ code. This would give us a crude way to implement better modularity by
+ having global constants which include the raw code for whatever C
+ functions we need to call in various places. These can then be included
+ via support_code.
+
+ The overhead is that the support code gets compiled in *every* dynamically
+ generated module, but I'm not sure that's a big deal since the big
+ compilation overhead seems to come from all the fancy C++ templating and
+ whatnot.
+
+ Later: ask Eric if there's a cleaner way to do this."""
+
+ N = len(a)
+ support = \
+"""
+double mult(double x,double y) {
+ return x*y;
+}
+"""
+ code = \
+"""
+double sum = 0.0;
+for (int i=0;i<N;++i) {
+ sum += mult(a(i),b(i));
+}
+return_val = sum;
+"""
+ return inline(code,['a','b','N'],
+ type_converters = converters.blitz,
+ support_code = support,
+ libraries = ['m'],
+ )
+
+#-----------------------------------------------------------------------------
+def sumC(x):
+ """Return the sum of the elements of a 1-d array.
+
+ An example of how weave accesses a Numeric array without blitz. """
+
+ num_types = {Float:'double',
+ Float32:'float'}
+ x_type = num_types[x.typecode()]
+
+ code = """
+ double result=0.0;
+ double element;
+
+ for (int i = 0; i < Nx[0]; i++){
+
+ // Note the type of the pointer below is computed in python
+ //element = *(%s *)(x->data+i*x->strides[0]);
+
+ // Weave's magic does the above for us:
+ element = x[i];
+
+ result += element;
+ std::cout << "Element " << i << " = " << element << "\\n";
+ }
+ std::cout << "size x " << Nx[0] << "\\n";
+
+ return_val = result;
+ """ % x_type;
+
+ return inline(code,['x'],verbose=0)
+
+#-----------------------------------------------------------------------------
+def Cglobals(arr):
+ """How to pass data from function to function via globals.
+
+ This allows the kind of 'over the head' parameter passing via globals
+ which is ugly but necessary for using things like generic integrators in
+ Numerical Recipes with aditional parameters. """
+
+ support = \
+"""
+// Declare globals here
+
+/* These blitz guys must be accessed via pointers to avoid a costly copy.
+Note that now the type is hardwired in. All python polymorphism is gone. I
+should look into whether this can be fixed by properly using blitz templating.
+*/
+blitz::Array<int, 1> *G_arr_pt;
+
+// The global M will be visible in the "code" segment
+int M = 99;
+
+void aprint(int N) {
+ std::cout << "In aprint()\\n";
+ for (int i=0;i<N;++i)
+ std::cout << "arr[" << i << "]=" << (*G_arr_pt)(i) << " ";
+ std::cout << std::endl;
+}
+
+"""
+ code = \
+"""
+// Get the passed array reference so the data becomes global
+G_arr_pt = &arr;
+
+std::cout << "global M=" << M << std::endl;
+std::cout << "local N=" << N << std::endl;
+
+
+std::cout << "First, print using the blitz internal printer:\\n";
+std::cout << "all arr\\n";
+std::cout << arr << std::endl;
+
+std::cout << "all G_arr\\n";
+std::cout << *G_arr_pt << std::endl;
+
+std::cout << "now by loop\\n";
+
+for (int i=0;i<N;++i)
+ std::cout << "arr[" << i << "]=" << arr(i) << " ";
+std::cout << std::endl;
+
+
+std::cout << "Now calling aprint\\n";
+
+aprint(N);
+"""
+ N = len(arr)
+ return inline(code,['arr','N'],
+ type_converters = converters.blitz,
+ support_code = support,
+ libraries = ['m'],
+ verbose = 0,
+ )
+
+
+#-----------------------------------------------------------------------------
+# Two trivial examples using the C math library follow.
+def powC(x,n):
+ """powC(x,n) -> x**n. Implemented using the C pow() function.
+ """
+ support = \
+"""
+#include <math.h>
+"""
+ code = \
+"""
+return_val = pow(x,n);
+"""
+ return inline(code,['x','n'],
+ type_converters = converters.blitz,
+ support_code = support,
+ libraries = ['m'],
+ )
+
+# Some callback examples
+def foo(x,y):
+ print "In Python's foo:"
+ print 'x',x
+ print 'y',y
+ return x
+
+def cfoo(x,y):
+ code = """
+ printf("Attemtping to call back foo() from C...\\n");
+ py::tuple foo_args(2);
+ py::object z; // This will hold the return value of foo()
+ foo_args[0] = x;
+ foo_args[1] = y;
+ z = foo.call(foo_args);
+ printf("Exiting C code.\\n");
+ return_val = z;
+ """
+ return inline(code,"foo x y".split() )
+
+x=99
+y="Hello"
+
+print "Pure python..."
+z=foo(x,y)
+print "foo returned:",z
+print "\nVia weave..."
+z=cfoo(x,y)
+print "cfoo returned:",z
+
+# Complex numbers
+def complex_test():
+ a = zeros((4,4),Complex)
+ a[0,0] = 1+2j
+ a[1,1] = 2+3.5j
+ print 'Before\n',a
+ code = \
+"""
+std::complex<double> i(0, 1);
+std::cout << a(1,1) << std::endl;
+a(2,2) = 3.0+4.5*i;
+//a(2,2).imag = 4.5;
+"""
+ inline(code,['a'],type_converters = converters.blitz)
+ print 'After\n',a
+
+complex_test()
+
+#-----------------------------------------------------------------------------
+def sinC(x):
+ """sinC(x) -> sin(x). Implemented using the C sin() function.
+ """
+ support = \
+"""
+#include <math.h>
+"""
+ code = \
+"""
+return_val = sin(x);
+"""
+ return inline(code,['x'],
+ type_converters = converters.blitz,
+ support_code = support,
+ libraries = ['m'],
+ )
+
+def in_place_multNum(num,mat):
+ mat *= num
+
+
+from weave import inline
+class bunch: pass
+
+def oaccess():
+ x=bunch()
+
+ x.a = 1
+
+ code = """ // BROKEN!
+ // Try to emulate Python's: print 'x.a',x.a
+ std::cout << "x.a " << x.a << std::endl;
+ """
+ inline(code,['x'])
+
+main2 = oaccess
+
+
+def ttest():
+ nrun = 10
+ size = 6000
+ mat = ones((size,size),'d')
+ num = 5.6
+ tNum = time_test(nrun,in_place_multNum,*(num,mat))
+ print 'time Num',tNum
+ tC = time_test(nrun,in_place_mult,*(num,mat))
+ print 'time C',tC
+
+def main():
+ print 'Printing comparisons:'
+ print '\nPassing an int - what the C was coded for:'
+ simple_print(42)
+ print '\nNow passing a float. C++ is fine (cout<< takes care of things) but C fails:'
+ simple_print(42.1)
+ print '\nAnd a string. Again, C++ is ok and C fails:'
+ simple_print('Hello World!')
+
+ A = zeros((3,3),'d')
+
+ A[0,0],A[1,1],A[2,2] = 1,2.5,3.3
+
+ print '\nMatrix A:\n',A
+ print 'Trace by two methods. Second fails, see code for details.'
+ print '\ntr(A)=',trace(A)
+ print '\ntr(A)=',trace2(A)
+
+ a = 5.6
+ print '\nMultiplying A in place by %s:' % a
+ in_place_mult(a,A)
+ print A
+
+ # now some simple operations with 3-vectors.
+ a = array([4.3,1.5,5.6])
+ b = array([0.8,2.9,3.8])
+
+ print '\nPython and C versions follow. Results should be identical:'
+ print 'a =',a
+ print 'b =',b
+
+ print '\nsum(a_i) =',sum(a)
+ print 'sum(a_i) =',sumC(a)
+
+ print '\na.b =',dot(a,b)
+ print 'a.b =',dot_product(a,b)
+
+ print '\na x b =',cross_product(a,b)
+ print 'a x b =',cross_productC(a,b)
+
+ print '\nIn-place versions.'
+ print 'a x b =',cross_productC2(a,b)
+ print 'a x b =',cross_productC3(a,b)
+
+ print '\nSimple functions using the C math library:'
+ import math
+ x = 3.5
+ n = 4
+ theta = math.pi/4.
+ print '\nx**'+str(n)+'=',x**n
+ print 'x**'+str(n)+'=',powC(x,n)
+ print '\nsin('+str(theta)+')=',math.sin(theta)
+ print 'sin('+str(theta)+')=',sinC(theta)
+
+ print '\nGlobal variables and explicitly typed blitz arrays.'
+ x = array([4,5,6])
+ print 'x is a Numeric array:\nx=',x
+ print 'Now using weave:'
+ Cglobals (x)
+
+if __name__ == '__main__':
+ main()
Property changes on: trunk/py4science/workbook/examples/wrap_weave.py
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/py4science/workbook/snippets/load_binary.ipy
===================================================================
--- trunk/py4science/workbook/snippets/load_binary.ipy (rev 0)
+++ trunk/py4science/workbook/snippets/load_binary.ipy 2008-10-19 07:10:58 UTC (rev 6265)
@@ -0,0 +1,13 @@
+# open a file as "read binary" and read it into a string
+In [1]: s = file('data/images/r1025.ima', 'rb').read()
+# the string is length 256*256*2 = 131072
+In [2]: len(s)
+Out[2]: 131072
+# the data are 2 byte / 16 bit integers
+# fromstring converts them to array
+In [3]: im = nx.fromstring(s, nx.Int16)
+# reshape the array to 256x256
+In [4]: im.shape = 256,256
+# and plot it with matplotlib's imshow function
+In [5]: imshow(im)
+Out[5]: <matplotlib.image.AxesImage instance at 0xb659230c>
Added: trunk/py4science/workbook/snippets/load_data.ipy
===================================================================
--- trunk/py4science/workbook/snippets/load_data.ipy (rev 0)
+++ trunk/py4science/workbook/snippets/load_data.ipy 2008-10-19 07:10:58 UTC (rev 6265)
@@ -0,0 +1,9 @@
+In [1]: X = load('data/ascii_data.dat') # X is an array
+In [2]: t = X[:,0] # extract the first column
+In [3]: v = X[:,1] # extract the second column
+In [4]: len(t)
+Out[4]: 20
+In [5]: len(v)
+Out[5]: 20
+In [6]: plot(t,v) # plot the data
+Out[6]: [<matplotlib.lines.Line2D instance at 0xb65921ac>]
Added: trunk/py4science/workbook/snippets/mpl_get.ipy
===================================================================
--- trunk/py4science/workbook/snippets/mpl_get.ipy (rev 0)
+++ trunk/py4science/workbook/snippets/mpl_get.ipy 2008-10-19 07:10:58 UTC (rev 6265)
@@ -0,0 +1,20 @@
+In [29]: get(lines)
+ alpha = 1.0
+ antialiased or aa = True
+ clip_on = True
+ color or c = blue
+ figure = <matplotlib.figure.Figure instance at 0xb40e1cec>
+ label =
+ linestyle or ls = None
+ linewidth or lw = 0.5
+ marker = o
+ markeredgecolor or mec = black
+ markeredgewidth or mew = 0.5
+ markerfacecolor or mfc = blue
+ markersize or ms = 6.0
+ transform = <Affine object at 0x8683c6c>
+ visible = True
+ xdata = [ 0.16952688 0.59729624 0.16829208 0.51311375 0.7227286 0.45925692]...
+ ydata = [ 0.86459035 0.25595992 0.01905832 0.24303582 0.74993261 0.28751132]...
+ zorder = 2
+
Added: trunk/py4science/workbook/snippets/mpl_plot_line.ipy
===================================================================
--- trunk/py4science/workbook/snippets/mpl_plot_line.ipy (rev 0)
+++ trunk/py4science/workbook/snippets/mpl_plot_line.ipy 2008-10-19 07:10:58 UTC (rev 6265)
@@ -0,0 +1,9 @@
+In [2]: x = rand(20); y = rand(20)
+
+In [3]: lines = plot(x,y,'o')
+
+In [4]: type(lines) # plot always returns a list
+Out[4]: <type 'list'>
+
+In [5]: len(lines) # even if it is length 1
+Out[5]: 1
Added: trunk/py4science/workbook/snippets/mpl_set.ipy
===================================================================
--- trunk/py4science/workbook/snippets/mpl_set.ipy (rev 0)
+++ trunk/py4science/workbook/snippets/mpl_set.ipy 2008-10-19 07:10:58 UTC (rev 6265)
@@ -0,0 +1,27 @@
+In [37]: set(lines)
+ alpha: float
+ antialiased or aa: [True | False]
+ clip_box: a matplotlib.transform.Bbox instance
+ clip_on: [True | False]
+ color or c: any matplotlib color - see help(colors)
+ dashes: sequence of on/off ink in points
+ data: (array xdata, array ydata)
+ data_clipping: [True | False]
+ figure: a matplotlib.figure.Figure instance
+ label: any string
+ linestyle or ls: [ '-' | '--' | '-.' | ':' | 'steps' | 'None' ]
+ linewidth or lw: float value in points
+ lod: [True | False]
+ marker: [ '+' | ',' | '.' | '1' | '2' | '3' | '4' | '<' | '>' | 'D' | 'H' | '^' | '_' | 'd' | 'h' | 'o' | 'p' | 's' | 'v' | 'x' | '|' ]
+ markeredgecolor or mec: any matplotlib color - see help(colors)
+ markeredgewidth or mew: float value in points
+ markerfacecolor or mfc: any matplotlib color - see help(colors)
+ markersize or ms: float
+ transform: a matplotlib.transform transformation instance
+ visible: [True | False]
+ xclip: (xmin, xmax)
+ xdata: array
+ yclip: (ymin, ymax)
+ ydata: array
+ zorder: any number
+
Added: trunk/py4science/workbook/snippets/mpl_text_set.ipy
===================================================================
--- trunk/py4science/workbook/snippets/mpl_text_set.ipy (rev 0)
+++ trunk/py4science/workbook/snippets/mpl_text_set.ipy 2008-10-19 07:10:58 UTC (rev 6265)
@@ -0,0 +1,30 @@
+In [8]: t = xlabel('time (s)')
+
+In [9]: set(t)
+ alpha: float
+ backgroundcolor: any matplotlib color - see help(colors)
+ bbox: rectangle prop dict plus key 'pad' which is a pad in points
+ clip_box: a matplotlib.transform.Bbox instance
+ clip_on: [True | False]
+ color: any matplotlib color - see help(colors)
+ family: [ 'serif' | 'sans-serif' | 'cursive' | 'fantasy' | 'monospace' ]
+ figure: a matplotlib.figure.Figure instance
+ fontproperties: a matplotlib.font_manager.FontProperties instance
+ horizontalalignment or ha: [ 'center' | 'right' | 'left' ]
+ label: any string
+ lod: [True | False]
+ multialignment: ['left' | 'right' | 'center' ]
+ name or fontname: string eg, ['Sans' | 'Courier' | 'Helvetica' ...]
+ position: (x,y)
+ rotation: [ angle in degrees 'vertical' | 'horizontal'
+ size or fontsize: [ size in points | relative size eg 'smaller', 'x-large' ] style or fontstyle: [ 'normal' | 'italic' | 'oblique']
+ text: string
+ transform: a matplotlib.transform transformation instance
+ variant: [ 'normal' | 'small-caps' ]
+ verticalalignment or va: [ 'center' | 'top' | 'bottom' ]
+ visible: [True | False]
+ weight or fontweight: [ 'normal' | 'bold' | 'heavy' | 'light' | 'ultrabold' | 'ultralight']
+ x: float
+ y: float
+ zorder: any number
+
Added: trunk/py4science/workbook/snippets/wrap_sub_sig.f
===================================================================
--- trunk/py4science/workbook/snippets/wrap_sub_sig.f (rev 0)
+++ trunk/py4science/workbook/snippets/wrap_sub_sig.f 2008-10-19 07:10:58 UTC (rev 6265)
@@ -0,0 +1,5 @@
+ subroutine phipol(j,mm,nodes,wei,nn,x,phi,wrk)
+
+ implicit real *8 (a-h, o-z)
+ real *8 nodes(*),wei(*),x(*),wrk(*),phi(*)
+ real *8 sum, one, two, half
Added: trunk/py4science/workbook/snippets/wrap_sub_sig_f2py.f
===================================================================
--- trunk/py4science/workbook/snippets/wrap_sub_sig_f2py.f (rev 0)
+++ trunk/py4science/workbook/snippets/wrap_sub_sig_f2py.f 2008-10-19 07:10:58 UTC (rev 6265)
@@ -0,0 +1,25 @@
+ subroutine phipol(j,mm,nodes,wei,nn,x,phi,wrk)
+c
+c Lines with Cf2py in them are directives for f2py to generate a better
+c python interface. These must come _before_ the Fortran variable
+c declarations so we can control the dimension of the arrays in Python.
+c
+c Inputs:
+Cf2py integer check(0<=j && j<mm),depend(mm) :: j
+Cf2py real *8 dimension(mm),intent(in) :: nodes
+Cf2py real *8 dimension(mm),intent(in) :: wei
+Cf2py real *8 dimension(nn),intent(in) :: x
+c
+c Outputs:
+Cf2py real *8 dimension(nn),intent(out),depend(nn) :: phi
+c
+c Hidden args:
+c - scratch areas can be auto-generated by python
+Cf2py real *8 dimension(2*mm+2),intent(hide,cache),depend(mm) :: wrk
+c - array sizes can be auto-determined
+Cf2py integer intent(hide),depend(x):: nn=len(x)
+Cf2py integer intent(hide),depend(nodes) :: mm = len(nodes)
+c
+ implicit real *8 (a-h, o-z)
+ real *8 nodes(*),wei(*),x(*),wrk(*),phi(*)
+ real *8 sum, one, two, half
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fer...@us...> - 2008-10-19 07:08:31
|
Revision: 6264
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6264&view=rev
Author: fer_perez
Date: 2008-10-19 07:08:18 +0000 (Sun, 19 Oct 2008)
Log Message:
-----------
Add local copy of bib files.
Added Paths:
-----------
trunk/py4science/workbook/python.bib
trunk/py4science/workbook/python2.bib
Added: trunk/py4science/workbook/python.bib
===================================================================
--- trunk/py4science/workbook/python.bib (rev 0)
+++ trunk/py4science/workbook/python.bib 2008-10-19 07:08:18 UTC (rev 6264)
@@ -0,0 +1,3176 @@
+%%% -*-BibTeX-*-
+%%% ====================================================================
+%%% BibTeX-file{
+%%% author = "Nelson H. F. Beebe",
+%%% version = "1.30",
+%%% date = "26 April 2005",
+%%% time = "18:00:48 MST",
+%%% filename = "python.bib",
+%%% address = "University of Utah
+%%% Department of Mathematics, 110 LCB
+%%% 155 S 1400 E RM 233
+%%% Salt Lake City, UT 84112-0090
+%%% USA",
+%%% telephone = "+1 801 581 5254",
+%%% FAX = "+1 801 581 4148",
+%%% URL = "http://www.math.utah.edu/~beebe",
+%%% checksum = "21232 3176 13549 129811",
+%%% email = "beebe at math.utah.edu, beebe at acm.org,
+%%% beebe at computer.org (Internet)",
+%%% codetable = "ISO/ASCII",
+%%% keywords = "bibliography; BibTeX; object-oriented
+%%% programming language; Python; scripting
+%%% language",
+%%% supported = "yes",
+%%% docstring = "This is a bibliography of books and other
+%%% publications about Python, an object-oriented
+%%% scripting and programming language.
+%%%
+%%% This language has its own World Wide Web
+%%% site at
+%%%
+%%% http://www.python.org/
+%%%
+%%% with information about the language, its
+%%% source code distributions, on-line
+%%% documentation, and e-mail discussion lists.
+%%%
+%%% At version 1.30, the year coverage looked
+%%% like this:
+%%%
+%%% 1991 ( 3) 1996 ( 14) 2001 ( 10)
+%%% 1992 ( 3) 1997 ( 32) 2002 ( 14)
+%%% 1993 ( 0) 1998 ( 26) 2003 ( 5)
+%%% 1994 ( 0) 1999 ( 5)
+%%% 1995 ( 10) 2000 ( 13)
+%%%
+%%% Article: 69
+%%% Book: 25
+%%% InCollection: 1
+%%% InProceedings: 13
+%%% MastersThesis: 1
+%%% Misc: 2
+%%% Proceedings: 12
+%%% TechReport: 11
+%%% Unpublished: 1
+%%%
+%%% Total entries: 135
+%%%
+%%% This bibliography was collected from the OCLC
+%%% library databases, from the Compendex
+%%% database, from the IEEE INSPEC database, from
+%%% the University of California MELVYL catalog,
+%%% from the U. S. Library of Congress catalog,
+%%% from the Python Web site, and from the
+%%% author's personal bibliography collections.
+%%%
+%%% Numerous errors in the sources noted above
+%%% have been corrected. Spelling has been
+%%% verified with the UNIX spell and GNU ispell
+%%% programs using the exception dictionary
+%%% stored in the companion file with extension
+%%% .sok.
+%%%
+%%% BibTeX citation tags are uniformly chosen as
+%%% name:year:abbrev, where name is the family
+%%% name of the first author or editor, year is a
+%%% 4-digit number, and abbrev is a 3-letter
+%%% condensation of important title words.
+%%% Citation tags were automatically generated by
+%%% software developed for the BibNet Project.
+%%%
+%%% In this bibliography, entries are sorted
+%%% first by ascending year, and within each
+%%% year, alphabetically by author or editor,
+%%% and then, if necessary, by the 3-letter
+%%% abbreviation at the end of the BibTeX
+%%% citation tag, using the bibsort -byyear
+%%% utility. Year order has been chosen to
+%%% make it easier to identify the most recent
+%%% work.
+%%%
+%%% The checksum field above contains a CRC-16
+%%% checksum as the first value, followed by the
+%%% equivalent of the standard UNIX wc (word
+%%% count) utility output of lines, words, and
+%%% characters. This is produced by Robert
+%%% Solovay's checksum utility.",
+%%% }
+%%% ====================================================================
+
+%%% ====================================================================
+%%% Acknowledgement abbreviations:
+
+@String{ack-nhfb = "Nelson H. F. Beebe,
+ University of Utah,
+ Department of Mathematics, 110 LCB,
+ 155 S 1400 E RM 233,
+ Salt Lake City, UT 84112-0090, USA,
+ Tel: +1 801 581 5254,
+ FAX: +1 801 581 4148,
+ e-mail: \path|be...@ma...|,
+ \path|be...@ac...|,
+ \path|be...@co...| (Internet),
+ URL: \path|http://www.math.utah.edu/~beebe/|"}
+
+%%% ====================================================================
+%%% Journal abbreviations:
+
+@String{j-BYTE = "Byte Magazine"}
+
+@String{j-CCPE = "Concurrency and Computation: Prac\-tice and
+ Experience"}
+
+@String{j-COMP-NET-ISDN = "Computer Networks and ISDN Systems"}
+
+@String{j-COMP-PHYSICS = "Computers in Physics"}
+
+@String{j-COMPUT-SCI-ENG = "Computing in Science and Engineering"}
+
+@String{j-DDJ = "Dr. Dobb's Journal of Software Tools"}
+
+@String{j-DDJ-SOURCEBOOK = "Dr. Dobb's Sourcebook"}
+
+@String{j-JERIC = "ACM Journal on Educational Resources in
+ Computing (JERIC)"}
+
+@String{j-EXE = ".EXE: the software developers' magazine"}
+
+@String{j-IEEE-CGA = "IEEE Computer Graphics and Applications"}
+
+@String{j-INTERACTIONS = "Interactions (New York, N.Y.)"}
+
+@String{j-J-RES-NATL-INST-STAND-TECHNOL = "Journal of research of the National
+ Institute of Standards and Technology"}
+
+@String{j-LECT-NOTES-COMP-SCI = "Lecture Notes in Computer Science"}
+
+@String{j-LINUX-J = "Linux journal"}
+
+@String{j-SUNWORLD-ONLINE = "SunWorld online"}
+
+@String{j-UNIX-DEVELOPER = "UNIX Developer"}
+
+@String{j-WEB-REVIEW = "Web Review"}
+
+@String{j-WEB-TECHNIQUES = "Web Techniques"}
+
+@String{j-WORLD-WIDE-WEB-J = "World Wide Web Journal"}
+
+@String{j-X-J = "The {X} Journal: Computing Technology with
+ the {X Window System}"}
+
+%%% ====================================================================
+%%% Publisher abbreviations:
+
+@String{pub-ACM = "ACM Press"}
+
+@String{pub-ACM:adr = "New York, NY 10036, USA"}
+
+@String{pub-APRESS = "Apress"}
+
+@String{pub-APRESS:adr = "Berkeley, CA, USA"}
+
+@String{pub-AW = "Ad{\-d}i{\-s}on-Wes{\-l}ey"}
+
+@String{pub-AW:adr = "Reading, MA, USA"}
+
+@String{pub-AW-LONGMAN = "Ad{\-d}i{\-s}on-Wes{\-l}ey Longman"}
+
+@String{pub-AW-LONGMAN:adr = "Reading, MA, USA"}
+
+@String{pub-CNRI = "Corporation for National Research
+ Initiatives"}
+
+@String{pub-CNRI:adr = "1895 Preston White Drive, Suite 100, Reston,
+ VA 20191, USA"}
+
+@String{pub-CWI = "Centrum voor Wiskunde en Informatica"}
+
+@String{pub-CWI:adr = "P. O. Box 4079, 1009 AB Amsterdam, The
+ Netherlands"}
+
+@String{pub-EUROPEN = "EurOpen"}
+
+@String{pub-EUROPEN:adr = "Buntingford, Herts, UK"}
+
+@String{pub-IEEE = "IEEE Computer Society Press"}
+
+@String{pub-IEEE:adr = "1109 Spring Street, Suite 300, Silver
+ Spring, MD 20910, USA"}
+
+@String{pub-MAC = "Macmillan Publishing Company"}
+
+@String{pub-MAC:adr = "New York, NY, USA"}
+
+@String{pub-MANNING = "Manning Publications"}
+
+@String{pub-MANNING:adr = "Greenwich, CT, USA"}
+
+@String{pub-MT = "M\&T Books"}
+
+@String{pub-MT:adr = "M\&T Publishing, Inc., 501 Galveston Drive,
+ Redwood City, CA 94063, USA"}
+
+@String{pub-NRP = "New Riders Publishing"}
+
+@String{pub-NRP:adr = "Carmel, IN, USA"}
+
+@String{pub-ORA = "O'Reilly \& {Associates, Inc.}"}
+
+@String{pub-ORA:adr = "103a Morris Street,
+ Sebastopol, CA 95472,
+ USA,
+ Tel: +1 707 829 0515,
+ and
+ 90 Sherman Street,
+ Cambridge, MA 02140,
+ USA,
+ Tel: +1 617 354 5800"}
+
+@String{pub-OSBORNE = "Osborne/McGraw-Hill"}
+
+@String{pub-OSBORNE:adr = "Berkeley, CA, USA"}
+
+@String{pub-PH = "Pren{\-}tice-Hall"}
+
+@String{pub-PH:adr = "Englewood Cliffs, NJ 07632, USA"}
+
+@String{pub-PHPTR = "P T R Pren{\-}tice-Hall"}
+
+@String{pub-PHPTR:adr = "Englewood Cliffs, NJ 07632, USA"}
+
+@String{pub-SAMS = "SAMS Publishing"}
+
+@String{pub-SAMS:adr = "Indianapolis, IN, USA"}
+
+@String{pub-SIAM = "Society for Industrial and Applied
+ Mathematics"}
+
+@String{pub-SIAM:adr = "Philadelphia, PA, USA"}
+
+@String{pub-USENIX = "USENIX"}
+
+@String{pub-USENIX:adr = "Berkeley, CA, USA"}
+
+@String{pub-WORLD-SCI = "World Scientific Publishing Co."}
+
+@String{pub-WORLD-SCI:adr = "Singapore; Philadelphia, PA, USA; River
+ Edge, NJ, USA"}
+
+%%% ====================================================================
+%%% Bibliography entries.
+
+@TechReport{MacLachlan:1991:CCL,
+ author = "Rob MacLachlan",
+ title = "{CMU Common Lisp} user's manual",
+ type = "Research paper",
+ number = "CMU-CS-91-108",
+ institution = "School of Computer Science, Carnegie Mellon
+ University",
+ address = "Pittsburgh, PA, USA",
+ pages = "vi + 168",
+ month = feb,
+ year = "1991",
+ bibdate = "Mon Nov 18 14:18:28 MST 1996",
+ bibsource = "ftp://ftp.math.utah.edu/pub/tex/bib/common-lisp.bib",
+ note = "This is a revised version of Technical Report
+ CMU-CS-87-156.",
+ abstract = "CMU Common Lisp is an implementation of Common Lisp
+ that currently runs under Mach, a Berkeley Unix 4.3
+ binary compatible operating system. CMU Common Lisp is
+ currently supported on MIPS-processor DECstations,
+ SPARC-based workstations from Sun and the IBM RT PC,
+ and other ports are planned. The largest single part of
+ this document describes the Python compiler and the
+ programming styles and techniques that the compiler
+ encourages. The rest of the document describes
+ extensions and the implementation dependent choices
+ made in developing this implementation of Common Lisp.
+ We have added several extensions, including the
+ proposed error system, a source level debugger, an
+ interface to Mach system calls, a foreign function call
+ interface, support for interprocess communication and
+ remote procedure call, and other features that provide
+ a good environment for developing Lisp code.",
+ acknowledgement = ack-nhfb,
+ annote = "Sponsored by the Defense Advanced Research Projects
+ Agency, Information Science and Technology Office.",
+ keywords = "LISP (Computer program language)",
+}
+
+@InProceedings{vanRossum:1991:LSG,
+ author = "G. {van Rossum} and J. {de Boer}",
+ title = "Linking a stub generator ({AIL}) to a prototyping
+ language ({Python})",
+ crossref = "EurOpen:1991:EUD",
+ pages = "229--247",
+ year = "1991",
+ bibdate = "Thu May 21 19:02:04 MDT 1998",
+ acknowledgement = ack-nhfb,
+ classification = "C5620 (Computer networks and techniques); C6110
+ (Systems analysis and programming); C6115 (Programming
+ support); C6140D (High level languages); C6150C
+ (Compilers, interpreters and other processors)",
+ conflocation = "Tromso, Norway; 20-24 May 1991",
+ corpsource = "CWI, Amsterdam, Netherlands",
+ keywords = "AIL; Amoeba; client/server interfaces; distributed
+ operating system; distributed processing; interpreted
+ prototyping language; parallel languages; parallel
+ programming; program processors; Python; Remote
+ Procedure Call stub generator; software prototyping;
+ usability",
+ pubcountry = "UK",
+ treatment = "P Practical",
+}
+
+@TechReport{MacLachlan:1992:CCL,
+ author = "Rob MacLachlan",
+ title = "{CMU Common Lisp} user's manual",
+ type = "Research paper",
+ number = "CMU-CS-92-161",
+ institution = "School of Computer Science, Carnegie Mellon
+ University",
+ address = "Pittsburgh, PA, USA",
+ pages = "v + 142",
+ month = jul,
+ year = "1992",
+ bibdate = "Mon Nov 18 14:18:28 MST 1996",
+ bibsource = "ftp://ftp.math.utah.edu/pub/tex/bib/common-lisp.bib",
+ note = "Supersedes Technical Reports CMU-CS-87-156 and
+ CMU-CS-91-108.",
+ abstract = "CMU Common Lisp is an implementation of that Common
+ Lisp is [sic] currently supported on MIPS-processor
+ DECstations, SPARC-based workstations from Sun and the
+ IBM RT PC, and other ports are planned. All
+ architectures are supported under Mach, a Berkeley Unix
+ 4.3 binary compatible operating system. The SPARC is
+ also supported under SunOS. The largest single part of
+ this document describes the Python compiler and the
+ programming styles and techniques that the compiler
+ encourages. The rest of the document describes
+ extensions and the implementation dependent choices
+ made in developing this implementation of Common Lisp.
+ We have added several extensions, including a source
+ level debugger, an interface to Unix system calls, a
+ foreign function call interface, support for
+ interprocess communication and remote procedure call,
+ and other features that provide a good environment for
+ developing Lisp code.",
+ acknowledgement = ack-nhfb,
+ annote = "Supported in part by the Defense Advanced Research
+ Projects Agency, Information Science and Technology
+ Office, issued by DARPA/CMO.",
+ keywords = "COMMON LISP (Computer program language); Compilers
+ (Computer programs)",
+}
+
+@InProceedings{MacLachlan:1992:PCC,
+ author = "Robert A. MacLachlan",
+ title = "{Python} compiler for {CMU} {Common Lisp}",
+ crossref = "ACM:1992:PAC",
+ pages = "235--246",
+ year = "1992",
+ bibdate = "Wed Aug 6 19:54:46 MDT 1997",
+ bibsource = "Compendex database;
+ ftp://ftp.math.utah.edu/pub/tex/bib/common-lisp.bib",
+ abstract = "The Python compiler for CMU Common Lisp has been under
+ development for over five years, and now forms the core
+ of a production quality public domain Lisp
+ implementation. Python synthesizes the good ideas from
+ Lisp compilers and source transformation systems with
+ mainstream optimization and retargetability techniques.
+ Novel features include strict type checking and
+ source-level debugging of compiled code. Unusual
+ attention has been paid to the compiler's user
+ interface.",
+ acknowledgement = ack-nhfb,
+ affiliation = "Carnegie Mellon Univ",
+ affiliationaddress = "Pittsburgh, PA, USA",
+ classification = "723.1; 723.1.1",
+ keywords = "Algorithms; Lisp (programming language); Mainstream
+ optimization and retargetability techniques; Program
+ compilers; Program debugging; Program processors;
+ Python compiler; Source level debugging; Type checking;
+ User interfaces",
+ sponsor = "ACM; SIGPLAN; SIGACT; SIGART",
+}
+
+@Article{Anonymous:1995:NIP,
+ author = "Anonymous",
+ title = "{NIST} Investigates {Python} Programming Language",
+ journal = j-J-RES-NATL-INST-STAND-TECHNOL,
+ volume = "100",
+ number = "1",
+ pages = "101--101",
+ month = jan # "\slash " # feb,
+ year = "1995",
+ CODEN = "JRITEF",
+ ISSN = "1044-677X",
+ bibdate = "Thu May 21 16:28:33 MDT 1998",
+ URL = "http://nvl.nist.gov/pub/nistpubs/jres/jrescont.pdf",
+ acknowledgement = ack-nhfb,
+}
+
+@Article{Anonymous:1995:VBA,
+ author = "Anonymous",
+ title = "{VR} Blackboard: {Alice}: Rapid Prototyping for
+ Virtual Reality",
+ journal = j-IEEE-CGA,
+ volume = "15",
+ number = "3",
+ pages = "8--11",
+ month = may,
+ year = "1995",
+ CODEN = "ICGADZ",
+ ISSN = "0272-1716",
+ bibdate = "Sat Jan 25 06:42:48 MST 1997",
+ bibsource = "Compendex database;
+ ftp://ftp.math.utah.edu/pub/tex/bib/ieeecga.bib",
+ acknowledgement = ack-nhfb,
+ classification = "722.2; 723; 723.1; 723.5",
+ journalabr = "IEEE Comput Graphics Appl",
+ keywords = "Animation; Computer keyboards; Computer programs;
+ Computer simulation; Computer software; Interactive
+ computer graphics; Mice (computer peripherals); Object
+ oriented programming; Python programming language;
+ Software prototyping; Three dimensional computer
+ graphics; Virtual reality",
+}
+
+@Article{Conway:1995:PGD,
+ author = "Matthew J. Conway",
+ title = "{Python}: a {GUI} development tool",
+ journal = j-INTERACTIONS,
+ volume = "2",
+ number = "2",
+ pages = "23--28",
+ month = apr,
+ year = "1995",
+ CODEN = "IERAE3",
+ ISSN = "1072-5520",
+ bibdate = "Thu May 21 19:02:04 MDT 1998",
+ acknowledgement = ack-nhfb,
+ classification = "C6115 (Programming support); C6140D (High level
+ languages); C6180G (Graphical user interfaces)",
+ corpsource = "Virginia Univ., Charlottesville, VA, USA",
+ keywords = "authoring languages; authoring systems; Eiffel;
+ graphical user interfaces; GUI development tool;
+ Modula-3; Perl5; Prolog; Python; Scheme; Self; Tcl/Tk;
+ Tk-aware interpreted languages; user interface
+ management systems",
+ treatment = "P Practical",
+}
+
+@InProceedings{Huang:1995:CEM,
+ author = "C. C. Huang and G. S. Couch and E. F. Pettersen and T.
+ E. Ferrin",
+ title = "{Chimera}: an extensible molecular modeling
+ application constructed using standard components",
+ crossref = "Hunter:1995:PSB",
+ pages = "724--??",
+ year = "1995",
+ bibdate = "Thu May 21 19:02:04 MDT 1998",
+ acknowledgement = ack-nhfb,
+ classification = "A3520B (General molecular conformation and symmetry;
+ A3620H (Macromolecular configuration (bonds,
+ dimensions)); A8715B (Biomolecular structure,
+ configuration, conformation, and active sites); C6110B
+ (Software engineering techniques); C6130B (Graphics
+ techniques); C7320 (Physics and chemistry computing);
+ C7330 (Biology and medical computing);
+ stereochemistry)",
+ conftitle = "Proceedings of Biocomputing '96",
+ corpsource = "Lab. of Comput. Graphics, California Univ., San
+ Francisco, CA, USA",
+ keywords = "application availability evaluation; biology
+ computing; Chimera; computer graphics; digital
+ simulation; interoperability; Kinemage files;
+ macromolecules; molecular biophysics; molecular
+ configurations; molecular modeling application; Open
+ Inventor; open systems; OpenGL; physics computing;
+ programmable command language; Python language
+ interpreter; software extensibility; software
+ libraries; software portability; standard components;
+ standard functionality; technological criteria;
+ workstations; X Windows; X/MOTIF user interface",
+ treatment = "P Practical",
+}
+
+@TechReport{vanRossum:1995:EEP,
+ author = "Guido {van Rossum}",
+ title = "Extending and embedding the {Python} interpreter",
+ type = "Report",
+ number = "CS-R9527",
+ institution = pub-CWI,
+ address = pub-CWI:adr,
+ pages = "i + 22",
+ month = apr,
+ year = "1995",
+ bibdate = "Thu May 21 14:06:05 MDT 1998",
+ abstract = "Python is an interpreted, object-oriented programming
+ language. This document describes how to write modules
+ in C or C++ to extend the Python interpreter with new
+ modules. Those modules can define new functions but
+ also new object types and their methods. The document
+ also describes how to embed the Python interpreter in
+ another application, for use as an extension language.
+ Finally, it shows how to compile and link extension
+ modules so that they can be loaded dynamically (at run
+ time) into the interpreter, if the underlying operating
+ system supports this feature. This document assumes
+ basic knowledge about Python. For an informal
+ introduction to the language, see the Python Tutorial.
+ The Python Reference Manual gives a more formal
+ definition of the language. The Python Library
+ Reference documents the existing object types,
+ functions and modules (both built-in and written in
+ Python) that give the language its wide application
+ range.",
+ acknowledgement = ack-nhfb,
+ keywords = "Object-oriented programming (Computer science);
+ Programming languages (Electronic computers)",
+}
+
+@TechReport{vanRossum:1995:PLR,
+ author = "Guido {van Rossum}",
+ title = "{Python} library reference",
+ type = "Report",
+ number = "CS-R9524",
+ institution = pub-CWI,
+ address = pub-CWI:adr,
+ pages = "iv + 186",
+ month = apr,
+ year = "1995",
+ bibdate = "Fri May 22 14:34:22 1998",
+ URL = "http://www.python.org/doc/lib/lib.html",
+ abstract = "Python is an extensible, interpreted, object-oriented
+ programming language. It supports a wide range of
+ applications, from simple text processing scripts to
+ interactive WWW browsers. While the Python Reference
+ Manual describes the exact syntax and semantics of the
+ language, it does not describe the standard library
+ that is distributed with the language, and which
+ greatly enhances its immediate usability. This library
+ contains built-in modules (written in C) that provide
+ access to system functionality such as file I/O that
+ would otherwise be inaccessible to Python programmers,
+ as well as modules written in Python that provide
+ standardized solutions for many problems that occur in
+ everyday programming. Some of theses modules are
+ explicitly designed to encourage and enhance the
+ portability of Python programs. This library reference
+ manual documents Python's standard library, as well as
+ many optional library modules (which may or may not be
+ available, depending on whether the underlying platform
+ supports them and on the configuration choices made at
+ compile time). It also documents the standard types of
+ the language and its built-in functions and exceptions,
+ many of which are not or incompletely documented in the
+ Reference Manual. This manual assumes basic knowledge
+ about the Python language. For an informal introduction
+ to Python, see the Python Tutorial; the Python
+ Reference Manual remains the highest authority on
+ syntactic and semantic questions. Finally, the manual
+ entitled Extending and Embedding the Python Interpreter
+ describes how to add new extensions to Python and how
+ to embed it in other applications.''",
+ acknowledgement = ack-nhfb,
+ keywords = "Object-oriented programming (Computer science);
+ Programming languages (Electronic computers)",
+}
+
+@TechReport{vanRossum:1995:PRM,
+ author = "Guido {van Rossum}",
+ title = "{Python} reference manual",
+ type = "Report",
+ number = "CS-R9525",
+ institution = pub-CWI,
+ address = pub-CWI:adr,
+ pages = "ii + 54",
+ month = apr,
+ year = "1995",
+ bibdate = "Thu May 21 14:06:05 MDT 1998",
+ URL = "http://www.python.org/doc/ref/ref-1.html",
+ abstract = "Python is a simple, yet powerful, interpreted
+ programming language that bridges the gap between C and
+ shell programming, and is thus ideally suited for
+ `throw-away programming' and rapid prototyping. Its
+ syntax is put together from constructs borrowed from a
+ variety of other languages; most prominent are
+ influences from ABC, C, Modula-3 and Icon. The Python
+ interpreter is easily extended with new functions and
+ data types implemented in C. Python is also suitable as
+ an extension language for highly customizable C
+ applications such as editors or window managers. Python
+ is available for various operating systems, amongst
+ which several flavors of UNIX (including Linux), the
+ Apple Macintosh O.S., MS-DOS, MS-Windows 3.1, Windows
+ NT, and OS/2. This reference manual describes the
+ syntax and `core semantics' of the language. It is
+ terse, but attempts to be exact and complete. The
+ semantics of non-essential built-in object types and of
+ the built-in functions and modules are described in the
+ Python Library Reference. For an informal introduction
+ to the language, see the Python Tutorial.",
+ acknowledgement = ack-nhfb,
+ keywords = "Object-oriented programming (Computer science);
+ Programming languages (Electronic computers)",
+}
+
+@TechReport{vanRossum:1995:PT,
+ author = "Guido {van Rossum}",
+ title = "{Python} tutorial",
+ type = "Report",
+ number = "CS-R9526",
+ institution = pub-CWI,
+ address = pub-CWI:adr,
+ pages = "iii + 65",
+ month = apr,
+ year = "1995",
+ bibdate = "Thu May 21 14:06:05 MDT 1998",
+ URL = "http://www.python.org/doc/tut/tut.html",
+ abstract = "Python is a simple, yet powerful programming language
+ that bridges the gap between C and shell programming,
+ and is thus ideally suited for `throw-away programming'
+ and rapid prototyping. Its syntax is put together from
+ constructs borrowed from a variety of other languages;
+ most prominent are influences from ABC, C, Modula-3 and
+ Icon. The Python interpreter is easily extended with
+ new functions and data types implemented in C. Python
+ is also suitable as an extension language for highly
+ customizable C applications such as editors or window
+ managers. Python is available for various operating
+ systems, amongst which several flavors of UNIX, Amoeba,
+ the Apple Macintosh O.S., and MS-DOS. This tutorial
+ introduces the reader informally to the basic concepts
+ and features of the Python language and system. It
+ helps to have a Python interpreter handy for hands-on
+ experience, but as the examples are self-contained, the
+ tutorial can be read off-line as well. For a
+ description of standard objects and modules, see the
+ Python Library Reference manual. The Python Reference
+ Manual gives a more formal definition of the
+ language.",
+ acknowledgement = ack-nhfb,
+ keywords = "Object-oriented programming (Computer science);
+ Programming languages (Electronic computers)",
+}
+
+@Article{Watters:1995:TAN,
+ author = "Aaron R. Watters",
+ title = "Tutorial Article No. 005: The What, Why, Who, and
+ Where of {Python}",
+ journal = "UnixWorld Online",
+ volume = "??",
+ number = "??",
+ pages = "??--??",
+ month = "????",
+ year = "1995",
+ bibdate = "Thu May 21 16:11:31 1998",
+ URL = "http://www.wcmh.com/uworld/archives/95/tutorial/005.html",
+ acknowledgement = ack-nhfb,
+}
+
+@Article{Bauer:1996:IP,
+ author = "Jeff Bauer",
+ title = "An Introduction to {Python}",
+ journal = j-LINUX-J,
+ volume = "21",
+ pages = "??--??",
+ month = jan,
+ year = "1996",
+ CODEN = "LIJOFX",
+ ISSN = "1075-3583",
+ bibdate = "Fri Oct 9 08:35:26 MDT 1998",
+ bibsource = "http://www.linuxjournal.com/issue21/index.html",
+ abstract = "Do you need help in the rapid development of
+ applications? Python could be the language for you.",
+ acknowledgement = ack-nhfb,
+}
+
+@InProceedings{Beazley:1996:SEU,
+ author = "D. M. Beazley",
+ title = "{SWIG}: an easy to use tool for integrating scripting
+ languages with {C} and {C++}",
+ crossref = "USENIX:1996:ATT",
+ pages = "129--139",
+ year = "1996",
+ bibdate = "Thu May 21 19:02:04 MDT 1998",
+ acknowledgement = ack-nhfb,
+ classification = "C6115 (Programming support); C6140D (High level
+ languages); C6180 (User interfaces)",
+ corpsource = "Dept. of Comput. Sci., Utah Univ., Salt Lake City, UT,
+ USA",
+ keywords = "ANSI C/C++ declarations; ASCII format; authoring
+ languages; automatic bindings generation; C language;
+ C++ language; classes; data types; documentation;
+ Guile; HTML; language integration; LaTeX; Perl;
+ pointers; program development tool; programming
+ environments; Python; scripting languages; Simplified
+ Wrapper and Interface Generator; software tools;
+ structures; SWIG; system documentation; Tcl/Tk; user
+ interface management systems",
+ treatment = "P Practical",
+}
+
+@Article{Crespo:1996:WBB,
+ author = "Arturo Crespo and Eric A. Bier",
+ title = "{WebWriter}: {A} browser-based editor for constructing
+ {Web} applications",
+ journal = j-COMP-NET-ISDN,
+ volume = "28",
+ number = "7--11",
+ pages = "1291--1306",
+ day = "1",
+ month = may,
+ year = "1996",
+ CODEN = "CNISE9",
+ ISSN = "0169-7552",
+ bibdate = "Fri Sep 24 20:21:29 MDT 1999",
+ bibsource = "ftp://ftp.math.utah.edu/pub/tex/bib/python.bib;
+ ftp://ftp.math.utah.edu/pub/tex/bib/sgml.bib;
+ http://www.elsevier.com/cgi-bin/cas/tree/store/cna/cas_free/browse/browse.cgi?year=1996&volume=28&issue=7-11",
+ URL = "http://www.elsevier.com/cgi-bin/cas/tree/store/comnet/cas_sub/browse/browse.cgi?year=1996&volume=28&issue=7-11&aid=1616",
+ acknowledgement = ack-nhfb,
+ affiliation = "Dept. of Comput. Sci., Stanford Univ., CA, USA",
+ classification = "C6115 (Programming support); C6130D (Document
+ processing techniques); C6130M (Multimedia); C6140D
+ (High level languages); C6150N (Distributed systems
+ software); C6180 (User interfaces)",
+ conflocation = "Paris, France; 6-10 May 1996",
+ conftitle = "Fifth International World Wide Web Conference",
+ corpsource = "Dept. of Comput. Sci., Stanford Univ., CA, USA",
+ keywords = "application generators; authoring systems;
+ browser-based editor; CGI protocol; clickable maps;
+ Common Gateway Interface; direct-manipulation Web page
+ editor; HTML extensions; hypermedia; Hypertext Markup
+ Language; network servers; nonprogrammers; output
+ regions; page description languages; page stack;
+ programming languages; Python; script; server-based
+ authoring tools; server-based World Wide Web
+ applications construction; server-side editors; SGML;
+ software packages; text editing; toolkit; user
+ interface layout; Web page generating programs;
+ WebWriter; {Internet}",
+ pubcountry = "Netherlands",
+ treatment = "P Practical",
+}
+
+@Article{Dubois:1996:EPO,
+ author = "P. F. Dubois and T.-Y. Yang",
+ title = "Extending {Python} [Object-oriented language]",
+ journal = j-COMP-PHYSICS,
+ volume = "10",
+ number = "4",
+ pages = "359--365",
+ month = jul # "\slash " # aug,
+ year = "1996",
+ CODEN = "CPHYE2",
+ ISSN = "0894-1866",
+ bibdate = "Thu May 21 19:02:04 MDT 1998",
+ acknowledgement = ack-nhfb,
+ classification = "C6110J (Object-oriented programming); C6120 (File
+ organisation); C6130 (Data handling techniques); C6140D
+ (High level languages); C6150C (Compilers, interpreters
+ and other processors); C7300 (Natural sciences
+ computing)",
+ corpsource = "Lawrence Livermore Nat. Lab., CA, USA",
+ keywords = "C language; C++; C++ static-constructor problem,;
+ compiled sources; dynamic loading; embedding; exception
+ handling; first-class functions; Fortran; free
+ language; garbage collection; high-performance
+ numerical extension; interpreted language; natural
+ sciences computing; object types; object- oriented
+ languages; object-oriented language; object-oriented
+ programming; portable language; program interpreters;
+ programmable application; Python interpreter; Python
+ language; Python program; scientific programming;
+ storage management; user interface",
+ treatment = "P Practical",
+}
+
+@Article{Dubois:1996:NP,
+ author = "P. F. Dubois and K. Hinsen and J. Hugunin",
+ title = "Numerical {Python}",
+ journal = j-COMP-PHYSICS,
+ volume = "10",
+ number = "3",
+ pages = "262--267",
+ month = may # "\slash " # jun,
+ year = "1996",
+ CODEN = "CPHYE2",
+ ISSN = "0894-1866",
+ bibdate = "Sun Apr 13 12:29:32 MDT 1997",
+ bibsource = "ftp://ftp.math.utah.edu/pub/tex/bib/linux.bib",
+ abstract = "Python is a small and easy-to-learn language with
+ surprising capabilities. It is an interpreted
+ object-oriented scripting language and has a full range
+ of sophisticated features such as first-class
+ functions, garbage collection, and exception handling.
+ Python has properties that make it especially appealing
+ for scientific programming: Python is quite simple and
+ easy to learn, but it is a full and complete language.
+ It is simple to extend Python with your own compiled
+ objects and functions. Python is portable, from Unix to
+ Windows 95 to Linux to Macintosh. Python is free, with
+ no license required even if you make a commercial
+ product out of it. Python has a large user-contributed
+ library of ``modules''. These modules cover a wide
+ variety of needs, such as audio and image processing,
+ World Wide Web programming, and graphical user
+ interfaces. In particular, there is an interface to the
+ popular Tk package for building windowing applications.
+ And now, Python has a high-performance array module
+ similar to the facilities in specialized array
+ languages such as Matlab, IDL, Basis, or Yorick. This
+ extension also adds complex numbers to the language.
+ Array operations in Python lead to the execution of
+ loops in C, so that most of the work is done at full
+ compiled speed.",
+ acknowledgement = ack-nhfb,
+ classcodes = "C6140D (High level languages); C6110J (Object-oriented
+ programming); C6150C (Compilers, interpreters and other
+ processors); C7300 (Natural sciences computing)",
+ corpsource = "Lawrence Livermore Nat. Lab., CA, USA",
+ keywords = "applications; compiled objects; exception; first-class
+ functions; garbage collection; graphical user
+ interfaces; handling; high-performance array module;
+ interpreted object-oriented scripting language; natural
+ sciences computing; object-oriented languages; program
+ interpreters; Python; scientific programming; Wide Web
+ programming; windowing; World",
+ treatment = "P Practical",
+}
+
+@Article{Dubois:1996:SPE,
+ author = "Paul F. Dubois and T.-Y. Yang",
+ title = "Scientific Programming: Extending {Python}",
+ journal = j-COMP-PHYSICS,
+ volume = "10",
+ number = "4",
+ pages = "359--??",
+ month = "????",
+ year = "1996",
+ CODEN = "CPHYE2",
+ ISSN = "0894-1866",
+ bibdate = "Thu May 21 16:28:33 MDT 1998",
+ acknowledgement = ack-nhfb,
+}
+
+@InProceedings{Hylton:1996:KPS,
+ author = "J. Hylton and K. Manheimer and F. L. {Drake, Jr.} and
+ B. Warsaw and R. Masse and G. {van Rossum}",
+ title = "Knowbot Programming: system support for mobile
+ agents",
+ crossref = "Cabrera:1996:PFI",
+ pages = "8--13",
+ year = "1996",
+ bibdate = "Thu May 21 19:02:04 MDT 1998",
+ acknowledgement = ack-nhfb,
+ classification = "C6110J (Object-oriented programming); C6130S (Data
+ security); C6150N (Distributed systems software); C6170
+ (Expert systems)",
+ conftitle = "Proceedings of the Fifth International Workshop on
+ Object- Orientation in Operating Systems",
+ corpsource = "Corporation for Nat. Res. Initiatives, Reston, VA,
+ USA",
+ keywords = "cooperative systems; distributed systems; Internet;
+ interprocess communication; Knowbot Programs; mobile
+ agents; multiple autonomous agents; network resources;
+ object-oriented languages; object-oriented programming;
+ object-oriented programming language; process
+ migration; prototype system; Python; security; security
+ of data; software agents",
+ sponsororg = "IEEE Comput. Soc. Tech. Committee on Oper. Syst.;
+ USENIX",
+ treatment = "P Practical",
+}
+
+@Book{Lutz:1996:PP,
+ author = "Mark Lutz",
+ title = "Programming {Python}",
+ publisher = pub-ORA,
+ address = pub-ORA:adr,
+ pages = "xxii + 880",
+ month = "Fall",
+ year = "1996",
+ ISBN = "1-56592-197-6",
+ LCCN = "QA76.73.P98L88 1996",
+ bibdate = "Sat Jun 28 10:26:23 1997",
+ bibsource = "ftp://ftp.math.utah.edu/pub/tex/bib/ora.bib",
+ note = "Also available in Japanese translation, see
+ \path=http://www.oreilly.co.jp/BOOK/python1.htm=.",
+ price = "US\$39.95",
+ URL = "http://www.oreilly.com/catalog/python;
+ http://shell.rmi.net/~lutz/",
+ acknowledgement = ack-nhfb,
+ keywords = "Python (Computer program language)",
+}
+
+@Article{Troan:1996:FSSa,
+ author = "Erik Troan",
+ title = "Free Software Solutions: The {Python} Language",
+ journal = j-X-J,
+ volume = "5",
+ number = "5",
+ pages = "96--??",
+ month = may,
+ year = "1996",
+ CODEN = "XJOUEA",
+ ISSN = "1056-7003",
+ bibdate = "Thu Sep 05 09:14:34 1996",
+ bibsource = "ftp://ftp.math.utah.edu/pub/tex/bib/xjournal.bib",
+ acknowledgement = ack-nhfb,
+}
+
+@Article{Troan:1996:FSSb,
+ author = "Erik Troan",
+ title = "Free Software Solutions: Basic {X} Programming in
+ {Python}",
+ journal = j-X-J,
+ volume = "5",
+ number = "6",
+ pages = "84--??",
+ month = jun,
+ year = "1996",
+ CODEN = "XJOUEA",
+ ISSN = "1056-7003",
+ bibdate = "Thu Sep 05 09:14:34 1996",
+ bibsource = "ftp://ftp.math.utah.edu/pub/tex/bib/xjournal.bib",
+ acknowledgement = ack-nhfb,
+}
+
+@Article{Troan:1996:FSSc,
+ author = "Erik Troan",
+ title = "Free Software Solutions: Meta Widgets in {Python}",
+ journal = j-X-J,
+ volume = "5",
+ number = "7",
+ pages = "??--??",
+ month = jul # "\slash " # aug,
+ year = "1996",
+ CODEN = "XJOUEA",
+ ISSN = "1056-7003",
+ bibdate = "Wed Sep 4 09:14:40 1996",
+ bibsource = "ftp://ftp.math.utah.edu/pub/tex/bib/xjournal.bib;
+ http://www.sigs.com/publications/docs/txjr/9607/txjr9607.toc.html",
+}
+
+@Book{Watters:1996:IPP,
+ author = "Aaron Watters and Guido {van Rossum} and James C.
+ Ahlstrom",
+ title = "{Internet} programming with {Python}",
+ publisher = pub-MT,
+ address = pub-MT:adr,
+ pages = "xviii + 477",
+ year = "1996",
+ ISBN = "1-55851-484-8",
+ LCCN = "QA76.73.P98 W38 1996",
+ bibdate = "Thu May 21 11:05:40 1998",
+ price = "US\$34.95",
+ URL = "http://www.fsbassociates.com/books/python.htm",
+ acknowledgement = ack-nhfb,
+ annote = "See book review \cite{Johnson:1997:BRI}.",
+ keywords = "Internet (Computer network); Python (Computer program
+ language)",
+}
+
+@Article{Anonymous:1997:BRI,
+ author = "Anonymous",
+ title = "Book Review: {Internet Programming with Python}",
+ journal = j-LINUX-J,
+ volume = "42",
+ pages = "??--??",
+ month = oct,
+ year = "1997",
+ CODEN = "LIJOFX",
+ ISSN = "1075-3583",
+ bibdate = "Fri Oct 9 08:35:26 MDT 1998",
+ bibsource = "http://www.linuxjournal.com/issue42/index.html",
+ URL = "http://www.linuxjournal.com/2152.html",
+ acknowledgement = ack-nhfb,
+}
+
+@Article{Arnold:1997:HDO,
+ author = "David Arnold and Andy Bond and Martin Chilvers",
+ title = "{Hector}: Distributed Objects in {Python}",
+ journal = j-DDJ-SOURCEBOOK,
+ volume = "??",
+ number = "??",
+ pages = "??--??",
+ month = jan # "\slash " # feb,
+ year = "1997",
+ ISSN = "1077-9019",
+ bibdate = "Thu May 21 15:33:54 1998",
+ URL = "http://www.ddj.com/ddsbk/1997/1997_01/arno.htm",
+ acknowledgement = ack-nhfb,
+}
+
+@InProceedings{Beazley:1997:BFL,
+ author = "David M. Beazley and Peter S. Lomdahl",
+ title = "Building flexible large-scale scientific computing
+ applications with scripting languages",
+ crossref = "Heath:1997:PES",
+ year = "1997",
+ bibdate = "Fri May 22 09:14:10 MDT 1998",
+ bibsource = "Compendex database",
+ abstract = "We describe our use of scripting languages with a
+ large-scale molecular dynamics code. We will show how
+ one can build an interactive, highly modular, and
+ easily extensible system without sacrificing
+ performance, building a huge monolithic package, or
+ complicating code development. We will also describe
+ our use of the Python language and the SWIG automated
+ interface generation tool that we have developed for
+ easily creating scripting language interfaces to C/C++
+ programs.",
+ acknowledgement = ack-nhfb,
+ affiliation = "Univ of Utah",
+ affiliationaddress = "Salt Lake City, UT, USA",
+ journalabr = "Proc SIAM Conf Parallel Process Sci Comput",
+ pagecount = "8",
+}
+
+@InProceedings{Beazley:1997:EMP,
+ author = "D. M. Beazley and P. S. Lomdahl",
+ title = "Extensible message passing application development and
+ debugging with {Python}",
+ crossref = "IEEE:1997:PIP",
+ pages = "650--655",
+ year = "1997",
+ bibdate = "Thu May 21 19:02:04 MDT 1998",
+ acknowledgement = ack-nhfb,
+ classification = "C5220P (Parallel architecture)C5440 (Multiprocessing
+ systems); C6110P (Parallel programming); C6115
+ (Programming support); C6140D (High level languages);
+ C6150C (Compilers, interpreters and other processors);
+ C6150G (Diagnostic, testing, debugging and evaluating
+ systems); C6150N (Distributed systems software)",
+ conftitle = "Proceedings 11th International Parallel Processing
+ Symposium",
+ corpsource = "Dept. of Comput. Sci., Utah Univ., Salt Lake City, UT,
+ USA",
+ keywords = "application specific debugging; CM-5; Cray T3D;
+ extensible message passing application debugging;
+ extensible message passing application development;
+ interpreted object oriented scripting language;
+ large-scale message passing applications; message
+ passing; message passing program writing; molecular
+ dynamics application; MPI; multiprocessing systems;
+ object-oriented languages; parallel machines; parallel
+ programming; program debugging; program interpreters;
+ Python parallelisation; rapid prototyping; software
+ prototyping; Sun multiprocessor servers",
+ sponsororg = "IEEE Comput. Soc. Tech. Committee on Parallel
+ Process.; ACM SIGARCH; Eur. Assoc. Theor. Comput. Sci.
+ (EATCS); Swiss Special Interest Group on Parallelism
+ (SIPAR); SPPEDUP Soc",
+ treatment = "P Practical",
+}
+
+@Article{Bielak:1997:UPG,
+ author = "Richie Bielak",
+ title = "Using {Python} to Generate {HTML} Pages",
+ journal = "Linux Gazette",
+ volume = "19",
+ number = "??",
+ pages = "??--??",
+ month = jul,
+ year = "1997",
+ bibdate = "Thu May 21 15:19:57 1998",
+ URL = "http://www.ssc.com/lg/issue19/python.html",
+ acknowledgement = ack-nhfb,
+}
+
+@InProceedings{Hammer:1997:ESI,
+ author = "J. Hammer and H. Garcia-Molina and J. Cho and R.
+ Aranha and Crespo and A.",
+ title = "Extracting semistructured information from the {Web}",
+ crossref = "Anonymous:1997:PWM",
+ pages = "18--25",
+ year = "1997",
+ bibdate = "Thu May 21 19:02:04 MDT 1998",
+ acknowledgement = ack-nhfb,
+ classification = "C6160B (Distributed databases); C7210 (Information
+ services and centres); C7250 (Information storage and
+ retrieval)",
+ conflocation = "Tucson, AZ, USA; 16 May 1997",
+ conftitle = "Proceedings of Workshop on Management of
+ Semi-Structured Data",
+ corpsource = "Dept. of Comput. Sci., Stanford Univ., CA, USA",
+ keywords = "configurable tool; DARPA I/sup 3/ technology
+ demonstration; database objects; declarative
+ specification; distributed databases; HTML pages;
+ information conversion; information retrieval;
+ Internet; Python programming language; semistructured
+ information extraction; TSIMMIS testbed; various WWW
+ sites; weather data extraction; Web extractor",
+ sponsororg = "NSF",
+ treatment = "P Practical",
+}
+
+@Unpublished{Hugunin:1997:PJB,
+ author = "Jim Hugunin",
+ title = "{Python} and {Java}: The Best of Both Worlds",
+ year = "1997",
+ bibdate = "Tue Jan 06 09:29:45 1998",
+ bibsource = "ftp://ftp.math.utah.edu/pub/tex/bib/java.bib",
+ note = "Discusses an implementation of the Python scripting
+ language in Java. The article and the code are
+ available electronically.",
+ URL = "http://www.python.org/jpython/",
+ acknowledgement = ack-nhfb,
+}
+
+@Article{Johnson:1997:BRI,
+ author = "Dwight Johnson",
+ title = "Book Review: {{\em Internet Programming with
+ Python}}",
+ journal = j-LINUX-J,
+ volume = "42",
+ pages = "??--??",
+ month = oct,
+ year = "1997",
+ CODEN = "LIJOFX",
+ ISSN = "1075-3583",
+ bibdate = "Fri Apr 30 10:36:13 1999",
+ note = "See book \cite{Watters:1996:IPP}.",
+ URL = "http://www.ssc.com/lj/issue42/2152.html",
+ acknowledgement = ack-nhfb,
+}
+
+@Article{Kim:1997:DIW,
+ author = "Hyeon Jong Kim and Ki Ho Lee",
+ title = "Design and implementation of {Web} documents creating
+ system with {HTML}-supporting library",
+ journal = "Journal of KISS(C) (Computing Practices)",
+ volume = "3",
+ number = "4",
+ pages = "375--383",
+ month = aug,
+ year = "1997",
+ CODEN = "CKNCFY",
+ ISSN = "1226-2293",
+ bibdate = "Thu May 21 19:02:04 MDT 1998",
+ acknowledgement = ack-nhfb,
+ classification = "C5620W (Other computer networks); C6110J
+ (Object-oriented programming); C6130D (Document
+ processing techniques); C6130M (Multimedia); C6140D
+ (High level languages); C6150N (Distributed systems
+ software); C7210 (Information services and centres)",
+ corpsource = "Korea Inf. Sci. Soc., Seoul, South Korea",
+ keywords = "CGI program; compact program; GUI; HTML documents;
+ HTML supporting library; hypermedia; Internet;
+ nonsequential construction; object oriented design;
+ object oriented programming language; object-oriented
+ languages; page description languages; print
+ statements; Python; Web browser; Web document creation
+ system; Web documents",
+ language = "Korean",
+ pubcountry = "South Korea",
+ treatment = "P Practical",
+}
+
+@Article{Kuchling:1997:PU,
+ author = "Andrew Kuchling",
+ title = "{Python} Update",
+ journal = j-LINUX-J,
+ volume = "37",
+ pages = "??--??",
+ month = may,
+ year = "1997",
+ CODEN = "LIJOFX",
+ ISSN = "1075-3583",
+ bibdate = "Fri Oct 9 08:35:26 MDT 1998",
+ bibsource = "http://www.linuxjournal.com/issue37/index.html",
+ acknowledgement = ack-nhfb,
+}
+
+@Article{Laird:1997:CSL,
+ author = "Cameron Laird and Kathryn Soraiz",
+ title = "Choosing a scripting language: {Perl}, {Tcl}, and
+ {Python}: they're not your father's scripting
+ languages",
+ journal = j-SUNWORLD-ONLINE,
+ volume = "??",
+ number = "??",
+ pages = "??--??",
+ month = oct,
+ year = "1997",
+ ISSN = "1091-8914",
+ bibdate = "Thu May 21 15:17:09 1998",
+ URL = "http://www.sun.com/sunworldonline/swol-10-1997/swol-10-scripting.html",
+ acknowledgement = ack-nhfb,
+}
+
+@Article{Orlowski:1997:NSC,
+ author = "A. Orlowski",
+ title = "And now for something completely different? [{Python}
+ language]",
+ journal = j-EXE,
+ volume = "12",
+ number = "2",
+ pages = "34--35, 37, 39, 41",
+ month = jul,
+ year = "1997",
+ CODEN = "EXEEE5",
+ ISSN = "0268-6872",
+ bibdate = "Thu May 21 19:02:04 MDT 1998",
+ acknowledgement = ack-nhfb,
+ classification = "C6110J (Object-oriented programming); C6140D (High
+ level languages); C6150N (Distributed systems
+ software)",
+ keywords = "Amoeba operating system; API; application program
+ interfaces; authoring languages; BSD- style sockets;
+ CGI facilities; client- server systems; client-server
+ system; CORBA; graphical user interface; GUI toolkits;
+ ILU; object-oriented languages; object-oriented
+ programming; operating systems (computers); Python
+ language; scripting language; shared objects; software
+ libraries; SQL interfaces",
+ pubcountry = "UK",
+ treatment = "P Practical",
+}
+
+@InProceedings{Pierce:1997:AEU,
+ author = "J. S. Pierce and S. Audia and T. Burnette and K.
+ Christiansen and D. Cosgrove and M. Conway and K.
+ Hinckley and K. Monkaitis and J. Patten and J. Shothet
+ and D. Staack and B. Stearns and Sturgill and C. and G.
+ Williams and R. Pausch",
+ title = "{Alice}: easy to use interactive {3D} graphics",
+ crossref = "ACM:1997:PAS",
+ pages = "77--78",
+ year = "1997",
+ bibdate = "Thu May 21 19:02:04 MDT 1998",
+ acknowledgement = ack-nhfb,
+ classification = "C6115 (Programming support); C6130B (Graphics
+ techniques); C6180 (User interfaces)",
+ conftitle = "Proceedings of Tenth Annual Symposium on User
+ Interface Software and Technology",
+ corpsource = "Dept. of Comput. Sci., Carnegie Mellon Univ.,
+ Pittsburgh, PA, USA",
+ keywords = "Alice; authoring languages; ease of use; human
+ factors; interactive 3D graphics; interactive
+ development environment; interactive systems; Internet;
+ interpreted language; Python; rapid prototyping system;
+ scripting language; simulations; software prototyping;
+ solid modelling; three dimensional graphics; usability;
+ user actions; user interfaces; virtual reality; virtual
+ reality applications; Windows 95",
+ sponsororg = "ACM",
+ treatment = "P Practical",
+}
+
+@InProceedings{Plosch:1997:DCP,
+ author = "R. Plosch",
+ title = "Design by contract for {Python}",
+ crossref = "IEEE:1997:PAP",
+ pages = "213--219",
+ year = "1997",
+ bibdate = "Thu May 21 19:02:04 MDT 1998",
+ acknowledgement = ack-nhfb,
+ classification = "C6110J (Object-oriented programming); C6140D (High
+ level languages)",
+ conftitle = "Proceedings of Joint 4th International Computer
+ Science Conference and 4th Asia Pacific Software
+ Engineering Conference",
+ corpsource = "Johannes Kepler Univ., Linz, Austria",
+ keywords = "design by contract; instance variables;
+ object-oriented languages; object-oriented programming;
+ object-oriented software systems; prototyping-oriented
+ software life cycle; run-time system; software
+ prototyping; statically typed object-oriented
+ programming language Eiffel",
+ sponsororg = "Croucher Found.; UNU/IIST; IEEE Hong Kong Sect.
+ Comput. Chapter; ACM Hong Kong Chapter; Hong Kong
+ Comput. Soc",
+ treatment = "P Practical",
+}
+
+@Misc{Rook:1997:LCC,
+ author = "David Rook",
+ title = "A Language Collector Comments On: {Java}, {Perl} \&
+ {Python}",
+ month = oct,
+ year = "1997",
+ bibdate = "Thu May 21 15:18:28 1998",
+ URL = "http://www.chips.navy.mil/chips/archives/97_oct/file12.htm",
+ acknowledgement = ack-nhfb,
+}
+
+@Article{Shell:1997:PDS,
+ author = "Jeffrey P. Shell",
+ title = "{Python} Does Scripts and Objects --- {Python} is a
+ platform-independent {OOP} language with capabilities
+ ranging from simple scripting to sophisticated object
+ libraries",
+ journal = j-...
[truncated message content] |
|
From: <fer...@us...> - 2008-10-19 07:05:11
|
Revision: 6263
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6263&view=rev
Author: fer_perez
Date: 2008-10-19 07:05:06 +0000 (Sun, 19 Oct 2008)
Log Message:
-----------
Remove links to old book dir to make the workbook self-contained.
Removed Paths:
-------------
trunk/py4science/workbook/examples
trunk/py4science/workbook/examples_solved
trunk/py4science/workbook/python.bib
trunk/py4science/workbook/python2.bib
trunk/py4science/workbook/snippets
Deleted: trunk/py4science/workbook/examples
===================================================================
--- trunk/py4science/workbook/examples 2008-10-19 06:58:58 UTC (rev 6262)
+++ trunk/py4science/workbook/examples 2008-10-19 07:05:06 UTC (rev 6263)
@@ -1 +0,0 @@
-link ../book/examples
\ No newline at end of file
Deleted: trunk/py4science/workbook/examples_solved
===================================================================
--- trunk/py4science/workbook/examples_solved 2008-10-19 06:58:58 UTC (rev 6262)
+++ trunk/py4science/workbook/examples_solved 2008-10-19 07:05:06 UTC (rev 6263)
@@ -1 +0,0 @@
-link ../examples
\ No newline at end of file
Deleted: trunk/py4science/workbook/python.bib
===================================================================
--- trunk/py4science/workbook/python.bib 2008-10-19 06:58:58 UTC (rev 6262)
+++ trunk/py4science/workbook/python.bib 2008-10-19 07:05:06 UTC (rev 6263)
@@ -1 +0,0 @@
-link ../book/python.bib
\ No newline at end of file
Deleted: trunk/py4science/workbook/python2.bib
===================================================================
--- trunk/py4science/workbook/python2.bib 2008-10-19 06:58:58 UTC (rev 6262)
+++ trunk/py4science/workbook/python2.bib 2008-10-19 07:05:06 UTC (rev 6263)
@@ -1 +0,0 @@
-link ../book/python2.bib
\ No newline at end of file
Deleted: trunk/py4science/workbook/snippets
===================================================================
--- trunk/py4science/workbook/snippets 2008-10-19 06:58:58 UTC (rev 6262)
+++ trunk/py4science/workbook/snippets 2008-10-19 07:05:06 UTC (rev 6263)
@@ -1 +0,0 @@
-link ../book/snippets
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|