Skip to content
Snippets Groups Projects
Commit 5a9b8fee authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

TEST: Expand naninfrange test to cover weird data

parent 52e5a60b
No related branches found
No related tags found
No related merge requests found
......@@ -50,3 +50,44 @@ def test_naninfrange():
if np.isfinite(expected[1]): assert result[1] == expected[1]
elif np.isnan( expected[1]): assert np.isnan(result[1])
elif np.isinf( expected[1]): assert np.isinf(result[1])
def test_naninfrange_structured_ordered_contiguous():
data = np.random.random((4, 5, 6))
cdata = data.copy(order='C')
fdata = data.copy(order='F')
sdtype = np.dtype([('R', 'float64'), ('G', 'float64'), ('B', 'float64')])
sdata = np.zeros(data.shape, dtype=sdtype)
sdata['R'] = data
sdata['G'] = data
sdata['B'] = data
csdata = sdata.copy(order='C')
fsdata = sdata.copy(order='F')
tests = [
cdata,
cdata.transpose(1, 0, 2),
cdata[2:4, 1:3, 0:4],
fdata,
fdata.transpose(1, 0, 2),
fdata[2:4, 1:3, 0:4],
csdata,
csdata.transpose(1, 0, 2),
csdata[2:4, 1:3, 0:4],
fsdata,
fsdata.transpose(1, 0, 2),
fsdata[2:4, 1:3, 0:4]
]
for t in tests:
if len(t.dtype) > 0:
expmin = np.min([t[n].min() for n in t.dtype.names])
expmax = np.max([t[n].max() for n in t.dtype.names])
else:
expmin, expmax = np.min(t), np.max(t)
result = naninfrange.naninfrange(t)
assert np.all(np.isclose(result, (expmin, expmax)))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment