sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
def sort_players(self, sort_key=None, sort_func=None, reverse=False): """ Return all home and away by player info sorted by either the provided key or function. Must provide at least one of the two parameters. Can sort either ascending or descending. :param sort_key: (def None) ...
Return all home and away by player info sorted by either the provided key or function. Must provide at least one of the two parameters. Can sort either ascending or descending. :param sort_key: (def None) dict key to sort on :param sort_func: (def None) sorting function :param r...
entailment
def top_by_key(self, sort_key): """ Return home/away by player info for the players on each team that are first in the provided category. :param sort_key: str, the dictionary key to be sorted on :returns: dict of the form ``{ 'home/away': { by_player_dict } }``. See :py:func:`ho...
Return home/away by player info for the players on each team that are first in the provided category. :param sort_key: str, the dictionary key to be sorted on :returns: dict of the form ``{ 'home/away': { by_player_dict } }``. See :py:func:`home_players` and :py:func:`away_players`
entailment
def top_by_func(self, sort_func): """ Return home/away by player info for the players on each team who come in first according to the provided sorting function. Will perform ascending sort. :param sort_func: function that yields the sorting quantity :returns: dict of the...
Return home/away by player info for the players on each team who come in first according to the provided sorting function. Will perform ascending sort. :param sort_func: function that yields the sorting quantity :returns: dict of the form ``{ 'home/away': { by_player_dict } }``. See :py...
entailment
def encode(obj): """ Encode one argument/object to json """ if hasattr(obj, 'json'): return obj.json if hasattr(obj, '__json__'): return obj.__json__() return dumps(obj)
Encode one argument/object to json
entailment
def encode_args(args, extra=False): """ Encode a list of arguments """ if not args: return '' methodargs = ', '.join([encode(a) for a in args]) if extra: methodargs += ', ' return methodargs
Encode a list of arguments
entailment
def _send(self, javascript): """ Establishes a socket connection to the zombie.js server and sends Javascript instructions. :param js: the Javascript string to execute """ # Prepend JS to switch to the proper client context. message = """ var _ctx = ...
Establishes a socket connection to the zombie.js server and sends Javascript instructions. :param js: the Javascript string to execute
entailment
def wait(self, method, *args): """ Call a method on the zombie.js Browser instance and wait on a callback. :param method: the method to call, e.g., html() :param args: one of more arguments for the method """ methodargs = encode_args(args, extra=True) js = """ ...
Call a method on the zombie.js Browser instance and wait on a callback. :param method: the method to call, e.g., html() :param args: one of more arguments for the method
entailment
def create_element(self, method, args=None): """ Evaluate a browser method and CSS selector against the document (or an optional context DOMNode) and return a single :class:`zombie.dom.DOMNode` object, e.g., browser._node('query', 'body > div') ...roughly translates to ...
Evaluate a browser method and CSS selector against the document (or an optional context DOMNode) and return a single :class:`zombie.dom.DOMNode` object, e.g., browser._node('query', 'body > div') ...roughly translates to the following Javascript... browser.query('body > div') ...
entailment
def create_elements(self, method, args=[]): """ Execute a browser method that will return a list of elements. Returns a list of the element indexes """ args = encode_args(args) js = """ create_elements(ELEMENTS, %(method)s(%(args)s)) """ % { ...
Execute a browser method that will return a list of elements. Returns a list of the element indexes
entailment
def fill(self, field, value): """ Fill a specified form field in the current document. :param field: an instance of :class:`zombie.dom.DOMNode` :param value: any string value :return: self to allow function chaining. """ self.client.nowait('browser.fill', (field,...
Fill a specified form field in the current document. :param field: an instance of :class:`zombie.dom.DOMNode` :param value: any string value :return: self to allow function chaining.
entailment
def query(self, selector, context=None): """ Evaluate a CSS selector against the document (or an optional context :class:`zombie.dom.DOMNode`) and return a single :class:`zombie.dom.DOMNode` object. :param selector: a string CSS selector (http://zombie.la...
Evaluate a CSS selector against the document (or an optional context :class:`zombie.dom.DOMNode`) and return a single :class:`zombie.dom.DOMNode` object. :param selector: a string CSS selector (http://zombie.labnotes.org/selectors) :param context: an (optional) i...
entailment
def queryAll(self, selector, context=None): """ Evaluate a CSS selector against the document (or an optional context :class:`zombie.dom.DOMNode`) and return a list of :class:`zombie.dom.DOMNode` objects. :param selector: a string CSS selector (http://zomb...
Evaluate a CSS selector against the document (or an optional context :class:`zombie.dom.DOMNode`) and return a list of :class:`zombie.dom.DOMNode` objects. :param selector: a string CSS selector (http://zombie.labnotes.org/selectors) :param context: an (optional)...
entailment
def link(self, selector): """ Finds and returns a link ``<a>`` element (:class:`zombie.dom.DOMNode`). You can use a CSS selector or find a link by its text contents (case sensitive, but ignores leading/trailing spaces). :param selector: an optional string CSS selector ...
Finds and returns a link ``<a>`` element (:class:`zombie.dom.DOMNode`). You can use a CSS selector or find a link by its text contents (case sensitive, but ignores leading/trailing spaces). :param selector: an optional string CSS selector (http://zombie.labnotes.org/sele...
entailment
def value(self, value): """ Used to set the ``value`` of form elements. """ self.client.nowait( 'set_field', (Literal('browser'), self.element, value))
Used to set the ``value`` of form elements.
entailment
def fire(self, event): """ Fires a specified DOM event on the current node. :param event: the name of the event to fire (e.g., 'click'). Returns the :class:`zombie.dom.DOMNode` to allow function chaining. """ self.browser.fire(self.element, event) return self
Fires a specified DOM event on the current node. :param event: the name of the event to fire (e.g., 'click'). Returns the :class:`zombie.dom.DOMNode` to allow function chaining.
entailment
def load_all(self): """ Force all reports to be loaded and parsed instead of lazy loading on demand. :returns: ``self`` or ``None`` if load fails """ try: self.toi.load_all() self.rosters.load_all() #self.summary.load_all() ...
Force all reports to be loaded and parsed instead of lazy loading on demand. :returns: ``self`` or ``None`` if load fails
entailment
def matchup(self): """ Return the game meta information displayed in report banners including team names, final score, game date, location, and attendance. Data format is .. code:: python { 'home': home, 'away': away, ...
Return the game meta information displayed in report banners including team names, final score, game date, location, and attendance. Data format is .. code:: python { 'home': home, 'away': away, 'final': final, ...
entailment
def _utf8_encode(self, d): """ Ensures all values are encoded in UTF-8 and converts them to lowercase """ for k, v in d.items(): if isinstance(v, str): d[k] = v.encode('utf8').lower() if isinstance(v, list): for index,item ...
Ensures all values are encoded in UTF-8 and converts them to lowercase
entailment
def _bool_encode(self, d): """ Converts bool values to lowercase strings """ for k, v in d.items(): if isinstance(v, bool): d[k] = str(v).lower() return d
Converts bool values to lowercase strings
entailment
def _options(self, **kwargs): """ Formats search parameters/values for use with API :param \*\*kwargs: search parameters/values """ def _format_fq(d): for k,v in d.items(): if isinstance(v, list): d[k] = ' '.join(m...
Formats search parameters/values for use with API :param \*\*kwargs: search parameters/values
entailment
def search(self, response_format = None, key = None, **kwargs): """ Calls the API and returns a dictionary of the search results :param response_format: the format that the API uses for its response, inc...
Calls the API and returns a dictionary of the search results :param response_format: the format that the API uses for its response, includes JSON (.json) and JSONP (.jsonp). Defaults to '.json'. :...
entailment
def parse(self): """Fully parses game summary report. :returns: boolean success indicator :rtype: bool """ r = super(GameSummRep, self).parse() try: self.parse_scoring_summary() return r and False except: return False
Fully parses game summary report. :returns: boolean success indicator :rtype: bool
entailment
def Create(event_type): """ Factory method creates objects derived from :py:class`.Event` with class name matching the :py:class`.EventType`. :param event_type: number for type of event :returns: constructed event corresponding to ``event_type`` :rtype: :py:class:`.Event...
Factory method creates objects derived from :py:class`.Event` with class name matching the :py:class`.EventType`. :param event_type: number for type of event :returns: constructed event corresponding to ``event_type`` :rtype: :py:class:`.Event`
entailment
def home_shift_summ(self): """ :returns: :py:class:`.ShiftSummary` by player for the home team :rtype: dict ``{ player_num: shift_summary_obj }`` """ if not self.__wrapped_home: self.__wrapped_home = self.__wrap(self._home.by_player) return self.__wra...
:returns: :py:class:`.ShiftSummary` by player for the home team :rtype: dict ``{ player_num: shift_summary_obj }``
entailment
def away_shift_summ(self): """ :returns: :py:class:`.ShiftSummary` by player for the away team :rtype: dict ``{ player_num: shift_summary_obj }`` """ if not self.__wrapped_away: self.__wrapped_away = self.__wrap(self._away.by_player) return self.__wra...
:returns: :py:class:`.ShiftSummary` by player for the away team :rtype: dict ``{ player_num: shift_summary_obj }``
entailment
def parse(self): """ Retreive and parse Play by Play data for the given :py:class:`nhlscrapi.games.game.GameKey`` :returns: ``self`` on success, ``None`` otherwise """ try: return super(RosterRep, self).parse() \ .parse_rosters() \ .p...
Retreive and parse Play by Play data for the given :py:class:`nhlscrapi.games.game.GameKey`` :returns: ``self`` on success, ``None`` otherwise
entailment
def parse_rosters(self): """ Parse the home and away game rosters :returns: ``self`` on success, ``None`` otherwise """ lx_doc = self.html_doc() if not self.__blocks: self.__pl_blocks(lx_doc) for t in ['home', 'away']: self.rosters[t] = ...
Parse the home and away game rosters :returns: ``self`` on success, ``None`` otherwise
entailment
def parse_scratches(self): """ Parse the home and away healthy scratches :returns: ``self`` on success, ``None`` otherwise """ lx_doc = self.html_doc() if not self.__blocks: self.__pl_blocks(lx_doc) for t in ['aw_scr', 'h_scr']: ix = 'awa...
Parse the home and away healthy scratches :returns: ``self`` on success, ``None`` otherwise
entailment
def parse_coaches(self): """ Parse the home and away coaches :returns: ``self`` on success, ``None`` otherwise """ lx_doc = self.html_doc() tr = lx_doc.xpath('//tr[@id="HeadCoaches"]')[0] for i, td in enumerate(tr): txt = td.xpath('.//text()') ...
Parse the home and away coaches :returns: ``self`` on success, ``None`` otherwise
entailment
def parse_officials(self): """ Parse the officials :returns: ``self`` on success, ``None`` otherwise """ # begin proper body of method lx_doc = self.html_doc() off_parser = opm(self.game_key.season) self.officials = off_parser(lx_doc) return self...
Parse the officials :returns: ``self`` on success, ``None`` otherwise
entailment
def is_email(address, check_dns=False, diagnose=False): """Validate an email address. Keyword arguments: address --- the email address as a string check_dns --- flag for whether to check the DNS status of the domain diagnose --- flag for whether to return True/False or a Diagnosis """ ...
Validate an email address. Keyword arguments: address --- the email address as a string check_dns --- flag for whether to check the DNS status of the domain diagnose --- flag for whether to return True/False or a Diagnosis
entailment
def dispatch_loader(scraper, loader_name): """ Decorator that enforces one time loading for scrapers. The one time loading is applied to partial loaders, e.g. only parse and load the home team roster once. This is not meant to be used directly. :param scraper: property name (string) containing ...
Decorator that enforces one time loading for scrapers. The one time loading is applied to partial loaders, e.g. only parse and load the home team roster once. This is not meant to be used directly. :param scraper: property name (string) containing an object of type :py:class:`scrapr.ReportLoader` :...
entailment
def parse_shifts(self): """ Parse shifts from TOI report :returns: self if successfule else None """ lx_doc = self.html_doc() pl_heads = lx_doc.xpath('//td[contains(@class, "playerHeading")]') for pl in pl_heads: sh_sum = { } ...
Parse shifts from TOI report :returns: self if successfule else None
entailment
def is_valid(self, domain, diagnose=False): """Check whether a domain has a valid MX or A record. Keyword arguments: domain --- the domain to check diagnose --- flag to report a diagnosis or a boolean (default False) """ return_status = [ValidDiagnosis()] dn...
Check whether a domain has a valid MX or A record. Keyword arguments: domain --- the domain to check diagnose --- flag to report a diagnosis or a boolean (default False)
entailment
def html_doc(self): """ :returns: the lxml processed html document :rtype: ``lxml.html.document_fromstring`` output """ if self.__lx_doc is None: cn = NHLCn() if hasattr(cn, self.report_type): html = getattr(cn, self.rep...
:returns: the lxml processed html document :rtype: ``lxml.html.document_fromstring`` output
entailment
def parse_matchup(self): """ Parse the banner matchup meta info for the game. :returns: ``self`` on success or ``None`` """ lx_doc = self.html_doc() try: if not self.matchup: self.matchup = self._fill_meta(lx_doc) return se...
Parse the banner matchup meta info for the game. :returns: ``self`` on success or ``None``
entailment
def parse_plays_stream(self): """Generate and yield a stream of parsed plays. Useful for per play processing.""" lx_doc = self.html_doc() if lx_doc is not None: parser = PlayParser(self.game_key.season, self.game_key.game_type) plays = lx_doc.xpath('//tr[@class =...
Generate and yield a stream of parsed plays. Useful for per play processing.
entailment
def ColMap(season): """ Returns a dictionary mapping the type of information in the RTSS play row to the appropriate column number. The column locations pre/post 2008 are different. :param season: int for the season number :returns: mapping of RTSS column to info type ...
Returns a dictionary mapping the type of information in the RTSS play row to the appropriate column number. The column locations pre/post 2008 are different. :param season: int for the season number :returns: mapping of RTSS column to info type :rtype: dict, keys are ``'play_num...
entailment
def build_play(self, pbp_row): """ Parses table row from RTSS. These are the rows tagged with ``<tr class='evenColor' ... >``. Result set contains :py:class:`nhlscrapi.games.playbyplay.Strength` and :py:class:`nhlscrapi.games.events.EventType` objects. Returned play data is in the form ...
Parses table row from RTSS. These are the rows tagged with ``<tr class='evenColor' ... >``. Result set contains :py:class:`nhlscrapi.games.playbyplay.Strength` and :py:class:`nhlscrapi.games.events.EventType` objects. Returned play data is in the form .. code:: python ...
entailment
def __skaters(self, tab): """ Constructs dictionary of players on the ice in the provided table at time of play. :param tab: RTSS table of the skaters and goalie on at the time of the play :rtype: dictionary, key = player number, value = [position, name] """ res ...
Constructs dictionary of players on the ice in the provided table at time of play. :param tab: RTSS table of the skaters and goalie on at the time of the play :rtype: dictionary, key = player number, value = [position, name]
entailment
def exclude_from(l, containing = [], equal_to = []): """Exclude elements in list l containing any elements from list ex. Example: >>> l = ['bob', 'r', 'rob\r', '\r\nrobert'] >>> containing = ['\n', '\r'] >>> equal_to = ['r'] >>> exclude_from(l, containing, equal_to) ['bob...
Exclude elements in list l containing any elements from list ex. Example: >>> l = ['bob', 'r', 'rob\r', '\r\nrobert'] >>> containing = ['\n', '\r'] >>> equal_to = ['r'] >>> exclude_from(l, containing, equal_to) ['bob']
entailment
def calc_surfdist(surface, labels, annot, reg, origin, target): import nibabel as nib import numpy as np import os from surfdist import load, utils, surfdist import csv """ inputs: surface - surface file (e.g. lh.pial, with full path) labels - label file (e.g. lh.cortex.label, with full path) annot -...
inputs: surface - surface file (e.g. lh.pial, with full path) labels - label file (e.g. lh.cortex.label, with full path) annot - annot file (e.g. lh.aparc.a2009s.annot, with full path) reg - registration file (lh.sphere.reg) origin - the label from which we calculate distances target - target surface (e.g. ...
entailment
def stack_files(files, hemi, source, target): """ This function takes a list of files as input and vstacks them """ import csv import os import numpy as np fname = "sdist_%s_%s_%s.csv" % (hemi, source, target) filename = os.path.join(os.getcwd(),fname) alldist = [] for dfile in files: alldist...
This function takes a list of files as input and vstacks them
entailment
def get_short_url(self, obj): """ Get short URL of blog post like '/blog/<slug>/' using ``get_absolute_url`` if available. Removes dependency on reverse URLs of Mezzanine views when deploying Mezzanine only as an API backend. """ try: url = obj.get_absolute_url() ...
Get short URL of blog post like '/blog/<slug>/' using ``get_absolute_url`` if available. Removes dependency on reverse URLs of Mezzanine views when deploying Mezzanine only as an API backend.
entailment
def head_to_head(self, home_num, away_num): """ Return the head-to-head face-off outcomes between two players. If the matchup didn't happen, ``{ }`` is returned. :param home_num: the number of the home team player :param away_num: the number of the away team player ...
Return the head-to-head face-off outcomes between two players. If the matchup didn't happen, ``{ }`` is returned. :param home_num: the number of the home team player :param away_num: the number of the away team player :returns: dict, either ``{ }`` or the following ...
entailment
def team_totals(self): """ Returns the overall faceoff win/total breakdown for home and away as :returns: dict, ``{ 'home/away': { 'won': won, 'total': total } }`` """ if self.__team_tots is None: self.__team_tots = self.__comp_tot() return {...
Returns the overall faceoff win/total breakdown for home and away as :returns: dict, ``{ 'home/away': { 'won': won, 'total': total } }``
entailment
def by_zone(self): """ Returns the faceoff win/total breakdown by zone for home and away as .. code:: python { 'home/away': { 'off/def/neut/all': { 'won': won, 'total': total } } } :returns: dict ...
Returns the faceoff win/total breakdown by zone for home and away as .. code:: python { 'home/away': { 'off/def/neut/all': { 'won': won, 'total': total } } } :returns: dict
entailment
def fo_pct(self): """ Get the by team overall face-off win %. :returns: dict, ``{ 'home': %, 'away': % }`` """ tots = self.team_totals return { t: tots[t]['won']/(1.0*tots[t]['total']) if tots[t]['total'] else 0.0 for t in [ 'home', 'away'...
Get the by team overall face-off win %. :returns: dict, ``{ 'home': %, 'away': % }``
entailment
def fo_pct_by_zone(self): """ Get the by team face-off win % by zone. Format is :returns: dict ``{ 'home/away': { 'off/def/neut': % } }`` """ bz = self.by_zone return { t: { z: bz[t][z]['won']/(1.0*bz[t][z]['total']) if bz[t][z]['t...
Get the by team face-off win % by zone. Format is :returns: dict ``{ 'home/away': { 'off/def/neut': % } }``
entailment
def update(self, play): """ Update the accumulator with the current play :returns: new tally :rtype: dict, ``{ 'period': per, 'time': clock, 'team': cumul, 'play': play }`` """ new_tally = { } #if any(isinstance(play.event, te) for te in self.trigger_even...
Update the accumulator with the current play :returns: new tally :rtype: dict, ``{ 'period': per, 'time': clock, 'team': cumul, 'play': play }``
entailment
def share(self): """ The Cori-share (% of shot attempts) for each team :returns: dict, ``{ 'home_name': %, 'away_name': % }`` """ tot = sum(self.total.values()) return { k: v/float(tot) for k,v in self.total.items() }
The Cori-share (% of shot attempts) for each team :returns: dict, ``{ 'home_name': %, 'away_name': % }``
entailment
def compute_stats(self): """ Compute the stats defined in ``self.cum_stats``. :returns: collection of all computed :py:class:`.AccumulateStats` :rtype: dict """ if not self.__have_stats: if self.init_cs_teams and self.cum_stats: self._...
Compute the stats defined in ``self.cum_stats``. :returns: collection of all computed :py:class:`.AccumulateStats` :rtype: dict
entailment
def __html_rep(self, game_key, rep_code): """Retrieves the nhl html reports for the specified game and report code""" seas, gt, num = game_key.to_tuple() url = [ self.__domain, "scores/htmlreports/", str(seas-1), str(seas), "/", rep_code, "0", str(gt), ("%04i" % (num)), ".HTM" ] ...
Retrieves the nhl html reports for the specified game and report code
entailment
def to_char(token): """Transforms the ASCII control character symbols to their real char. Note: If the token is not an ASCII control character symbol, just return the token. Keyword arguments: token -- the token to transform """ if ord(token) in _range(9216, 9229 + 1): token = _un...
Transforms the ASCII control character symbols to their real char. Note: If the token is not an ASCII control character symbol, just return the token. Keyword arguments: token -- the token to transform
entailment
def is_email(self, address, diagnose=False): """Check that an address address conforms to RFCs 5321, 5322 and others. More specifically, see the follow RFCs: * http://tools.ietf.org/html/rfc5321 * http://tools.ietf.org/html/rfc5322 * http://tools.ietf.org/html/rfc429...
Check that an address address conforms to RFCs 5321, 5322 and others. More specifically, see the follow RFCs: * http://tools.ietf.org/html/rfc5321 * http://tools.ietf.org/html/rfc5322 * http://tools.ietf.org/html/rfc4291#section-2.2 * http://tools.ietf.org/html/r...
entailment
def load_freesurfer_label(annot_input, label_name, cortex=None): """ Get source node list for a specified freesurfer label. Inputs ------- annot_input : freesurfer annotation label file label_name : freesurfer label name cortex : not used """ if cortex is not None: print("W...
Get source node list for a specified freesurfer label. Inputs ------- annot_input : freesurfer annotation label file label_name : freesurfer label name cortex : not used
entailment
def get_freesurfer_label(annot_input, verbose = True): """ Print freesurfer label names. """ labels, color_table, names = nib.freesurfer.read_annot(annot_input) if verbose: print(names) return names
Print freesurfer label names.
entailment
def viz(coords, faces, stat_map=None, elev=0, azim=0, cmap='coolwarm', threshold=None, alpha='auto', bg_map=None, bg_on_stat=False, figsize=None, **kwargs): ''' Visualize results on cortical surface using matplotlib. Inputs ------- coords : numpy array of shape ...
Visualize results on cortical surface using matplotlib. Inputs ------- coords : numpy array of shape (n_nodes,3), each row specifying the x,y,z coordinates of one node of surface mesh faces : numpy array of shape (n_faces, 3), each row specifying the indices of the three nodes b...
entailment
def surf_keep_cortex(surf, cortex): """ Remove medial wall from cortical surface to ensure that shortest paths are only calculated through the cortex. Inputs ------- surf : Tuple containing two numpy arrays of shape (n_nodes,3). Each node of the first array specifies the x, y, z coordina...
Remove medial wall from cortical surface to ensure that shortest paths are only calculated through the cortex. Inputs ------- surf : Tuple containing two numpy arrays of shape (n_nodes,3). Each node of the first array specifies the x, y, z coordinates one node of the surface mesh. Each node of t...
entailment
def triangles_keep_cortex(triangles, cortex): """ Remove triangles with nodes not contained in the cortex label array """ # for or each face/triangle keep only those that only contain nodes within the list of cortex nodes input_shape = triangles.shape triangle_is_in_cortex = np.all(np.reshape(n...
Remove triangles with nodes not contained in the cortex label array
entailment
def translate_src(src, cortex): """ Convert source nodes to new surface (without medial wall). """ src_new = np.array(np.where(np.in1d(cortex, src))[0], dtype=np.int32) return src_new
Convert source nodes to new surface (without medial wall).
entailment
def recort(input_data, surf, cortex): """ Return data values to space of full cortex (including medial wall), with medial wall equal to zero. """ data = np.zeros(len(surf[0])) data[cortex] = input_data return data
Return data values to space of full cortex (including medial wall), with medial wall equal to zero.
entailment
def find_node_match(simple_vertices, complex_vertices): """ Thanks to juhuntenburg. Functions taken from https://github.com/juhuntenburg/brainsurfacescripts Finds those points on the complex mesh that correspond best to the simple mesh while forcing a one-to-one mapping. """ import scipy.s...
Thanks to juhuntenburg. Functions taken from https://github.com/juhuntenburg/brainsurfacescripts Finds those points on the complex mesh that correspond best to the simple mesh while forcing a one-to-one mapping.
entailment
def parse(self): """ Retreive and parse Event Summary report for the given :py:class:`nhlscrapi.games.game.GameKey` :returns: ``self`` on success, ``None`` otherwise """ try: return super(EventSummRep, self).parse() \ .parse_away_shots() \ ...
Retreive and parse Event Summary report for the given :py:class:`nhlscrapi.games.game.GameKey` :returns: ``self`` on success, ``None`` otherwise
entailment
def parse_home_shots(self): """ Parse shot info for home team. :returns: ``self`` on success, ``None`` otherwise """ try: self.__set_shot_tables() self.shots['home'] = self.__parse_shot_tables( self.__home_top, self...
Parse shot info for home team. :returns: ``self`` on success, ``None`` otherwise
entailment
def parse_away_shots(self): """ Parse shot info for away team. :returns: ``self`` on success, ``None`` otherwise """ try: self.__set_shot_tables() self.shots['away'] = self.__parse_shot_tables( self.__aw_top, self._...
Parse shot info for away team. :returns: ``self`` on success, ``None`` otherwise
entailment
def parse_home_fo(self): """ Parse face-off info for home team. :returns: ``self`` on success, ``None`` otherwise """ try: self.__set_fo_tables() self.face_offs['home'] = self.__parse_fo_table(self.__home_fo) return self except...
Parse face-off info for home team. :returns: ``self`` on success, ``None`` otherwise
entailment
def parse_away_fo(self): """ Parse face-off info for away team. :returns: ``self`` on success, ``None`` otherwise """ try: self.__set_fo_tables() self.face_offs['away'] = self.__parse_fo_table(self.__away_fo) return self except...
Parse face-off info for away team. :returns: ``self`` on success, ``None`` otherwise
entailment
def dist_calc(surf, cortex, source_nodes): """ Calculate exact geodesic distance along cortical surface from set of source nodes. "dist_type" specifies whether to calculate "min", "mean", "median", or "max" distance values from a region-of-interest. If running only on single node, defaults to "min". ...
Calculate exact geodesic distance along cortical surface from set of source nodes. "dist_type" specifies whether to calculate "min", "mean", "median", or "max" distance values from a region-of-interest. If running only on single node, defaults to "min".
entailment
def zone_calc(surf, cortex, src): """ Calculate closest nodes to each source node using exact geodesic distance along the cortical surface. """ cortex_vertices, cortex_triangles = surf_keep_cortex(surf, cortex) dist_vals = np.zeros((len(source_nodes), len(cortex_vertices))) for x in range(len...
Calculate closest nodes to each source node using exact geodesic distance along the cortical surface.
entailment
def dist_calc_matrix(surf, cortex, labels, exceptions = ['Unknown', 'Medial_wall'], verbose = True): """ Calculate exact geodesic distance along cortical surface from set of source nodes. "labels" specifies the freesurfer label file to use. All values will be used other than those specified in "exceptio...
Calculate exact geodesic distance along cortical surface from set of source nodes. "labels" specifies the freesurfer label file to use. All values will be used other than those specified in "exceptions" (default: 'Unknown' and 'Medial_Wall'). returns: dist_mat: symmetrical nxn matrix of minimum dista...
entailment
def parse(self): """ Retreive and parse Play by Play data for the given nhlscrapi.GameKey :returns: ``self`` on success, ``None`` otherwise """ try: return ( super(FaceOffRep, self).parse() and self.parse_home_face_offs() ...
Retreive and parse Play by Play data for the given nhlscrapi.GameKey :returns: ``self`` on success, ``None`` otherwise
entailment
def parse_home_face_offs(self): """ Parse only the home faceoffs :returns: ``self`` on success, ``None`` otherwise """ self.__set_team_docs() self.face_offs['home'] = FaceOffRep.__read_team_doc(self.__home_doc) return self
Parse only the home faceoffs :returns: ``self`` on success, ``None`` otherwise
entailment
def parse_away_face_offs(self): """ Parse only the away faceoffs :returns: ``self`` on success, ``None`` otherwise """ self.__set_team_docs() self.face_offs['away'] = FaceOffRep.__read_team_doc(self.__vis_doc) return self
Parse only the away faceoffs :returns: ``self`` on success, ``None`` otherwise
entailment
def load_module(filename): """ Loads a module by filename """ basename = os.path.basename(filename) path = os.path.dirname(filename) sys.path.append(path) # TODO(tlan) need to figure out how to handle errors thrown here return __import__(os.path.splitext(basename)[0])
Loads a module by filename
entailment
def make_machine_mapping(machine_list): """ Convert the machine list argument from a list of names into a mapping of logical names to physical hosts. This is similar to the _parse_configs function but separated to provide the opportunity for extension and additional checking of machine access """ if machine...
Convert the machine list argument from a list of names into a mapping of logical names to physical hosts. This is similar to the _parse_configs function but separated to provide the opportunity for extension and additional checking of machine access
entailment
def parse_config_list(config_list): """ Parse a list of configuration properties separated by '=' """ if config_list is None: return {} else: mapping = {} for pair in config_list: if (constants.CONFIG_SEPARATOR not in pair) or (pair.count(constants.CONFIG_SEPARATOR) != 1): raise Valu...
Parse a list of configuration properties separated by '='
entailment
def parse_config_file(config_file_path): """ Parse a configuration file. Currently only supports .json, .py and properties separated by '=' :param config_file_path: :return: a dict of the configuration properties """ extension = os.path.splitext(config_file_path)[1] if extension == '.pyc': raise Value...
Parse a configuration file. Currently only supports .json, .py and properties separated by '=' :param config_file_path: :return: a dict of the configuration properties
entailment
def exec_with_env(ssh, command, msg='', env={}, **kwargs): """ :param ssh: :param command: :param msg: :param env: :param synch: :return: """ bash_profile_command = "source .bash_profile > /dev/null 2> /dev/null;" env_command = build_os_environment_string(env) new_command = bash_profi...
:param ssh: :param command: :param msg: :param env: :param synch: :return:
entailment
def better_exec_command(ssh, command, msg): """Uses paramiko to execute a command but handles failure by raising a ParamikoError if the command fails. Note that unlike paramiko.SSHClient.exec_command this is not asynchronous because we wait until the exit status is known :Parameter ssh: a paramiko SSH Client...
Uses paramiko to execute a command but handles failure by raising a ParamikoError if the command fails. Note that unlike paramiko.SSHClient.exec_command this is not asynchronous because we wait until the exit status is known :Parameter ssh: a paramiko SSH Client :Parameter command: the command to execute ...
entailment
def log_output(chan): """ logs the output from a remote command the input should be an open channel in the case of synchronous better_exec_command otherwise this will not log anything and simply return to the caller :param chan: :return: """ if hasattr(chan, "recv"): str = chan.recv(1024) ...
logs the output from a remote command the input should be an open channel in the case of synchronous better_exec_command otherwise this will not log anything and simply return to the caller :param chan: :return:
entailment
def copy_dir(ftp, filename, outputdir, prefix, pattern=''): """ Recursively copy a directory flattens the output into a single directory but prefixes the files with the path from the original input directory :param ftp: :param filename: :param outputdir: :param prefix: :param pattern: a regex pa...
Recursively copy a directory flattens the output into a single directory but prefixes the files with the path from the original input directory :param ftp: :param filename: :param outputdir: :param prefix: :param pattern: a regex pattern for files to match (by default matches everything) :return:
entailment
def open_remote_file(hostname, filename, mode='r', bufsize=-1, username=None, password=None): """ :param hostname: :param filename: :return: """ with get_ssh_client(hostname, username=username, password=password) as ssh: sftp = None f = None try: sftp = ssh.open_sftp() f...
:param hostname: :param filename: :return:
entailment
def deploy(self, unique_id, configs=None): """Deploys the service to the host. This should at least perform the same actions as install and start but may perform additional tasks as needed. :Parameter unique_id: the name of the process :Parameter configs: a mao of configs the deployer may use to modif...
Deploys the service to the host. This should at least perform the same actions as install and start but may perform additional tasks as needed. :Parameter unique_id: the name of the process :Parameter configs: a mao of configs the deployer may use to modify the deployment
entailment
def undeploy(self, unique_id, configs=None): """Undeploys the service. This should at least perform the same actions as stop and uninstall but may perform additional tasks as needed. :Parameter unique_id: the name of the process :Parameter configs: a map of configs the deployer may use """ sel...
Undeploys the service. This should at least perform the same actions as stop and uninstall but may perform additional tasks as needed. :Parameter unique_id: the name of the process :Parameter configs: a map of configs the deployer may use
entailment
def soft_bounce(self, unique_id, configs=None): """ Performs a soft bounce (stop and start) for the specified process :Parameter unique_id: the name of the process """ self.stop(unique_id, configs) self.start(unique_id, configs)
Performs a soft bounce (stop and start) for the specified process :Parameter unique_id: the name of the process
entailment
def hard_bounce(self, unique_id, configs=None): """ Performs a hard bounce (kill and start) for the specified process :Parameter unique_id: the name of the process """ self.kill(unique_id, configs) self.start(unique_id, configs)
Performs a hard bounce (kill and start) for the specified process :Parameter unique_id: the name of the process
entailment
def sleep(self, unique_id, delay, configs=None): """ Pauses the process for the specified delay and then resumes it :Parameter unique_id: the name of the process :Parameter delay: delay time in seconds """ self.pause(unique_id, configs) time.sleep(delay) self.resume(unique_id, configs)
Pauses the process for the specified delay and then resumes it :Parameter unique_id: the name of the process :Parameter delay: delay time in seconds
entailment
def pause(self, unique_id, configs=None): """ Issues a sigstop for the specified process :Parameter unique_id: the name of the process """ pids = self.get_pid(unique_id, configs) if pids != constants.PROCESS_NOT_RUNNING_PID: pid_str = ' '.join(str(pid) for pid in pids) hostname = self.p...
Issues a sigstop for the specified process :Parameter unique_id: the name of the process
entailment
def _send_signal(self, unique_id, signalno, configs): """ Issues a signal for the specified process :Parameter unique_id: the name of the process """ pids = self.get_pid(unique_id, configs) if pids != constants.PROCESS_NOT_RUNNING_PID: pid_str = ' '.join(str(pid) for pid in pids) hostna...
Issues a signal for the specified process :Parameter unique_id: the name of the process
entailment
def resume(self, unique_id, configs=None): """ Issues a sigcont for the specified process :Parameter unique_id: the name of the process """ self._send_signal(unique_id, signal.SIGCONT,configs)
Issues a sigcont for the specified process :Parameter unique_id: the name of the process
entailment
def kill(self, unique_id, configs=None): """ Issues a kill -9 to the specified process calls the deployers get_pid function for the process. If no pid_file/pid_keyword is specified a generic grep of ps aux command is executed on remote machine based on process parameters which may not be reliable if mor...
Issues a kill -9 to the specified process calls the deployers get_pid function for the process. If no pid_file/pid_keyword is specified a generic grep of ps aux command is executed on remote machine based on process parameters which may not be reliable if more process are running with similar name :Par...
entailment
def terminate(self, unique_id, configs=None): """ Issues a kill -15 to the specified process :Parameter unique_id: the name of the process """ self._send_signal(unique_id, signal.SIGTERM, configs)
Issues a kill -15 to the specified process :Parameter unique_id: the name of the process
entailment
def hangup(self, unique_id, configs=None): """ Issue a signal to hangup the specified process :Parameter unique_id: the name of the process """ self._send_signal(unique_id, signal.SIGHUP, configs)
Issue a signal to hangup the specified process :Parameter unique_id: the name of the process
entailment
def get_logs(self, unique_id, logs, directory, pattern=constants.FILTER_NAME_ALLOW_NONE): """deprecated name for fetch_logs""" self.fetch_logs(unique_id, logs, directory, pattern)
deprecated name for fetch_logs
entailment
def fetch_logs(self, unique_id, logs, directory, pattern=constants.FILTER_NAME_ALLOW_NONE): """ Copies logs from the remote host that the process is running on to the provided directory :Parameter unique_id the unique_id of the process in question :Parameter logs a list of logs given by absolute path from ...
Copies logs from the remote host that the process is running on to the provided directory :Parameter unique_id the unique_id of the process in question :Parameter logs a list of logs given by absolute path from the remote host :Parameter directory the local directory to store the copied logs :Parameter...
entailment
def fetch_logs_from_host(hostname, install_path, prefix, logs, directory, pattern): """ Static method Copies logs from specified host on the specified install path :Parameter hostname the remote host from where we need to fetch the logs :Parameter install_path path where the app is installed :Parameter...
Static method Copies logs from specified host on the specified install path :Parameter hostname the remote host from where we need to fetch the logs :Parameter install_path path where the app is installed :Parameter prefix prefix used to copy logs. Generall the unique_id of process :Parameter logs a li...
entailment
def generate(self): """ Generates the report """ self._setup() for config_name in self.report_info.config_to_test_names_map.keys(): config_dir = os.path.join(self.report_info.resource_dir, config_name) utils.makedirs(config_dir) testsuite = self._generate_junit_xml(config_name) ...
Generates the report
entailment
def install(self, unique_id, configs=None): """ Copies the executable to the remote machine under install path. Inspects the configs for the possible keys 'hostname': the host to install on 'install_path': the location on the remote host 'executable': the executable to copy 'no_copy': if this co...
Copies the executable to the remote machine under install path. Inspects the configs for the possible keys 'hostname': the host to install on 'install_path': the location on the remote host 'executable': the executable to copy 'no_copy': if this config is passed in and true then this method will not cop...
entailment
def start(self, unique_id, configs=None): """ Start the service. If `unique_id` has already been installed the deployer will start the service on that host. Otherwise this will call install with the configs. Within the context of this function, only four configs are considered 'start_command': the ...
Start the service. If `unique_id` has already been installed the deployer will start the service on that host. Otherwise this will call install with the configs. Within the context of this function, only four configs are considered 'start_command': the command to run (if provided will replace the default) ...
entailment