Exemplo n.º 1
0
Arquivo: stark.py Projeto: oberix/star
    def _update(self):
        ''' Call this method every time VD is changed to update Stark
        data.  Iter over VD and fill up different lists of keys, each
        list contains names from each data type.

        '''
        # Start from clean lists
        self._dim = []
        self._elab = []
        self._num = []
        self._imm = []
        self._rate = []
        self._curr = []
        # Sort md.items() by 'ORD' to have output lists already ordered.
        md_items = self._md['vars'].items()
        # md_items.sort(key=lambda x: x[1].get('ORD', 0))
        for key, val in md_items:
            if val['type'] == 'D':
                self._dim += utils.unroll({key: val})
            elif val['type'] == 'E':
                # (Re)evaluate elab columns
                self._df[key] = self._eval(self._md['vars'][key]['elab'])
                self._elab.append(key)
            elif val['type'] == 'N':
                # TODO: check that dtypes are really numeric types
                self._num.append(key)
            elif val['type'] == 'I':
                self._imm.append(key)
            elif val['type'] == 'C':
                self._curr.append(key)
            elif val['type'] == 'R':
                self._rate.append(key)
Exemplo n.º 2
0
Arquivo: stark.py Projeto: oberix/star
 def __delitem__(self, key):
     del self._df[key]
     target = utils.unroll(self._md)
     target.remove(key)
     self._md = utils.filter_tree(self._md, target)