def make(self, dsargs): # use cache if available for gen_ver, prev_dsargs in self.used_dsargs.items(): if dst.filteredDict(dsargs, 'name', True) == dst.filteredDict(prev_dsargs, 'name', True): # compare everything but the name, but check all up to final '_ver<X>' parts1 = dsargs.name.split('_') parts2 = prev_dsargs.name.split('_') # will have one more part if parts1 == parts2[:-2]: print("Reusing identical build") return dst.loadObjects(os.path.join(self.cwd, 'models', prev_dsargs.name+'.sav'))[0] # no matches return self.build(dsargs)
def make(self, dsargs): # use cache if available for gen_ver, prev_dsargs in self.used_dsargs.items(): if dst.filteredDict(dsargs, 'name', True) == dst.filteredDict( prev_dsargs, 'name', True): # compare everything but the name, but check all up to final '_ver<X>' parts1 = dsargs.name.split('_') parts2 = prev_dsargs.name.split('_') # will have one more part if parts1 == parts2[:-2]: print("Reusing identical build") return dst.loadObjects( os.path.join(self.cwd, 'models', prev_dsargs.name + '.sav'))[0] # no matches return self.build(dsargs)
def map_workspace(con, pts, *args): """ Returns a list of dictionaries, each representing the state of the calc_context workspace for each of the points given. Optional positional arguments will be passed first to the calc_context when calling it. This assumes the calc_context local_init accepts `pt` as an argument. """ wseq = [] for pt in pts: con(*args, pt=pt) wseq.append(dst.filteredDict(con.workspace.__dict__, ['_name'], neg=True)) return wseq
def clip_to_pt(): """Extract clipboard point from gui to a dictionary""" pt = dst.filteredDict(gui.capturedPts['Master'], ['V', 'm', 'n']) return {'V': pt['V'], 'Na.m': pt['m'], 'K.n': pt['n']}