Permalink
Browse files

REF remove deprecated lar.movingrank()

Also remove remanants of lar.movingsum()
  • Loading branch information...
1 parent 8b6bcd4 commit 4864b3c9b973fbf12f580406e0512a771edf4e1c @kwgoodman committed Mar 19, 2013
View
4 README.rst
@@ -122,9 +122,9 @@ After you have installed ``la``, run the suite of unit tests::
>>> import la
>>> la.test()
<snip>
- Ran 3012 tests in 9.225s
+ Ran 2997 tests in 9.225s
OK
- <nose.result.TextTestResult run=3012 errors=0 failures=0>
+ <nose.result.TextTestResult run=2997 errors=0 failures=0>
The ``la`` package contains C extensions that speed up common alignment
operations such as adding two unaligned larrys. If the C extensions don't
View
3 RELEASE.rst
@@ -32,7 +32,8 @@ la 0.7
**Breakage from la 0.6**
- Numpy array version of move_median() removed since bottleneck now used
-- deprecated lar.movingsum() removed (use the faster lar.move_sum() instead)
+- deprecated lar.movingsum() removed (use faster lar.move_sum() instead)
+- deprecated lar.movingrank() removed (use faster lar.move_ranking() instead)
**Bug fixes**
View
12 la/deflarry.py
@@ -1612,7 +1612,7 @@ def lastrank(self, axis=-1, decay=0):
See Also
--------
la.larry.ranking: Rank elements treating NaN as missing.
- la.larry.movingrank: Moving rank in a given window along axis.
+ la.larry.move_ranking: Moving rank in a given window along axis.
Examples
--------
@@ -3057,17 +3057,7 @@ def movingsum_forward(self, window, skip=0, axis=-1, norm=False):
y = self.copy()
y.x = movingsum_forward(y.x, window, skip=skip, axis=axis, norm=norm)
return y
-
- @np.deprecate(new_name='move_ranking')
- def movingrank(self, window, axis=-1):
- """Moving rank (normalized to -1 and 1) of a given window along axis.
- Normalized for missing (NaN) data.
- A data point with NaN data is returned as NaN
- If a window is all NaNs except last, this is returned as NaN
- """
- return self.move_ranking(window, axis=axis)
-
# Calc ------------------------------------------------------------------
def demean(self, axis=None):
View
23 la/farray/move.py
@@ -7,7 +7,7 @@
from la.farray import lastrank
__all__ = ['move_nanmedian', 'move_func', 'move_nanranking',
- 'movingsum', 'movingsum_forward', 'movingrank'] #Last row deprecated
+ 'movingsum_forward'] #Last row deprecated
# MEDIAN --------------------------------------------------------------------
@@ -335,24 +335,3 @@ def movingsum_forward(x, window, skip=0, axis=-1, norm=False):
flip_index[axis] = slice(None, None, -1)
msf = movingsum(x[flip_index], window, skip=skip, axis=axis, norm=norm)
return msf[flip_index]
-
-def movingrank(x, window, axis=-1):
- """Moving rank (normalized to -1 and 1) of a given window along axis.
-
- Normalized for missing (NaN) data.
- A data point with NaN data is returned as NaN
- If a window is all NaNs except last, this is returned as NaN
- """
- if window > x.shape[axis]:
- raise ValueError('Window is too big.')
- if window < 2:
- raise ValueError('Window is too small.')
- nt = x.shape[axis]
- mr = np.nan * np.zeros(x.shape)
- for i in xrange(window-1, nt):
- index1 = [slice(None)] * x.ndim
- index1[axis] = i
- index2 = [slice(None)] * x.ndim
- index2[axis] = slice(i-window+1, i+1, None)
- mr[index1] = np.squeeze(lastrank(x[index2], axis=axis))
- return mr
View
112 la/farray/tests/farray_test.py
@@ -12,9 +12,8 @@
from la.util.testing import printfail
from la.farray import group_ranking, group_mean, group_median
-from la.farray import (movingsum, movingrank, movingsum_forward, ranking,
- geometric_mean, unique_group, correlation, lastrank,
- covMissing)
+from la.farray import (movingsum_forward, ranking, geometric_mean,
+ unique_group, correlation, lastrank, covMissing)
# Sector functions ----------------------------------------------------------
@@ -420,68 +419,6 @@ def test_geometric_mean_7(self):
msg = printfail(desired, actual)
self.assert_((abs(desired - actual) < 1e187).all(), msg)
-class Test_movingsum(unittest.TestCase):
- "Test farray.movingsum"
-
- def setUp(self):
- self.x = np.array([[1.0, nan, 6.0, 0.0, 8.0],
- [2.0, 4.0, 8.0, 0.0,-1.0]])
- self.xnan = np.array([[ nan, nan, nan, nan, nan],
- [ nan, nan, nan, nan, nan]])
- self.window = 2
- self.x2 = np.array([[ 2.0, 2.0],
- [ 1.0, 3.0],
- [ 3.0, 1.0]])
-
- def test_movingsum_1(self):
- "farray.movingsum #1"
- desired = self.xnan
- with np.errstate(invalid='ignore'):
- actual = movingsum(self.xnan, self.window, norm=True)
- assert_almost_equal(actual, desired)
-
- def test_movingsum_2(self):
- "farray.movingsum #2"
- desired = self.xnan
- actual = movingsum(self.xnan, self.window, norm=False)
- assert_almost_equal(actual, desired)
-
- def test_movingsum_3(self):
- "farray.movingsum #3"
- desired = np.array([[ nan, 2.0, 12.0, 6.0, 8.0],
- [ nan, 6.0, 12.0, 8.0,-1.0]])
- actual = movingsum(self.x, self.window, norm=True)
- assert_almost_equal(actual, desired)
-
- def test_movingsum_4(self):
- "farray.movingsum #4"
- desired = np.array([[ nan, 1.0, 6.0, 6.0, 8.0],
- [ nan, 6.0, 12.0, 8.0,-1.0]])
- actual = movingsum(self.x, self.window, norm=False)
- assert_almost_equal(actual, desired)
-
- def test_movingsum_5(self):
- "farray.movingsum #5"
- desired = np.array([[nan, nan, nan, nan, nan],
- [3.0, 8.0, 14.0, 0.0, 7.0]])
- actual = movingsum(self.x, self.window, axis=0, norm=True)
- assert_almost_equal(actual, desired)
-
- def test_movingsum_6(self):
- "farray.movingsum #6"
- desired = np.array([[nan, nan, nan, nan, nan],
- [3.0, 4.0, 14.0, 0.0, 7.0]])
- actual = movingsum(self.x, self.window, axis=0, norm=False)
- assert_almost_equal(actual, desired)
-
- def test_movingsum_7(self):
- "farray.movingsum #7"
- desired = np.array([[nan, 4.0],
- [nan, 4.0],
- [nan, 4.0]])
- actual = movingsum(self.x2, self.window)
- assert_almost_equal(actual, desired)
-
class Test_movingsum_forward(unittest.TestCase):
"Test farray.movingsum_forward"
@@ -533,51 +470,6 @@ def test_movingsum_forward_5(self):
actual = movingsum_forward(self.x, window, skip, axis=0)
assert_almost_equal(actual, desired)
-class Test_movingrank(unittest.TestCase):
- "Test movingrank"
-
- def setUp(self):
- self.x = np.array([[1.0, nan, 6.0, 0.0, 8.0],
- [2.0, 4.0, 8.0, 0.0,-1.0]])
- self.xnan = np.array([[nan, nan, nan, nan, nan],
- [nan, nan, nan, nan, nan]])
- self.window = 2
- self.x2 = np.array([[nan, 2.0],
- [1.0, 3.0],
- [3.0, 1.0]])
-
- def test_movingrank_1(self):
- "farray.movingrank #1"
- desired = self.xnan
- with np.errstate(invalid='ignore'):
- actual = movingrank(self.xnan, self.window)
- assert_almost_equal(actual, desired)
-
- def test_movingrank_2(self):
- "farray.movingrank #2"
- desired = np.array([[ nan, nan, nan,-1.0,1.0],
- [ nan,1.0,1.0,-1.0,-1.0]])
- with np.errstate(invalid='ignore', divide='ignore'):
- actual = movingrank(self.x, self.window)
- assert_almost_equal(actual, desired)
-
- def test_movingrank_3(self):
- "farray.movingrank #3"
- desired = np.array([[nan, nan, nan, nan, nan],
- [1.0, nan, 1.0, 0.0, -1.0]])
- with np.errstate(invalid='ignore'):
- actual = movingrank(self.x, self.window, axis=0)
- assert_almost_equal(actual, desired)
-
- def test_movingrank_4(self):
- "farray.movingrank #4"
- desired = np.array([[nan, nan],
- [nan, 1.0],
- [nan, -1.0]])
- with np.errstate(invalid='ignore', divide='ignore'):
- actual = movingrank(self.x2, self.window)
- assert_almost_equal(actual, desired)
-
class Test_correlation(unittest.TestCase):
"Test farray.correlation"
View
2 la/tests/all_nan_test.py
@@ -19,7 +19,7 @@ def functions():
'zscore', 'geometric_mean'],
(0,): ['cumsum', 'cumprod', 'ranking', 'lastrank'],
(1,): ['power', 'move_sum', 'movingsum_forward'],
- (2,): ['movingrank', 'quantile']}
+ (2,): ['move_ranking', 'quantile']}
return f
def test_all_nan():
View
24 la/tests/deflarry_test.py
@@ -2490,10 +2490,10 @@ def test_ranking_17(self):
t = la.larry(t, label)
ale(p, t, original=lx)
- def test_movingrank_1(self):
- "larry.movingrank_1"
+ def test_move_ranking_1(self):
+ "larry.move_ranking_1"
t = self.x6
- p = self.l6.movingrank(2)
+ p = self.l6.move_ranking(2)
label = [range(2), range(5)]
msg = printfail(t, p.x, 'x')
t[np.isnan(t)] = self.nancode
@@ -2502,12 +2502,12 @@ def test_movingrank_1(self):
self.assertTrue(label == p.label, printfail(label, p.label, 'label'))
self.assertTrue(noreference(p, self.l6), 'Reference found')
- def test_movingrank_2(self):
- "larry.movingrank_2"
+ def test_move_ranking_2(self):
+ "larry.move_ranking_2"
t = np.array([[ nan, nan, nan,-1.0,1.0],
[ nan,1.0,1.0,-1.0,-1.0]])
with np.errstate(invalid='ignore', divide='ignore'):
- p = self.l5.movingrank(2)
+ p = self.l5.move_ranking(2)
label = [range(2), range(5)]
msg = printfail(t, p.x, 'x')
t[np.isnan(t)] = self.nancode
@@ -2516,12 +2516,12 @@ def test_movingrank_2(self):
self.assertTrue(label == p.label, printfail(label, p.label, 'label'))
self.assertTrue(noreference(p, self.l5), 'Reference found')
- def test_movingrank_3(self):
- "larry.movingrank_3"
+ def test_move_ranking_3(self):
+ "larry.move_ranking_3"
t = np.array([[nan, nan, nan, nan, nan],
[1.0, nan, 1.0, 0.0, -1.0]])
with np.errstate(invalid='ignore', divide='ignore'):
- p = self.l5.movingrank(2, axis=0)
+ p = self.l5.move_ranking(2, axis=0)
label = [range(2), range(5)]
msg = printfail(t, p.x, 'x')
t[np.isnan(t)] = self.nancode
@@ -2530,13 +2530,13 @@ def test_movingrank_3(self):
self.assertTrue(label == p.label, printfail(label, p.label, 'label'))
self.assertTrue(noreference(p, self.l5), 'Reference found')
- def test_movingrank_4(self):
- "larry.movingrank_4"
+ def test_move_ranking_4(self):
+ "larry.move_ranking_4"
t = np.array([[nan, nan],
[nan, 1.0],
[nan, -1.0]])
with np.errstate(invalid='ignore', divide='ignore'):
- p = self.l7.movingrank(2)
+ p = self.l7.move_ranking(2)
label = [range(3), range(2)]
msg = printfail(t, p.x, 'x')
t[np.isnan(t)] = self.nancode
View
2 la/tests/empty_larry_test.py
@@ -83,7 +83,7 @@ def arr():
#('minlabel',[0],IndexError) , # Unit test doesn't handle Errors
('morph' , [[], 0] , lar()),
('morph_like' , [lar()] , lar()),
- #('movingrank' , None , lar()), # 2d only
+ #('move_ranking' , None , lar()), # 2d only
#('move_sum' , [0] , ValueError), # 2d only
#('movingsum_forward',[0],ValueError), # 2d only
('nan_replace', [0] , lar()),
View
2 la/tests/larry_axis_test.py
@@ -39,7 +39,7 @@ def lar():
('median' , ['axis']),
('min' , ['axis']),
('minlabel' , ['axis']),
- ('movingrank' , [2, 'axis']),
+ ('move_ranking', [2, 'axis']),
('move_sum' , [1, 'axis']),
('movingsum_forward', [1, 0, 'axis']),
('prod' , ['axis']),
View
7 la/tests/more_test.py
@@ -8,13 +8,12 @@
nan = np.nan
from la.farray import (push, geometric_mean, lastrank,
- movingrank, movingsum_forward,
- quantile, ranking, group_mean, group_median,
- group_ranking)
+ movingsum_forward, quantile, ranking,
+ group_mean, group_median, group_ranking)
# Functions to test
funcs_one = [geometric_mean, lastrank, ranking]
-funcs_oneint = [movingrank, movingsum_forward, quantile, push]
+funcs_oneint = [movingsum_forward, quantile, push]
funcs_onefrac = [lastrank]
funcs_sect = [group_mean, group_median, group_ranking]
View
1 la/tests/test_3d.py
@@ -14,7 +14,6 @@ def getfuncs(argint, argfrac, argsector):
funcs = [('geometric_mean' , (), ()),
('lastrank' , (), ()),
('ranking' , (), ()),
- ('movingrank' , (argint,), ()),
('movingsum_forward' , (argint,), ()),
('quantile' , (argint,), ()),
('push' , (argint,), ()),

0 comments on commit 4864b3c

Please sign in to comment.