idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
28,100 | def increment ( self , gold_set , test_set ) : "Add examples from sets." self . gold += len ( gold_set ) self . test += len ( test_set ) self . correct += len ( gold_set & test_set ) | Add examples from sets . |
28,101 | def output_row ( self , name ) : "Output a scoring row." print ( "%10s %4d %0.3f %0.3f %0.3f" % ( name , self . gold , self . precision ( ) , self . recall ( ) , self . fscore ( ) ) ) | Output a scoring row . |
28,102 | def output ( self ) : "Print out the f-score table." FScore . output_header ( ) nts = list ( self . nt_score . keys ( ) ) nts . sort ( ) for nt in nts : self . nt_score [ nt ] . output_row ( nt ) print ( ) self . total_score . output_row ( "total" ) | Print out the f - score table . |
28,103 | def invoke ( ctx , data_file ) : click . echo ( 'invoking' ) response = ctx . invoke ( data_file . read ( ) ) log_data = base64 . b64decode ( response [ 'LogResult' ] ) click . echo ( log_data ) click . echo ( 'Response:' ) click . echo ( response [ 'Payload' ] . read ( ) ) click . echo ( 'done' ) | Invoke the command synchronously |
28,104 | def tail ( ctx ) : click . echo ( 'tailing logs' ) for e in ctx . tail ( ) [ - 10 : ] : ts = datetime . utcfromtimestamp ( e [ 'timestamp' ] // 1000 ) . isoformat ( ) click . echo ( "{}: {}" . format ( ts , e [ 'message' ] ) ) click . echo ( 'done' ) | Show the last 10 lines of the log file |
28,105 | def status ( ctx ) : status = ctx . status ( ) click . echo ( click . style ( 'Policy' , bold = True ) ) if status [ 'policy' ] : line = ' {} ({})' . format ( status [ 'policy' ] [ 'PolicyName' ] , status [ 'policy' ] [ 'Arn' ] ) click . echo ( click . style ( line , fg = 'green' ) ) click . echo ( click . style ( '... | Print a status of this Lambda function |
28,106 | def event_sources ( ctx , command ) : if command == 'list' : click . echo ( 'listing event sources' ) event_sources = ctx . list_event_sources ( ) for es in event_sources : click . echo ( 'arn: {}' . format ( es [ 'arn' ] ) ) click . echo ( 'starting position: {}' . format ( es [ 'starting_position' ] ) ) click . echo ... | List enable and disable event sources specified in the config file |
28,107 | def check_interface_is_subset ( circuit1 , circuit2 ) : circuit1_port_names = circuit1 . interface . ports . keys ( ) for name in circuit1_port_names : if name not in circuit2 . interface . ports : raise ValueError ( f"{circuit2} (circuit2) does not have port {name}" ) circuit1_kind = type ( type ( getattr ( circuit1 ,... | Checks that the interface of circuit1 is a subset of circuit2 |
28,108 | def CoerceValue ( value , value_type ) : if isinstance ( value , tuple ) : if ( len ( value ) not in [ 2 , 3 ] or ( len ( value ) == 3 and not isinstance ( value [ 2 ] , dict ) ) ) : raise DataTableException ( "Wrong format for value and formatting - %s." % str ( value ) ) if not isinstance ( value [ 1 ] , six . string... | Coerces a single value into the type expected for its column . |
28,109 | def ColumnTypeParser ( description ) : if not description : raise DataTableException ( "Description error: empty description given" ) if not isinstance ( description , ( six . string_types , tuple ) ) : raise DataTableException ( "Description error: expected either string or " "tuple, got %s." % type ( description ) ) ... | Parses a single column description . Internal helper method . |
28,110 | def TableDescriptionParser ( table_description , depth = 0 ) : if isinstance ( table_description , ( six . string_types , tuple ) ) : parsed_col = DataTable . ColumnTypeParser ( table_description ) parsed_col [ "depth" ] = depth parsed_col [ "container" ] = "scalar" return [ parsed_col ] if not hasattr ( table_descript... | Parses the table_description object for internal use . |
28,111 | def LoadData ( self , data , custom_properties = None ) : self . __data = [ ] self . AppendData ( data , custom_properties ) | Loads new rows to the data table clearing existing rows . |
28,112 | def AppendData ( self , data , custom_properties = None ) : if not self . __columns [ - 1 ] [ "depth" ] : for row in data : self . _InnerAppendData ( ( { } , custom_properties ) , row , 0 ) else : self . _InnerAppendData ( ( { } , custom_properties ) , data , 0 ) | Appends new data to the table . |
28,113 | def _InnerAppendData ( self , prev_col_values , data , col_index ) : if col_index >= len ( self . __columns ) : raise DataTableException ( "The data does not match description, too deep" ) if self . __columns [ col_index ] [ "container" ] == "scalar" : prev_col_values [ 0 ] [ self . __columns [ col_index ] [ "id" ] ] =... | Inner function to assist LoadData . |
28,114 | def _PreparedData ( self , order_by = ( ) ) : if not order_by : return self . __data sorted_data = self . __data [ : ] if isinstance ( order_by , six . string_types ) or ( isinstance ( order_by , tuple ) and len ( order_by ) == 2 and order_by [ 1 ] . lower ( ) in [ "asc" , "desc" ] ) : order_by = ( order_by , ) for key... | Prepares the data for enumeration - sorting it by order_by . |
28,115 | def ToJSCode ( self , name , columns_order = None , order_by = ( ) ) : encoder = DataTableJSONEncoder ( ) if columns_order is None : columns_order = [ col [ "id" ] for col in self . __columns ] col_dict = dict ( [ ( col [ "id" ] , col ) for col in self . __columns ] ) jscode = "var %s = new google.visualization.DataTab... | Writes the data table as a JS code string . |
28,116 | def ToHtml ( self , columns_order = None , order_by = ( ) ) : table_template = "<html><body><table border=\"1\">%s</table></body></html>" columns_template = "<thead><tr>%s</tr></thead>" rows_template = "<tbody>%s</tbody>" row_template = "<tr>%s</tr>" header_cell_template = "<th>%s</th>" cell_template = "<td>%s</td>" if... | Writes the data table as an HTML table code string . |
28,117 | def ToCsv ( self , columns_order = None , order_by = ( ) , separator = "," ) : csv_buffer = six . StringIO ( ) writer = csv . writer ( csv_buffer , delimiter = separator ) if columns_order is None : columns_order = [ col [ "id" ] for col in self . __columns ] col_dict = dict ( [ ( col [ "id" ] , col ) for col in self .... | Writes the data table as a CSV string . |
28,118 | def ToTsvExcel ( self , columns_order = None , order_by = ( ) ) : csv_result = self . ToCsv ( columns_order , order_by , separator = "\t" ) if not isinstance ( csv_result , six . text_type ) : csv_result = csv_result . decode ( "utf-8" ) return csv_result . encode ( "UTF-16LE" ) | Returns a file in tab - separated - format readable by MS Excel . |
28,119 | def _ToJSonObj ( self , columns_order = None , order_by = ( ) ) : if columns_order is None : columns_order = [ col [ "id" ] for col in self . __columns ] col_dict = dict ( [ ( col [ "id" ] , col ) for col in self . __columns ] ) col_objs = [ ] for col_id in columns_order : col_obj = { "id" : col_dict [ col_id ] [ "id" ... | Returns an object suitable to be converted to JSON . |
28,120 | def ToJSon ( self , columns_order = None , order_by = ( ) ) : encoded_response_str = DataTableJSONEncoder ( ) . encode ( self . _ToJSonObj ( columns_order , order_by ) ) if not isinstance ( encoded_response_str , str ) : return encoded_response_str . encode ( "utf-8" ) return encoded_response_str | Returns a string that can be used in a JS DataTable constructor . |
28,121 | def ToJSonResponse ( self , columns_order = None , order_by = ( ) , req_id = 0 , response_handler = "google.visualization.Query.setResponse" ) : response_obj = { "version" : "0.6" , "reqId" : str ( req_id ) , "table" : self . _ToJSonObj ( columns_order , order_by ) , "status" : "ok" } encoded_response_str = DataTableJS... | Writes a table as a JSON response that can be returned as - is to a client . |
28,122 | def ToResponse ( self , columns_order = None , order_by = ( ) , tqx = "" ) : tqx_dict = { } if tqx : tqx_dict = dict ( opt . split ( ":" ) for opt in tqx . split ( ";" ) ) if tqx_dict . get ( "version" , "0.6" ) != "0.6" : raise DataTableException ( "Version (%s) passed by request is not supported." % tqx_dict [ "versi... | Writes the right response according to the request string passed in tqx . |
28,123 | def copy_fields ( self , model ) : fields = { '__module__' : model . __module__ } for field in model . _meta . fields : if not field . name in self . _exclude : field = copy . deepcopy ( field ) if isinstance ( field , models . AutoField ) : field . __class__ = models . IntegerField if field . primary_key : field . ser... | Creates copies of the fields we are keeping track of for the provided model returning a dictionary mapping field name to a copied field object . |
28,124 | def get_logging_fields ( self , model ) : rel_name = '_%s_audit_log_entry' % model . _meta . object_name . lower ( ) def entry_instance_to_unicode ( log_entry ) : try : result = '%s: %s %s at %s' % ( model . _meta . object_name , log_entry . object_state , log_entry . get_action_type_display ( ) . lower ( ) , log_entry... | Returns a dictionary mapping of the fields that are used for keeping the acutal audit log entries . |
28,125 | def get_meta_options ( self , model ) : result = { 'ordering' : ( '-action_date' , ) , 'app_label' : model . _meta . app_label , } from django . db . models . options import DEFAULT_NAMES if 'default_permissions' in DEFAULT_NAMES : result . update ( { 'default_permissions' : ( ) } ) return result | Returns a dictionary of Meta options for the autdit log model . |
28,126 | def create_log_entry_model ( self , model ) : attrs = self . copy_fields ( model ) attrs . update ( self . get_logging_fields ( model ) ) attrs . update ( Meta = type ( str ( 'Meta' ) , ( ) , self . get_meta_options ( model ) ) ) name = str ( '%sAuditLogEntry' % model . _meta . object_name ) return type ( name , ( mode... | Creates a log entry model that will be associated with the model provided . |
28,127 | def decode_kempressed ( bytestring ) : subvol = fpzip . decompress ( bytestring , order = 'F' ) return np . swapaxes ( subvol , 3 , 2 ) - 2.0 | subvol not bytestring since numpy conversion is done inside fpzip extension . |
28,128 | def bbox2array ( vol , bbox , order = 'F' , readonly = False , lock = None , location = None ) : location = location or vol . shared_memory_id shape = list ( bbox . size3 ( ) ) + [ vol . num_channels ] return ndarray ( shape = shape , dtype = vol . dtype , location = location , readonly = readonly , lock = lock , order... | Convenince method for creating a shared memory numpy array based on a CloudVolume and Bbox . c . f . sharedmemory . ndarray for information on the optional lock parameter . |
28,129 | def ndarray_fs ( shape , dtype , location , lock , readonly = False , order = 'F' , ** kwargs ) : dbytes = np . dtype ( dtype ) . itemsize nbytes = Vec ( * shape ) . rectVolume ( ) * dbytes directory = mkdir ( EMULATED_SHM_DIRECTORY ) filename = os . path . join ( directory , location ) if lock : lock . acquire ( ) exi... | Emulate shared memory using the filesystem . |
28,130 | def cutout ( vol , requested_bbox , steps , channel_slice = slice ( None ) , parallel = 1 , shared_memory_location = None , output_to_shared_memory = False ) : global fs_lock cloudpath_bbox = requested_bbox . expand_to_chunk_size ( vol . underlying , offset = vol . voxel_offset ) cloudpath_bbox = Bbox . clamp ( cloudpa... | Cutout a requested bounding box from storage and return it as a numpy array . |
28,131 | def decode ( vol , filename , content ) : bbox = Bbox . from_filename ( filename ) content_len = len ( content ) if content is not None else 0 if not content : if vol . fill_missing : content = '' else : raise EmptyVolumeException ( filename ) shape = list ( bbox . size3 ( ) ) + [ vol . num_channels ] try : return chun... | Decode content according to settings in a cloudvolume instance . |
28,132 | def shade ( renderbuffer , bufferbbox , img3d , bbox ) : if not Bbox . intersects ( bufferbbox , bbox ) : return spt = max2 ( bbox . minpt , bufferbbox . minpt ) ept = min2 ( bbox . maxpt , bufferbbox . maxpt ) ZERO3 = Vec ( 0 , 0 , 0 ) istart = max2 ( spt - bbox . minpt , ZERO3 ) iend = min2 ( ept - bbox . maxpt , ZER... | Shade a renderbuffer with a downloaded chunk . The buffer will only be painted in the overlapping region of the content . |
28,133 | def cdn_cache_control ( val ) : if val is None : return 'max-age=3600, s-max-age=3600' elif type ( val ) is str : return val elif type ( val ) is bool : if val : return 'max-age=3600, s-max-age=3600' else : return 'no-cache' elif type ( val ) is int : if val < 0 : raise ValueError ( 'cdn_cache must be a positive intege... | Translate cdn_cache into a Cache - Control HTTP header . |
28,134 | def upload_image ( vol , img , offset , parallel = 1 , manual_shared_memory_id = None , manual_shared_memory_bbox = None , manual_shared_memory_order = 'F' ) : global NON_ALIGNED_WRITE if not np . issubdtype ( img . dtype , np . dtype ( vol . dtype ) . type ) : raise ValueError ( 'The uploaded image data type must matc... | Upload img to vol with offset . This is the primary entry point for uploads . |
28,135 | def decompress ( content , encoding , filename = 'N/A' ) : try : encoding = ( encoding or '' ) . lower ( ) if encoding == '' : return content elif encoding == 'gzip' : return gunzip ( content ) except DecompressionError as err : print ( "Filename: " + str ( filename ) ) raise raise NotImplementedError ( str ( encoding ... | Decompress file content . |
28,136 | def compress ( content , method = 'gzip' ) : if method == True : method = 'gzip' method = ( method or '' ) . lower ( ) if method == '' : return content elif method == 'gzip' : return gzip_compress ( content ) raise NotImplementedError ( str ( method ) + ' is not currently supported. Supported Options: None, gzip' ) | Compresses file content . |
28,137 | def gunzip ( content ) : gzip_magic_numbers = [ 0x1f , 0x8b ] first_two_bytes = [ byte for byte in bytearray ( content ) [ : 2 ] ] if first_two_bytes != gzip_magic_numbers : raise DecompressionError ( 'File is not in gzip format. Magic numbers {}, {} did not match {}, {}.' . format ( hex ( first_two_bytes [ 0 ] ) , hex... | Decompression is applied if the first to bytes matches with the gzip magic numbers . There is once chance in 65536 that a file that is not gzipped will be ungzipped . |
28,138 | def flush ( self , preserve = None ) : if not os . path . exists ( self . path ) : return if preserve is None : shutil . rmtree ( self . path ) return for mip in self . vol . available_mips : preserve_mip = self . vol . slices_from_global_coords ( preserve ) preserve_mip = Bbox . from_slices ( preserve_mip ) mip_path =... | Delete the cache for this dataset . Optionally preserve a region . Helpful when working with overlaping volumes . |
28,139 | def flush_region ( self , region , mips = None ) : if not os . path . exists ( self . path ) : return if type ( region ) in ( list , tuple ) : region = generate_slices ( region , self . vol . bounds . minpt , self . vol . bounds . maxpt , bounded = False ) region = Bbox . from_slices ( region ) mips = self . vol . mip ... | Delete a cache region at one or more mip levels bounded by a Bbox for this dataset . Bbox coordinates should be specified in mip 0 coordinates . |
28,140 | def save_images ( self , directory = None , axis = 'z' , channel = None , global_norm = True , image_format = 'PNG' ) : if directory is None : directory = os . path . join ( './saved_images' , self . dataset_name , self . layer , str ( self . mip ) , self . bounds . to_filename ( ) ) return save_images ( self , directo... | See cloudvolume . lib . save_images for more information . |
28,141 | def from_path ( kls , vertices ) : if vertices . shape [ 0 ] == 0 : return PrecomputedSkeleton ( ) skel = PrecomputedSkeleton ( vertices ) edges = np . zeros ( shape = ( skel . vertices . shape [ 0 ] - 1 , 2 ) , dtype = np . uint32 ) edges [ : , 0 ] = np . arange ( skel . vertices . shape [ 0 ] - 1 ) edges [ : , 1 ] = ... | Given an Nx3 array of vertices that constitute a single path generate a skeleton with appropriate edges . |
28,142 | def simple_merge ( kls , skeletons ) : if len ( skeletons ) == 0 : return PrecomputedSkeleton ( ) if type ( skeletons [ 0 ] ) is np . ndarray : skeletons = [ skeletons ] ct = 0 edges = [ ] for skel in skeletons : edge = skel . edges + ct edges . append ( edge ) ct += skel . vertices . shape [ 0 ] return PrecomputedSkel... | Simple concatenation of skeletons into one object without adding edges between them . |
28,143 | def decode ( kls , skelbuf , segid = None ) : if len ( skelbuf ) < 8 : raise SkeletonDecodeError ( "{} bytes is fewer than needed to specify the number of verices and edges." . format ( len ( skelbuf ) ) ) num_vertices , num_edges = struct . unpack ( '<II' , skelbuf [ : 8 ] ) min_format_length = 8 + 12 * num_vertices +... | Convert a buffer into a PrecomputedSkeleton object . |
28,144 | def equivalent ( kls , first , second ) : if first . empty ( ) and second . empty ( ) : return True elif first . vertices . shape [ 0 ] != second . vertices . shape [ 0 ] : return False elif first . edges . shape [ 0 ] != second . edges . shape [ 0 ] : return False EPSILON = 1e-7 vertex1 , inv1 = np . unique ( first . ... | Tests that two skeletons are the same in form not merely that their array contents are exactly the same . This test can be made more sophisticated . |
28,145 | def crop ( self , bbox ) : skeleton = self . clone ( ) bbox = Bbox . create ( bbox ) if skeleton . empty ( ) : return skeleton nodes_valid_mask = np . array ( [ bbox . contains ( vtx ) for vtx in skeleton . vertices ] , dtype = np . bool ) nodes_valid_idx = np . where ( nodes_valid_mask ) [ 0 ] if nodes_valid_idx . sha... | Crop away all vertices and edges that lie outside of the given bbox . The edge counts as inside . |
28,146 | def consolidate ( self ) : nodes = self . vertices edges = self . edges radii = self . radii vertex_types = self . vertex_types if self . empty ( ) : return PrecomputedSkeleton ( ) eff_nodes , uniq_idx , idx_representative = np . unique ( nodes , axis = 0 , return_index = True , return_inverse = True ) edge_vector_map ... | Remove duplicate vertices and edges from this skeleton without side effects . |
28,147 | def downsample ( self , factor ) : if int ( factor ) != factor or factor < 1 : raise ValueError ( "Argument `factor` must be a positive integer greater than or equal to 1. Got: <{}>({})" , type ( factor ) , factor ) paths = self . interjoint_paths ( ) for i , path in enumerate ( paths ) : paths [ i ] = np . concatenate... | Compute a downsampled version of the skeleton by striding while preserving endpoints . |
28,148 | def _single_tree_paths ( self , tree ) : skel = tree . consolidate ( ) tree = defaultdict ( list ) for edge in skel . edges : svert = edge [ 0 ] evert = edge [ 1 ] tree [ svert ] . append ( evert ) tree [ evert ] . append ( svert ) def dfs ( path , visited ) : paths = [ ] stack = [ ( path , visited ) ] while stack : pa... | Get all traversal paths from a single tree . |
28,149 | def paths ( self ) : paths = [ ] for tree in self . components ( ) : paths += self . _single_tree_paths ( tree ) return paths | Assuming the skeleton is structured as a single tree return a list of all traversal paths across all components . For each component start from the first vertex find the most distant vertex by hops and set that as the root . Then use depth first traversal to produce paths . |
28,150 | def interjoint_paths ( self ) : paths = [ ] for tree in self . components ( ) : subpaths = self . _single_tree_interjoint_paths ( tree ) paths . extend ( subpaths ) return paths | Returns paths between the adjacent critical points in the skeleton where a critical point is the set of terminal and branch points . |
28,151 | def components ( self ) : skel , forest = self . _compute_components ( ) if len ( forest ) == 0 : return [ ] elif len ( forest ) == 1 : return [ skel ] orig_verts = { tuple ( coord ) : i for i , coord in enumerate ( skel . vertices ) } skeletons = [ ] for edge_list in forest : edge_list = np . array ( edge_list , dtype... | Extract connected components from graph . Useful for ensuring that you re working with a single tree . |
28,152 | def get ( self , segids ) : list_return = True if type ( segids ) in ( int , float ) : list_return = False segids = [ int ( segids ) ] paths = [ os . path . join ( self . path , str ( segid ) ) for segid in segids ] StorageClass = Storage if len ( segids ) > 1 else SimpleStorage with StorageClass ( self . vol . layer_c... | Retrieve one or more skeletons from the data layer . |
28,153 | def put ( self , fn ) : self . _inserted += 1 self . _queue . put ( fn , block = True ) return self | Enqueue a task function for processing . |
28,154 | def start_threads ( self , n_threads ) : if n_threads == len ( self . _threads ) : return self self . _terminate . set ( ) self . _terminate = threading . Event ( ) threads = [ ] for _ in range ( n_threads ) : worker = threading . Thread ( target = self . _consume_queue , args = ( self . _terminate , ) ) worker . daemo... | Terminate existing threads and create a new set if the thread number doesn t match the desired number . |
28,155 | def kill_threads ( self ) : self . _terminate . set ( ) while self . are_threads_alive ( ) : time . sleep ( 0.001 ) self . _threads = ( ) return self | Kill all threads . |
28,156 | def wait ( self , progress = None ) : if not len ( self . _threads ) : return self desc = None if type ( progress ) is str : desc = progress last = self . _inserted with tqdm ( total = self . _inserted , disable = ( not progress ) , desc = desc ) as pbar : while not self . _queue . empty ( ) : size = self . _queue . qs... | Allow background threads to process until the task queue is empty . If there are no threads in theory the queue should always be empty as processing happens immediately on the main thread . |
28,157 | def _radix_sort ( L , i = 0 ) : if len ( L ) <= 1 : return L done_bucket = [ ] buckets = [ [ ] for x in range ( 255 ) ] for s in L : if i >= len ( s ) : done_bucket . append ( s ) else : buckets [ ord ( s [ i ] ) ] . append ( s ) buckets = [ _radix_sort ( b , i + 1 ) for b in buckets ] return done_bucket + [ b for blis... | Most significant char radix sort |
28,158 | def files_exist ( self , file_paths ) : results = { } def exist_thunk ( paths , interface ) : results . update ( interface . files_exist ( paths ) ) if len ( self . _threads ) : for block in scatter ( file_paths , len ( self . _threads ) ) : self . put ( partial ( exist_thunk , block ) ) else : exist_thunk ( file_paths... | Threaded exists for all file paths . |
28,159 | def get_files ( self , file_paths ) : results = [ ] def get_file_thunk ( path , interface ) : result = error = None try : result = interface . get_file ( path ) except Exception as err : error = err print ( err ) content , encoding = result content = compression . decompress ( content , encoding ) results . append ( { ... | returns a list of files faster by using threads |
28,160 | def get_file ( self , file_path ) : try : resp = self . _conn . get_object ( Bucket = self . _path . bucket , Key = self . get_path_to_file ( file_path ) , ) encoding = '' if 'ContentEncoding' in resp : encoding = resp [ 'ContentEncoding' ] return resp [ 'Body' ] . read ( ) , encoding except botocore . exceptions . Cli... | There are many types of execptions which can get raised from this method . We want to make sure we only return None when the file doesn t exist . |
28,161 | def init_submodules ( self , cache ) : self . cache = CacheService ( cache , weakref . proxy ( self ) ) self . mesh = PrecomputedMeshService ( weakref . proxy ( self ) ) self . skeleton = PrecomputedSkeletonService ( weakref . proxy ( self ) ) | cache = path or bool |
28,162 | def create_new_info ( cls , num_channels , layer_type , data_type , encoding , resolution , voxel_offset , volume_size , mesh = None , skeletons = None , chunk_size = ( 64 , 64 , 64 ) , compressed_segmentation_block_size = ( 8 , 8 , 8 ) , max_mip = 0 , factor = Vec ( 2 , 2 , 1 ) ) : if not isinstance ( factor , Vec ) :... | Used for creating new neuroglancer info files . |
28,163 | def bbox_to_mip ( self , bbox , mip , to_mip ) : if not type ( bbox ) is Bbox : bbox = lib . generate_slices ( bbox , self . mip_bounds ( mip ) . minpt , self . mip_bounds ( mip ) . maxpt , bounded = False ) bbox = Bbox . from_slices ( bbox ) def one_level ( bbox , mip , to_mip ) : original_dtype = bbox . dtype downsam... | Convert bbox or slices from one mip level to another . |
28,164 | def slices_to_global_coords ( self , slices ) : bbox = self . bbox_to_mip ( slices , self . mip , 0 ) return bbox . to_slices ( ) | Used to convert from a higher mip level into mip 0 resolution . |
28,165 | def slices_from_global_coords ( self , slices ) : bbox = self . bbox_to_mip ( slices , 0 , self . mip ) return bbox . to_slices ( ) | Used for converting from mip 0 coordinates to upper mip level coordinates . This is mainly useful for debugging since the neuroglancer client displays the mip 0 coordinates for your cursor . |
28,166 | def __realized_bbox ( self , requested_bbox ) : realized_bbox = requested_bbox . expand_to_chunk_size ( self . underlying , offset = self . voxel_offset ) return Bbox . clamp ( realized_bbox , self . bounds ) | The requested bbox might not be aligned to the underlying chunk grid or even outside the bounds of the dataset . Convert the request into a bbox representing something that can be actually downloaded . |
28,167 | def exists ( self , bbox_or_slices ) : if type ( bbox_or_slices ) is Bbox : requested_bbox = bbox_or_slices else : ( requested_bbox , _ , _ ) = self . __interpret_slices ( bbox_or_slices ) realized_bbox = self . __realized_bbox ( requested_bbox ) cloudpaths = txrx . chunknames ( realized_bbox , self . bounds , self . k... | Produce a summary of whether all the requested chunks exist . |
28,168 | def delete ( self , bbox_or_slices ) : if type ( bbox_or_slices ) is Bbox : requested_bbox = bbox_or_slices else : ( requested_bbox , _ , _ ) = self . __interpret_slices ( bbox_or_slices ) realized_bbox = self . __realized_bbox ( requested_bbox ) if requested_bbox != realized_bbox : raise exceptions . AlignmentError ( ... | Delete the files within the bounding box . |
28,169 | def transfer_to ( self , cloudpath , bbox , block_size = None , compress = True ) : if type ( bbox ) is Bbox : requested_bbox = bbox else : ( requested_bbox , _ , _ ) = self . __interpret_slices ( bbox ) realized_bbox = self . __realized_bbox ( requested_bbox ) if requested_bbox != realized_bbox : raise exceptions . Al... | Transfer files from one storage location to another bypassing volume painting . This enables using a single CloudVolume instance to transfer big volumes . In some cases gsutil or aws s3 cli tools may be more appropriate . This method is provided for convenience . It may be optimized for better performance over time as ... |
28,170 | def download_point ( self , pt , size = 256 , mip = None ) : if isinstance ( size , int ) : size = Vec ( size , size , size ) else : size = Vec ( * size ) if mip is None : mip = self . mip size2 = size // 2 pt = self . point_to_mip ( pt , mip = 0 , to_mip = mip ) bbox = Bbox ( pt - size2 , pt + size2 ) saved_mip = self... | Download to the right of point given in mip 0 coords . Useful for quickly visualizing a neuroglancer coordinate at an arbitary mip level . |
28,171 | def download_to_shared_memory ( self , slices , location = None ) : if self . path . protocol == 'boss' : raise NotImplementedError ( 'BOSS protocol does not support shared memory download.' ) if type ( slices ) == Bbox : slices = slices . to_slices ( ) ( requested_bbox , steps , channel_slice ) = self . __interpret_sl... | Download images to a shared memory array . |
28,172 | def get ( self , segids , remove_duplicate_vertices = True , fuse = True , chunk_size = None ) : segids = toiter ( segids ) dne = self . _check_missing_manifests ( segids ) if dne : missing = ', ' . join ( [ str ( segid ) for segid in dne ] ) raise ValueError ( red ( 'Segment ID(s) {} are missing corresponding mesh man... | Merge fragments derived from these segids into a single vertex and face list . |
28,173 | def _check_missing_manifests ( self , segids ) : manifest_paths = [ self . _manifest_path ( segid ) for segid in segids ] with Storage ( self . vol . layer_cloudpath , progress = self . vol . progress ) as stor : exists = stor . files_exist ( manifest_paths ) dne = [ ] for path , there in exists . items ( ) : if not th... | Check if there are any missing mesh manifests prior to downloading . |
28,174 | def save ( self , segids , filepath = None , file_format = 'ply' ) : if type ( segids ) != list : segids = [ segids ] meshdata = self . get ( segids ) if not filepath : filepath = str ( segids [ 0 ] ) + "." + file_format if len ( segids ) > 1 : filepath = "{}_{}.{}" . format ( segids [ 0 ] , segids [ - 1 ] , file_forma... | Save one or more segids into a common mesh format as a single file . |
28,175 | def pad_block ( block , block_size ) : unique_vals , unique_counts = np . unique ( block , return_counts = True ) most_frequent_value = unique_vals [ np . argmax ( unique_counts ) ] return np . pad ( block , tuple ( ( 0 , desired_size - actual_size ) for desired_size , actual_size in zip ( block_size , block . shape ) ... | Pad a block to block_size with its most frequent value |
28,176 | def find_closest_divisor ( to_divide , closest_to ) : def find_closest ( td , ct ) : min_distance = td best = td for divisor in divisors ( td ) : if abs ( divisor - ct ) < min_distance : min_distance = abs ( divisor - ct ) best = divisor return best return [ find_closest ( td , ct ) for td , ct in zip ( to_divide , clo... | This is used to find the right chunk size for importing a neuroglancer dataset that has a chunk import size that s not evenly divisible by 64 64 64 . |
28,177 | def divisors ( n ) : for i in range ( 1 , int ( math . sqrt ( n ) + 1 ) ) : if n % i == 0 : yield i if i * i != n : yield n / i | Generate the divisors of n |
28,178 | def expand_to_chunk_size ( self , chunk_size , offset = Vec ( 0 , 0 , 0 , dtype = int ) ) : chunk_size = np . array ( chunk_size , dtype = np . float32 ) result = self . clone ( ) result = result - offset result . minpt = np . floor ( result . minpt / chunk_size ) * chunk_size result . maxpt = np . ceil ( result . maxp... | Align a potentially non - axis aligned bbox to the grid by growing it to the nearest grid lines . |
28,179 | def round_to_chunk_size ( self , chunk_size , offset = Vec ( 0 , 0 , 0 , dtype = int ) ) : chunk_size = np . array ( chunk_size , dtype = np . float32 ) result = self . clone ( ) result = result - offset result . minpt = np . round ( result . minpt / chunk_size ) * chunk_size result . maxpt = np . round ( result . maxp... | Align a potentially non - axis aligned bbox to the grid by rounding it to the nearest grid lines . |
28,180 | def contains ( self , point ) : return ( point [ 0 ] >= self . minpt [ 0 ] and point [ 1 ] >= self . minpt [ 1 ] and point [ 2 ] >= self . minpt [ 2 ] and point [ 0 ] <= self . maxpt [ 0 ] and point [ 1 ] <= self . maxpt [ 1 ] and point [ 2 ] <= self . maxpt [ 2 ] ) | Tests if a point on or within a bounding box . |
28,181 | def display ( self , display ) : if display is None : raise ValueError ( "Invalid value for `display`, must not be `None`" ) allowed_values = [ "BANNER" , "TOASTER" ] if display not in allowed_values : raise ValueError ( "Invalid value for `display` ({0}), must be one of {1}" . format ( display , allowed_values ) ) sel... | Sets the display of this Message . |
28,182 | def scope ( self , scope ) : if scope is None : raise ValueError ( "Invalid value for `scope`, must not be `None`" ) allowed_values = [ "CLUSTER" , "CUSTOMER" , "USER" ] if scope not in allowed_values : raise ValueError ( "Invalid value for `scope` ({0}), must be one of {1}" . format ( scope , allowed_values ) ) self .... | Sets the scope of this Message . |
28,183 | def severity ( self , severity ) : if severity is None : raise ValueError ( "Invalid value for `severity`, must not be `None`" ) allowed_values = [ "MARKETING" , "INFO" , "WARN" , "SEVERE" ] if severity not in allowed_values : raise ValueError ( "Invalid value for `severity` ({0}), must be one of {1}" . format ( severi... | Sets the severity of this Message . |
28,184 | def facet_query_matching_method ( self , facet_query_matching_method ) : allowed_values = [ "CONTAINS" , "STARTSWITH" , "EXACT" , "TAGPATH" ] if facet_query_matching_method not in allowed_values : raise ValueError ( "Invalid value for `facet_query_matching_method` ({0}), must be one of {1}" . format ( facet_query_match... | Sets the facet_query_matching_method of this FacetSearchRequestContainer . |
28,185 | def running_state ( self , running_state ) : allowed_values = [ "ONGOING" , "PENDING" , "ENDED" ] if running_state not in allowed_values : raise ValueError ( "Invalid value for `running_state` ({0}), must be one of {1}" . format ( running_state , allowed_values ) ) self . _running_state = running_state | Sets the running_state of this MaintenanceWindow . |
28,186 | def dynamic_field_type ( self , dynamic_field_type ) : allowed_values = [ "SOURCE" , "SOURCE_TAG" , "METRIC_NAME" , "TAG_KEY" , "MATCHING_SOURCE_TAG" ] if dynamic_field_type not in allowed_values : raise ValueError ( "Invalid value for `dynamic_field_type` ({0}), must be one of {1}" . format ( dynamic_field_type , allo... | Sets the dynamic_field_type of this DashboardParameterValue . |
28,187 | def parameter_type ( self , parameter_type ) : allowed_values = [ "SIMPLE" , "LIST" , "DYNAMIC" ] if parameter_type not in allowed_values : raise ValueError ( "Invalid value for `parameter_type` ({0}), must be one of {1}" . format ( parameter_type , allowed_values ) ) self . _parameter_type = parameter_type | Sets the parameter_type of this DashboardParameterValue . |
28,188 | def fixed_legend_filter_field ( self , fixed_legend_filter_field ) : allowed_values = [ "CURRENT" , "MEAN" , "MEDIAN" , "SUM" , "MIN" , "MAX" , "COUNT" ] if fixed_legend_filter_field not in allowed_values : raise ValueError ( "Invalid value for `fixed_legend_filter_field` ({0}), must be one of {1}" . format ( fixed_leg... | Sets the fixed_legend_filter_field of this ChartSettings . |
28,189 | def fixed_legend_filter_sort ( self , fixed_legend_filter_sort ) : allowed_values = [ "TOP" , "BOTTOM" ] if fixed_legend_filter_sort not in allowed_values : raise ValueError ( "Invalid value for `fixed_legend_filter_sort` ({0}), must be one of {1}" . format ( fixed_legend_filter_sort , allowed_values ) ) self . _fixed_... | Sets the fixed_legend_filter_sort of this ChartSettings . |
28,190 | def fixed_legend_position ( self , fixed_legend_position ) : allowed_values = [ "RIGHT" , "TOP" , "LEFT" , "BOTTOM" ] if fixed_legend_position not in allowed_values : raise ValueError ( "Invalid value for `fixed_legend_position` ({0}), must be one of {1}" . format ( fixed_legend_position , allowed_values ) ) self . _fi... | Sets the fixed_legend_position of this ChartSettings . |
28,191 | def line_type ( self , line_type ) : allowed_values = [ "linear" , "step-before" , "step-after" , "basis" , "cardinal" , "monotone" ] if line_type not in allowed_values : raise ValueError ( "Invalid value for `line_type` ({0}), must be one of {1}" . format ( line_type , allowed_values ) ) self . _line_type = line_type | Sets the line_type of this ChartSettings . |
28,192 | def sparkline_display_horizontal_position ( self , sparkline_display_horizontal_position ) : allowed_values = [ "MIDDLE" , "LEFT" , "RIGHT" ] if sparkline_display_horizontal_position not in allowed_values : raise ValueError ( "Invalid value for `sparkline_display_horizontal_position` ({0}), must be one of {1}" . format... | Sets the sparkline_display_horizontal_position of this ChartSettings . |
28,193 | def sparkline_display_value_type ( self , sparkline_display_value_type ) : allowed_values = [ "VALUE" , "LABEL" ] if sparkline_display_value_type not in allowed_values : raise ValueError ( "Invalid value for `sparkline_display_value_type` ({0}), must be one of {1}" . format ( sparkline_display_value_type , allowed_valu... | Sets the sparkline_display_value_type of this ChartSettings . |
28,194 | def sparkline_size ( self , sparkline_size ) : allowed_values = [ "BACKGROUND" , "BOTTOM" , "NONE" ] if sparkline_size not in allowed_values : raise ValueError ( "Invalid value for `sparkline_size` ({0}), must be one of {1}" . format ( sparkline_size , allowed_values ) ) self . _sparkline_size = sparkline_size | Sets the sparkline_size of this ChartSettings . |
28,195 | def sparkline_value_color_map_apply_to ( self , sparkline_value_color_map_apply_to ) : allowed_values = [ "TEXT" , "BACKGROUND" ] if sparkline_value_color_map_apply_to not in allowed_values : raise ValueError ( "Invalid value for `sparkline_value_color_map_apply_to` ({0}), must be one of {1}" . format ( sparkline_value... | Sets the sparkline_value_color_map_apply_to of this ChartSettings . |
28,196 | def stack_type ( self , stack_type ) : allowed_values = [ "zero" , "expand" , "wiggle" , "silhouette" ] if stack_type not in allowed_values : raise ValueError ( "Invalid value for `stack_type` ({0}), must be one of {1}" . format ( stack_type , allowed_values ) ) self . _stack_type = stack_type | Sets the stack_type of this ChartSettings . |
28,197 | def tag_mode ( self , tag_mode ) : allowed_values = [ "all" , "top" , "custom" ] if tag_mode not in allowed_values : raise ValueError ( "Invalid value for `tag_mode` ({0}), must be one of {1}" . format ( tag_mode , allowed_values ) ) self . _tag_mode = tag_mode | Sets the tag_mode of this ChartSettings . |
28,198 | def windowing ( self , windowing ) : allowed_values = [ "full" , "last" ] if windowing not in allowed_values : raise ValueError ( "Invalid value for `windowing` ({0}), must be one of {1}" . format ( windowing , allowed_values ) ) self . _windowing = windowing | Sets the windowing of this ChartSettings . |
28,199 | def result ( self , result ) : if result is None : raise ValueError ( "Invalid value for `result`, must not be `None`" ) allowed_values = [ "OK" , "ERROR" ] if result not in allowed_values : raise ValueError ( "Invalid value for `result` ({0}), must be one of {1}" . format ( result , allowed_values ) ) self . _result =... | Sets the result of this ResponseStatus . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.