-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from parkin/absoluteChangeStrategy
Absolute change strategy implemented
- Loading branch information
Showing
4 changed files
with
112 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__author__ = 'parkin' |
28 changes: 28 additions & 0 deletions
28
src/pypore/strategies/tests/test_absolute_change_threshold_strategy.py
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import unittest | ||
|
||
from pypore.strategies.absolute_change_threshold_strategy import AbsoluteChangeThresholdStrategy | ||
|
||
|
||
class TestAbsoluteChangeThresholdStrategy(unittest.TestCase): | ||
def test_compute_starting_threshold(self): | ||
""" | ||
Test that the starting and ending thresholds do not depend on the baseline or variance. | ||
""" | ||
start_changes = [-1.e9, -1, -1.e-9, 0., 1, 1.e-9, 1.e9] | ||
end_changes = [-1.e9, -1, -1.e-9, 0., 1, 1.e-9, 1.e9] | ||
baselines = [-1.e9, -1., -1.e-9, 0., 1, 1.e-9, 1.e9] | ||
variances = [-1.e9, -1., -1.e-9, 0., 1, 1.e-9, 1.e9] | ||
for i in xrange(len(start_changes)): | ||
strategy = AbsoluteChangeThresholdStrategy(start_changes[i], end_changes[i]) | ||
|
||
for j in xrange(len(variances)): | ||
start_thresh = strategy.compute_starting_threshold(baselines[j], variances[j]) | ||
end_thresh = strategy.compute_ending_threshold(baselines[j], variances[j]) | ||
|
||
self.assertEqual(start_thresh, start_changes[i], | ||
"Unexpected starting threshold. Should be {0}, was {1}.".format(start_changes[i], | ||
start_thresh)) | ||
self.assertEqual(end_thresh, end_changes[i], | ||
"Unexpected ending threshold. Should be {0}, was {1}.".format(end_changes[i], | ||
end_thresh)) | ||
|
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