Skip to content

Commit

Permalink
Change subok test to use custom array subclass instead of unsupported…
Browse files Browse the repository at this point in the history
… MaskedArray
  • Loading branch information
zklaus committed Oct 29, 2020
1 parent 8ea7415 commit e2cd3dd
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions numpy/lib/tests/test_stride_tricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,12 +487,16 @@ def test_writeable(self):
assert_array_equal(arr, np.array([0, 3, 2, 3, 4]))

def test_subok(self):
arr = np.ma.arange(5)
assert_(not np.ma.isMaskedArray(sliding_window_view(arr, 2,
subok=False)))
assert_(np.ma.isMaskedArray(sliding_window_view(arr, 2, subok=True)))
class MyArray(np.ndarray):
pass

arr = np.arange(5).view(MyArray)
assert_(not isinstance(sliding_window_view(arr, 2,
subok=False),
MyArray))
assert_(isinstance(sliding_window_view(arr, 2, subok=True), MyArray))
# Default behavior
assert_(not np.ma.isMaskedArray(sliding_window_view(arr, 2)))
assert_(not isinstance(sliding_window_view(arr, 2), MyArray))


def as_strided_writeable():
Expand Down

0 comments on commit e2cd3dd

Please sign in to comment.