Commit 790752d9 authored by dboe's avatar dboe
Browse files

pytests run ALL

parent f4ed25ce
......@@ -9,7 +9,7 @@ ATOL = 1e-8
class Base_Check(object):
def demand_equal(self, other):
raise NotImplementedError(self.__class__)
self.assertIsInstance(other, type(self._inst))
def test_pickle(self):
with NamedTemporaryFile(suffix='.pickle') as out_file:
......@@ -69,6 +69,7 @@ class Tensors_Check(AbstractNdarray_Check):
_inst = None
def demand_equal(self, other, atol=False, transformed=False):
super().demand_equal(other)
if atol:
self.assertTrue(self._inst.equal(other, atol=ATOL))
else:
......@@ -313,6 +314,7 @@ class TensorMaps_NoFields_Test(TensorMaps_Test):
class Maps_Test(Base_Check, unittest.TestCase):
def demand_equal(self, other):
super().demand_equal(other)
self._inst.equal(other)
def setUp(self):
......@@ -327,6 +329,7 @@ class Maps_Test(Base_Check, unittest.TestCase):
class Container_Check(AbstractNdarray_Check):
def demand_equal(self, other):
super().demand_equal(other)
for i, item in enumerate(self._inst.items):
if issubclass(type(item), tfields.core.AbstractNdarray):
self.assertTrue(other.items[i].equal(item))
......@@ -353,7 +356,6 @@ class Container_Test(Container_Check, unittest.TestCase):
(-np.pi / 2, np.pi / 2, 3),
coord_sys='spherical')
sphere2 = sphere.copy() * 3
print(type(sphere2))
self._inst = tfields.Container([sphere, sphere2], labels=['test'])
......
......@@ -2073,10 +2073,18 @@ class Container(Fields):
if len(items) == 1 and issubclass(type(items[0]), list):
# Container([a, b, ...]) - includes copy constructor
items = items[0]
if labels is None and issubclass(type(items), Container):
labels = items.labels
super().__init__(items)
self.labels = labels
def __setstate__(self, state):
self.__dict__ = state
def copy(self):
return deepcopy(self)
@property
def items(self):
return list(self)
......@@ -2247,7 +2255,11 @@ class TensorMaps(TensorFields):
]
def __new__(cls, tensors, *fields, **kwargs):
maps = Maps(kwargs.pop("maps", {}))
if issubclass(type(tensors), TensorMaps):
default_maps = tensors.maps
else:
default_maps = {}
maps = Maps(kwargs.pop("maps", default_maps))
obj = super(TensorMaps, cls).__new__(cls, tensors, *fields, **kwargs)
obj.maps = maps
return obj
......
......@@ -733,8 +733,6 @@ class Mesh3D(tfields.TensorMaps):
for field, map_field, merge_function in \
zip(fields, empty_map_fields, merge_functions):
for i, f_index in enumerate(point_face_assignment_set):
# if i % 1000 == 0:
# print(i, len(point_face_assignment_set))
if f_index == -1:
# point could not be mapped
continue
......
......@@ -630,13 +630,7 @@ class Triangles3D(tfields.TensorFields):
masks = np.zeros((len(tensors), self.ntriangles()), dtype=bool)
with tensors.tmp_transform(self.coord_sys):
for i, point in enumerate(iter(tensors)):
# print(i)
# print("Status: {i} points processed. Yet {nP} are found "
# "to be in triangles (before handling assign_multiple)."
# .format(nP=masks.sum(), **locals())) # SLOW!
masks[i] = self._in_triangles(point, delta)
# print("Status: All points processed. Yet {nP} are found "
# "to be in triangles.".format(nP=masks.sum() - 1, **locals()))
if len(masks) == 0:
# empty sequence
......
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