idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
14,400 | def create_tags ( self , entry ) : tag_list = [ t . lower ( ) . strip ( ) for t in entry . tag_string . split ( ',' ) ] for t in tag_list : tag , created = self . get_or_create ( name = t ) entry . tags . add ( tag ) | Inspects an Entry instance and builds associates Tag objects based on the values in the Entry s tag_string . |
14,401 | def _create_date_slug ( self ) : if not self . pk : d = utc_now ( ) elif self . published and self . published_on : d = self . published_on elif self . updated_on : d = self . updated_on self . date_slug = u"{0}/{1}" . format ( d . strftime ( "%Y/%m/%d" ) , self . slug ) | Prefixes the slug with the published_on date . |
14,402 | def _render_content ( self ) : if self . content_format == "rst" and docutils_publish is not None : doc_parts = docutils_publish ( source = self . raw_content , writer_name = "html4css1" ) self . rendered_content = doc_parts [ 'fragment' ] elif self . content_format == "rs" and docutils_publish is None : raise RuntimeE... | Renders the content according to the content_format . |
14,403 | def save ( self , * args , ** kwargs ) : self . _create_slug ( ) self . _create_date_slug ( ) self . _render_content ( ) send_published_signal = False if self . published and self . published_on is None : send_published_signal = self . _set_published ( ) super ( Entry , self ) . save ( * args , ** kwargs ) if send_publ... | Auto - generate a slug from the name . |
14,404 | def get_absolute_url_with_date ( self ) : pub_date = self . published_on if pub_date and settings . USE_TZ : pub_date = make_naive ( pub_date , pytz . utc ) pub_date = pytz . timezone ( settings . TIME_ZONE ) . localize ( pub_date ) if pub_date : args = [ pub_date . strftime ( "%Y" ) , pub_date . strftime ( "%m" ) , pu... | URL based on the entry s date & slug . |
14,405 | def tag_list ( self ) : tags = [ tag . strip ( ) for tag in self . tag_string . split ( "," ) ] return sorted ( filter ( None , tags ) ) | Return a plain python list containing all of this Entry s tags . |
14,406 | def heartbeat ( self ) : url = urljoin ( self . base_url , 'heartbeat' ) return self . session . get ( url ) . json ( ) [ 'ok' ] | Check The API Is Up . |
14,407 | def venue_healthcheck ( self ) : url = urljoin ( self . base_url , 'venues/TESTEX/heartbeat' ) return self . session . get ( url ) . json ( ) [ 'ok' ] | Check A Venue Is Up . |
14,408 | def venue_stocks ( self ) : url = urljoin ( self . base_url , 'venues/{0}/stocks' . format ( self . venue ) ) return self . session . get ( url ) . json ( ) | List the stocks available for trading on the venue . |
14,409 | def orderbook_for_stock ( self , stock ) : url_fragment = 'venues/{venue}/stocks/{stock}' . format ( venue = self . venue , stock = stock , ) url = urljoin ( self . base_url , url_fragment ) return self . session . get ( url ) . json ( ) | Get the orderbook for a particular stock . |
14,410 | def place_new_order ( self , stock , price , qty , direction , order_type ) : url_fragment = 'venues/{venue}/stocks/{stock}/orders' . format ( venue = self . venue , stock = stock , ) data = { "stock" : stock , "price" : price , "venue" : self . venue , "account" : self . account , "qty" : qty , "direction" : direction... | Place an order for a stock . |
14,411 | def status_for_order ( self , order_id , stock ) : url_fragment = 'venues/{venue}/stocks/{stock}/orders/{order_id}' . format ( venue = self . venue , stock = stock , order_id = order_id , ) url = urljoin ( self . base_url , url_fragment ) return self . session . get ( url ) . json ( ) | Status For An Existing Order |
14,412 | def cancel_order ( self , order_id , stock ) : url_fragment = 'venues/{venue}/stocks/{stock}/orders/{order_id}' . format ( venue = self . venue , stock = stock , order_id = order_id , ) url = urljoin ( self . base_url , url_fragment ) return self . session . delete ( url ) . json ( ) | Cancel An Order |
14,413 | def status_for_all_orders ( self ) : url_fragment = 'venues/{venue}/accounts/{account}/orders' . format ( venue = self . venue , account = self . account , ) url = urljoin ( self . base_url , url_fragment ) return self . session . get ( url ) . json ( ) | Status for all orders |
14,414 | def status_for_all_orders_in_a_stock ( self , stock ) : url_fragment = 'venues/{venue}/accounts/{account}/stocks/{stock}/orders' . format ( stock = stock , venue = self . venue , account = self . account , ) url = urljoin ( self . base_url , url_fragment ) return self . session . get ( url ) . json ( ) | Status for all orders in a stock |
14,415 | def scan_django_settings ( values , imports ) : if isinstance ( values , ( str , bytes ) ) : if utils . is_import_str ( values ) : imports . add ( values ) elif isinstance ( values , dict ) : for k , v in values . items ( ) : scan_django_settings ( k , imports ) scan_django_settings ( v , imports ) elif hasattr ( value... | Recursively scans Django settings for values that appear to be imported modules . |
14,416 | def handle_django_settings ( filename ) : old_sys_path = sys . path [ : ] dirpath = os . path . dirname ( filename ) project = os . path . basename ( dirpath ) cwd = os . getcwd ( ) project_path = os . path . normpath ( os . path . join ( dirpath , '..' ) ) if project_path not in sys . path : sys . path . insert ( 0 , ... | Attempts to load a Django project and get package dependencies from settings . |
14,417 | def _url ( endpoint : str , sandbox : bool = False ) -> str : if sandbox is True : url = BASE_URL_SANDBOX else : url = BASE_URL return "{0}{1}" . format ( url , endpoint ) | Build a URL from the API s base URLs . |
14,418 | def update ( self , goal : Dict = None ) -> None : if goal is None : endpoint = "/account/{0}/savings-goals/{1}" . format ( self . _account_uid , self . uid ) response = get ( _url ( endpoint , self . _sandbox ) , headers = self . _auth_headers ) response . raise_for_status ( ) goal = response . json ( ) self . uid = g... | Update a single savings goals data . |
14,419 | def deposit ( self , deposit_minor_units : int ) -> None : endpoint = "/account/{0}/savings-goals/{1}/add-money/{2}" . format ( self . _account_uid , self . uid , uuid4 ( ) ) body = { "amount" : { "currency" : self . total_saved_currency , "minorUnits" : deposit_minor_units } } response = put ( _url ( endpoint , self .... | Add funds to a savings goal . |
14,420 | def get_image ( self , filename : str = None ) -> None : if filename is None : filename = "{0}.png" . format ( self . name ) endpoint = "/account/{0}/savings-goals/{1}/photo" . format ( self . _account_uid , self . uid ) response = get ( _url ( endpoint , self . _sandbox ) , headers = self . _auth_headers ) response . ... | Download the photo associated with a Savings Goal . |
14,421 | def update_account_data ( self ) -> None : response = get ( _url ( "/accounts/{0}/identifiers" . format ( self . _account_uid ) , self . _sandbox ) , headers = self . _auth_headers ) response . raise_for_status ( ) response = response . json ( ) self . account_identifier = response . get ( 'accountIdentifier' ) self . ... | Get basic information for the account . |
14,422 | def update_balance_data ( self ) -> None : response = get ( _url ( "/accounts/{0}/balance" . format ( self . _account_uid ) , self . _sandbox ) , headers = self . _auth_headers ) response . raise_for_status ( ) response = response . json ( ) self . cleared_balance = response [ 'clearedBalance' ] [ 'minorUnits' ] self .... | Get the latest balance information for the account . |
14,423 | def update_savings_goal_data ( self ) -> None : response = get ( _url ( "/account/{0}/savings-goals" . format ( self . _account_uid ) , self . _sandbox ) , headers = self . _auth_headers ) response . raise_for_status ( ) response = response . json ( ) response_savings_goals = response . get ( 'savingsGoalList' , { } ) ... | Get the latest savings goal information for the account . |
14,424 | def process_inlines ( parser , token ) : args = token . split_contents ( ) if not len ( args ) in ( 2 , 4 , 6 ) : raise template . TemplateSyntaxError ( "%r tag requires either 1, 3 or 5 arguments." % args [ 0 ] ) var_name = args [ 1 ] ALLOWED_ARGS = [ 'as' , 'in' ] kwargs = { 'template_directory' : None } if len ( arg... | Searches through the provided content and applies inlines where ever they are found . |
14,425 | def build_current_graph ( ) : graph = SQLStateGraph ( ) for app_name , config in apps . app_configs . items ( ) : try : module = import_module ( '.' . join ( ( config . module . __name__ , SQL_CONFIG_MODULE ) ) ) sql_items = module . sql_items except ( ImportError , AttributeError ) : continue for sql_item in sql_items... | Read current state of SQL items from the current project state . |
14,426 | def build_graph ( self ) : for child , parents in self . dependencies . items ( ) : if child not in self . nodes : raise NodeNotFoundError ( "App %s SQL item dependencies reference nonexistent child node %r" % ( child [ 0 ] , child ) , child ) for parent in parents : if parent not in self . nodes : raise NodeNotFoundEr... | Read lazy dependency list and build graph . |
14,427 | def sample ( self , n_to_sample , ** kwargs ) : n_to_sample = verify_positive ( int ( n_to_sample ) ) n_remaining = self . _max_iter - self . t_ if n_remaining == 0 : if ( not self . replace ) and ( self . _n_items == self . _max_iter ) : raise Exception ( "All items have already been sampled" ) else : raise Exception ... | Sample a sequence of items from the pool |
14,428 | def sample_distinct ( self , n_to_sample , ** kwargs ) : n_notsampled = np . sum ( np . isnan ( self . cached_labels_ ) ) if n_notsampled == 0 : raise Exception ( "All distinct items have already been sampled." ) if n_to_sample > n_notsampled : warnings . warn ( "Only {} distinct item(s) have not yet been sampled." " S... | Sample a sequence of items from the pool until a minimum number of distinct items are queried |
14,429 | def _sample_item ( self , ** kwargs ) : if self . replace : loc = np . random . choice ( self . _n_items ) else : not_seen_ids = np . where ( np . isnan ( self . cached_labels_ ) ) [ 0 ] loc = np . random . choice ( not_seen_ids ) return loc , 1 , { } | Sample an item from the pool |
14,430 | def _query_label ( self , loc ) : ell = self . cached_labels_ [ loc ] if np . isnan ( ell ) : oracle_arg = self . identifiers [ loc ] ell = self . oracle ( oracle_arg ) if ell not in [ 0 , 1 ] : raise Exception ( "Oracle provided an invalid label." ) self . _queried_oracle [ self . t_ ] = True self . cached_labels_ [ l... | Query the label for the item with index loc . Preferentially queries the label from the cache but if not yet cached queries the oracle . |
14,431 | def _F_measure ( self , alpha , TP , FP , FN , return_num_den = False ) : num = np . float64 ( TP ) den = np . float64 ( alpha * ( TP + FP ) + ( 1 - alpha ) * ( TP + FN ) ) with np . errstate ( divide = 'ignore' , invalid = 'ignore' ) : F_measure = num / den if return_num_den : return F_measure , num , den else : retur... | Calculate the weighted F - measure |
14,432 | def key_occurrence ( self , key , update = True ) : if update : self . update ( ) result = { } for k , v in self . database . items ( ) : if key in v : result [ str ( v [ key ] ) ] = k return result | Return a dict containing the value of the provided key and its uuid as value . |
14,433 | def zmq_address ( self , key ) : zmq_address = "tcp://" + self . database [ key ] [ 'node' ] + ":" + str ( self . database [ key ] [ 'ports' ] [ 'REQ' ] ) return zmq_address | Return a ZeroMQ address to the module with the provided key . |
14,434 | def _get_json ( location ) : location = os . path . expanduser ( location ) try : if os . path . isfile ( location ) : with io . open ( location , encoding = "utf-8" ) as json_data : return json . load ( json_data , object_pairs_hook = OrderedDict ) . get ( "tests" ) elif "http" in location : json_data = requests . get... | Reads JSON data from file or URL . |
14,435 | def _calculate_duration ( start_time , finish_time ) : if not ( start_time and finish_time ) : return 0 start = datetime . datetime . fromtimestamp ( start_time ) finish = datetime . datetime . fromtimestamp ( finish_time ) duration = finish - start decimals = float ( ( "0." + str ( duration . microseconds ) ) ) return... | Calculates how long it took to execute the testcase . |
14,436 | def _filter_parameters ( parameters ) : if not parameters : return None return OrderedDict ( ( param , value ) for param , value in six . iteritems ( parameters ) if param not in IGNORED_PARAMS ) | Filters the ignored parameters out . |
14,437 | def _append_record ( test_data , results , test_path ) : statuses = test_data . get ( "statuses" ) jenkins_data = test_data . get ( "jenkins" ) or { } data = [ ( "title" , test_data . get ( "test_name" ) or _get_testname ( test_path ) ) , ( "verdict" , statuses . get ( "overall" ) ) , ( "source" , test_data . get ( "so... | Adds data of single testcase results to results database . |
14,438 | def _parse_ostriz ( ostriz_data ) : if not ostriz_data : raise NothingToDoException ( "No data to import" ) results = [ ] found_build = None last_finish_time = [ 0 ] for test_path , test_data in six . iteritems ( ostriz_data ) : curr_build = test_data . get ( "build" ) if not curr_build : continue if not found_build : ... | Reads the content of the input JSON and returns testcases results . |
14,439 | def send_array ( socket , A = None , metadata = None , flags = 0 , copy = False , track = False , compress = None , chunksize = 50 * 1000 * 1000 ) : md = { } md [ 'timestamp' ] = datetime . datetime . now ( ) . isoformat ( ) if metadata : md . update ( metadata ) if A is None : md [ 'parts' ] = 0 socket . send_json ( m... | send a numpy array with metadata over zmq |
14,440 | def recv_array ( socket , flags = 0 , copy = False , track = False , poll = None , poll_timeout = 10000 ) : if poll is None : md = socket . recv_json ( flags = flags ) else : socks = dict ( poll . poll ( poll_timeout ) ) if socks . get ( socket ) == zmq . POLLIN : reply = socket . recv_json ( flags = flags ) md = reply... | recv a metadata and an optional numpy array from a zmq socket |
14,441 | def is_sql_equal ( sqls1 , sqls2 ) : is_seq1 = isinstance ( sqls1 , ( list , tuple ) ) is_seq2 = isinstance ( sqls2 , ( list , tuple ) ) if not is_seq1 : sqls1 = ( sqls1 , ) if not is_seq2 : sqls2 = ( sqls2 , ) if len ( sqls1 ) != len ( sqls2 ) : return False for sql1 , sql2 in zip ( sqls1 , sqls2 ) : sql1 , params1 = ... | Find out equality of two SQL items . |
14,442 | def add_sql_operation ( self , app_label , sql_name , operation , dependencies ) : deps = [ ( dp [ 0 ] , SQL_BLOB , dp [ 1 ] , self . _sql_operations . get ( dp ) ) for dp in dependencies ] self . add_operation ( app_label , operation , dependencies = deps ) self . _sql_operations [ ( app_label , sql_name ) ] = operati... | Add SQL operation and register it to be used as dependency for further sequential operations . |
14,443 | def _generate_reversed_sql ( self , keys , changed_keys ) : for key in keys : if key not in changed_keys : continue app_label , sql_name = key old_item = self . from_sql_graph . nodes [ key ] new_item = self . to_sql_graph . nodes [ key ] if not old_item . reverse_sql or old_item . reverse_sql == RunSQL . noop or new_i... | Generate reversed operations for changes that require full rollback and creation . |
14,444 | def _generate_delete_sql ( self , delete_keys ) : for key in delete_keys : app_label , sql_name = key old_node = self . from_sql_graph . nodes [ key ] operation = DeleteSQL ( sql_name , old_node . reverse_sql , reverse_sql = old_node . sql ) sql_deps = [ n . key for n in self . from_sql_graph . node_map [ key ] . child... | Generate forward delete operations for SQL items . |
14,445 | def generate_sql_changes ( self ) : from_keys = set ( self . from_sql_graph . nodes . keys ( ) ) to_keys = set ( self . to_sql_graph . nodes . keys ( ) ) new_keys = to_keys - from_keys delete_keys = from_keys - to_keys changed_keys = set ( ) dep_changed_keys = [ ] for key in from_keys & to_keys : old_node = self . from... | Starting point of this tool which identifies changes and generates respective operations . |
14,446 | def check_dependency ( self , operation , dependency ) : if isinstance ( dependency [ 1 ] , SQLBlob ) : return dependency [ 3 ] == operation return super ( MigrationAutodetector , self ) . check_dependency ( operation , dependency ) | Enhances default behavior of method by checking dependency for matching operation . |
14,447 | def reactivate ( credit_card_id : str ) -> None : logger . info ( 'reactivating-credit-card' , credit_card_id = credit_card_id ) with transaction . atomic ( ) : cc = CreditCard . objects . get ( pk = credit_card_id ) cc . reactivate ( ) cc . save ( ) | Reactivates a credit card . |
14,448 | def sync ( self , syncPointList ) : if len ( syncPointList ) == 0 : return subsCopy = self . _subs . clone ( ) syncPointList . sort ( ) SubAssert ( syncPointList [ 0 ] . subNo >= 0 ) SubAssert ( syncPointList [ 0 ] . subNo < subsCopy . size ( ) ) SubAssert ( syncPointList [ - 1 ] . subNo < subsCopy . size ( ) ) firstSy... | Synchronise subtitles using a given list of SyncPoints . |
14,449 | def _getDeltas ( self , firstSub , secondSub ) : startDelta = max ( firstSub . start , secondSub . start ) - min ( firstSub . start , secondSub . start ) endDelta = max ( firstSub . end , secondSub . end ) - min ( firstSub . end , secondSub . end ) return ( startDelta , endDelta ) | Arguments must have start and end properties which are FrameTimes . |
14,450 | async def scan_for_units ( self , iprange ) : units = [ ] for ip_address in ipaddress . IPv4Network ( iprange ) : sock = socket . socket ( ) sock . settimeout ( 0.02 ) host = str ( ip_address ) try : scan_result = sock . connect ( ( host , PORT ) ) except socket . error : scan_result = 1 _LOGGER . debug ( 'Checking por... | Scan local network for GH units . |
14,451 | async def bluetooth_scan ( ) : async with aiohttp . ClientSession ( ) as session : ghlocalapi = Bluetooth ( LOOP , session , IPADDRESS ) await ghlocalapi . scan_for_devices ( ) await ghlocalapi . get_scan_result ( ) print ( "Device info:" , ghlocalapi . devices ) | Get nearby bluetooth devices . |
14,452 | def reduce_fit ( interface , state , label , inp ) : from disco . util import kvgroup import numpy as np out = interface . output ( 0 ) fit_model = { "y_labels" : [ ] , "y_sum" : 0 , "iv" : set ( ) } combiner = { } means , variances = [ ] , [ ] k_prev = "" for key , value in kvgroup ( inp ) : k_split = key . split ( st... | Function separates aggregation of continuous and discrete features . For continuous features it aggregates partially calculated means and variances and returns them . For discrete features it aggregates pairs and returns them . Pairs with label occurrences are used to calculate prior probabilities |
14,453 | def map_predict ( interface , state , label , inp ) : import numpy as np out = interface . output ( 0 ) continuous = [ j for i , j in enumerate ( state [ "X_indices" ] ) if state [ "X_meta" ] [ i ] == "c" ] discrete = [ j for i , j in enumerate ( state [ "X_indices" ] ) if state [ "X_meta" ] [ i ] == "d" ] cont = True ... | Function makes a predictions of samples with given model . It calculates probabilities with multinomial and Gaussian distribution . |
14,454 | def predict ( dataset , fitmodel_url , m = 1 , save_results = True , show = False ) : from disco . worker . pipeline . worker import Worker , Stage from disco . core import Job , result_iterator import numpy as np try : m = float ( m ) except ValueError : raise Exception ( "Parameter m should be numerical." ) if "naive... | Function starts a job that makes predictions to input data with a given model |
14,455 | def data ( self ) : if self . _data : return self . _data retval = { } data = self . get_request_data ( ) for subdata in data : for key , value in subdata . iteritems ( ) : if not key in retval : retval [ key ] = value self . _data = retval return retval | Returns the request data as a dictionary . |
14,456 | def get_resource ( self , resource , ** kwargs ) : return resource ( request = self . request , response = self . response , path_params = self . path_params , application = self . application , ** kwargs ) | Returns a new instance of the resource class passed in as resource . This is a helper to make future - compatibility easier when new arguments get added to the constructor . |
14,457 | def assert_conditions ( self ) : self . assert_condition_md5 ( ) etag = self . clean_etag ( self . call_method ( 'get_etag' ) ) self . response . last_modified = self . call_method ( 'get_last_modified' ) self . assert_condition_etag ( ) self . assert_condition_last_modified ( ) | Handles various HTTP conditions and raises HTTP exceptions to abort the request . |
14,458 | def assert_condition_md5 ( self ) : if 'Content-MD5' in self . request . headers : body_md5 = hashlib . md5 ( self . request . body ) . hexdigest ( ) if body_md5 != self . request . headers [ 'Content-MD5' ] : raise_400 ( self , msg = 'Invalid Content-MD5 request header.' ) | If the Content - MD5 request header is present in the request it s verified against the MD5 hash of the request body . If they don t match a 400 HTTP response is returned . |
14,459 | def get_allowed_methods ( self ) : return ", " . join ( [ method for method in dir ( self ) if method . upper ( ) == method and callable ( getattr ( self , method ) ) ] ) | Returns a coma - separated list of method names that are allowed on this instance . Useful to set the Allowed response header . |
14,460 | def convert_param ( self , method , param , value ) : rules = self . _get_validation ( method , param ) if not rules or not rules . get ( 'convert' ) : return value try : return rules [ 'convert' ] ( value ) except ValueError : raise ValidationException ( "{0} value {1} does not validate." . format ( param , value ) ) | Converts the parameter using the function convert function of the validation rules . Same parameters as the validate_param method so it might have just been added there . But lumping together the two functionalities would make overwriting harder . |
14,461 | def _get_validation ( self , method , param ) : if hasattr ( method , '_validations' ) and param in method . _validations : return method . _validations [ param ] elif ( hasattr ( method . im_class , '_validations' ) and param in method . im_class . _validations ) : return method . im_class . _validations [ param ] els... | Return the correct validations dictionary for this parameter . First checks the method itself and then its class . If no validation is defined for this parameter None is returned . |
14,462 | def convert_response ( self ) : if hasattr ( self . response , 'body_raw' ) : if self . response . body_raw is not None : to_type = re . sub ( '[^a-zA-Z_]' , '_' , self . type ) to_type_method = 'to_' + to_type if hasattr ( self , to_type_method ) : self . response . body = getattr ( self , to_type_method ) ( self . re... | Finish filling the instance s response object so it s ready to be served to the client . This includes converting the body_raw property to the content type requested by the user if necessary . |
14,463 | def handle_exception ( self , e , status = 500 ) : logger . exception ( "An exception occurred while handling the request: %s" , e ) self . response . body_raw = { 'error' : str ( e ) } self . response . status = status | Handle the given exception . Log sets the response code and output the exception message as an error message . |
14,464 | def handle_exception_404 ( self , e ) : logger . debug ( "A 404 Not Found exception occurred while handling " "the request." ) self . response . body_raw = { 'error' : 'Not Found' } self . response . status = 404 | Handle the given exception . Log sets the response code to 404 and output the exception message as an error message . |
14,465 | def set_response_content_md5 ( self ) : self . response . content_md5 = hashlib . md5 ( self . response . body ) . hexdigest ( ) | Set the Content - MD5 response header . Calculated from the the response body by creating the MD5 hash from it . |
14,466 | def get_request_data ( self ) : request_data = [ self . path_params , self . request . GET ] if self . request . headers . get ( 'Content-Type' ) == 'application/json' and self . request . body : try : post = json . loads ( self . request . body ) except ValueError : raise_400 ( self , msg = 'Invalid JSON content data'... | Read the input values . |
14,467 | def _merge_defaults ( self , data , method_params , defaults ) : if defaults : optional_args = method_params [ - len ( defaults ) : ] for key , value in zip ( optional_args , defaults ) : if not key in data : data [ key ] = value return data | Helper method for adding default values to the data dictionary . |
14,468 | def _get_columns ( self , X , cols ) : if isinstance ( X , DataSet ) : X = X [ cols ] return_vector = False if isinstance ( cols , basestring ) : return_vector = True cols = [ cols ] if isinstance ( X , list ) : X = [ x [ cols ] for x in X ] X = pd . DataFrame ( X ) if return_vector : t = X [ cols [ 0 ] ] else : t = X ... | Get a subset of columns from the given table X . X a Pandas dataframe ; the table to select columns from cols a string or list of strings representing the columns to select Returns a numpy array with the data from the selected columns |
14,469 | def _requirement_element ( self , parent_element , req_data ) : req_data = self . _transform_result ( req_data ) if not req_data : return title = req_data . get ( "title" ) if not title : logger . warning ( "Skipping requirement, title is missing" ) return req_id = req_data . get ( "id" ) if not self . _check_lookup_pr... | Adds requirement XML element . |
14,470 | def export ( self ) : top = self . _top_element ( ) properties = self . _properties_element ( top ) self . _fill_requirements ( top ) self . _fill_lookup_prop ( properties ) return utils . prettify_xml ( top ) | Returns requirements XML . |
14,471 | def write_xml ( xml , output_file = None ) : gen_filename = "requirements-{:%Y%m%d%H%M%S}.xml" . format ( datetime . datetime . now ( ) ) utils . write_xml ( xml , output_loc = output_file , filename = gen_filename ) | Outputs the XML content into a file . |
14,472 | def _client ( self , id , secret ) : url = self . api_url + self . auth_token_url auth_string = '%s:%s' % ( id , secret ) authorization = base64 . b64encode ( auth_string . encode ( ) ) . decode ( ) headers = { 'Authorization' : "Basic " + authorization , 'Content-Type' : "application/x-www-form-urlencoded" } params = ... | Performs client login with the provided credentials |
14,473 | def aggregate_cap_val ( self , conn , ** kwargs ) : region = kwargs [ 'region' ] [ pv_df , wind_df , cap ] = self . get_timeseries ( conn , geometry = region . geom , ** kwargs ) if kwargs . get ( 'store' , False ) : self . store_full_df ( pv_df , wind_df , ** kwargs ) cap = cap . sum ( ) df = pd . concat ( [ pv_df . s... | Returns the normalised feedin profile and installed capacity for a given region . |
14,474 | def save_assets ( self , dest_path ) : for idx , subplot in enumerate ( self . subplots ) : subplot . save_assets ( dest_path , suffix = '_%d' % idx ) | Save plot assets alongside dest_path . |
14,475 | def set_empty ( self , row , column ) : subplot = self . get_subplot_at ( row , column ) subplot . set_empty ( ) | Keep one of the subplots completely empty . |
14,476 | def set_empty_for_all ( self , row_column_list ) : for row , column in row_column_list : self . set_empty ( row , column ) | Keep all specified subplots completely empty . |
14,477 | def set_title ( self , row , column , text ) : subplot = self . get_subplot_at ( row , column ) subplot . set_title ( text ) | Set a title text . |
14,478 | def set_label ( self , row , column , text , location = 'upper right' , style = None ) : subplot = self . get_subplot_at ( row , column ) subplot . set_label ( text , location , style ) | Set a label for the subplot . |
14,479 | def show_xticklabels ( self , row , column ) : subplot = self . get_subplot_at ( row , column ) subplot . show_xticklabels ( ) | Show the x - axis tick labels for a subplot . |
14,480 | def show_xticklabels_for_all ( self , row_column_list = None ) : if row_column_list is None : for subplot in self . subplots : subplot . show_xticklabels ( ) else : for row , column in row_column_list : self . show_xticklabels ( row , column ) | Show the x - axis tick labels for all specified subplots . |
14,481 | def show_yticklabels ( self , row , column ) : subplot = self . get_subplot_at ( row , column ) subplot . show_yticklabels ( ) | Show the y - axis tick labels for a subplot . |
14,482 | def show_yticklabels_for_all ( self , row_column_list = None ) : if row_column_list is None : for subplot in self . subplots : subplot . show_yticklabels ( ) else : for row , column in row_column_list : self . show_yticklabels ( row , column ) | Show the y - axis tick labels for all specified subplots . |
14,483 | def set_xlimits ( self , row , column , min = None , max = None ) : subplot = self . get_subplot_at ( row , column ) subplot . set_xlimits ( min , max ) | Set x - axis limits of a subplot . |
14,484 | def set_xlimits_for_all ( self , row_column_list = None , min = None , max = None ) : if row_column_list is None : self . limits [ 'xmin' ] = min self . limits [ 'xmax' ] = max else : for row , column in row_column_list : self . set_xlimits ( row , column , min , max ) | Set x - axis limits of specified subplots . |
14,485 | def set_ylimits ( self , row , column , min = None , max = None ) : subplot = self . get_subplot_at ( row , column ) subplot . set_ylimits ( min , max ) | Set y - axis limits of a subplot . |
14,486 | def set_ylimits_for_all ( self , row_column_list = None , min = None , max = None ) : if row_column_list is None : self . limits [ 'ymin' ] = min self . limits [ 'ymax' ] = max else : for row , column in row_column_list : self . set_ylimits ( row , column , min , max ) | Set y - axis limits of specified subplots . |
14,487 | def set_slimits ( self , row , column , min , max ) : subplot = self . get_subplot_at ( row , column ) subplot . set_slimits ( min , max ) | Set limits for the point sizes . |
14,488 | def set_ytick_labels ( self , row , column , labels ) : subplot = self . get_subplot_at ( row , column ) subplot . set_ytick_labels ( labels ) | Manually specify the y - axis tick labels . |
14,489 | def get_subplot_at ( self , row , column ) : idx = row * self . columns + column return self . subplots [ idx ] | Return the subplot at row column position . |
14,490 | def set_subplot_xlabel ( self , row , column , text ) : subplot = self . get_subplot_at ( row , column ) subplot . set_xlabel ( text ) | Set a label for the x - axis of a subplot . |
14,491 | def set_subplot_ylabel ( self , row , column , text ) : subplot = self . get_subplot_at ( row , column ) subplot . set_ylabel ( text ) | Set a label for the y - axis of a subplot . |
14,492 | def set_scalebar_for_all ( self , row_column_list = None , location = 'lower right' ) : if row_column_list is None : for subplot in self . subplots : subplot . set_scalebar ( location ) else : for row , column in row_column_list : subplot = self . get_subplot_at ( row , column ) subplot . set_scalebar ( location ) | Show marker area scale for subplots . |
14,493 | def set_colorbar ( self , label = '' , horizontal = False ) : if self . limits [ 'mmin' ] is None or self . limits [ 'mmax' ] is None : warnings . warn ( 'Set (only) global point meta limits to ensure the ' 'colorbar is correct for all subplots.' ) self . colorbar = { 'label' : label , 'horizontal' : horizontal } | Show the colorbar it will be attached to the last plot . |
14,494 | def set_axis_options ( self , row , column , text ) : subplot = self . get_subplot_at ( row , column ) subplot . set_axis_options ( text ) | Set additionnal options as plain text . |
14,495 | def initialize ( self , configfile = None ) : method = "initialize" A = None metadata = { method : configfile } send_array ( self . socket , A , metadata ) A , metadata = recv_array ( self . socket , poll = self . poll , poll_timeout = self . poll_timeout , flags = self . zmq_flags ) | Initialize the module |
14,496 | def finalize ( self ) : method = "finalize" A = None metadata = { method : - 1 } send_array ( self . socket , A , metadata ) A , metadata = recv_array ( self . socket , poll = self . poll , poll_timeout = self . poll_timeout , flags = self . zmq_flags ) | Finalize the module |
14,497 | def set_current_time ( self , t ) : method = "set_current_time" A = None metadata = { method : t } send_array ( self . socket , A , metadata ) A , metadata = recv_array ( self . socket , poll = self . poll , poll_timeout = self . poll_timeout , flags = self . zmq_flags ) | Set current time of simulation |
14,498 | def set_var_slice ( self , name , start , count , var ) : method = "set_var_slice" A = var metadata = { method : name , "start" : start , "count" : count } send_array ( self . socket , A , metadata ) A , metadata = recv_array ( self . socket , poll = self . poll , poll_timeout = self . poll_timeout , flags = self . zmq... | Set the variable name with the values of var |
14,499 | def update ( self , dt ) : method = "update" A = None metadata = { method : dt } send_array ( self . socket , A , metadata ) A , metadata = recv_array ( self . socket , poll = self . poll , poll_timeout = self . poll_timeout , flags = self . zmq_flags ) | Advance the module with timestep dt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.