idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
35,300 | def watch_activations ( self , flag ) : lib . EnvSetDefruleWatchActivations ( self . _env , int ( flag ) , self . _rule ) | Whether or not the Rule Activations are being watched . |
35,301 | def matches ( self , verbosity = Verbosity . TERSE ) : data = clips . data . DataObject ( self . _env ) lib . EnvMatches ( self . _env , self . _rule , verbosity , data . byref ) return tuple ( data . value ) | Shows partial matches and activations . |
35,302 | def refresh ( self ) : if lib . EnvRefresh ( self . _env , self . _rule ) != 1 : raise CLIPSError ( self . _env ) | Refresh the Rule . |
35,303 | def undefine ( self ) : if lib . EnvUndefrule ( self . _env , self . _rule ) != 1 : raise CLIPSError ( self . _env ) self . _env = None | Undefine the Rule . |
35,304 | def name ( self ) : return ffi . string ( lib . EnvGetActivationName ( self . _env , self . _act ) ) . decode ( ) | Activation Rule name . |
35,305 | def salience ( self , salience ) : lib . EnvSetActivationSalience ( self . _env , self . _act , salience ) | Activation salience value . |
35,306 | def delete ( self ) : if lib . EnvDeleteActivation ( self . _env , self . _act ) != 1 : raise CLIPSError ( self . _env ) self . _env = None | Remove the activation from the agenda . |
35,307 | def globals_changed ( self ) : value = bool ( lib . EnvGetGlobalsChanged ( self . _env ) ) lib . EnvSetGlobalsChanged ( self . _env , int ( False ) ) return value | True if any Global has changed . |
35,308 | def find_global ( self , name ) : defglobal = lib . EnvFindDefglobal ( self . _env , name . encode ( ) ) if defglobal == ffi . NULL : raise LookupError ( "Global '%s' not found" % name ) return Global ( self . _env , defglobal ) | Find the Global by its name . |
35,309 | def modules ( self ) : defmodule = lib . EnvGetNextDefmodule ( self . _env , ffi . NULL ) while defmodule != ffi . NULL : yield Module ( self . _env , defmodule ) defmodule = lib . EnvGetNextDefmodule ( self . _env , defmodule ) | Iterates over the defined Modules . |
35,310 | def find_module ( self , name ) : defmodule = lib . EnvFindDefmodule ( self . _env , name . encode ( ) ) if defmodule == ffi . NULL : raise LookupError ( "Module '%s' not found" % name ) return Module ( self . _env , defmodule ) | Find the Module by its name . |
35,311 | def value ( self ) : data = clips . data . DataObject ( self . _env ) if lib . EnvGetDefglobalValue ( self . _env , self . name . encode ( ) , data . byref ) != 1 : raise CLIPSError ( self . _env ) return data . value | Global value . |
35,312 | def module ( self ) : modname = ffi . string ( lib . EnvDefglobalModule ( self . _env , self . _glb ) ) defmodule = lib . EnvFindDefmodule ( self . _env , modname ) return Module ( self . _env , defmodule ) | The module in which the Global is defined . |
35,313 | def watch ( self , flag ) : lib . EnvSetDefglobalWatch ( self . _env , int ( flag ) , self . _glb ) | Whether or not the Global is being watched . |
35,314 | def undefine ( self ) : if lib . EnvUndefglobal ( self . _env , self . _glb ) != 1 : raise CLIPSError ( self . _env ) self . _env = None | Undefine the Global . |
35,315 | def find_function ( self , name ) : deffunction = lib . EnvFindDeffunction ( self . _env , name . encode ( ) ) if deffunction == ffi . NULL : raise LookupError ( "Function '%s' not found" % name ) return Function ( self . _env , deffunction ) | Find the Function by its name . |
35,316 | def generics ( self ) : defgeneric = lib . EnvGetNextDefgeneric ( self . _env , ffi . NULL ) while defgeneric != ffi . NULL : yield Generic ( self . _env , defgeneric ) defgeneric = lib . EnvGetNextDefgeneric ( self . _env , defgeneric ) | Iterates over the defined Generics . |
35,317 | def find_generic ( self , name ) : defgeneric = lib . EnvFindDefgeneric ( self . _env , name . encode ( ) ) if defgeneric == ffi . NULL : raise LookupError ( "Generic '%s' not found" % name ) return Generic ( self . _env , defgeneric ) | Find the Generic by its name . |
35,318 | def name ( self ) : return ffi . string ( lib . EnvGetDeffunctionName ( self . _env , self . _fnc ) ) . decode ( ) | Function name . |
35,319 | def module ( self ) : modname = ffi . string ( lib . EnvDeffunctionModule ( self . _env , self . _fnc ) ) defmodule = lib . EnvFindDefmodule ( self . _env , modname ) return Module ( self . _env , defmodule ) | The module in which the Function is defined . |
35,320 | def watch ( self , flag ) : lib . EnvSetDeffunctionWatch ( self . _env , int ( flag ) , self . _fnc ) | Whether or not the Function is being watched . |
35,321 | def undefine ( self ) : if lib . EnvUndeffunction ( self . _env , self . _fnc ) != 1 : raise CLIPSError ( self . _env ) self . _env = None | Undefine the Function . |
35,322 | def undefine ( self ) : if lib . EnvUndefgeneric ( self . _env , self . _gnc ) != 1 : raise CLIPSError ( self . _env ) self . _env = None | Undefine the Generic . |
35,323 | def undefine ( self ) : if lib . EnvUndefmethod ( self . _env , self . _gnc , self . _idx ) != 1 : raise CLIPSError ( self . _env ) self . _env = None | Undefine the Method . |
35,324 | def selection_std ( populations , low = None , high = None , n_std_low = 2.5 , n_std_high = 2.5 , scale = 'logicle' ) : if scale == 'linear' : sf = lambda x : x elif scale == 'log' : sf = np . log10 elif scale == 'logicle' : t = FlowCal . plot . _LogicleTransform ( data = populations [ 0 ] , channel = 0 ) . inverted ( ... | Select populations if most of their elements are between two values . |
35,325 | def fit_beads_autofluorescence ( fl_rfi , fl_mef ) : if len ( fl_rfi ) != len ( fl_mef ) : raise ValueError ( "fl_rfi and fl_mef have different lengths" ) if len ( fl_rfi ) <= 2 : raise ValueError ( "standard curve model requires at least three " "values" ) params = np . zeros ( 3 ) params [ 0 ] = ( np . log ( fl_mef [... | Fit a standard curve using a beads model with autofluorescence . |
35,326 | def plot_standard_curve ( fl_rfi , fl_mef , beads_model , std_crv , xscale = 'linear' , yscale = 'linear' , xlim = None , ylim = ( 1. , 1e8 ) ) : plt . plot ( fl_rfi , fl_mef , 'o' , label = 'Beads' , color = standard_curve_colors [ 0 ] ) if xlim is None : xlim = plt . xlim ( ) if xscale == 'linear' : xdata = np . lins... | Plot a standard curve with fluorescence of calibration beads . |
35,327 | def read_table ( filename , sheetname , index_col = None ) : if sheetname is None or ( hasattr ( sheetname , '__iter__' ) and not isinstance ( sheetname , six . string_types ) ) : raise TypeError ( "sheetname should specify a single sheet" ) if packaging . version . parse ( pd . __version__ ) < packaging . version . pa... | Return the contents of an Excel table as a pandas DataFrame . |
35,328 | def write_workbook ( filename , table_list , column_width = None ) : format_module_found = False try : if packaging . version . parse ( pd . __version__ ) <= packaging . version . parse ( '0.18' ) : format_module = pd . core . format elif packaging . version . parse ( pd . __version__ ) < packaging . version . parse ( ... | Write an Excel workbook from a list of tables . |
35,329 | def generate_histograms_table ( samples_table , samples , max_bins = 1024 ) : headers = list ( samples_table . columns ) hist_headers = [ h for h in headers if re_units . match ( h ) ] hist_channels = [ re_units . match ( h ) . group ( 1 ) for h in hist_headers ] n_columns = 0 for sample_id , sample in zip ( samples_ta... | Generate a table of histograms as a DataFrame . |
35,330 | def generate_about_table ( extra_info = { } ) : keywords = [ ] values = [ ] keywords . append ( 'FlowCal version' ) values . append ( FlowCal . __version__ ) keywords . append ( 'Date of analysis' ) values . append ( time . strftime ( "%Y/%m/%d" ) ) keywords . append ( 'Time of analysis' ) values . append ( time . strf... | Make a table with information about FlowCal and the current analysis . |
35,331 | def show_open_file_dialog ( filetypes ) : Tk ( ) . withdraw ( ) if platform . system ( ) == 'Darwin' : subprocess . call ( "defaults write org.python.python " + "ApplePersistenceIgnoreState YES" , shell = True ) filename = askopenfilename ( filetypes = filetypes ) subprocess . call ( "defaults write org.python.python "... | Show an open file dialog and return the path of the file selected . |
35,332 | def run ( input_path = None , output_path = None , verbose = True , plot = True , hist_sheet = False ) : if input_path is None : input_path = show_open_file_dialog ( filetypes = [ ( 'Excel files' , '*.xlsx' ) ] ) if not input_path : if verbose : print ( "No input file selected." ) return input_dir , input_filename = os... | Run the MS Excel User Interface . |
35,333 | def run_command_line ( args = None ) : if args is None : args = sys . argv [ 1 : ] import argparse parser = argparse . ArgumentParser ( description = "process flow cytometry files with FlowCal's Excel UI." ) parser . add_argument ( "-i" , "--inputpath" , type = str , nargs = '?' , help = "input Excel file name. If not ... | Entry point for the FlowCal and flowcal console scripts . |
35,334 | def read_fcs_header_segment ( buf , begin = 0 ) : fields = [ 'version' , 'text_begin' , 'text_end' , 'data_begin' , 'data_end' , 'analysis_begin' , 'analysis_end' ] FCSHeader = collections . namedtuple ( 'FCSHeader' , fields ) field_values = [ ] buf . seek ( begin ) field_values . append ( buf . read ( 10 ) . decode ( ... | Read HEADER segment of FCS file . |
35,335 | def read_fcs_text_segment ( buf , begin , end , delim = None , supplemental = False ) : if delim is None : if supplemental : raise ValueError ( "must specify ``delim`` if reading supplemental" + " TEXT segment" ) else : buf . seek ( begin ) delim = buf . read ( 1 ) . decode ( encoding ) buf . seek ( begin ) raw = buf .... | Read TEXT segment of FCS file . |
35,336 | def acquisition_time ( self ) : time_channel_idx = [ idx for idx , channel in enumerate ( self . channels ) if channel . lower ( ) == 'time' ] if len ( time_channel_idx ) > 1 : raise KeyError ( "more than one time channel in data" ) elif len ( time_channel_idx ) == 1 : time_channel = self . channels [ time_channel_idx ... | Acquisition time in seconds . |
35,337 | def _parse_time_string ( time_str ) : if time_str is None : return None time_l = time_str . split ( ':' ) if len ( time_l ) == 3 : if '.' in time_l [ 2 ] : time_str = time_str . replace ( '.' , ':' ) else : time_str = time_str + ':0' try : t = datetime . datetime . strptime ( time_str , '%H:%M:%S:%f' ) . time ( ) excep... | Get a datetime . time object from a string time representation . |
35,338 | def _parse_date_string ( date_str ) : if date_str is None : return None try : return datetime . datetime . strptime ( date_str , '%d-%b-%y' ) except ValueError : pass try : return datetime . datetime . strptime ( date_str , '%d-%b-%Y' ) except ValueError : pass try : return datetime . datetime . strptime ( date_str , '... | Get a datetime . date object from a string date representation . |
35,339 | def _name_to_index ( self , channels ) : if hasattr ( channels , '__iter__' ) and not isinstance ( channels , six . string_types ) : return [ self . _name_to_index ( ch ) for ch in channels ] if isinstance ( channels , six . string_types ) : if channels in self . channels : return self . channels . index ( channels ) e... | Return the channel indices for the specified channel names . |
35,340 | def find_version ( file_path ) : with open ( file_path , 'r' ) as f : file_contents = f . read ( ) version_match = re . search ( r"^__version__\s*=\s*['\"]([^'\"]*)['\"]" , file_contents , re . M ) if version_match : return version_match . group ( 1 ) else : raise RuntimeError ( "unable to find version string" ) | Scrape version information from specified file path . |
35,341 | def start_end ( data , num_start = 250 , num_end = 100 , full_output = False ) : if num_start < 0 : num_start = 0 if num_end < 0 : num_end = 0 if data . shape [ 0 ] < ( num_start + num_end ) : raise ValueError ( 'Number of events to discard greater than total' + ' number of events.' ) mask = np . ones ( shape = data . ... | Gate out first and last events . |
35,342 | def high_low ( data , channels = None , high = None , low = None , full_output = False ) : if channels is None : data_ch = data else : data_ch = data [ : , channels ] if data_ch . ndim == 1 : data_ch = data_ch . reshape ( ( - 1 , 1 ) ) if high is None : if hasattr ( data_ch , 'range' ) : high = [ np . Inf if di is None... | Gate out high and low values across all specified channels . |
35,343 | def ellipse ( data , channels , center , a , b , theta = 0 , log = False , full_output = False ) : if len ( channels ) != 2 : raise ValueError ( '2 channels should be specified.' ) data_ch = data [ : , channels ] . view ( np . ndarray ) if log : data_ch = np . log10 ( data_ch ) center = np . array ( center ) data_cente... | Gate that preserves events inside an ellipse - shaped region . |
35,344 | def transform ( data , channels , transform_fxn , def_channels = None ) : data_t = data . copy ( ) . astype ( np . float64 ) if channels is None : if def_channels is None : channels = range ( data_t . shape [ 1 ] ) else : channels = def_channels if not ( hasattr ( channels , '__iter__' ) and not isinstance ( channels ,... | Apply some transformation function to flow cytometry data . |
35,345 | def to_mef ( data , channels , sc_list , sc_channels = None ) : if sc_channels is None : if data . ndim == 1 : sc_channels = range ( data . shape [ 0 ] ) else : sc_channels = range ( data . shape [ 1 ] ) if len ( sc_channels ) != len ( sc_list ) : raise ValueError ( "sc_channels and sc_list should have the same length"... | Transform flow cytometry data using a standard curve function . |
35,346 | def scatter3d_and_projections ( data_list , channels = [ 0 , 1 , 2 ] , xscale = 'logicle' , yscale = 'logicle' , zscale = 'logicle' , xlabel = None , ylabel = None , zlabel = None , xlim = None , ylim = None , zlim = None , color = None , figsize = None , savefig = None , ** kwargs ) : if len ( channels ) != 3 : raise ... | Plot a 3D scatter plot and 2D projections from FCSData objects . |
35,347 | def transform_non_affine ( self , x , mask_out_of_range = True ) : if mask_out_of_range : x_masked = np . ma . masked_where ( ( x < self . _xmin ) | ( x > self . _xmax ) , x ) else : x_masked = x return np . interp ( x_masked , self . _x_range , self . _s_range ) | Transform a Nx1 numpy array . |
35,348 | def transform_non_affine ( self , s ) : T = self . _T M = self . _M W = self . _W p = self . _p return T * 10 ** ( - ( M - W ) ) * ( 10 ** ( s - W ) - ( p ** 2 ) * 10 ** ( - ( s - W ) / p ) + p ** 2 - 1 ) | Apply transformation to a Nx1 numpy array . |
35,349 | def set_params ( self , subs = None , numticks = None ) : if numticks is not None : self . numticks = numticks if subs is not None : self . _subs = subs | Set parameters within this locator . |
35,350 | def view_limits ( self , vmin , vmax ) : b = self . _transform . base if vmax < vmin : vmin , vmax = vmax , vmin if not matplotlib . ticker . is_decade ( abs ( vmin ) , b ) : if vmin < 0 : vmin = - matplotlib . ticker . decade_up ( - vmin , b ) else : vmin = matplotlib . ticker . decade_down ( vmin , b ) if not matplot... | Try to choose the view limits intelligently . |
35,351 | def get_transform ( self ) : return _InterpolatedInverseTransform ( transform = self . _transform , smin = 0 , smax = self . _transform . _M ) | Get a new object to perform the scaling transformation . |
35,352 | def set_default_locators_and_formatters ( self , axis ) : axis . set_major_locator ( _LogicleLocator ( self . _transform ) ) axis . set_minor_locator ( _LogicleLocator ( self . _transform , subs = np . arange ( 2.0 , 10. ) ) ) axis . set_major_formatter ( matplotlib . ticker . LogFormatterSciNotation ( labelOnlyBase = ... | Set up the locators and formatters for the scale . |
35,353 | def limit_range_for_scale ( self , vmin , vmax , minpos ) : vmin_bound = self . _transform . transform_non_affine ( 0 ) vmax_bound = self . _transform . transform_non_affine ( self . _transform . M ) vmin = max ( vmin , vmin_bound ) vmax = min ( vmax , vmax_bound ) return vmin , vmax | Return minimum and maximum bounds for the logicle axis . |
35,354 | def mean ( data , channels = None ) : if channels is None : data_stats = data else : data_stats = data [ : , channels ] return np . mean ( data_stats , axis = 0 ) | Calculate the mean of the events in an FCSData object . |
35,355 | def gmean ( data , channels = None ) : if channels is None : data_stats = data else : data_stats = data [ : , channels ] return scipy . stats . gmean ( data_stats , axis = 0 ) | Calculate the geometric mean of the events in an FCSData object . |
35,356 | def median ( data , channels = None ) : if channels is None : data_stats = data else : data_stats = data [ : , channels ] return np . median ( data_stats , axis = 0 ) | Calculate the median of the events in an FCSData object . |
35,357 | def mode ( data , channels = None ) : if channels is None : data_stats = data else : data_stats = data [ : , channels ] return scipy . stats . mode ( data_stats , axis = 0 ) [ 0 ] [ 0 ] | Calculate the mode of the events in an FCSData object . |
35,358 | def std ( data , channels = None ) : if channels is None : data_stats = data else : data_stats = data [ : , channels ] return np . std ( data_stats , axis = 0 ) | Calculate the standard deviation of the events in an FCSData object . |
35,359 | def cv ( data , channels = None ) : if channels is None : data_stats = data else : data_stats = data [ : , channels ] return np . std ( data_stats , axis = 0 ) / np . mean ( data_stats , axis = 0 ) | Calculate the Coeff . of Variation of the events in an FCSData object . |
35,360 | def gstd ( data , channels = None ) : if channels is None : data_stats = data else : data_stats = data [ : , channels ] return np . exp ( np . std ( np . log ( data_stats ) , axis = 0 ) ) | Calculate the geometric std . dev . of the events in an FCSData object . |
35,361 | def gcv ( data , channels = None ) : if channels is None : data_stats = data else : data_stats = data [ : , channels ] return np . sqrt ( np . exp ( np . std ( np . log ( data_stats ) , axis = 0 ) ** 2 ) - 1 ) | Calculate the geometric CV of the events in an FCSData object . |
35,362 | def iqr ( data , channels = None ) : if channels is None : data_stats = data else : data_stats = data [ : , channels ] q75 , q25 = np . percentile ( data_stats , [ 75 , 25 ] , axis = 0 ) return q75 - q25 | Calculate the Interquartile Range of the events in an FCSData object . |
35,363 | def rcv ( data , channels = None ) : if channels is None : data_stats = data else : data_stats = data [ : , channels ] q75 , q25 = np . percentile ( data_stats , [ 75 , 25 ] , axis = 0 ) return ( q75 - q25 ) / np . median ( data_stats , axis = 0 ) | Calculate the RCV of the events in an FCSData object . |
35,364 | def convert_tree ( message , config , indent = 0 , wrap_alternative = True , charset = None ) : ct = message . get_content_type ( ) cs = message . get_content_subtype ( ) if charset is None : charset = get_charset_from_message_fragment ( message ) if not message . is_multipart ( ) : converted = None disposition = messa... | Recursively convert a potentially - multipart tree . |
35,365 | def smtp_connection ( c ) : if c . smtp_ssl : klass = smtplib . SMTP_SSL else : klass = smtplib . SMTP conn = klass ( c . smtp_host , c . smtp_port , timeout = c . smtp_timeout ) if not c . smtp_ssl : conn . ehlo ( ) conn . starttls ( ) conn . ehlo ( ) if c . smtp_username : conn . login ( c . smtp_username , c . smtp_... | Create an SMTP connection from a Config object |
35,366 | def issuers ( self ) : issuers = self . _get_property ( 'issuers' ) or [ ] result = { '_embedded' : { 'issuers' : issuers , } , 'count' : len ( issuers ) , } return List ( result , Issuer ) | Return the list of available issuers for this payment method . |
35,367 | def delete ( self , payment_id , data = None ) : if not payment_id or not payment_id . startswith ( self . RESOURCE_ID_PREFIX ) : raise IdentifierError ( "Invalid payment ID: '{id}'. A payment ID should start with '{prefix}'." . format ( id = payment_id , prefix = self . RESOURCE_ID_PREFIX ) ) result = super ( Payments... | Cancel payment and return the payment object . |
35,368 | def mandate ( self ) : return self . client . customer_mandates . with_parent_id ( self . customer_id ) . get ( self . mandate_id ) | Return the mandate for this payment . |
35,369 | def subscription ( self ) : return self . client . customer_subscriptions . with_parent_id ( self . customer_id ) . get ( self . subscription_id ) | Return the subscription for this payment . |
35,370 | def order ( self ) : from . . resources . orders import Order url = self . _get_link ( 'order' ) if url : resp = self . client . orders . perform_api_call ( self . client . orders . REST_READ , url ) return Order ( resp , self . client ) | Return the order for this payment . |
35,371 | def create_refund ( self , data = None , ** params ) : if data is None : data = { 'lines' : [ ] } refund = OrderRefunds ( self . client ) . on ( self ) . create ( data , ** params ) return refund | Create a refund for the order . When no data arg is given a refund for all order lines is assumed . |
35,372 | def cancel_lines ( self , data = None ) : from . . resources . order_lines import OrderLines if data is None : data = { 'lines' : [ ] } canceled = OrderLines ( self . client ) . on ( self ) . delete ( data ) return canceled | Cancel the lines given . When no lines are given cancel all the lines . |
35,373 | def update_line ( self , resource_id , data ) : return OrderLines ( self . client ) . on ( self ) . update ( resource_id , data ) | Update a line for an order . |
35,374 | def create_shipment ( self , data = None ) : if data is None : data = { 'lines' : [ ] } return Shipments ( self . client ) . on ( self ) . create ( data ) | Create a shipment for an order . When no data arg is given a shipment for all order lines is assumed . |
35,375 | def get_shipment ( self , resource_id ) : return Shipments ( self . client ) . on ( self ) . get ( resource_id ) | Retrieve a single shipment by a shipment s ID . |
35,376 | def update_shipment ( self , resource_id , data ) : return Shipments ( self . client ) . on ( self ) . update ( resource_id , data ) | Update the tracking information of a shipment . |
35,377 | def create_payment ( self , data ) : return OrderPayments ( self . client ) . on ( self ) . create ( data ) | Creates a new payment object for an order . |
35,378 | def delete ( self , data , * args ) : path = self . get_resource_name ( ) result = self . perform_api_call ( self . REST_DELETE , path , data = data ) return result | Custom handling for deleting orderlines . |
35,379 | def update ( self , resource_id , data = None , ** params ) : path = self . get_resource_name ( ) + '/' + str ( resource_id ) result = self . perform_api_call ( self . REST_UPDATE , path , data = data ) for line in result [ 'lines' ] : if line [ 'id' ] == resource_id : return self . get_resource_object ( line ) raise D... | Custom handling for updating orderlines . |
35,380 | def get_next ( self ) : url = self . _get_link ( 'next' ) resource = self . object_type . get_resource_class ( self . client ) resp = resource . perform_api_call ( resource . REST_READ , url ) return List ( resp , self . object_type , self . client ) | Return the next set of objects in a list |
35,381 | def delete ( self , subscription_id , data = None ) : if not subscription_id or not subscription_id . startswith ( self . RESOURCE_ID_PREFIX ) : raise IdentifierError ( "Invalid subscription ID: '{id}'. A subscription ID should start with '{prefix}'." . format ( id = subscription_id , prefix = self . RESOURCE_ID_PREFIX... | Cancel subscription and return the subscription object . |
35,382 | def get ( self , chargeback_id , ** params ) : if not chargeback_id or not chargeback_id . startswith ( self . RESOURCE_ID_PREFIX ) : raise IdentifierError ( "Invalid chargeback ID: '{id}'. A chargeback ID should start with '{prefix}'." . format ( id = chargeback_id , prefix = self . RESOURCE_ID_PREFIX ) ) return super... | Verify the chargeback ID and retrieve the chargeback from the API . |
35,383 | def generate_querystring ( params ) : if not params : return None parts = [ ] for param , value in sorted ( params . items ( ) ) : if not isinstance ( value , dict ) : parts . append ( urlencode ( { param : value } ) ) else : for key , sub_value in sorted ( value . items ( ) ) : composed = '{param}[{key}]' . format ( p... | Generate a querystring suitable for use in the v2 api . |
35,384 | def set_user_agent_component ( self , key , value , sanitize = True ) : if sanitize : key = '' . join ( _x . capitalize ( ) for _x in re . findall ( r'\S+' , key ) ) if re . search ( r'\s+' , value ) : value = '_' . join ( re . findall ( r'\S+' , value ) ) self . user_agent_components [ key ] = value | Add or replace new user - agent component strings . |
35,385 | def user_agent ( self ) : components = [ "/" . join ( x ) for x in self . user_agent_components . items ( ) ] return " " . join ( components ) | Return the formatted user agent string . |
35,386 | def factory ( resp ) : status = resp [ 'status' ] if status == 401 : return UnauthorizedError ( resp ) elif status == 404 : return NotFoundError ( resp ) elif status == 422 : return UnprocessableEntityError ( resp ) else : return ResponseError ( resp ) | Return a ResponseError subclass based on the API payload . |
35,387 | def delete ( self , order_id , data = None ) : if not order_id or not order_id . startswith ( self . RESOURCE_ID_PREFIX ) : raise IdentifierError ( "Invalid order ID: '{id}'. An order ID should start with '{prefix}'." . format ( id = order_id , prefix = self . RESOURCE_ID_PREFIX ) ) result = super ( Orders , self ) . d... | Cancel order and return the order object . |
35,388 | def customer ( self ) : url = self . _get_link ( 'customer' ) if url : resp = self . client . customers . perform_api_call ( self . client . customers . REST_READ , url ) return Customer ( resp ) | Return the customer for this subscription . |
35,389 | def payments ( self ) : payments = self . client . subscription_payments . on ( self ) . list ( ) return payments | Return a list of payments for this subscription . |
35,390 | def list_permissions ( self , group_name = None , resource = None , url_prefix = None , auth = None , session = None , send_opts = None ) : filter_params = { } if group_name : filter_params [ "group" ] = group_name if resource : filter_params . update ( resource . get_dict_route ( ) ) req = self . get_permission_reques... | List the permission sets for the logged in user |
35,391 | def list ( self , resource , url_prefix , auth , session , send_opts ) : req = self . get_request ( resource , 'GET' , 'application/json' , url_prefix , auth , proj_list_req = True ) prep = session . prepare_request ( req ) resp = session . send ( prep , ** send_opts ) if resp . status_code == 200 : return self . _get_... | List all resources of the same type as the given resource . |
35,392 | def _get_resource_params ( self , resource , for_update = False ) : if isinstance ( resource , CollectionResource ) : return self . _get_collection_params ( resource ) if isinstance ( resource , ExperimentResource ) : return self . _get_experiment_params ( resource , for_update ) if isinstance ( resource , CoordinateFr... | Get dictionary containing all parameters for the given resource . |
35,393 | def _get_resource_list ( self , rsrc_dict ) : if 'collections' in rsrc_dict : return rsrc_dict [ 'collections' ] if 'experiments' in rsrc_dict : return rsrc_dict [ 'experiments' ] if 'channels' in rsrc_dict : return rsrc_dict [ 'channels' ] if 'coords' in rsrc_dict : return rsrc_dict [ 'coords' ] raise RuntimeError ( '... | Extracts list of resources from the HTTP response . |
35,394 | def check_version ( ) : import requests r = requests . get ( 'https://pypi.python.org/pypi/intern/json' ) . json ( ) r = r [ 'info' ] [ 'version' ] if r != __version__ : print ( "You are using version {}. A newer version of intern is available: {} " . format ( __version__ , r ) + "\n\n'pip install -U intern' to update.... | Tells you if you have an old version of intern . |
35,395 | def check_channel ( fcn ) : def wrapper ( * args , ** kwargs ) : if not isinstance ( args [ 1 ] , ChannelResource ) : raise RuntimeError ( 'resource must be an instance of intern.resource.boss.ChannelResource.' ) if not args [ 1 ] . cutout_ready : raise PartialChannelResourceError ( 'ChannelResource not fully initializ... | Decorator that ensures a valid channel passed in . |
35,396 | def create ( self , resource , keys_vals , url_prefix , auth , session , send_opts ) : success = True exc = HTTPErrorList ( 'At least one key-value create failed.' ) for pair in keys_vals . items ( ) : key = pair [ 0 ] value = pair [ 1 ] req = self . get_metadata_request ( resource , 'POST' , 'application/json' , url_p... | Create the given key - value pairs for the given resource . |
35,397 | def get_bit_width ( self , resource ) : datatype = resource . datatype if "uint" in datatype : bit_width = int ( datatype . split ( "uint" ) [ 1 ] ) else : raise ValueError ( "Unsupported datatype: {}" . format ( datatype ) ) return bit_width | Method to return the bit width for blosc based on the Resource |
35,398 | def get_graphviz_dot ( machine ) : s = [ ] s . append ( 'digraph G {\n' ) s . append ( 'node [shape=box style=rounded fontname=Helvetica];\n' ) s . append ( 'edge [ fontname=Helvetica ];\n' ) s . append ( 'initial [shape=point width=0.2];\n' ) counter = 1 for t_id in machine . _table : transition = machine . _table [ t... | Return the graph of the state machine . |
35,399 | def _parse_arg_list ( arglist ) : args = [ ] for arg in arglist . split ( ',' ) : arg = arg . strip ( ) if arg : args . append ( eval ( arg ) ) return args | Parses a list of arguments . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.