def _reshape(self, array):
"""
checks shapes, eg convert them (2d), raise if not possible
after checks passed, set self._array and return it.
"""
if array.ndim == 1:
array = np.atleast_2d(array).T
elif array.ndim == 2:
pass
else:
shape = array.shape
# hold first dimension, multiply the rest
shape_2d = (shape[0],
functools.reduce(lambda x, y: x * y, shape[1:]))
array = np.reshape(array, shape_2d)
return array
评论列表
文章目录