forked from NicoNeureiter/sBayes
-
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
1 parent
6fffd9a
commit 751744d
Showing
3 changed files
with
88 additions
and
33 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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
import numpy as np | ||
import unittest | ||
|
||
from sbayes.plot import Plot, main | ||
|
||
|
||
class TestPlot(unittest.TestCase): | ||
|
||
""" | ||
Test cases of plotting functions in ´sbayes/plot.py´. | ||
""" | ||
|
||
@staticmethod | ||
def test_example(): | ||
main( | ||
config='test/plot_test_files/config_plot.json', | ||
plot_types=['map'], | ||
) | ||
# #!/usr/bin/env python3 | ||
# # -*- coding: utf-8 -*- | ||
# import numpy as np | ||
# import unittest | ||
# | ||
# from sbayes.plot import Plot, main | ||
# | ||
# | ||
# class TestPlot(unittest.TestCase): | ||
# | ||
# """ | ||
# Test cases of plotting functions in ´sbayes/plot.py´. | ||
# """ | ||
# | ||
# @staticmethod | ||
# def test_example(): | ||
# main( | ||
# config='test/plot_test_files/config_plot.json', | ||
# plot_types=['map'], | ||
# ) |
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 numpy as np | ||
import unittest | ||
|
||
from sbayes.sampling.state import ArrayParameter, CalculationNode, GroupedParameters | ||
|
||
class TestArrayParameter(unittest.TestCase): | ||
|
||
N_GROUPS = 3 | ||
N_ITEMS = 4 | ||
|
||
def setUp(self) -> None: | ||
arr = np.arange(12).reshape((self.N_GROUPS, self.N_ITEMS)) | ||
self.param = GroupedParameters(arr) | ||
self.calc = CalculationNode(np.empty((self.N_GROUPS, self.N_ITEMS))) | ||
|
||
def test_initial_state(self): | ||
self.assertEqual(self.param.value[1, 2], 6) | ||
self.assertEqual(self.param.version, 0) | ||
|
||
def test_set_items(self): | ||
# Change parameter using set_items | ||
self.param.set_items((1, 2), 1000) | ||
|
||
# Validate changes in value and version number | ||
self.assertEqual(self.param.value[1,2], 1000) | ||
self.assertEqual(self.param.version, 1) | ||
|
||
def test_edit(self): | ||
# Change parameter using the .edit() context manager | ||
with self.param.edit() as value: | ||
value[1, 2] = 1000 | ||
|
||
# Validate changes in value and version number | ||
self.assertEqual(self.param.value[1,2], 1000) | ||
self.assertEqual(self.param.version, 1) | ||
|
||
def test_set_value(self): | ||
# Change parameter using the .edit() context manager | ||
new_value = self.param.value.copy() | ||
new_value[1, 2] = 1000 | ||
self.param.set_value(new_value) | ||
|
||
# Validate changes in value and version number | ||
self.assertEqual(self.param.value[1,2], 1000) | ||
self.assertEqual(self.param.version, 1) | ||
|
||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |