[Numpy-svn] r5078 - trunk/numpy/ma/tests

numpy-svn at scipy.org numpy-svn at scipy.org
Thu Apr 24 20:48:35 EDT 2008


Author: pierregm
Date: 2008-04-24 19:48:33 -0500 (Thu, 24 Apr 2008)
New Revision: 5078

Removed:
   trunk/numpy/ma/tests/test_morestats.py
   trunk/numpy/ma/tests/test_mstats.py
Log:
removed tests/test_mstat and tests/test_morestats (now available in scipy)

Deleted: trunk/numpy/ma/tests/test_morestats.py
===================================================================
--- trunk/numpy/ma/tests/test_morestats.py	2008-04-24 06:57:13 UTC (rev 5077)
+++ trunk/numpy/ma/tests/test_morestats.py	2008-04-25 00:48:33 UTC (rev 5078)
@@ -1,114 +0,0 @@
-# pylint: disable-msg=W0611, W0612, W0511,R0201
-"""Tests suite for maskedArray statistics.
-
-:author: Pierre Gerard-Marchant
-:contact: pierregm_at_uga_dot_edu
-:version: $Id: test_morestats.py 317 2007-10-04 19:31:14Z backtopop $
-"""
-__author__ = "Pierre GF Gerard-Marchant ($Author: backtopop $)"
-__version__ = '1.0'
-__revision__ = "$Revision: 317 $"
-__date__     = '$Date: 2007-10-04 15:31:14 -0400 (Thu, 04 Oct 2007) $'
-
-import numpy
-
-import numpy.ma
-from numpy.ma import masked, masked_array
-
-import numpy.ma.mstats
-from numpy.ma.mstats import *
-import numpy.ma.morestats
-from numpy.ma.morestats import *
-
-import numpy.ma.testutils
-from numpy.ma.testutils import *
-
-
-class TestMisc(NumpyTestCase):
-    #
-    def __init__(self, *args, **kwargs):
-        NumpyTestCase.__init__(self, *args, **kwargs)
-    #
-    def test_mjci(self):
-        "Tests the Marits-Jarrett estimator"
-        data = masked_array([ 77, 87, 88,114,151,210,219,246,253,262,
-                             296,299,306,376,428,515,666,1310,2611])
-        assert_almost_equal(mjci(data),[55.76819,45.84028,198.8788],5)
-    #
-    def test_trimmedmeanci(self):
-        "Tests the confidence intervals of the trimmed mean."
-        data = masked_array([545,555,558,572,575,576,578,580,
-                             594,605,635,651,653,661,666])
-        assert_almost_equal(trimmed_mean(data,0.2), 596.2, 1)
-        assert_equal(numpy.round(trimmed_mean_ci(data,0.2),1), [561.8, 630.6])
-
-#..............................................................................
-class TestRanking(NumpyTestCase):
-    #
-    def __init__(self, *args, **kwargs):
-        NumpyTestCase.__init__(self, *args, **kwargs)
-    #
-    def test_ranking(self):
-        x = masked_array([0,1,1,1,2,3,4,5,5,6,])
-        assert_almost_equal(rank_data(x),[1,3,3,3,5,6,7,8.5,8.5,10])
-        x[[3,4]] = masked
-        assert_almost_equal(rank_data(x),[1,2.5,2.5,0,0,4,5,6.5,6.5,8])
-        assert_almost_equal(rank_data(x,use_missing=True),
-                            [1,2.5,2.5,4.5,4.5,4,5,6.5,6.5,8])
-        x = masked_array([0,1,5,1,2,4,3,5,1,6,])
-        assert_almost_equal(rank_data(x),[1,3,8.5,3,5,7,6,8.5,3,10])
-        x = masked_array([[0,1,1,1,2], [3,4,5,5,6,]])
-        assert_almost_equal(rank_data(x),[[1,3,3,3,5],[6,7,8.5,8.5,10]])
-        assert_almost_equal(rank_data(x,axis=1),[[1,3,3,3,5],[1,2,3.5,3.5,5]])
-        assert_almost_equal(rank_data(x,axis=0),[[1,1,1,1,1],[2,2,2,2,2,]])
-
-#..............................................................................
-class TestQuantiles(NumpyTestCase):
-    #
-    def __init__(self, *args, **kwargs):
-        NumpyTestCase.__init__(self, *args, **kwargs)
-    #
-    def test_hdquantiles(self):
-        data = [0.706560797,0.727229578,0.990399276,0.927065621,0.158953014,
-            0.887764025,0.239407086,0.349638551,0.972791145,0.149789972,
-            0.936947700,0.132359948,0.046041972,0.641675031,0.945530547,
-            0.224218684,0.771450991,0.820257774,0.336458052,0.589113496,
-            0.509736129,0.696838829,0.491323573,0.622767425,0.775189248,
-            0.641461450,0.118455200,0.773029450,0.319280007,0.752229111,
-            0.047841438,0.466295911,0.583850781,0.840581845,0.550086491,
-            0.466470062,0.504765074,0.226855960,0.362641207,0.891620942,
-            0.127898691,0.490094097,0.044882048,0.041441695,0.317976349,
-            0.504135618,0.567353033,0.434617473,0.636243375,0.231803616,
-            0.230154113,0.160011327,0.819464108,0.854706985,0.438809221,
-            0.487427267,0.786907310,0.408367937,0.405534192,0.250444460,
-            0.995309248,0.144389588,0.739947527,0.953543606,0.680051621,
-            0.388382017,0.863530727,0.006514031,0.118007779,0.924024803,
-            0.384236354,0.893687694,0.626534881,0.473051932,0.750134705,
-            0.241843555,0.432947602,0.689538104,0.136934797,0.150206859,
-            0.474335206,0.907775349,0.525869295,0.189184225,0.854284286,
-            0.831089744,0.251637345,0.587038213,0.254475554,0.237781276,
-            0.827928620,0.480283781,0.594514455,0.213641488,0.024194386,
-            0.536668589,0.699497811,0.892804071,0.093835427,0.731107772]
-        #
-        assert_almost_equal(hdquantiles(data,[0., 1.]),
-                            [0.006514031, 0.995309248])
-        hdq = hdquantiles(data,[0.25, 0.5, 0.75])
-        assert_almost_equal(hdq, [0.253210762, 0.512847491, 0.762232442,])
-        hdq = hdquantiles_sd(data,[0.25, 0.5, 0.75])
-        assert_almost_equal(hdq, [0.03786954, 0.03805389, 0.03800152,], 4)
-        #
-        data = numpy.array(data).reshape(10,10)
-        hdq = hdquantiles(data,[0.25,0.5,0.75],axis=0)
-        assert_almost_equal(hdq[:,0], hdquantiles(data[:,0],[0.25,0.5,0.75]))
-        assert_almost_equal(hdq[:,-1], hdquantiles(data[:,-1],[0.25,0.5,0.75]))
-        hdq = hdquantiles(data,[0.25,0.5,0.75],axis=0,var=True)
-        assert_almost_equal(hdq[...,0],
-                            hdquantiles(data[:,0],[0.25,0.5,0.75],var=True))
-        assert_almost_equal(hdq[...,-1],
-                            hdquantiles(data[:,-1],[0.25,0.5,0.75], var=True))
-
-
-###############################################################################
-#------------------------------------------------------------------------------
-if __name__ == "__main__":
-    NumpyTest().run()

