-
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.
- Loading branch information
1 parent
1cf1c84
commit 9b1d467
Showing
2 changed files
with
39 additions
and
0 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,36 @@ | ||
#unit tests for gpfit.fit module" | ||
import unittest | ||
from gpfit.fit import fit | ||
|
||
class t_fit(unittest.TestCase): | ||
m = 501 | ||
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(x, y, K, "SMA") | ||
self.assertTrue(self.rms_error < 1e-4) | ||
cstrt, rms_error = fit(x, y, K, "ISMA") | ||
self.assertTrue(self.rms_error < 1e-5) | ||
cstrt, rms_error = fit(x, y, K, "MA") | ||
self.assertTrue(self.rms_error < 1e-2) | ||
|
||
def test_incorrect_inputs(self): | ||
err = fit(x, 0, K, "MA") | ||
self.assertEqual(self.err, 'Dependent data should be a 1D numpy array') | ||
|
||
|
||
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) | ||
|