From: Eric F. <ef...@ha...> - 2009-09-30 21:12:52
|
> - I don't follow what the snippet of code below is doing: > > if cbook.iterable(value): > vtype = 'array' > val = ma.asarray(value).astype(np.float) > else: > vtype = 'scalar' > val = ma.array([value]).astype(np.float) > The idea is that the norm __call__ method should return a scalar when given a scalar input, or an array when given a sequence input. It is easiest to do the calculation with masked arrays or ndarrays, however, so inputs are converted, keeping track of whether it is a scalar or not, so that if it is a scalar, the output can be converted from 1-element array back to a scalar. Eric |