Deleted: trunk/numpy/ma/tests/test_mstats.py
===================================================================
--- trunk/numpy/ma/tests/test_mstats.py	2008-04-24 06:57:13 UTC (rev 5077)
+++ trunk/numpy/ma/tests/test_mstats.py	2008-04-25 00:48:33 UTC (rev 5078)
@@ -1,175 +0,0 @@
-# pylint: disable-msg=W0611, W0612, W0511,R0201
-"""Tests suite for maskedArray statistics.
-
-:author: Pierre Gerard-Marchant
-:contact: pierregm_at_uga_dot_edu
-:version: $Id: test_mstats.py 3473 2007-10-29 15:18:13Z jarrod.millman $
-"""
-__author__ = "Pierre GF Gerard-Marchant ($Author: jarrod.millman $)"
-__version__ = '1.0'
-__revision__ = "$Revision: 3473 $"
-__date__     = '$Date: 2007-10-29 17:18:13 +0200 (Mon, 29 Oct 2007) $'
-
-import numpy
-
-import numpy.ma
-from numpy.ma import masked, masked_array
-
-import numpy.ma.testutils
-from numpy.ma.testutils import *
-
-from numpy.ma.mstats import *
-from numpy.ma import median
-
-#..............................................................................
-class TestQuantiles(NumpyTestCase):
-    "Base test class for MaskedArrays."
-    def __init__(self, *args, **kwds):
-        NumpyTestCase.__init__(self, *args, **kwds)
-        self.a = numpy.ma.arange(1,101)
-    #
-    def test_1d_nomask(self):
-        "Test quantiles 1D - w/o mask."
-        a = self.a
-        assert_almost_equal(mquantiles(a, alphap=1., betap=1.),
-                            [25.75, 50.5, 75.25])
-        assert_almost_equal(mquantiles(a, alphap=0, betap=1.),
-                            [25., 50., 75.])
-        assert_almost_equal(mquantiles(a, alphap=0.5, betap=0.5),
-                            [25.5, 50.5, 75.5])
-        assert_almost_equal(mquantiles(a, alphap=0., betap=0.),
-                            [25.25, 50.5, 75.75])
-        assert_almost_equal(mquantiles(a, alphap=1./3, betap=1./3),
-                            [25.41666667, 50.5, 75.5833333])
-        assert_almost_equal(mquantiles(a, alphap=3./8, betap=3./8),
-                            [25.4375, 50.5, 75.5625])
-        assert_almost_equal(mquantiles(a), [25.45, 50.5, 75.55])#
-    #
-    def test_1d_mask(self):
-        "Test quantiles 1D - w/ mask."
-        a = self.a
-        a[1::2] = masked
-        assert_almost_equal(mquantiles(a, alphap=1., betap=1.),
-                            [25.5, 50.0, 74.5])
-        assert_almost_equal(mquantiles(a, alphap=0, betap=1.),
-                            [24., 49., 74.])
-        assert_almost_equal(mquantiles(a, alphap=0.5, betap=0.5),
-                            [25., 50., 75.])
-        assert_almost_equal(mquantiles(a, alphap=0., betap=0.),
-                            [24.5, 50.0, 75.5])
-        assert_almost_equal(mquantiles(a, alphap=1./3, betap=1./3),
-                            [24.833333, 50.0, 75.166666])
-        assert_almost_equal(mquantiles(a, alphap=3./8, betap=3./8),
-                            [24.875, 50., 75.125])
-        assert_almost_equal(mquantiles(a), [24.9, 50., 75.1])
-    #
-    def test_2d_nomask(self):
-        "Test quantiles 2D - w/o mask."
-        a = self.a
-        b = numpy.ma.resize(a, (100,100))
-        assert_almost_equal(mquantiles(b), [25.45, 50.5, 75.55])
-        assert_almost_equal(mquantiles(b, axis=0), numpy.ma.resize(a,(3,100)))
-        assert_almost_equal(mquantiles(b, axis=1),
-                            numpy.ma.resize([25.45, 50.5, 75.55], (100,3)))
-    #
-    def test_2d_mask(self):
-        "Test quantiles 2D - w/ mask."
-        a = self.a
-        a[1::2] = masked
-        b = numpy.ma.resize(a, (100,100))
-        assert_almost_equal(mquantiles(b), [25., 50., 75.])
-        assert_almost_equal(mquantiles(b, axis=0), numpy.ma.resize(a,(3,100)))
-        assert_almost_equal(mquantiles(b, axis=1),
-                            numpy.ma.resize([24.9, 50., 75.1], (100,3)))
-
-class TestMedian(NumpyTestCase):
-    def __init__(self, *args, **kwds):
-        NumpyTestCase.__init__(self, *args, **kwds)
-
-    def test_2d(self):
-        "Tests median w/ 2D"
-        (n,p) = (101,30)
-        x = masked_array(numpy.linspace(-1.,1.,n),)
-        x[:10] = x[-10:] = masked
-        z = masked_array(numpy.empty((n,p), dtype=numpy.float_))
-        z[:,0] = x[:]
-        idx = numpy.arange(len(x))
-        for i in range(1,p):
-            numpy.random.shuffle(idx)
-            z[:,i] = x[idx]
-        assert_equal(median(z[:,0]), 0)
-        assert_equal(median(z), numpy.zeros((p,)))
-
-    def test_3d(self):
-        "Tests median w/ 3D"
-        x = numpy.ma.arange(24).reshape(3,4,2)
-        x[x%3==0] = masked
-        assert_equal(median(x,0), [[12,9],[6,15],[12,9],[18,15]])
-        x.shape = (4,3,2)
-        assert_equal(median(x,0),[[99,10],[11,99],[13,14]])
-        x = numpy.ma.arange(24).reshape(4,3,2)
-        x[x%5==0] = masked
-        assert_equal(median(x,0), [[12,10],[8,9],[16,17]])
-
-#..............................................................................
-class TestTrimming(NumpyTestCase):
-    #
-    def __init__(self, *args, **kwds):
-        NumpyTestCase.__init__(self, *args, **kwds)
-    #
-    def test_trim(self):
-        "Tests trimming."
-        x = numpy.ma.arange(100)
-        assert_equal(trim_both(x).count(), 60)
-        assert_equal(trim_tail(x,tail='r').count(), 80)
-        x[50:70] = masked
-        trimx = trim_both(x)
-        assert_equal(trimx.count(), 48)
-        assert_equal(trimx._mask, [1]*16 + [0]*34 + [1]*20 + [0]*14 + [1]*16)
-        x._mask = nomask
-        x.shape = (10,10)
-        assert_equal(trim_both(x).count(), 60)
-        assert_equal(trim_tail(x).count(), 80)
-    #
-    def test_trimmedmean(self):
-        "Tests the trimmed mean."
-        data = masked_array([ 77, 87, 88,114,151,210,219,246,253,262,
-                             296,299,306,376,428,515,666,1310,2611])
-        assert_almost_equal(trimmed_mean(data,0.1), 343, 0)
-        assert_almost_equal(trimmed_mean(data,0.2), 283, 0)
-    #
-    def test_trimmed_stde(self):
-        "Tests the trimmed mean standard error."
-        data = masked_array([ 77, 87, 88,114,151,210,219,246,253,262,
-                             296,299,306,376,428,515,666,1310,2611])
-        assert_almost_equal(trimmed_stde(data,0.2), 56.1, 1)
-    #
-    def test_winsorization(self):
-        "Tests the Winsorization of the data."
-        data = masked_array([ 77, 87, 88,114,151,210,219,246,253,262,
-                             296,299,306,376,428,515,666,1310,2611])
-        assert_almost_equal(winsorize(data).var(ddof=1), 21551.4, 1)
-        data[5] = masked
-        winsorized = winsorize(data)
-        assert_equal(winsorized.mask, data.mask)
-#..............................................................................
-
-class TestMisc(NumpyTestCase):
-    def __init__(self, *args, **kwds):
-        NumpyTestCase.__init__(self, *args, **kwds)
-
-    def check_cov(self):
-        "Tests the cov function."
-        x = masked_array([[1,2,3],[4,5,6]], mask=[[1,0,0],[0,0,0]])
-        c = cov(x[0])
-        assert_equal(c, (x[0].anom()**2).sum())
-        c = cov(x[1])
-        assert_equal(c, (x[1].anom()**2).sum()/2.)
-        c = cov(x)
-        assert_equal(c[1,0], (x[0].anom()*x[1].anom()).sum())
-
-
-###############################################################################
-#------------------------------------------------------------------------------
-if __name__ == "__main__":
-    NumpyTest().run()




More information about the Numpy-svn mailing list