_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q241400
TimerHeap.remove_all_timers
train
def remove_all_timers(self): """Remove all waiting timers and terminate any blocking threads.""" with self.lock: if self.rtimer is not None: self.rtimer.cancel() self.timers = {} self.heap = [] self.rtimer = None self.expiring ...
python
{ "resource": "" }
q241401
CompoundMixin.get_llur
train
def get_llur(self): """ Get lower-left and upper-right coordinates of the bounding box of this compound object. Returns ------- x1, y1, x2, y2: a 4-tuple of the lower-left and upper-right coords """ points = np.array([obj.get_llur() for obj in self.object...
python
{ "resource": "" }
q241402
BasicCanvasView.build_gui
train
def build_gui(self, container): """ This is responsible for building the viewer's UI. It should place the UI in `container`. Override this to make a custom UI. """ vbox = Widgets.VBox() vbox.set_border_width(0) w = Viewers.GingaViewerWidget(viewer=self)...
python
{ "resource": "" }
q241403
BasicCanvasView.embed
train
def embed(self, width=600, height=650): """ Embed a viewer into a Jupyter notebook. """ from IPython.display import IFrame return IFrame(self.url, width, height)
python
{ "resource": "" }
q241404
BasicCanvasView.load_fits
train
def load_fits(self, filepath): """ Load a FITS file into the viewer. """ image = AstroImage.AstroImage(logger=self.logger) image.load_file(filepath) self.set_image(image)
python
{ "resource": "" }
q241405
BasicCanvasView.load_hdu
train
def load_hdu(self, hdu): """ Load an HDU into the viewer. """ image = AstroImage.AstroImage(logger=self.logger) image.load_hdu(hdu) self.set_image(image)
python
{ "resource": "" }
q241406
BasicCanvasView.load_data
train
def load_data(self, data_np): """ Load raw numpy data into the viewer. """ image = AstroImage.AstroImage(logger=self.logger) image.set_data(data_np) self.set_image(image)
python
{ "resource": "" }
q241407
BasicCanvasView.set_html5_canvas_format
train
def set_html5_canvas_format(self, fmt): """ Sets the format used for rendering to the HTML5 canvas. 'png' offers greater clarity, especially for small text, but does not have as good of performance as 'jpeg'. """ fmt = fmt.lower() if fmt not in ('jpeg', 'png'): ...
python
{ "resource": "" }
q241408
EnhancedCanvasView.build_gui
train
def build_gui(self, container): """ This is responsible for building the viewer's UI. It should place the UI in `container`. """ vbox = Widgets.VBox() vbox.set_border_width(2) vbox.set_spacing(1) w = Viewers.GingaViewerWidget(viewer=self) vbox.ad...
python
{ "resource": "" }
q241409
ViewerFactory.get_viewer
train
def get_viewer(self, v_id, viewer_class=None, width=512, height=512, force_new=False): """ Get an existing viewer by viewer id. If the viewer does not yet exist, make a new one. """ if not force_new: try: return self.viewers[v_id] ...
python
{ "resource": "" }
q241410
Pick.detailxy
train
def detailxy(self, canvas, button, data_x, data_y): """Motion event in the pick fits window. Show the pointing information under the cursor. """ if button == 0: # TODO: we could track the focus changes to make this check # more efficient chviewer = se...
python
{ "resource": "" }
q241411
reference_viewer
train
def reference_viewer(sys_argv): """Create reference viewer from command line.""" viewer = ReferenceViewer(layout=default_layout) viewer.add_default_plugins() viewer.add_separately_distributed_plugins() # Parse command line options with optparse module from optparse import OptionParser usag...
python
{ "resource": "" }
q241412
ReferenceViewer.add_default_plugins
train
def add_default_plugins(self, except_global=[], except_local=[]): """ Add the ginga-distributed default set of plugins to the reference viewer. """ # add default global plugins for spec in plugins: ptype = spec.get('ptype', 'local') if ptype == 'gl...
python
{ "resource": "" }
q241413
ReferenceViewer.add_default_options
train
def add_default_options(self, optprs): """ Adds the default reference viewer startup options to an OptionParser instance `optprs`. """ optprs.add_option("--bufsize", dest="bufsize", metavar="NUM", type="int", default=10, help="B...
python
{ "resource": "" }
q241414
GwMain.gui_call
train
def gui_call(self, method, *args, **kwdargs): """General method for synchronously calling into the GUI. This waits until the method has completed before returning. """ my_id = thread.get_ident() if my_id == self.gui_thread_id: return method(*args, **kwdargs) e...
python
{ "resource": "" }
q241415
WBrowser.show_help
train
def show_help(self, plugin=None, no_url_callback=None): """See `~ginga.GingaPlugin` for usage of optional keywords.""" if not Widgets.has_webkit: return self.fv.nongui_do(self._download_doc, plugin=plugin, no_url_callback=no_url_callback)
python
{ "resource": "" }
q241416
get_mean
train
def get_mean(data_np): """Calculate mean for valid values. Parameters ---------- data_np : ndarray Input array. Returns ------- result : float Mean of array values that are finite. If array contains no finite values, returns NaN. """ i = np.isfinite(data_np...
python
{ "resource": "" }
q241417
IQCalc.calc_fwhm_gaussian
train
def calc_fwhm_gaussian(self, arr1d, medv=None, gauss_fn=None): """FWHM calculation on a 1D array by using least square fitting of a gaussian function on the data. arr1d is a 1D array cut in either X or Y direction on the object. """ if gauss_fn is None: gauss_fn = se...
python
{ "resource": "" }
q241418
IQCalc.calc_fwhm_moffat
train
def calc_fwhm_moffat(self, arr1d, medv=None, moffat_fn=None): """FWHM calculation on a 1D array by using least square fitting of a Moffat function on the data. arr1d is a 1D array cut in either X or Y direction on the object. """ if moffat_fn is None: moffat_fn = sel...
python
{ "resource": "" }
q241419
my_import
train
def my_import(name, path=None): """Return imported module for the given name.""" # Documentation for importlib says this may be needed to pick up # modules created after the program has started if hasattr(importlib, 'invalidate_caches'): # python 3.3+ importlib.invalidate_caches() ...
python
{ "resource": "" }
q241420
ModuleManager.get_module
train
def get_module(self, module_name): """Return loaded module from the given name.""" try: return self.module[module_name] except KeyError: return sys.modules[module_name]
python
{ "resource": "" }
q241421
ImageViewBindings.parse_combo
train
def parse_combo(self, combo, modes_set, modifiers_set, pfx): """ Parse a string into a mode, a set of modifiers and a trigger. """ mode, mods, trigger = None, set([]), combo if '+' in combo: if combo.endswith('+'): # special case: probably contains the...
python
{ "resource": "" }
q241422
ImageViewBindings.get_direction
train
def get_direction(self, direction, rev=False): """ Translate a direction in compass degrees into 'up' or 'down'. """ if (direction < 90.0) or (direction >= 270.0): if not rev: return 'up' else: return 'down' elif (90.0 <= di...
python
{ "resource": "" }
q241423
ImageViewBindings.kp_pan_px_center
train
def kp_pan_px_center(self, viewer, event, data_x, data_y, msg=True): """This pans so that the cursor is over the center of the current pixel.""" if not self.canpan: return False self.pan_center_px(viewer) return True
python
{ "resource": "" }
q241424
ImageViewBindings.ms_zoom
train
def ms_zoom(self, viewer, event, data_x, data_y, msg=True): """Zoom the image by dragging the cursor left or right. """ if not self.canzoom: return True msg = self.settings.get('msg_zoom', msg) x, y = self.get_win_xy(viewer) if event.state == 'move': ...
python
{ "resource": "" }
q241425
ImageViewBindings.ms_zoom_in
train
def ms_zoom_in(self, viewer, event, data_x, data_y, msg=False): """Zoom in one level by a mouse click. """ if not self.canzoom: return True if not (event.state == 'down'): return True with viewer.suppress_redraw: viewer.panset_xy(data_x, data...
python
{ "resource": "" }
q241426
ImageViewBindings.ms_rotate
train
def ms_rotate(self, viewer, event, data_x, data_y, msg=True): """Rotate the image by dragging the cursor left or right. """ if not self.canrotate: return True msg = self.settings.get('msg_rotate', msg) x, y = self.get_win_xy(viewer) if event.state == 'move':...
python
{ "resource": "" }
q241427
ImageViewBindings.ms_contrast
train
def ms_contrast(self, viewer, event, data_x, data_y, msg=True): """Shift the colormap by dragging the cursor left or right. Stretch the colormap by dragging the cursor up or down. """ if not self.cancmap: return True msg = self.settings.get('msg_contrast', msg) ...
python
{ "resource": "" }
q241428
ImageViewBindings.ms_contrast_restore
train
def ms_contrast_restore(self, viewer, event, data_x, data_y, msg=True): """An interactive way to restore the colormap contrast settings after a warp operation. """ if self.cancmap and (event.state == 'down'): self.restore_contrast(viewer, msg=msg) return True
python
{ "resource": "" }
q241429
ImageViewBindings.ms_cmap_restore
train
def ms_cmap_restore(self, viewer, event, data_x, data_y, msg=True): """An interactive way to restore the colormap settings after a rotate or invert operation. """ if self.cancmap and (event.state == 'down'): self.restore_colormap(viewer, msg) return True
python
{ "resource": "" }
q241430
ImageViewBindings.ms_pan
train
def ms_pan(self, viewer, event, data_x, data_y): """A 'drag' or proportional pan, where the image is panned by 'dragging the canvas' up or down. The amount of the pan is proportionate to the length of the drag. """ if not self.canpan: return True x, y = view...
python
{ "resource": "" }
q241431
ImageViewBindings.ms_cutlo
train
def ms_cutlo(self, viewer, event, data_x, data_y): """An interactive way to set the low cut level. """ if not self.cancut: return True x, y = self.get_win_xy(viewer) if event.state == 'move': self._cutlow_xy(viewer, x, y) elif event.state == 'do...
python
{ "resource": "" }
q241432
ImageViewBindings.ms_cutall
train
def ms_cutall(self, viewer, event, data_x, data_y): """An interactive way to set the low AND high cut levels. """ if not self.cancut: return True x, y = self.get_win_xy(viewer) if event.state == 'move': self._cutboth_xy(viewer, x, y) elif event....
python
{ "resource": "" }
q241433
ImageViewBindings.sc_cuts_coarse
train
def sc_cuts_coarse(self, viewer, event, msg=True): """Adjust cuts interactively by setting the low AND high cut levels. This function adjusts it coarsely. """ if self.cancut: # adjust the cut by 10% on each end self._adjust_cuts(viewer, event.direction, 0.1, msg=...
python
{ "resource": "" }
q241434
ImageViewBindings.sc_cuts_alg
train
def sc_cuts_alg(self, viewer, event, msg=True): """Adjust cuts algorithm interactively. """ if self.cancut: direction = self.get_direction(event.direction) self._cycle_cuts_alg(viewer, msg, direction=direction) return True
python
{ "resource": "" }
q241435
ImageViewBindings.sc_zoom
train
def sc_zoom(self, viewer, event, msg=True): """Interactively zoom the image by scrolling motion. This zooms by the zoom steps configured under Preferences. """ self._sc_zoom(viewer, event, msg=msg, origin=None) return True
python
{ "resource": "" }
q241436
ImageViewBindings.sc_zoom_coarse
train
def sc_zoom_coarse(self, viewer, event, msg=True): """Interactively zoom the image by scrolling motion. This zooms by adjusting the scale in x and y coarsely. """ if not self.canzoom: return True zoom_accel = self.settings.get('scroll_zoom_acceleration', 1.0) ...
python
{ "resource": "" }
q241437
ImageViewBindings.sc_pan
train
def sc_pan(self, viewer, event, msg=True): """Interactively pan the image by scrolling motion. """ if not self.canpan: return True # User has "Pan Reverse" preference set? rev = self.settings.get('pan_reverse', False) direction = event.direction if r...
python
{ "resource": "" }
q241438
ImageViewBindings.sc_dist
train
def sc_dist(self, viewer, event, msg=True): """Interactively change the color distribution algorithm by scrolling. """ direction = self.get_direction(event.direction) self._cycle_dist(viewer, msg, direction=direction) return True
python
{ "resource": "" }
q241439
ImageViewBindings.sc_cmap
train
def sc_cmap(self, viewer, event, msg=True): """Interactively change the color map by scrolling. """ direction = self.get_direction(event.direction) self._cycle_cmap(viewer, msg, direction=direction) return True
python
{ "resource": "" }
q241440
ImageViewBindings.sc_imap
train
def sc_imap(self, viewer, event, msg=True): """Interactively change the intensity map by scrolling. """ direction = self.get_direction(event.direction) self._cycle_imap(viewer, msg, direction=direction) return True
python
{ "resource": "" }
q241441
ImageViewBindings.pa_naxis
train
def pa_naxis(self, viewer, event, msg=True): """Interactively change the slice of the image in a data cube by pan gesture. """ event = self._pa_synth_scroll_event(event) if event.state != 'move': return False # TODO: be able to pick axis axis = 2 ...
python
{ "resource": "" }
q241442
BindingMapper.mode_key_down
train
def mode_key_down(self, viewer, keyname): """This method is called when a key is pressed and was not handled by some other handler with precedence, such as a subcanvas. """ # Is this a mode key? if keyname not in self.mode_map: if (keyname not in self.mode_tbl) or (se...
python
{ "resource": "" }
q241443
BindingMapper.mode_key_up
train
def mode_key_up(self, viewer, keyname): """This method is called when a key is pressed in a mode and was not handled by some other handler with precedence, such as a subcanvas. """ # Is this a mode key? if keyname not in self.mode_map: # <== no ret...
python
{ "resource": "" }
q241444
get_4pt_bezier
train
def get_4pt_bezier(steps, points): """Gets a series of bezier curve points with 1 set of 4 control points.""" for i in range(steps): t = i / float(steps) xloc = (math.pow(1 - t, 3) * points[0][0] + 3 * t * math.pow(1 - t, 2) * points[1][0] + 3 * (1 - t) * mat...
python
{ "resource": "" }
q241445
get_bezier
train
def get_bezier(steps, points): """Gets a series of bezier curve points with any number of sets of 4 control points.""" res = [] num_pts = len(points) for i in range(0, num_pts + 1, 3): if i + 4 < num_pts + 1: res.extend(list(get_4pt_bezier(steps, points[i:i + 4]))) return res
python
{ "resource": "" }
q241446
get_bezier_ellipse
train
def get_bezier_ellipse(x, y, xradius, yradius, kappa=0.5522848): """Get a set of 12 bezier control points necessary to form an ellipse.""" xs, ys = x - xradius, y - yradius ox, oy = xradius * kappa, yradius * kappa xe, ye = x + xradius, y + yradius pts = [(xs, y), (xs, y - oy), (x -...
python
{ "resource": "" }
q241447
Preferences.set_cmap_cb
train
def set_cmap_cb(self, w, index): """This callback is invoked when the user selects a new color map from the preferences pane.""" name = cmap.get_names()[index] self.t_.set(color_map=name)
python
{ "resource": "" }
q241448
Preferences.set_imap_cb
train
def set_imap_cb(self, w, index): """This callback is invoked when the user selects a new intensity map from the preferences pane.""" name = imap.get_names()[index] self.t_.set(intensity_map=name)
python
{ "resource": "" }
q241449
Preferences.set_calg_cb
train
def set_calg_cb(self, w, index): """This callback is invoked when the user selects a new color hashing algorithm from the preferences pane.""" #index = w.get_index() name = self.calg_names[index] self.t_.set(color_algorithm=name)
python
{ "resource": "" }
q241450
Preferences.autocut_params_changed_cb
train
def autocut_params_changed_cb(self, paramObj, ac_obj): """This callback is called when the user changes the attributes of an object via the paramSet. """ args, kwdargs = paramObj.get_params() params = list(kwdargs.items()) self.t_.set(autocut_params=params)
python
{ "resource": "" }
q241451
Preferences.set_sort_cb
train
def set_sort_cb(self, w, index): """This callback is invoked when the user selects a new sort order from the preferences pane.""" name = self.sort_options[index] self.t_.set(sort_order=name)
python
{ "resource": "" }
q241452
Preferences.set_scrollbars_cb
train
def set_scrollbars_cb(self, w, tf): """This callback is invoked when the user checks the 'Use Scrollbars' box in the preferences pane.""" scrollbars = 'on' if tf else 'off' self.t_.set(scrollbars=scrollbars)
python
{ "resource": "" }
q241453
Info.zoomset_cb
train
def zoomset_cb(self, setting, value, channel): """This callback is called when the main window is zoomed. """ if not self.gui_up: return info = channel.extdata._info_info if info is None: return #scale_x, scale_y = fitsimage.get_scale_xy() ...
python
{ "resource": "" }
q241454
MultiDim.redo
train
def redo(self): """Called when an image is set in the channel.""" image = self.channel.get_current_image() if image is None: return True path = image.get('path', None) if path is None: self.fv.show_error( "Cannot open image: no value for m...
python
{ "resource": "" }
q241455
reorder_image
train
def reorder_image(dst_order, src_arr, src_order): """Reorder src_arr, with order of color planes in src_order, as dst_order. """ depth = src_arr.shape[2] if depth != len(src_order): raise ValueError("src_order (%s) does not match array depth (%d)" % ( src_order, depth)) band...
python
{ "resource": "" }
q241456
strip_z
train
def strip_z(pts): """Strips a Z component from `pts` if it is present.""" pts = np.asarray(pts) if pts.shape[-1] > 2: pts = np.asarray((pts.T[0], pts.T[1])).T return pts
python
{ "resource": "" }
q241457
get_bounds
train
def get_bounds(pts): """Return the minimum point and maximum point bounding a set of points.""" pts_t = np.asarray(pts).T return np.asarray(([np.min(_pts) for _pts in pts_t], [np.max(_pts) for _pts in pts_t]))
python
{ "resource": "" }
q241458
trim_prefix
train
def trim_prefix(text, nchr): """Trim characters off of the beginnings of text lines. Parameters ---------- text : str The text to be trimmed, with newlines (\n) separating lines nchr: int The number of spaces to trim off the beginning of a line if it starts with that many s...
python
{ "resource": "" }
q241459
ImageViewMock._get_color
train
def _get_color(self, r, g, b): """Convert red, green and blue values specified in floats with range 0-1 to whatever the native widget color object is. """ clr = (r, g, b) return clr
python
{ "resource": "" }
q241460
ImageViewEvent.key_press_event
train
def key_press_event(self, widget, event): """ Called when a key is pressed and the window has the focus. Adjust method signature as appropriate for callback. """ # get keyname or keycode and translate to ginga standard # keyname = # keycode = keyname = '' ...
python
{ "resource": "" }
q241461
ImageViewEvent.key_release_event
train
def key_release_event(self, widget, event): """ Called when a key is released after being pressed. Adjust method signature as appropriate for callback. """ # get keyname or keycode and translate to ginga standard # keyname = # keycode = keyname = '' # sel...
python
{ "resource": "" }
q241462
ScrolledView.resizeEvent
train
def resizeEvent(self, event): """Override from QAbstractScrollArea. Resize the viewer widget when the viewport is resized.""" vp = self.viewport() rect = vp.geometry() x1, y1, x2, y2 = rect.getCoords() width = x2 - x1 + 1 height = y2 - y1 + 1 self.v_w.res...
python
{ "resource": "" }
q241463
ScrolledView.scrollContentsBy
train
def scrollContentsBy(self, dx, dy): """Override from QAbstractScrollArea. Called when the scroll bars are adjusted by the user. """ if self._adjusting: return self._scrolling = True try: bd = self.viewer.get_bindings() res = bd.calc_pa...
python
{ "resource": "" }
q241464
get_catalog
train
def get_catalog(): """Returns a catalog of available transforms. These are used to build chains for rendering with different back ends. """ tforms = {} for name, value in list(globals().items()): if name.endswith('Transform'): tforms[name] = value return Bunch.Bunch(tforms,...
python
{ "resource": "" }
q241465
masktorgb
train
def masktorgb(mask, color='lightgreen', alpha=1.0): """Convert boolean mask to RGB image object for canvas overlay. Parameters ---------- mask : ndarray Boolean mask to overlay. 2D image only. color : str Color name accepted by Ginga. alpha : float Opacity. Unmasked da...
python
{ "resource": "" }
q241466
_find_rtd_version
train
def _find_rtd_version(): """Find closest RTD doc version.""" vstr = 'latest' try: import ginga from bs4 import BeautifulSoup except ImportError: return vstr # No active doc build before this release, just use latest. if not minversion(ginga, '2.6.0'): return vstr...
python
{ "resource": "" }
q241467
_download_rtd_zip
train
def _download_rtd_zip(rtd_version=None, **kwargs): """ Download and extract HTML ZIP from RTD to installed doc data path. Download is skipped if content already exists. Parameters ---------- rtd_version : str or `None` RTD version to download; e.g., "latest", "stable", or "v2.6.0". ...
python
{ "resource": "" }
q241468
get_doc
train
def get_doc(logger=None, plugin=None, reporthook=None): """ Return URL to documentation. Attempt download if does not exist. Parameters ---------- logger : obj or `None` Ginga logger. plugin : obj or `None` Plugin object. If given, URL points to plugin doc directly. If ...
python
{ "resource": "" }
q241469
SaveImage.redo
train
def redo(self, *args): """Generate listing of images that user can save.""" if not self.gui_up: return mod_only = self.w.modified_only.get_state() treedict = Bunch.caselessDict() self.treeview.clear() self.w.status.set_text('') channel = self.fv.get_...
python
{ "resource": "" }
q241470
SaveImage.update_channels
train
def update_channels(self): """Update the GUI to reflect channels and image listing. """ if not self.gui_up: return self.logger.debug("channel configuration has changed--updating gui") try: channel = self.fv.get_channel(self.chname) except KeyErro...
python
{ "resource": "" }
q241471
SaveImage._format_extname
train
def _format_extname(self, ext): """Pretty print given extension name and number tuple.""" if ext is None: outs = ext else: outs = '{0},{1}'.format(ext[0], ext[1]) return outs
python
{ "resource": "" }
q241472
SaveImage.browse_outdir
train
def browse_outdir(self): """Browse for output directory.""" self.dirsel.popup( 'Select directory', self.w.outdir.set_text, initialdir=self.outdir) self.set_outdir()
python
{ "resource": "" }
q241473
SaveImage.set_outdir
train
def set_outdir(self): """Set output directory.""" dirname = self.w.outdir.get_text() if os.path.isdir(dirname): self.outdir = dirname self.logger.debug('Output directory set to {0}'.format(self.outdir)) else: self.w.outdir.set_text(self.outdir) ...
python
{ "resource": "" }
q241474
SaveImage.set_suffix
train
def set_suffix(self): """Set output suffix.""" self.suffix = self.w.suffix.get_text() self.logger.debug('Output suffix set to {0}'.format(self.suffix))
python
{ "resource": "" }
q241475
SaveImage._write_history
train
def _write_history(self, pfx, hdu, linechar=60, indentchar=2): """Write change history to given HDU header. Limit each HISTORY line to given number of characters. Subsequent lines of the same history will be indented. """ channel = self.fv.get_channel(self.chname) if chan...
python
{ "resource": "" }
q241476
SaveImage._write_header
train
def _write_header(self, image, hdu): """Write header from image object to given HDU.""" hduhdr = hdu.header # Ginga image header object for the given extension only. # Cannot use get_header() because that might also return PRI hdr. ghdr = image.metadata['header'] for ke...
python
{ "resource": "" }
q241477
SaveImage._write_mef
train
def _write_mef(self, key, extlist, outfile): """Write out regular multi-extension FITS data.""" channel = self.fv.get_channel(self.chname) with fits.open(outfile, mode='update') as pf: # Process each modified data extension for idx in extlist: k = '{0}[{1}...
python
{ "resource": "" }
q241478
SaveImage.toggle_save_cb
train
def toggle_save_cb(self, w, res_dict): """Only enable saving if something is selected.""" if len(res_dict) > 0: self.w.save.set_enabled(True) else: self.w.save.set_enabled(False)
python
{ "resource": "" }
q241479
SaveImage.save_images
train
def save_images(self): """Save selected images. This uses Astropy FITS package to save the outputs no matter what user chose to load the images. """ res_dict = self.treeview.get_selected() clobber = self.settings.get('clobber', False) self.treeview.clear_selecti...
python
{ "resource": "" }
q241480
font_info
train
def font_info(font_str): """Extract font information from a font string, such as supplied to the 'font' argument to a widget. """ vals = font_str.split(';') point_size, style, weight = 8, 'normal', 'normal' family = vals[0] if len(vals) > 1: style = vals[1] if len(vals) > 2: ...
python
{ "resource": "" }
q241481
CanvasObjectBase.get_points
train
def get_points(self): """Get the set of points that is used to draw the object. Points are returned in *data* coordinates. """ if hasattr(self, 'points'): points = self.crdmap.to_data(self.points) else: points = [] return points
python
{ "resource": "" }
q241482
CanvasObjectBase.get_data_points
train
def get_data_points(self, points=None): """Points returned are in data coordinates.""" if points is None: points = self.points points = self.crdmap.to_data(points) return points
python
{ "resource": "" }
q241483
CanvasObjectBase.set_data_points
train
def set_data_points(self, points): """ Input `points` must be in data coordinates, will be converted to the coordinate space of the object and stored. """ self.points = np.asarray(self.crdmap.data_to(points))
python
{ "resource": "" }
q241484
CanvasObjectBase.convert_mapper
train
def convert_mapper(self, tomap): """ Converts our object from using one coordinate map to another. NOTE: In some cases this only approximately preserves the equivalent point values when transforming between coordinate spaces. """ frommap = self.crdmap if ...
python
{ "resource": "" }
q241485
CanvasObjectBase.point_within_radius
train
def point_within_radius(self, points, pt, canvas_radius, scales=(1.0, 1.0)): """Points `points` and point `pt` are in data coordinates. Return True for points within the circle defined by a center at point `pt` and within canvas_radius. """ scale_x, sc...
python
{ "resource": "" }
q241486
CanvasObjectBase.within_radius
train
def within_radius(self, viewer, points, pt, canvas_radius): """Points `points` and point `pt` are in data coordinates. Return True for points within the circle defined by a center at point `pt` and within canvas_radius. The distance between points is scaled by the canvas scale. "...
python
{ "resource": "" }
q241487
CanvasObjectBase.get_pt
train
def get_pt(self, viewer, points, pt, canvas_radius=None): """Takes an array of points `points` and a target point `pt`. Returns the first index of the point that is within the radius of the target point. If none of the points are within the radius, returns None. """ if c...
python
{ "resource": "" }
q241488
CanvasObjectBase.within_line
train
def within_line(self, viewer, points, p_start, p_stop, canvas_radius): """Points `points` and line endpoints `p_start`, `p_stop` are in data coordinates. Return True for points within the line defined by a line from p_start to p_end and within `canvas_radius`. The distance betwee...
python
{ "resource": "" }
q241489
CanvasObjectBase.get_bbox
train
def get_bbox(self, points=None): """ Get bounding box of this object. Returns ------- (p1, p2, p3, p4): a 4-tuple of the points in data coordinates, beginning with the lower-left and proceeding counter-clockwise. """ if points is None: x1, y1,...
python
{ "resource": "" }
q241490
TimerFactory.set
train
def set(self, time_sec, callback_fn, *args, **kwdargs): """Convenience function to create and set a timer. Equivalent to: timer = timer_factory.timer() timer.set_callback('expired', callback_fn, *args, **kwdargs) timer.set(time_sec) """ timer = self.t...
python
{ "resource": "" }
q241491
ImageViewBase.set_window_size
train
def set_window_size(self, width, height): """Report the size of the window to display the image. **Callbacks** Will call any callbacks registered for the ``'configure'`` event. Callbacks should have a method signature of:: (viewer, width, height, ...) .. note:: ...
python
{ "resource": "" }
q241492
ImageViewBase.set_renderer
train
def set_renderer(self, renderer): """Set and initialize the renderer used by this instance. """ self.renderer = renderer width, height = self.get_window_size() if width > 0 and height > 0: renderer.resize((width, height))
python
{ "resource": "" }
q241493
ImageViewBase.set_canvas
train
def set_canvas(self, canvas, private_canvas=None): """Set the canvas object. Parameters ---------- canvas : `~ginga.canvas.types.layer.DrawingCanvas` Canvas object. private_canvas : `~ginga.canvas.types.layer.DrawingCanvas` or `None` Private canvas objec...
python
{ "resource": "" }
q241494
ImageViewBase.initialize_private_canvas
train
def initialize_private_canvas(self, private_canvas): """Initialize the private canvas used by this instance. """ if self.t_.get('show_pan_position', False): self.show_pan_mark(True) if self.t_.get('show_focus_indicator', False): self.show_focus_indicator(True)
python
{ "resource": "" }
q241495
ImageViewBase.set_rgbmap
train
def set_rgbmap(self, rgbmap): """Set RGB map object used by this instance. It controls how the values in the image are mapped to color. Parameters ---------- rgbmap : `~ginga.RGBMap.RGBMapper` RGB map. """ self.rgbmap = rgbmap t_ = rgbmap.get...
python
{ "resource": "" }
q241496
ImageViewBase.get_image
train
def get_image(self): """Get the image currently being displayed. Returns ------- image : `~ginga.AstroImage.AstroImage` or `~ginga.RGBImage.RGBImage` Image object. """ if self._imgobj is not None: # quick optomization return self._img...
python
{ "resource": "" }
q241497
ImageViewBase.get_canvas_image
train
def get_canvas_image(self): """Get canvas image object. Returns ------- imgobj : `~ginga.canvas.types.image.NormImage` Normalized image sitting on the canvas. """ if self._imgobj is not None: return self._imgobj try: # See if...
python
{ "resource": "" }
q241498
ImageViewBase.set_image
train
def set_image(self, image, add_to_canvas=True): """Set an image to be displayed. If there is no error, the ``'image-unset'`` and ``'image-set'`` callbacks will be invoked. Parameters ---------- image : `~ginga.AstroImage.AstroImage` or `~ginga.RGBImage.RGBImage` ...
python
{ "resource": "" }
q241499
ImageViewBase.save_profile
train
def save_profile(self, **params): """Save the given parameters into profile settings. Parameters ---------- params : dict Keywords and values to be saved. """ image = self.get_image() if (image is None): return profile = image.ge...
python
{ "resource": "" }