idx int64 0 251k | question stringlengths 53 3.53k | target stringlengths 5 1.23k | len_question int64 20 893 | len_target int64 3 238 |
|---|---|---|---|---|
4,700 | def _commit ( self , session , errorMessage ) : try : session . commit ( ) except IntegrityError : # Raise special error if the commit fails due to empty files log . error ( 'Commit to database failed. %s' % errorMessage ) except : # Raise other errors as normal raise | Custom commit function for file objects | 62 | 6 |
4,701 | def run ( self ) : print ( " creating %s" % versionfile_source ) with open ( versionfile_source , "w" ) as f : f . write ( get_vcs_code ( ) ) ipy = os . path . join ( os . path . dirname ( versionfile_source ) , "__init__.py" ) try : with open ( ipy , "r" ) as f : old = f . read ( ) except EnvironmentError : old = "" i... | Create the versioneer . py file . | 647 | 8 |
4,702 | def linkChunk ( key , chunk ) : # Extract link type card linkType = chunk [ 1 ] . strip ( ) . split ( ) [ 0 ] # Cases if linkType == 'DX' : # Cross section link type handler result = xSectionLink ( chunk ) elif linkType == 'STRUCTURE' : # Structure link type handler result = structureLink ( chunk ) elif linkType in ( '... | Parse LINK Chunk Method | 113 | 6 |
4,703 | def structureLink ( lines ) : # Constants KEYWORDS = ( 'LINK' , 'STRUCTURE' , 'NUMSTRUCTS' , 'STRUCTTYPE' ) WEIR_KEYWORDS = ( 'STRUCTTYPE' , 'CREST_LENGTH' , 'CREST_LOW_ELEV' , 'DISCHARGE_COEFF_FORWARD' , 'DISCHARGE_COEFF_REVERSE' , 'CREST_LOW_LOC' , 'STEEP_SLOPE' , 'SHALLOW_SLOPE' ) CULVERT_KEYWORDS = ( 'STRUCTTYPE' ,... | Parse STRUCTURE LINK Method | 734 | 7 |
4,704 | def reservoirLink ( lines ) : # Constants KEYWORDS = ( 'LINK' , 'RESERVOIR' , 'RES_MINWSE' , 'RES_INITWSE' , 'RES_MAXWSE' , 'RES_NUMPTS' , 'LAKE' , 'MINWSE' , 'INITWSE' , 'MAXWSE' , 'NUMPTS' ) result = { 'header' : { 'link' : None , 'res_minwse' : None , 'res_initwse' : None , 'res_maxwse' : None , 'res_numpts' : None ... | Parse RESERVOIR Link Method | 486 | 8 |
4,705 | def nodeChunk ( lines ) : # Constants KEYWORDS = ( 'NODE' , 'X_Y' , 'ELEV' ) result = { 'node' : None , 'x' : None , 'y' : None , 'elev' : None } chunks = pt . chunk ( KEYWORDS , lines ) # Parse chunks associated with each key for key , chunkList in iteritems ( chunks ) : # Parse each chunk in the chunk list for chunk ... | Parse NODE Method | 174 | 5 |
4,706 | def xSectionChunk ( lines ) : # Constants KEYWORDS = ( 'MANNINGS_N' , 'BOTTOM_WIDTH' , 'BANKFULL_DEPTH' , 'SIDE_SLOPE' , 'NPAIRS' , 'NUM_INTERP' , 'X1' , 'ERODE' , 'MAX_EROSION' , 'SUBSURFACE' , 'M_RIVER' , 'K_RIVER' ) result = { 'mannings_n' : None , 'bottom_width' : None , 'bankfull_depth' : None , 'side_slope' : Non... | Parse XSEC Method | 390 | 5 |
4,707 | def structureChunk ( keywords , resultDict , lines ) : chunks = pt . chunk ( keywords , lines ) # Parse chunks associated with each key for key , chunkList in iteritems ( chunks ) : # Parse each chunk in the chunk list for chunk in chunkList : # Strip and split the line (only one item in each list) schunk = chunk [ 0 ]... | Parse Weir and Culvert Structures Method | 120 | 9 |
4,708 | def bar ( self , width , * * _ ) : width -= self . _width_offset self . _position += self . _direction # Change direction. if self . _position <= 0 and self . _direction < 0 : self . _position = 0 self . _direction = 1 elif self . _position > width : self . _position = width - 1 self . _direction = - 1 final_bar = ( se... | Returns the completed progress bar . Every time this is called the animation moves . | 151 | 15 |
4,709 | def _read ( self , directory , filename , session , path , name , extension , spatial = False , spatialReferenceID = 4236 , replaceParamFile = None , readIndexMaps = True ) : # Set file extension property self . fileExtension = extension # Dictionary of keywords/cards and parse function names KEYWORDS = { 'INDEX_MAP' :... | Mapping Table Read from File Method | 775 | 7 |
4,710 | def _write ( self , session , openFile , replaceParamFile = None , writeIndexMaps = True ) : # Extract directory directory = os . path . split ( openFile . name ) [ 0 ] # Derive a Unique Set of Contaminants for mapTable in self . getOrderedMapTables ( session ) : if mapTable . name == 'CONTAMINANT_TRANSPORT' : contamin... | Map Table Write to File Method | 414 | 6 |
4,711 | def getOrderedMapTables ( self , session ) : return session . query ( MapTable ) . filter ( MapTable . mapTableFile == self ) . order_by ( MapTable . name ) . all ( ) | Retrieve the map tables ordered by name | 47 | 8 |
4,712 | def deleteMapTable ( self , name , session ) : duplicate_map_tables = session . query ( MapTable ) . filter ( MapTable . mapTableFile == self ) . filter ( MapTable . name == name ) . all ( ) for duplicate_map_table in duplicate_map_tables : if duplicate_map_table . indexMap : session . delete ( duplicate_map_table . in... | Remove duplicate map table if it exists | 104 | 7 |
4,713 | def _createValueObjects ( self , valueList , varList , mapTable , indexMap , contaminant , replaceParamFile ) : def assign_values_to_table ( value_list , layer_id ) : for i , value in enumerate ( value_list ) : value = vrp ( value , replaceParamFile ) # Create MTValue object and associate with MTIndex and MapTable mtVa... | Populate GSSHAPY MTValue and MTIndex Objects Method | 307 | 15 |
4,714 | def _readContaminantOutputFiles ( self , directory , baseFileName , session , spatial , spatialReferenceID ) : if not os . path . isdir ( directory ) : return if baseFileName == '' : return # Look for channel output files denoted by the ".chan" after the base filename chanBaseFileName = '.' . join ( [ baseFileName , 'c... | Read any contaminant output files if available | 269 | 8 |
4,715 | def _writeMapTable ( self , session , fileObject , mapTable , replaceParamFile ) : # Write mapping name fileObject . write ( '%s "%s"\n' % ( mapTable . name , mapTable . indexMap . name ) ) # Write mapping table global variables if mapTable . numIDs : fileObject . write ( 'NUM_IDS %s\n' % ( mapTable . numIDs ) ) if map... | Write Generic Map Table Method | 227 | 5 |
4,716 | def _writeContaminantTable ( self , session , fileObject , mapTable , contaminants , replaceParamFile ) : # Write the contaminant mapping table header fileObject . write ( '%s\n' % ( mapTable . name ) ) fileObject . write ( 'NUM_CONTAM %s\n' % ( mapTable . numContam ) ) # Write out each contaminant and it's values for ... | This method writes the contaminant transport mapping table case . | 341 | 11 |
4,717 | def _writeSedimentTable ( self , session , fileObject , mapTable , replaceParamFile ) : # Write the sediment mapping table header fileObject . write ( '%s\n' % ( mapTable . name ) ) fileObject . write ( 'NUM_SED %s\n' % ( mapTable . numSed ) ) # Write the value header line fileObject . write ( 'Sediment Description%sSp... | Write Sediment Mapping Table Method | 373 | 7 |
4,718 | def _preprocessContaminantOutFilePath ( outPath ) : if '/' in outPath : splitPath = outPath . split ( '/' ) elif '\\' in outPath : splitPath = outPath . split ( '\\' ) else : splitPath = [ outPath , ] if splitPath [ - 1 ] == '' : outputFilename = splitPath [ - 2 ] else : outputFilename = splitPath [ - 1 ] if '.' in out... | Preprocess the contaminant output file path to a relative path . | 118 | 13 |
4,719 | def _set_wildcards ( self , inputs = None , outputs = None ) : w = self . _wildcards = set ( ) # Clean wildcards. if outputs and inputs : node , wi = self . nodes , self . _wait_in . get # Namespace shortcut. # Input data nodes that are in output_targets. w_crd = { u : node [ u ] for u in inputs if u in outputs or wi (... | Update wildcards set with the input data nodes that are also outputs . | 142 | 14 |
4,720 | def result ( self , timeout = None ) : it , exceptions , future_lists = [ ] , [ ] , [ ] from concurrent . futures import Future , wait as wait_fut def update ( fut , data , key ) : if isinstance ( fut , Future ) : it . append ( ( fut , data , key ) ) elif isinstance ( fut , AsyncList ) and fut not in future_lists : fut... | Set all asynchronous results . | 360 | 5 |
4,721 | def _check_targets ( self ) : if self . outputs : targets = self . outputs . copy ( ) # Namespace shortcut for speed. def check_targets ( node_id ) : """ Terminates ArciDispatch algorithm when all targets have been visited. :param node_id: Data or function node id. :type node_id: str :return: True if all targets have b... | Returns a function to terminate the ArciDispatch algorithm when all targets have been visited . | 169 | 17 |
4,722 | def _get_node_estimations ( self , node_attr , node_id ) : # Get data node estimations. estimations = self . _wf_pred [ node_id ] wait_in = node_attr [ 'wait_inputs' ] # Namespace shortcut. # Check if node has multiple estimations and it is not waiting inputs. if len ( estimations ) > 1 and not self . _wait_in . get ( ... | Returns the data nodes estimations and wait_inputs flag . | 290 | 13 |
4,723 | def _set_node_output ( self , node_id , no_call , next_nds = None , * * kw ) : # Namespace shortcuts. node_attr = self . nodes [ node_id ] node_type = node_attr [ 'type' ] if node_type == 'data' : # Set data node. return self . _set_data_node_output ( node_id , node_attr , no_call , next_nds , * * kw ) elif node_type =... | Set the node outputs from node inputs . | 157 | 8 |
4,724 | def _set_data_node_output ( self , node_id , node_attr , no_call , next_nds = None , * * kw ) : # Get data node estimations. est , wait_in = self . _get_node_estimations ( node_attr , node_id ) if not no_call : if node_id is PLOT : est = est . copy ( ) est [ PLOT ] = { 'value' : { 'obj' : self } } sf , args = False , (... | Set the data node output from node estimations . | 582 | 10 |
4,725 | def _set_function_node_output ( self , node_id , node_attr , no_call , next_nds = None , * * kw ) : # Namespace shortcuts for speed. o_nds , dist = node_attr [ 'outputs' ] , self . dist # List of nodes that can still be estimated by the function node. output_nodes = next_nds or set ( self . _succ [ node_id ] ) . differ... | Set the function node output from node inputs . | 384 | 9 |
4,726 | def _add_initial_value ( self , data_id , value , initial_dist = 0.0 , fringe = None , check_cutoff = None , no_call = None ) : # Namespace shortcuts for speed. nodes , seen , edge_weight = self . nodes , self . seen , self . _edge_length wf_remove_edge , check_wait_in = self . _wf_remove_edge , self . check_wait_in wf... | Add initial values updating workflow seen and fringe . | 750 | 9 |
4,727 | def _visit_nodes ( self , node_id , dist , fringe , check_cutoff , no_call = False , * * kw ) : # Namespace shortcuts. wf_rm_edge , wf_has_edge = self . _wf_remove_edge , self . workflow . has_edge edge_weight , nodes = self . _edge_length , self . nodes self . dist [ node_id ] = dist # Set minimum dist. self . _visite... | Visits a node updating workflow seen and fringe .. | 383 | 10 |
4,728 | def _see_node ( self , node_id , fringe , dist , w_wait_in = 0 ) : # Namespace shortcuts. seen , dists = self . seen , self . dist wait_in = self . nodes [ node_id ] [ 'wait_inputs' ] # Wait inputs flag. self . _update_meeting ( node_id , dist ) # Update view distance. # Check if inputs are satisfied. if self . check_w... | See a node updating seen and fringe . | 298 | 8 |
4,729 | def _remove_unused_nodes ( self ) : # Namespace shortcuts. nodes , wf_remove_node = self . nodes , self . workflow . remove_node add_visited , succ = self . _visited . add , self . workflow . succ # Remove unused function and sub-dispatcher nodes. for n in ( set ( self . _wf_pred ) - set ( self . _visited ) ) : node_ty... | Removes unused function and sub - dispatcher nodes . | 211 | 10 |
4,730 | def _init_sub_dsp ( self , dsp , fringe , outputs , no_call , initial_dist , index , full_name ) : # Initialize as sub-dispatcher. sol = self . __class__ ( dsp , { } , outputs , False , None , None , no_call , False , wait_in = self . _wait_in . get ( dsp , None ) , index = self . index + index , full_name = full_name ... | Initialize the dispatcher as sub - dispatcher and update the fringe . | 174 | 13 |
4,731 | def _set_sub_dsp_node_input ( self , node_id , dsp_id , fringe , check_cutoff , no_call , initial_dist ) : # Namespace shortcuts. node = self . nodes [ dsp_id ] dsp , pred = node [ 'function' ] , self . _wf_pred [ dsp_id ] distances , sub_sol = self . dist , self . sub_sol iv_nodes = [ node_id ] # Nodes do be added as ... | Initializes the sub - dispatcher and set its inputs . | 461 | 11 |
4,732 | def _warning ( self , msg , node_id , ex , * args , * * kwargs ) : raises = self . raises ( ex ) if callable ( self . raises ) else self . raises if raises and isinstance ( ex , DispatcherError ) : ex . update ( self ) raise ex self . _errors [ node_id ] = msg % ( ( node_id , ex ) + args ) node_id = '/' . join ( self .... | Handles the error messages . | 189 | 6 |
4,733 | def _read ( self , directory , filename , session , path , name , extension , spatial , spatialReferenceID , replaceParamFile ) : # Set file extension property self . fileExtension = extension # Keywords KEYWORDS = ( 'STREAMCELLS' , 'CELLIJ' ) # Parse file into chunks associated with keywords/cards with open ( path , '... | Grid Stream File Read from File Method | 234 | 7 |
4,734 | def _write ( self , session , openFile , replaceParamFile ) : # Write lines openFile . write ( 'GRIDSTREAMFILE\n' ) openFile . write ( 'STREAMCELLS %s\n' % self . streamCells ) for cell in self . gridStreamCells : openFile . write ( 'CELLIJ %s %s\n' % ( cell . cellI , cell . cellJ ) ) openFile . write ( 'NUMNODES %s\n'... | Grid Stream File Write to File Method | 168 | 7 |
4,735 | def _createGsshaPyObjects ( self , cell ) : # Initialize GSSHAPY PipeGridCell object gridCell = GridStreamCell ( cellI = cell [ 'i' ] , cellJ = cell [ 'j' ] , numNodes = cell [ 'numNodes' ] ) # Associate GridStreamCell with GridStreamFile gridCell . gridStreamFile = self for linkNode in cell [ 'linkNodes' ] : # Create ... | Create GSSHAPY PipeGridCell and PipeGridNode Objects Method | 169 | 15 |
4,736 | def _read ( self , directory , filename , session , path , name , extension , spatial , spatialReferenceID , replaceParamFile ) : # Set file extension property self . fileExtension = extension # Open file and read plain text into text field with open ( path , 'r' ) as f : self . rasterText = f . read ( ) # Retrieve met... | Index Map Read from File Method | 376 | 6 |
4,737 | def write ( self , directory , name = None , session = None , replaceParamFile = None ) : # Initiate file if name != None : filename = '%s.%s' % ( name , self . fileExtension ) filePath = os . path . join ( directory , filename ) else : filePath = os . path . join ( directory , self . filename ) # If the raster field i... | Index Map Write to File Method | 280 | 6 |
4,738 | def _write ( self , session , openFile , replaceParamFile ) : # Write Lines openFile . write ( 'GRIDPIPEFILE\n' ) openFile . write ( 'PIPECELLS %s\n' % self . pipeCells ) for cell in self . gridPipeCells : openFile . write ( 'CELLIJ %s %s\n' % ( cell . cellI , cell . cellJ ) ) openFile . write ( 'NUMPIPES %s\n' % cell ... | Grid Pipe File Write to File Method | 171 | 7 |
4,739 | def _createGsshaPyObjects ( self , cell ) : # Initialize GSSHAPY GridPipeCell object gridCell = GridPipeCell ( cellI = cell [ 'i' ] , cellJ = cell [ 'j' ] , numPipes = cell [ 'numPipes' ] ) # Associate GridPipeCell with GridPipeFile gridCell . gridPipeFile = self for spipe in cell [ 'spipes' ] : # Create GSSHAPY GridPi... | Create GSSHAPY GridPipeCell and GridPipeNode Objects Method | 180 | 17 |
4,740 | def _cellChunk ( self , lines ) : KEYWORDS = ( 'CELLIJ' , 'NUMPIPES' , 'SPIPE' ) result = { 'i' : None , 'j' : None , 'numPipes' : None , 'spipes' : [ ] } chunks = pt . chunk ( KEYWORDS , lines ) # Parse chunks associated with each key for card , chunkList in iteritems ( chunks ) : # Parse each chunk in the chunk list ... | Parse CELLIJ Chunk Method | 264 | 8 |
4,741 | def _read ( self , directory , filename , session , path , name , extension , spatial , spatialReferenceID , replaceParamFile ) : # Set file extension property self . fileExtension = extension # Open file and parse into a data structure with open ( path , 'r' ) as f : for line in f : sline = line . strip ( ) . split ( ... | Replace Param File Read from File Method | 148 | 8 |
4,742 | def _write ( self , session , openFile , replaceParamFile ) : # Retrieve TargetParameter objects targets = self . targetParameters # Write lines openFile . write ( '%s\n' % self . numParameters ) for target in targets : openFile . write ( '%s %s\n' % ( target . targetVariable , target . varFormat ) ) | Replace Param File Write to File Method | 79 | 8 |
4,743 | def _read ( self , directory , filename , session , path , name , extension , spatial , spatialReferenceID , replaceParamFile ) : # Set file extension property self . fileExtension = extension # Open file and parse into a data structure with open ( path , 'r' ) as f : for line in f : valLine = ReplaceValLine ( ) valLin... | Replace Val File Read from File Method | 89 | 8 |
4,744 | def _write ( self , session , openFile , replaceParamFile ) : # Write lines for line in self . lines : openFile . write ( line . contents ) | Replace Val File Write to File Method | 35 | 8 |
4,745 | def emit ( self , data_frame ) : if self . result is not None : raise MultipleEmitsError ( ) data_frame . columns = [ self . prefix + '__' + c for c in data_frame . columns ] self . result = data_frame | Use this function in emit data into the store . | 57 | 10 |
4,746 | def trigger_hats ( self , command , arg = None , callback = None ) : threads = [ ] for scriptable in [ self . project . stage ] + self . project . sprites : threads += self . trigger_scriptable_hats ( scriptable , command , arg , callback ) return threads | Returns a list with each script that is triggered . | 64 | 10 |
4,747 | def push_script ( self , scriptable , script , callback = None ) : if script in self . threads : self . threads [ script ] . finish ( ) thread = Thread ( self . run_script ( scriptable , script ) , scriptable , callback ) self . new_threads [ script ] = thread return thread | Run the script and add it to the list of threads . | 68 | 12 |
4,748 | def tick ( self , events ) : self . add_new_threads ( ) if self . drag_sprite : ( mx , my ) = self . screen . get_mouse_pos ( ) ( ox , oy ) = self . drag_offset new_position = ( mx + ox , my + oy ) if self . drag_sprite . position != new_position : self . has_dragged = True self . drag_sprite . position = new_position ... | Execute one frame of the interpreter . | 561 | 8 |
4,749 | def stop ( self ) : self . threads = { } self . new_threads = { } self . answer = "" self . ask_lock = False | Stop running threads . | 33 | 4 |
4,750 | def evaluate ( self , s , value , insert = None ) : assert not isinstance ( value , kurt . Script ) if insert and insert . unevaluated : return value if isinstance ( value , kurt . Block ) : if value . type . shape == "hat" : return [ ] if value . type not in self . COMMANDS : if getattr ( value . type , '_workaround' ... | Expression evaluator . | 545 | 6 |
4,751 | def get_cluster_name ( self ) : return self . _get ( url = self . url + '/api/cluster-name' , headers = self . headers , auth = self . auth ) | Name identifying this RabbitMQ cluster . | 44 | 7 |
4,752 | def get_connection ( self , name ) : return self . _api_get ( '/api/connections/{0}' . format ( urllib . parse . quote_plus ( name ) ) ) | An individual connection . | 45 | 4 |
4,753 | def delete_connection ( self , name , reason = None ) : headers = { 'X-Reason' : reason } if reason else { } self . _api_delete ( '/api/connections/{0}' . format ( urllib . parse . quote_plus ( name ) ) , headers = headers , ) | Closes an individual connection . Give an optional reason | 69 | 10 |
4,754 | def list_connection_channels ( self , name ) : return self . _api_get ( '/api/connections/{0}/channels' . format ( urllib . parse . quote_plus ( name ) ) ) | List of all channels for a given connection . | 51 | 9 |
4,755 | def get_channel ( self , name ) : return self . _api_get ( '/api/channels/{0}' . format ( urllib . parse . quote_plus ( name ) ) ) | Details about an individual channel . | 45 | 6 |
4,756 | def list_consumers_for_vhost ( self , vhost ) : return self . _api_get ( '/api/consumers/{0}' . format ( urllib . parse . quote_plus ( vhost ) ) ) | A list of all consumers in a given virtual host . | 53 | 11 |
4,757 | def list_exchanges_for_vhost ( self , vhost ) : return self . _api_get ( '/api/exchanges/{0}' . format ( urllib . parse . quote_plus ( vhost ) ) ) | A list of all exchanges in a given virtual host . | 53 | 11 |
4,758 | def get_exchange_for_vhost ( self , exchange , vhost ) : return self . _api_get ( '/api/exchanges/{0}/{1}' . format ( urllib . parse . quote_plus ( vhost ) , urllib . parse . quote_plus ( exchange ) ) ) | An individual exchange | 72 | 3 |
4,759 | def delete_exchange_for_vhost ( self , exchange , vhost , if_unused = False ) : self . _api_delete ( '/api/exchanges/{0}/{1}' . format ( urllib . parse . quote_plus ( vhost ) , urllib . parse . quote_plus ( exchange ) ) , params = { 'if-unused' : if_unused } , ) | Delete an individual exchange . You can add the parameter if_unused = True . This prevents the delete from succeeding if the exchange is bound to a queue or as a source to another exchange . | 95 | 39 |
4,760 | def list_bindings_for_vhost ( self , vhost ) : return self . _api_get ( '/api/bindings/{}' . format ( urllib . parse . quote_plus ( vhost ) ) ) | A list of all bindings in a given virtual host . | 52 | 11 |
4,761 | def get_vhost ( self , name ) : return self . _api_get ( '/api/vhosts/{0}' . format ( urllib . parse . quote_plus ( name ) ) ) | Details about an individual vhost . | 47 | 7 |
4,762 | def create_vhost ( self , name , tracing = False ) : data = { 'tracing' : True } if tracing else { } self . _api_put ( '/api/vhosts/{0}' . format ( urllib . parse . quote_plus ( name ) ) , data = data , ) | Create an individual vhost . | 70 | 6 |
4,763 | def get_user ( self , name ) : return self . _api_get ( '/api/users/{0}' . format ( urllib . parse . quote_plus ( name ) ) ) | Details about an individual user . | 44 | 6 |
4,764 | def list_user_permissions ( self , name ) : return self . _api_get ( '/api/users/{0}/permissions' . format ( urllib . parse . quote_plus ( name ) ) ) | A list of all permissions for a given user . | 50 | 10 |
4,765 | def list_policies_for_vhost ( self , vhost ) : return self . _api_get ( '/api/policies/{0}' . format ( urllib . parse . quote_plus ( vhost ) ) ) | A list of all policies for a vhost . | 55 | 10 |
4,766 | def get_policy_for_vhost ( self , vhost , name ) : return self . _api_get ( '/api/policies/{0}/{1}' . format ( urllib . parse . quote_plus ( vhost ) , urllib . parse . quote_plus ( name ) , ) ) | Get a specific policy for a vhost . | 73 | 9 |
4,767 | def create_policy_for_vhost ( self , vhost , name , definition , pattern = None , priority = 0 , apply_to = 'all' ) : data = { "pattern" : pattern , "definition" : definition , "priority" : priority , "apply-to" : apply_to } self . _api_put ( '/api/policies/{0}/{1}' . format ( urllib . parse . quote_plus ( vhost ) , ur... | Create a policy for a vhost . | 126 | 8 |
4,768 | def delete_policy_for_vhost ( self , vhost , name ) : self . _api_delete ( '/api/policies/{0}/{1}/' . format ( urllib . parse . quote_plus ( vhost ) , urllib . parse . quote_plus ( name ) , ) ) | Delete a specific policy for a vhost . | 73 | 9 |
4,769 | def is_vhost_alive ( self , vhost ) : return self . _api_get ( '/api/aliveness-test/{0}' . format ( urllib . parse . quote_plus ( vhost ) ) ) | Declares a test queue then publishes and consumes a message . Intended for use by monitoring tools . | 53 | 20 |
4,770 | def write ( self , session , directory , name , maskMap ) : # Assemble Path to file name_split = name . split ( '.' ) name = name_split [ 0 ] # Default extension extension = '' if len ( name_split ) >= 2 : extension = name_split [ - 1 ] # Run name preprocessor method if present try : name = self . _namePreprocessor ( n... | Write from database to file . | 190 | 6 |
4,771 | def getAsKmlGridAnimation ( self , session , projectFile = None , path = None , documentName = None , colorRamp = None , alpha = 1.0 , noDataValue = 0.0 ) : # Prepare rasters timeStampedRasters = self . _assembleRasterParams ( projectFile , self . rasters ) # Create a raster converter converter = RasterConverter ( sqlA... | Retrieve the WMS dataset as a gridded time stamped KML string . | 276 | 17 |
4,772 | def getAsKmlPngAnimation ( self , session , projectFile = None , path = None , documentName = None , colorRamp = None , alpha = 1.0 , noDataValue = 0 , drawOrder = 0 , cellSize = None , resampleMethod = 'NearestNeighbour' ) : # Prepare rasters timeStampedRasters = self . _assembleRasterParams ( projectFile , self . ras... | Retrieve the WMS dataset as a PNG time stamped KMZ | 449 | 13 |
4,773 | def _read ( self , directory , filename , session , path , name , extension , spatial , spatialReferenceID , maskMap ) : # Assign file extension attribute to file object self . fileExtension = extension if isinstance ( maskMap , RasterMapFile ) and maskMap . fileExtension == 'msk' : # Vars from mask map columns = maskM... | WMS Dataset File Read from File Method | 790 | 10 |
4,774 | def _write ( self , session , openFile , maskMap ) : # Magic numbers FIRST_VALUE_INDEX = 12 # Write the header openFile . write ( 'DATASET\r\n' ) if self . type == self . SCALAR_TYPE : openFile . write ( 'OBJTYPE {0}\r\n' . format ( self . objectType ) ) openFile . write ( 'BEGSCL\r\n' ) elif self . type == self . VECT... | WMS Dataset File Write to File Method | 564 | 10 |
4,775 | def getAsWmsDatasetString ( self , session ) : # Magic numbers FIRST_VALUE_INDEX = 12 # Write value raster if type ( self . raster ) != type ( None ) : # Convert to GRASS ASCII Raster valueGrassRasterString = self . getAsGrassAsciiGrid ( session ) # Split by lines values = valueGrassRasterString . split ( ) # Assemble ... | Retrieve the WMS Raster as a string in the WMS Dataset format | 171 | 18 |
4,776 | def check_watershed_boundary_geometry ( shapefile_path ) : wfg = gpd . read_file ( shapefile_path ) first_shape = wfg . iloc [ 0 ] . geometry if hasattr ( first_shape , 'geoms' ) : raise ValueError ( "Invalid watershed boundary geometry. " "To fix this, remove disconnected shapes or run " "gsshapy.modeling.GSSHAModel.c... | Make sure that there are no random artifacts in the file . | 106 | 12 |
4,777 | def get_batch ( sentences , token_dict , ignore_case = False , unk_index = 1 , eos_index = 2 ) : batch_size = len ( sentences ) max_sentence_len = max ( map ( len , sentences ) ) inputs = [ [ 0 ] * max_sentence_len for _ in range ( batch_size ) ] outputs_forward = [ [ 0 ] * max_sentence_len for _ in range ( batch_size ... | Get a batch of inputs and outputs from given sentences . | 353 | 11 |
4,778 | def fit ( self , inputs , outputs , epochs = 1 ) : self . model . fit ( inputs , outputs , epochs = epochs ) | Simple wrapper of model . fit . | 31 | 7 |
4,779 | def get_feature_layers ( self , input_layer = None , trainable = False , use_weighted_sum = False ) : model = keras . models . clone_model ( self . model , input_layer ) if not trainable : for layer in model . layers : layer . trainable = False if use_weighted_sum : rnn_layers_forward = list ( map ( lambda x : model . ... | Get layers that output the Bi - LM feature . | 449 | 10 |
4,780 | def join ( self , n1 ) : if self . id == n1 . get_id ( ) : for i in range ( k ) : self . finger [ i ] = self . proxy self . predecessor = self . proxy self . run = True return True else : try : self . init_finger_table ( n1 ) except Exception : print 'Join failed' # raise Exception('Join failed') return False else : se... | if join returns false the node did not entry the ring . Retry it | 96 | 15 |
4,781 | def _read ( self , directory , filename , session , path , name , extension , spatial , spatialReferenceID , replaceParamFile ) : # Set file extension property self . fileExtension = extension # Open file and parse with open ( path , 'r' ) as nwsrfsFile : for line in nwsrfsFile : sline = line . strip ( ) . split ( ) # ... | NWSRFS Read from File Method | 279 | 7 |
4,782 | def _write ( self , session , openFile , replaceParamFile ) : # Write lines openFile . write ( 'Number_Bands: %s\n' % self . numBands ) openFile . write ( 'Lower_Elevation Upper_Elevation MF_Min MF_Max SCF FR_USE TIPM NMF FUA PCWHC\n' ) # Retrieve NwsrfsRecords records = self . nwsrfsRecords for record in records : ope... | NWSRFS Write to File Method | 413 | 7 |
4,783 | def _read ( self , directory , filename , session , path , name , extension , spatial , spatialReferenceID , replaceParamFile ) : # Set file extension property self . fileExtension = extension # Open file and parse into HmetRecords with open ( path , 'r' ) as orthoFile : for line in orthoFile : sline = line . strip ( )... | Orographic Gage File Read from File Method | 310 | 10 |
4,784 | def _write ( self , session , openFile , replaceParamFile ) : # Write lines openFile . write ( 'Num_Sites: %s\n' % self . numSites ) openFile . write ( 'Elev_Base %s\n' % self . elevBase ) openFile . write ( 'Elev_2 %s\n' % self . elev2 ) openFile . write ( 'Year Month Day Hour Temp_2\n' ) # Retrieve OrographicMeasurem... | Orographic Gage File Write to File Method | 243 | 10 |
4,785 | def getFluvialLinks ( self ) : # Define fluvial types fluvialTypeKeywords = ( 'TRAPEZOID' , 'TRAP' , 'BREAKPOINT' , 'ERODE' , 'SUBSURFACE' ) fluvialLinks = [ ] for link in self . streamLinks : for fluvialTypeKeyword in fluvialTypeKeywords : if fluvialTypeKeyword in link . type : fluvialLinks . append ( link ) break ret... | Retrieve only the links that represent fluvial portions of the stream . Returns a list of StreamLink instances . | 115 | 23 |
4,786 | def getOrderedLinks ( self , session ) : streamLinks = session . query ( StreamLink ) . filter ( StreamLink . channelInputFile == self ) . order_by ( StreamLink . linkNumber ) . all ( ) return streamLinks | Retrieve the links in the order of the link number . | 51 | 12 |
4,787 | def getStreamNetworkAsWkt ( self , session , withNodes = True ) : wkt_list = [ ] for link in self . streamLinks : wkt_link = link . getAsWkt ( session ) if wkt_link : wkt_list . append ( wkt_link ) if withNodes : for node in link . nodes : wkt_node = node . getAsWkt ( session ) if wkt_node : wkt_list . append ( wkt_nod... | Retrieve the stream network geometry in Well Known Text format . | 135 | 12 |
4,788 | def getStreamNetworkAsGeoJson ( self , session , withNodes = True ) : features_list = [ ] # Assemble link features for link in self . streamLinks : link_geoJson = link . getAsGeoJson ( session ) if link_geoJson : link_geometry = json . loads ( link . getAsGeoJson ( session ) ) link_properties = { "link_number" : link .... | Retrieve the stream network geometry in GeoJSON format . | 378 | 11 |
4,789 | def _read ( self , directory , filename , session , path , name , extension , spatial , spatialReferenceID , replaceParamFile ) : # Set file extension property self . fileExtension = extension # Dictionary of keywords/cards and parse function names KEYWORDS = { 'ALPHA' : cic . cardChunk , 'BETA' : cic . cardChunk , 'TH... | Channel Input File Read from File Method | 471 | 7 |
4,790 | def _write ( self , session , openFile , replaceParamFile ) : # Write lines openFile . write ( 'GSSHA_CHAN\n' ) alpha = vwp ( self . alpha , replaceParamFile ) try : openFile . write ( 'ALPHA%s%.6f\n' % ( ' ' * 7 , alpha ) ) except : openFile . write ( 'ALPHA%s%s\n' % ( ' ' * 7 , alpha ) ) beta = vwp ( self . beta , re... | Channel Input File Write to File Method | 361 | 7 |
4,791 | def _createLink ( self , linkResult , replaceParamFile ) : link = None # Cases if linkResult [ 'type' ] == 'XSEC' : # Cross section link handler link = self . _createCrossSection ( linkResult , replaceParamFile ) elif linkResult [ 'type' ] == 'STRUCTURE' : # Structure link handler link = self . _createStructure ( linkR... | Create GSSHAPY Link Object Method | 139 | 9 |
4,792 | def _createConnectivity ( self , linkList , connectList ) : # Create StreamLink-Connectivity Pairs for idx , link in enumerate ( linkList ) : connectivity = connectList [ idx ] # Initialize GSSHAPY UpstreamLink objects for upLink in connectivity [ 'upLinks' ] : upstreamLink = UpstreamLink ( upstreamLinkID = int ( upLin... | Create GSSHAPY Connect Object Method | 127 | 9 |
4,793 | def _createCrossSection ( self , linkResult , replaceParamFile ) : # Extract header variables from link result object header = linkResult [ 'header' ] # Initialize GSSHAPY StreamLink object link = StreamLink ( linkNumber = int ( header [ 'link' ] ) , type = header [ 'xSecType' ] , numElements = header [ 'nodes' ] , dx ... | Create GSSHAPY Cross Section Objects Method | 799 | 10 |
4,794 | def _createStructure ( self , linkResult , replaceParamFile ) : # Constants WEIRS = ( 'WEIR' , 'SAG_WEIR' ) CULVERTS = ( 'ROUND_CULVERT' , 'RECT_CULVERT' ) CURVES = ( 'RATING_CURVE' , 'SCHEDULED_RELEASE' , 'RULE_CURVE' ) header = linkResult [ 'header' ] # Initialize GSSHAPY StreamLink object link = StreamLink ( linkNum... | Create GSSHAPY Structure Objects Method | 711 | 9 |
4,795 | def _createReservoir ( self , linkResult , replaceParamFile ) : # Extract header variables from link result object header = linkResult [ 'header' ] # Cases if linkResult [ 'type' ] == 'LAKE' : # Lake handler initWSE = vrp ( header [ 'initwse' ] , replaceParamFile ) minWSE = vrp ( header [ 'minwse' ] , replaceParamFile ... | Create GSSHAPY Reservoir Objects Method | 417 | 10 |
4,796 | def _createGeometry ( self , session , spatialReferenceID ) : # Flush the current session session . flush ( ) # Create geometry for each fluvial link for link in self . getFluvialLinks ( ) : # Retrieve the nodes for each link nodes = link . nodes nodeCoordinates = [ ] # Create geometry for each node for node in nodes :... | Create PostGIS geometric objects | 302 | 6 |
4,797 | def _writeConnectivity ( self , links , fileObject ) : for link in links : linkNum = link . linkNumber downLink = link . downstreamLinkID numUpLinks = link . numUpstreamLinks upLinks = '' for upLink in link . upstreamLinks : upLinks = '{}{:>5}' . format ( upLinks , str ( upLink . upstreamLinkID ) ) line = 'CONNECT{:>5}... | Write Connectivity Lines to File Method | 138 | 7 |
4,798 | def _writeLinks ( self , links , fileObject , replaceParamFile ) : for link in links : linkType = link . type fileObject . write ( 'LINK %s\n' % link . linkNumber ) # Cases if 'TRAP' in linkType or 'TRAPEZOID' in linkType or 'BREAKPOINT' in linkType : self . _writeCrossSectionLink ( link , fileObject , replaceParamFile... | Write Link Lines to File Method | 195 | 6 |
4,799 | def _writeCrossSectionLink ( self , link , fileObject , replaceParamFile ) : linkType = link . type # Write cross section link header dx = vwp ( link . dx , replaceParamFile ) try : fileObject . write ( 'DX %.6f\n' % dx ) except : fileObject . write ( 'DX %s\n' % dx ) fileObject . write ( '%s\n' % linkType ) fileObject... | Write Cross Section Link to File Method | 846 | 7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.