Remove min_overlap kwarg

This commit is contained in:
Steven Silvester
2015-07-14 07:47:22 -05:00
parent c948f9fe97
commit 1f56de9595
2 changed files with 1 additions and 32 deletions
+1 -16
View File
@@ -104,7 +104,7 @@ def view_as_blocks(arr_in, block_shape):
return arr_out
def view_as_windows(arr_in, window_shape, step=1, min_overlap=False):
def view_as_windows(arr_in, window_shape, step=1):
"""Rolling window view of the input n-dimensional array.
Windows are overlapping views of the input array, with adjacent windows
@@ -122,9 +122,6 @@ def view_as_windows(arr_in, window_shape, step=1, min_overlap=False):
step : integer or tuple of length arr_in.ndim
Indicates step size at which extraction shall be performed.
If integer is given, then the step is uniform in all dimensions.
min_overlap: bool, optional
When True, selects a ``step`` that will give full coverage of
``arr_in`` with minimal overlap.
Returns
-------
@@ -229,18 +226,6 @@ def view_as_windows(arr_in, window_shape, step=1, min_overlap=False):
if not (len(window_shape) == ndim):
raise ValueError("`window_shape` is incompatible with `arr_in.shape`")
if min_overlap:
# start with no overlap
step = list(window_shape)
# subtract the initial window shape from the overall shape
remainder = np.array(arr_in.shape) - np.array(window_shape)
# shrink the step size in each direction as needed
# to get full coverage
for (ind, size) in enumerate(window_shape):
num_steps = int(np.ceil(arr_in.shape[ind] / size))
while step[ind] * (num_steps - 1) > remainder[ind]:
step[ind] -= 1
if isinstance(step, numbers.Number):
if step < 1:
raise ValueError("`step` must be >= 1")
-16
View File
@@ -176,21 +176,5 @@ def test_view_as_windows_step_tuple():
[22, 23]]]])
def test_view_as_windows_min_overlap():
A = np.arange(24).reshape((6, 4))
B = view_as_windows(A, (3, 2), min_overlap=True)
assert B.shape == (2, 2, 3, 2)
assert B.size == A.size
A = np.arange(512 * 512).reshape((512, 512))
B = view_as_windows(A, (10, 10), min_overlap=True)
assert B.shape == (56, 56, 10, 10)
assert B.size >= A.size
C = view_as_windows(A, (11, 9), min_overlap=True)
assert C.shape == (51, 63, 11, 9)
assert C.size >= A.size
if __name__ == '__main__':
np.testing.run_module_suite()