Commit d23dec96 authored by dboe's avatar dboe
Browse files

really just subclassing list now

parent 6ec44d8a
...@@ -32,8 +32,6 @@ class AbstractNdarray_Check(object): ...@@ -32,8 +32,6 @@ class AbstractNdarray_Check(object):
def test_dict(self): def test_dict(self):
d = self._inst._as_dict() d = self._inst._as_dict()
print("DONE")
print(d)
other = type(self._inst)._from_dict(**d) other = type(self._inst)._from_dict(**d)
self.demand_equal(other) self.demand_equal(other)
...@@ -204,16 +202,24 @@ class Container_Test(Container_Check, unittest.TestCase): ...@@ -204,16 +202,24 @@ class Container_Test(Container_Check, unittest.TestCase):
self._inst = tfields.Container([sphere, sphere2]) self._inst = tfields.Container([sphere, sphere2])
class ContainerFolded_Test(Container_Check, unittest.TestCase): class ContainerNoList_Test(Container_Check, unittest.TestCase):
def demand_equal_tensors(self, one, other, atol=False, transformed=False):
if atol:
self.assertTrue(one.equal(other, atol=ATOL))
else:
self.assertTrue(one.equal(other))
if not transformed:
self.assertEqual(one.coord_sys, other.coord_sys)
self.assertEqual(one.name, other.name)
def demand_equal(self, other):
self.demand_equal_tensors(self._inst.items.items[0], other)
self.demand_equal_tensors(self._inst.items.items[1], other)
def setUp(self): def setUp(self):
sphere = tfields.Mesh3D.grid( t = tfields.TensorFields([[1, 2, 3]])
(1, 1, 1), self._inst = tfields.Container(t)
(-np.pi, np.pi, 3), print(self._inst.items)
(-np.pi / 2, np.pi / 2, 3),
coord_sys='spherical')
sphere2 = sphere.copy() * 3
self._container = tfields.Container([sphere, sphere2])
self._inst = tfields.Container(self._container)
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -469,7 +469,8 @@ class AbstractNdarray(np.ndarray): ...@@ -469,7 +469,8 @@ class AbstractNdarray(np.ndarray):
sub_dict = list_dict[key] sub_dict = list_dict[key]
list_dict[key] = [] list_dict[key] = []
for index in sorted(list(sub_dict)): for index in sorted(list(sub_dict)):
bulk_type = sub_dict[index].get("bulk_type").tolist() bulk_type = sub_dict[index].get("bulk_type")
# bulk_type = bulk_type.tolist() was necessary before. no clue
if isinstance(bulk_type, bytes): if isinstance(bulk_type, bytes):
# asthonishingly, this is not necessary under linux. # asthonishingly, this is not necessary under linux.
# Found under nt. ??? # Found under nt. ???
...@@ -483,6 +484,8 @@ class AbstractNdarray(np.ndarray): ...@@ -483,6 +484,8 @@ class AbstractNdarray(np.ndarray):
''' '''
bulk = kwargs.pop('bulk') bulk = kwargs.pop('bulk')
bulk_type = kwargs.pop('bulk_type') bulk_type = kwargs.pop('bulk_type')
print("-"*100)
print(bulk, bulk_type, kwargs)
obj = cls.__new__(cls, bulk, **kwargs) obj = cls.__new__(cls, bulk, **kwargs)
''' '''
...@@ -1928,7 +1931,7 @@ class Container(AbstractNdarray): ...@@ -1928,7 +1931,7 @@ class Container(AbstractNdarray):
__slots__ = ["items", "labels"] __slots__ = ["items", "labels"]
def __new__(cls, items, **kwargs): def __new__(cls, items, **kwargs):
if issubclass(type(items), cls): if issubclass(type(items), Container):
kwargs.setdefault('labels', items.labels) kwargs.setdefault('labels', items.labels)
items = items.items items = items.items
kwargs["items"] = items kwargs["items"] = items
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment