def test_nan_threshold_alt(): # test threshold on odd numbers data = ones((3, 6)) data[0] = nan data[1, 2:5] = nan expected = [(0.4, [nan, nan]), (0.5, [1, nan]), (0.7, [1, 1])] for thresh, exp in expected: res = _resample(data, xscale=3, yscale=3, thresh=thresh) assert_array_equal(res, reshape(exp, res.shape))
def test_nan_threshold(): # test threshold based on number of NaNs per averaging tile data = ones((2, 10)) data[0, 3:] = nan data[1, 7:] = nan # key: NaN threshold as a % of pixels, expected result expected = [(0.0, [1, nan, nan, nan, nan]), (0.25, [1, nan, nan, nan, nan]), (0.5, [1, 1, nan, nan, nan]), (0.75, [1, 1, 1, nan, nan]), (1.0, [1, 1, 1, 1, nan])] for thresh, exp in expected: res = _resample(data, xscale=2, yscale=2, thresh=thresh) assert_array_equal(res, reshape(exp, res.shape))