Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

REF remove deprecated lar.movingrank()

Also remove remanants of lar.movingsum()
  • Loading branch information...
commit 4864b3c9b973fbf12f580406e0512a771edf4e1c 1 parent 8b6bcd4
kwgoodman authored March 19, 2013
4  README.rst
Source Rendered
@@ -122,9 +122,9 @@ After you have installed ``la``, run the suite of unit tests::
122 122
     >>> import la
123 123
     >>> la.test()
124 124
     <snip>
125  
-    Ran 3012 tests in 9.225s
  125
+    Ran 2997 tests in 9.225s
126 126
     OK
127  
-    <nose.result.TextTestResult run=3012 errors=0 failures=0>
  127
+    <nose.result.TextTestResult run=2997 errors=0 failures=0>
128 128
     
129 129
 The ``la`` package contains C extensions that speed up common alignment
130 130
 operations such as adding two unaligned larrys. If the C extensions don't
3  RELEASE.rst
Source Rendered
@@ -32,7 +32,8 @@ la 0.7
32 32
 **Breakage from la 0.6**
33 33
 
34 34
 - Numpy array version of move_median() removed since bottleneck now used
35  
-- deprecated lar.movingsum() removed (use the faster lar.move_sum() instead)
  35
+- deprecated lar.movingsum() removed (use faster lar.move_sum() instead)
  36
+- deprecated lar.movingrank() removed (use faster lar.move_ranking() instead)
36 37
 
37 38
 **Bug fixes**
38 39
 
12  la/deflarry.py
@@ -1612,7 +1612,7 @@ def lastrank(self, axis=-1, decay=0):
1612 1612
         See Also
1613 1613
         --------
1614 1614
         la.larry.ranking: Rank elements treating NaN as missing. 
1615  
-        la.larry.movingrank: Moving rank in a given window along axis.
  1615
+        la.larry.move_ranking: Moving rank in a given window along axis.
1616 1616
                 
1617 1617
         Examples
1618 1618
         -------- 
@@ -3057,17 +3057,7 @@ def movingsum_forward(self, window, skip=0, axis=-1, norm=False):
3057 3057
         y = self.copy()
3058 3058
         y.x = movingsum_forward(y.x, window, skip=skip, axis=axis, norm=norm)
3059 3059
         return y
3060  
-    
3061  
-    @np.deprecate(new_name='move_ranking')                        
3062  
-    def movingrank(self, window, axis=-1):
3063  
-        """Moving rank (normalized to -1 and 1) of a given window along axis.
3064 3060
 
3065  
-        Normalized for missing (NaN) data.
3066  
-        A data point with NaN data is returned as NaN
3067  
-        If a window is all NaNs except last, this is returned as NaN
3068  
-        """
3069  
-        return self.move_ranking(window, axis=axis)
3070  
-        
3071 3061
     # Calc ------------------------------------------------------------------
3072 3062
 
3073 3063
     def demean(self, axis=None):
23  la/farray/move.py
@@ -7,7 +7,7 @@
7 7
 from la.farray import lastrank
8 8
 
9 9
 __all__ = ['move_nanmedian', 'move_func', 'move_nanranking',
10  
-           'movingsum', 'movingsum_forward', 'movingrank'] #Last row deprecated
  10
+           'movingsum_forward'] #Last row deprecated
11 11
 
12 12
 
13 13
 # MEDIAN --------------------------------------------------------------------
@@ -335,24 +335,3 @@ def movingsum_forward(x, window, skip=0, axis=-1, norm=False):
335 335
     flip_index[axis] = slice(None, None, -1)
336 336
     msf = movingsum(x[flip_index], window, skip=skip, axis=axis, norm=norm)
337 337
     return msf[flip_index]
338  
-
339  
-def movingrank(x, window, axis=-1):
340  
-    """Moving rank (normalized to -1 and 1) of a given window along axis.
341  
-
342  
-    Normalized for missing (NaN) data.
343  
-    A data point with NaN data is returned as NaN
344  
-    If a window is all NaNs except last, this is returned as NaN
345  
-    """
346  
-    if window > x.shape[axis]:
347  
-        raise ValueError('Window is too big.')
348  
-    if window < 2:
349  
-        raise ValueError('Window is too small.')
350  
-    nt = x.shape[axis]
351  
-    mr = np.nan * np.zeros(x.shape)        
352  
-    for i in xrange(window-1, nt): 
353  
-        index1 = [slice(None)] * x.ndim 
354  
-        index1[axis] = i
355  
-        index2 = [slice(None)] * x.ndim 
356  
-        index2[axis] = slice(i-window+1, i+1, None)
357  
-        mr[index1] = np.squeeze(lastrank(x[index2], axis=axis))
358  
-    return mr
112  la/farray/tests/farray_test.py
@@ -12,9 +12,8 @@
12 12
 
