def __cast_data(self, data):
    if isinstance(data, list):
        try:
            data = np.array(data)
        except Exception as e:
            raise Exception(('MfList error: casting list to ndarray: ' + str(e)))
    if isinstance(data, dict):
        if (not list(data.keys())):
            raise Exception('MfList error: data dict is empty')
        for (kper, d) in data.items():
            try:
                kper = int(kper)
            except Exception as e:
                raise Exception((((('MfList error: data dict key ' + '{0:s} not integer: '.format(kper)) + str(type(kper))) + '\n') + str(e)))
            if isinstance(d, list):
                try:
                    d = np.array(d)
                except Exception as e:
                    raise Exception((('MfList error: casting list ' + 'to ndarray: ') + str(e)))
            if isinstance(d, np.recarray):
                self.__cast_recarray(kper, d)
            elif isinstance(d, np.ndarray):
                self.__cast_ndarray(kper, d)
            elif isinstance(d, int):
                self.__cast_int(kper, d)
            elif isinstance(d, str):
                self.__cast_str(kper, d)
            elif (d is None):
                self.__data[kper] = (- 1)
                self.__vtype[kper] = None
            else:
                raise Exception(((('MfList error: unsupported data type: ' + str(type(d))) + ' at kper ') + '{0:d}'.format(kper)))
    elif isinstance(data, np.recarray):
        self.__cast_recarray(0, data)
    elif isinstance(data, np.ndarray):
        self.__cast_ndarray(0, data)
    elif isinstance(data, str):
        self.__cast_str(0, data)
    else:
        raise Exception(('MfList error: unsupported data type: ' + str(type(data))))
def __cast_data(self, data):
    if isinstance(data, list):
        try:
            data = np.array(data)
        except Exception as e:
            raise Exception(('MfList error: casting list to ndarray: ' + str(e)))
    if isinstance(data, dict):
        if (not list(data.keys())):
            raise Exception('MfList error: data dict is empty')
        for (kper, d) in data.items():
            try:
                kper = int(kper)
            except Exception as e:
                raise Exception((((('MfList error: data dict key ' + '{0:s} not integer: '.format(kper)) + str(type(kper))) + '\n') + str(e)))
            if isinstance(d, list):
                try:
                    d = np.array(d)
                except Exception as e:
                    raise Exception((('MfList error: casting list ' + 'to ndarray: ') + str(e)))
            if isinstance(d, np.recarray):
                self.__cast_recarray(kper, d)
            elif isinstance(d, np.ndarray):
                self.__cast_ndarray(kper, d)
            elif isinstance(d, int):
                self.__cast_int(kper, d)
            elif isinstance(d, str):
                self.__cast_str(kper, d)
            elif (d is None):
                self.__data[kper] = (- 1)
                self.__vtype[kper] = None
            else:
                raise Exception(((('MfList error: unsupported data type: ' + str(type(d))) + ' at kper ') + '{0:d}'.format(kper)))
    elif isinstance(data, np.recarray):
        self.__cast_recarray(0, data)
    elif isinstance(data, np.ndarray):
        self.__cast_ndarray(0, data)
    elif isinstance(data, str):
        self.__cast_str(0, data)
    else:
        raise Exception(('MfList error: unsupported data type: ' + str(type(data))))