idx int64 0 252k | question stringlengths 48 5.28k | target stringlengths 5 1.23k |
|---|---|---|
238,600 | def applicable_file_flags ( self ) : if not self . _ptr : raise BfdException ( "BFD not initialized" ) return _bfd . get_bfd_attribute ( self . _ptr , BfdAttributes . APPLICABLE_FILE_FLAGS ) | Return the applicable file flags attribute of the BFD file being processed . |
238,601 | def my_archieve ( self ) : if not self . _ptr : raise BfdException ( "BFD not initialized" ) return _bfd . get_bfd_attribute ( self . _ptr , BfdAttributes . MY_ARCHIEVE ) | Return the my archieve attribute of the BFD file being processed . |
238,602 | def has_map ( self ) : if not self . _ptr : raise BfdException ( "BFD not initialized" ) return _bfd . get_bfd_attribute ( self . _ptr , BfdAttributes . HAS_MAP ) | Return the has map attribute of the BFD file being processed . |
238,603 | def is_thin_archieve ( self ) : if not self . _ptr : raise BfdException ( "BFD not initialized" ) return _bfd . get_bfd_attribute ( self . _ptr , BfdAttributes . IS_THIN_ARCHIEVE ) | Return the is thin archieve attribute of the BFD file being processed . |
238,604 | def has_gap_in_elf_shndx ( self ) : if not self . _ptr : raise BfdException ( "BFD not initialized" ) return _bfd . get_bfd_attribute ( self . _ptr , BfdAttributes . HAS_GAP_IN_ELF_SHNDX ) | Return the has gap in elf shndx attribute of the BFD file being processed . |
238,605 | def valid_reloction_types ( self ) : if not self . _ptr : raise BfdException ( "BFD not initialized" ) return _bfd . get_bfd_attribute ( self . _ptr , BfdAttributes . VALID_RELOC_TYPES ) | Return the valid_reloc_types attribute of the BFD file being processed . |
238,606 | def user_data ( self ) : if not self . _ptr : raise BfdException ( "BFD not initialized" ) return _bfd . get_bfd_attribute ( self . _ptr , BfdAttributes . USRDATA ) | Return the usrdata attribute of the BFD file being processed . |
238,607 | def start_address ( self ) : if not self . _ptr : raise BfdException ( "BFD not initialized" ) return _bfd . get_bfd_attribute ( self . _ptr , BfdAttributes . START_ADDRESS ) | Return the start address attribute of the BFD file being processed . |
238,608 | def symbols_count ( self ) : if not self . _ptr : raise BfdException ( "BFD not initialized" ) return _bfd . get_bfd_attribute ( self . _ptr , BfdAttributes . SYMCOUNT ) | Return the symcount attribute of the BFD file being processed . |
238,609 | def out_symbols ( self ) : if not self . _ptr : raise BfdException ( "BFD not initialized" ) return _bfd . get_bfd_attribute ( self . _ptr , BfdAttributes . OUTSYMBOLS ) | Return the out symbols attribute of the BFD file being processed . |
238,610 | def sections_count ( self ) : if not self . _ptr : raise BfdException ( "BFD not initialized" ) return _bfd . get_bfd_attribute ( self . _ptr , BfdAttributes . COUNT_SECTIONS ) | Return the sections_count attribute of the BFD file being processed . |
238,611 | def dynamic_symbols_count ( self ) : if not self . _ptr : raise BfdException ( "BFD not initialized" ) return _bfd . get_bfd_attribute ( self . _ptr , BfdAttributes . DYNAMIC_SYMCOUNT ) | Return the dynamic symbols count attribute of the BFD file being processed . |
238,612 | def symbol_leading_char ( self ) : if not self . _ptr : raise BfdException ( "BFD not initialized" ) return _bfd . get_bfd_attribute ( self . _ptr , BfdAttributes . SYMBOL_LEADING_CHAR ) | Return the symbol leading char attribute of the BFD file being processed . |
238,613 | def arch_size ( self ) : if not self . _ptr : raise BfdException ( "BFD not initialized" ) try : return _bfd . get_arch_size ( self . _ptr ) except Exception , err : raise BfdException ( "Unable to determine architeure size." ) | Return the architecure size in bits . |
238,614 | def display_matrix ( self , matrix , interval = 2.0 , brightness = 1.0 , fading = False , ignore_duplicates = False ) : self . _matrix_writer . write ( matrix = matrix , interval = interval , brightness = brightness , fading = fading , ignore_duplicates = ignore_duplicates ) | Displays an LED matrix on Nuimo s LED matrix display . |
238,615 | def get_asn_origin_whois ( self , asn_registry = 'radb' , asn = None , retry_count = 3 , server = None , port = 43 ) : try : if server is None : server = ASN_ORIGIN_WHOIS [ asn_registry ] [ 'server' ] conn = socket . socket ( socket . AF_INET , socket . SOCK_STREAM ) conn . settimeout ( self . timeout ) log . debug ( '... | The function for retrieving CIDR info for an ASN via whois . |
238,616 | def get_http_json ( self , url = None , retry_count = 3 , rate_limit_timeout = 120 , headers = None ) : if headers is None : headers = { 'Accept' : 'application/rdap+json' } try : log . debug ( 'HTTP query for {0} at {1}' . format ( self . address_str , url ) ) conn = Request ( url , headers = headers ) data = self . o... | The function for retrieving a json result via HTTP . |
238,617 | def get_host ( self , retry_count = 3 ) : try : default_timeout_set = False if not socket . getdefaulttimeout ( ) : socket . setdefaulttimeout ( self . timeout ) default_timeout_set = True log . debug ( 'Host query for {0}' . format ( self . address_str ) ) ret = socket . gethostbyaddr ( self . address_str ) if default... | The function for retrieving host information for an IP address . |
238,618 | def get_http_raw ( self , url = None , retry_count = 3 , headers = None , request_type = 'GET' , form_data = None ) : if headers is None : headers = { 'Accept' : 'text/html' } enc_form_data = None if form_data : enc_form_data = urlencode ( form_data ) try : enc_form_data = bytes ( enc_form_data , encoding = 'ascii' ) e... | The function for retrieving a raw HTML result via HTTP . |
238,619 | def generate_output ( line = '0' , short = None , name = None , value = None , is_parent = False , colorize = True ) : output = '{0}{1}{2}{3}{4}{5}{6}{7}\n' . format ( LINES [ '{0}{1}' . format ( line , 'C' if colorize else '' ) ] if ( line in LINES . keys ( ) ) else '' , COLOR_DEPTH [ line ] if ( colorize and line in ... | The function for formatting CLI output results . |
238,620 | def generate_output_header ( self , query_type = 'RDAP' ) : output = '\n{0}{1}{2} query for {3}:{4}\n\n' . format ( ANSI [ 'ul' ] , ANSI [ 'b' ] , query_type , self . obj . address_str , ANSI [ 'end' ] ) return output | The function for generating the CLI output header . |
238,621 | def generate_output_newline ( self , line = '0' , colorize = True ) : return generate_output ( line = line , is_parent = True , colorize = colorize ) | The function for generating a CLI output new line . |
238,622 | def generate_output_asn ( self , json_data = None , hr = True , show_name = False , colorize = True ) : if json_data is None : json_data = { } keys = { 'asn' , 'asn_cidr' , 'asn_country_code' , 'asn_date' , 'asn_registry' , 'asn_description' } . intersection ( json_data ) output = '' for key in keys : output += generat... | The function for generating CLI output ASN results . |
238,623 | def generate_output_entities ( self , json_data = None , hr = True , show_name = False , colorize = True ) : output = '' short = HR_RDAP [ 'entities' ] [ '_short' ] if hr else 'entities' name = HR_RDAP [ 'entities' ] [ '_name' ] if ( hr and show_name ) else None output += generate_output ( line = '0' , short = short , ... | The function for generating CLI output RDAP entity results . |
238,624 | def generate_output_events ( self , source , key , val , line = '2' , hr = True , show_name = False , colorize = True ) : output = generate_output ( line = line , short = HR_RDAP [ source ] [ key ] [ '_short' ] if hr else key , name = HR_RDAP [ source ] [ key ] [ '_name' ] if ( hr and show_name ) else None , is_parent ... | The function for generating CLI output RDAP events results . |
238,625 | def generate_output_list ( self , source , key , val , line = '2' , hr = True , show_name = False , colorize = True ) : output = generate_output ( line = line , short = HR_RDAP [ source ] [ key ] [ '_short' ] if hr else key , name = HR_RDAP [ source ] [ key ] [ '_name' ] if ( hr and show_name ) else None , is_parent = ... | The function for generating CLI output RDAP list results . |
238,626 | def generate_output_notices ( self , source , key , val , line = '1' , hr = True , show_name = False , colorize = True ) : output = generate_output ( line = line , short = HR_RDAP [ source ] [ key ] [ '_short' ] if hr else key , name = HR_RDAP [ source ] [ key ] [ '_name' ] if ( hr and show_name ) else None , is_parent... | The function for generating CLI output RDAP notices results . |
238,627 | def generate_output_network ( self , json_data = None , hr = True , show_name = False , colorize = True ) : if json_data is None : json_data = { } output = generate_output ( line = '0' , short = HR_RDAP [ 'network' ] [ '_short' ] if hr else 'network' , name = HR_RDAP [ 'network' ] [ '_name' ] if ( hr and show_name ) el... | The function for generating CLI output RDAP network results . |
238,628 | def generate_output_whois_nets ( self , json_data = None , hr = True , show_name = False , colorize = True ) : if json_data is None : json_data = { } output = generate_output ( line = '0' , short = HR_WHOIS [ 'nets' ] [ '_short' ] if hr else 'nets' , name = HR_WHOIS [ 'nets' ] [ '_name' ] if ( hr and show_name ) else N... | The function for generating CLI output Legacy Whois networks results . |
238,629 | def generate_output_nir ( self , json_data = None , hr = True , show_name = False , colorize = True ) : if json_data is None : json_data = { } output = generate_output ( line = '0' , short = HR_WHOIS_NIR [ 'nets' ] [ '_short' ] if hr else 'nir_nets' , name = HR_WHOIS_NIR [ 'nets' ] [ '_name' ] if ( hr and show_name ) e... | The function for generating CLI output NIR network results . |
238,630 | def parse_fields_whois ( self , response ) : try : temp = response . split ( '|' ) ret = { 'asn_registry' : temp [ 4 ] . strip ( ' \n' ) } if ret [ 'asn_registry' ] not in self . rir_whois . keys ( ) : raise ASNRegistryError ( 'ASN registry {0} is not known.' . format ( ret [ 'asn_registry' ] ) ) ret [ 'asn' ] = temp [... | The function for parsing ASN fields from a whois response . |
238,631 | def parse_fields_http ( self , response , extra_org_map = None ) : org_map = self . org_map . copy ( ) try : org_map . update ( extra_org_map ) except ( TypeError , ValueError , IndexError , KeyError ) : pass try : asn_data = { 'asn_registry' : None , 'asn' : None , 'asn_cidr' : None , 'asn_country_code' : None , 'asn_... | The function for parsing ASN fields from a http response . |
238,632 | def get_nets_radb ( self , response , is_http = False ) : nets = [ ] if is_http : regex = r'route(?:6)?:[^\S\n]+(?P<val>.+?)<br>' else : regex = r'^route(?:6)?:[^\S\n]+(?P<val>.+|.+)$' for match in re . finditer ( regex , response , re . MULTILINE ) : try : net = copy . deepcopy ( BASE_NET ) net [ 'cidr' ] = match . gr... | The function for parsing network blocks from ASN origin data . |
238,633 | def get_nets_jpnic ( self , response ) : nets = [ ] for match in re . finditer ( r'^.*?(\[Network Number\])[^\S\n]+.+?>(?P<val>.+?)</A>$' , response , re . MULTILINE ) : try : net = copy . deepcopy ( BASE_NET ) tmp = ip_network ( match . group ( 2 ) ) try : network_address = tmp . network_address except AttributeError ... | The function for parsing network blocks from jpnic whois data . |
238,634 | def get_contact ( self , response = None , nir = None , handle = None , retry_count = 3 , dt_format = None ) : if response or nir == 'krnic' : contact_response = response else : contact_response = self . _net . get_http_raw ( url = str ( NIR_WHOIS [ nir ] [ 'url' ] ) . format ( handle ) , retry_count = retry_count , he... | The function for retrieving and parsing NIR whois data based on NIR_WHOIS contact_fields . |
238,635 | def _parse_address ( self , val ) : ret = { 'type' : None , 'value' : None } try : ret [ 'type' ] = val [ 1 ] [ 'type' ] except ( KeyError , ValueError , TypeError ) : pass try : ret [ 'value' ] = val [ 1 ] [ 'label' ] except ( KeyError , ValueError , TypeError ) : ret [ 'value' ] = '\n' . join ( val [ 3 ] ) . strip ( ... | The function for parsing the vcard address . |
238,636 | def _parse_phone ( self , val ) : ret = { 'type' : None , 'value' : None } try : ret [ 'type' ] = val [ 1 ] [ 'type' ] except ( IndexError , KeyError , ValueError , TypeError ) : pass ret [ 'value' ] = val [ 3 ] . strip ( ) try : self . vars [ 'phone' ] . append ( ret ) except AttributeError : self . vars [ 'phone' ] =... | The function for parsing the vcard phone numbers . |
238,637 | def _parse_email ( self , val ) : ret = { 'type' : None , 'value' : None } try : ret [ 'type' ] = val [ 1 ] [ 'type' ] except ( KeyError , ValueError , TypeError ) : pass ret [ 'value' ] = val [ 3 ] . strip ( ) try : self . vars [ 'email' ] . append ( ret ) except AttributeError : self . vars [ 'email' ] = [ ] self . v... | The function for parsing the vcard email addresses . |
238,638 | def parse ( self ) : keys = { 'fn' : self . _parse_name , 'kind' : self . _parse_kind , 'adr' : self . _parse_address , 'tel' : self . _parse_phone , 'email' : self . _parse_email , 'role' : self . _parse_role , 'title' : self . _parse_title } for val in self . vcard : try : parser = keys . get ( val [ 0 ] ) parser ( v... | The function for parsing the vcard to the vars dictionary . |
238,639 | def ipv4_lstrip_zeros ( address ) : obj = address . strip ( ) . split ( '.' ) for x , y in enumerate ( obj ) : obj [ x ] = y . split ( '/' ) [ 0 ] . lstrip ( '0' ) if obj [ x ] in [ '' , None ] : obj [ x ] = '0' return '.' . join ( obj ) | The function to strip leading zeros in each octet of an IPv4 address . |
238,640 | def get_countries ( is_legacy_xml = False ) : countries = { } if sys . platform == 'win32' and getattr ( sys , 'frozen' , False ) : data_dir = path . dirname ( sys . executable ) else : data_dir = path . dirname ( __file__ ) if is_legacy_xml : log . debug ( 'Opening country code legacy XML: {0}' . format ( str ( data_d... | The function to generate a dictionary containing ISO_3166 - 1 country codes to names . |
238,641 | def unique_everseen ( iterable , key = None ) : seen = set ( ) seen_add = seen . add if key is None : for element in filterfalse ( seen . __contains__ , iterable ) : seen_add ( element ) yield element else : for element in iterable : k = key ( element ) if k not in seen : seen_add ( k ) yield element | The generator to list unique elements preserving the order . Remember all elements ever seen . This was taken from the itertools recipes . |
238,642 | def get_nets_arin ( self , response ) : nets = [ ] pattern = re . compile ( r'^NetRange:[^\S\n]+(.+)$' , re . MULTILINE ) temp = pattern . search ( response ) net_range = None net_range_start = None if temp is not None : net_range = temp . group ( 1 ) . strip ( ) net_range_start = temp . start ( ) for match in re . fin... | The function for parsing network blocks from ARIN whois data . |
238,643 | def get_nets_lacnic ( self , response ) : nets = [ ] for match in re . finditer ( r'^(inetnum|inet6num|route):[^\S\n]+(.+?,[^\S\n].+|.+)$' , response , re . MULTILINE ) : try : net = copy . deepcopy ( BASE_NET ) net_range = match . group ( 2 ) . strip ( ) try : net [ 'range' ] = net [ 'range' ] = '{0} - {1}' . format (... | The function for parsing network blocks from LACNIC whois data . |
238,644 | def get_nets_other ( self , response ) : nets = [ ] for match in re . finditer ( r'^(inetnum|inet6num|route):[^\S\n]+((.+?)[^\S\n]-[^\S\n](.+)|' '.+)$' , response , re . MULTILINE ) : try : net = copy . deepcopy ( BASE_NET ) net_range = match . group ( 2 ) . strip ( ) try : net [ 'range' ] = net [ 'range' ] = '{0} - {1... | The function for parsing network blocks from generic whois data . |
238,645 | def convert_default ( self , field , ** params ) : for klass , ma_field in self . TYPE_MAPPING : if isinstance ( field , klass ) : return ma_field ( ** params ) return fields . Raw ( ** params ) | Return raw field . |
238,646 | def make_instance ( self , data ) : if not self . opts . model : return data if self . instance is not None : for key , value in data . items ( ) : setattr ( self . instance , key , value ) return self . instance return self . opts . model ( ** data ) | Build object from data . |
238,647 | def _extract ( self , stim ) : props = [ ( e . text , e . onset , e . duration ) for e in stim . elements ] vals , onsets , durations = map ( list , zip ( * props ) ) return ExtractorResult ( vals , stim , self , [ 'word' ] , onsets , durations ) | Returns all words . |
238,648 | def get_filename ( self ) : if self . filename is None or not os . path . exists ( self . filename ) : tf = tempfile . mktemp ( ) + self . _default_file_extension self . save ( tf ) yield tf os . remove ( tf ) else : yield self . filename | Return the source filename of the current Stim . |
238,649 | def get_stim ( self , type_ , return_all = False ) : if isinstance ( type_ , string_types ) : type_ = _get_stim_class ( type_ ) matches = [ ] for s in self . elements : if isinstance ( s , type_ ) : if not return_all : return s matches . append ( s ) if not matches : return [ ] if return_all else None return matches | Returns component elements of the specified type . |
238,650 | def has_types ( self , types , all_ = True ) : func = all if all_ else any return func ( [ self . get_stim ( t ) for t in listify ( types ) ] ) | Check whether the current component list matches all Stim types in the types argument . |
238,651 | def save ( self , path ) : self . clip . write_audiofile ( path , fps = self . sampling_rate ) | Save clip data to file . |
238,652 | def get_converter ( in_type , out_type , * args , ** kwargs ) : convs = pliers . converters . __all__ out_type = listify ( out_type ) [ : : - 1 ] default_convs = config . get_option ( 'default_converters' ) for ot in out_type : conv_str = '%s->%s' % ( in_type . __name__ , ot . __name__ ) if conv_str in default_convs : ... | Scans the list of available Converters and returns an instantiation of the first one whose input and output types match those passed in . |
238,653 | def create_graph ( ) : with tf . gfile . FastGFile ( os . path . join ( FLAGS . model_dir , 'classify_image_graph_def.pb' ) , 'rb' ) as f : graph_def = tf . GraphDef ( ) graph_def . ParseFromString ( f . read ( ) ) _ = tf . import_graph_def ( graph_def , name = '' ) | Creates a graph from saved GraphDef file and returns a saver . |
238,654 | def run_inference_on_image ( image ) : if not tf . gfile . Exists ( image ) : tf . logging . fatal ( 'File does not exist %s' , image ) image_data = tf . gfile . FastGFile ( image , 'rb' ) . read ( ) create_graph ( ) with tf . Session ( ) as sess : softmax_tensor = sess . graph . get_tensor_by_name ( 'softmax:0' ) pred... | Runs inference on an image . |
238,655 | def load ( self , label_lookup_path , uid_lookup_path ) : if not tf . gfile . Exists ( uid_lookup_path ) : tf . logging . fatal ( 'File does not exist %s' , uid_lookup_path ) if not tf . gfile . Exists ( label_lookup_path ) : tf . logging . fatal ( 'File does not exist %s' , label_lookup_path ) proto_as_ascii_lines = t... | Loads a human readable English name for each softmax node . |
238,656 | def fetch_dictionary ( name , url = None , format = None , index = 0 , rename = None , save = True , force_retrieve = False ) : file_path = os . path . join ( _get_dictionary_path ( ) , name + '.csv' ) if not force_retrieve and os . path . exists ( file_path ) : df = pd . read_csv ( file_path ) index = datasets [ name ... | Retrieve a dictionary of text norms from the web or local storage . |
238,657 | def _to_df ( self , result , handle_annotations = None ) : annotations = result . _data if handle_annotations == 'first' : annotations = [ annotations [ 0 ] ] face_results = [ ] for i , annotation in enumerate ( annotations ) : data_dict = { } for field , val in annotation . items ( ) : if 'Confidence' in field : data_... | Converts a Google API Face JSON response into a Pandas Dataframe . |
238,658 | def correlation_matrix ( df ) : columns = df . columns . tolist ( ) corr = pd . DataFrame ( np . corrcoef ( df , rowvar = 0 ) , columns = columns , index = columns ) return corr | Returns a pandas DataFrame with the pair - wise correlations of the columns . |
238,659 | def eigenvalues ( df ) : corr = np . corrcoef ( df , rowvar = 0 ) eigvals = np . linalg . eigvals ( corr ) return pd . Series ( eigvals , df . columns , name = 'Eigenvalue' ) | Returns a pandas Series with eigenvalues of the correlation matrix . |
238,660 | def condition_indices ( df ) : eigvals = eigenvalues ( df ) cond_idx = np . sqrt ( eigvals . max ( ) / eigvals ) return pd . Series ( cond_idx , df . columns , name = 'Condition index' ) | Returns a pandas Series with condition indices of the df columns . |
238,661 | def mahalanobis_distances ( df , axis = 0 ) : df = df . transpose ( ) if axis == 1 else df means = df . mean ( ) try : inv_cov = np . linalg . inv ( df . cov ( ) ) except LinAlgError : return pd . Series ( [ np . NAN ] * len ( df . index ) , df . index , name = 'Mahalanobis' ) dists = [ ] for i , sample in df . iterrow... | Returns a pandas Series with Mahalanobis distances for each sample on the axis . |
238,662 | def summary ( self , stdout = True , plot = False ) : if stdout : print ( 'Collinearity summary:' ) print ( pd . concat ( [ self . results [ 'Eigenvalues' ] , self . results [ 'ConditionIndices' ] , self . results [ 'VIFs' ] , self . results [ 'CorrelationMatrix' ] ] , axis = 1 ) ) print ( 'Outlier summary:' ) print ( ... | Displays diagnostics to the user |
238,663 | def add_nodes ( self , nodes , parent = None , mode = 'horizontal' ) : for n in nodes : node_args = self . _parse_node_args ( n ) if mode == 'horizontal' : self . add_node ( parent = parent , ** node_args ) elif mode == 'vertical' : parent = self . add_node ( parent = parent , return_node = True , ** node_args ) else :... | Adds one or more nodes to the current graph . |
238,664 | def add_node ( self , transformer , name = None , children = None , parent = None , parameters = { } , return_node = False ) : node = Node ( transformer , name , ** parameters ) self . nodes [ node . id ] = node if parent is None : self . roots . append ( node ) else : parent = self . nodes [ parent . id ] parent . add... | Adds a node to the current graph . |
238,665 | def run ( self , stim , merge = True , ** merge_kwargs ) : results = list ( chain ( * [ self . run_node ( n , stim ) for n in self . roots ] ) ) results = list ( flatten ( results ) ) self . _results = results return merge_results ( results , ** merge_kwargs ) if merge else results | Executes the graph by calling all Transformers in sequence . |
238,666 | def run_node ( self , node , stim ) : if isinstance ( node , string_types ) : node = self . nodes [ node ] result = node . transformer . transform ( stim ) if node . is_leaf ( ) : return listify ( result ) stim = result if len ( node . children ) > 1 and isgenerator ( stim ) : stim = list ( stim ) return list ( chain (... | Executes the Transformer at a specific node . |
238,667 | def draw ( self , filename , color = True ) : verify_dependencies ( [ 'pgv' ] ) if not hasattr ( self , '_results' ) : raise RuntimeError ( "Graph cannot be drawn before it is executed. " "Try calling run() first." ) g = pgv . AGraph ( directed = True ) g . node_attr [ 'colorscheme' ] = 'set312' for elem in self . _res... | Render a plot of the graph via pygraphviz . |
238,668 | def to_json ( self ) : roots = [ ] for r in self . roots : roots . append ( r . to_json ( ) ) return { 'roots' : roots } | Returns the JSON representation of this graph . |
238,669 | def flatten ( l ) : for el in l : if isinstance ( el , collections . Iterable ) and not isinstance ( el , string_types ) : for sub in flatten ( el ) : yield sub else : yield el | Flatten an iterable . |
238,670 | def set_iterable_type ( obj ) : if not isiterable ( obj ) : return obj if config . get_option ( 'use_generators' ) : return obj if isgenerator ( obj ) else ( i for i in obj ) else : return [ set_iterable_type ( i ) for i in obj ] | Returns either a generator or a list depending on config - level settings . Should be used to wrap almost every internal iterable return . Also inspects elements recursively in the case of list returns to ensure that there are no nested generators . |
238,671 | def isgenerator ( obj ) : return isinstance ( obj , GeneratorType ) or ( hasattr ( obj , 'iterable' ) and isinstance ( getattr ( obj , 'iterable' ) , GeneratorType ) ) | Returns True if object is a generator or a generator wrapped by a tqdm object . |
238,672 | def progress_bar_wrapper ( iterable , ** kwargs ) : return tqdm ( iterable , ** kwargs ) if ( config . get_option ( 'progress_bar' ) and not isinstance ( iterable , tqdm ) ) else iterable | Wrapper that applies tqdm progress bar conditional on config settings . |
238,673 | def get_frame ( self , index ) : frame_num = self . frame_index [ index ] onset = float ( frame_num ) / self . fps if index < self . n_frames - 1 : next_frame_num = self . frame_index [ index + 1 ] end = float ( next_frame_num ) / self . fps else : end = float ( self . duration ) duration = end - onset if end > onset e... | Get video frame at the specified index . |
238,674 | def save ( self , path ) : self . clip . write_videofile ( path , audio_fps = self . clip . audio . fps ) | Save source video to file . |
238,675 | def get_frame ( self , index = None , onset = None ) : if onset : index = int ( onset * self . fps ) return super ( VideoStim , self ) . get_frame ( index ) | Overrides the default behavior by giving access to the onset argument . |
238,676 | def hash_data ( data , blocksize = 65536 ) : data = pickle . dumps ( data ) hasher = hashlib . sha1 ( ) hasher . update ( data ) return hasher . hexdigest ( ) | Hashes list of data strings or data |
238,677 | def check_updates ( transformers , datastore = None , stimuli = None ) : datastore = datastore or expanduser ( '~/.pliers_updates' ) prior_data = pd . read_csv ( datastore ) if exists ( datastore ) else None stimuli = stimuli or glob . glob ( join ( dirname ( realpath ( __file__ ) ) , '../tests/data/image/CC0/*' ) ) st... | Run transformers through a battery of stimuli and check if output has changed . Store results in csv file for comparison . |
238,678 | def scan ( args ) : backend = _get_backend ( args ) print ( 'Scanning for 10 seconds...' ) devices = miflora_scanner . scan ( backend , 10 ) print ( 'Found {} devices:' . format ( len ( devices ) ) ) for device in devices : print ( ' {}' . format ( device ) ) | Scan for sensors . |
238,679 | def _get_backend ( args ) : if args . backend == 'gatttool' : backend = GatttoolBackend elif args . backend == 'bluepy' : backend = BluepyBackend elif args . backend == 'pygatt' : backend = PygattBackend else : raise Exception ( 'unknown backend: {}' . format ( args . backend ) ) return backend | Extract the backend class from the command line arguments . |
238,680 | def list_backends ( _ ) : backends = [ b . __name__ for b in available_backends ( ) ] print ( '\n' . join ( backends ) ) | List all available backends . |
238,681 | def scan ( backend , timeout = 10 ) : result = [ ] for ( mac , name ) in backend . scan_for_devices ( timeout ) : if ( name is not None and name . lower ( ) in VALID_DEVICE_NAMES ) or mac is not None and mac . upper ( ) . startswith ( DEVICE_PREFIX ) : result . append ( mac . upper ( ) ) return result | Scan for miflora devices . |
238,682 | def parameter_value ( self , parameter , read_cached = True ) : if parameter == MI_BATTERY : return self . battery_level ( ) with self . lock : if ( read_cached is False ) or ( self . _last_read is None ) or ( datetime . now ( ) - self . _cache_timeout > self . _last_read ) : self . fill_cache ( ) else : _LOGGER . debu... | Return a value of one of the monitored paramaters . |
238,683 | def parse_version_string ( version_string ) : string_parts = version_string . split ( "." ) version_parts = [ int ( re . match ( "([0-9]*)" , string_parts [ 0 ] ) . group ( 0 ) ) , int ( re . match ( "([0-9]*)" , string_parts [ 1 ] ) . group ( 0 ) ) , int ( re . match ( "([0-9]*)" , string_parts [ 2 ] ) . group ( 0 ) )... | Parses a semver version string stripping off rc stuff if present . |
238,684 | def bigger_version ( version_string_a , version_string_b ) : major_a , minor_a , patch_a = parse_version_string ( version_string_a ) major_b , minor_b , patch_b = parse_version_string ( version_string_b ) if major_a > major_b : return version_string_a elif major_a == major_b and minor_a > minor_b : return version_strin... | Returns the bigger version of two version strings . |
238,685 | def api_version ( created_ver , last_changed_ver , return_value_ver ) : def api_min_version_decorator ( function ) : def wrapper ( function , self , * args , ** kwargs ) : if not self . version_check_mode == "none" : if self . version_check_mode == "created" : version = created_ver else : version = bigger_version ( las... | Version check decorator . Currently only checks Bigger Than . |
238,686 | def verify_minimum_version ( self , version_str ) : self . retrieve_mastodon_version ( ) major , minor , patch = parse_version_string ( version_str ) if major > self . mastodon_major : return False elif major == self . mastodon_major and minor > self . mastodon_minor : return False elif major == self . mastodon_major a... | Update version info from server and verify that at least the specified version is present . Returns True if version requirement is satisfied False if not . |
238,687 | def log_in ( self , username = None , password = None , code = None , redirect_uri = "urn:ietf:wg:oauth:2.0:oob" , refresh_token = None , scopes = __DEFAULT_SCOPES , to_file = None ) : if username is not None and password is not None : params = self . __generate_params ( locals ( ) , [ 'scopes' , 'to_file' , 'code' , '... | Get the access token for a user . The username is the e - mail used to log in into mastodon . |
238,688 | def timeline_list ( self , id , max_id = None , min_id = None , since_id = None , limit = None ) : id = self . __unpack_id ( id ) return self . timeline ( 'list/{0}' . format ( id ) , max_id = max_id , min_id = min_id , since_id = since_id , limit = limit ) | Fetches a timeline containing all the toots by users in a given list . |
238,689 | def conversations ( self , max_id = None , min_id = None , since_id = None , limit = None ) : if max_id != None : max_id = self . __unpack_id ( max_id ) if min_id != None : min_id = self . __unpack_id ( min_id ) if since_id != None : since_id = self . __unpack_id ( since_id ) params = self . __generate_params ( locals ... | Fetches a users conversations . Returns a list of conversation dicts _ . |
238,690 | def status ( self , id ) : id = self . __unpack_id ( id ) url = '/api/v1/statuses/{0}' . format ( str ( id ) ) return self . __api_request ( 'GET' , url ) | Fetch information about a single toot . |
238,691 | def status_context ( self , id ) : id = self . __unpack_id ( id ) url = '/api/v1/statuses/{0}/context' . format ( str ( id ) ) return self . __api_request ( 'GET' , url ) | Fetch information about ancestors and descendants of a toot . |
238,692 | def status_reblogged_by ( self , id ) : id = self . __unpack_id ( id ) url = '/api/v1/statuses/{0}/reblogged_by' . format ( str ( id ) ) return self . __api_request ( 'GET' , url ) | Fetch a list of users that have reblogged a status . |
238,693 | def status_favourited_by ( self , id ) : id = self . __unpack_id ( id ) url = '/api/v1/statuses/{0}/favourited_by' . format ( str ( id ) ) return self . __api_request ( 'GET' , url ) | Fetch a list of users that have favourited a status . |
238,694 | def scheduled_status ( self , id ) : id = self . __unpack_id ( id ) url = '/api/v1/scheduled_statuses/{0}' . format ( str ( id ) ) return self . __api_request ( 'GET' , url ) | Fetch information about the scheduled status with the given id . |
238,695 | def poll ( self , id ) : id = self . __unpack_id ( id ) url = '/api/v1/polls/{0}' . format ( str ( id ) ) return self . __api_request ( 'GET' , url ) | Fetch information about the poll with the given id |
238,696 | def account ( self , id ) : id = self . __unpack_id ( id ) url = '/api/v1/accounts/{0}' . format ( str ( id ) ) return self . __api_request ( 'GET' , url ) | Fetch account information by user id . Does not require authentication . Returns a user dict _ . |
238,697 | def account_following ( self , id , max_id = None , min_id = None , since_id = None , limit = None ) : id = self . __unpack_id ( id ) if max_id != None : max_id = self . __unpack_id ( max_id ) if min_id != None : min_id = self . __unpack_id ( min_id ) if since_id != None : since_id = self . __unpack_id ( since_id ) par... | Fetch users the given user is following . |
238,698 | def account_lists ( self , id ) : id = self . __unpack_id ( id ) params = self . __generate_params ( locals ( ) , [ 'id' ] ) url = '/api/v1/accounts/{0}/lists' . format ( str ( id ) ) return self . __api_request ( 'GET' , url , params ) | Get all of the logged - in users lists which the specified user is a member of . Returns a list of list dicts _ . |
238,699 | def filter ( self , id ) : id = self . __unpack_id ( id ) url = '/api/v1/filters/{0}' . format ( str ( id ) ) return self . __api_request ( 'GET' , url ) | Fetches information about the filter with the specified id . Returns a filter dict _ . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.