From 1f5a6c6ce747bb37e74f9c0bb10de91c8bb1f3bf Mon Sep 17 00:00:00 2001 From: Theo Steininger <theos@mpa-garching.mpg.de> Date: Mon, 1 May 2017 03:32:36 +0200 Subject: [PATCH] Fixed infer_dtype in Field --- nifty/field.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nifty/field.py b/nifty/field.py index eddc59009..5796f78bc 100644 --- a/nifty/field.py +++ b/nifty/field.py @@ -90,9 +90,11 @@ class Field(Loggable, Versionable, object): try: dtype = val.dtype except AttributeError: - if val is not None: + try: + if val is None: + raise TypeError dtype = np.result_type(val) - else: + except(TypeError): dtype = np.dtype(gc['default_field_dtype']) else: dtype = np.dtype(dtype) @@ -307,6 +309,9 @@ class Field(Loggable, Versionable, object): # check if the `spaces` input is valid spaces = utilities.cast_axis_to_tuple(spaces, len(self.domain)) + if spaces is None: + spaces = range(len(self.domain)) + for power_space_index in spaces: power_space = self.domain[power_space_index] if not isinstance(power_space, PowerSpace): -- GitLab