idx int64 0 252k | question stringlengths 48 5.28k | target stringlengths 5 1.23k |
|---|---|---|
4,700 | def datasetHeaderChunk ( key , lines ) : KEYWORDS = ( 'DATASET' , 'OBJTYPE' , 'VECTYPE' , 'BEGSCL' , 'BEGVEC' , 'OBJID' , 'ND' , 'NC' , 'NAME' ) TYPE_KEYS = ( 'BEGSCL' , 'BEGVEC' ) result = { 'type' : None , 'numberData' : None , 'numberCells' : None , 'name' : None , 'objectID' : None , 'objectType' : None , 'vectorTy... | Process the dataset header |
4,701 | def datasetScalarTimeStepChunk ( lines , numberColumns , numberCells ) : END_DATASET_TAG = 'ENDDS' result = { 'iStatus' : None , 'timestamp' : None , 'cellArray' : None , 'rasterText' : None } timeStep = pt . splitLine ( lines . pop ( 0 ) ) startCellsIndex = numberCells iStatus = int ( timeStep [ 1 ] ) if iStatus == 0 ... | Process the time step chunks for scalar datasets |
4,702 | def save_dispatcher ( dsp , path ) : import dill with open ( path , 'wb' ) as f : dill . dump ( dsp , f ) | Write Dispatcher object in Python pickle format . |
4,703 | def save_default_values ( dsp , path ) : import dill with open ( path , 'wb' ) as f : dill . dump ( dsp . default_values , f ) | Write Dispatcher default values in Python pickle format . |
4,704 | def load_default_values ( dsp , path ) : import dill with open ( path , 'rb' ) as f : dsp . __init__ ( dmap = dsp . dmap , default_values = dill . load ( f ) ) | Load Dispatcher default values in Python pickle format . |
4,705 | def save_map ( dsp , path ) : import dill with open ( path , 'wb' ) as f : dill . dump ( dsp . dmap , f ) | Write Dispatcher graph object in Python pickle format . |
4,706 | def chunk ( keywords , lines ) : chunks = dict ( ) chunk = [ ] for keyword in keywords : chunks [ keyword ] = [ ] for line in lines : if line . strip ( ) : token = line . split ( ) [ 0 ] if token in keywords : chunk = [ line ] chunks [ token ] . append ( chunk ) else : chunk . append ( line ) return chunks | Divide a file into chunks between key words in the list |
4,707 | def valueReadPreprocessor ( valueString , replaceParamsFile = None ) : if type ( valueString ) is bool : log . warning ( "Only numerical variable types can be handled by the valueReadPreprocessor function." ) return valueString processedValue = valueString if replaceParamsFile is not None and valueString is not None : ... | Apply global pre - processing to values during reading throughout the project . |
4,708 | def valueWritePreprocessor ( valueString , replaceParamsFile = None ) : if type ( valueString ) is bool : log . warning ( "Only numerical variable types can be handled by the valueReadPreprocessor function." ) return valueString variableString = valueString if replaceParamsFile is not None : if variableString == REPLAC... | Look up variable name in replace param file for the negative id given and return it . |
4,709 | def run ( self , dataset_path ) : features = self . _generate_features ( self . _feature_extractors ) features . to_csv ( dataset_path ) | Run all FeatureExtractors and output results to CSV . |
4,710 | def _generate_features ( self , feature_extractors ) : results = [ pd . DataFrame ( ) ] n_ext = len ( feature_extractors ) for i , extractor in enumerate ( feature_extractors ) : log . info ( "generating: '%s' (%d/%d)" , extractor . name , i + 1 , n_ext ) cached_extractor = self . _cache [ extractor . name ] if extract... | Run all FeatureExtractors and record results in a key - value format . |
4,711 | def read ( self , directory , filename , session , spatial = False , spatialReferenceID = 4236 , replaceParamFile = None , ** kwargs ) : path = os . path . join ( directory , filename ) filename_split = filename . split ( '.' ) name = filename_split [ 0 ] extension = '' if len ( filename_split ) >= 2 : extension = file... | Generic read file into database method . |
4,712 | def write ( self , session , directory , name , replaceParamFile = None , ** kwargs ) : name_split = name . split ( '.' ) name = name_split [ 0 ] extension = '' if len ( name_split ) >= 2 : extension = name_split [ - 1 ] try : name = self . _namePreprocessor ( name ) except : 'DO NOTHING' if extension == '' : filename ... | Write from database back to file . |
4,713 | def _commit ( self , session , errorMessage ) : try : session . commit ( ) except IntegrityError : log . error ( 'Commit to database failed. %s' % errorMessage ) except : raise | Custom commit function for file objects |
4,714 | 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 . |
4,715 | def linkChunk ( key , chunk ) : linkType = chunk [ 1 ] . strip ( ) . split ( ) [ 0 ] if linkType == 'DX' : result = xSectionLink ( chunk ) elif linkType == 'STRUCTURE' : result = structureLink ( chunk ) elif linkType in ( 'RESERVOIR' , 'LAKE' ) : result = reservoirLink ( chunk ) return result | Parse LINK Chunk Method |
4,716 | def structureLink ( lines ) : 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' , 'UPINVERT' ... | Parse STRUCTURE LINK Method |
4,717 | def xSectionLink ( lines ) : KEYWORDS = ( 'LINK' , 'DX' , 'TRAPEZOID' , 'TRAPEZOID_ERODE' , 'TRAPEZOID_SUBSURFACE' , 'ERODE_TRAPEZOID' , 'ERODE_SUBSURFACE' , 'SUBSURFACE_TRAPEZOID' , 'SUBSURFACE_ERODE' , 'TRAPEZOID_ERODE_SUBSURFACE' , 'TRAPEZOID_SUBSURFACE_ERODE' , 'ERODE_TRAPEZOID_SUBSURFACE' , 'ERODE_SUBSURFACE_TRAPE... | Parse Cross Section Links Method |
4,718 | def reservoirLink ( lines ) : 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 , 'minwse' :... | Parse RESERVOIR Link Method |
4,719 | def nodeChunk ( lines ) : KEYWORDS = ( 'NODE' , 'X_Y' , 'ELEV' ) result = { 'node' : None , 'x' : None , 'y' : None , 'elev' : None } chunks = pt . chunk ( KEYWORDS , lines ) for key , chunkList in iteritems ( chunks ) : for chunk in chunkList : schunk = chunk [ 0 ] . strip ( ) . split ( ) if key == 'X_Y' : result [ 'x... | Parse NODE Method |
4,720 | def xSectionChunk ( lines ) : 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' : None , 'npairs'... | Parse XSEC Method |
4,721 | def structureChunk ( keywords , resultDict , lines ) : chunks = pt . chunk ( keywords , lines ) for key , chunkList in iteritems ( chunks ) : for chunk in chunkList : schunk = chunk [ 0 ] . strip ( ) . split ( ) resultDict [ key . lower ( ) ] = schunk [ 1 ] return resultDict | Parse Weir and Culvert Structures Method |
4,722 | def bar ( self , width , ** _ ) : width -= self . _width_offset self . _position += self . _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 = ( self . CHAR_LEFT_BORDER... | Returns the completed progress bar . Every time this is called the animation moves . |
4,723 | def _read ( self , directory , filename , session , path , name , extension , spatial = False , spatialReferenceID = 4236 , replaceParamFile = None , readIndexMaps = True ) : self . fileExtension = extension KEYWORDS = { 'INDEX_MAP' : mtc . indexMapChunk , 'ROUGHNESS' : mtc . mapTableChunk , 'INTERCEPTION' : mtc . mapT... | Mapping Table Read from File Method |
4,724 | def _write ( self , session , openFile , replaceParamFile = None , writeIndexMaps = True ) : directory = os . path . split ( openFile . name ) [ 0 ] for mapTable in self . getOrderedMapTables ( session ) : if mapTable . name == 'CONTAMINANT_TRANSPORT' : contaminantList = [ ] for mtValue in mapTable . values : if mtValu... | Map Table Write to File Method |
4,725 | def getOrderedMapTables ( self , session ) : return session . query ( MapTable ) . filter ( MapTable . mapTableFile == self ) . order_by ( MapTable . name ) . all ( ) | Retrieve the map tables ordered by name |
4,726 | 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 |
4,727 | def _createGsshaPyObjects ( self , mapTables , indexMaps , replaceParamFile , directory , session , spatial , spatialReferenceID ) : for mt in mapTables : try : if mt [ 'indexMapName' ] is not None : indexMaps [ mt [ 'indexMapName' ] ] mapTable = MapTable ( name = mt [ 'name' ] , numIDs = mt [ 'numVars' ] [ 'NUM_IDS' ]... | Create GSSHAPY Mapping Table ORM Objects Method |
4,728 | 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 ) mtValue = MTValue ( variable = varList [ i ] , value = float ( value... | Populate GSSHAPY MTValue and MTIndex Objects Method |
4,729 | def _readContaminantOutputFiles ( self , directory , baseFileName , session , spatial , spatialReferenceID ) : if not os . path . isdir ( directory ) : return if baseFileName == '' : return chanBaseFileName = '.' . join ( [ baseFileName , 'chan' ] ) directoryList = os . listdir ( directory ) chanFiles = [ ] for thing i... | Read any contaminant output files if available |
4,730 | def _writeMapTable ( self , session , fileObject , mapTable , replaceParamFile ) : fileObject . write ( '%s "%s"\n' % ( mapTable . name , mapTable . indexMap . name ) ) if mapTable . numIDs : fileObject . write ( 'NUM_IDS %s\n' % ( mapTable . numIDs ) ) if mapTable . maxNumCells : fileObject . write ( 'MAX_NUMBER_CELLS... | Write Generic Map Table Method |
4,731 | def _writeContaminantTable ( self , session , fileObject , mapTable , contaminants , replaceParamFile ) : fileObject . write ( '%s\n' % ( mapTable . name ) ) fileObject . write ( 'NUM_CONTAM %s\n' % ( mapTable . numContam ) ) for contaminant in contaminants : fileObject . write ( '"%s" "%s" %s\n' % ( contaminant . na... | This method writes the contaminant transport mapping table case . |
4,732 | def _writeSedimentTable ( self , session , fileObject , mapTable , replaceParamFile ) : fileObject . write ( '%s\n' % ( mapTable . name ) ) fileObject . write ( 'NUM_SED %s\n' % ( mapTable . numSed ) ) fileObject . write ( 'Sediment Description%sSpec. Grav%sPart. Dia%sOutput Filename\n' % ( ' ' * 22 , ' ' * 3 , ' ' * 5... | Write Sediment Mapping Table Method |
4,733 | def _valuePivot ( self , session , mapTable , contaminant , replaceParaFile ) : indexes = session . query ( MTIndex ) . join ( MTValue . index ) . filter ( MTValue . mapTable == mapTable ) . filter ( MTValue . contaminant == contaminant ) . order_by ( MTIndex . index ) . all ( ) layer_indices = [ 0 ] if mapTable . name... | This function retrieves the values of a mapping table from the database and pivots them into the format that is required by the mapping table file . This function returns a list of strings that can be printed to the file directly . |
4,734 | 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 . |
4,735 | def addRoughnessMapFromLandUse ( self , name , session , land_use_grid , land_use_to_roughness_table = None , land_use_grid_id = None , ) : LAND_USE_GRID_TABLES = { 'nga' : 'land_cover_nga.txt' , 'glcf' : 'land_cover_glcf_modis.txt' , 'nlcd' : 'land_cover_nlcd.txt' , } if isinstance ( land_use_to_roughness_table , pd .... | Adds a roughness map from land use file |
4,736 | def _set_wildcards ( self , inputs = None , outputs = None ) : w = self . _wildcards = set ( ) if outputs and inputs : node , wi = self . nodes , self . _wait_in . get w_crd = { u : node [ u ] for u in inputs if u in outputs or wi ( u , False ) } w . update ( [ k for k , v in w_crd . items ( ) if v . get ( 'wildcard' ,... | Update wildcards set with the input data nodes that are also outputs . |
4,737 | 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 . |
4,738 | def _check_targets ( self ) : if self . outputs : targets = self . outputs . copy ( ) def check_targets ( node_id ) : try : targets . remove ( node_id ) return not targets except KeyError : return False else : def check_targets ( node_id ) : return False return check_targets | Returns a function to terminate the ArciDispatch algorithm when all targets have been visited . |
4,739 | def _get_node_estimations ( self , node_attr , node_id ) : estimations = self . _wf_pred [ node_id ] wait_in = node_attr [ 'wait_inputs' ] if len ( estimations ) > 1 and not self . _wait_in . get ( node_id , wait_in ) : dist , edg_length , adj = self . dist , self . _edge_length , self . dmap . adj est = [ ] for k , v ... | Returns the data nodes estimations and wait_inputs flag . |
4,740 | def _set_node_output ( self , node_id , no_call , next_nds = None , ** kw ) : node_attr = self . nodes [ node_id ] node_type = node_attr [ 'type' ] if node_type == 'data' : return self . _set_data_node_output ( node_id , node_attr , no_call , next_nds , ** kw ) elif node_type == 'function' : return self . _set_function... | Set the node outputs from node inputs . |
4,741 | def _set_data_node_output ( self , node_id , node_attr , no_call , next_nds = None , ** kw ) : 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 , ( { k : v [ 'value' ] for k , v... | Set the data node output from node estimations . |
4,742 | def _set_function_node_output ( self , node_id , node_attr , no_call , next_nds = None , ** kw ) : o_nds , dist = node_attr [ 'outputs' ] , self . dist output_nodes = next_nds or set ( self . _succ [ node_id ] ) . difference ( dist ) if not output_nodes : self . workflow . remove_node ( node_id ) return False wf_add_ed... | Set the function node output from node inputs . |
4,743 | def _add_initial_value ( self , data_id , value , initial_dist = 0.0 , fringe = None , check_cutoff = None , no_call = None ) : 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_edge , dsp_in = self . _wf_a... | Add initial values updating workflow seen and fringe . |
4,744 | def _visit_nodes ( self , node_id , dist , fringe , check_cutoff , no_call = False , ** kw ) : 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 self . _visited . add ( node_id ) if not self . _set_node_... | Visits a node updating workflow seen and fringe .. |
4,745 | def _see_node ( self , node_id , fringe , dist , w_wait_in = 0 ) : seen , dists = self . seen , self . dist wait_in = self . nodes [ node_id ] [ 'wait_inputs' ] self . _update_meeting ( node_id , dist ) if self . check_wait_in ( wait_in , node_id ) : pass elif node_id in dists : if dist < dists [ node_id ] : raise Disp... | See a node updating seen and fringe . |
4,746 | def _remove_unused_nodes ( self ) : nodes , wf_remove_node = self . nodes , self . workflow . remove_node add_visited , succ = self . _visited . add , self . workflow . succ for n in ( set ( self . _wf_pred ) - set ( self . _visited ) ) : node_type = nodes [ n ] [ 'type' ] if node_type == 'data' : continue if node_type... | Removes unused function and sub - dispatcher nodes . |
4,747 | def _init_sub_dsp ( self , dsp , fringe , outputs , no_call , initial_dist , index , full_name ) : 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 ) sol . sub_sol = self . sub_sol... | Initialize the dispatcher as sub - dispatcher and update the fringe . |
4,748 | def _set_sub_dsp_node_input ( self , node_id , dsp_id , fringe , check_cutoff , no_call , initial_dist ) : 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 ] self . _meet [ dsp_id ] = initial_dist if self... | Initializes the sub - dispatcher and set its inputs . |
4,749 | 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 . |
4,750 | def _read ( self , directory , filename , session , path , name , extension , spatial , spatialReferenceID , replaceParamFile ) : self . fileExtension = extension KEYWORDS = ( 'STREAMCELLS' , 'CELLIJ' ) with open ( path , 'r' ) as f : chunks = pt . chunk ( KEYWORDS , f ) for key , chunkList in iteritems ( chunks ) : fo... | Grid Stream File Read from File Method |
4,751 | def _write ( self , session , openFile , replaceParamFile ) : 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' % cell .... | Grid Stream File Write to File Method |
4,752 | def _createGsshaPyObjects ( self , cell ) : gridCell = GridStreamCell ( cellI = cell [ 'i' ] , cellJ = cell [ 'j' ] , numNodes = cell [ 'numNodes' ] ) gridCell . gridStreamFile = self for linkNode in cell [ 'linkNodes' ] : gridNode = GridStreamNode ( linkNumber = linkNode [ 'linkNumber' ] , nodeNumber = linkNode [ 'nod... | Create GSSHAPY PipeGridCell and PipeGridNode Objects Method |
4,753 | def _read ( self , directory , filename , session , path , name , extension , spatial , spatialReferenceID , replaceParamFile ) : self . fileExtension = extension with open ( path , 'r' ) as f : self . rasterText = f . read ( ) lines = self . rasterText . split ( '\n' ) for line in lines [ 0 : 6 ] : spline = line . spl... | Index Map Read from File Method |
4,754 | def write ( self , directory , name = None , session = None , replaceParamFile = None ) : if name != None : filename = '%s.%s' % ( name , self . fileExtension ) filePath = os . path . join ( directory , filename ) else : filePath = os . path . join ( directory , self . filename ) if type ( self . raster ) != type ( Non... | Index Map Write to File Method |
4,755 | def _write ( self , session , openFile , replaceParamFile ) : 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 . numPipe... | Grid Pipe File Write to File Method |
4,756 | def _createGsshaPyObjects ( self , cell ) : gridCell = GridPipeCell ( cellI = cell [ 'i' ] , cellJ = cell [ 'j' ] , numPipes = cell [ 'numPipes' ] ) gridCell . gridPipeFile = self for spipe in cell [ 'spipes' ] : gridNode = GridPipeNode ( linkNumber = spipe [ 'linkNumber' ] , nodeNumber = spipe [ 'nodeNumber' ] , fract... | Create GSSHAPY GridPipeCell and GridPipeNode Objects Method |
4,757 | def _cellChunk ( self , lines ) : KEYWORDS = ( 'CELLIJ' , 'NUMPIPES' , 'SPIPE' ) result = { 'i' : None , 'j' : None , 'numPipes' : None , 'spipes' : [ ] } chunks = pt . chunk ( KEYWORDS , lines ) for card , chunkList in iteritems ( chunks ) : for chunk in chunkList : schunk = chunk [ 0 ] . strip ( ) . split ( ) if card... | Parse CELLIJ Chunk Method |
4,758 | def _read ( self , directory , filename , session , path , name , extension , spatial , spatialReferenceID , replaceParamFile ) : self . fileExtension = extension with open ( path , 'r' ) as f : for line in f : sline = line . strip ( ) . split ( ) if len ( sline ) == 1 : self . numParameters = sline [ 0 ] else : target... | Replace Param File Read from File Method |
4,759 | def _write ( self , session , openFile , replaceParamFile ) : targets = self . targetParameters 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 |
4,760 | def _read ( self , directory , filename , session , path , name , extension , spatial , spatialReferenceID , replaceParamFile ) : self . fileExtension = extension with open ( path , 'r' ) as f : for line in f : valLine = ReplaceValLine ( ) valLine . contents = line valLine . replaceValFile = self | Replace Val File Read from File Method |
4,761 | def _write ( self , session , openFile , replaceParamFile ) : for line in self . lines : openFile . write ( line . contents ) | Replace Val File Write to File Method |
4,762 | 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 . |
4,763 | 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 . |
4,764 | 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 . |
4,765 | 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 . |
4,766 | def stop ( self ) : self . threads = { } self . new_threads = { } self . answer = "" self . ask_lock = False | Stop running threads . |
4,767 | 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 . |
4,768 | 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 . |
4,769 | def get_connection ( self , name ) : return self . _api_get ( '/api/connections/{0}' . format ( urllib . parse . quote_plus ( name ) ) ) | An individual connection . |
4,770 | 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 |
4,771 | 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 . |
4,772 | def get_channel ( self , name ) : return self . _api_get ( '/api/channels/{0}' . format ( urllib . parse . quote_plus ( name ) ) ) | Details about an individual channel . |
4,773 | 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 . |
4,774 | 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 . |
4,775 | 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 |
4,776 | 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 . |
4,777 | 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 . |
4,778 | def get_vhost ( self , name ) : return self . _api_get ( '/api/vhosts/{0}' . format ( urllib . parse . quote_plus ( name ) ) ) | Details about an individual vhost . |
4,779 | 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 . |
4,780 | def get_user ( self , name ) : return self . _api_get ( '/api/users/{0}' . format ( urllib . parse . quote_plus ( name ) ) ) | Details about an individual user . |
4,781 | 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 . |
4,782 | 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 . |
4,783 | 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 . |
4,784 | 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 . |
4,785 | 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 . |
4,786 | 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 . |
4,787 | def write ( self , session , directory , name , maskMap ) : name_split = name . split ( '.' ) name = name_split [ 0 ] extension = '' if len ( name_split ) >= 2 : extension = name_split [ - 1 ] try : name = self . _namePreprocessor ( name ) except : 'DO NOTHING' if extension == '' : filename = '{0}.{1}' . format ( name ... | Write from database to file . |
4,788 | def getAsKmlGridAnimation ( self , session , projectFile = None , path = None , documentName = None , colorRamp = None , alpha = 1.0 , noDataValue = 0.0 ) : timeStampedRasters = self . _assembleRasterParams ( projectFile , self . rasters ) converter = RasterConverter ( sqlAlchemyEngineOrSession = session ) if isinstanc... | Retrieve the WMS dataset as a gridded time stamped KML string . |
4,789 | def getAsKmlPngAnimation ( self , session , projectFile = None , path = None , documentName = None , colorRamp = None , alpha = 1.0 , noDataValue = 0 , drawOrder = 0 , cellSize = None , resampleMethod = 'NearestNeighbour' ) : timeStampedRasters = self . _assembleRasterParams ( projectFile , self . rasters ) converter =... | Retrieve the WMS dataset as a PNG time stamped KMZ |
4,790 | def _read ( self , directory , filename , session , path , name , extension , spatial , spatialReferenceID , maskMap ) : self . fileExtension = extension if isinstance ( maskMap , RasterMapFile ) and maskMap . fileExtension == 'msk' : columns = maskMap . columns rows = maskMap . rows upperLeftX = maskMap . west upperLe... | WMS Dataset File Read from File Method |
4,791 | def _write ( self , session , openFile , maskMap ) : FIRST_VALUE_INDEX = 12 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 . VECTOR_TYPE : openFile . write ( 'VECTY... | WMS Dataset File Write to File Method |
4,792 | def getAsWmsDatasetString ( self , session ) : FIRST_VALUE_INDEX = 12 if type ( self . raster ) != type ( None ) : valueGrassRasterString = self . getAsGrassAsciiGrid ( session ) values = valueGrassRasterString . split ( ) wmsDatasetString = '' for i in range ( FIRST_VALUE_INDEX , len ( values ) ) : wmsDatasetString +=... | Retrieve the WMS Raster as a string in the WMS Dataset format |
4,793 | 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 . |
4,794 | 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 . |
4,795 | def fit ( self , inputs , outputs , epochs = 1 ) : self . model . fit ( inputs , outputs , epochs = epochs ) | Simple wrapper of model . fit . |
4,796 | 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 . |
4,797 | 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' return False else : self . run = True return True | if join returns false the node did not entry the ring . Retry it |
4,798 | def _read ( self , directory , filename , session , path , name , extension , spatial , spatialReferenceID , replaceParamFile ) : self . fileExtension = extension with open ( path , 'r' ) as nwsrfsFile : for line in nwsrfsFile : sline = line . strip ( ) . split ( ) if sline [ 0 ] . lower ( ) == 'number_bands:' : self .... | NWSRFS Read from File Method |
4,799 | def _write ( self , session , openFile , replaceParamFile ) : 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' ) records = self . nwsrfsRecords for record in records : openFile . write ( '%s%s%s%s%.... | NWSRFS Write to File Method |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.