Skip to content

Commit

Permalink
Merge pull request #62 from glos/spike-test-masked-array-fix
Browse files Browse the repository at this point in the history
Fixed spike test masked array issue
  • Loading branch information
kwilcox committed Aug 5, 2021
2 parents 04f4b7b + ba9c292 commit ad438eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ioos_qc/qartod.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def spike_test(inp: Sequence[N],
# Apply different method
if method == 'average':
# Calculate the average of n-2 and n
ref = np.zeros(inp.size, dtype=np.float64)
ref = np.ma.zeros(inp.size, dtype=np.float64)
ref[1:-1] = (inp[0:-2] + inp[2:]) / 2
ref = np.ma.masked_invalid(ref)

Expand Down
8 changes: 4 additions & 4 deletions tests/test_qartod.py
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ def test_spike_masked(self):

# First and last elements should always be good data, unless someone
# has set a threshold to zero.
expected = [2, 4, 4, 4, 1, 3, 1, 1, 9, 9, 4, 4, 4, 9]
expected = [2, 4, 4, 4, 1, 3, 1, 9, 9, 9, 4, 4, 9, 9]

inputs = [
arr,
Expand Down Expand Up @@ -995,7 +995,7 @@ def test_spike_methods(self):
inp = [3, 4.99, 5, 6, 8, 6, 6, 6.75, 6, 6, 5.3, 6, 6, 9, 5, None, 4, 4]
suspect_threshold = .5
fail_threshold = 1
average_method_expected = [2, 3, 1, 1, 4, 3, 1, 3, 1, 1, 3, 1, 4, 4, 4, 9, 9, 2]
average_method_expected = [2, 3, 1, 1, 4, 3, 1, 3, 1, 1, 3, 1, 4, 4, 9, 9, 9, 2]
diff_method_expected = [2, 1, 1, 1, 4, 1, 1, 3, 1, 1, 3, 1, 1, 4, 9, 9, 9, 2]

# Test average method
Expand Down Expand Up @@ -1052,8 +1052,8 @@ def test_spike_test_bad_method(self):

def test_spike_test_inputs(self):
inp = [3, 4.99, 5, 6, 8, 6, 6, 6.75, 6, 6, 5.3, 6, 6, 9, 5, None, 4, 4]
expected_suspect_only = [2, 3, 1, 1, 3, 3, 1, 3, 1, 1, 3, 1, 3, 3, 3, 9, 9, 2]
expected_fail_only = [2, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 9, 9, 2]
expected_suspect_only = [2, 3, 1, 1, 3, 3, 1, 3, 1, 1, 3, 1, 3, 3, 9, 9, 9, 2]
expected_fail_only = [2, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 4, 4, 9, 9, 9, 2]
suspect_threshold = .5
fail_threshold = 1

Expand Down

0 comments on commit ad438eb

Please sign in to comment.