13 13
 from la.util.testing import printfail
14 14
 from la.farray import group_ranking, group_mean, group_median
15  
-from la.farray import (movingsum, movingrank, movingsum_forward, ranking, 
16  
-                       geometric_mean, unique_group, correlation, lastrank,
17  
-                       covMissing)
  15
+from la.farray import (movingsum_forward, ranking,  geometric_mean,
  16
+                       unique_group, correlation, lastrank, covMissing)
18 17
 
19 18
 # Sector functions ----------------------------------------------------------
20 19
 
@@ -420,68 +419,6 @@ def test_geometric_mean_7(self):
420 419
         msg = printfail(desired, actual)
421 420
         self.assert_((abs(desired - actual) < 1e187).all(), msg)         
422 421
         
423  
-class Test_movingsum(unittest.TestCase):
424  
-    "Test farray.movingsum"       
425  
-
426  
-    def setUp(self):
427  
-        self.x = np.array([[1.0, nan, 6.0, 0.0, 8.0],
428  
-                           [2.0, 4.0, 8.0, 0.0,-1.0]])
429  
-        self.xnan = np.array([[  nan,  nan,  nan,  nan,  nan],
430  
-                              [  nan,  nan,  nan,  nan,  nan]])
431  
-        self.window = 2
432  
-        self.x2 = np.array([[ 2.0,  2.0],
433  
-                            [ 1.0,  3.0],
434  
-                            [ 3.0,  1.0]]) 
435  
-
436  
-    def test_movingsum_1(self):
437  
-        "farray.movingsum #1"  
438  
-        desired = self.xnan 
439  
-        with np.errstate(invalid='ignore'):
440  
-            actual = movingsum(self.xnan, self.window, norm=True)
441  
-        assert_almost_equal(actual, desired)             
442  
-
443  
-    def test_movingsum_2(self):
444  
-        "farray.movingsum #2"    
445  
-        desired = self.xnan
446  
-        actual = movingsum(self.xnan, self.window, norm=False)
447  
-        assert_almost_equal(actual, desired)   
448  
-
449  
-    def test_movingsum_3(self):
450  
-        "farray.movingsum #3"    
451  
-        desired = np.array([[  nan, 2.0, 12.0, 6.0, 8.0],
452  
-                            [  nan, 6.0, 12.0, 8.0,-1.0]])   
453  
-        actual = movingsum(self.x, self.window, norm=True)
454  
-        assert_almost_equal(actual, desired) 
455  
-
456  
-    def test_movingsum_4(self):
457  
-        "farray.movingsum #4"   
458  
-        desired = np.array([[  nan, 1.0,  6.0, 6.0, 8.0],
459  
-                            [  nan, 6.0, 12.0, 8.0,-1.0]])
460  
-        actual = movingsum(self.x, self.window, norm=False)
461  
-        assert_almost_equal(actual, desired) 
462  
-
463  
-    def test_movingsum_5(self):
464  
-        "farray.movingsum #5"    
465  
-        desired = np.array([[nan,  nan,  nan,  nan,  nan],
466  
-                            [3.0,  8.0,  14.0, 0.0,  7.0]])
467  
-        actual = movingsum(self.x, self.window, axis=0, norm=True)
468  
-        assert_almost_equal(actual, desired) 
469  
-
470  
-    def test_movingsum_6(self):
471  
-        "farray.movingsum #6"    
472  
-        desired = np.array([[nan,  nan,  nan,  nan,  nan],
473  
-                            [3.0,  4.0,  14.0, 0.0,  7.0]])
474  
-        actual = movingsum(self.x, self.window, axis=0, norm=False)
475  
-        assert_almost_equal(actual, desired) 
476  
-        
477  
-    def test_movingsum_7(self):
478  
-        "farray.movingsum #7"  
479  
-        desired = np.array([[nan, 4.0],
480  
-                            [nan, 4.0],
481  
-                            [nan, 4.0]])
482  
-        actual = movingsum(self.x2, self.window)
483  
-        assert_almost_equal(actual, desired) 
484  
-
485 422
 class Test_movingsum_forward(unittest.TestCase):
486 423
     "Test farray.movingsum_forward"
487 424
  
@@ -533,51 +470,6 @@ def test_movingsum_forward_5(self):
533 470
         actual = movingsum_forward(self.x, window, skip, axis=0)
534 471
         assert_almost_equal(actual, desired)          
535 472
 
