-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
251 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import numpy as np | ||
|
||
|
||
def size_one_or_n(value, other_array, name): | ||
|
||
value_ = np.array(value, dtype=float, ndmin=1) | ||
|
||
if value_.shape[0] == 1: | ||
|
||
value_ = np.zeros(other_array.shape[0], dtype=float) + value | ||
|
||
else: | ||
|
||
assert value_.shape[0] == other_array.shape[0], "The size of %s must be either 1 or the same size of n" % name | ||
|
||
return value_ |
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,50 @@ | ||
import pytest | ||
import numpy as np | ||
|
||
from poisson_poisson import significance as poi_poi_significance | ||
from poisson_poisson import z_bi_significance as poi_poi_zbi | ||
|
||
from poisson_gaussian import significance as poi_gau_significance | ||
from poisson_gaussian import z_bi_significance as poi_gau_zbi | ||
|
||
from ideal_case import significance as ideal_significance | ||
|
||
|
||
def test_poi_poi_significance(): | ||
|
||
# Test with one number | ||
s = poi_poi_significance(20, 80, 0.1, k=0, sigma=0) | ||
|
||
s = poi_poi_significance(20, 80, 0.1, k=0.1, sigma=0) | ||
|
||
s = poi_poi_significance(20, 80, 0.1, k=0, sigma=0.1) | ||
|
||
assert np.isclose(poi_poi_zbi(140, 100, 1 / 1.2), 3.93, rtol=0.01) | ||
|
||
# Test with arrays | ||
s = poi_poi_significance([20, 30], [80, 90], 0.1) | ||
s = poi_poi_significance([20, 30], [80, 90], [0.1, 0.2]) | ||
|
||
s = poi_poi_significance([20, 30], [80, 90], 0.1, k=0.1) | ||
s = poi_poi_significance([20, 30], [80, 90], [0.1, 0.2], k=[0.1, 0.1]) | ||
|
||
s = poi_poi_significance([20, 30], [80, 90], 0.1, sigma=0.1) | ||
s = poi_poi_significance([20, 30], [80, 90], [0.1, 0.2], sigma=[0.1, 0.1]) | ||
|
||
assert np.allclose(poi_poi_zbi([140, 140], [100, 100], [1 / 1.2, 1/1.2]), [3.93, 3.93], rtol=0.01) | ||
|
||
# Test mixed | ||
s = poi_poi_significance([20, 30, 40], [80, 90, 100], alpha=[0.1, 0.1, 0.1], | ||
k=[0, 0.1, 0], sigma=[0, 0, 10]) | ||
|
||
def test_poi_gau_significance(): | ||
|
||
# Test with one number | ||
s = poi_gau_significance(120, 80, 5.3) | ||
|
||
assert np.isclose(poi_gau_zbi(140, 83.33, 8.333), 3.93, rtol=0.01) | ||
|
||
# Test with vectors | ||
s = poi_gau_significance([120, 130], [80, 90], [5.3, 5.3]) | ||
|
||
assert np.allclose(poi_gau_zbi([140, 140], [83.33, 83.33], [8.333, 8.333]), [3.93, 3.93], rtol=0.01) |
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
Oops, something went wrong.