Commit b628605f authored by Theo Steininger's avatar Theo Steininger

Added caching to field.shape

parent a014e614
......@@ -112,7 +112,6 @@ class Field(Loggable, Versionable, object):
def __init__(self, domain=None, val=None, dtype=None,
distribution_strategy=None, copy=False):
self.domain = self._parse_domain(domain=domain, val=val)
self.domain_axes = self._get_axes_tuple(self.domain)
......@@ -128,6 +127,7 @@ class Field(Loggable, Versionable, object):
else:
self.set_val(new_val=val, copy=copy)
def _parse_domain(self, domain, val=None):
if domain is None:
if isinstance(val, Field):
......@@ -775,14 +775,14 @@ class Field(Loggable, Versionable, object):
dim
"""
if not hasattr(self, '_shape'):
shape_tuple = tuple(sp.shape for sp in self.domain)
try:
global_shape = reduce(lambda x, y: x + y, shape_tuple)
except TypeError:
global_shape = ()
return global_shape
self._shape = global_shape
return self._shape
@property
def dim(self):
......
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