-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into another_plotfit_fix
- Loading branch information
Showing
3 changed files
with
42 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#unit tests for gpfit.fit module" | ||
import unittest | ||
from numpy import logspace, log10, log, vstack | ||
from gpfit.fit import fit | ||
|
||
class t_fit(unittest.TestCase): | ||
|
||
u = logspace(0, log10(3), 501) | ||
w = (u**2 + 3)/(u+1)**2 | ||
x = log(u) | ||
y = log(w) | ||
K = 3 | ||
|
||
def test_rms_error(self): | ||
cstrt, rms_error = fit(self.x, self.y, self.K, "SMA") | ||
self.assertTrue(rms_error < 1e-4) | ||
cstrt, rms_error = fit(self.x, self.y, self.K, "ISMA") | ||
self.assertTrue(rms_error < 1e-5) | ||
cstrt, rms_error = fit(self.x, self.y, self.K, "MA") | ||
self.assertTrue(rms_error < 1e-2) | ||
|
||
def test_incorrect_inputs(self): | ||
with self.assertRaises(ValueError): | ||
fit(self.x, vstack((self.y, self.y)), self.K, "MA") | ||
|
||
|
||
TESTS = [t_fit] | ||
|
||
if __name__ == '__main__': | ||
SUITE = unittest.TestSuite() | ||
LOADER = unittest.TestLoader() | ||
|
||
for t in TESTS: | ||
SUITE.addTests(LOADER.loadTestsFromTestCase(t)) | ||
|
||
unittest.TextTestRunner(verbosity=2).run(SUITE) |