Commit c23a7f37 authored by Patrick Godwin's avatar Patrick Godwin
Browse files

test_mock.py: check for subdtype rather than subclass for checking type of ndarray

parent 1d749965
Pipeline #95361 passed with stages
in 3 minutes and 59 seconds
......@@ -23,21 +23,21 @@ class TestMock(object):
"""
def test_random_trigger_value(self):
far = mock.random_trigger_value('far', 1)
assert issubclass(far.dtype.type, float), 'expected type float for far'
assert numpy.issubdtype(far.dtype.type, float), 'expected type float for far'
assert far <= 1e-2, 'expected far <= far threshold'
snr = mock.random_trigger_value('snr', 1)
assert issubclass(snr.dtype.type, float), 'expected type float for snr'
assert numpy.issubdtype(snr.dtype.type, float), 'expected type float for snr'
assert snr >= 0, 'expected snr >= 0'
seg = mock.random_trigger_value('segment', 10)
assert isinstance(seg, numpy.ndarray), 'expected segment to be numpy.ndarray'
assert issubclass(seg.dtype.type, int), 'expected type int for snr'
assert numpy.issubdtype(seg.dtype.type, int), 'expected type int for snr'
assert numpy.all((seg == 1) | (seg == 0)), 'expected segment values to be either 0 or 1'
runiform = mock.random_trigger_value('rand', 5)
assert isinstance(runiform, numpy.ndarray), 'expected random uniform to be numpy.ndarray'
assert issubclass(runiform.dtype.type, float), 'expected type float for random uniform'
assert numpy.issubdtype(runiform.dtype.type, float), 'expected type float for random uniform'
assert numpy.all((runiform >= 0) & (runiform <= 1)), 'expected segment values to be between 0 and 1'
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment