Commit c8018d8e authored by Martin Reinecke's avatar Martin Reinecke
Browse files

experiment with dtypes

parent 585414a4
Pipeline #28419 passed with stages
in 2 minutes and 42 seconds
......@@ -47,19 +47,30 @@ class MultiField(object):
def copy(self):
return MultiField({key: val.copy() for key, val in self.items()})
@staticmethod
def build_dtype(dtype, domain):
if isinstance(dtype, dict):
return dtype
if dtype is None:
dtype = np.float64
return {key: dtype for key in domain.keys()}
@staticmethod
def zeros(domain, dtype=None):
return MultiField({key: Field.zeros(dom, dtype=dtype)
dtype = self.build_dtype(dtype, domain)
return MultiField({key: Field.zeros(dom, dtype=dtype[key])
for key, dom in domain.items()})
@staticmethod
def ones(domain, dtype=None):
return MultiField({key: Field.ones(dom, dtype=dtype)
dtype = self.build_dtype(dtype, domain)
return MultiField({key: Field.ones(dom, dtype=dtype[key])
for key, dom in domain.items()})
@staticmethod
def empty(domain, dtype=None):
return MultiField({key: Field.empty(dom, dtype=dtype)
dtype = self.build_dtype(dtype, domain)
return MultiField({key: Field.empty(dom, dtype=dtype[key])
for key, dom in domain.items()})
def norm(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