Revision: 7927
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7927&view=rev
Author:   jdh2358
Date:     2009-11-03 20:51:55 +0000 (Tue, 03 Nov 2009)

Log Message:
-----------
added pca test

Modified Paths:
--------------
    trunk/matplotlib/lib/matplotlib/__init__.py
    trunk/matplotlib/lib/matplotlib/mlab.py

Added Paths:
-----------
    trunk/matplotlib/lib/matplotlib/tests/test_mlab.py

Modified: trunk/matplotlib/lib/matplotlib/__init__.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/__init__.py 2009-11-03 20:27:23 UTC (rev 
7926)
+++ trunk/matplotlib/lib/matplotlib/__init__.py 2009-11-03 20:51:55 UTC (rev 
7927)
@@ -905,6 +905,7 @@
     'matplotlib.tests.test_backend_svg',
     'matplotlib.tests.test_basic',
     'matplotlib.tests.test_cbook',
+    'matplotlib.tests.test_mlab',
     'matplotlib.tests.test_transforms',
     'matplotlib.tests.test_axes',
     'matplotlib.tests.test_dates',

Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py     2009-11-03 20:27:23 UTC (rev 
7926)
+++ trunk/matplotlib/lib/matplotlib/mlab.py     2009-11-03 20:51:55 UTC (rev 
7927)
@@ -761,7 +761,7 @@
     """
 
     WARNING: this function is deprecated -- please see class PCA instead
-    
+
     Compute the principal components of *P*.  *P* is a (*numVars*,
     *numObs*) array.  *frac* is the minimum fraction of variance that a
     component must contain to be included.
@@ -870,6 +870,27 @@
         'center the data using the mean and sigma from training set a'
         return (x - self.mu)/self.sigma
 
+
+
+    @staticmethod
+    def _get_colinear():
+        c0 = np.array([
+            0.19294738,  0.6202667 ,  0.45962655,  0.07608613,  0.135818  ,
+            0.83580842,  0.07218851,  0.48318321,  0.84472463,  0.18348462,
+            0.81585306,  0.96923926,  0.12835919,  0.35075355,  0.15807861,
+            0.837437  ,  0.10824303,  0.1723387 ,  0.43926494,  0.83705486])
+
+        c1 = np.array([
+            -1.17705601, -0.513883  , -0.26614584,  0.88067144,  1.00474954,
+            -1.1616545 ,  0.0266109 ,  0.38227157,  1.80489433,  0.21472396,
+            -1.41920399, -2.08158544, -0.10559009,  1.68999268,  0.34847107,
+            -0.4685737 ,  1.23980423, -0.14638744, -0.35907697,  0.22442616])
+
+        c2 = c0 + 2*c1
+        c3 = -3*c0 + 4*c1
+        a = np.array([c3, c0, c1, c2]).T
+        return a
+
 def prctile(x, p = (0.0, 25.0, 50.0, 75.0, 100.0)):
     """
     Return the percentiles of *x*.  *p* can either be a sequence of

Added: trunk/matplotlib/lib/matplotlib/tests/test_mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/tests/test_mlab.py                          
(rev 0)
+++ trunk/matplotlib/lib/matplotlib/tests/test_mlab.py  2009-11-03 20:51:55 UTC 
(rev 7927)
@@ -0,0 +1,11 @@
+import numpy as np
+import matplotlib.mlab as mlab
+
+...@staticmethod
+def test_colinear_pca():
+    a = mlab.PCA._get_colinear()
+    pca = mlab.PCA(a)
+
+    assert(np.allclose(pca.fracs[2:], 0.))
+    assert(np.allclose(pca.Y[:,2:], 0.))
+


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

Reply via email to