idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
41,100 | def points_awarded ( target = None , source = None , since = None ) : lookup_params = { } if target is not None : if isinstance ( target , get_user_model ( ) ) : lookup_params [ "target_user" ] = target else : lookup_params . update ( { "target_content_type" : ContentType . objects . get_for_model ( target ) , "target_... | Determine out how many points the given target has received . |
41,101 | def __validate_dates ( start_date , end_date ) : try : start_date = datetime . datetime . strptime ( start_date , '%Y-%m-%d' ) end_date = datetime . datetime . strptime ( end_date , '%Y-%m-%d' ) except ValueError : raise ValueError ( "Incorrect data format, should be yyyy-mm-dd" ) if ( end_date - start_date ) . days > ... | Validate if a date string . |
41,102 | def __yahoo_request ( query ) : query = quote ( query ) url = 'https://query.yahooapis.com/v1/public/yql?q=' + query + '&format=json&env=store://datatables.org/alltableswithkeys' response = urlopen ( url ) . read ( ) return json . loads ( response . decode ( 'utf-8' ) ) [ 'query' ] [ 'results' ] | Request Yahoo Finance information . |
41,103 | def request_quotes ( tickers_list , selected_columns = [ '*' ] ) : __validate_list ( tickers_list ) __validate_list ( selected_columns ) query = 'select {cols} from yahoo.finance.quotes where symbol in ({vals})' query = query . format ( cols = ', ' . join ( selected_columns ) , vals = ', ' . join ( '"{0}"' . format ( s... | Request Yahoo Finance recent quotes . |
41,104 | def request_historical ( ticker , start_date , end_date ) : __validate_dates ( start_date , end_date ) cols = [ 'Date' , 'Open' , 'High' , 'Low' , 'Close' , 'Volume' , 'Adj_Close' ] query = 'select {cols} from yahoo.finance.historicaldata ' + 'where symbol in ("{ticker}") and startDate = "{start_date}" ' + 'and endDate... | Get stock s daily historical information . |
41,105 | def download_historical ( tickers_list , output_folder ) : __validate_list ( tickers_list ) for ticker in tickers_list : file_name = os . path . join ( output_folder , ticker + '.csv' ) with open ( file_name , 'wb' ) as f : base_url = 'http://real-chart.finance.yahoo.com/table.csv?s=' try : urlopen ( base_url + ticker ... | Download historical data from Yahoo Finance . |
41,106 | def load ( self , file_name ) : new_rundata = self . loader ( file_name ) new_rundata = self . inspect ( new_rundata ) return new_rundata | Load a raw data - file |
41,107 | def datetime2ole ( dt ) : delta = dt - OLE_TIME_ZERO delta_float = delta / datetime . timedelta ( days = 1 ) return delta_float | converts from datetime object to ole datetime float |
41,108 | def loader ( self , file_name , bad_steps = None , ** kwargs ) : new_tests = [ ] if not os . path . isfile ( file_name ) : self . logger . info ( "Missing file_\n %s" % file_name ) return None filesize = os . path . getsize ( file_name ) hfilesize = humanize_bytes ( filesize ) txt = "Filesize: %i (%s)" % ( filesize ,... | Loads data from biologics . mpr files . |
41,109 | def csv_dumper ( ** kwargs ) : logging . info ( "dumping to csv" ) barn = kwargs [ "barn" ] farms = kwargs [ "farms" ] experiments = kwargs [ "experiments" ] for experiment , farm in zip ( experiments , farms ) : name = experiment . journal . name project = experiment . journal . project project_dir , batch_dir , raw_d... | dump data to csv |
41,110 | def ram_dumper ( ** kwargs ) : logging . debug ( "trying to save stuff in memory" ) farms = kwargs [ "farms" ] experiments = kwargs [ "experiments" ] engine = kwargs [ "engine" ] try : engine_name = engine . __name__ except AttributeError : engine_name = engine . __dict__ . __name__ accepted_engines = [ "summary_engine... | Dump data to memory for later usage . |
41,111 | def screen_dumper ( ** kwargs ) : farms = kwargs [ "farms" ] engine = kwargs [ "engine" ] logging . info ( "dumping to screen" ) print ( f"\n[Screen dumper] ({engine})" ) try : if len ( farms ) == 1 : print ( f"You have one farm with little pandas." ) else : print ( f"You have {len(farms)} farms with little pandas." ) ... | Dump data to screen . |
41,112 | def create_legend ( info , c , option = "clean" , use_index = False ) : logging . debug ( " - creating legends" ) mass , loading , label = info . loc [ c , [ "masses" , "loadings" , "labels" ] ] if use_index or not label : label = c . split ( "_" ) label = "_" . join ( label [ 1 : ] ) if option == "clean" : return l... | creating more informative legends |
41,113 | def create_plot_option_dicts ( info , marker_types = None , colors = None , line_dash = None , size = None ) : logging . debug ( " - creating plot-options-dict (for bokeh)" ) if marker_types is None : marker_types = [ "circle" , "square" , "triangle" , "invertedtriangle" , "diamond" , "cross" , "asterix" ] if line_d... | Create two dictionaries with plot - options . |
41,114 | def summary_plotting_engine ( ** kwargs ) : logging . debug ( f"Using {prms.Batch.backend} for plotting" ) experiments = kwargs [ "experiments" ] farms = kwargs [ "farms" ] barn = None logging . debug ( " - summary_plot_engine" ) farms = _preparing_data_and_plotting ( experiments = experiments , farms = farms ) retu... | creates plots of summary data . |
41,115 | def _read ( name ) : logging . debug ( "Reading config-file: %s" % name ) try : with open ( name , "r" ) as config_file : prm_dict = yaml . load ( config_file ) except yaml . YAMLError : raise yaml . YAMLErrorr else : return prm_dict | read the yml file |
41,116 | def cycles_engine ( ** kwargs ) : logging . info ( "cycles_engine:" ) logging . info ( "Not ready for production" ) experiments = kwargs [ "experiments" ] farms = [ ] barn = "raw_dir" for experiment in experiments : farms . append ( [ ] ) if experiment . all_in_memory : logging . debug ( "all in memory" ) for key in ex... | engine to extract cycles |
41,117 | def raw_data_engine ( ** kwargs ) : logger . debug ( "cycles_engine" ) raise NotImplementedError experiments = kwargs [ "experiments" ] farms = [ ] barn = "raw_dir" for experiment in experiments : farms . append ( [ ] ) return farms , barn | engine to extract raw data |
41,118 | def summary_engine ( ** kwargs ) : logger . debug ( "summary_engine" ) farms = [ ] experiments = kwargs [ "experiments" ] for experiment in experiments : if experiment . selected_summaries is None : selected_summaries = [ "discharge_capacity" , "charge_capacity" , "coulombic_efficiency" , "cumulated_coulombic_efficienc... | engine to extract summary data |
41,119 | def simple_db_engine ( reader = None , srnos = None ) : if reader is None : reader = dbreader . Reader ( ) logger . debug ( "No reader provided. Creating one myself." ) info_dict = dict ( ) info_dict [ "filenames" ] = [ reader . get_cell_name ( srno ) for srno in srnos ] info_dict [ "masses" ] = [ reader . get_mass ( s... | engine that gets values from the simple excel db |
41,120 | def orify ( event , changed_callback ) : event . changed = changed_callback if not hasattr ( event , '_set' ) : event . _set = event . set event . _clear = event . clear event . set = lambda : or_set ( event ) event . clear = lambda : or_clear ( event ) | Override set and clear methods on event to call specified callback function after performing default behaviour . |
41,121 | def request ( device , response_queue , payload , timeout_s = None , poll = POLL_QUEUES ) : device . write ( payload ) if poll : start = dt . datetime . now ( ) while not response_queue . qsize ( ) : if ( dt . datetime . now ( ) - start ) . total_seconds ( ) > timeout_s : raise queue . Empty ( 'No response received.' )... | Send payload to serial device and wait for response . |
41,122 | def connection_made ( self , transport ) : self . port = transport . serial . port logger . debug ( 'connection_made: `%s` `%s`' , self . port , transport ) self . transport = transport self . connected . set ( ) self . disconnected . clear ( ) | Called when reader thread is started |
41,123 | def connection_lost ( self , exception ) : if isinstance ( exception , Exception ) : logger . debug ( 'Connection to port `%s` lost: %s' , self . port , exception ) else : logger . debug ( 'Connection to port `%s` closed' , self . port ) self . connected . clear ( ) self . disconnected . set ( ) | \ Called when the serial port is closed or the reader loop terminated otherwise . |
41,124 | def write ( self , data , timeout_s = None ) : self . connected . wait ( timeout_s ) self . protocol . transport . write ( data ) | Write to serial port . |
41,125 | def fieldname_to_dtype ( fieldname ) : if fieldname == 'mode' : return ( 'mode' , np . uint8 ) elif fieldname in ( "ox/red" , "error" , "control changes" , "Ns changes" , "counter inc." ) : return ( fieldname , np . bool_ ) elif fieldname in ( "time/s" , "P/W" , "(Q-Qo)/mA.h" , "x" , "control/V" , "control/V/mA" , "(Q-... | Converts a column header from the MPT file into a tuple of canonical name and appropriate numpy dtype |
41,126 | def comma_converter ( float_string ) : trans_table = maketrans ( b',' , b'.' ) return float ( float_string . translate ( trans_table ) ) | Convert numbers to floats whether the decimal point is . or |
41,127 | def MPTfile ( file_or_path ) : if isinstance ( file_or_path , str ) : mpt_file = open ( file_or_path , 'rb' ) else : mpt_file = file_or_path magic = next ( mpt_file ) if magic != b'EC-Lab ASCII FILE\r\n' : raise ValueError ( "Bad first line for EC-Lab file: '%s'" % magic ) nb_headers_match = re . match ( b'Nb header li... | Opens . mpt files as numpy record arrays |
41,128 | def MPTfileCSV ( file_or_path ) : if isinstance ( file_or_path , str ) : mpt_file = open ( file_or_path , 'r' ) else : mpt_file = file_or_path magic = next ( mpt_file ) if magic . rstrip ( ) != 'EC-Lab ASCII FILE' : raise ValueError ( "Bad first line for EC-Lab file: '%s'" % magic ) nb_headers_match = re . match ( 'Nb ... | Simple function to open MPT files as csv . DictReader objects |
41,129 | def get_headers_global ( ) : headers = dict ( ) headers [ "applications_path_txt" ] = 'Applications_Path' headers [ "channel_index_txt" ] = 'Channel_Index' headers [ "channel_number_txt" ] = 'Channel_Number' headers [ "channel_type_txt" ] = 'Channel_Type' headers [ "comments_txt" ] = 'Comments' headers [ "creator_txt" ... | Defines the so - called global column headings for Arbin . res - files |
41,130 | def _save_multi ( data , file_name , sep = ";" ) : logger . debug ( "saving multi" ) with open ( file_name , "w" , newline = '' ) as f : logger . debug ( f"{file_name} opened" ) writer = csv . writer ( f , delimiter = sep ) try : writer . writerows ( itertools . zip_longest ( * data ) ) except Exception as e : logger .... | convenience function for storing data column - wise in a csv - file . |
41,131 | def _extract_dqdv ( cell_data , extract_func , last_cycle ) : from cellpy . utils . ica import dqdv list_of_cycles = cell_data . get_cycle_numbers ( ) if last_cycle is not None : list_of_cycles = [ c for c in list_of_cycles if c <= int ( last_cycle ) ] logger . debug ( f"only processing up to cycle {last_cycle}" ) logg... | Simple wrapper around the cellpy . utils . ica . dqdv function . |
41,132 | def make_df_from_batch ( batch_name , batch_col = "b01" , reader = None , reader_label = None ) : batch_name = batch_name batch_col = batch_col logger . debug ( f"batch_name, batch_col: {batch_name}, {batch_col}" ) if reader is None : reader_obj = get_db_reader ( reader_label ) reader = reader_obj ( ) srnos = reader . ... | Create a pandas DataFrame with the info needed for cellpy to load the runs . |
41,133 | def create_folder_structure ( project_name , batch_name ) : out_data_dir = prms . Paths [ "outdatadir" ] project_dir = os . path . join ( out_data_dir , project_name ) batch_dir = os . path . join ( project_dir , batch_name ) raw_dir = os . path . join ( batch_dir , "raw_data" ) if not os . path . isdir ( project_dir )... | This function creates a folder structure for the batch project . |
41,134 | def save_summaries ( frames , keys , selected_summaries , batch_dir , batch_name ) : if not frames : logger . info ( "Could save summaries - no summaries to save!" ) logger . info ( "You have no frames - aborting" ) return None if not keys : logger . info ( "Could save summaries - no summaries to save!" ) logger . info... | Writes the summaries to csv - files |
41,135 | def pick_summary_data ( key , summary_df , selected_summaries ) : selected_summaries_dict = create_selected_summaries_dict ( selected_summaries ) value = selected_summaries_dict [ key ] return summary_df . iloc [ : , summary_df . columns . get_level_values ( 1 ) == value ] | picks the selected pandas . DataFrame |
41,136 | def plot_summary_data ( ax , df , info_df , color_list , symbol_list , is_charge = False , plot_style = None ) : logger . debug ( "trying to plot summary data" ) if plot_style is None : logger . debug ( "no plot_style given, using default" ) plot_style = DEFAULT_PLOT_STYLE else : logger . debug ( "plot_style given" ) l... | creates a plot of the selected df - data in the given axes . |
41,137 | def init ( * args , ** kwargs ) : default_log_level = kwargs . pop ( "default_log_level" , None ) import cellpy . log as log log . setup_logging ( custom_log_dir = prms . Paths [ "filelogdir" ] , default_level = default_log_level ) b = Batch ( * args , ** kwargs ) return b | Returns an initialized instance of the Batch class |
41,138 | def debugging ( ) : print ( "In debugging" ) json_file = r"C:\Scripting\Processing\Cell" r"data\outdata\SiBEC\cellpy_batch_bec_exp02.json" b = init ( default_log_level = "DEBUG" ) b . load_info_df ( json_file ) print ( b . info_df . head ( ) ) b . export_raw = False b . export_cycles = False b . export_ica = False b . ... | This one I use for debugging ... |
41,139 | def save_info_df ( self ) : logger . debug ( "running save_info_df" ) info_df = self . info_df top_level_dict = { 'info_df' : info_df , 'metadata' : self . _prm_packer ( ) } jason_string = json . dumps ( top_level_dict , default = lambda info_df : json . loads ( info_df . to_json ( ) ) ) with open ( self . info_file , ... | Saves the DataFrame with info about the runs to a JSON file |
41,140 | def create_folder_structure ( self ) : self . info_file , directories = create_folder_structure ( self . project , self . name ) self . project_dir , self . batch_dir , self . raw_dir = directories logger . debug ( "create folders:" + str ( directories ) ) | Creates a folder structure based on the project and batch name . |
41,141 | def make_summaries ( self ) : self . summary_df = save_summaries ( self . frames , self . keys , self . selected_summaries , self . batch_dir , self . name ) logger . debug ( "made and saved summaries" ) | Make and save summary csv files each containing values from all cells |
41,142 | def plot_summaries ( self , show = False , save = True , figure_type = None ) : if not figure_type : figure_type = self . default_figure_type if not figure_type in self . default_figure_types : logger . debug ( "unknown figure type selected" ) figure_type = self . default_figure_type color_list , symbol_list = self . _... | Plot summary graphs . |
41,143 | def link ( self ) : logging . info ( "[estblishing links]" ) logging . debug ( "checking and establishing link to data" ) cell_data_frames = dict ( ) counter = 0 errors = [ ] try : for indx , row in self . journal . pages . iterrows ( ) : counter += 1 l_txt = "starting to process file # %i (index=%s)" % ( counter , ind... | Ensure that an appropriate link to the cellpy - files exists for each cell . |
41,144 | def get_default_config_file_path ( init_filename = None ) : prm_dir = get_package_prm_dir ( ) if not init_filename : init_filename = DEFAULT_FILENAME src = os . path . join ( prm_dir , init_filename ) return src | gets the path to the default config - file |
41,145 | def get_user_dir_and_dst ( init_filename ) : user_dir = get_user_dir ( ) dst_file = os . path . join ( user_dir , init_filename ) return user_dir , dst_file | gets the name of the user directory and full prm filepath |
41,146 | def setup ( interactive , not_relative , dry_run , reset , root_dir , testuser ) : click . echo ( "[cellpy] (setup)" ) init_filename = create_custom_init_filename ( ) userdir , dst_file = get_user_dir_and_dst ( init_filename ) if testuser : if not root_dir : root_dir = os . getcwd ( ) click . echo ( f"[cellpy] (setup) ... | This will help you to setup cellpy . |
41,147 | def _parse_g_dir ( repo , gdirpath ) : for f in repo . get_contents ( gdirpath ) : if f . type == "dir" : for sf in repo . get_contents ( f . path ) : yield sf else : yield f | parses a repo directory two - levels deep |
41,148 | def look_up_and_get ( cellpy_file_name , table_name ) : root = '/CellpyData' table_path = '/' . join ( [ root , table_name ] ) logging . debug ( f"look_up_and_get({cellpy_file_name}, {table_name}" ) store = pd . HDFStore ( cellpy_file_name ) table = store . select ( table_path ) store . close ( ) return table | Extracts table from cellpy hdf5 - file . |
41,149 | def fix_groups ( groups ) : _groups = [ ] for g in groups : try : if not float ( g ) > 0 : _groups . append ( 1000 ) else : _groups . append ( int ( g ) ) except TypeError as e : logging . info ( "Error in reading group number (check your db)" ) logging . debug ( g ) logging . debug ( e ) _groups . append ( 1000 ) retu... | Takes care of strange group numbers . |
41,150 | def create_selected_summaries_dict ( summaries_list ) : headers_summary = cellpy . parameters . internal_settings . get_headers_summary ( ) selected_summaries = dict ( ) for h in summaries_list : selected_summaries [ h ] = headers_summary [ h ] return selected_summaries | Creates a dictionary with summary column headers . |
41,151 | def generate_folder_names ( name , project ) : out_data_dir = prms . Paths . outdatadir project_dir = os . path . join ( out_data_dir , project ) batch_dir = os . path . join ( project_dir , name ) raw_dir = os . path . join ( batch_dir , "raw_data" ) return out_data_dir , project_dir , batch_dir , raw_dir | Creates sensible folder names . |
41,152 | def _interpolate_df_col ( df , x = None , y = None , new_x = None , dx = 10.0 , number_of_points = None , direction = 1 , ** kwargs ) : if x is None : x = df . columns [ 0 ] if y is None : y = df . columns [ 1 ] xs = df [ x ] . values ys = df [ y ] . values if direction > 0 : x_min = xs . min ( ) x_max = xs . max ( ) e... | Interpolate a column based on another column . |
41,153 | def _collect_capacity_curves ( data , direction = "charge" ) : minimum_v_value = np . Inf maximum_v_value = - np . Inf charge_list = [ ] cycles = data . get_cycle_numbers ( ) for cycle in cycles : try : if direction == "charge" : q , v = data . get_ccap ( cycle ) else : q , v = data . get_dcap ( cycle ) except NullData... | Create a list of pandas . DataFrames one for each charge step . |
41,154 | def cell ( filename = None , mass = None , instrument = None , logging_mode = "INFO" , cycle_mode = None , auto_summary = True ) : from cellpy import log log . setup_logging ( default_level = logging_mode ) cellpy_instance = setup_cellpy_instance ( ) if instrument is not None : cellpy_instance . set_instrument ( instru... | Create a CellpyData object |
41,155 | def load_and_save_resfile ( filename , outfile = None , outdir = None , mass = 1.00 ) : d = CellpyData ( ) if not outdir : outdir = prms . Paths [ "cellpydatadir" ] if not outfile : outfile = os . path . basename ( filename ) . split ( "." ) [ 0 ] + ".h5" outfile = os . path . join ( outdir , outfile ) print ( "filenam... | Load a raw data file and save it as cellpy - file . |
41,156 | def load_and_print_resfile ( filename , info_dict = None ) : if info_dict is None : info_dict = dict ( ) info_dict [ "mass" ] = 1.23 info_dict [ "nom_cap" ] = 3600 info_dict [ "tot_mass" ] = 2.33 d = CellpyData ( ) print ( "filename:" , filename ) print ( "info_dict in:" , end = ' ' ) print ( info_dict ) d . from_raw (... | Load a raw data file and print information . |
41,157 | def set_raw_datadir ( self , directory = None ) : if directory is None : self . logger . info ( "no directory name given" ) return if not os . path . isdir ( directory ) : self . logger . info ( directory ) self . logger . info ( "directory does not exist" ) return self . raw_datadir = directory | Set the directory containing . res - files . |
41,158 | def set_cellpy_datadir ( self , directory = None ) : if directory is None : self . logger . info ( "no directory name given" ) return if not os . path . isdir ( directory ) : self . logger . info ( "directory does not exist" ) return self . cellpy_datadir = directory | Set the directory containing . hdf5 - files . |
41,159 | def _check_raw ( self , file_names , abort_on_missing = False ) : strip_file_names = True check_on = self . filestatuschecker if not self . _is_listtype ( file_names ) : file_names = [ file_names , ] ids = dict ( ) for f in file_names : self . logger . debug ( f"checking res file {f}" ) fid = FileID ( f ) if fid . name... | Get the file - ids for the res_files . |
41,160 | def _check_cellpy_file ( self , filename ) : strip_filenames = True check_on = self . filestatuschecker self . logger . debug ( "checking cellpy-file" ) self . logger . debug ( filename ) if not os . path . isfile ( filename ) : self . logger . debug ( "cellpy-file does not exist" ) return None try : store = pd . HDFSt... | Get the file - ids for the cellpy_file . |
41,161 | def loadcell ( self , raw_files , cellpy_file = None , mass = None , summary_on_raw = False , summary_ir = True , summary_ocv = False , summary_end_v = True , only_summary = False , only_first = False , force_raw = False , use_cellpy_stat_file = None ) : self . logger . info ( "started loadcell" ) if cellpy_file is Non... | Loads data for given cells . |
41,162 | def from_raw ( self , file_names = None , ** kwargs ) : if file_names : self . file_names = file_names if not isinstance ( file_names , ( list , tuple ) ) : self . file_names = [ file_names , ] raw_file_loader = self . loader set_number = 0 test = None counter = 0 self . logger . debug ( "start iterating through file(s... | Load a raw data - file . |
41,163 | def check ( self ) : if len ( self . status_datasets ) == 0 : return False if all ( self . status_datasets ) : return True return False | Returns False if no datasets exists or if one or more of the datasets are empty |
41,164 | def load ( self , cellpy_file , parent_level = "CellpyData" ) : try : self . logger . debug ( "loading cellpy-file (hdf5):" ) self . logger . debug ( cellpy_file ) new_datasets = self . _load_hdf5 ( cellpy_file , parent_level ) self . logger . debug ( "cellpy-file loaded" ) except AttributeError : new_datasets = [ ] se... | Loads a cellpy file . |
41,165 | def _load_hdf5 ( self , filename , parent_level = "CellpyData" ) : if not os . path . isfile ( filename ) : self . logger . info ( f"file does not exist: {filename}" ) raise IOError store = pd . HDFStore ( filename ) required_keys = [ 'dfdata' , 'dfsummary' , 'info' ] required_keys = [ "/" + parent_level + "/" + _ for ... | Load a cellpy - file . |
41,166 | def merge ( self , datasets = None , separate_datasets = False ) : self . logger . info ( "merging" ) if separate_datasets : warnings . warn ( "The option seperate_datasets=True is" "not implemented yet. Performing merging, but" "neglecting the option." ) else : if datasets is None : datasets = list ( range ( len ( sel... | This function merges datasets into one set . |
41,167 | def print_step_table ( self , dataset_number = None ) : dataset_number = self . _validate_dataset_number ( dataset_number ) if dataset_number is None : self . _report_empty_dataset ( ) return st = self . datasets [ dataset_number ] . step_table print ( st ) | Print the step table . |
41,168 | def load_step_specifications ( self , file_name , short = False , dataset_number = None ) : dataset_number = self . _validate_dataset_number ( dataset_number ) if dataset_number is None : self . _report_empty_dataset ( ) return step_specs = pd . read_csv ( file_name , sep = prms . Reader . sep ) if "step" not in step_s... | Load a table that contains step - type definitions . |
41,169 | def sget_voltage ( self , cycle , step , set_number = None ) : time_00 = time . time ( ) set_number = self . _validate_dataset_number ( set_number ) if set_number is None : self . _report_empty_dataset ( ) return cycle_index_header = self . headers_normal . cycle_index_txt voltage_header = self . headers_normal . volta... | Returns voltage for cycle step . |
41,170 | def sget_steptime ( self , cycle , step , dataset_number = None ) : dataset_number = self . _validate_dataset_number ( dataset_number ) if dataset_number is None : self . _report_empty_dataset ( ) return cycle_index_header = self . headers_normal . cycle_index_txt step_time_header = self . headers_normal . step_time_tx... | Returns step time for cycle step . |
41,171 | def sget_timestamp ( self , cycle , step , dataset_number = None ) : dataset_number = self . _validate_dataset_number ( dataset_number ) if dataset_number is None : self . _report_empty_dataset ( ) return cycle_index_header = self . headers_normal . cycle_index_txt timestamp_header = self . headers_normal . test_time_t... | Returns timestamp for cycle step . |
41,172 | def get_ocv ( self , cycles = None , direction = "up" , remove_first = False , interpolated = False , dx = None , number_of_points = None ) : if cycles is None : cycles = self . get_cycle_numbers ( ) else : if not isinstance ( cycles , ( list , tuple ) ) : cycles = [ cycles , ] else : remove_first = False ocv_rlx_id = ... | get the open curcuit voltage relaxation curves . |
41,173 | def get_number_of_cycles ( self , dataset_number = None , steptable = None ) : if steptable is None : dataset_number = self . _validate_dataset_number ( dataset_number ) if dataset_number is None : self . _report_empty_dataset ( ) return d = self . datasets [ dataset_number ] . dfdata no_cycles = np . amax ( d [ self .... | Get the number of cycles in the test . |
41,174 | def get_cycle_numbers ( self , dataset_number = None , steptable = None ) : if steptable is None : dataset_number = self . _validate_dataset_number ( dataset_number ) if dataset_number is None : self . _report_empty_dataset ( ) return d = self . datasets [ dataset_number ] . dfdata cycles = np . unique ( d [ self . hea... | Get a list containing all the cycle numbers in the test . |
41,175 | def get_converter_to_specific ( self , dataset = None , mass = None , to_unit = None , from_unit = None ) : if not dataset : dataset_number = self . _validate_dataset_number ( None ) if dataset_number is None : self . _report_empty_dataset ( ) return dataset = self . datasets [ dataset_number ] if not mass : mass = dat... | get the convertion values |
41,176 | def set_col_first ( df , col_names ) : column_headings = df . columns column_headings = column_headings . tolist ( ) try : for col_name in col_names : i = column_headings . index ( col_name ) column_headings . pop ( column_headings . index ( col_name ) ) column_headings . insert ( 0 , col_name ) finally : df = df . rei... | set selected columns first in a pandas . DataFrame . |
41,177 | def get_summary ( self , dataset_number = None , use_dfsummary_made = False ) : dataset_number = self . _validate_dataset_number ( dataset_number ) if dataset_number is None : self . _report_empty_dataset ( ) return None test = self . get_dataset ( dataset_number ) if use_dfsummary_made : dfsummary_made = test . dfsumm... | Retrieve summary returned as a pandas DataFrame . |
41,178 | def make_summary ( self , find_ocv = False , find_ir = False , find_end_voltage = False , use_cellpy_stat_file = None , all_tests = True , dataset_number = 0 , ensure_step_table = True , convert_date = False ) : if self . tester == "arbin" : convert_date = True if ensure_step_table is None : ensure_step_table = self . ... | Convenience function that makes a summary of the cycling data . |
41,179 | def single_html ( epub_file_path , html_out = sys . stdout , mathjax_version = None , numchapters = None , includes = None ) : epub = cnxepub . EPUB . from_file ( epub_file_path ) if len ( epub ) != 1 : raise Exception ( 'Expecting an epub with one book' ) package = epub [ 0 ] binder = cnxepub . adapt_package ( package... | Generate complete book HTML . |
41,180 | def _pack_prms ( ) : config_dict = { "Paths" : prms . Paths . to_dict ( ) , "FileNames" : prms . FileNames . to_dict ( ) , "Db" : prms . Db . to_dict ( ) , "DbCols" : prms . DbCols . to_dict ( ) , "DataSet" : prms . DataSet . to_dict ( ) , "Reader" : prms . Reader . to_dict ( ) , "Instruments" : prms . Instruments . to... | if you introduce new save - able parameter dictionaries then you have to include them here |
41,181 | def _read_prm_file ( prm_filename ) : logger . debug ( "Reading config-file: %s" % prm_filename ) try : with open ( prm_filename , "r" ) as config_file : prm_dict = yaml . load ( config_file ) except yaml . YAMLError : raise ConfigFileNotRead else : _update_prms ( prm_dict ) | read the prm file |
41,182 | def _get_prm_file ( file_name = None , search_order = None ) : if file_name is not None : if os . path . isfile ( file_name ) : return file_name else : logger . info ( "Could not find the prm-file" ) default_name = prms . _prm_default_name prm_globtxt = prms . _prm_globtxt script_dir = os . path . abspath ( os . path .... | returns name of the prm file |
41,183 | def info ( ) : print ( "convenience function for listing prms" ) print ( type ( prms ) ) print ( prms . __name__ ) print ( f"prm file: {_get_prm_file()}" ) for key in prms . __dict__ : if isinstance ( prms . __dict__ [ key ] , box . Box ) : print ( ) print ( 80 * "=" ) print ( f"prms.{key}:" ) print ( 80 * "-" ) for su... | this function will show only the box - type attributes and their content in the cellpy . prms module |
41,184 | def _replace_tex_math ( node , mml_url , mc_client = None , retry = 0 ) : math = node . attrib [ 'data-math' ] or node . text if math is None : return None eq = { } if mc_client : math_key = hashlib . md5 ( math . encode ( 'utf-8' ) ) . hexdigest ( ) eq = json . loads ( mc_client . get ( math_key ) or '{}' ) if not eq ... | call mml - api service to replace TeX math in body of node with mathml |
41,185 | def exercise_callback_factory ( match , url_template , mc_client = None , token = None , mml_url = None ) : def _replace_exercises ( elem ) : item_code = elem . get ( 'href' ) [ len ( match ) : ] url = url_template . format ( itemCode = item_code ) exercise = { } if mc_client : mc_key = item_code + ( token or '' ) exer... | Create a callback function to replace an exercise by fetching from a server . |
41,186 | def html_listify ( tree , root_xl_element , extensions , list_type = 'ol' ) : for node in tree : li_elm = etree . SubElement ( root_xl_element , 'li' ) if node [ 'id' ] not in extensions : span_elm = lxml . html . fragment_fromstring ( node [ 'title' ] , create_parent = 'span' ) li_elm . append ( span_elm ) else : a_el... | Convert a node tree into an xhtml nested list - of - lists . |
41,187 | def _generate_ids ( self , document , content ) : existing_ids = content . xpath ( '//*/@id' ) elements = [ 'p' , 'dl' , 'dt' , 'dd' , 'table' , 'div' , 'section' , 'figure' , 'blockquote' , 'q' , 'code' , 'pre' , 'object' , 'img' , 'audio' , 'video' , ] elements_xpath = '|' . join ( [ './/{}|.//xhtml:{}' . format ( el... | Generate unique ids for html elements in page content so that it s possible to link to them . |
41,188 | def to_file ( package , directory ) : opf_filepath = os . path . join ( directory , package . name ) for name in ( 'contents' , 'resources' , ) : path = os . path . join ( directory , name ) if not os . path . exists ( path ) : os . mkdir ( path ) locations = { } for item in package : if item . media_type == 'applicati... | Write the package to the given directory . Returns the OPF filename . |
41,189 | def from_file ( self , file_name = None ) : file_name = self . _check_file_name ( file_name ) with open ( file_name , 'r' ) as infile : top_level_dict = json . load ( infile ) pages_dict = top_level_dict [ 'info_df' ] pages = pd . DataFrame ( pages_dict ) self . pages = pages self . file_name = file_name self . _prm_pa... | Loads a DataFrame with all the needed info about the experiment |
41,190 | def to_file ( self , file_name = None ) : file_name = self . _check_file_name ( file_name ) pages = self . pages top_level_dict = { 'info_df' : pages , 'metadata' : self . _prm_packer ( ) } jason_string = json . dumps ( top_level_dict , default = lambda info_df : json . loads ( info_df . to_json ( ) ) ) self . paginate... | Saves a DataFrame with all the needed info about the experiment |
41,191 | def generate_folder_names ( self ) : self . project_dir = os . path . join ( prms . Paths . outdatadir , self . project ) self . batch_dir = os . path . join ( self . project_dir , self . name ) self . raw_dir = os . path . join ( self . batch_dir , "raw_data" ) | Set appropriate folder names . |
41,192 | def paginate ( self ) : project_dir = self . project_dir raw_dir = self . raw_dir batch_dir = self . batch_dir if project_dir is None : raise UnderDefined ( "no project directory defined" ) if raw_dir is None : raise UnderDefined ( "no raw directory defined" ) if batch_dir is None : raise UnderDefined ( "no batcb direc... | Make folders where we would like to put results etc . |
41,193 | def generate_file_name ( self ) : if not self . project : raise UnderDefined ( "project name not given" ) out_data_dir = prms . Paths . outdatadir project_dir = os . path . join ( out_data_dir , self . project ) file_name = "cellpy_batch_%s.json" % self . name self . file_name = os . path . join ( project_dir , file_na... | generate a suitable file name for the experiment |
41,194 | def info ( self ) : print ( "Sorry, but I don't have much to share." ) print ( "This is me:" ) print ( self ) print ( "And these are the experiments assigned to me:" ) print ( self . experiments ) | Delivers some info to you about the class . |
41,195 | def assign ( self , experiment ) : self . experiments . append ( experiment ) self . farms . append ( empty_farm ) | Assign an experiment . |
41,196 | def flatten_model ( model ) : yield model if isinstance ( model , ( TranslucentBinder , Binder , ) ) : for m in model : for x in flatten_model ( m ) : yield x | Flatten a model to a list of models . This is used to flatten a Binder ish model down to a list of contained models . |
41,197 | def _discover_uri_type ( uri ) : parsed_uri = urlparse ( uri ) if not parsed_uri . netloc : if parsed_uri . scheme == 'data' : type_ = INLINE_REFERENCE_TYPE else : type_ = INTERNAL_REFERENCE_TYPE else : type_ = EXTERNAL_REFERENCE_TYPE return type_ | Given a uri determine if it is internal or external . |
41,198 | def _parse_references ( xml ) : references = [ ] ref_finder = HTMLReferenceFinder ( xml ) for elm , uri_attr in ref_finder : type_ = _discover_uri_type ( elm . get ( uri_attr ) ) references . append ( Reference ( elm , type_ , uri_attr ) ) return references | Parse the references to Reference instances . |
41,199 | def _set_uri_from_bound_model ( self ) : value = self . _uri_template . format ( self . _bound_model . id ) self . elm . set ( self . _uri_attr , value ) | Using the bound model set the uri . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.