536  
-class Test_movingrank(unittest.TestCase):
537  
-    "Test movingrank"
538  
-
539  
-    def setUp(self):
540  
-        self.x = np.array([[1.0, nan, 6.0, 0.0, 8.0],
541  
-                           [2.0, 4.0, 8.0, 0.0,-1.0]])
542  
-        self.xnan = np.array([[nan, nan, nan, nan, nan],
543  
-                              [nan, nan, nan, nan, nan]])
544  
-        self.window = 2
545  
-        self.x2 = np.array([[nan, 2.0],
546  
-                            [1.0, 3.0],
547  
-                            [3.0, 1.0]])                  
548  
-    
549  
-    def test_movingrank_1(self):
550  
-        "farray.movingrank #1"    
551  
-        desired = self.xnan 
552  
-        with np.errstate(invalid='ignore'):
553  
-            actual = movingrank(self.xnan, self.window)
554  
-        assert_almost_equal(actual, desired) 
555  
-    
556  
-    def test_movingrank_2(self):
557  
-        "farray.movingrank #2"    
558  
-        desired = np.array([[  nan,  nan,  nan,-1.0,1.0],
559  
-                           [  nan,1.0,1.0,-1.0,-1.0]]) 
560  
-        with np.errstate(invalid='ignore', divide='ignore'):
561  
-            actual = movingrank(self.x, self.window)
562  
-        assert_almost_equal(actual, desired)          
563  
-
564  
-    def test_movingrank_3(self):
565  
-        "farray.movingrank #3"    
566  
-        desired = np.array([[nan,  nan,  nan,  nan,  nan],
567  
-                           [1.0,  nan,  1.0,  0.0,  -1.0]])
568  
-        with np.errstate(invalid='ignore'):
569  
-            actual = movingrank(self.x, self.window, axis=0)
570  
-        assert_almost_equal(actual, desired) 
571  
-        
572  
-    def test_movingrank_4(self):
573  
-        "farray.movingrank #4"    
574  
-        desired = np.array([[nan,  nan],
575  
-                           [nan,  1.0],
576  
-                           [nan, -1.0]])
577  
-        with np.errstate(invalid='ignore', divide='ignore'):
578  
-            actual = movingrank(self.x2, self.window)
579  
-        assert_almost_equal(actual, desired)
580  
-        
581 473
 class Test_correlation(unittest.TestCase):
582 474
     "Test farray.correlation"
583 475
     
2  la/tests/all_nan_test.py
@@ -19,7 +19,7 @@ def functions():
19 19
               'zscore', 'geometric_mean'],
20 20
          (0,): ['cumsum', 'cumprod', 'ranking', 'lastrank'],
21 21
          (1,): ['power', 'move_sum', 'movingsum_forward'],
22  
-         (2,): ['movingrank', 'quantile']} 
  22
+         (2,): ['move_ranking', 'quantile']}
23 23
     return f                   
24 24
                         
25 25
 def test_all_nan(): 
24  la/tests/deflarry_test.py
@@ -2490,10 +2490,10 @@ def test_ranking_17(self):
2490 2490
         t = la.larry(t, label)
2491 2491
         ale(p, t, original=lx)
2492 2492
 
2493  
-    def test_movingrank_1(self):
2494  
-        "larry.movingrank_1"    
  2493
+    def test_move_ranking_1(self):
  2494
+        "larry.move_ranking_1"
2495 2495
         t = self.x6 
2496  
-        p = self.l6.movingrank(2)
  2496
+        p = self.l6.move_ranking(2)
2497 2497
         label = [range(2), range(5)]
2498 2498
         msg = printfail(t, p.x, 'x')  
2499 2499
         t[np.isnan(t)] = self.nancode
@@ -2502,12 +2502,12 @@ def test_movingrank_1(self):
2502 2502
         self.assertTrue(label == p.label, printfail(label, p.label, 'label'))
2503 2503
         self.assertTrue(noreference(p, self.l6), 'Reference found') 
2504 2504
     
2505  
-    def test_movingrank_2(self):
2506  
-        "larry.movingrank_2"    
  2505
+    def test_move_ranking_2(self):
  2506
+        "larry.move_ranking_2"
2507 2507
         t = np.array([[  nan,  nan,  nan,-1.0,1.0],
2508 2508
                       [  nan,1.0,1.0,-1.0,-1.0]]) 
2509 2509
         with np.errstate(invalid='ignore', divide='ignore'):
2510  
-            p = self.l5.movingrank(2)
  2510
+            p = self.l5.move_ranking(2)
2511 2511
         label = [range(2), range(5)]
2512 2512
         msg = printfail(t, p.x, 'x')  
2513 2513
         t[np.isnan(t)] = self.nancode
@@ -2516,12 +2516,12 @@ def test_movingrank_2(self):
2516 2516
         self.assertTrue(label == p.label, printfail(label, p.label, 'label'))
