def preprocess(self): ''' ''' if self.has_docstring and self.strip_docstring: dl = self.docstring.count('\n') + 1 self.ignore_lines = list(range(self.start + 1, self.start + 1 + dl)) if self.strip_comments: ix = np.array(where_true(self.sublines, self.matcher.match)) self.ignore_lines += list(ix+self.start) if self.strip_blanks: ix = np.array(where_true(self.sublines, str.isspace )) self.ignore_lines += list(ix+self.start) if self.condense: #don't print source code for sections that weren't excecuted #(eg. inside if statement or nested function not followed. Instead #print seperator lines to segment. #FIXME: single line skip printed as ellipses #FIXME: def line not printed.... #FIXME: blank lines still printed?? #FIXME: multiline functions are cut! linenos = sorted( {self.start} | set(self.stats.keys()) | {self.end} ) nrpairs = np.array(list(pairwise(linenos))) gaps = np.subtract(*zip(*nrpairs)) intervals = nrpairs[gaps < -2] + (1,-1) self.ignore_lines += list(flatiter(starmap(range, intervals))) self.where_gaps = nrpairs[gaps < -1][:,0] #relative to source code line numbers #truncate and fill lines with whitespace to create block text maxlen = max(map(len, self.sublines)) if self.truncate_lines: self.sublines = truncate(self.sublines, self.truncate_lines, self.ellipses)
def update(self, draggable, xydata, draw_on=True): '''draw all artists that where changed by the motion''' artists = filter(None, (func(xydata) for cid, func in draggable.observers.items())) #six.iteritems(self.observers): if draw_on: #self._draw_on if self._use_blit: self.canvas.restore_region(self.background) for art in flatiter((artists, draggable.ref_art)): #WARNING: will flatten containers etc art.draw(self.canvas.renderer) self.canvas.blit(self.figure.bbox) else: self.canvas.draw() return artists
from astropy.io.fits.hdu.base import register_hdu from recipes.iter import flatiter, itersubclasses from .core import * # register HDU classes register_hdu(shocNewHDU) register_hdu(shocOldHDU) # TODO: Consider shocBiasHDU, shocFlatFieldHDU + match headers by looking at obstype keywords # Collect named cubes in a dict namedObsClasses = {cls.kind: cls for cls in flatiter((itersubclasses(shocObs), shocObs))} namedRunClasses = {cls.obsClass.kind: cls for cls in flatiter((itersubclasses(shocRun), shocRun))} def cubeFactory(kind): # not really a factory return namedObsClasses.get(kind, shocObs) def runFactory(kind): return namedRunClasses.get(kind, shocRun) def load(filenames, kind='science'): """ Parameters ---------- filenames