Revision: 7895
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7895&view=rev
Author: mdboom
Date: 2009-10-21 13:23:47 +0000 (Wed, 21 Oct 2009)
Log Message:
-----------
Fix bug in simplification code that was clipping peaks.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/polar_axes.png
trunk/matplotlib/lib/matplotlib/tests/test_simplification.py
trunk/matplotlib/src/path_converters.h
Added Paths:
-----------
trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_simplification/fft_peaks.pdf
trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_simplification/fft_peaks.png
trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_simplification/fft_peaks.svg
Modified:
trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_axes/polar_axes.png
===================================================================
(Binary files differ)
Added:
trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_simplification/fft_peaks.pdf
===================================================================
(Binary files differ)
Property changes on:
trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_simplification/fft_peaks.pdf
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_simplification/fft_peaks.png
===================================================================
(Binary files differ)
Property changes on:
trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_simplification/fft_peaks.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_simplification/fft_peaks.svg
===================================================================
---
trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_simplification/fft_peaks.svg
(rev 0)
+++
trunk/matplotlib/lib/matplotlib/tests/baseline_images/test_simplification/fft_peaks.svg
2009-10-21 13:23:47 UTC (rev 7895)
@@ -0,0 +1,50 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Created with matplotlib (http://matplotlib.sourceforge.net/) -->
+<svg width="576pt" height="432pt" viewBox="0 0 576 432"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ version="1.1"
+ id="svg1">
+<filter id="colorAdd"><feComposite in="SourceGraphic" in2="BackgroundImage"
operator="arithmetic" k2="1" k3="1"/></filter>
+<g id="figure1">
+<g id="patch1">
+<path style="fill: #ffffff; stroke: #ffffff; stroke-width: 1.000000;
stroke-linejoin: round; stroke-linecap: square; opacity: 1.000000"
d="M0.000000 432.000000L576.000000 432.000000L576.000000 0.000000
+L0.000000 0.000000L0.000000 432.000000"/>
+</g>
+<g id="axes1">
+<g id="patch2">
+<path style="fill: #ffffff; opacity: 1.000000" d="M72.000000
388.800000L518.400000 388.800000L518.400000 43.200000
+L72.000000 43.200000L72.000000 388.800000"/>
+</g>
+<g id="line2d1">
+<defs>
+ <clipPath id="p50431ccdcb28178602d99d9270004dde">
+<rect x="72.000000" y="43.200000" width="446.400000" height="345.600000"/>
+ </clipPath>
+</defs><path style="fill: none; stroke: #0000ff; stroke-width: 1.000000;
stroke-linejoin: round; stroke-linecap: square; opacity: 1.000000"
clip-path="url(#p50431ccdcb28178602d99d9270004dde)" d="M72.000000
388.800000L76.145143 388.578724L76.151520 388.455734
+L76.157897 388.474541L76.177029 70.552590L76.489509 388.799636
+L175.303337 388.800000L485.723520 388.493668L485.736274 386.681411
+L485.755406 70.552590L486.067886 388.799652L489.926057 388.800000
+L489.926057 388.800000"/>
+</g>
+<g id="matplotlib.axis1">
+</g>
+<g id="matplotlib.axis2">
+</g>
+<g id="patch3">
+<path style="fill: none; stroke: #000000; stroke-width: 1.000000;
stroke-linejoin: round; stroke-linecap: square; opacity: 1.000000"
d="M72.000000 43.200000L518.400000 43.200000"/>
+</g>
+<g id="patch4">
+<path style="fill: none; stroke: #000000; stroke-width: 1.000000;
stroke-linejoin: round; stroke-linecap: square; opacity: 1.000000"
d="M518.400000 388.800000L518.400000 43.200000"/>
+</g>
+<g id="patch5">
+<path style="fill: none; stroke: #000000; stroke-width: 1.000000;
stroke-linejoin: round; stroke-linecap: square; opacity: 1.000000"
d="M72.000000 388.800000L518.400000 388.800000"/>
+</g>
+<g id="patch6">
+<path style="fill: none; stroke: #000000; stroke-width: 1.000000;
stroke-linejoin: round; stroke-linecap: square; opacity: 1.000000"
d="M72.000000 388.800000L72.000000 43.200000"/>
+</g>
+</g>
+</g>
+</svg>
Modified: trunk/matplotlib/lib/matplotlib/tests/test_simplification.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_simplification.py
2009-10-19 09:04:42 UTC (rev 7894)
+++ trunk/matplotlib/lib/matplotlib/tests/test_simplification.py
2009-10-21 13:23:47 UTC (rev 7895)
@@ -70,7 +70,7 @@
path = transform.transform_path(path)
simplified = list(path.iter_segments(simplify=(800, 600)))
- assert len(simplified) == 2662
+ assert len(simplified) == 2675
def test_sine_plus_noise():
np.random.seed(0)
@@ -87,7 +87,7 @@
path = transform.transform_path(path)
simplified = list(path.iter_segments(simplify=(800, 600)))
- assert len(simplified) == 279
+ assert len(simplified) == 628
@image_comparison(baseline_images=['simplify_curve'])
def test_simplify_curve():
@@ -116,7 +116,24 @@
fig.savefig('hatch_simplify')
+...@image_comparison(baseline_images=['fft_peaks'])
+def test_fft_peaks():
+ fig = plt.figure()
+ t = arange(65536)
+ ax = fig.add_subplot(111)
+ p1 = ax.plot(abs(fft(sin(2*pi*.01*t)*blackman(len(t)))))
+ ax.set_xticks([])
+ ax.set_yticks([])
+ fig.savefig('fft_peaks')
+
+ path = p1[0].get_path()
+ transform = p1[0].get_transform()
+ path = transform.transform_path(path)
+ simplified = list(path.iter_segments(simplify=(800, 600)))
+
+ assert len(simplified) == 13
+
if __name__=='__main__':
import nose
nose.runmodule(argv=['-s','--with-doctest'], exit=False)
Modified: trunk/matplotlib/src/path_converters.h
===================================================================
--- trunk/matplotlib/src/path_converters.h 2009-10-19 09:04:42 UTC (rev
7894)
+++ trunk/matplotlib/src/path_converters.h 2009-10-21 13:23:47 UTC (rev
7895)
@@ -568,11 +568,15 @@
}
m_after_moveto = false;
+ /* NOTE: We used to skip this very short segments, but if
+ you have a lot of them cumulatively, you can miss
+ maxima or minima in the data. */
+
/* Don't render line segments less than one pixel long */
- if (fabs(*x - m_lastx) < 1.0 && fabs(*y - m_lasty) < 1.0)
- {
- continue;
- }
+ /* if (fabs(*x - m_lastx) < 1.0 && fabs(*y - m_lasty) < 1.0) */
+ /* { */
+ /* continue; */
+ /* } */
/* if we have no orig vector, set it to this vector and
continue. this orig vector is the reference vector we
@@ -649,7 +653,7 @@
}
else
{
- if (paradNorm2 > m_dnorm2Min)
+ if (paradNorm2 < m_dnorm2Min)
{
m_dnorm2Min = paradNorm2;
m_nextX = *x;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins