output stringlengths 1 928k | instruction stringlengths 7 928k | system stringlengths 0 104k |
|---|---|---|
Takes a hit table and stores only selected hits into a new table. | Can you generate the documentation for the following Python 3 function
def select_hits_from_cluster_info(input_file_hits, output_file_hits, cluster_size_condition, n_cluster_condition, chunk_size=4000000):
''' Takes a hit table and stores only selected hits into a new table. The selection is done on an event base a... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def select_hits(input_file_hits, output_file_hits, condition=None, cluster_size_condition=None, n_cluster_condition=None, chunk_size=5000000):
''' Takes a hit table and stores only selected hits into a new table. The selection of hits is done with a numexp string. Only if
this expression evaluates to true the h... | Create a Python 3 function for
selecting hits from the given file and stores only those that satisfy the given condition. | You are a Python code analyst, evaluating scripts for potential improvements. |
Reads in the cluster info table in chunks and histograms the seed pixels into one occupancy array. | How would you explain what the following Python 3 function does
def histogram_cluster_table(analyzed_data_file, output_file, chunk_size=10000000):
'''Reads in the cluster info table in chunks and histograms the seed pixels into one occupancy array.
The 3rd dimension of the occupancy array is the number of diffe... | As a Python code composer, you craft elegant and concise scripts. |
Takes the hit table and analyzes the hits per scan parameter | Can you generate a brief explanation for the following Python 3 code
def analyze_hits_per_scan_parameter(analyze_data, scan_parameters=None, chunk_size=50000):
'''Takes the hit table and analyzes the hits per scan parameter
Parameters
----------
analyze_data : analysis.analyze_raw_data.AnalyzeRawData o... | You are a Python code analyst, evaluating scripts for potential improvements. |
Interprets raw data from Tektronix and returns time voltage time_unit and voltage_unit | Can you tell what is the following Python 3 function doing
def interpret_data_from_tektronix(preamble, data):
''' Interprets raw data from Tektronix
returns: lists of x, y values in seconds/volt'''
# Y mode ("WFMPRE:PT_FMT"):
# Xn = XZEro + XINcr (n - PT_Off)
# Yn = YZEro + YMUlt (yn - YOFf)
vol... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def read_chip_sn(self):
'''Reading Chip S/N
Note
----
Bits [MSB-LSB] | [15] | [14-6] | [5-0]
Content | reserved | wafer number | chip number
'''
commands = []
commands.extend(self.register.get_commands("ConfMode"))
self.register_utils.send_commands(com... | Can you create a Python 3 function that
reads the Chip S and N from the specified address. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Reads the global register and returns the register value. | How would you explain what the following Python 3 function does
def read_global_register(self, name, overwrite_config=False):
'''The function reads the global register, interprets the data and returns the register value.
Parameters
----------
name : register name
overwrite_config : bool
... | As a python code expert, you are capable of creating scripts from specifications. |
Reads the specified pixel register and returns a list of masked numpy arrays with the data for the chosen pixel register. | Here you have a function in Python 3, explain what it does
def read_pixel_register(self, pix_regs=None, dcs=range(40), overwrite_config=False):
'''The function reads the pixel register, interprets the data and returns a masked numpy arrays with the data for the chosen pixel register.
Pixels without any data a... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Get FEI4 status of module. | Here you have a function in Python 3, explain what it does
def is_fe_ready(self):
'''Get FEI4 status of module.
If FEI4 is not ready, resetting service records is necessary to bring the FEI4 to a defined state.
Returns
-------
value : bool
True if FEI4 is ready, False if the FEI4 w... | You are a Python code architect, reviewing and designing scalable and efficient code |
Invert a pixel mask. | Can you tell what is the following Python 3 function doing
def invert_pixel_mask(mask):
'''Invert pixel mask (0->1, 1(and greater)->0).
Parameters
----------
mask : array-like
Mask.
Returns
-------
inverted_mask : array-like
Inverted Mask.
'''
inverted_... | You are a Python code architect, reviewing and designing scalable and efficient code |
def make_pixel_mask(steps, shift, default=0, value=1, enable_columns=None, mask=None):
'''Generate pixel mask.
Parameters
----------
steps : int
Number of mask steps, e.g. steps=3 (every third pixel is enabled), steps=336 (one pixel per column), steps=672 (one pixel per double column).
... | Write a Python 3 script for
generating a mask array for each of the specified steps. | As a python code expert, you are capable of creating scripts from specifications. |
def make_pixel_mask_from_col_row(column, row, default=0, value=1):
'''Generate mask from column and row lists
Parameters
----------
column : iterable, int
List of colums values.
row : iterable, int
List of row values.
default : int
Value of pixels that are not ... | How would you code a function in Python 3 to
generate a mask from column and row lists. | As a python code expert, you are capable of creating scripts from specifications. |
def make_box_pixel_mask_from_col_row(column, row, default=0, value=1):
'''Generate box shaped mask from column and row lists. Takes the minimum and maximum value from each list.
Parameters
----------
column : iterable, int
List of colums values.
row : iterable, int
List of r... | How would you implement a function in Python 3 that
generates a box shaped mask from column and row lists. Takes the minimum and maximum value from each list. | You are a Python code generator, capable of creating scripts from specifications. |
Generate an extended mask that is the same size as the pixel mask. | Can you generate the documentation for the following Python 3 function
def make_xtalk_mask(mask):
col, row = mask.nonzero()
row_plus_one = row + 1
del_index = np.where(row_plus_one > 335)
row_plus_one = np.delete(row_plus_one, del_index)
col_plus_one = np.delete(col.copy(), del_index)
row_... | As a python code expert, you are capable of creating scripts from specifications. |
def make_checkerboard_mask(column_distance, row_distance, column_offset=0, row_offset=0, default=0, value=1):
"""
Generate chessboard/checkerboard mask.
Parameters
----------
column_distance : int
Column distance of the enabled pixels.
row_distance : int
Row distance of... | Create a Python 3 function for
generating a Chessboard mask for a given column and row. | You are a Python code analyst, evaluating scripts for potential improvements. |
Implementation of the mask shifting loop over double columns. | Make a summary of the following Python 3 code
def scan_loop(self, command, repeat_command=100, use_delay=True, additional_delay=0, mask_steps=3, enable_mask_steps=None, enable_double_columns=None, same_mask_for_all_dc=False, fast_dc_loop=True, bol_function=None, eol_function=None, digital_injection=False, enable_shift_... | As a Python code composer, you craft elegant and concise scripts. |
Reset all the Service Records in the current thread. | Can you generate the documentation for the following Python 3 function
def reset_service_records(self):
'''Resetting Service Records
This will reset Service Record counters. This will also bring back alive some FE where the output FIFO is stuck (no data is coming out in run mode).
This shou... | You are a Python code analyst, evaluating scripts for potential improvements. |
Reset the Bunch Counter | Given the following Python 3 function, write the documentation
def reset_bunch_counter(self):
'''Resetting Bunch Counter
'''
logging.info('Resetting Bunch Counter')
commands = []
commands.extend(self.register.get_commands("RunMode"))
commands.extend(self.register.ge... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Mask array elements when equal 0. 0 or greater than 10 times the median
| Can you generate a brief explanation for the following Python 3 code
def generate_threshold_mask(hist):
'''Masking array elements when equal 0.0 or greater than 10 times the median
Parameters
----------
hist : array_like
Input data.
Returns
-------
masked array
Returns copy... | As a Python code analyst, you investigate and solve complex coding mysteries |
Takes a numpy array and returns the array reduced to unique rows. | Can you generate the documentation for the following Python 3 function
def unique_row(array, use_columns=None, selected_columns_only=False):
'''Takes a numpy array and returns the array reduced to unique rows. If columns are defined only these columns are taken to define a unique row.
The returned array can hav... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Takes an array and calculates ranges [ start stop ]. | Given the following Python 3 function, write the documentation
def get_ranges_from_array(arr, append_last=True):
'''Takes an array and calculates ranges [start, stop[. The last range end is none to keep the same length.
Parameters
----------
arr : array like
append_last: bool
If True, appen... | You are a Python code analyst, evaluating scripts for potential improvements. |
def in1d_sorted(ar1, ar2):
"""
Does the same than np.in1d but uses the fact that ar1 and ar2 are sorted. Is therefore much faster.
"""
if ar1.shape[0] == 0 or ar2.shape[0] == 0: # check for empty arrays to avoid crash
return []
inds = ar2.searchsorted(ar1)
inds[inds == len(ar2)] = 0
... | Create a Python 3 function to
return true if ar1 and ar2 are in 1 - dimensional order. | As a Python code analyst, you investigate and solve complex coding mysteries |
Returns the dy and dx of the central difference of x and y. | Here you have a function in Python 3, explain what it does
def central_difference(x, y):
'''Returns the dy/dx(x) via central difference method
Parameters
----------
x : array like
y : array like
Returns
-------
dy/dx : array like
'''
if (len(x) != len(y)):
raise ValueEr... | As a Python code composer, you craft elegant and concise scripts. |
def get_profile_histogram(x, y, n_bins=100):
'''Takes 2D point data (x,y) and creates a profile histogram similar to the TProfile in ROOT. It calculates
the y mean for every bin at the bin center and gives the y mean error as error bars.
Parameters
----------
x : array like
data x positions... | How would you code a function in Python 3 to
take 2D point data x and y and creates a profile histogram similar to the TProfile in ROOT. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Calculates the rate normalization factor for each hit in the hit file. | Can you generate a brief explanation for the following Python 3 code
def get_rate_normalization(hit_file, parameter, reference='event', cluster_file=None, plot=False, chunk_size=500000):
''' Takes different hit files (hit_files), extracts the number of events or the scan time (reference) per scan parameter (paramet... | As a Python code analyst, you investigate and solve complex coding mysteries |
def get_parameter_value_from_file_names(files, parameters=None, unique=False, sort=True):
"""
Takes a list of files, searches for the parameter name in the file name and returns a ordered dict with the file name
in the first dimension and the corresponding parameter value in the second.
The file names c... | Create a Python 3 function to
take a list of files and searches for the parameter name in the file name and returns a dict with the file name Insights and the corresponding parameter value in the second dimension. | You are a Python code analyst, evaluating scripts for potential improvements. |
Generate a list of. h5 files which have a similar file name. | Make a summary of the following Python 3 code
def get_data_file_names_from_scan_base(scan_base, filter_str=['_analyzed.h5', '_interpreted.h5', '_cut.h5', '_result.h5', '_hists.h5'], sort_by_time=True, meta_data_v2=True):
data_files = []
if scan_base is None:
return data_files
if isinstance(scan_base... | You are a Python code analyst, evaluating scripts for potential improvements. |
Takes a list of files searches for the parameter name in the first dimension and the corresponding parameter values in the second dimension. | Here you have a function in Python 3, explain what it does
def get_parameter_from_files(files, parameters=None, unique=False, sort=True):
''' Takes a list of files, searches for the parameter name in the file name and in the file.
Returns a ordered dict with the file name in the first dimension and the correspo... | You are a Python code architect, reviewing and designing scalable and efficient code |
def check_parameter_similarity(files_dict):
"""
Checks if the parameter names of all files are similar. Takes the dictionary from get_parameter_from_files output as input.
"""
try:
parameter_names = files_dict.itervalues().next().keys() # get the parameter names of the first file, to check if ... | Write a Python 3 script to
check if the parameter names of all files are similar. Takes the dictionary from get_parameter_from_files output as input. | You are a Python code architect, reviewing and designing scalable and efficient code |
def combine_meta_data(files_dict, meta_data_v2=True):
"""
Takes the dict of hdf5 files and combines their meta data tables into one new numpy record array.
Parameters
----------
meta_data_v2 : bool
True for new (v2) meta data format, False for the old (v1) format.
"""
if len(files_d... | Implement a Python 3 function for
taking a dict of hdf5 files and combines their meta data tables into one numpy record array. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def smooth_differentiation(x, y, weigths=None, order=5, smoothness=3, derivation=1):
'''Returns the dy/dx(x) with the fit and differentiation of a spline curve
Parameters
----------
x : array like
y : array like
Returns
-------
dy/dx : array like
'''
if (len(x) != len(y)):
... | Create a Python 3 function for
returning the dy / dx of a spline curve with the fit and differentiation of a spline curve. | You are a Python code architect, reviewing and designing scalable and efficient code |
Takes two sorted arrays and return the intersection ar1 in ar2 in ar1. | Explain what the following Python 3 code does
def reduce_sorted_to_intersect(ar1, ar2):
# Ravel both arrays, behavior for the first array could be different
ar1 = np.asarray(ar1).ravel()
ar2 = np.asarray(ar2).ravel()
# get min max values of the arrays
ar1_biggest_value = ar1[-1]
ar1_smallest_va... | As a python code expert, you are capable of creating scripts from specifications. |
def get_not_unique_values(array):
'''Returns the values that appear at least twice in array.
Parameters
----------
array : array like
Returns
-------
numpy.array
'''
s = np.sort(array, axis=None)
s = s[s[1:] == s[:-1]]
return np.unique(s) | Write a Python 3 script to
return the values that appear at least twice in array. | You are a Python code generator, capable of creating scripts from specifications. |
Takes the analyzed meta_data table and returns the indices where the scan parameter changes | Explain what the following Python 3 code does
def get_meta_data_index_at_scan_parameter(meta_data_array, scan_parameter_name):
'''Takes the analyzed meta_data table and returns the indices where the scan parameter changes
Parameters
----------
meta_data_array : numpy.recordarray
scan_parameter_name... | As a Python code analyst, you investigate and solve complex coding mysteries |
Selects the hits with condition. | How would you explain what the following Python 3 function does
def select_hits(hits_array, condition=None):
'''Selects the hits with condition.
E.g.: condition = 'rel_BCID == 7 & event_number < 1000'
Parameters
----------
hits_array : numpy.array
condition : string
A condition that is ... | You are a Python code generator, capable of creating scripts from specifications. |
def get_hits_in_events(hits_array, events, assume_sorted=True, condition=None):
'''Selects the hits that occurred in events and optional selection criterion.
If a event range can be defined use the get_data_in_event_range function. It is much faster.
Parameters
----------
hits_array : numpy.arr... | Write a Python 3 function that can
select the hits that occurred in events and optional selection criterion. | As a python code expert, you are capable of creating scripts from specifications. |
Takes the hit table of a hdf5 file and returns hits in chunks for each unique combination of scan_parameters. | How would you explain what the following Python 3 function does
def get_hits_of_scan_parameter(input_file_hits, scan_parameters=None, try_speedup=False, chunk_size=10000000):
'''Takes the hit table of a hdf5 file and returns hits in chunks for each unique combination of scan_parameters.
Yields the hits in chunk... | You are a Python code architect, reviewing and designing scalable and efficient code |
Selects the data that occurred in the given event range [ event_start event_stop ] | How would you explain what the following Python 3 function does
def get_data_in_event_range(array, event_start=None, event_stop=None, assume_sorted=True):
'''Selects the data (rows of a table) that occurred in the given event range [event_start, event_stop[
Parameters
----------
array : numpy.array
... | You are a Python code generator, capable of creating scripts from specifications. |
def write_hits_in_events(hit_table_in, hit_table_out, events, start_hit_word=0, chunk_size=5000000, condition=None):
'''Selects the hits that occurred in events and writes them to a pytable. This function reduces the in RAM operations and has to be
used if the get_hits_in_events function raises a memory error. ... | How would you implement a function in Python 3 that
selects the hits that occurred in events and writes them to a pytable. | As a Python code composer, you craft elegant and concise scripts. |
This function writes hits that occurred in given event range to a hit table. | Can you tell what is the following Python 3 function doing
def write_hits_in_event_range(hit_table_in, hit_table_out, event_start=None, event_stop=None, start_hit_word=0, chunk_size=5000000, condition=None):
'''Selects the hits that occurred in given event range [event_start, event_stop[ and write them to a pytable... | You are a Python code architect, reviewing and designing scalable and efficient code |
Selects the events with a certain number of cluster. | Given the following Python 3 function, write the documentation
def get_events_with_n_cluster(event_number, condition='n_cluster==1'):
'''Selects the events with a certain number of cluster.
Parameters
----------
event_number : numpy.array
Returns
-------
numpy.array
'''
logging.de... | As a Python code analyst, you investigate and solve complex coding mysteries |
def get_events_with_cluster_size(event_number, cluster_size, condition='cluster_size==1'):
'''Selects the events with cluster of a given cluster size.
Parameters
----------
event_number : numpy.array
cluster_size : numpy.array
condition : string
Returns
-------
numpy.array
'''
... | Write a Python 3 script to
select the events with cluster of a given cluster size. | You are a Python code generator, capable of creating scripts from specifications. |
def get_events_with_error_code(event_number, event_status, select_mask=0b1111111111111111, condition=0b0000000000000000):
'''Selects the events with a certain error code.
Parameters
----------
event_number : numpy.array
event_status : numpy.array
select_mask : int
The mask that selects ... | Can you create a Python 3 function that
selects the events with a certain error code. | You are a Python code generator, capable of creating scripts from specifications. |
def get_scan_parameter(meta_data_array, unique=True):
'''Takes the numpy meta data array and returns the different scan parameter settings and the name aligned in a dictionary
Parameters
----------
meta_data_array : numpy.ndarray
unique: boolean
If true only unique values for each scan para... | Write a Python 3 function for
taking the numpy meta data array and returns the different scan parameter settings and the name aligned in a dictionary | As a Python code translator, you convert algorithms and pseudocode into Python. |
Takes the meta data array and returns the scan parameter values as a view of a numpy array only containing the parameter data. | Explain what the following Python 3 code does
def get_scan_parameters_table_from_meta_data(meta_data_array, scan_parameters=None):
'''Takes the meta data array and returns the scan parameter values as a view of a numpy array only containing the parameter data .
Parameters
----------
meta_data_array : nu... | You are a Python code architect, reviewing and designing scalable and efficient code |
def get_scan_parameters_index(scan_parameter):
'''Takes the scan parameter array and creates a scan parameter index labeling the unique scan parameter combinations.
Parameters
----------
scan_parameter : numpy.ndarray
The table with the scan parameters.
Returns
-------
numpy.Histogr... | Write a Python 3 function that can
take the scan parameter array and creates a scan parameter index labeling the unique scan parameter combinations. | As a python code expert, you are capable of creating scripts from specifications. |
Takes the numpy meta data array and returns the first rows with unique combinations of different scan parameter values for selected scan parameters. | Explain what the following Python 3 code does
def get_unique_scan_parameter_combinations(meta_data_array, scan_parameters=None, scan_parameter_columns_only=False):
'''Takes the numpy meta data array and returns the first rows with unique combinations of different scan parameter values for selected scan parameters.
... | As a Python code analyst, you investigate and solve complex coding mysteries |
Takes the table with a event_number column and returns chunks with the size up to chunk_size. | Can you tell what is the following Python 3 function doing
def data_aligned_at_events(table, start_event_number=None, stop_event_number=None, start_index=None, stop_index=None, chunk_size=10000000, try_speedup=False, first_event_aligned=True, fail_on_missing_events=True):
'''Takes the table with a event_number colu... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Takes the hit array and masks all pixels with a certain occupancy. | Can you generate a brief explanation for the following Python 3 code
def select_good_pixel_region(hits, col_span, row_span, min_cut_threshold=0.2, max_cut_threshold=2.0):
'''Takes the hit array and masks all pixels with a certain occupancy.
Parameters
----------
hits : array like
If dim > 2 the... | As a Python code composer, you craft elegant and concise scripts. |
def get_hit_rate_correction(gdacs, calibration_gdacs, cluster_size_histogram):
'''Calculates a correction factor for single hit clusters at the given GDACs from the cluster_size_histogram via cubic interpolation.
Parameters
----------
gdacs : array like
The GDAC settings where the threshold sho... | Create a Python 3 function to
calculate a correction factor for a single hit cluster at the given GDACs from the cluster_size_histogram via cubic interpolation. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def get_mean_threshold_from_calibration(gdac, mean_threshold_calibration):
'''Calculates the mean threshold from the threshold calibration at the given gdac settings. If the given gdac value was not used during caluibration
the value is determined by interpolation.
Parameters
----------
gdacs : arr... | Implement a Python 3 function for
calculating the mean threshold from the threshold calibration at the given gdac settings. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Calculates the threshold for all pixels in threshold_calibration_array at the given GDACs. | Make a summary of the following Python 3 code
def get_pixel_thresholds_from_calibration_array(gdacs, calibration_gdacs, threshold_calibration_array, bounds_error=True):
'''Calculates the threshold for all pixels in threshold_calibration_array at the given GDAC settings via linear interpolation. The GDAC settings us... | You are a Python code generator, capable of creating scripts from specifications. |
Calculates the number of cluster in every event. | Can you tell what is the following Python 3 function doing
def get_n_cluster_per_event_hist(cluster_table):
'''Calculates the number of cluster in every event.
Parameters
----------
cluster_table : pytables.table
Returns
-------
numpy.Histogram
'''
logging.info("Histogram number of... | As a python code expert, you are capable of creating scripts from specifications. |
def contiguous_regions(condition):
"""Finds contiguous True regions of the boolean array "condition". Returns
a 2D array where the first column is the start index of the region and the
second column is the end index.
http://stackoverflow.com/questions/4494404/find-large-number-of-consecutive-values-fulf... | Write a Python 3 script for
finding contiguous True regions of the array condition. Returns a 2D array where first column is the start index and second column is the end index. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def check_bad_data(raw_data, prepend_data_headers=None, trig_count=None):
"""Checking FEI4 raw data array for corrupted data.
"""
consecutive_triggers = 16 if trig_count == 0 else trig_count
is_fe_data_header = logical_and(is_fe_word, is_data_header)
trigger_idx = np.where(is_trigger_word(raw_data) ... | How would you code a function in Python 3 to
check FEI4 raw data array for corrupted data. | As a python code expert, you are capable of creating scripts from specifications. |
Converts array into chunks with consecutive elements of given step size. | How would you explain what the following Python 3 function does
def consecutive(data, stepsize=1):
return np.split(data, np.where(np.diff(data) != stepsize)[0] + 1) | You are a Python code architect, reviewing and designing scalable and efficient code |
Print FEI4 raw data from a file. | Can you tell what is the following Python 3 function doing
def print_raw_data_file(input_file, start_index=0, limit=200, flavor='fei4b', select=None, tdc_trig_dist=False, trigger_data_mode=0, meta_data_v2=True):
with tb.open_file(input_file + '.h5', mode="r") as file_h5:
if meta_data_v2:
index_s... | You are a Python code analyst, evaluating scripts for potential improvements. |
Print FEI4 raw data array for debugging. | How would you explain what the following Python 3 function does
def print_raw_data(raw_data, start_index=0, limit=200, flavor='fei4b', index_offset=0, select=None, tdc_trig_dist=False, trigger_data_mode=0):
if not select:
select = ['DH', 'TW', "AR", "VR", "SR", "DR", 'TDC', 'UNKNOWN FE WORD', 'UNKNOWN WORD'... | You are a Python code generator, capable of creating scripts from specifications. |
Updates the widget to show the ETA or total time when finished. | Explain what the following Python 3 code does
def update(self, pbar):
'Updates the widget to show the ETA or total time when finished.'
self.n_refresh += 1
if pbar.currval == 0:
return 'ETA: --:--:--'
elif pbar.finished:
return 'Time: %s' % self.format_time(pbar.... | As a Python code analyst, you investigate and solve complex coding mysteries |
Fit spline to the profile histogramed data and differentiate determine MPV and plot. | How would you explain what the following Python 3 function does
def plot_result(x_p, y_p, y_p_e, smoothed_data, smoothed_data_diff, filename=None):
''' Fit spline to the profile histogramed data, differentiate, determine MPV and plot.
Parameters
----------
x_p, y_p : array like
data poi... | As a Python code analyst, you investigate and solve complex coding mysteries |
def create_hitor_calibration(output_filename, plot_pixel_calibrations=False):
'''Generating HitOr calibration file (_calibration.h5) from raw data file and plotting of calibration data.
Parameters
----------
output_filename : string
Input raw data file name.
plot_pixel_calibrations :... | Can you implement a function in Python 3 that
generates HitOR calibration file from raw data file and plotting of calibration data. | As a Python code composer, you craft elegant and concise scripts. |
def send_mail(subject, body, smtp_server, user, password, from_addr, to_addrs):
''' Sends a run status mail with the traceback to a specified E-Mail address if a run crashes.
'''
logging.info('Send status E-Mail (' + subject + ')')
content = string.join((
"From: %s" % from_addr,
"To: %s"... | Write a Python 3 function that can
send a run status mail with the traceback to a specified E - Mail address. | As a python code expert, you are capable of creating scripts from specifications. |
Extracts the configuration of the modules. | Can you generate a brief explanation for the following Python 3 code
def _parse_module_cfgs(self):
''' Extracts the configuration of the modules.
'''
# Adding here default run config parameters.
if "dut" not in self._conf or self._conf["dut"] is None:
raise ValueError('Parame... | You are a Python code analyst, evaluating scripts for potential improvements. |
def _set_default_cfg(self):
''' Sets the default parameters if they are not specified.
'''
# adding special conf for accessing all DUT drivers
self._module_cfgs[None] = {
'flavor': None,
'chip_address': None,
'FIFO': list(set([self._module_cfgs[module_... | Can you implement a function in Python 3 that
sets the default parameters if they are not specified. | You are a Python code analyst, evaluating scripts for potential improvements. |
Initialize all modules consecutively | How would you explain what the following Python 3 function does
def init_modules(self):
''' Initialize all modules consecutively'''
for module_id, module_cfg in self._module_cfgs.items():
if module_id in self._modules or module_id in self._tx_module_groups:
if module_id in se... | You are a Python code architect, reviewing and designing scalable and efficient code |
Start runs on all modules sequentially. | Make a summary of the following Python 3 code
def do_run(self):
''' Start runs on all modules sequentially.
Sets properties to access current module properties.
'''
if self.broadcast_commands: # Broadcast FE commands
if self.threaded_scan:
with ExitStack() a... | You are a Python code generator, capable of creating scripts from specifications. |
Closes the DUT and releases hardware resources. | Here you have a function in Python 3, explain what it does
def close(self):
'''Releasing hardware resources.
'''
try:
self.dut.close()
except Exception:
logging.warning('Closing DUT was not successful')
else:
logging.debug('Closed DUT') | You are a Python code analyst, evaluating scripts for potential improvements. |
Handling of the data. | Can you generate a brief explanation for the following Python 3 code
def handle_data(self, data, new_file=False, flush=True):
'''Handling of the data.
Parameters
----------
data : list, tuple
Data tuple of the format (data (np.array), last_time (float), curr_time (float), st... | You are a Python code analyst, evaluating scripts for potential improvements. |
Handling of Exceptions.
Parameters
----------
exc : list, tuple
Information of the exception of the format (type, value, traceback).
Uses the return value of sys.exc_info(). | Make a summary of the following Python 3 code
def handle_err(self, exc):
'''Handling of Exceptions.
Parameters
----------
exc : list, tuple
Information of the exception of the format (type, value, traceback).
Uses the return value of sys.exc_info().
'''
... | As a python code expert, you are capable of creating scripts from specifications. |
def get_configuration(self, module_id, run_number=None):
''' Returns the configuration for a given module ID.
The working directory is searched for a file matching the module_id with the
given run number. If no run number is defined the last successfull run defines
the run number.
... | Write a Python 3 script for
returning the configuration file for a given module ID and run number. | As a python code expert, you are capable of creating scripts from specifications. |
def select_module(self, module_id):
''' Select module and give access to the module.
'''
if not isinstance(module_id, basestring) and isinstance(module_id, Iterable) and set(module_id) - set(self._modules):
raise ValueError('Module IDs invalid:' % ", ".join(set(module_id) - set(self.... | How would you code a function in Python 3 to
select module and give access to the module. | You are a Python code analyst, evaluating scripts for potential improvements. |
Deselect module and cleanup. | Can you generate a brief explanation for the following Python 3 code
def deselect_module(self):
''' Deselect module and cleanup.
'''
self._enabled_fe_channels = [] # ignore any RX sync errors
self._readout_fifos = []
self._filter = []
self._converter = []
self.du... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Wait for all threads to appear then continue. | How would you explain what the following Python 3 function does
def enter_sync(self):
''' Waiting for all threads to appear, then continue.
'''
if self._scan_threads and self.current_module_handle not in [t.name for t in self._scan_threads]:
raise RuntimeError('Thread name "%s" is no... | As a Python code analyst, you investigate and solve complex coding mysteries |
Waiting for all threads to appear, then continue. | Here you have a function in Python 3, explain what it does
def exit_sync(self):
''' Waiting for all threads to appear, then continue.
'''
if self._scan_threads and self.current_module_handle not in [t.name for t in self._scan_threads]:
raise RuntimeError('Thread name "%s" is not vali... | You are a Python code generator, capable of creating scripts from specifications. |
A context manager that starts the FIFO readout while executing other statements. | Make a summary of the following Python 3 code
def readout(self, *args, **kwargs):
''' Running the FIFO readout while executing other statements.
Starting and stopping of the FIFO readout is synchronized between the threads.
'''
timeout = kwargs.pop('timeout', 10.0)
self.start_re... | You are a Python code architect, reviewing and designing scalable and efficient code |
Start the FIFO readout. | Explain what the following Python 3 code does
def start_readout(self, *args, **kwargs):
''' Starting the FIFO readout.
Starting of the FIFO readout is executed only once by a random thread.
Starting of the FIFO readout is synchronized between all threads reading out the FIFO.
'''
... | As a python code expert, you are capable of creating scripts from specifications. |
Stops the FIFO readout. | Can you tell what is the following Python 3 function doing
def stop_readout(self, timeout=10.0):
''' Stopping the FIFO readout.
Stopping of the FIFO readout is executed only once by a random thread.
Stopping of the FIFO readout is synchronized between all threads reading out the FIFO.
'... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def get_charge_calibration(calibation_file, max_tdc):
''' Open the hit or calibration file and return the calibration per pixel'''
with tb.open_file(calibation_file, mode="r") as in_file_calibration_h5:
tdc_calibration = in_file_calibration_h5.root.HitOrCalibration[:, :, :, 1]
tdc_calibration_va... | Write a Python 3 script for
opening the hit or calibration file and return the calibration per pixel | You are a Python code generator, capable of creating scripts from specifications. |
def addEntry(self):
"""Add the `Plot pyBAR data`. entry to `Dataset` menu.
"""
export_icon = QtGui.QIcon()
pixmap = QtGui.QPixmap(os.path.join(PLUGINSDIR,
'csv/icons/document-export.png'))
export_icon.addPixmap(pixmap, QtGui.QIcon.Norma... | Write a Python 3 script to
add the Plot pyBAR data. entry to Dataset menu. | You are a Python code analyst, evaluating scripts for potential improvements. |
def updateDatasetMenu(self):
"""Update the `export` QAction when the Dataset menu is pulled down.
This method is a slot. See class ctor for details.
"""
enabled = True
current = self.vtgui.dbs_tree_view.currentIndex()
if current:
leaf = self.vtgui.dbs_tree_mo... | Write a Python 3 function for
updating the export QAction when the Dataset menu is pulled down. | You are a Python code analyst, evaluating scripts for potential improvements. |
This method exports a given dataset to a CSV file. | Can you generate the documentation for the following Python 3 function
def plot(self):
# The PyTables node tied to the current leaf of the databases tree
current = self.vtgui.dbs_tree_view.currentIndex()
leaf = self.vtgui.dbs_tree_model.nodeFromIndex(current).node
data_name = leaf.name
... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Help text for the object. | Can you generate the documentation for the following Python 3 function
def helpAbout(self):
# Text to be displayed
about_text = translate('pyBarPlugin',
"""<qt>
<p>Data plotting plug-in for pyBAR.
</qt>""",
'About')
... | You are a Python code architect, reviewing and designing scalable and efficient code |
def send_meta_data(socket, conf, name):
'''Sends the config via ZeroMQ to a specified socket. Is called at the beginning of a run and when the config changes. Conf can be any config dictionary.
'''
meta_data = dict(
name=name,
conf=conf
)
try:
socket.send_json(meta_data, flag... | Implement a Python 3 function for
sending the config via ZeroMQ to a specified socket. | As a python code expert, you are capable of creating scripts from specifications. |
Sends the data of every read out to a specified socket | Here you have a function in Python 3, explain what it does
def send_data(socket, data, scan_parameters={}, name='ReadoutData'):
'''Sends the data of every read out (raw data and meta data) via ZeroMQ to a specified socket
'''
if not scan_parameters:
scan_parameters = {}
data_meta_data = dict(
... | You are a Python code generator, capable of creating scripts from specifications. |
def save_raw_data_from_data_queue(data_queue, filename, mode='a', title='', scan_parameters=None): # mode="r+" to append data, raw_data_file_h5 must exist, "w" to overwrite raw_data_file_h5, "a" to append data, if raw_data_file_h5 does not exist it is created
'''Writing raw data file from data queue
If you ne... | Write a Python 3 script to
write raw data from data queue to file | You are a Python code generator, capable of creating scripts from specifications. |
Plots a linear relation between two data sets. | How would you explain what the following Python 3 function does
def plot_linear_relation(x, y, x_err=None, y_err=None, title=None, point_label=None, legend=None, plot_range=None, plot_range_y=None, x_label=None, y_label=None, y_2_label=None, log_x=False, log_y=False, size=None, filename=None):
''' Takes point data... | You are a Python code analyst, evaluating scripts for potential improvements. |
def plot_profile_histogram(x, y, n_bins=100, title=None, x_label=None, y_label=None, log_y=False, filename=None):
'''Takes 2D point data (x,y) and creates a profile histogram similar to the TProfile in ROOT. It calculates
the y mean for every bin at the bin center and gives the y mean error as error bars.
... | Create a Python 3 function to
plot a 2D histogram of x and y. | As a Python code composer, you craft elegant and concise scripts. |
Round up to the nearest multiple of any positive integer. | Explain what the following Python 3 code does
def round_to_multiple(number, multiple):
'''Rounding up to the nearest multiple of any positive integer
Parameters
----------
number : int, float
Input number.
multiple : int
Round up to multiple of multiple. Will be converted to... | You are a Python code architect, reviewing and designing scalable and efficient code |
def hist_quantiles(hist, prob=(0.05, 0.95), return_indices=False, copy=True):
'''Calculate quantiles from histograms, cuts off hist below and above given quantile. This function will not cut off more than the given values.
Parameters
----------
hist : array_like, iterable
Input histogram ... | Write a Python 3 script to
calculate quantiles from histograms cuts off hist below and above given quantile. | As a python code expert, you are capable of creating scripts from specifications. |
def hist_last_nonzero(hist, return_index=False, copy=True):
'''Find the last nonzero index and mask the remaining entries.
Parameters
----------
hist : array_like, iterable
Input histogram with dimension at most 1.
return_index : bool, optional
If true, return the index.
... | Create a Python 3 function to
return the last nonzero entry in a histogram. | You are a Python code generator, capable of creating scripts from specifications. |
Readout thread continuously reading FIFO. | Can you generate the documentation for the following Python 3 function
def readout(self, fifo, no_data_timeout=None):
'''Readout thread continuously reading FIFO.
Readout thread, which uses read_raw_data_from_fifo() and appends data to self._fifo_data_deque (collection.deque).
'''
... | As a Python code composer, you craft elegant and concise scripts. |
This method is a thread that continuously filters and converts data when data becomes available. | Given the following Python 3 function, write the documentation
def worker(self, fifo):
'''Worker thread continuously filtering and converting data when data becomes available.
'''
logging.debug('Starting worker thread for %s', fifo)
self._fifo_conditions[fifo].acquire()
whil... | You are a Python code generator, capable of creating scripts from specifications. |
def writer(self, index, no_data_timeout=None):
'''Writer thread continuously calling callback function for writing data when data becomes available.
'''
is_fe_data_header = logical_and(is_fe_word, is_data_header)
logging.debug('Starting writer thread with index %d', index)
s... | Write a Python 3 function that can
thread continuously calling callback function for writing data when data becomes available. | You are a Python code architect, reviewing and designing scalable and efficient code |
Reads local data buffer and returns data and meta data dicts. | Here you have a function in Python 3, explain what it does
def get_data_from_buffer(self, filter_func=None, converter_func=None):
'''Reads local data buffer and returns data and meta data list.
Returns
-------
data : list
List of data and meta data dicts.
'''
... | As a Python code analyst, you investigate and solve complex coding mysteries |
def get_raw_data_from_buffer(self, filter_func=None, converter_func=None):
'''Reads local data buffer and returns raw data array.
Returns
-------
data : np.array
An array containing data words from the local data buffer.
'''
if self._is_running:
... | Write a Python 3 script for
reading local data buffer and returns raw data array. | You are a Python code analyst, evaluating scripts for potential improvements. |
Reads FIFO data and returns raw data array. | Explain what the following Python 3 code does
def read_raw_data_from_fifo(self, fifo, filter_func=None, converter_func=None):
'''Reads FIFO data and returns raw data array.
Returns
-------
data : np.array
An array containing FIFO data words.
'''
retur... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def get_item_from_queue(Q, timeout=0.01):
""" Attempts to retrieve an item from the queue Q. If Q is
empty, None is returned.
Blocks for 'timeout' seconds in case the queue is empty,
so don't use this method for speedy retrieval of multiple
items (use get_all_from_queue for th... | Write a Python 3 function for
getting an item from the queue Q. | You are a Python code generator, capable of creating scripts from specifications. |
Returns a list of elements of seq with the lowest scores. | Explain what the following Python 3 code does
def argmin_list(seq, func):
best_score, best = func(seq[0]), []
for x in seq:
x_score = func(x)
if x_score < best_score:
best, best_score = [x], x_score
elif x_score == best_score:
best.append(x)
return bes... | You are a Python code analyst, evaluating scripts for potential improvements. |
def flatten_iterable(iterable):
"""flatten iterable, but leaves out strings
[[[1, 2, 3], [4, 5]], 6] -> [1, 2, 3, 4, 5, 6]
"""
for item in iterable:
if isinstance(item, collections.Iterable) and not isinstance(item, basestring):
for sub in flatten_iterable(item):
... | Implement a function in Python 3 to
flatten iterable but leaves out strings | As a Python code analyst, you investigate and solve complex coding mysteries |
def iterable(item):
"""generate iterable from item, but leaves out strings
"""
if isinstance(item, collections.Iterable) and not isinstance(item, basestring):
return item
else:
return [item] | Can you write a function in Python 3 where it
generates iterable from item but leaves out strings | As a python code expert, you are capable of creating scripts from specifications. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.