def initialize(self): """Initialize the link.""" # check input arguments self.check_arg_types(read_key=str, store_key=str, results_path=str, methods=list, pages_key=str) self.check_arg_vals('read_key') # read report templates with open(resources.template('df_summary_report.tex')) as templ_file: self.report_template = templ_file.read() with open(resources.template( 'df_summary_report_page.tex')) as templ_file: self.page_template = templ_file.read() self._process_results_path() # check methods for method in self.methods: if method not in ALL_CORRS: logstring = '"{}" is not a valid correlation method, please use one of {}' logstring = logstring.format( method, ', '.join(['"' + m + '"' for m in ALL_CORRS])) raise AssertionError(logstring) # initialize attributes self.pages = [] return StatusCode.Success
def initialize(self): """Initialize the link.""" # check input arguments self.check_arg_types(pages_key=str) if isinstance(self.copy_into_ws, str): self.copy_into_ws = [self.copy_into_ws] assert isinstance( self.copy_into_ws, list), 'copy_into_ws needs to be a string or list of strings.' if isinstance(self.copy_into_ds, str): self.copy_into_ds = [self.copy_into_ds] assert isinstance( self.copy_into_ds, list), 'copy_into_ds needs to be a string or list of strings.' # read report templates with open(resources.template('df_summary_report.tex')) as templ_file: self.report_template = templ_file.read() with open(resources.template( 'df_summary_report_page.tex')) as templ_file: self.page_template = templ_file.read() with open( resources.template('df_summary_table_page.tex')) as templ_file: self.table_template = templ_file.read() self._process_results_path() # make sure Eskapade RooFit library is loaded for fitting (for plotting correlation matrix) if self._fit: roofit_utils.load_libesroofit() return StatusCode.Success
def initialize(self): """Initialize the link.""" # check input arguments self.check_arg_types(read_key=str, pages_key=str) self.check_arg_types(recurse=True, allow_none=True, columns=str, hist_keys=str, var_labels=str, var_units=str) self.check_arg_vals('read_key') # read report templates with open(resources.template('df_summary_report.tex')) as templ_file: self.report_template = templ_file.read() with open(resources.template( 'df_summary_report_page.tex')) as templ_file: self.page_template = templ_file.read() self._process_results_path() # add hist_keys to columns, ensure sum is a unique set self.columns += self.hist_keys self.columns = sorted(list(set(self.columns))) return StatusCode.Success
def generate_notebook(notebook_dir, notebook_name, macro_path=None): """Generate Eskapade notebook. :param notebook_dir: absolute path to a directory where the notebook will be generated :param notebook_name: name of the notebook to generate :param macro_path: absolute path to a macro the notebook executes """ import platform from eskapade import resources if macro_path: macro_path = "'{path}'".format(path=macro_path) else: macro_path = "resources.tutorial('tutorial_1.py')" with open(resources.template('notebook_template.ipynb')) as file: template = file.read() content = template.format(macro_path=macro_path, notebook_name=notebook_name, python_version=platform.python_version()) create_file(path=notebook_dir, file_name='{notebook_name!s}.ipynb'.format( notebook_name=notebook_name), content=content)
def initialize(self): """Initialize the link.""" # check input arguments self.check_arg_types(read_key=str, pages_key=str) self.check_arg_types(recurse=True, allow_none=True, column=str, cause_columns=list, statistics=list) self.check_arg_vals('read_key') # read report templates, we use the summary_report template from the df summary link with open(resources.template('df_summary_report.tex')) as templ_file: self.report_template = templ_file.read() with open(resources.template( 'df_summary_report_page.tex')) as templ_file: self.page_template = templ_file.read() self._process_results_path() return StatusCode.Success
def initialize(self): """Initialize the link. :returns: status code of initialization :rtype: StatusCode """ # -- initialize the report template and page template with open(resources.template('df_summary_report.tex')) as tmpl_file: self.report_template = tmpl_file.read() with open(resources.template( 'df_summary_report_page.tex')) as page_tmp_file: self.page_template = page_tmp_file.read() with open(resources.template( 'df_summary_table_page.tex')) as page_tmp_file: self.page_table_template = page_tmp_file.read() # -- Process the results path self._process_results_path() # -- List to save the pdf pages self.pages = [] return StatusCode.Success
def initialize(self): """Initialize the link.""" # check input arguments self.check_arg_types(read_key=str, significance_key=str, sk_significance_map=str, sk_residuals_map=str, sk_residuals_overview=str, default_number_of_bins=int, nsims_per_significance=int, prefix=str, var_binning=dict, z_threshold=float, pages_key=str, client_pages_key=str, hist_dict_key=str, var_binning_key=str) self.check_arg_types(recurse=True, allow_none=True, columns=str) self.check_arg_types(recurse=True, allow_none=True, x_columns=str) self.check_arg_types(recurse=True, allow_none=True, y_columns=str) self.check_arg_types(recurse=True, allow_none=True, ignore_categories=str) self.check_arg_types(recurse=True, allow_none=True, accept_categories=str) self.check_arg_types(recurse=True, allow_none=True, ignore_values=float) self.check_arg_vals('read_key') self.check_arg_vals('significance_key') if self.map_to_original and not isinstance(self.map_to_original, str) \ and not isinstance(self.map_to_original, dict): raise TypeError('map_to_original needs to be a dict or string (to fetch a dict from the datastore)') # read report templates with open(resources.template('df_summary_report.tex')) as templ_file: self.report_template = templ_file.read() with open(resources.template('df_summary_report_page.tex')) as templ_file: self.page_template = templ_file.read() with open(resources.template('df_summary_table_page.tex')) as templ_file: self.table_template = templ_file.read() self._process_results_path() self._process_prefix() # check provided columns if self.columns: assert not self.x_columns and not self.y_columns, 'Set either columns OR x_columns and y_columns.' if self.x_columns: assert not self.columns and self.y_columns, 'Set either columns OR x_columns and y_columns.' # check that var_ignore_categories are set correctly. for col, ic in self.var_ignore_categories.items(): if isinstance(ic, str): self.var_ignore_categories[col] = [ic] elif not isinstance(ic, list): raise TypeError('var_ignore_categories key "{}" needs to be a string or list of strings'.format(col)) # check that var_accept_categories are set correctly. for col, ic in self.var_accept_categories.items(): if isinstance(ic, str): self.var_accept_categories[col] = [ic] elif not isinstance(ic, list): raise TypeError('var_accept_categories key "{}" needs to be a string or list of strings'.format(col)) # check that var_ignore_values are set correctly. for col, iv in self.var_ignore_values.items(): if isinstance(iv, float): self.var_ignore_values[col] = [iv] elif not isinstance(iv, list): raise TypeError('var_ignore_values key "{}" needs to be a float or list of floats'.format(col)) # load roofit classes roofit_utils.load_libesroofit() return StatusCode.Success