-
Notifications
You must be signed in to change notification settings - Fork 89
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 #131 from ran-wei-verses/obj_array_130
make safe obj_array_from_list to address issue #130 with test
- Loading branch information
Showing
2 changed files
with
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
""" Agent Class | ||
__author__: Conor Heins, Alexander Tschantz, Daphne Demekas, Brennan Klein | ||
""" | ||
|
||
import unittest | ||
|
||
import numpy as np | ||
|
||
from pymdp import utils | ||
|
||
class TestUtils(unittest.TestCase): | ||
def test_obj_array_from_list(self): | ||
""" | ||
Tests `obj_array_from_list` | ||
""" | ||
# make arrays with same leading dimensions. naive method trigger numpy broadcasting error. | ||
arrs = [np.zeros((3, 6)), np.zeros((3, 4, 5))] | ||
obs_arrs = utils.obj_array_from_list(arrs) | ||
|
||
self.assertTrue(all([np.all(a == b) for a, b in zip(arrs, obs_arrs)])) | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |