_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q280600
coverage._source_for_file
test
def _source_for_file(self, filename): """Return the source file for `filename`.""" if not filename.endswith(".py"): if filename[-4:-1] == ".py": filename = filename[:-1] elif filename.endswith("$py.class"): # jython filename = filename[:-9] + ".py"...
python
{ "resource": "" }
q280601
coverage._should_trace_with_reason
test
def _should_trace_with_reason(self, filename, frame): """Decide whether to trace execution in `filename`, with a reason. This function is called from the trace function. As each new file name is encountered, this function determines whether it is traced or not. Returns a pair of value...
python
{ "resource": "" }
q280602
coverage._should_trace
test
def _should_trace(self, filename, frame): """Decide whether to trace execution in `filename`. Calls `_should_trace_with_reason`, and returns just the decision. """ canonical, reason = self._should_trace_with_reason(filename, frame) if self.debug.should('trace'): if ...
python
{ "resource": "" }
q280603
coverage._warn
test
def _warn(self, msg): """Use `msg` as a warning.""" self._warnings.append(msg) sys.stderr.write("Coverage.py warning: %s\n" % msg)
python
{ "resource": "" }
q280604
coverage._check_for_packages
test
def _check_for_packages(self): """Update the source_match matcher with latest imported packages.""" # Our self.source_pkgs attribute is a list of package names we want to # measure. Each time through here, we see if we've imported any of # them yet. If so, we add its file to source_mat...
python
{ "resource": "" }
q280605
coverage.start
test
def start(self): """Start measuring code coverage. Coverage measurement actually occurs in functions called after `start` is invoked. Statements in the same scope as `start` won't be measured. Once you invoke `start`, you must also call `stop` eventually, or your process might...
python
{ "resource": "" }
q280606
coverage._atexit
test
def _atexit(self): """Clean up on process shutdown.""" if self._started: self.stop() if self.auto_data: self.save()
python
{ "resource": "" }
q280607
coverage.exclude
test
def exclude(self, regex, which='exclude'): """Exclude source lines from execution consideration. A number of lists of regular expressions are maintained. Each list selects lines that are treated differently during reporting. `which` determines which list is modified. The "exclude" li...
python
{ "resource": "" }
q280608
coverage._exclude_regex
test
def _exclude_regex(self, which): """Return a compiled regex for the given exclusion list.""" if which not in self._exclude_re: excl_list = getattr(self.config, which + "_list") self._exclude_re[which] = join_regex(excl_list) return self._exclude_re[which]
python
{ "resource": "" }
q280609
coverage.save
test
def save(self): """Save the collected coverage data to the data file.""" data_suffix = self.data_suffix if data_suffix is True: # If data_suffix was a simple true value, then make a suffix with # plenty of distinguishing information. We do this here in # `sav...
python
{ "resource": "" }
q280610
coverage.combine
test
def combine(self): """Combine together a number of similarly-named coverage data files. All coverage data files whose name starts with `data_file` (from the coverage() constructor) will be read, and combined together into the current measurements. """ aliases = None ...
python
{ "resource": "" }
q280611
coverage._harvest_data
test
def _harvest_data(self): """Get the collected data and reset the collector. Also warn about various problems collecting data. """ if not self._measured: return self.data.add_line_data(self.collector.get_line_data()) self.data.add_arc_data(self.collector.get...
python
{ "resource": "" }
q280612
coverage.analysis
test
def analysis(self, morf): """Like `analysis2` but doesn't return excluded line numbers.""" f, s, _, m, mf = self.analysis2(morf) return f, s, m, mf
python
{ "resource": "" }
q280613
coverage.analysis2
test
def analysis2(self, morf): """Analyze a module. `morf` is a module or a filename. It will be analyzed to determine its coverage statistics. The return value is a 5-tuple: * The filename for the module. * A list of line numbers of executable statements. * A list of lin...
python
{ "resource": "" }
q280614
coverage._analyze
test
def _analyze(self, it): """Analyze a single morf or code unit. Returns an `Analysis` object. """ self._harvest_data() if not isinstance(it, CodeUnit): it = code_unit_factory(it, self.file_locator)[0] return Analysis(self, it)
python
{ "resource": "" }
q280615
coverage.report
test
def report(self, morfs=None, show_missing=True, ignore_errors=None, file=None, # pylint: disable=W0622 omit=None, include=None ): """Write a summary report to `file`. Each module in `morfs` is listed, with counts of statements, ex...
python
{ "resource": "" }
q280616
coverage.annotate
test
def annotate(self, morfs=None, directory=None, ignore_errors=None, omit=None, include=None): """Annotate a list of modules. Each module in `morfs` is annotated. The source is written to a new file, named with a ",cover" suffix, with each line prefixed with a marker ...
python
{ "resource": "" }
q280617
coverage.html_report
test
def html_report(self, morfs=None, directory=None, ignore_errors=None, omit=None, include=None, extra_css=None, title=None): """Generate an HTML report. The HTML is written to `directory`. The file "index.html" is the overview starting point, with links to more detailed page...
python
{ "resource": "" }
q280618
coverage.xml_report
test
def xml_report(self, morfs=None, outfile=None, ignore_errors=None, omit=None, include=None): """Generate an XML report of coverage results. The report is compatible with Cobertura reports. Each module in `morfs` is included in the report. `outfile` is the path to w...
python
{ "resource": "" }
q280619
display
test
def display(*objs, **kwargs): """Display a Python object in all frontends. By default all representations will be computed and sent to the frontends. Frontends can decide which representation is used and how. Parameters ---------- objs : tuple of objects The Python objects to display. ...
python
{ "resource": "" }
q280620
display_html
test
def display_html(*objs, **kwargs): """Display the HTML representation of an object. Parameters ---------- objs : tuple of objects The Python objects to display, or if raw=True raw HTML data to display. raw : bool Are the data objects raw data or Python objects that need to b...
python
{ "resource": "" }
q280621
display_svg
test
def display_svg(*objs, **kwargs): """Display the SVG representation of an object. Parameters ---------- objs : tuple of objects The Python objects to display, or if raw=True raw svg data to display. raw : bool Are the data objects raw data or Python objects that need to be ...
python
{ "resource": "" }
q280622
display_png
test
def display_png(*objs, **kwargs): """Display the PNG representation of an object. Parameters ---------- objs : tuple of objects The Python objects to display, or if raw=True raw png data to display. raw : bool Are the data objects raw data or Python objects that need to be ...
python
{ "resource": "" }
q280623
display_jpeg
test
def display_jpeg(*objs, **kwargs): """Display the JPEG representation of an object. Parameters ---------- objs : tuple of objects The Python objects to display, or if raw=True raw JPEG data to display. raw : bool Are the data objects raw data or Python objects that need to b...
python
{ "resource": "" }
q280624
display_latex
test
def display_latex(*objs, **kwargs): """Display the LaTeX representation of an object. Parameters ---------- objs : tuple of objects The Python objects to display, or if raw=True raw latex data to display. raw : bool Are the data objects raw data or Python objects that need t...
python
{ "resource": "" }
q280625
display_json
test
def display_json(*objs, **kwargs): """Display the JSON representation of an object. Note that not many frontends support displaying JSON. Parameters ---------- objs : tuple of objects The Python objects to display, or if raw=True raw json data to display. raw : bool Are...
python
{ "resource": "" }
q280626
display_javascript
test
def display_javascript(*objs, **kwargs): """Display the Javascript representation of an object. Parameters ---------- objs : tuple of objects The Python objects to display, or if raw=True raw javascript data to display. raw : bool Are the data objects raw data or Python obje...
python
{ "resource": "" }
q280627
DisplayObject.reload
test
def reload(self): """Reload the raw data from file or URL.""" if self.filename is not None: with open(self.filename, self._read_flags) as f: self.data = f.read() elif self.url is not None: try: import urllib2 response = urll...
python
{ "resource": "" }
q280628
_find_cmd
test
def _find_cmd(cmd): """Find the full path to a command using which.""" path = sp.Popen(['/usr/bin/env', 'which', cmd], stdout=sp.PIPE, stderr=sp.PIPE).communicate()[0] return py3compat.bytes_to_str(path)
python
{ "resource": "" }
q280629
ProcessHandler.system
test
def system(self, cmd): """Execute a command in a subshell. Parameters ---------- cmd : str A command to be executed in the system shell. Returns ------- int : child's exitstatus """ # Get likely encoding for the output. enc = DE...
python
{ "resource": "" }
q280630
forward_read_events
test
def forward_read_events(fd, context=None): """Forward read events from an FD over a socket. This method wraps a file in a socket pair, so it can be polled for read events by select (specifically zmq.eventloop.ioloop) """ if context is None: context = zmq.Context.instance() push = contex...
python
{ "resource": "" }
q280631
ForwarderThread.run
test
def run(self): """Loop through lines in self.fd, and send them over self.sock.""" line = self.fd.readline() # allow for files opened in unicode mode if isinstance(line, unicode): send = self.sock.send_unicode else: send = self.sock.send while line:...
python
{ "resource": "" }
q280632
find_launcher_class
test
def find_launcher_class(clsname, kind): """Return a launcher for a given clsname and kind. Parameters ========== clsname : str The full name of the launcher class, either with or without the module path, or an abbreviation (MPI, SSH, SGE, PBS, LSF, WindowsHPC). kind : str ...
python
{ "resource": "" }
q280633
IPClusterStop.start
test
def start(self): """Start the app for the stop subcommand.""" try: pid = self.get_pid_from_file() except PIDFileError: self.log.critical( 'Could not read pid file, cluster is probably not running.' ) # Here I exit with a unusual exi...
python
{ "resource": "" }
q280634
IPClusterEngines.build_launcher
test
def build_launcher(self, clsname, kind=None): """import and instantiate a Launcher based on importstring""" try: klass = find_launcher_class(clsname, kind) except (ImportError, KeyError): self.log.fatal("Could not import launcher class: %r"%clsname) self.exit(...
python
{ "resource": "" }
q280635
IPClusterEngines.start
test
def start(self): """Start the app for the engines subcommand.""" self.log.info("IPython cluster: started") # First see if the cluster is already running # Now log and daemonize self.log.info( 'Starting engines with [daemon=%r]' % self.daemonize ) # TO...
python
{ "resource": "" }
q280636
IPClusterStart.start
test
def start(self): """Start the app for the start subcommand.""" # First see if the cluster is already running try: pid = self.get_pid_from_file() except PIDFileError: pass else: if self.check_pid(pid): self.log.critical( ...
python
{ "resource": "" }
q280637
get_app_wx
test
def get_app_wx(*args, **kwargs): """Create a new wx app or return an exiting one.""" import wx app = wx.GetApp() if app is None: if not kwargs.has_key('redirect'): kwargs['redirect'] = False app = wx.PySimpleApp(*args, **kwargs) return app
python
{ "resource": "" }
q280638
is_event_loop_running_wx
test
def is_event_loop_running_wx(app=None): """Is the wx event loop running.""" if app is None: app = get_app_wx() if hasattr(app, '_in_event_loop'): return app._in_event_loop else: return app.IsMainLoopRunning()
python
{ "resource": "" }
q280639
start_event_loop_wx
test
def start_event_loop_wx(app=None): """Start the wx event loop in a consistent manner.""" if app is None: app = get_app_wx() if not is_event_loop_running_wx(app): app._in_event_loop = True app.MainLoop() app._in_event_loop = False else: app._in_event_loop = True
python
{ "resource": "" }
q280640
get_app_qt4
test
def get_app_qt4(*args, **kwargs): """Create a new qt4 app or return an existing one.""" from IPython.external.qt_for_kernel import QtGui app = QtGui.QApplication.instance() if app is None: if not args: args = ([''],) app = QtGui.QApplication(*args, **kwargs) return app
python
{ "resource": "" }
q280641
is_event_loop_running_qt4
test
def is_event_loop_running_qt4(app=None): """Is the qt4 event loop running.""" if app is None: app = get_app_qt4(['']) if hasattr(app, '_in_event_loop'): return app._in_event_loop else: # Does qt4 provide a other way to detect this? return False
python
{ "resource": "" }
q280642
start_event_loop_qt4
test
def start_event_loop_qt4(app=None): """Start the qt4 event loop in a consistent manner.""" if app is None: app = get_app_qt4(['']) if not is_event_loop_running_qt4(app): app._in_event_loop = True app.exec_() app._in_event_loop = False else: app._in_event_loop = Tr...
python
{ "resource": "" }
q280643
Canvas.blank_canvas
test
def blank_canvas(width, height): """Return a blank canvas to annotate. :param width: xdim (int) :param height: ydim (int) :returns: :class:`jicbioimage.illustrate.Canvas` """ canvas = np.zeros((height, width, 3), dtype=np.uint8) return canvas.view(Canvas)
python
{ "resource": "" }
q280644
Canvas.draw_cross
test
def draw_cross(self, position, color=(255, 0, 0), radius=4): """Draw a cross on the canvas. :param position: (row, col) tuple :param color: RGB tuple :param radius: radius of the cross (int) """ y, x = position for xmod in np.arange(-radius, radius+1, 1): ...
python
{ "resource": "" }
q280645
Canvas.draw_line
test
def draw_line(self, pos1, pos2, color=(255, 0, 0)): """Draw a line between pos1 and pos2 on the canvas. :param pos1: position 1 (row, col) tuple :param pos2: position 2 (row, col) tuple :param color: RGB tuple """ r1, c1 = tuple([int(round(i, 0)) for i in pos1]) ...
python
{ "resource": "" }
q280646
Canvas.text_at
test
def text_at(self, text, position, color=(255, 255, 255), size=12, antialias=False, center=False): """Write text at x, y top left corner position. By default the x and y coordinates represent the top left hand corner of the text. The text can be centered vertically and horizontal...
python
{ "resource": "" }
q280647
AnnotatedImage.from_grayscale
test
def from_grayscale(im, channels_on=(True, True, True)): """Return a canvas from a grayscale image. :param im: single channel image :channels_on: channels to populate with input image :returns: :class:`jicbioimage.illustrate.Canvas` """ xdim, ydim = im.shape canva...
python
{ "resource": "" }
q280648
get_uuid
test
def get_uuid(length=32, version=1): """ Returns a unique ID of a given length. User `version=2` for cross-systems uniqueness. """ if version == 1: return uuid.uuid1().hex[:length] else: return uuid.uuid4().hex[:length]
python
{ "resource": "" }
q280649
get_unique_key_from_get
test
def get_unique_key_from_get(get_dict): """ Build a unique key from get data """ site = Site.objects.get_current() key = get_dict_to_encoded_url(get_dict) cache_key = '{}_{}'.format(site.domain, key) return hashlib.md5(cache_key).hexdigest()
python
{ "resource": "" }
q280650
get_domain
test
def get_domain(url): """ Returns domain name portion of a URL """ if 'http' not in url.lower(): url = 'http://{}'.format(url) return urllib.parse.urlparse(url).hostname
python
{ "resource": "" }
q280651
get_url_args
test
def get_url_args(url): """ Returns a dictionary from a URL params """ url_data = urllib.parse.urlparse(url) arg_dict = urllib.parse.parse_qs(url_data.query) return arg_dict
python
{ "resource": "" }