def __init__(self, dims: List[int], typecode: str = 'd'): length = _.reduce(lambda agg, i: agg * i, dims, 1) sparseLS = Map().mutate() dimsLen = len(dims) self.__buffer__ = sparseLS self.__dims__ = dims if dimsLen == 1: self.__calcPos__ = calcPos1 elif dimsLen == 2: self.__calcPos__ = calcPos2 elif dimsLen == 3: self.__calcPos__ = calcPos3
def __init__(self, dims: List[int], typecode: str = 'd', silent=False): length = _.reduce(lambda agg, i: agg * i, dims, 1) ls = array(typecode, map(lambda i: 0, range(length))) dimsLen = len(dims) self.__buffer__ = ls if silent is False: print('\nContainer size in memory: {0} KB'.format( len(ls) * ls.itemsize / 1024)) self.__dims__ = dims if dimsLen == 1: self.__calcPos__ = calcPos1 elif dimsLen == 2: self.__calcPos__ = calcPos2 elif dimsLen == 3: self.__calcPos__ = calcPos3