Commit 4b6b4e79 authored by Theo Steininger's avatar Theo Steininger
Browse files

Added lazy initialization for Field.val.

Set default dtype for FieldArray
parent 2d541f05
Pipeline #10030 passed with stages
in 17 minutes and 34 seconds
......@@ -34,7 +34,10 @@ class Field(Loggable, Versionable, object):
self.set_val(new_val=val, copy=copy)
if val is None:
self._val = None
self.set_val(new_val=val, copy=copy)
def _parse_domain(self, domain, val=None):
if domain is None:
......@@ -406,6 +409,9 @@ class Field(Loggable, Versionable, object):
return self
def get_val(self, copy=False):
if self._val is None:
if copy:
return self._val.copy()
......@@ -413,11 +419,11 @@ class Field(Loggable, Versionable, object):
def val(self):
return self._val
return self.get_val(copy=False)
def val(self, new_val):
self._val = self.cast(new_val)
self.set_val(new_val=new_val, copy=False)
def shape(self):
......@@ -2,12 +2,14 @@
import pickle
import numpy as np
from field_type import FieldType
class FieldArray(FieldType):
def __init__(self, dtype, shape):
def __init__(self, shape, dtype=np.float):
new_shape = tuple([int(i) for i in shape])
except TypeError:
Supports Markdown
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