Example #1
0
def test_3D_axis1():
    open(logfile, 'w').close()
    checks = {'MEAN_IN_RANGE': (0, 7)}
    arr = arr_3D.copy()
    arr[np.isnan(arr)] = 0
    arr[arr < 0] = 0
    ck.check(arr, checks, data_tag, logger, 1)
    assert is_text_in_file(logfile, 'frame #0')
    assert is_text_in_file(logfile, 'frame #1')
    assert not is_text_in_file(logfile, 'frame #2')
Example #2
0
def test_no_sat_no_in_range():
    checks = {'SAT_IN_RANGE': (1, 2)}
    arr = arr_3D.copy()
    arr[np.isnan(arr)] = 0
    arr[arr < 0] = 0
    verified = ck.check(arr, checks, data_tag, logger)
    assert not verified
Example #3
0
def test_is_mean_in_range():
    checks = {'MEAN_IN_RANGE': (0, 7)}
    arr = arr_2D.copy()
    arr[np.isnan(arr)] = 0
    arr[arr < 0] = 0
    verified = ck.check(arr, checks, data_tag, logger)
    assert verified
Example #4
0
def test_no_mean_no_in_range():
    checks = {'MEAN_IN_RANGE': (100, 107)}
    arr = arr_3D.copy()
    arr[np.isnan(arr)] = 0
    arr[arr < 0] = 0
    verified = ck.check(arr, checks, data_tag, logger)
    assert not verified
Example #5
0
def test_is_complex():
    checks = {'IS_COMPLEX': ()}
    arr = arr_3D.copy()
    arr[np.isnan(arr)] = 0
    arr = arr.astype(np.dtype(np.complex))
    verified = ck.check(arr, checks, data_tag, logger)
    assert verified
Example #6
0
def test_no_float():
    checks = {'IS_FLOAT': ()}
    arr = arr_3D.copy()
    arr[np.isnan(arr)] = 0
    arr = arr.astype(int)
    verified = ck.check(arr, checks, data_tag, logger)
    assert not verified
Example #7
0
def test_is_int():
    checks = {'IS_INT': ()}
    arr = arr_3D.copy()
    arr[np.isnan(arr)] = 0
    arr = arr.astype(int)
    verified = ck.check(arr, checks, data_tag, logger)
    assert verified
Example #8
0
def test_no_tag():
    open('default.log', 'w').close()
    checks = {'IS_NPARRAY': ()}
    verified = ck.check(arr_2D, checks)
    assert verified
    assert is_text_in_file(
        'default.log', 'mydata' + ' evaluated "is_nparray" with result True')
    os.remove('default.log')
Example #9
0
def test_3D_no_axis():
    open(logfile, 'w').close()
    checks = {'MEAN_IN_RANGE': (0, 7)}
    arr = arr_2D.copy()
    arr[np.isnan(arr)] = 0
    arr[arr < 0] = 0
    verified = ck.check(arr, checks, data_tag, logger)
    assert verified
    assert is_text_in_file(
        logfile,
        data_tag + ' evaluated frame #0 mean_in_range with result True')
    assert not is_text_in_file(logfile, 'frame #1')
Example #10
0
def test_no_size_dims():
    checks = {'IS_SIZE': arr_3D.shape}
    verified = ck.check(arr_2D, checks, data_tag, logger)
    assert not verified
Example #11
0
def test_no_logger():
    checks = {'IS_NPARRAY': ()}
    verified = ck.check(arr_2D, checks, data_tag)
    assert verified
    assert is_text_in_file(
        'default.log', data_tag + ' evaluated "is_nparray" with result True')
Example #12
0
def test_no_nans():
    checks = {'HAS_NO_NAN': ()}
    arr = arr_3D.copy()
    arr[np.isnan(arr)] = 0
    verified = ck.check(arr, checks, data_tag, logger)
    assert verified
Example #13
0
def test_no_negative():
    checks = {'HAS_NO_NEGATIVE': ()}
    arr = arr_2D.copy()
    arr[arr < 0] = 0
    verified = ck.check(arr, checks, data_tag, logger)
    assert verified
Example #14
0
def test_nparray():
    checks = {'IS_NPARRAY': ()}
    verified = ck.check(arr_2D, checks, data_tag, logger)
    assert verified
Example #15
0
def test_is_size():
    checks = {'IS_SIZE': (4, 2, 3)}
    verified = ck.check(arr_3D, checks, data_tag, logger)
    assert verified
Example #16
0
def test_no_complex():
    checks = {'IS_COMPLEX': ()}
    arr = arr_3D.copy()
    arr[np.isnan(arr)] = 0
    verified = ck.check(arr, checks, data_tag, logger)
    assert not verified
Example #17
0
def test_has_nans():
    checks = {'HAS_NO_NAN': ()}
    verified = ck.check(arr_3D, checks, data_tag, logger)
    assert not verified
Example #18
0
def test_no_nparra():
    checks = {'IS_NPARRAY': ()}
    verified = ck.check('a', checks, data_tag, logger)
    assert not verified
Example #19
0
def test_no_size_shape():
    checks = {'IS_SIZE': (9, 10)}
    verified = ck.check(arr_2D, checks, data_tag, logger)
    assert not verified
Example #20
0
def test_has_negative():
    checks = {'HAS_NO_NEGATIVE': ()}
    verified = ck.check(arr_3D, checks, data_tag, logger)
    assert not verified
Example #21
0
import censor.checks as ck
import numpy as np

arr_3D = np.array([[[1, 2, 3], [np.log(-1.), -5, -7]],[[1, 2, 3], [4, 5, 6]],
[[1, 2, 3], [4, 5, 6]], [[1, 2, 3], [4, 5, 6]]])

checks = {'MEAN_IN_RANGE': (0, 7)}
arr = arr_3D.copy()
arr[np.isnan(arr)] = 0
arr[arr < 0] = 0
ck.check(arr, checks)