Exemplo n.º 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')
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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')
Exemplo n.º 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')
Exemplo n.º 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
Exemplo n.º 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')
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 14
0
def test_nparray():
    checks = {'IS_NPARRAY': ()}
    verified = ck.check(arr_2D, checks, data_tag, logger)
    assert verified
Exemplo n.º 15
0
def test_is_size():
    checks = {'IS_SIZE': (4, 2, 3)}
    verified = ck.check(arr_3D, checks, data_tag, logger)
    assert verified
Exemplo n.º 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
Exemplo n.º 17
0
def test_has_nans():
    checks = {'HAS_NO_NAN': ()}
    verified = ck.check(arr_3D, checks, data_tag, logger)
    assert not verified
Exemplo n.º 18
0
def test_no_nparra():
    checks = {'IS_NPARRAY': ()}
    verified = ck.check('a', checks, data_tag, logger)
    assert not verified
Exemplo n.º 19
0
def test_no_size_shape():
    checks = {'IS_SIZE': (9, 10)}
    verified = ck.check(arr_2D, checks, data_tag, logger)
    assert not verified
Exemplo n.º 20
0
def test_has_negative():
    checks = {'HAS_NO_NEGATIVE': ()}
    verified = ck.check(arr_3D, checks, data_tag, logger)
    assert not verified
Exemplo n.º 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)