提交 85ef3da4 编写于 作者: wgzqz's avatar wgzqz

Fix _process_input bug that will appear when (sub,div) are lists but not np.array instances.

上级 61761bf8
...@@ -30,15 +30,15 @@ class Model(object): ...@@ -30,15 +30,15 @@ class Model(object):
# Make self._preprocess to be (0,1) if possible, so that don't need # Make self._preprocess to be (0,1) if possible, so that don't need
# to do substract or divide. # to do substract or divide.
if preprocess is not None: if preprocess is not None:
sub, div = preprocess sub, div = np.array(preprocess)
if not np.any(sub): if not np.any(sub):
sub = None sub = 0
if np.all(np.array(div) == 1): if np.all(div == 1):
div = None div = 1
assert (div is None) or np.all(div) assert (div is None) or np.all(div)
self._preprocess = (sub, div) self._preprocess = (sub, div)
else: else:
self._preprocess = (None, None) self._preprocess = (0, 1)
def bounds(self): def bounds(self):
""" """
...@@ -55,9 +55,9 @@ class Model(object): ...@@ -55,9 +55,9 @@ class Model(object):
def _process_input(self, input_): def _process_input(self, input_):
res = None res = None
sub, div = self._preprocess sub, div = self._preprocess
if sub is not None: if np.any(sub != 0):
res = input_ - sub res = input_ - sub
if div is not None: if not np.all(sub == 1):
if res is None: # "res = input_ - sub" is not executed! if res is None: # "res = input_ - sub" is not executed!
res = input_ / div res = input_ / div
else: else:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册