|
33 | 33 | def get_absPath(filename): |
34 | 34 | """Returns the path of the notebooks folder""" |
35 | 35 | path = os.path.abspath( |
36 | | - os.path.join(os.path.dirname(__file__), os.path.pardir, |
37 | | - os.path.pardir, "data", filename)) |
| 36 | + os.path.join( |
| 37 | + os.path.dirname(__file__), os.path.pardir, os.path.pardir, "data", filename |
| 38 | + ) |
| 39 | + ) |
38 | 40 | return path |
39 | 41 |
|
40 | 42 |
|
@@ -81,42 +83,42 @@ def get_absPath(filename): |
81 | 83 | def test_check_schema(): |
82 | 84 | datafile = get_absPath("diabetes.csv") |
83 | 85 | # check that file exists |
84 | | - assert(os.path.exists(datafile)) |
| 86 | + assert os.path.exists(datafile) |
85 | 87 | dataset = pd.read_csv(datafile) |
86 | 88 | header = dataset[dataset.columns[:-1]] |
87 | 89 | actual_columns = header.shape[1] |
88 | 90 | # check header has expected number of columns |
89 | | - assert(actual_columns == expected_columns) |
| 91 | + assert actual_columns == expected_columns |
90 | 92 |
|
91 | 93 |
|
92 | 94 | def test_check_bad_schema(): |
93 | 95 | datafile = get_absPath("diabetes_bad_schema.csv") |
94 | 96 | # check that file exists |
95 | | - assert(os.path.exists(datafile)) |
| 97 | + assert os.path.exists(datafile) |
96 | 98 | dataset = pd.read_csv(datafile) |
97 | 99 | header = dataset[dataset.columns[:-1]] |
98 | 100 | actual_columns = header.shape[1] |
99 | 101 | # check header has expected number of columns |
100 | | - assert(actual_columns != expected_columns) |
| 102 | + assert actual_columns != expected_columns |
101 | 103 |
|
102 | 104 |
|
103 | 105 | def test_check_missing_values(): |
104 | 106 | datafile = get_absPath("diabetes_missing_values.csv") |
105 | 107 | # check that file exists |
106 | | - assert(os.path.exists(datafile)) |
| 108 | + assert os.path.exists(datafile) |
107 | 109 | dataset = pd.read_csv(datafile) |
108 | 110 | n_nan = np.sum(np.isnan(dataset.values)) |
109 | | - assert(n_nan > 0) |
| 111 | + assert n_nan > 0 |
110 | 112 |
|
111 | 113 |
|
112 | 114 | def test_check_distribution(): |
113 | 115 | datafile = get_absPath("diabetes_bad_dist.csv") |
114 | 116 | # check that file exists |
115 | | - assert(os.path.exists(datafile)) |
| 117 | + assert os.path.exists(datafile) |
116 | 118 | dataset = pd.read_csv(datafile) |
117 | 119 | mean = np.mean(dataset.values, axis=0) |
118 | 120 | std = np.mean(dataset.values, axis=0) |
119 | | - assert(np.sum(abs(mean - historical_mean) > shift_tolerance * |
120 | | - abs(historical_mean)) or |
121 | | - np.sum(abs(std - historical_std) > shift_tolerance * |
122 | | - abs(historical_std)) > 0) |
| 121 | + assert ( |
| 122 | + np.sum(abs(mean - historical_mean) > shift_tolerance * abs(historical_mean)) |
| 123 | + or np.sum(abs(std - historical_std) > shift_tolerance * abs(historical_std)) > 0 |
| 124 | + ) |
0 commit comments