2517 2517
         self.assertTrue(noreference(p, self.l5), 'Reference found')          
2518 2518
 
2519  
-    def test_movingrank_3(self):
2520  
-        "larry.movingrank_3"    
  2519
+    def test_move_ranking_3(self):
  2520
+        "larry.move_ranking_3"
2521 2521
         t = np.array([[nan,  nan,  nan,  nan,  nan],
2522 2522
                       [1.0,  nan,  1.0,  0.0,  -1.0]])
2523 2523
         with np.errstate(invalid='ignore', divide='ignore'):
2524  
-            p = self.l5.movingrank(2, axis=0)
  2524
+            p = self.l5.move_ranking(2, axis=0)
2525 2525
         label = [range(2), range(5)]
2526 2526
         msg = printfail(t, p.x, 'x')  
2527 2527
         t[np.isnan(t)] = self.nancode
@@ -2530,13 +2530,13 @@ def test_movingrank_3(self):
2530 2530
         self.assertTrue(label == p.label, printfail(label, p.label, 'label'))
2531 2531
         self.assertTrue(noreference(p, self.l5), 'Reference found')
2532 2532
         
2533  
-    def test_movingrank_4(self):
2534  
-        "larry.movingrank_4"    
  2533
+    def test_move_ranking_4(self):
  2534
+        "larry.move_ranking_4"
2535 2535
         t = np.array([[nan,  nan],
2536 2536
                       [nan,  1.0],
2537 2537
                       [nan, -1.0]])
2538 2538
         with np.errstate(invalid='ignore', divide='ignore'):
2539  
-            p = self.l7.movingrank(2)
  2539
+            p = self.l7.move_ranking(2)
2540 2540
         label = [range(3), range(2)]
2541 2541
         msg = printfail(t, p.x, 'x')  
2542 2542
         t[np.isnan(t)] = self.nancode
2  la/tests/empty_larry_test.py
@@ -83,7 +83,7 @@ def arr():
83 83
       #('minlabel',[0],IndexError) ,    # Unit test doesn't handle Errors
84 84
        ('morph'      ,  [[], 0]    ,    lar()),              
85 85
        ('morph_like' ,  [lar()]    ,    lar()), 
86  
-      #('movingrank' ,  None       ,    lar()),       # 2d only
  86
+      #('move_ranking' ,  None       ,    lar()),       # 2d only
87 87
       #('move_sum'   , [0] ,    ValueError),          # 2d only
88 88
       #('movingsum_forward',[0],ValueError),          # 2d only
89 89
        ('nan_replace',  [0]        ,    lar()),
2  la/tests/larry_axis_test.py
@@ -39,7 +39,7 @@ def lar():
39 39
        ('median'     ,  ['axis']),
40 40
        ('min'        ,  ['axis']),
41 41
        ('minlabel'   ,  ['axis']),       
42  
-       ('movingrank' ,  [2, 'axis']),
  42
+       ('move_ranking', [2, 'axis']),
43 43
        ('move_sum'   ,  [1, 'axis']),
44 44
        ('movingsum_forward', [1, 0, 'axis']),
45 45
        ('prod'       ,  ['axis']), 
7  la/tests/more_test.py
@@ -8,13 +8,12 @@
8 8
 nan = np.nan
9 9
 
10 10
 from la.farray import (push, geometric_mean, lastrank,
11  
-                       movingrank, movingsum_forward,
12  
-                       quantile, ranking, group_mean, group_median,
13  
-                       group_ranking)
  11
+                       movingsum_forward, quantile, ranking,
  12
+                       group_mean, group_median, group_ranking)
14 13
 
15 14
 # Functions to test
16 15
 funcs_one = [geometric_mean, lastrank, ranking]
17  
-funcs_oneint = [movingrank, movingsum_forward, quantile, push]
  16
+funcs_oneint = [movingsum_forward, quantile, push]
18 17
 funcs_onefrac = [lastrank]
19 18
 funcs_sect = [group_mean, group_median, group_ranking]
20 19
 
1  la/tests/test_3d.py
@@ -14,7 +14,6 @@ def getfuncs(argint, argfrac, argsector):
14 14
     funcs = [('geometric_mean'        , (), ()),
15 15
              ('lastrank'              , (), ()),
16 16
              ('ranking'               , (), ()),
17  
-             ('movingrank'            , (argint,), ()),
18 17
              ('movingsum_forward'     , (argint,), ()),
19 18
              ('quantile'              , (argint,), ()),
20 19
              ('push'                  , (argint,), ()),

0 notes on commit 4864b3c

Please sign in to comment.
Something went wrong with that request. Please try again.