-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: attributes -> attrs * NaN features from spike, rate of change, and morello * style: PEP8 on rate_of_change.py * fix: Correct relative path to fuzzy * refactor: cumulative rate of change with NaN Cumulative Rate of Change procedure now returns NaN features when values are invalid, and a few more improvements, including improvements in the validation tests. * Global range using NaN instead of masked array * Rate of Change, feature with NaN
- Loading branch information
Showing
9 changed files
with
127 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,56 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
""" Check cummulative Rate of Change QC test | ||
""" Verify the Cummulative Rate of Change QC test | ||
""" | ||
|
||
from numpy import ma | ||
import numpy as np | ||
from cotede.qctests import CumRateOfChange, cum_rate_of_change | ||
from data import DummyData | ||
|
||
|
||
def test(): | ||
profile = DummyData() | ||
def test_cum_rate_of_change(): | ||
x = [1, -1, 2, 2, 3, 2, 4] | ||
memory = 0.8 | ||
y = cum_rate_of_change(x, memory) | ||
|
||
output = [np.nan, 2.0, 3.0, 2.4, 2.12, 1.896, 2.0] | ||
|
||
dummy_output = ma.masked_array([0, 5.43, 4.93, 14.68], | ||
mask=[True, False, False, False]) | ||
assert isinstance(y, np.ndarray) | ||
assert np.allclose(y, output, equal_nan=True) | ||
|
||
cfg = { | ||
'memory': 0.8, | ||
'threshold': 4, | ||
'flag_good': 1, | ||
'flag_bad': 4 | ||
} | ||
|
||
y = CumRateOfChange(profile, 'TEMP', cfg) | ||
assert type(y.features) is dict | ||
def test_standard_dataset(): | ||
"""Test CumRateOfChange with a standard dataset | ||
""" | ||
profile = DummyData() | ||
|
||
x = cum_rate_of_change(profile['TEMP'], cfg['memory']) | ||
assert type(x) is ma.MaskedArray | ||
# assert ma.allclose(x, dummy_output) | ||
features = { | ||
"cum_rate_of_change": [ | ||
np.nan, | ||
0.02, | ||
0.016, | ||
0.03, | ||
0.32, | ||
1.53, | ||
1.61, | ||
3.9, | ||
3.632, | ||
4.31, | ||
4.278, | ||
3.6224, | ||
3.34192, | ||
3.099536, | ||
np.nan, | ||
] | ||
} | ||
flags = {"cum_rate_of_change": [0, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 1, 1, 1, 9]} | ||
|
||
cfg = {"memory": 0.8, "threshold": 4, "flag_good": 1, "flag_bad": 4} | ||
|
||
y = CumRateOfChange(profile, "TEMP", cfg) | ||
|
||
for f in features: | ||
assert np.allclose(y.features[f], features[f], equal_nan=True) | ||
for f in flags: | ||
assert np.allclose(y.flags[f], flags[f], equal_nan=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters