idx int64 0 252k | question stringlengths 48 5.28k | target stringlengths 5 1.23k |
|---|---|---|
233,800 | def _exponent_handler_factory ( ion_type , exp_chars , parse_func , first_char = None ) : def transition ( prev , c , ctx , trans ) : if c in _SIGN and prev in exp_chars : ctx . value . append ( c ) else : _illegal_character ( c , ctx ) return trans illegal = exp_chars + _SIGN return _numeric_handler_factory ( _DIGITS ... | Generates a handler co - routine which tokenizes an numeric exponent . |
233,801 | def _coefficient_handler_factory ( trans_table , parse_func , assertion = lambda c , ctx : True , ion_type = None , append_first_if_not = None ) : def transition ( prev , c , ctx , trans ) : if prev == _UNDERSCORE : _illegal_character ( c , ctx , 'Underscore before %s.' % ( _chr ( c ) , ) ) return ctx . immediate_trans... | Generates a handler co - routine which tokenizes a numeric coefficient . |
233,802 | def _radix_int_handler_factory ( radix_indicators , charset , parse_func ) : def assertion ( c , ctx ) : return c in radix_indicators and ( ( len ( ctx . value ) == 1 and ctx . value [ 0 ] == _ZERO ) or ( len ( ctx . value ) == 2 and ctx . value [ 0 ] == _MINUS and ctx . value [ 1 ] == _ZERO ) ) and ctx . ion_type == I... | Generates a handler co - routine which tokenizes a integer of a particular radix . |
233,803 | def _timestamp_zero_start_handler ( c , ctx ) : val = ctx . value ctx . set_ion_type ( IonType . TIMESTAMP ) if val [ 0 ] == _MINUS : _illegal_character ( c , ctx , 'Negative year not allowed.' ) val . append ( c ) c , self = yield trans = ctx . immediate_transition ( self ) while True : if c in _TIMESTAMP_YEAR_DELIMIT... | Handles numeric values that start with a zero followed by another digit . This is either a timestamp or an error . |
233,804 | def _parse_timestamp ( tokens ) : def parse ( ) : precision = TimestampPrecision . YEAR off_hour = tokens [ _TimestampState . OFF_HOUR ] off_minutes = tokens [ _TimestampState . OFF_MINUTE ] microsecond = None fraction_digits = None if off_hour is not None : assert off_minutes is not None off_sign = - 1 if _MINUS in of... | Parses each token in the given _TimestampTokens and marshals the numeric components into a Timestamp . |
233,805 | def _comment_handler ( c , ctx , whence ) : assert c == _SLASH c , self = yield if c == _SLASH : ctx . set_line_comment ( ) block_comment = False elif c == _ASTERISK : if ctx . line_comment : ctx . set_line_comment ( False ) block_comment = True else : _illegal_character ( c , ctx , 'Illegal character sequence "/%s".' ... | Handles comments . Upon completion of the comment immediately transitions back to whence . |
233,806 | def _sexp_slash_handler ( c , ctx , whence = None , pending_event = None ) : assert c == _SLASH if whence is None : whence = ctx . whence c , self = yield ctx . queue . unread ( c ) if c == _ASTERISK or c == _SLASH : yield ctx . immediate_transition ( _comment_handler ( _SLASH , ctx , whence ) ) else : if pending_event... | Handles the special case of a forward - slash within an s - expression . This is either an operator or a comment . |
233,807 | def _typed_null_handler ( c , ctx ) : assert c == _DOT c , self = yield nxt = _NULL_STARTS i = 0 length = None done = False trans = ctx . immediate_transition ( self ) while True : if done : if _ends_value ( c ) or ( ctx . container . ion_type is IonType . SEXP and c in _OPERATORS ) : trans = ctx . event_transition ( I... | Handles typed null values . Entered once null . has been found . |
233,808 | def _inf_or_operator_handler_factory ( c_start , is_delegate = True ) : @ coroutine def inf_or_operator_handler ( c , ctx ) : next_ctx = None if not is_delegate : ctx . value . append ( c_start ) c , self = yield else : assert ctx . value [ 0 ] == c_start assert c not in _DIGITS ctx . queue . unread ( c ) next_ctx = ct... | Generates handler co - routines for values that may be + inf or - inf . |
233,809 | def _operator_symbol_handler ( c , ctx ) : assert c in _OPERATORS ctx . set_unicode ( ) val = ctx . value val . append ( c ) c , self = yield trans = ctx . immediate_transition ( self ) while c in _OPERATORS : val . append ( c ) c , _ = yield trans yield ctx . event_transition ( IonEvent , IonEventType . SCALAR , IonTy... | Handles operator symbol values within s - expressions . |
233,810 | def _symbol_token_end ( c , ctx , is_field_name , value = None ) : if value is None : value = ctx . value if is_field_name or c in _SYMBOL_TOKEN_TERMINATORS or ctx . quoted_text : ctx . set_self_delimiting ( ctx . quoted_text ) . set_pending_symbol ( value ) . set_quoted_text ( False ) trans = ctx . immediate_transitio... | Returns a transition which ends the current symbol token . |
233,811 | def _unquoted_symbol_handler ( c , ctx , is_field_name = False ) : in_sexp = ctx . container . ion_type is IonType . SEXP ctx . set_unicode ( ) if c not in _IDENTIFIER_CHARACTERS : if in_sexp and c in _OPERATORS : c_next , _ = yield ctx . queue . unread ( c_next ) assert ctx . value yield _CompositeTransition ( ctx . e... | Handles identifier symbol tokens . If in an s - expression these may be followed without whitespace by operators . |
233,812 | def _single_quote_handler_factory ( on_single_quote , on_other ) : @ coroutine def single_quote_handler ( c , ctx , is_field_name = False ) : assert c == _SINGLE_QUOTE c , self = yield if c == _SINGLE_QUOTE and not _is_escaped ( c ) : yield on_single_quote ( c , ctx , is_field_name ) else : ctx . set_unicode ( quoted_t... | Generates handlers used for classifying tokens that begin with one or more single quotes . |
233,813 | def _struct_or_lob_handler ( c , ctx ) : assert c == _OPEN_BRACE c , self = yield yield ctx . immediate_transition ( _STRUCT_OR_LOB_TABLE [ c ] ( c , ctx ) ) | Handles tokens that begin with an open brace . |
233,814 | def _lob_start_handler ( c , ctx ) : assert c == _OPEN_BRACE c , self = yield trans = ctx . immediate_transition ( self ) quotes = 0 while True : if c in _WHITESPACE : if quotes > 0 : _illegal_character ( c , ctx ) elif c == _DOUBLE_QUOTE : if quotes > 0 : _illegal_character ( c , ctx ) ctx . set_ion_type ( IonType . C... | Handles tokens that begin with two open braces . |
233,815 | def _lob_end_handler_factory ( ion_type , action , validate = lambda c , ctx , action_res : None ) : assert ion_type is IonType . BLOB or ion_type is IonType . CLOB @ coroutine def lob_end_handler ( c , ctx ) : val = ctx . value prev = c action_res = None if c != _CLOSE_BRACE and c not in _WHITESPACE : action_res = act... | Generates handlers for the end of blob or clob values . |
233,816 | def _blob_end_handler_factory ( ) : def expand_res ( res ) : if res is None : return 0 , 0 return res def action ( c , ctx , prev , res , is_first ) : num_digits , num_pads = expand_res ( res ) if c in _BASE64_DIGITS : if prev == _CLOSE_BRACE or prev == _BASE64_PAD : _illegal_character ( c , ctx . set_ion_type ( IonTyp... | Generates the handler for the end of a blob value . This includes the base - 64 data and the two closing braces . |
233,817 | def _clob_end_handler_factory ( ) : def action ( c , ctx , prev , res , is_first ) : if is_first and ctx . is_self_delimiting and c == _DOUBLE_QUOTE : assert c is prev return res _illegal_character ( c , ctx ) return _lob_end_handler_factory ( IonType . CLOB , action ) | Generates the handler for the end of a clob value . This includes anything from the data s closing quote through the second closing brace . |
233,818 | def _container_start_handler_factory ( ion_type , before_yield = lambda c , ctx : None ) : assert ion_type . is_container @ coroutine def container_start_handler ( c , ctx ) : before_yield ( c , ctx ) yield yield ctx . event_transition ( IonEvent , IonEventType . CONTAINER_START , ion_type , value = None ) return conta... | Generates handlers for tokens that begin with container start characters . |
233,819 | def _skip_trampoline ( handler ) : data_event , self = ( yield None ) delegate = handler event = None depth = 0 while True : def pass_through ( ) : _trans = delegate . send ( Transition ( data_event , delegate ) ) return _trans , _trans . delegate , _trans . event if data_event is not None and data_event . type is Read... | Intercepts events from container handlers emitting them only if they should not be skipped . |
233,820 | def _next_code_point_handler ( whence , ctx ) : data_event , self = yield queue = ctx . queue unicode_escapes_allowed = ctx . ion_type is not IonType . CLOB escaped_newline = False escape_sequence = b'' low_surrogate_required = False while True : if len ( queue ) == 0 : yield ctx . read_data_event ( self ) queue_iter =... | Retrieves the next code point from within a quoted string or symbol . |
233,821 | def read_data_event ( self , whence , complete = False , can_flush = False ) : return Transition ( None , _read_data_handler ( whence , self , complete , can_flush ) ) | Creates a transition to a co - routine for retrieving data as bytes . |
233,822 | def set_unicode ( self , quoted_text = False ) : if isinstance ( self . value , CodePointArray ) : assert self . quoted_text == quoted_text return self self . value = CodePointArray ( self . value ) self . quoted_text = quoted_text self . line_comment = False return self | Converts the context s value to a sequence of unicode code points for holding text tokens indicating whether the text is quoted . |
233,823 | def set_quoted_text ( self , quoted_text ) : self . quoted_text = quoted_text self . line_comment = False return self | Sets the context s quoted_text flag . Useful when entering and exiting quoted text tokens . |
233,824 | def derive_container_context ( self , ion_type , whence ) : if ion_type is IonType . STRUCT : container = _C_STRUCT elif ion_type is IonType . LIST : container = _C_LIST elif ion_type is IonType . SEXP : container = _C_SEXP else : raise TypeError ( 'Cannot derive container context for non-container type %s.' % ( ion_ty... | Derives a container context as a child of the current context . |
233,825 | def derive_child_context ( self , whence ) : return _HandlerContext ( container = self . container , queue = self . queue , field_name = None , annotations = None , depth = self . depth , whence = whence , value = bytearray ( ) , ion_type = None , pending_symbol = None ) | Derives a scalar context as a child of the current context . |
233,826 | def set_ion_type ( self , ion_type ) : if ion_type is self . ion_type : return self self . ion_type = ion_type self . line_comment = False return self | Sets context to the given IonType . |
233,827 | def set_annotation ( self ) : assert self . pending_symbol is not None assert not self . value annotations = ( _as_symbol ( self . pending_symbol , is_symbol_value = False ) , ) self . annotations = annotations if not self . annotations else self . annotations + annotations self . ion_type = None self . pending_symbol ... | Appends the context s pending_symbol to its annotations sequence . |
233,828 | def set_field_name ( self ) : assert self . pending_symbol is not None assert not self . value self . field_name = _as_symbol ( self . pending_symbol , is_symbol_value = False ) self . pending_symbol = None self . quoted_text = False self . line_comment = False self . is_self_delimiting = False return self | Sets the context s pending_symbol as its field_name . |
233,829 | def set_pending_symbol ( self , pending_symbol = None ) : if pending_symbol is None : pending_symbol = CodePointArray ( ) self . value = bytearray ( ) self . pending_symbol = pending_symbol self . line_comment = False return self | Sets the context s pending_symbol with the given unicode sequence and resets the context s value . |
233,830 | def _write_base ( buf , value , bits_per_octet , end_bit = 0 , sign_bit = 0 , is_signed = False ) : if value == 0 : buf . append ( sign_bit | end_bit ) return 1 num_bits = bit_length ( value ) num_octets = num_bits // bits_per_octet remainder = num_bits % bits_per_octet if remainder != 0 or is_signed : num_octets += 1 ... | Write a field to the provided buffer . |
233,831 | def record ( * fields ) : @ six . add_metaclass ( _RecordMetaClass ) class RecordType ( object ) : _record_sentinel = True _record_fields = fields return RecordType | Constructs a type that can be extended to create immutable value types . |
233,832 | def coroutine ( func ) : def wrapper ( * args , ** kwargs ) : gen = func ( * args , ** kwargs ) val = next ( gen ) if val != None : raise TypeError ( 'Unexpected value from start of coroutine' ) return gen wrapper . __name__ = func . __name__ wrapper . __doc__ = func . __doc__ return wrapper | Wraps a PEP - 342 enhanced generator in a way that avoids boilerplate of the priming call to next . |
233,833 | def derive_field_name ( self , field_name ) : cls = type ( self ) return cls ( self [ 0 ] , self [ 1 ] , self [ 2 ] , field_name , self [ 4 ] , self [ 5 ] ) | Derives a new event from this one setting the field_name attribute . |
233,834 | def derive_annotations ( self , annotations ) : cls = type ( self ) return cls ( self [ 0 ] , self [ 1 ] , self [ 2 ] , self [ 3 ] , annotations , self [ 5 ] ) | Derives a new event from this one setting the annotations attribute . |
233,835 | def derive_value ( self , value ) : return IonEvent ( self . event_type , self . ion_type , value , self . field_name , self . annotations , self . depth ) | Derives a new event from this one setting the value attribute . |
233,836 | def derive_depth ( self , depth ) : cls = type ( self ) return cls ( self [ 0 ] , self [ 1 ] , self [ 2 ] , self [ 3 ] , self [ 4 ] , depth ) | Derives a new event from this one setting the depth attribute . |
233,837 | def adjust_from_utc_fields ( * args , ** kwargs ) : raw_ts = Timestamp ( * args , ** kwargs ) offset = raw_ts . utcoffset ( ) if offset is None or offset == timedelta ( ) : return raw_ts adjusted = raw_ts + offset if raw_ts . precision is None : return adjusted return Timestamp ( adjusted . year , adjusted . month , ad... | Constructs a timestamp from UTC fields adjusted to the local offset if given . |
233,838 | def raw_writer ( indent = None ) : is_whitespace_str = isinstance ( indent , str ) and re . search ( r'\A\s*\Z' , indent , re . M ) is not None if not ( indent is None or is_whitespace_str ) : raise ValueError ( 'The indent parameter must either be None or a string containing only whitespace' ) indent_bytes = six . b (... | Returns a raw text writer co - routine . |
233,839 | def writer_trampoline ( start ) : trans = Transition ( None , start ) while True : ion_event = ( yield trans . event ) if trans . event is None : if ion_event is None : raise TypeError ( 'Cannot start Writer with no event' ) else : if trans . event . type is WriteEventType . HAS_PENDING and ion_event is not None : rais... | Provides the co - routine trampoline for a writer state machine . |
233,840 | def _drain ( writer , ion_event ) : result_event = _WRITE_EVENT_HAS_PENDING_EMPTY while result_event . type is WriteEventType . HAS_PENDING : result_event = writer . send ( ion_event ) ion_event = None yield result_event | Drain the writer of its pending write events . |
233,841 | def blocking_writer ( writer , output ) : result_type = None while True : ion_event = ( yield result_type ) for result_event in _drain ( writer , ion_event ) : output . write ( result_event . data ) result_type = result_event . type | Provides an implementation of using the writer co - routine with a file - like object . |
233,842 | def from_event ( cls , ion_event ) : if ion_event . value is not None : args , kwargs = cls . _to_constructor_args ( ion_event . value ) else : args , kwargs = ( ) , { } value = cls ( * args , ** kwargs ) value . ion_event = ion_event value . ion_type = ion_event . ion_type value . ion_annotations = ion_event . annotat... | Constructs the given native extension from the properties of an event . |
233,843 | def from_value ( cls , ion_type , value , annotations = ( ) ) : if value is None : value = IonPyNull ( ) else : args , kwargs = cls . _to_constructor_args ( value ) value = cls ( * args , ** kwargs ) value . ion_event = None value . ion_type = ion_type value . ion_annotations = annotations return value | Constructs a value as a copy with an associated Ion type and annotations . |
233,844 | def to_event ( self , event_type , field_name = None , depth = None ) : if self . ion_event is None : value = self if isinstance ( self , IonPyNull ) : value = None self . ion_event = IonEvent ( event_type , ion_type = self . ion_type , value = value , field_name = field_name , annotations = self . ion_annotations , de... | Constructs an IonEvent from this _IonNature value . |
233,845 | def _remove_sig ( signature , idempotent = False ) : try : signaturep = next ( signature . iterancestors ( ) ) except StopIteration : if idempotent : return raise ValueError ( "Can't remove the root signature node" ) if signature . tail is not None : try : signatures = next ( signature . itersiblings ( preceding = True... | Remove the signature node from its parent keeping any tail element . This is needed for eneveloped signatures . |
233,846 | def authorize ( self , scope = None , redirect_uri = None , state = None ) : _logger . debug ( "Called authorize()" ) params = { 'client_id' : self . client_id } if scope : params [ 'scope' ] = scope if redirect_uri : params [ 'redirect_uri' ] = redirect_uri if state : params [ 'state' ] = state url = self . auth_url +... | Redirect to GitHub and request access to a user s data . |
233,847 | def authorized_handler ( self , f ) : @ wraps ( f ) def decorated ( * args , ** kwargs ) : if 'code' in request . args : data = self . _handle_response ( ) else : data = self . _handle_invalid_response ( ) return f ( * ( ( data , ) + args ) , ** kwargs ) return decorated | Decorator for the route that is used as the callback for authorizing with GitHub . This callback URL can be set in the settings for the app or passed in during authorization . |
233,848 | def _handle_response ( self ) : _logger . debug ( "Handling response from GitHub" ) params = { 'code' : request . args . get ( 'code' ) , 'client_id' : self . client_id , 'client_secret' : self . client_secret } url = self . auth_url + 'access_token' _logger . debug ( "POSTing to %s" , url ) _logger . debug ( params ) ... | Handles response after the redirect to GitHub . This response determines if the user has allowed the this application access . If we were then we send a POST request for the access_key used to authenticate requests to GitHub . |
233,849 | def decode_lazy ( rlp , sedes = None , ** sedes_kwargs ) : item , end = consume_item_lazy ( rlp , 0 ) if end != len ( rlp ) : raise DecodingError ( 'RLP length prefix announced wrong length' , rlp ) if isinstance ( item , LazyList ) : item . sedes = sedes item . sedes_kwargs = sedes_kwargs return item elif sedes : retu... | Decode an RLP encoded object in a lazy fashion . |
233,850 | def consume_item_lazy ( rlp , start ) : p , t , l , s = consume_length_prefix ( rlp , start ) if t is bytes : item , _ , end = consume_payload ( rlp , p , s , bytes , l ) return item , end else : assert t is list return LazyList ( rlp , s , s + l ) , s + l | Read an item from an RLP string lazily . |
233,851 | def peek ( rlp , index , sedes = None ) : ll = decode_lazy ( rlp ) if not isinstance ( index , Iterable ) : index = [ index ] for i in index : if isinstance ( ll , Atomic ) : raise IndexError ( 'Too many indices given' ) ll = ll [ i ] if sedes : return sedes . deserialize ( ll ) else : return ll | Get a specific element from an rlp encoded nested list . |
233,852 | def fixed_length ( cls , l , allow_empty = False ) : return cls ( l , l , allow_empty = allow_empty ) | Create a sedes for text data with exactly l encoded characters . |
233,853 | def _eq ( left , right ) : if isinstance ( left , ( tuple , list ) ) and isinstance ( right , ( tuple , list ) ) : return len ( left ) == len ( right ) and all ( _eq ( * pair ) for pair in zip ( left , right ) ) else : return left == right | Equality comparison that allows for equality between tuple and list types with equivalent elements . |
233,854 | def is_sequence ( obj ) : return isinstance ( obj , Sequence ) and not ( isinstance ( obj , str ) or BinaryClass . is_valid_type ( obj ) ) | Check if obj is a sequence but not a string or bytes . |
233,855 | def encode ( obj , sedes = None , infer_serializer = True , cache = True ) : if isinstance ( obj , Serializable ) : cached_rlp = obj . _cached_rlp if sedes is None and cached_rlp : return cached_rlp else : really_cache = ( cache and sedes is None ) else : really_cache = False if sedes : item = sedes . serialize ( obj )... | Encode a Python object in RLP format . |
233,856 | def consume_payload ( rlp , prefix , start , type_ , length ) : if type_ is bytes : item = rlp [ start : start + length ] return ( item , [ prefix + item ] , start + length ) elif type_ is list : items = [ ] per_item_rlp = [ ] list_rlp = prefix next_item_start = start end = next_item_start + length while next_item_star... | Read the payload of an item from an RLP string . |
233,857 | def consume_item ( rlp , start ) : p , t , l , s = consume_length_prefix ( rlp , start ) return consume_payload ( rlp , p , s , t , l ) | Read an item from an RLP string . |
233,858 | def decode ( rlp , sedes = None , strict = True , recursive_cache = False , ** kwargs ) : if not is_bytes ( rlp ) : raise DecodingError ( 'Can only decode RLP bytes, got type %s' % type ( rlp ) . __name__ , rlp ) try : item , per_item_rlp , end = consume_item ( rlp , 0 ) except IndexError : raise DecodingError ( 'RLP s... | Decode an RLP encoded object . |
233,859 | def infer_sedes ( obj ) : if is_sedes ( obj . __class__ ) : return obj . __class__ elif not isinstance ( obj , bool ) and isinstance ( obj , int ) and obj >= 0 : return big_endian_int elif BinaryClass . is_valid_type ( obj ) : return binary elif not isinstance ( obj , str ) and isinstance ( obj , collections . Sequence... | Try to find a sedes objects suitable for a given Python object . |
233,860 | def destinations ( self , cluster = 'main' ) : if not self . config . has_section ( cluster ) : raise SystemExit ( "Cluster '%s' not defined in %s" % ( cluster , self . config_file ) ) destinations = self . config . get ( cluster , 'destinations' ) return destinations . replace ( ' ' , '' ) . split ( ',' ) | Return a list of destinations for a cluster . |
233,861 | def replication_factor ( self , cluster = 'main' ) : if not self . config . has_section ( cluster ) : raise SystemExit ( "Cluster '%s' not defined in %s" % ( cluster , self . config_file ) ) return int ( self . config . get ( cluster , 'replication_factor' ) ) | Return the replication factor for a cluster as an integer . |
233,862 | def ssh_user ( self , cluster = 'main' ) : if not self . config . has_section ( cluster ) : raise SystemExit ( "Cluster '%s' not defined in %s" % ( cluster , self . config_file ) ) try : return self . config . get ( cluster , 'ssh_user' ) except NoOptionError : return pwd . getpwuid ( os . getuid ( ) ) . pw_name | Return the ssh user for a cluster or current user if undefined . |
233,863 | def whisper_lock_writes ( self , cluster = 'main' ) : if not self . config . has_section ( cluster ) : raise SystemExit ( "Cluster '%s' not defined in %s" % ( cluster , self . config_file ) ) try : return bool ( self . config . get ( cluster , 'whisper_lock_writes' ) ) except NoOptionError : return False | Lock whisper files during carbon - sync . |
233,864 | def hashing_type ( self , cluster = 'main' ) : if not self . config . has_section ( cluster ) : raise SystemExit ( "Cluster '%s' not defined in %s" % ( cluster , self . config_file ) ) hashing_type = 'carbon_ch' try : return self . config . get ( cluster , 'hashing_type' ) except NoOptionError : return hashing_type | Hashing type of cluster . |
233,865 | def fill_archives ( src , dst , startFrom , endAt = 0 , overwrite = False , lock_writes = False ) : if lock_writes is False : whisper . LOCK = False elif whisper . CAN_LOCK and lock_writes is True : whisper . LOCK = True header = whisper . info ( dst ) archives = header [ 'archives' ] archives = sorted ( archives , key... | Fills gaps in dst using data from src . |
233,866 | def data ( path , hours , offset = 0 ) : now = time . time ( ) end = now - _to_sec ( offset ) start = end - _to_sec ( hours ) _data = whisper . fetch ( path , start , end ) return all ( x is None for x in _data [ - 1 ] ) | Does the metric at path have any whisper data newer than hours ? |
233,867 | def stat ( path , hours , offset = None ) : return os . stat ( path ) . st_mtime < ( time . time ( ) - _to_sec ( hours ) ) | Has the metric file at path been modified since hours ago? |
233,868 | def short_path ( path , cwd = None ) : if not isinstance ( path , str ) : return path if cwd is None : cwd = os . getcwd ( ) abspath = os . path . abspath ( path ) relpath = os . path . relpath ( path , cwd ) if len ( abspath ) <= len ( relpath ) : return abspath return relpath | Return relative or absolute path name whichever is shortest . |
233,869 | def check_rest ( module , names , dots = True ) : try : skip_types = ( dict , str , unicode , float , int ) except NameError : skip_types = ( dict , str , float , int ) results = [ ] if module . __name__ [ 6 : ] not in OTHER_MODULE_DOCS : results += [ ( module . __name__ , ) + validate_rst_syntax ( inspect . getdoc ( m... | Check reStructuredText formatting of docstrings |
233,870 | def update_header ( self ) : set_technician ( self . handle , du ( self . technician ) ) set_recording_additional ( self . handle , du ( self . recording_additional ) ) set_patientname ( self . handle , du ( self . patient_name ) ) set_patientcode ( self . handle , du ( self . patient_code ) ) set_patient_additional ( ... | Updates header to edffile struct |
233,871 | def setHeader ( self , fileHeader ) : self . technician = fileHeader [ "technician" ] self . recording_additional = fileHeader [ "recording_additional" ] self . patient_name = fileHeader [ "patientname" ] self . patient_additional = fileHeader [ "patient_additional" ] self . patient_code = fileHeader [ "patientcode" ] ... | Sets the file header |
233,872 | def setSignalHeader ( self , edfsignal , channel_info ) : if edfsignal < 0 or edfsignal > self . n_channels : raise ChannelDoesNotExist ( edfsignal ) self . channels [ edfsignal ] = channel_info self . update_header ( ) | Sets the parameter for signal edfsignal . |
233,873 | def setSignalHeaders ( self , signalHeaders ) : for edfsignal in np . arange ( self . n_channels ) : self . channels [ edfsignal ] = signalHeaders [ edfsignal ] self . update_header ( ) | Sets the parameter for all signals |
233,874 | def set_number_of_annotation_signals ( self , number_of_annotations ) : number_of_annotations = max ( ( min ( ( int ( number_of_annotations ) , 64 ) ) , 1 ) ) self . number_of_annotations = number_of_annotations self . update_header ( ) | Sets the number of annotation signals . The default value is 1 This function is optional and can be called only after opening a file in writemode and before the first sample write action Normally you don t need to change the default value . Only when the number of annotations you want to write is more than the number o... |
233,875 | def setStartdatetime ( self , recording_start_time ) : if isinstance ( recording_start_time , datetime ) : self . recording_start_time = recording_start_time else : self . recording_start_time = datetime . strptime ( recording_start_time , "%d %b %Y %H:%M:%S" ) self . update_header ( ) | Sets the recording start Time |
233,876 | def setSamplefrequency ( self , edfsignal , samplefrequency ) : if edfsignal < 0 or edfsignal > self . n_channels : raise ChannelDoesNotExist ( edfsignal ) self . channels [ edfsignal ] [ 'sample_rate' ] = samplefrequency self . update_header ( ) | Sets the samplefrequency of signal edfsignal . |
233,877 | def setPhysicalMaximum ( self , edfsignal , physical_maximum ) : if edfsignal < 0 or edfsignal > self . n_channels : raise ChannelDoesNotExist ( edfsignal ) self . channels [ edfsignal ] [ 'physical_max' ] = physical_maximum self . update_header ( ) | Sets the physical_maximum of signal edfsignal . |
233,878 | def setPhysicalMinimum ( self , edfsignal , physical_minimum ) : if ( edfsignal < 0 or edfsignal > self . n_channels ) : raise ChannelDoesNotExist ( edfsignal ) self . channels [ edfsignal ] [ 'physical_min' ] = physical_minimum self . update_header ( ) | Sets the physical_minimum of signal edfsignal . |
233,879 | def setDigitalMaximum ( self , edfsignal , digital_maximum ) : if ( edfsignal < 0 or edfsignal > self . n_channels ) : raise ChannelDoesNotExist ( edfsignal ) self . channels [ edfsignal ] [ 'digital_max' ] = digital_maximum self . update_header ( ) | Sets the samplefrequency of signal edfsignal . Usually the value 32767 is used for EDF + and 8388607 for BDF + . |
233,880 | def setTransducer ( self , edfsignal , transducer ) : if ( edfsignal < 0 or edfsignal > self . n_channels ) : raise ChannelDoesNotExist ( edfsignal ) self . channels [ edfsignal ] [ 'transducer' ] = transducer self . update_header ( ) | Sets the transducer of signal edfsignal |
233,881 | def readAnnotations ( self ) : annot = self . read_annotation ( ) annot = np . array ( annot ) if ( annot . shape [ 0 ] == 0 ) : return np . array ( [ ] ) , np . array ( [ ] ) , np . array ( [ ] ) ann_time = self . _get_float ( annot [ : , 0 ] ) ann_text = annot [ : , 2 ] ann_text_out = [ "" for x in range ( len ( anno... | Annotations from a edf - file |
233,882 | def getHeader ( self ) : return { "technician" : self . getTechnician ( ) , "recording_additional" : self . getRecordingAdditional ( ) , "patientname" : self . getPatientName ( ) , "patient_additional" : self . getPatientAdditional ( ) , "patientcode" : self . getPatientCode ( ) , "equipment" : self . getEquipment ( ) ... | Returns the file header as dict |
233,883 | def getSignalHeader ( self , chn ) : return { 'label' : self . getLabel ( chn ) , 'dimension' : self . getPhysicalDimension ( chn ) , 'sample_rate' : self . getSampleFrequency ( chn ) , 'physical_max' : self . getPhysicalMaximum ( chn ) , 'physical_min' : self . getPhysicalMinimum ( chn ) , 'digital_max' : self . getDi... | Returns the header of one signal as dicts |
233,884 | def getSignalHeaders ( self ) : signalHeader = [ ] for chn in np . arange ( self . signals_in_file ) : signalHeader . append ( self . getSignalHeader ( chn ) ) return signalHeader | Returns the header of all signals as array of dicts |
233,885 | def getStartdatetime ( self ) : return datetime ( self . startdate_year , self . startdate_month , self . startdate_day , self . starttime_hour , self . starttime_minute , self . starttime_second ) | Returns the date and starttime as datetime object |
233,886 | def getBirthdate ( self , string = True ) : if string : return self . _convert_string ( self . birthdate . rstrip ( ) ) else : return datetime . strptime ( self . _convert_string ( self . birthdate . rstrip ( ) ) , "%d %b %Y" ) | Returns the birthdate as string object |
233,887 | def getSampleFrequencies ( self ) : return np . array ( [ round ( self . samplefrequency ( chn ) ) for chn in np . arange ( self . signals_in_file ) ] ) | Returns samplefrequencies of all signals . |
233,888 | def getSampleFrequency ( self , chn ) : if 0 <= chn < self . signals_in_file : return round ( self . samplefrequency ( chn ) ) else : return 0 | Returns the samplefrequency of signal edfsignal . |
233,889 | def getPhysicalMaximum ( self , chn = None ) : if chn is not None : if 0 <= chn < self . signals_in_file : return self . physical_max ( chn ) else : return 0 else : physMax = np . zeros ( self . signals_in_file ) for i in np . arange ( self . signals_in_file ) : physMax [ i ] = self . physical_max ( i ) return physMax | Returns the maximum physical value of signal edfsignal . |
233,890 | def getPhysicalMinimum ( self , chn = None ) : if chn is not None : if 0 <= chn < self . signals_in_file : return self . physical_min ( chn ) else : return 0 else : physMin = np . zeros ( self . signals_in_file ) for i in np . arange ( self . signals_in_file ) : physMin [ i ] = self . physical_min ( i ) return physMin | Returns the minimum physical value of signal edfsignal . |
233,891 | def getDigitalMaximum ( self , chn = None ) : if chn is not None : if 0 <= chn < self . signals_in_file : return self . digital_max ( chn ) else : return 0 else : digMax = np . zeros ( self . signals_in_file ) for i in np . arange ( self . signals_in_file ) : digMax [ i ] = self . digital_max ( i ) return digMax | Returns the maximum digital value of signal edfsignal . |
233,892 | def getDigitalMinimum ( self , chn = None ) : if chn is not None : if 0 <= chn < self . signals_in_file : return self . digital_min ( chn ) else : return 0 else : digMin = np . zeros ( self . signals_in_file ) for i in np . arange ( self . signals_in_file ) : digMin [ i ] = self . digital_min ( i ) return digMin | Returns the minimum digital value of signal edfsignal . |
233,893 | def readSignal ( self , chn , start = 0 , n = None ) : if start < 0 : return np . array ( [ ] ) if n is not None and n < 0 : return np . array ( [ ] ) nsamples = self . getNSamples ( ) if chn < len ( nsamples ) : if n is None : n = nsamples [ chn ] elif n > nsamples [ chn ] : return np . array ( [ ] ) x = np . zeros ( ... | Returns the physical data of signal chn . When start and n is set a subset is returned |
233,894 | def stackplot ( marray , seconds = None , start_time = None , ylabels = None ) : tarray = np . transpose ( marray ) stackplot_t ( tarray , seconds = seconds , start_time = start_time , ylabels = ylabels ) plt . show ( ) | will plot a stack of traces one above the other assuming marray . shape = numRows numSamples |
233,895 | def stackplot_t ( tarray , seconds = None , start_time = None , ylabels = None ) : data = tarray numSamples , numRows = tarray . shape if seconds : t = seconds * np . arange ( numSamples , dtype = float ) / numSamples if start_time : t = t + start_time xlm = ( start_time , start_time + seconds ) else : xlm = ( 0 , seco... | will plot a stack of traces one above the other assuming tarray . shape = numSamples numRows |
233,896 | def find_path ( start , goal , neighbors_fnct , reversePath = False , heuristic_cost_estimate_fnct = lambda a , b : Infinite , distance_between_fnct = lambda a , b : 1.0 , is_goal_reached_fnct = lambda a , b : a == b ) : class FindPath ( AStar ) : def heuristic_cost_estimate ( self , current , goal ) : return heuristic... | A non - class version of the path finding algorithm |
233,897 | def validate ( source , ** options ) : source , options , inspector_settings = _parse_arguments ( source , ** options ) inspector = Inspector ( ** inspector_settings ) report = inspector . inspect ( source , ** options ) return report | Validates a source file and returns a report . |
233,898 | def init_datapackage ( resource_paths ) : dp = datapackage . Package ( { 'name' : 'change-me' , 'schema' : 'tabular-data-package' , } ) for path in resource_paths : dp . infer ( path ) return dp | Create tabular data package with resources . |
233,899 | def init ( paths , output , ** kwargs ) : dp = goodtables . init_datapackage ( paths ) click . secho ( json_module . dumps ( dp . descriptor , indent = 4 ) , file = output ) exit ( dp . valid ) | Init data package from list of files . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.