def setDF(self, df, update=1): # config = self.get_config() configDict = self.__getstate__() [configDict.pop(k) for k in list(configDict) if k.startswith('_')] if isinstance(df, pd.Series): df = df.values if isinstance(df, pyutil.np.ndarray): if update and (df.shape == self.shape): self.loc[:, :] = df res = self else: res = pyutil.init_DF(df, rowName=self.index) else: res = df if not isinstance(res, self.__class__): assert isinstance(res, pd.DataFrame) # print self.__class__, res.__class__ res = self.__class__.from_DataFrame(df=res, ) res.__setstate__(configDict) res.set__colMeta(res.colMeta) res.set__rowMeta(res.rowMeta) # res.set_config(**config) return res
def __init__(self, C=None, rowName=None, colName=None, name=None, look=None, cmap=None, vlim=None, fname=None, model=None, **kwargs): df = pyutil.init_DF(C=C, rowName=rowName, colName=colName) # print self.__class__,countMatrix, isinstance(self,countMatrix,) super(countMatrix, self).__init__(df) self.name_ = name self.look = look self.cmap = cmap self.vlim = vlim self.fname = fname self.model = model self.param = { 'normF': 'identityNorm', } self.set_config(test=None, **kwargs) self.test = None
def __init__(self, C=None, rowName=None, colName=None, name=None, look=None, cmap=None, vlim=None, fname=None, model=None, colMeta=None, rowMeta=None, height=1., **kwargs): df = pyutil.init_DF(C=C, rowName=rowName, colName=colName) # print self.__class__,countMatrix, isinstance(self,countMatrix,) super(countMatrix, self).__init__(df) self.name_ = name self.look = look self.cmap = cmap self.vlim = vlim self.fname = fname self.model = model self.height = height # self.colMeta_ = colMeta self.set__colMeta(colMeta) self.set__rowMeta(rowMeta) # self.rowMeta_ = rowMeta self.param = { 'normF': 'identityNorm', } self.set_config(test=None, **kwargs) self.test = None assert self.name != 'test', 'Track name cannot be %s' % self.name
def from_deepcache(cls, d=None, fname=None): if fname is not None: d = np.load(fname) d = dict(d) else: assert d is not None, 'must specify one of variables: "d" or "fname"' deepdict = d C = deepdict.get('matrix', np.array([[]])) colName = deepdict.get('labels', None) rowName = deepdict.get('which is row name?', None) df = pyutil.init_DF(C=C, colName=colName, rowName=rowName) ins = cls.from_DataFrame(df=df) return ins
def setDF(self, df): config = self.get_config() if isinstance(df, pd.Series): df = df.values if isinstance(df, pyutil.np.ndarray): if df.shape == self.shape: self.loc[:, :] = df res = self else: res = pyutil.init_DF(df, rowName=self.index) else: res = df if not isinstance(res, self.__class__): assert isinstance(res, pd.DataFrame) # print self.__class__, res.__class__ res = self.__class__.from_DataFrame(df=res, ) res.set_config(**config) return res