repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
SiLab-Bonn/pyBAR
pybar/fei4_run_base.py
Fei4RunBase.handle_err
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(). ''' if self.reset_rx_on_error and isinstanc...
python
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(). ''' if self.reset_rx_on_error and isinstanc...
[ "def", "handle_err", "(", "self", ",", "exc", ")", ":", "if", "self", ".", "reset_rx_on_error", "and", "isinstance", "(", "exc", "[", "1", "]", ",", "(", "RxSyncError", ",", "EightbTenbError", ")", ")", ":", "self", ".", "fifo_readout", ".", "print_reado...
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().
[ "Handling", "of", "Exceptions", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4_run_base.py#L881-L897
train
SiLab-Bonn/pyBAR
pybar/fei4_run_base.py
Fei4RunBase.get_configuration
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. ...
python
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. ...
[ "def", "get_configuration", "(", "self", ",", "module_id", ",", "run_number", "=", "None", ")", ":", "def", "find_file", "(", "run_number", ")", ":", "module_path", "=", "self", ".", "get_module_path", "(", "module_id", ")", "for", "root", ",", "_", ",", ...
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.
[ "Returns", "the", "configuration", "for", "a", "given", "module", "ID", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4_run_base.py#L904-L938
train
SiLab-Bonn/pyBAR
pybar/fei4_run_base.py
Fei4RunBase.select_module
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....
python
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....
[ "def", "select_module", "(", "self", ",", "module_id", ")", ":", "if", "not", "isinstance", "(", "module_id", ",", "basestring", ")", "and", "isinstance", "(", "module_id", ",", "Iterable", ")", "and", "set", "(", "module_id", ")", "-", "set", "(", "self...
Select module and give access to the module.
[ "Select", "module", "and", "give", "access", "to", "the", "module", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4_run_base.py#L1014-L1077
train
SiLab-Bonn/pyBAR
pybar/fei4_run_base.py
Fei4RunBase.deselect_module
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.dut['TX']['OUTPUT_ENABLE'] = 0 self._current_module_handle = No...
python
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.dut['TX']['OUTPUT_ENABLE'] = 0 self._current_module_handle = No...
[ "def", "deselect_module", "(", "self", ")", ":", "self", ".", "_enabled_fe_channels", "=", "[", "]", "# ignore any RX sync errors", "self", ".", "_readout_fifos", "=", "[", "]", "self", ".", "_filter", "=", "[", "]", "self", ".", "_converter", "=", "[", "]...
Deselect module and cleanup.
[ "Deselect", "module", "and", "cleanup", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4_run_base.py#L1079-L1089
train
SiLab-Bonn/pyBAR
pybar/fei4_run_base.py
Fei4RunBase.enter_sync
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 not valid.') if self._scan_threads and self.current_module...
python
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 not valid.') if self._scan_threads and self.current_module...
[ "def", "enter_sync", "(", "self", ")", ":", "if", "self", ".", "_scan_threads", "and", "self", ".", "current_module_handle", "not", "in", "[", "t", ".", "name", "for", "t", "in", "self", ".", "_scan_threads", "]", ":", "raise", "RuntimeError", "(", "'Thr...
Waiting for all threads to appear, then continue.
[ "Waiting", "for", "all", "threads", "to", "appear", "then", "continue", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4_run_base.py#L1169-L1184
train
SiLab-Bonn/pyBAR
pybar/fei4_run_base.py
Fei4RunBase.exit_sync
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 valid.') if self._scan_threads and self.current_module_...
python
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 valid.') if self._scan_threads and self.current_module_...
[ "def", "exit_sync", "(", "self", ")", ":", "if", "self", ".", "_scan_threads", "and", "self", ".", "current_module_handle", "not", "in", "[", "t", ".", "name", "for", "t", "in", "self", ".", "_scan_threads", "]", ":", "raise", "RuntimeError", "(", "'Thre...
Waiting for all threads to appear, then continue.
[ "Waiting", "for", "all", "threads", "to", "appear", "then", "continue", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4_run_base.py#L1186-L1201
train
SiLab-Bonn/pyBAR
pybar/fei4_run_base.py
Fei4RunBase.readout
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_readout(*args, **kwargs) try: ...
python
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_readout(*args, **kwargs) try: ...
[ "def", "readout", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "timeout", "=", "kwargs", ".", "pop", "(", "'timeout'", ",", "10.0", ")", "self", ".", "start_readout", "(", "*", "args", ",", "*", "*", "kwargs", ")", "try", ":"...
Running the FIFO readout while executing other statements. Starting and stopping of the FIFO readout is synchronized between the threads.
[ "Running", "the", "FIFO", "readout", "while", "executing", "other", "statements", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4_run_base.py#L1204-L1222
train
SiLab-Bonn/pyBAR
pybar/fei4_run_base.py
Fei4RunBase.start_readout
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. ''' # Pop parameters for fifo_readout.start ...
python
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. ''' # Pop parameters for fifo_readout.start ...
[ "def", "start_readout", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Pop parameters for fifo_readout.start", "callback", "=", "kwargs", ".", "pop", "(", "'callback'", ",", "self", ".", "handle_data", ")", "errback", "=", "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.
[ "Starting", "the", "FIFO", "readout", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4_run_base.py#L1224-L1254
train
SiLab-Bonn/pyBAR
pybar/fei4_run_base.py
Fei4RunBase.stop_readout
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. ''' if self._scan_threads and self.current_module_ha...
python
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. ''' if self._scan_threads and self.current_module_ha...
[ "def", "stop_readout", "(", "self", ",", "timeout", "=", "10.0", ")", ":", "if", "self", ".", "_scan_threads", "and", "self", ".", "current_module_handle", "not", "in", "[", "t", ".", "name", "for", "t", "in", "self", ".", "_scan_threads", "]", ":", "r...
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.
[ "Stopping", "the", "FIFO", "readout", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4_run_base.py#L1256-L1274
train
SiLab-Bonn/pyBAR
pybar/scans/analyze_timewalk.py
get_charge
def get_charge(max_tdc, tdc_calibration_values, tdc_pixel_calibration): # Return the charge from calibration ''' Interpolatet the TDC calibration for each pixel from 0 to max_tdc''' charge_calibration = np.zeros(shape=(80, 336, max_tdc)) for column in range(80): for row in range(336): a...
python
def get_charge(max_tdc, tdc_calibration_values, tdc_pixel_calibration): # Return the charge from calibration ''' Interpolatet the TDC calibration for each pixel from 0 to max_tdc''' charge_calibration = np.zeros(shape=(80, 336, max_tdc)) for column in range(80): for row in range(336): a...
[ "def", "get_charge", "(", "max_tdc", ",", "tdc_calibration_values", ",", "tdc_pixel_calibration", ")", ":", "# Return the charge from calibration", "charge_calibration", "=", "np", ".", "zeros", "(", "shape", "=", "(", "80", ",", "336", ",", "max_tdc", ")", ")", ...
Interpolatet the TDC calibration for each pixel from 0 to max_tdc
[ "Interpolatet", "the", "TDC", "calibration", "for", "each", "pixel", "from", "0", "to", "max_tdc" ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/scans/analyze_timewalk.py#L21-L33
train
SiLab-Bonn/pyBAR
pybar/scans/analyze_timewalk.py
get_charge_calibration
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...
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...
[ "def", "get_charge_calibration", "(", "calibation_file", ",", "max_tdc", ")", ":", "with", "tb", ".", "open_file", "(", "calibation_file", ",", "mode", "=", "\"r\"", ")", "as", "in_file_calibration_h5", ":", "tdc_calibration", "=", "in_file_calibration_h5", ".", "...
Open the hit or calibration file and return the calibration per pixel
[ "Open", "the", "hit", "or", "calibration", "file", "and", "return", "the", "calibration", "per", "pixel" ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/scans/analyze_timewalk.py#L36-L41
train
SiLab-Bonn/pyBAR
pybar/ViTablesPlugin/pybar_plugin.py
pyBarPlugin.addEntry
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...
python
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...
[ "def", "addEntry", "(", "self", ")", ":", "export_icon", "=", "QtGui", ".", "QIcon", "(", ")", "pixmap", "=", "QtGui", ".", "QPixmap", "(", "os", ".", "path", ".", "join", "(", "PLUGINSDIR", ",", "'csv/icons/document-export.png'", ")", ")", "export_icon", ...
Add the `Plot pyBAR data`. entry to `Dataset` menu.
[ "Add", "the", "Plot", "pyBAR", "data", ".", "entry", "to", "Dataset", "menu", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/ViTablesPlugin/pybar_plugin.py#L145-L172
train
SiLab-Bonn/pyBAR
pybar/ViTablesPlugin/pybar_plugin.py
pyBarPlugin.updateDatasetMenu
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...
python
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...
[ "def", "updateDatasetMenu", "(", "self", ")", ":", "enabled", "=", "True", "current", "=", "self", ".", "vtgui", ".", "dbs_tree_view", ".", "currentIndex", "(", ")", "if", "current", ":", "leaf", "=", "self", ".", "vtgui", ".", "dbs_tree_model", ".", "no...
Update the `export` QAction when the Dataset menu is pulled down. This method is a slot. See class ctor for details.
[ "Update", "the", "export", "QAction", "when", "the", "Dataset", "menu", "is", "pulled", "down", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/ViTablesPlugin/pybar_plugin.py#L174-L186
train
SiLab-Bonn/pyBAR
pybar/ViTablesPlugin/pybar_plugin.py
pyBarPlugin.plot
def plot(self): """Export a given dataset to a `CSV` file. This method is a slot connected to the `export` QAction. See the :meth:`addEntry` method for details. """ # The PyTables node tied to the current leaf of the databases tree current = self.vtgui.dbs_tree_view.curr...
python
def plot(self): """Export a given dataset to a `CSV` file. This method is a slot connected to the `export` QAction. See the :meth:`addEntry` method for details. """ # The PyTables node tied to the current leaf of the databases tree current = self.vtgui.dbs_tree_view.curr...
[ "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", ".", "n...
Export a given dataset to a `CSV` file. This method is a slot connected to the `export` QAction. See the :meth:`addEntry` method for details.
[ "Export", "a", "given", "dataset", "to", "a", "CSV", "file", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/ViTablesPlugin/pybar_plugin.py#L188-L214
train
SiLab-Bonn/pyBAR
pybar/ViTablesPlugin/pybar_plugin.py
pyBarPlugin.helpAbout
def helpAbout(self): """Brief description of the plugin. """ # Text to be displayed about_text = translate('pyBarPlugin', """<qt> <p>Data plotting plug-in for pyBAR. </qt>""", 'About') descr =...
python
def helpAbout(self): """Brief description of the plugin. """ # Text to be displayed about_text = translate('pyBarPlugin', """<qt> <p>Data plotting plug-in for pyBAR. </qt>""", 'About') descr =...
[ "def", "helpAbout", "(", "self", ")", ":", "# Text to be displayed", "about_text", "=", "translate", "(", "'pyBarPlugin'", ",", "\"\"\"<qt>\n <p>Data plotting plug-in for pyBAR.\n </qt>\"\"\"", ",", "'About'", ")", "descr", "=", "dict", "(", "module_na...
Brief description of the plugin.
[ "Brief", "description", "of", "the", "plugin", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/ViTablesPlugin/pybar_plugin.py#L216-L234
train
SiLab-Bonn/pyBAR
pybar/daq/fei4_raw_data.py
send_meta_data
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...
python
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...
[ "def", "send_meta_data", "(", "socket", ",", "conf", ",", "name", ")", ":", "meta_data", "=", "dict", "(", "name", "=", "name", ",", "conf", "=", "conf", ")", "try", ":", "socket", ".", "send_json", "(", "meta_data", ",", "flags", "=", "zmq", ".", ...
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.
[ "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", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/fei4_raw_data.py#L13-L23
train
SiLab-Bonn/pyBAR
pybar/daq/fei4_raw_data.py
send_data
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( name=name, dtype=str(data[0].dtype), ...
python
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( name=name, dtype=str(data[0].dtype), ...
[ "def", "send_data", "(", "socket", ",", "data", ",", "scan_parameters", "=", "{", "}", ",", "name", "=", "'ReadoutData'", ")", ":", "if", "not", "scan_parameters", ":", "scan_parameters", "=", "{", "}", "data_meta_data", "=", "dict", "(", "name", "=", "n...
Sends the data of every read out (raw data and meta data) via ZeroMQ to a specified socket
[ "Sends", "the", "data", "of", "every", "read", "out", "(", "raw", "data", "and", "meta", "data", ")", "via", "ZeroMQ", "to", "a", "specified", "socket" ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/fei4_raw_data.py#L26-L44
train
SiLab-Bonn/pyBAR
pybar/daq/fei4_raw_data.py
open_raw_data_file
def open_raw_data_file(filename, mode="w", title="", scan_parameters=None, socket_address=None): '''Mimics pytables.open_file() and stores the configuration and run configuration Returns: RawDataFile Object Examples: with open_raw_data_file(filename = self.scan_data_filename, title=self.scan_id, s...
python
def open_raw_data_file(filename, mode="w", title="", scan_parameters=None, socket_address=None): '''Mimics pytables.open_file() and stores the configuration and run configuration Returns: RawDataFile Object Examples: with open_raw_data_file(filename = self.scan_data_filename, title=self.scan_id, s...
[ "def", "open_raw_data_file", "(", "filename", ",", "mode", "=", "\"w\"", ",", "title", "=", "\"\"", ",", "scan_parameters", "=", "None", ",", "socket_address", "=", "None", ")", ":", "return", "RawDataFile", "(", "filename", "=", "filename", ",", "mode", "...
Mimics pytables.open_file() and stores the configuration and run configuration Returns: RawDataFile Object Examples: with open_raw_data_file(filename = self.scan_data_filename, title=self.scan_id, scan_parameters=[scan_parameter]) as raw_data_file: # do something here raw_data_file.app...
[ "Mimics", "pytables", ".", "open_file", "()", "and", "stores", "the", "configuration", "and", "run", "configuration" ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/fei4_raw_data.py#L47-L58
train
SiLab-Bonn/pyBAR
pybar/daq/fei4_raw_data.py
save_raw_data_from_data_queue
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...
python
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...
[ "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\" ...
Writing raw data file from data queue If you need to write raw data once in a while this function may make it easy for you.
[ "Writing", "raw", "data", "file", "from", "data", "queue" ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/fei4_raw_data.py#L240-L248
train
SiLab-Bonn/pyBAR
pybar/scans/tune_fei4.py
Fei4Tuning.scan
def scan(self): '''Metascript that calls other scripts to tune the FE. Parameters ---------- cfg_name : string Name of the config to be created. This config holds the tuning results. target_threshold : int The target threshold value in PlsrDAC. ...
python
def scan(self): '''Metascript that calls other scripts to tune the FE. Parameters ---------- cfg_name : string Name of the config to be created. This config holds the tuning results. target_threshold : int The target threshold value in PlsrDAC. ...
[ "def", "scan", "(", "self", ")", ":", "for", "iteration", "in", "range", "(", "0", ",", "self", ".", "global_iterations", ")", ":", "# tune iteratively with decreasing range to save time\r", "if", "self", ".", "stop_run", ".", "is_set", "(", ")", ":", "break",...
Metascript that calls other scripts to tune the FE. Parameters ---------- cfg_name : string Name of the config to be created. This config holds the tuning results. target_threshold : int The target threshold value in PlsrDAC. target_charge : int ...
[ "Metascript", "that", "calls", "other", "scripts", "to", "tune", "the", "FE", ".", "Parameters", "----------", "cfg_name", ":", "string", "Name", "of", "the", "config", "to", "be", "created", ".", "This", "config", "holds", "the", "tuning", "results", ".", ...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/scans/tune_fei4.py#L92-L184
train
SiLab-Bonn/pyBAR
pybar/analysis/plotting/plotting.py
plot_linear_relation
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 (x,y) with errors(x,y) and fits a straight line. The deviation ...
python
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 (x,y) with errors(x,y) and fits a straight line. The deviation ...
[ "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", "=", ...
Takes point data (x,y) with errors(x,y) and fits a straight line. The deviation to this line is also plotted, showing the offset. Parameters ---------- x, y, x_err, y_err: iterable filename: string, PdfPages object or None PdfPages file object: plot is appended to the pdf stri...
[ "Takes", "point", "data", "(", "x", "y", ")", "with", "errors", "(", "x", "y", ")", "and", "fits", "a", "straight", "line", ".", "The", "deviation", "to", "this", "line", "is", "also", "plotted", "showing", "the", "offset", ".", "Parameters", "--------...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/plotting/plotting.py#L52-L121
train
SiLab-Bonn/pyBAR
pybar/analysis/plotting/plotting.py
plot_profile_histogram
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. ...
python
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. ...
[ "def", "plot_profile_histogram", "(", "x", ",", "y", ",", "n_bins", "=", "100", ",", "title", "=", "None", ",", "x_label", "=", "None", ",", "y_label", "=", "None", ",", "log_y", "=", "False", ",", "filename", "=", "None", ")", ":", "if", "len", "(...
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 y : array like data y positions...
[ "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"...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/plotting/plotting.py#L241-L284
train
SiLab-Bonn/pyBAR
pybar/analysis/plotting/plotting.py
round_to_multiple
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 int. Must not be equal zero. Returns ...
python
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 int. Must not be equal zero. Returns ...
[ "def", "round_to_multiple", "(", "number", ",", "multiple", ")", ":", "multiple", "=", "int", "(", "multiple", ")", "if", "multiple", "==", "0", ":", "multiple", "=", "1", "ceil_mod_number", "=", "number", "-", "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 int. Must not be equal zero. Returns ------- ceil_mod_number : int Rou...
[ "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...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/plotting/plotting.py#L352-L374
train
SiLab-Bonn/pyBAR
pybar/analysis/plotting/plotting.py
hist_quantiles
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 ...
python
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 ...
[ "def", "hist_quantiles", "(", "hist", ",", "prob", "=", "(", "0.05", ",", "0.95", ")", ",", "return_indices", "=", "False", ",", "copy", "=", "True", ")", ":", "# make np array\r", "hist_t", "=", "np", ".", "array", "(", "hist", ")", "# calculate cumulat...
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 with dimension at most 1. prob : float, list, tuple List of quantiles to...
[ "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", ":", ...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/plotting/plotting.py#L831-L879
train
SiLab-Bonn/pyBAR
pybar/analysis/plotting/plotting.py
hist_last_nonzero
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. ...
python
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. ...
[ "def", "hist_last_nonzero", "(", "hist", ",", "return_index", "=", "False", ",", "copy", "=", "True", ")", ":", "# make np array\r", "hist_t", "=", "np", ".", "array", "(", "hist", ")", "index", "=", "(", "np", ".", "where", "(", "hist_t", ")", "[", ...
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. copy : bool, optional Whether to copy the input data (Tru...
[ "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", "op...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/plotting/plotting.py#L882-L910
train
SiLab-Bonn/pyBAR
pybar/daq/fifo_readout.py
FifoReadout.readout
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). ''' logging.info('Starting readout thread for %s', fifo) time_last...
python
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). ''' logging.info('Starting readout thread for %s', fifo) time_last...
[ "def", "readout", "(", "self", ",", "fifo", ",", "no_data_timeout", "=", "None", ")", ":", "logging", ".", "info", "(", "'Starting readout thread for %s'", ",", "fifo", ")", "time_last_data", "=", "time", "(", ")", "time_wait", "=", "0.0", "empty_reads", "="...
Readout thread continuously reading FIFO. Readout thread, which uses read_raw_data_from_fifo() and appends data to self._fifo_data_deque (collection.deque).
[ "Readout", "thread", "continuously", "reading", "FIFO", ".", "Readout", "thread", "which", "uses", "read_raw_data_from_fifo", "()", "and", "appends", "data", "to", "self", ".", "_fifo_data_deque", "(", "collection", ".", "deque", ")", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/fifo_readout.py#L270-L320
train
SiLab-Bonn/pyBAR
pybar/daq/fifo_readout.py
FifoReadout.worker
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() while True: try: data_tuple = self._f...
python
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() while True: try: data_tuple = self._f...
[ "def", "worker", "(", "self", ",", "fifo", ")", ":", "logging", ".", "debug", "(", "'Starting worker thread for %s'", ",", "fifo", ")", "self", ".", "_fifo_conditions", "[", "fifo", "]", ".", "acquire", "(", ")", "while", "True", ":", "try", ":", "data_t...
Worker thread continuously filtering and converting data when data becomes available.
[ "Worker", "thread", "continuously", "filtering", "and", "converting", "data", "when", "data", "becomes", "available", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/fifo_readout.py#L322-L352
train
SiLab-Bonn/pyBAR
pybar/daq/fifo_readout.py
FifoReadout.writer
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...
python
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...
[ "def", "writer", "(", "self", ",", "index", ",", "no_data_timeout", "=", "None", ")", ":", "is_fe_data_header", "=", "logical_and", "(", "is_fe_word", ",", "is_data_header", ")", "logging", ".", "debug", "(", "'Starting writer thread with index %d'", ",", "index",...
Writer thread continuously calling callback function for writing data when data becomes available.
[ "Writer", "thread", "continuously", "calling", "callback", "function", "for", "writing", "data", "when", "data", "becomes", "available", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/fifo_readout.py#L354-L403
train
SiLab-Bonn/pyBAR
pybar/daq/fifo_readout.py
FifoReadout.get_data_from_buffer
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. ''' if self._is_running: raise RuntimeErr...
python
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. ''' if self._is_running: raise RuntimeErr...
[ "def", "get_data_from_buffer", "(", "self", ",", "filter_func", "=", "None", ",", "converter_func", "=", "None", ")", ":", "if", "self", ".", "_is_running", ":", "raise", "RuntimeError", "(", "'Readout thread running'", ")", "if", "not", "self", ".", "fill_buf...
Reads local data buffer and returns data and meta data list. Returns ------- data : list List of data and meta data dicts.
[ "Reads", "local", "data", "buffer", "and", "returns", "data", "and", "meta", "data", "list", ".", "Returns", "-------", "data", ":", "list", "List", "of", "data", "and", "meta", "data", "dicts", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/fifo_readout.py#L425-L437
train
SiLab-Bonn/pyBAR
pybar/daq/fifo_readout.py
FifoReadout.get_raw_data_from_buffer
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: ...
python
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: ...
[ "def", "get_raw_data_from_buffer", "(", "self", ",", "filter_func", "=", "None", ",", "converter_func", "=", "None", ")", ":", "if", "self", ".", "_is_running", ":", "raise", "RuntimeError", "(", "'Readout thread running'", ")", "if", "not", "self", ".", "fill...
Reads local data buffer and returns raw data array. Returns ------- data : np.array An array containing data words from the local data buffer.
[ "Reads", "local", "data", "buffer", "and", "returns", "raw", "data", "array", ".", "Returns", "-------", "data", ":", "np", ".", "array", "An", "array", "containing", "data", "words", "from", "the", "local", "data", "buffer", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/fifo_readout.py#L439-L451
train
SiLab-Bonn/pyBAR
pybar/daq/fifo_readout.py
FifoReadout.read_raw_data_from_fifo
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. ''' return convert_data_array(self.dut[fifo].get_data()...
python
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. ''' return convert_data_array(self.dut[fifo].get_data()...
[ "def", "read_raw_data_from_fifo", "(", "self", ",", "fifo", ",", "filter_func", "=", "None", ",", "converter_func", "=", "None", ")", ":", "return", "convert_data_array", "(", "self", ".", "dut", "[", "fifo", "]", ".", "get_data", "(", ")", ",", "filter_fu...
Reads FIFO data and returns raw data array. Returns ------- data : np.array An array containing FIFO data words.
[ "Reads", "FIFO", "data", "and", "returns", "raw", "data", "array", ".", "Returns", "-------", "data", ":", "np", ".", "array", "An", "array", "containing", "FIFO", "data", "words", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/fifo_readout.py#L453-L461
train
SiLab-Bonn/pyBAR
pybar/utils/utils.py
get_item_from_queue
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...
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...
[ "def", "get_item_from_queue", "(", "Q", ",", "timeout", "=", "0.01", ")", ":", "try", ":", "item", "=", "Q", ".", "get", "(", "True", ",", "0.01", ")", "except", "Queue", ".", "Empty", ":", "return", "None", "return", "item" ]
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 that).
[ "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", ...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/utils/utils.py#L38-L51
train
SiLab-Bonn/pyBAR
pybar/utils/utils.py
argmin_list
def argmin_list(seq, func): """ Return a list of elements of seq[i] with the lowest func(seq[i]) scores. >>> argmin_list(['one', 'to', 'three', 'or'], len) ['to', 'or'] """ best_score, best = func(seq[0]), [] for x in seq: x_score = func(x) if x_score < b...
python
def argmin_list(seq, func): """ Return a list of elements of seq[i] with the lowest func(seq[i]) scores. >>> argmin_list(['one', 'to', 'three', 'or'], len) ['to', 'or'] """ best_score, best = func(seq[0]), [] for x in seq: x_score = func(x) if x_score < b...
[ "def", "argmin_list", "(", "seq", ",", "func", ")", ":", "best_score", ",", "best", "=", "func", "(", "seq", "[", "0", "]", ")", ",", "[", "]", "for", "x", "in", "seq", ":", "x_score", "=", "func", "(", "x", ")", "if", "x_score", "<", "best_sco...
Return a list of elements of seq[i] with the lowest func(seq[i]) scores. >>> argmin_list(['one', 'to', 'three', 'or'], len) ['to', 'or']
[ "Return", "a", "list", "of", "elements", "of", "seq", "[", "i", "]", "with", "the", "lowest", "func", "(", "seq", "[", "i", "]", ")", "scores", ".", ">>>", "argmin_list", "(", "[", "one", "to", "three", "or", "]", "len", ")", "[", "to", "or", "...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/utils/utils.py#L62-L75
train
SiLab-Bonn/pyBAR
pybar/utils/utils.py
flatten_iterable
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): ...
python
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): ...
[ "def", "flatten_iterable", "(", "iterable", ")", ":", "for", "item", "in", "iterable", ":", "if", "isinstance", "(", "item", ",", "collections", ".", "Iterable", ")", "and", "not", "isinstance", "(", "item", ",", "basestring", ")", ":", "for", "sub", "in...
flatten iterable, but leaves out strings [[[1, 2, 3], [4, 5]], 6] -> [1, 2, 3, 4, 5, 6]
[ "flatten", "iterable", "but", "leaves", "out", "strings", "[[[", "1", "2", "3", "]", "[", "4", "5", "]]", "6", "]", "-", ">", "[", "1", "2", "3", "4", "5", "6", "]" ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/utils/utils.py#L198-L209
train
SiLab-Bonn/pyBAR
pybar/utils/utils.py
iterable
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]
python
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]
[ "def", "iterable", "(", "item", ")", ":", "if", "isinstance", "(", "item", ",", "collections", ".", "Iterable", ")", "and", "not", "isinstance", "(", "item", ",", "basestring", ")", ":", "return", "item", "else", ":", "return", "[", "item", "]" ]
generate iterable from item, but leaves out strings
[ "generate", "iterable", "from", "item", "but", "leaves", "out", "strings" ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/utils/utils.py#L212-L219
train
SiLab-Bonn/pyBAR
pybar/utils/utils.py
natsorted
def natsorted(seq, cmp=natcmp): "Returns a copy of seq, sorted by natural string sort." import copy temp = copy.copy(seq) natsort(temp, cmp) return temp
python
def natsorted(seq, cmp=natcmp): "Returns a copy of seq, sorted by natural string sort." import copy temp = copy.copy(seq) natsort(temp, cmp) return temp
[ "def", "natsorted", "(", "seq", ",", "cmp", "=", "natcmp", ")", ":", "import", "copy", "temp", "=", "copy", ".", "copy", "(", "seq", ")", "natsort", "(", "temp", ",", "cmp", ")", "return", "temp" ]
Returns a copy of seq, sorted by natural string sort.
[ "Returns", "a", "copy", "of", "seq", "sorted", "by", "natural", "string", "sort", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/utils/utils.py#L258-L263
train
SiLab-Bonn/pyBAR
pybar/utils/utils.py
get_iso_time
def get_iso_time(): '''returns time as ISO string, mapping to and from datetime in ugly way convert to string with str() ''' t1 = time.time() t2 = datetime.datetime.fromtimestamp(t1) t4 = t2.__str__() try: t4a, t4b = t4.split(".", 1) except ValueError: t4a = t...
python
def get_iso_time(): '''returns time as ISO string, mapping to and from datetime in ugly way convert to string with str() ''' t1 = time.time() t2 = datetime.datetime.fromtimestamp(t1) t4 = t2.__str__() try: t4a, t4b = t4.split(".", 1) except ValueError: t4a = t...
[ "def", "get_iso_time", "(", ")", ":", "t1", "=", "time", ".", "time", "(", ")", "t2", "=", "datetime", ".", "datetime", ".", "fromtimestamp", "(", "t1", ")", "t4", "=", "t2", ".", "__str__", "(", ")", "try", ":", "t4a", ",", "t4b", "=", "t4", "...
returns time as ISO string, mapping to and from datetime in ugly way convert to string with str()
[ "returns", "time", "as", "ISO", "string", "mapping", "to", "and", "from", "datetime", "in", "ugly", "way", "convert", "to", "string", "with", "str", "()" ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/utils/utils.py#L267-L282
train
SiLab-Bonn/pyBAR
pybar/utils/utils.py
get_float_time
def get_float_time(): '''returns time as double precision floats - Time64 in pytables - mapping to and from python datetime's ''' t1 = time.time() t2 = datetime.datetime.fromtimestamp(t1) return time.mktime(t2.timetuple()) + 1e-6 * t2.microsecond
python
def get_float_time(): '''returns time as double precision floats - Time64 in pytables - mapping to and from python datetime's ''' t1 = time.time() t2 = datetime.datetime.fromtimestamp(t1) return time.mktime(t2.timetuple()) + 1e-6 * t2.microsecond
[ "def", "get_float_time", "(", ")", ":", "t1", "=", "time", ".", "time", "(", ")", "t2", "=", "datetime", ".", "datetime", ".", "fromtimestamp", "(", "t1", ")", "return", "time", ".", "mktime", "(", "t2", ".", "timetuple", "(", ")", ")", "+", "1e-6"...
returns time as double precision floats - Time64 in pytables - mapping to and from python datetime's
[ "returns", "time", "as", "double", "precision", "floats", "-", "Time64", "in", "pytables", "-", "mapping", "to", "and", "from", "python", "datetime", "s" ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/utils/utils.py#L285-L291
train
SiLab-Bonn/pyBAR
pybar/utils/utils.py
groupby_dict
def groupby_dict(dictionary, key): ''' Group dict of dicts by key. ''' return dict((k, list(g)) for k, g in itertools.groupby(sorted(dictionary.keys(), key=lambda name: dictionary[name][key]), key=lambda name: dictionary[name][key]))
python
def groupby_dict(dictionary, key): ''' Group dict of dicts by key. ''' return dict((k, list(g)) for k, g in itertools.groupby(sorted(dictionary.keys(), key=lambda name: dictionary[name][key]), key=lambda name: dictionary[name][key]))
[ "def", "groupby_dict", "(", "dictionary", ",", "key", ")", ":", "return", "dict", "(", "(", "k", ",", "list", "(", "g", ")", ")", "for", "k", ",", "g", "in", "itertools", ".", "groupby", "(", "sorted", "(", "dictionary", ".", "keys", "(", ")", ",...
Group dict of dicts by key.
[ "Group", "dict", "of", "dicts", "by", "key", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/utils/utils.py#L313-L316
train
SiLab-Bonn/pyBAR
pybar/utils/utils.py
zip_nofill
def zip_nofill(*iterables): '''Zipping iterables without fillvalue. Note: https://stackoverflow.com/questions/38054593/zip-longest-without-fillvalue ''' return (tuple([entry for entry in iterable if entry is not None]) for iterable in itertools.izip_longest(*iterables, fillvalue=None))
python
def zip_nofill(*iterables): '''Zipping iterables without fillvalue. Note: https://stackoverflow.com/questions/38054593/zip-longest-without-fillvalue ''' return (tuple([entry for entry in iterable if entry is not None]) for iterable in itertools.izip_longest(*iterables, fillvalue=None))
[ "def", "zip_nofill", "(", "*", "iterables", ")", ":", "return", "(", "tuple", "(", "[", "entry", "for", "entry", "in", "iterable", "if", "entry", "is", "not", "None", "]", ")", "for", "iterable", "in", "itertools", ".", "izip_longest", "(", "*", "itera...
Zipping iterables without fillvalue. Note: https://stackoverflow.com/questions/38054593/zip-longest-without-fillvalue
[ "Zipping", "iterables", "without", "fillvalue", ".", "Note", ":", "https", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "38054593", "/", "zip", "-", "longest", "-", "without", "-", "fillvalue" ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/utils/utils.py#L334-L339
train
SiLab-Bonn/pyBAR
pybar/utils/utils.py
find_file_dir_up
def find_file_dir_up(filename, path=None, n=None): '''Finding file in directory upwards. ''' if path is None: path = os.getcwd() i = 0 while True: current_path = path for _ in range(i): current_path = os.path.split(current_path)[0] if os.path.isf...
python
def find_file_dir_up(filename, path=None, n=None): '''Finding file in directory upwards. ''' if path is None: path = os.getcwd() i = 0 while True: current_path = path for _ in range(i): current_path = os.path.split(current_path)[0] if os.path.isf...
[ "def", "find_file_dir_up", "(", "filename", ",", "path", "=", "None", ",", "n", "=", "None", ")", ":", "if", "path", "is", "None", ":", "path", "=", "os", ".", "getcwd", "(", ")", "i", "=", "0", "while", "True", ":", "current_path", "=", "path", ...
Finding file in directory upwards.
[ "Finding", "file", "in", "directory", "upwards", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/utils/utils.py#L342-L360
train
SiLab-Bonn/pyBAR
pybar/fei4/register.py
load_configuration_from_text_file
def load_configuration_from_text_file(register, configuration_file): '''Loading configuration from text files to register object Parameters ---------- register : pybar.fei4.register object configuration_file : string Full path (directory and filename) of the configuration file. If na...
python
def load_configuration_from_text_file(register, configuration_file): '''Loading configuration from text files to register object Parameters ---------- register : pybar.fei4.register object configuration_file : string Full path (directory and filename) of the configuration file. If na...
[ "def", "load_configuration_from_text_file", "(", "register", ",", "configuration_file", ")", ":", "logging", ".", "info", "(", "\"Loading configuration: %s\"", "%", "configuration_file", ")", "register", ".", "configuration_file", "=", "configuration_file", "config_dict", ...
Loading configuration from text files to register object Parameters ---------- register : pybar.fei4.register object configuration_file : string Full path (directory and filename) of the configuration file. If name is not given, reload configuration from file.
[ "Loading", "configuration", "from", "text", "files", "to", "register", "object", "Parameters", "----------", "register", ":", "pybar", ".", "fei4", ".", "register", "object", "configuration_file", ":", "string", "Full", "path", "(", "directory", "and", "filename",...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register.py#L715-L781
train
SiLab-Bonn/pyBAR
pybar/fei4/register.py
load_configuration_from_hdf5
def load_configuration_from_hdf5(register, configuration_file, node=''): '''Loading configuration from HDF5 file to register object Parameters ---------- register : pybar.fei4.register object configuration_file : string, file Filename of the HDF5 configuration file or file object. ...
python
def load_configuration_from_hdf5(register, configuration_file, node=''): '''Loading configuration from HDF5 file to register object Parameters ---------- register : pybar.fei4.register object configuration_file : string, file Filename of the HDF5 configuration file or file object. ...
[ "def", "load_configuration_from_hdf5", "(", "register", ",", "configuration_file", ",", "node", "=", "''", ")", ":", "def", "load_conf", "(", ")", ":", "logging", ".", "info", "(", "\"Loading configuration: %s\"", "%", "h5_file", ".", "filename", ")", "register"...
Loading configuration from HDF5 file to register object Parameters ---------- register : pybar.fei4.register object configuration_file : string, file Filename of the HDF5 configuration file or file object. node : string Additional identifier (subgroup). Useful when more than...
[ "Loading", "configuration", "from", "HDF5", "file", "to", "register", "object", "Parameters", "----------", "register", ":", "pybar", ".", "fei4", ".", "register", "object", "configuration_file", ":", "string", "file", "Filename", "of", "the", "HDF5", "configurati...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register.py#L784-L860
train
SiLab-Bonn/pyBAR
pybar/fei4/register.py
save_configuration_to_text_file
def save_configuration_to_text_file(register, configuration_file): '''Saving configuration to text files from register object Parameters ---------- register : pybar.fei4.register object configuration_file : string Filename of the configuration file. ''' configuration_path, ...
python
def save_configuration_to_text_file(register, configuration_file): '''Saving configuration to text files from register object Parameters ---------- register : pybar.fei4.register object configuration_file : string Filename of the configuration file. ''' configuration_path, ...
[ "def", "save_configuration_to_text_file", "(", "register", ",", "configuration_file", ")", ":", "configuration_path", ",", "filename", "=", "os", ".", "path", ".", "split", "(", "configuration_file", ")", "if", "os", ".", "path", ".", "split", "(", "configuratio...
Saving configuration to text files from register object Parameters ---------- register : pybar.fei4.register object configuration_file : string Filename of the configuration file.
[ "Saving", "configuration", "to", "text", "files", "from", "register", "object", "Parameters", "----------", "register", ":", "pybar", ".", "fei4", ".", "register", "object", "configuration_file", ":", "string", "Filename", "of", "the", "configuration", "file", "."...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register.py#L863-L930
train
SiLab-Bonn/pyBAR
pybar/fei4/register.py
save_configuration_to_hdf5
def save_configuration_to_hdf5(register, configuration_file, name=''): '''Saving configuration to HDF5 file from register object Parameters ---------- register : pybar.fei4.register object configuration_file : string, file Filename of the HDF5 configuration file or file object. ...
python
def save_configuration_to_hdf5(register, configuration_file, name=''): '''Saving configuration to HDF5 file from register object Parameters ---------- register : pybar.fei4.register object configuration_file : string, file Filename of the HDF5 configuration file or file object. ...
[ "def", "save_configuration_to_hdf5", "(", "register", ",", "configuration_file", ",", "name", "=", "''", ")", ":", "def", "save_conf", "(", ")", ":", "logging", ".", "info", "(", "\"Saving configuration: %s\"", "%", "h5_file", ".", "filename", ")", "register", ...
Saving configuration to HDF5 file from register object Parameters ---------- register : pybar.fei4.register object configuration_file : string, file Filename of the HDF5 configuration file or file object. name : string Additional identifier (subgroup). Useful when storing mo...
[ "Saving", "configuration", "to", "HDF5", "file", "from", "register", "object", "Parameters", "----------", "register", ":", "pybar", ".", "fei4", ".", "register", "object", "configuration_file", ":", "string", "file", "Filename", "of", "the", "HDF5", "configuratio...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register.py#L933-L1019
train
SiLab-Bonn/pyBAR
pybar/fei4/register.py
FEI4Register.load_configuration
def load_configuration(self, configuration_file): '''Loading configuration Parameters ---------- configuration_file : string Path to the configuration file (text or HDF5 file). ''' if os.path.isfile(configuration_file): if not isinstance(...
python
def load_configuration(self, configuration_file): '''Loading configuration Parameters ---------- configuration_file : string Path to the configuration file (text or HDF5 file). ''' if os.path.isfile(configuration_file): if not isinstance(...
[ "def", "load_configuration", "(", "self", ",", "configuration_file", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "configuration_file", ")", ":", "if", "not", "isinstance", "(", "configuration_file", ",", "tb", ".", "file", ".", "File", ")", "and...
Loading configuration Parameters ---------- configuration_file : string Path to the configuration file (text or HDF5 file).
[ "Loading", "configuration", "Parameters", "----------", "configuration_file", ":", "string", "Path", "to", "the", "configuration", "file", "(", "text", "or", "HDF5", "file", ")", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register.py#L135-L149
train
SiLab-Bonn/pyBAR
pybar/fei4/register.py
FEI4Register.save_configuration
def save_configuration(self, configuration_file): '''Saving configuration Parameters ---------- configuration_file : string Filename of the configuration file. ''' if not isinstance(configuration_file, tb.file.File) and os.path.splitext(configuration_...
python
def save_configuration(self, configuration_file): '''Saving configuration Parameters ---------- configuration_file : string Filename of the configuration file. ''' if not isinstance(configuration_file, tb.file.File) and os.path.splitext(configuration_...
[ "def", "save_configuration", "(", "self", ",", "configuration_file", ")", ":", "if", "not", "isinstance", "(", "configuration_file", ",", "tb", ".", "file", ".", "File", ")", "and", "os", ".", "path", ".", "splitext", "(", "configuration_file", ")", "[", "...
Saving configuration Parameters ---------- configuration_file : string Filename of the configuration file.
[ "Saving", "configuration", "Parameters", "----------", "configuration_file", ":", "string", "Filename", "of", "the", "configuration", "file", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register.py#L151-L162
train
SiLab-Bonn/pyBAR
pybar/fei4/register.py
FEI4Register.get_commands
def get_commands(self, command_name, **kwargs): """get fe_command from command name and keyword arguments wrapper for build_commands() implements FEI4 specific behavior """ chip_id = kwargs.pop("ChipID", self.chip_id_bitarray) commands = [] if command_n...
python
def get_commands(self, command_name, **kwargs): """get fe_command from command name and keyword arguments wrapper for build_commands() implements FEI4 specific behavior """ chip_id = kwargs.pop("ChipID", self.chip_id_bitarray) commands = [] if command_n...
[ "def", "get_commands", "(", "self", ",", "command_name", ",", "*", "*", "kwargs", ")", ":", "chip_id", "=", "kwargs", ".", "pop", "(", "\"ChipID\"", ",", "self", ".", "chip_id_bitarray", ")", "commands", "=", "[", "]", "if", "command_name", "==", "\"zero...
get fe_command from command name and keyword arguments wrapper for build_commands() implements FEI4 specific behavior
[ "get", "fe_command", "from", "command", "name", "and", "keyword", "arguments", "wrapper", "for", "build_commands", "()", "implements", "FEI4", "specific", "behavior" ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register.py#L205-L410
train
SiLab-Bonn/pyBAR
pybar/fei4/register.py
FEI4Register.build_command
def build_command(self, command_name, **kwargs): """build command from command_name and keyword values Returns ------- command_bitvector : list List of bitarrays. Usage ----- Receives: command name as defined inside xml file, key-value-pair...
python
def build_command(self, command_name, **kwargs): """build command from command_name and keyword values Returns ------- command_bitvector : list List of bitarrays. Usage ----- Receives: command name as defined inside xml file, key-value-pair...
[ "def", "build_command", "(", "self", ",", "command_name", ",", "*", "*", "kwargs", ")", ":", "# command_name = command_name.lower()\r", "command_bitvector", "=", "bitarray", "(", "0", ",", "endian", "=", "'little'", ")", "if", "command_name", "not", "in", ...
build command from command_name and keyword values Returns ------- command_bitvector : list List of bitarrays. Usage ----- Receives: command name as defined inside xml file, key-value-pairs as defined inside bit stream filed for each command
[ "build", "command", "from", "command_name", "and", "keyword", "values", "Returns", "-------", "command_bitvector", ":", "list", "List", "of", "bitarrays", ".", "Usage", "-----", "Receives", ":", "command", "name", "as", "defined", "inside", "xml", "file", "key",...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register.py#L412-L465
train
SiLab-Bonn/pyBAR
pybar/fei4/register.py
FEI4Register.get_global_register_attributes
def get_global_register_attributes(self, register_attribute, do_sort=True, **kwargs): """Calculating register numbers from register names. Usage: get_global_register_attributes("attribute_name", name = [regname_1, regname_2, ...], addresses = 2) Receives: attribute name to be returned, dict...
python
def get_global_register_attributes(self, register_attribute, do_sort=True, **kwargs): """Calculating register numbers from register names. Usage: get_global_register_attributes("attribute_name", name = [regname_1, regname_2, ...], addresses = 2) Receives: attribute name to be returned, dict...
[ "def", "get_global_register_attributes", "(", "self", ",", "register_attribute", ",", "do_sort", "=", "True", ",", "*", "*", "kwargs", ")", ":", "# speed up of the most often used keyword name\r", "try", ":", "names", "=", "iterable", "(", "kwargs", ".", "pop", "(...
Calculating register numbers from register names. Usage: get_global_register_attributes("attribute_name", name = [regname_1, regname_2, ...], addresses = 2) Receives: attribute name to be returned, dictionaries (kwargs) of register attributes and values for making cuts Returns: list of attr...
[ "Calculating", "register", "numbers", "from", "register", "names", ".", "Usage", ":", "get_global_register_attributes", "(", "attribute_name", "name", "=", "[", "regname_1", "regname_2", "...", "]", "addresses", "=", "2", ")", "Receives", ":", "attribute", "name",...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register.py#L467-L493
train
SiLab-Bonn/pyBAR
pybar/fei4/register.py
FEI4Register.get_global_register_objects
def get_global_register_objects(self, do_sort=None, reverse=False, **kwargs): """Generate register objects (list) from register name list Usage: get_global_register_objects(name = ["Amp2Vbn", "GateHitOr", "DisableColumnCnfg"], address = [2, 3]) Receives: keyword lists of register names, add...
python
def get_global_register_objects(self, do_sort=None, reverse=False, **kwargs): """Generate register objects (list) from register name list Usage: get_global_register_objects(name = ["Amp2Vbn", "GateHitOr", "DisableColumnCnfg"], address = [2, 3]) Receives: keyword lists of register names, add...
[ "def", "get_global_register_objects", "(", "self", ",", "do_sort", "=", "None", ",", "reverse", "=", "False", ",", "*", "*", "kwargs", ")", ":", "# speed up of the most often used keyword name\r", "try", ":", "names", "=", "iterable", "(", "kwargs", ".", "pop", ...
Generate register objects (list) from register name list Usage: get_global_register_objects(name = ["Amp2Vbn", "GateHitOr", "DisableColumnCnfg"], address = [2, 3]) Receives: keyword lists of register names, addresses,... for making cuts Returns: list of register objects
[ "Generate", "register", "objects", "(", "list", ")", "from", "register", "name", "list", "Usage", ":", "get_global_register_objects", "(", "name", "=", "[", "Amp2Vbn", "GateHitOr", "DisableColumnCnfg", "]", "address", "=", "[", "2", "3", "]", ")", "Receives", ...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register.py#L495-L518
train
SiLab-Bonn/pyBAR
pybar/fei4/register.py
FEI4Register.get_global_register_bitsets
def get_global_register_bitsets(self, register_addresses): # TOTO: add sorting """Calculating register bitsets from register addresses. Usage: get_global_register_bitsets([regaddress_1, regaddress_2, ...]) Receives: list of register addresses Returns: list of register bitsets ...
python
def get_global_register_bitsets(self, register_addresses): # TOTO: add sorting """Calculating register bitsets from register addresses. Usage: get_global_register_bitsets([regaddress_1, regaddress_2, ...]) Receives: list of register addresses Returns: list of register bitsets ...
[ "def", "get_global_register_bitsets", "(", "self", ",", "register_addresses", ")", ":", "# TOTO: add sorting\r", "register_bitsets", "=", "[", "]", "for", "register_address", "in", "register_addresses", ":", "register_objects", "=", "self", ".", "get_global_register_objec...
Calculating register bitsets from register addresses. Usage: get_global_register_bitsets([regaddress_1, regaddress_2, ...]) Receives: list of register addresses Returns: list of register bitsets
[ "Calculating", "register", "bitsets", "from", "register", "addresses", ".", "Usage", ":", "get_global_register_bitsets", "(", "[", "regaddress_1", "regaddress_2", "...", "]", ")", "Receives", ":", "list", "of", "register", "addresses", "Returns", ":", "list", "of"...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register.py#L520-L548
train
SiLab-Bonn/pyBAR
pybar/fei4/register.py
FEI4Register.get_pixel_register_objects
def get_pixel_register_objects(self, do_sort=None, reverse=False, **kwargs): """Generate register objects (list) from register name list Usage: get_pixel_register_objects(name = ["TDAC", "FDAC"]) Receives: keyword lists of register names, addresses,... Returns: list of register obj...
python
def get_pixel_register_objects(self, do_sort=None, reverse=False, **kwargs): """Generate register objects (list) from register name list Usage: get_pixel_register_objects(name = ["TDAC", "FDAC"]) Receives: keyword lists of register names, addresses,... Returns: list of register obj...
[ "def", "get_pixel_register_objects", "(", "self", ",", "do_sort", "=", "None", ",", "reverse", "=", "False", ",", "*", "*", "kwargs", ")", ":", "# speed up of the most often used keyword name\r", "try", ":", "names", "=", "iterable", "(", "kwargs", ".", "pop", ...
Generate register objects (list) from register name list Usage: get_pixel_register_objects(name = ["TDAC", "FDAC"]) Receives: keyword lists of register names, addresses,... Returns: list of register objects
[ "Generate", "register", "objects", "(", "list", ")", "from", "register", "name", "list", "Usage", ":", "get_pixel_register_objects", "(", "name", "=", "[", "TDAC", "FDAC", "]", ")", "Receives", ":", "keyword", "lists", "of", "register", "names", "addresses", ...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register.py#L550-L573
train
SiLab-Bonn/pyBAR
pybar/fei4/register.py
FEI4Register.get_pixel_register_bitset
def get_pixel_register_bitset(self, register_object, bit_no, dc_no): """Calculating pixel register bitsets from pixel register addresses. Usage: get_pixel_register_bitset(object, bit_number, double_column_number) Receives: register object, bit number, double column number Returns: ...
python
def get_pixel_register_bitset(self, register_object, bit_no, dc_no): """Calculating pixel register bitsets from pixel register addresses. Usage: get_pixel_register_bitset(object, bit_number, double_column_number) Receives: register object, bit number, double column number Returns: ...
[ "def", "get_pixel_register_bitset", "(", "self", ",", "register_object", ",", "bit_no", ",", "dc_no", ")", ":", "if", "not", "0", "<=", "dc_no", "<", "40", ":", "raise", "ValueError", "(", "\"Pixel register %s: DC out of range\"", "%", "register_object", "[", "'...
Calculating pixel register bitsets from pixel register addresses. Usage: get_pixel_register_bitset(object, bit_number, double_column_number) Receives: register object, bit number, double column number Returns: double column bitset
[ "Calculating", "pixel", "register", "bitsets", "from", "pixel", "register", "addresses", ".", "Usage", ":", "get_pixel_register_bitset", "(", "object", "bit_number", "double_column_number", ")", "Receives", ":", "register", "object", "bit", "number", "double", "column...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register.py#L575-L597
train
SiLab-Bonn/pyBAR
pybar/fei4/register.py
FEI4Register.create_restore_point
def create_restore_point(self, name=None): '''Creating a configuration restore point. Parameters ---------- name : str Name of the restore point. If not given, a md5 hash will be generated. ''' if name is None: for i in iter(int, 1): ...
python
def create_restore_point(self, name=None): '''Creating a configuration restore point. Parameters ---------- name : str Name of the restore point. If not given, a md5 hash will be generated. ''' if name is None: for i in iter(int, 1): ...
[ "def", "create_restore_point", "(", "self", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "for", "i", "in", "iter", "(", "int", ",", "1", ")", ":", "name", "=", "datetime", ".", "datetime", ".", "utcnow", "(", ")", ".", "st...
Creating a configuration restore point. Parameters ---------- name : str Name of the restore point. If not given, a md5 hash will be generated.
[ "Creating", "a", "configuration", "restore", "point", ".", "Parameters", "----------", "name", ":", "str", "Name", "of", "the", "restore", "point", ".", "If", "not", "given", "a", "md5", "hash", "will", "be", "generated", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register.py#L607-L627
train
SiLab-Bonn/pyBAR
pybar/fei4/register.py
FEI4Register.restore
def restore(self, name=None, keep=False, last=True, global_register=True, pixel_register=True): '''Restoring a configuration restore point. Parameters ---------- name : str Name of the restore point. If not given, a md5 hash will be generated. keep : bool ...
python
def restore(self, name=None, keep=False, last=True, global_register=True, pixel_register=True): '''Restoring a configuration restore point. Parameters ---------- name : str Name of the restore point. If not given, a md5 hash will be generated. keep : bool ...
[ "def", "restore", "(", "self", ",", "name", "=", "None", ",", "keep", "=", "False", ",", "last", "=", "True", ",", "global_register", "=", "True", ",", "pixel_register", "=", "True", ")", ":", "if", "name", "is", "None", ":", "if", "keep", ":", "na...
Restoring a configuration restore point. Parameters ---------- name : str Name of the restore point. If not given, a md5 hash will be generated. keep : bool Keeping restore point for later use. last : bool If name is not given, the la...
[ "Restoring", "a", "configuration", "restore", "point", ".", "Parameters", "----------", "name", ":", "str", "Name", "of", "the", "restore", "point", ".", "If", "not", "given", "a", "md5", "hash", "will", "be", "generated", ".", "keep", ":", "bool", "Keepin...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register.py#L629-L660
train
SiLab-Bonn/pyBAR
pybar/fei4/register.py
FEI4Register.clear_restore_points
def clear_restore_points(self, name=None): '''Deleting all/a configuration restore points/point. Parameters ---------- name : str Name of the restore point to be deleted. If not given, all restore points will be deleted. ''' if name is None: ...
python
def clear_restore_points(self, name=None): '''Deleting all/a configuration restore points/point. Parameters ---------- name : str Name of the restore point to be deleted. If not given, all restore points will be deleted. ''' if name is None: ...
[ "def", "clear_restore_points", "(", "self", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "self", ".", "config_state", ".", "clear", "(", ")", "else", ":", "del", "self", ".", "config_state", "[", "name", "]" ]
Deleting all/a configuration restore points/point. Parameters ---------- name : str Name of the restore point to be deleted. If not given, all restore points will be deleted.
[ "Deleting", "all", "/", "a", "configuration", "restore", "points", "/", "point", ".", "Parameters", "----------", "name", ":", "str", "Name", "of", "the", "restore", "point", "to", "be", "deleted", ".", "If", "not", "given", "all", "restore", "points", "wi...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/fei4/register.py#L662-L673
train
SiLab-Bonn/pyBAR
pybar/daq/readout_utils.py
save_configuration_dict
def save_configuration_dict(h5_file, configuation_name, configuration, **kwargs): '''Stores any configuration dictionary to HDF5 file. Parameters ---------- h5_file : string, file Filename of the HDF5 configuration file or file object. configuation_name : str Configuration n...
python
def save_configuration_dict(h5_file, configuation_name, configuration, **kwargs): '''Stores any configuration dictionary to HDF5 file. Parameters ---------- h5_file : string, file Filename of the HDF5 configuration file or file object. configuation_name : str Configuration n...
[ "def", "save_configuration_dict", "(", "h5_file", ",", "configuation_name", ",", "configuration", ",", "*", "*", "kwargs", ")", ":", "def", "save_conf", "(", ")", ":", "try", ":", "h5_file", ".", "remove_node", "(", "h5_file", ".", "root", ".", "configuratio...
Stores any configuration dictionary to HDF5 file. Parameters ---------- h5_file : string, file Filename of the HDF5 configuration file or file object. configuation_name : str Configuration name. Will be used for table name. configuration : dict Configuration diction...
[ "Stores", "any", "configuration", "dictionary", "to", "HDF5", "file", ".", "Parameters", "----------", "h5_file", ":", "string", "file", "Filename", "of", "the", "HDF5", "configuration", "file", "or", "file", "object", ".", "configuation_name", ":", "str", "Conf...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/readout_utils.py#L13-L49
train
SiLab-Bonn/pyBAR
pybar/daq/readout_utils.py
convert_data_array
def convert_data_array(array, filter_func=None, converter_func=None): # TODO: add copy parameter, otherwise in-place '''Filter and convert raw data numpy array (numpy.ndarray). Parameters ---------- array : numpy.array Raw data array. filter_func : function Function that ta...
python
def convert_data_array(array, filter_func=None, converter_func=None): # TODO: add copy parameter, otherwise in-place '''Filter and convert raw data numpy array (numpy.ndarray). Parameters ---------- array : numpy.array Raw data array. filter_func : function Function that ta...
[ "def", "convert_data_array", "(", "array", ",", "filter_func", "=", "None", ",", "converter_func", "=", "None", ")", ":", "# TODO: add copy parameter, otherwise in-place\r", "# if filter_func != None:\r", "# if not hasattr(filter_func, '__call__'):\r", "# ra...
Filter and convert raw data numpy array (numpy.ndarray). Parameters ---------- array : numpy.array Raw data array. filter_func : function Function that takes array and returns true or false for each item in array. converter_func : function Function that takes array ...
[ "Filter", "and", "convert", "raw", "data", "numpy", "array", "(", "numpy", ".", "ndarray", ")", ".", "Parameters", "----------", "array", ":", "numpy", ".", "array", "Raw", "data", "array", ".", "filter_func", ":", "function", "Function", "that", "takes", ...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/readout_utils.py#L52-L79
train
SiLab-Bonn/pyBAR
pybar/daq/readout_utils.py
convert_data_iterable
def convert_data_iterable(data_iterable, filter_func=None, converter_func=None): # TODO: add concatenate parameter '''Convert raw data in data iterable. Parameters ---------- data_iterable : iterable Iterable where each element is a tuple with following content: (raw data, timestamp_star...
python
def convert_data_iterable(data_iterable, filter_func=None, converter_func=None): # TODO: add concatenate parameter '''Convert raw data in data iterable. Parameters ---------- data_iterable : iterable Iterable where each element is a tuple with following content: (raw data, timestamp_star...
[ "def", "convert_data_iterable", "(", "data_iterable", ",", "filter_func", "=", "None", ",", "converter_func", "=", "None", ")", ":", "# TODO: add concatenate parameter\r", "data_list", "=", "[", "]", "for", "item", "in", "data_iterable", ":", "data_list", ".", "ap...
Convert raw data in data iterable. Parameters ---------- data_iterable : iterable Iterable where each element is a tuple with following content: (raw data, timestamp_start, timestamp_stop, status). filter_func : function Function that takes array and returns true or false for eac...
[ "Convert", "raw", "data", "in", "data", "iterable", ".", "Parameters", "----------", "data_iterable", ":", "iterable", "Iterable", "where", "each", "element", "is", "a", "tuple", "with", "following", "content", ":", "(", "raw", "data", "timestamp_start", "timest...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/readout_utils.py#L82-L102
train
SiLab-Bonn/pyBAR
pybar/daq/readout_utils.py
data_array_from_data_iterable
def data_array_from_data_iterable(data_iterable): '''Convert data iterable to raw data numpy array. Parameters ---------- data_iterable : iterable Iterable where each element is a tuple with following content: (raw data, timestamp_start, timestamp_stop, status). Returns ------...
python
def data_array_from_data_iterable(data_iterable): '''Convert data iterable to raw data numpy array. Parameters ---------- data_iterable : iterable Iterable where each element is a tuple with following content: (raw data, timestamp_start, timestamp_stop, status). Returns ------...
[ "def", "data_array_from_data_iterable", "(", "data_iterable", ")", ":", "try", ":", "data_array", "=", "np", ".", "concatenate", "(", "[", "item", "[", "0", "]", "for", "item", "in", "data_iterable", "]", ")", "except", "ValueError", ":", "# length is 0\r", ...
Convert data iterable to raw data numpy array. Parameters ---------- data_iterable : iterable Iterable where each element is a tuple with following content: (raw data, timestamp_start, timestamp_stop, status). Returns ------- data_array : numpy.array concatenated data...
[ "Convert", "data", "iterable", "to", "raw", "data", "numpy", "array", ".", "Parameters", "----------", "data_iterable", ":", "iterable", "Iterable", "where", "each", "element", "is", "a", "tuple", "with", "following", "content", ":", "(", "raw", "data", "times...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/readout_utils.py#L105-L122
train
SiLab-Bonn/pyBAR
pybar/daq/readout_utils.py
convert_tdc_to_channel
def convert_tdc_to_channel(channel): ''' Converts TDC words at a given channel to common TDC header (0x4). ''' def f(value): filter_func = logical_and(is_tdc_word, is_tdc_from_channel(channel)) select = filter_func(value) value[select] = np.bitwise_and(value[select], 0x0FFFFFFF...
python
def convert_tdc_to_channel(channel): ''' Converts TDC words at a given channel to common TDC header (0x4). ''' def f(value): filter_func = logical_and(is_tdc_word, is_tdc_from_channel(channel)) select = filter_func(value) value[select] = np.bitwise_and(value[select], 0x0FFFFFFF...
[ "def", "convert_tdc_to_channel", "(", "channel", ")", ":", "def", "f", "(", "value", ")", ":", "filter_func", "=", "logical_and", "(", "is_tdc_word", ",", "is_tdc_from_channel", "(", "channel", ")", ")", "select", "=", "filter_func", "(", "value", ")", "valu...
Converts TDC words at a given channel to common TDC header (0x4).
[ "Converts", "TDC", "words", "at", "a", "given", "channel", "to", "common", "TDC", "header", "(", "0x4", ")", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/readout_utils.py#L151-L161
train
SiLab-Bonn/pyBAR
pybar/daq/readout_utils.py
is_data_from_channel
def is_data_from_channel(channel=4): # function factory '''Selecting FE data from given channel. Parameters ---------- channel : int Channel number (4 is default channel on Single Chip Card). Returns ------- Function. Usage: 1 Selecting FE data from channel 4...
python
def is_data_from_channel(channel=4): # function factory '''Selecting FE data from given channel. Parameters ---------- channel : int Channel number (4 is default channel on Single Chip Card). Returns ------- Function. Usage: 1 Selecting FE data from channel 4...
[ "def", "is_data_from_channel", "(", "channel", "=", "4", ")", ":", "# function factory\r", "if", "channel", ">=", "0", "and", "channel", "<", "16", ":", "def", "f", "(", "value", ")", ":", "return", "np", ".", "equal", "(", "np", ".", "right_shift", "(...
Selecting FE data from given channel. Parameters ---------- channel : int Channel number (4 is default channel on Single Chip Card). Returns ------- Function. Usage: 1 Selecting FE data from channel 4 (combine with is_fe_word): filter_fe_data_from_channel_...
[ "Selecting", "FE", "data", "from", "given", "channel", ".", "Parameters", "----------", "channel", ":", "int", "Channel", "number", "(", "4", "is", "default", "channel", "on", "Single", "Chip", "Card", ")", ".", "Returns", "-------", "Function", ".", "Usage"...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/readout_utils.py#L164-L196
train
SiLab-Bonn/pyBAR
pybar/daq/readout_utils.py
logical_and
def logical_and(f1, f2): # function factory '''Logical and from functions. Parameters ---------- f1, f2 : function Function that takes array and returns true or false for each item in array. Returns ------- Function. Usage: filter_func=logical_and(is_data_rec...
python
def logical_and(f1, f2): # function factory '''Logical and from functions. Parameters ---------- f1, f2 : function Function that takes array and returns true or false for each item in array. Returns ------- Function. Usage: filter_func=logical_and(is_data_rec...
[ "def", "logical_and", "(", "f1", ",", "f2", ")", ":", "# function factory\r", "def", "f", "(", "value", ")", ":", "return", "np", ".", "logical_and", "(", "f1", "(", "value", ")", ",", "f2", "(", "value", ")", ")", "f", ".", "__name__", "=", "\"(\"...
Logical and from functions. Parameters ---------- f1, f2 : function Function that takes array and returns true or false for each item in array. Returns ------- Function. Usage: filter_func=logical_and(is_data_record, is_data_from_channel(4)) # new filter function ...
[ "Logical", "and", "from", "functions", ".", "Parameters", "----------", "f1", "f2", ":", "function", "Function", "that", "takes", "array", "and", "returns", "true", "or", "false", "for", "each", "item", "in", "array", ".", "Returns", "-------", "Function", "...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/readout_utils.py#L199-L218
train
SiLab-Bonn/pyBAR
pybar/daq/readout_utils.py
logical_or
def logical_or(f1, f2): # function factory '''Logical or from functions. Parameters ---------- f1, f2 : function Function that takes array and returns true or false for each item in array. Returns ------- Function. ''' def f(value): return np.logical_o...
python
def logical_or(f1, f2): # function factory '''Logical or from functions. Parameters ---------- f1, f2 : function Function that takes array and returns true or false for each item in array. Returns ------- Function. ''' def f(value): return np.logical_o...
[ "def", "logical_or", "(", "f1", ",", "f2", ")", ":", "# function factory\r", "def", "f", "(", "value", ")", ":", "return", "np", ".", "logical_or", "(", "f1", "(", "value", ")", ",", "f2", "(", "value", ")", ")", "f", ".", "__name__", "=", "\"(\"",...
Logical or from functions. Parameters ---------- f1, f2 : function Function that takes array and returns true or false for each item in array. Returns ------- Function.
[ "Logical", "or", "from", "functions", ".", "Parameters", "----------", "f1", "f2", ":", "function", "Function", "that", "takes", "array", "and", "returns", "true", "or", "false", "for", "each", "item", "in", "array", ".", "Returns", "-------", "Function", "....
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/readout_utils.py#L221-L236
train
SiLab-Bonn/pyBAR
pybar/daq/readout_utils.py
logical_not
def logical_not(f): # function factory '''Logical not from functions. Parameters ---------- f1, f2 : function Function that takes array and returns true or false for each item in array. Returns ------- Function. ''' def f(value): return np.logical_not(...
python
def logical_not(f): # function factory '''Logical not from functions. Parameters ---------- f1, f2 : function Function that takes array and returns true or false for each item in array. Returns ------- Function. ''' def f(value): return np.logical_not(...
[ "def", "logical_not", "(", "f", ")", ":", "# function factory\r", "def", "f", "(", "value", ")", ":", "return", "np", ".", "logical_not", "(", "f", "(", "value", ")", ")", "f", ".", "__name__", "=", "\"not_\"", "+", "f", ".", "__name__", "return", "f...
Logical not from functions. Parameters ---------- f1, f2 : function Function that takes array and returns true or false for each item in array. Returns ------- Function.
[ "Logical", "not", "from", "functions", ".", "Parameters", "----------", "f1", "f2", ":", "function", "Function", "that", "takes", "array", "and", "returns", "true", "or", "false", "for", "each", "item", "in", "array", ".", "Returns", "-------", "Function", "...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/readout_utils.py#L239-L254
train
SiLab-Bonn/pyBAR
pybar/daq/readout_utils.py
logical_xor
def logical_xor(f1, f2): # function factory '''Logical xor from functions. Parameters ---------- f1, f2 : function Function that takes array and returns true or false for each item in array. Returns ------- Function. ''' def f(value): return np.logical...
python
def logical_xor(f1, f2): # function factory '''Logical xor from functions. Parameters ---------- f1, f2 : function Function that takes array and returns true or false for each item in array. Returns ------- Function. ''' def f(value): return np.logical...
[ "def", "logical_xor", "(", "f1", ",", "f2", ")", ":", "# function factory\r", "def", "f", "(", "value", ")", ":", "return", "np", ".", "logical_xor", "(", "f1", "(", "value", ")", ",", "f2", "(", "value", ")", ")", "f", ".", "__name__", "=", "\"(\"...
Logical xor from functions. Parameters ---------- f1, f2 : function Function that takes array and returns true or false for each item in array. Returns ------- Function.
[ "Logical", "xor", "from", "functions", ".", "Parameters", "----------", "f1", "f2", ":", "function", "Function", "that", "takes", "array", "and", "returns", "true", "or", "false", "for", "each", "item", "in", "array", ".", "Returns", "-------", "Function", "...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/readout_utils.py#L257-L272
train
SiLab-Bonn/pyBAR
pybar/daq/readout_utils.py
get_trigger_data
def get_trigger_data(value, mode=0): '''Returns 31bit trigger counter (mode=0), 31bit timestamp (mode=1), 15bit timestamp and 16bit trigger counter (mode=2) ''' if mode == 2: return np.right_shift(np.bitwise_and(value, 0x7FFF0000), 16), np.bitwise_and(value, 0x0000FFFF) else: retur...
python
def get_trigger_data(value, mode=0): '''Returns 31bit trigger counter (mode=0), 31bit timestamp (mode=1), 15bit timestamp and 16bit trigger counter (mode=2) ''' if mode == 2: return np.right_shift(np.bitwise_and(value, 0x7FFF0000), 16), np.bitwise_and(value, 0x0000FFFF) else: retur...
[ "def", "get_trigger_data", "(", "value", ",", "mode", "=", "0", ")", ":", "if", "mode", "==", "2", ":", "return", "np", ".", "right_shift", "(", "np", ".", "bitwise_and", "(", "value", ",", "0x7FFF0000", ")", ",", "16", ")", ",", "np", ".", "bitwis...
Returns 31bit trigger counter (mode=0), 31bit timestamp (mode=1), 15bit timestamp and 16bit trigger counter (mode=2)
[ "Returns", "31bit", "trigger", "counter", "(", "mode", "=", "0", ")", "31bit", "timestamp", "(", "mode", "=", "1", ")", "15bit", "timestamp", "and", "16bit", "trigger", "counter", "(", "mode", "=", "2", ")" ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/readout_utils.py#L315-L321
train
SiLab-Bonn/pyBAR
pybar/daq/readout_utils.py
get_col_row_tot_array_from_data_record_array
def get_col_row_tot_array_from_data_record_array(array): # TODO: max ToT '''Convert raw data array to column, row, and ToT array. Parameters ---------- array : numpy.array Raw data array. Returns ------- Tuple of arrays. ''' def get_col_row_tot_1_array_from_dat...
python
def get_col_row_tot_array_from_data_record_array(array): # TODO: max ToT '''Convert raw data array to column, row, and ToT array. Parameters ---------- array : numpy.array Raw data array. Returns ------- Tuple of arrays. ''' def get_col_row_tot_1_array_from_dat...
[ "def", "get_col_row_tot_array_from_data_record_array", "(", "array", ")", ":", "# TODO: max ToT\r", "def", "get_col_row_tot_1_array_from_data_record_array", "(", "value", ")", ":", "return", "np", ".", "right_shift", "(", "np", ".", "bitwise_and", "(", "value", ",", "...
Convert raw data array to column, row, and ToT array. Parameters ---------- array : numpy.array Raw data array. Returns ------- Tuple of arrays.
[ "Convert", "raw", "data", "array", "to", "column", "row", "and", "ToT", "array", ".", "Parameters", "----------", "array", ":", "numpy", ".", "array", "Raw", "data", "array", ".", "Returns", "-------", "Tuple", "of", "arrays", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/readout_utils.py#L342-L370
train
SiLab-Bonn/pyBAR
pybar/daq/readout_utils.py
interpret_pixel_data
def interpret_pixel_data(data, dc, pixel_array, invert=True): '''Takes the pixel raw data and interprets them. This includes consistency checks and pixel/data matching. The data has to come from one double column only but can have more than one pixel bit (e.g. TDAC = 5 bit). Parameters ---------- ...
python
def interpret_pixel_data(data, dc, pixel_array, invert=True): '''Takes the pixel raw data and interprets them. This includes consistency checks and pixel/data matching. The data has to come from one double column only but can have more than one pixel bit (e.g. TDAC = 5 bit). Parameters ---------- ...
[ "def", "interpret_pixel_data", "(", "data", ",", "dc", ",", "pixel_array", ",", "invert", "=", "True", ")", ":", "# data validity cut, VR has to follow an AR\r", "index_value", "=", "np", ".", "where", "(", "is_address_record", "(", "data", ")", ")", "[", "0", ...
Takes the pixel raw data and interprets them. This includes consistency checks and pixel/data matching. The data has to come from one double column only but can have more than one pixel bit (e.g. TDAC = 5 bit). Parameters ---------- data : numpy.ndarray The raw data words. dc : int ...
[ "Takes", "the", "pixel", "raw", "data", "and", "interprets", "them", ".", "This", "includes", "consistency", "checks", "and", "pixel", "/", "data", "matching", ".", "The", "data", "has", "to", "come", "from", "one", "double", "column", "only", "but", "can"...
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/daq/readout_utils.py#L428-L499
train
SiLab-Bonn/pyBAR
pybar/analysis/analyze_raw_data.py
AnalyzeRawData.set_standard_settings
def set_standard_settings(self): '''Set all settings to their standard values. ''' if self.is_open(self.out_file_h5): self.out_file_h5.close() self.out_file_h5 = None self._setup_clusterizer() self.chunk_size = 3000000 self.n_injections = None ...
python
def set_standard_settings(self): '''Set all settings to their standard values. ''' if self.is_open(self.out_file_h5): self.out_file_h5.close() self.out_file_h5 = None self._setup_clusterizer() self.chunk_size = 3000000 self.n_injections = None ...
[ "def", "set_standard_settings", "(", "self", ")", ":", "if", "self", ".", "is_open", "(", "self", ".", "out_file_h5", ")", ":", "self", ".", "out_file_h5", ".", "close", "(", ")", "self", ".", "out_file_h5", "=", "None", "self", ".", "_setup_clusterizer", ...
Set all settings to their standard values.
[ "Set", "all", "settings", "to", "their", "standard", "values", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analyze_raw_data.py#L263-L312
train
SiLab-Bonn/pyBAR
pybar/analysis/analyze_raw_data.py
AnalyzeRawData.trig_count
def trig_count(self, value): """Set the numbers of BCIDs (usually 16) of one event.""" self._trig_count = 16 if value == 0 else value self.interpreter.set_trig_count(self._trig_count)
python
def trig_count(self, value): """Set the numbers of BCIDs (usually 16) of one event.""" self._trig_count = 16 if value == 0 else value self.interpreter.set_trig_count(self._trig_count)
[ "def", "trig_count", "(", "self", ",", "value", ")", ":", "self", ".", "_trig_count", "=", "16", "if", "value", "==", "0", "else", "value", "self", ".", "interpreter", ".", "set_trig_count", "(", "self", ".", "_trig_count", ")" ]
Set the numbers of BCIDs (usually 16) of one event.
[ "Set", "the", "numbers", "of", "BCIDs", "(", "usually", "16", ")", "of", "one", "event", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analyze_raw_data.py#L531-L534
train
SiLab-Bonn/pyBAR
pybar/analysis/analyze_raw_data.py
AnalyzeRawData.max_tot_value
def max_tot_value(self, value): """Set maximum ToT value that is considered to be a hit""" self._max_tot_value = value self.interpreter.set_max_tot(self._max_tot_value) self.histogram.set_max_tot(self._max_tot_value) self.clusterizer.set_max_hit_charge(self._max_tot_value)
python
def max_tot_value(self, value): """Set maximum ToT value that is considered to be a hit""" self._max_tot_value = value self.interpreter.set_max_tot(self._max_tot_value) self.histogram.set_max_tot(self._max_tot_value) self.clusterizer.set_max_hit_charge(self._max_tot_value)
[ "def", "max_tot_value", "(", "self", ",", "value", ")", ":", "self", ".", "_max_tot_value", "=", "value", "self", ".", "interpreter", ".", "set_max_tot", "(", "self", ".", "_max_tot_value", ")", "self", ".", "histogram", ".", "set_max_tot", "(", "self", "....
Set maximum ToT value that is considered to be a hit
[ "Set", "maximum", "ToT", "value", "that", "is", "considered", "to", "be", "a", "hit" ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analyze_raw_data.py#L542-L547
train
SiLab-Bonn/pyBAR
pybar/analysis/analyze_raw_data.py
AnalyzeRawData.interpret_word_table
def interpret_word_table(self, analyzed_data_file=None, use_settings_from_file=True, fei4b=None): '''Interprets the raw data word table of all given raw data files with the c++ library. Creates the h5 output file and PDF plots. Parameters ---------- analyzed_data_file : string ...
python
def interpret_word_table(self, analyzed_data_file=None, use_settings_from_file=True, fei4b=None): '''Interprets the raw data word table of all given raw data files with the c++ library. Creates the h5 output file and PDF plots. Parameters ---------- analyzed_data_file : string ...
[ "def", "interpret_word_table", "(", "self", ",", "analyzed_data_file", "=", "None", ",", "use_settings_from_file", "=", "True", ",", "fei4b", "=", "None", ")", ":", "logging", ".", "info", "(", "'Interpreting raw data file(s): '", "+", "(", "', '", ")", ".", "...
Interprets the raw data word table of all given raw data files with the c++ library. Creates the h5 output file and PDF plots. Parameters ---------- analyzed_data_file : string The file name of the output analyzed data file. If None, the output analyzed data file ...
[ "Interprets", "the", "raw", "data", "word", "table", "of", "all", "given", "raw", "data", "files", "with", "the", "c", "++", "library", ".", "Creates", "the", "h5", "output", "file", "and", "PDF", "plots", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analyze_raw_data.py#L643-L921
train
SiLab-Bonn/pyBAR
pybar/analysis/analyze_raw_data.py
AnalyzeRawData.analyze_hit_table
def analyze_hit_table(self, analyzed_data_file=None, analyzed_data_out_file=None): '''Analyzes a hit table with the c++ histogrammming/clusterizer. Parameters ---------- analyzed_data_file : string The filename of the analyzed data file. If None, the analyzed data file ...
python
def analyze_hit_table(self, analyzed_data_file=None, analyzed_data_out_file=None): '''Analyzes a hit table with the c++ histogrammming/clusterizer. Parameters ---------- analyzed_data_file : string The filename of the analyzed data file. If None, the analyzed data file ...
[ "def", "analyze_hit_table", "(", "self", ",", "analyzed_data_file", "=", "None", ",", "analyzed_data_out_file", "=", "None", ")", ":", "close_analyzed_data_file", "=", "False", "if", "analyzed_data_file", "is", "not", "None", ":", "# if an output file name is specified ...
Analyzes a hit table with the c++ histogrammming/clusterizer. Parameters ---------- analyzed_data_file : string The filename of the analyzed data file. If None, the analyzed data file specified during initialization is taken. Filename extension (.h5) does not...
[ "Analyzes", "a", "hit", "table", "with", "the", "c", "++", "histogrammming", "/", "clusterizer", "." ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analyze_raw_data.py#L1067-L1204
train
SiLab-Bonn/pyBAR
pybar/analysis/analyze_raw_data.py
AnalyzeRawData._deduce_settings_from_file
def _deduce_settings_from_file(self, opened_raw_data_file): # TODO: parse better '''Tries to get the scan parameters needed for analysis from the raw data file ''' try: # take infos raw data files (not avalable in old files) flavor = opened_raw_data_file.root.configuration.miscella...
python
def _deduce_settings_from_file(self, opened_raw_data_file): # TODO: parse better '''Tries to get the scan parameters needed for analysis from the raw data file ''' try: # take infos raw data files (not avalable in old files) flavor = opened_raw_data_file.root.configuration.miscella...
[ "def", "_deduce_settings_from_file", "(", "self", ",", "opened_raw_data_file", ")", ":", "# TODO: parse better", "try", ":", "# take infos raw data files (not avalable in old files)", "flavor", "=", "opened_raw_data_file", ".", "root", ".", "configuration", ".", "miscellaneou...
Tries to get the scan parameters needed for analysis from the raw data file
[ "Tries", "to", "get", "the", "scan", "parameters", "needed", "for", "analysis", "from", "the", "raw", "data", "file" ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analyze_raw_data.py#L1399-L1431
train
SiLab-Bonn/pyBAR
pybar/analysis/analyze_raw_data.py
AnalyzeRawData._get_plsr_dac_charge
def _get_plsr_dac_charge(self, plsr_dac_array, no_offset=False): '''Takes the PlsrDAC calibration and the stored C-high/C-low mask to calculate the charge from the PlsrDAC array on a pixel basis ''' charge = np.zeros_like(self.c_low_mask, dtype=np.float16) # charge in electrons if self....
python
def _get_plsr_dac_charge(self, plsr_dac_array, no_offset=False): '''Takes the PlsrDAC calibration and the stored C-high/C-low mask to calculate the charge from the PlsrDAC array on a pixel basis ''' charge = np.zeros_like(self.c_low_mask, dtype=np.float16) # charge in electrons if self....
[ "def", "_get_plsr_dac_charge", "(", "self", ",", "plsr_dac_array", ",", "no_offset", "=", "False", ")", ":", "charge", "=", "np", ".", "zeros_like", "(", "self", ".", "c_low_mask", ",", "dtype", "=", "np", ".", "float16", ")", "# charge in electrons", "if", ...
Takes the PlsrDAC calibration and the stored C-high/C-low mask to calculate the charge from the PlsrDAC array on a pixel basis
[ "Takes", "the", "PlsrDAC", "calibration", "and", "the", "stored", "C", "-", "high", "/", "C", "-", "low", "mask", "to", "calculate", "the", "charge", "from", "the", "PlsrDAC", "array", "on", "a", "pixel", "basis" ]
5ad95bbcd41cd358825823fb78f396cfce23593e
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analyze_raw_data.py#L1433-L1442
train
yougov/solr-doc-manager
mongo_connector/doc_managers/solr_doc_manager.py
DocManager._parse_fields
def _parse_fields(self, result, field_name): """ If Schema access, parse fields and build respective lists """ field_list = [] for key, value in result.get('schema', {}).get(field_name, {}).items(): if key not in field_list: field_list.append(key) retu...
python
def _parse_fields(self, result, field_name): """ If Schema access, parse fields and build respective lists """ field_list = [] for key, value in result.get('schema', {}).get(field_name, {}).items(): if key not in field_list: field_list.append(key) retu...
[ "def", "_parse_fields", "(", "self", ",", "result", ",", "field_name", ")", ":", "field_list", "=", "[", "]", "for", "key", ",", "value", "in", "result", ".", "get", "(", "'schema'", ",", "{", "}", ")", ".", "get", "(", "field_name", ",", "{", "}",...
If Schema access, parse fields and build respective lists
[ "If", "Schema", "access", "parse", "fields", "and", "build", "respective", "lists" ]
1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd
https://github.com/yougov/solr-doc-manager/blob/1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd/mongo_connector/doc_managers/solr_doc_manager.py#L83-L90
train
yougov/solr-doc-manager
mongo_connector/doc_managers/solr_doc_manager.py
DocManager._build_fields
def _build_fields(self): """ Builds a list of valid fields """ declared_fields = self.solr._send_request('get', ADMIN_URL) result = decoder.decode(declared_fields) self.field_list = self._parse_fields(result, 'fields') # Build regular expressions to match dynamic fields....
python
def _build_fields(self): """ Builds a list of valid fields """ declared_fields = self.solr._send_request('get', ADMIN_URL) result = decoder.decode(declared_fields) self.field_list = self._parse_fields(result, 'fields') # Build regular expressions to match dynamic fields....
[ "def", "_build_fields", "(", "self", ")", ":", "declared_fields", "=", "self", ".", "solr", ".", "_send_request", "(", "'get'", ",", "ADMIN_URL", ")", "result", "=", "decoder", ".", "decode", "(", "declared_fields", ")", "self", ".", "field_list", "=", "se...
Builds a list of valid fields
[ "Builds", "a", "list", "of", "valid", "fields" ]
1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd
https://github.com/yougov/solr-doc-manager/blob/1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd/mongo_connector/doc_managers/solr_doc_manager.py#L93-L110
train
yougov/solr-doc-manager
mongo_connector/doc_managers/solr_doc_manager.py
DocManager._clean_doc
def _clean_doc(self, doc, namespace, timestamp): """Reformats the given document before insertion into Solr. This method reformats the document in the following ways: - removes extraneous fields that aren't defined in schema.xml - unwinds arrays in order to find and later flatten su...
python
def _clean_doc(self, doc, namespace, timestamp): """Reformats the given document before insertion into Solr. This method reformats the document in the following ways: - removes extraneous fields that aren't defined in schema.xml - unwinds arrays in order to find and later flatten su...
[ "def", "_clean_doc", "(", "self", ",", "doc", ",", "namespace", ",", "timestamp", ")", ":", "# Translate the _id field to whatever unique key we're using.", "# _id may not exist in the doc, if we retrieved it from Solr", "# as part of update.", "if", "'_id'", "in", "doc", ":", ...
Reformats the given document before insertion into Solr. This method reformats the document in the following ways: - removes extraneous fields that aren't defined in schema.xml - unwinds arrays in order to find and later flatten sub-documents - flattens the document so that there ...
[ "Reformats", "the", "given", "document", "before", "insertion", "into", "Solr", "." ]
1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd
https://github.com/yougov/solr-doc-manager/blob/1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd/mongo_connector/doc_managers/solr_doc_manager.py#L112-L165
train
yougov/solr-doc-manager
mongo_connector/doc_managers/solr_doc_manager.py
DocManager.apply_update
def apply_update(self, doc, update_spec): """Override DocManagerBase.apply_update to have flat documents.""" # Replace a whole document if not '$set' in update_spec and not '$unset' in update_spec: # update_spec contains the new document. # Update the key in Solr based on...
python
def apply_update(self, doc, update_spec): """Override DocManagerBase.apply_update to have flat documents.""" # Replace a whole document if not '$set' in update_spec and not '$unset' in update_spec: # update_spec contains the new document. # Update the key in Solr based on...
[ "def", "apply_update", "(", "self", ",", "doc", ",", "update_spec", ")", ":", "# Replace a whole document", "if", "not", "'$set'", "in", "update_spec", "and", "not", "'$unset'", "in", "update_spec", ":", "# update_spec contains the new document.", "# Update the key in S...
Override DocManagerBase.apply_update to have flat documents.
[ "Override", "DocManagerBase", ".", "apply_update", "to", "have", "flat", "documents", "." ]
1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd
https://github.com/yougov/solr-doc-manager/blob/1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd/mongo_connector/doc_managers/solr_doc_manager.py#L195-L226
train
yougov/solr-doc-manager
mongo_connector/doc_managers/solr_doc_manager.py
DocManager.update
def update(self, document_id, update_spec, namespace, timestamp): """Apply updates given in update_spec to the document whose id matches that of doc. """ # Commit outstanding changes so that the document to be updated is the # same version to which the changes apply. sel...
python
def update(self, document_id, update_spec, namespace, timestamp): """Apply updates given in update_spec to the document whose id matches that of doc. """ # Commit outstanding changes so that the document to be updated is the # same version to which the changes apply. sel...
[ "def", "update", "(", "self", ",", "document_id", ",", "update_spec", ",", "namespace", ",", "timestamp", ")", ":", "# Commit outstanding changes so that the document to be updated is the", "# same version to which the changes apply.", "self", ".", "commit", "(", ")", "# Ne...
Apply updates given in update_spec to the document whose id matches that of doc.
[ "Apply", "updates", "given", "in", "update_spec", "to", "the", "document", "whose", "id", "matches", "that", "of", "doc", "." ]
1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd
https://github.com/yougov/solr-doc-manager/blob/1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd/mongo_connector/doc_managers/solr_doc_manager.py#L229-L258
train
yougov/solr-doc-manager
mongo_connector/doc_managers/solr_doc_manager.py
DocManager.upsert
def upsert(self, doc, namespace, timestamp): """Update or insert a document into Solr This method should call whatever add/insert/update method exists for the backend engine and add the document in there. The input will always be one mongo document, represented as a Python dictionary. ...
python
def upsert(self, doc, namespace, timestamp): """Update or insert a document into Solr This method should call whatever add/insert/update method exists for the backend engine and add the document in there. The input will always be one mongo document, represented as a Python dictionary. ...
[ "def", "upsert", "(", "self", ",", "doc", ",", "namespace", ",", "timestamp", ")", ":", "if", "self", ".", "auto_commit_interval", "is", "not", "None", ":", "self", ".", "solr", ".", "add", "(", "[", "self", ".", "_clean_doc", "(", "doc", ",", "names...
Update or insert a document into Solr This method should call whatever add/insert/update method exists for the backend engine and add the document in there. The input will always be one mongo document, represented as a Python dictionary.
[ "Update", "or", "insert", "a", "document", "into", "Solr" ]
1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd
https://github.com/yougov/solr-doc-manager/blob/1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd/mongo_connector/doc_managers/solr_doc_manager.py#L261-L274
train
yougov/solr-doc-manager
mongo_connector/doc_managers/solr_doc_manager.py
DocManager.bulk_upsert
def bulk_upsert(self, docs, namespace, timestamp): """Update or insert multiple documents into Solr docs may be any iterable """ if self.auto_commit_interval is not None: add_kwargs = { "commit": (self.auto_commit_interval == 0), "commitWithin...
python
def bulk_upsert(self, docs, namespace, timestamp): """Update or insert multiple documents into Solr docs may be any iterable """ if self.auto_commit_interval is not None: add_kwargs = { "commit": (self.auto_commit_interval == 0), "commitWithin...
[ "def", "bulk_upsert", "(", "self", ",", "docs", ",", "namespace", ",", "timestamp", ")", ":", "if", "self", ".", "auto_commit_interval", "is", "not", "None", ":", "add_kwargs", "=", "{", "\"commit\"", ":", "(", "self", ".", "auto_commit_interval", "==", "0...
Update or insert multiple documents into Solr docs may be any iterable
[ "Update", "or", "insert", "multiple", "documents", "into", "Solr" ]
1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd
https://github.com/yougov/solr-doc-manager/blob/1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd/mongo_connector/doc_managers/solr_doc_manager.py#L277-L298
train
yougov/solr-doc-manager
mongo_connector/doc_managers/solr_doc_manager.py
DocManager.remove
def remove(self, document_id, namespace, timestamp): """Removes documents from Solr The input is a python dictionary that represents a mongo document. """ self.solr.delete(id=u(document_id), commit=(self.auto_commit_interval == 0))
python
def remove(self, document_id, namespace, timestamp): """Removes documents from Solr The input is a python dictionary that represents a mongo document. """ self.solr.delete(id=u(document_id), commit=(self.auto_commit_interval == 0))
[ "def", "remove", "(", "self", ",", "document_id", ",", "namespace", ",", "timestamp", ")", ":", "self", ".", "solr", ".", "delete", "(", "id", "=", "u", "(", "document_id", ")", ",", "commit", "=", "(", "self", ".", "auto_commit_interval", "==", "0", ...
Removes documents from Solr The input is a python dictionary that represents a mongo document.
[ "Removes", "documents", "from", "Solr" ]
1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd
https://github.com/yougov/solr-doc-manager/blob/1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd/mongo_connector/doc_managers/solr_doc_manager.py#L320-L326
train
yougov/solr-doc-manager
mongo_connector/doc_managers/solr_doc_manager.py
DocManager._stream_search
def _stream_search(self, query): """Helper method for iterating over Solr search results.""" for doc in self.solr.search(query, rows=100000000): if self.unique_key != "_id": doc["_id"] = doc.pop(self.unique_key) yield doc
python
def _stream_search(self, query): """Helper method for iterating over Solr search results.""" for doc in self.solr.search(query, rows=100000000): if self.unique_key != "_id": doc["_id"] = doc.pop(self.unique_key) yield doc
[ "def", "_stream_search", "(", "self", ",", "query", ")", ":", "for", "doc", "in", "self", ".", "solr", ".", "search", "(", "query", ",", "rows", "=", "100000000", ")", ":", "if", "self", ".", "unique_key", "!=", "\"_id\"", ":", "doc", "[", "\"_id\"",...
Helper method for iterating over Solr search results.
[ "Helper", "method", "for", "iterating", "over", "Solr", "search", "results", "." ]
1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd
https://github.com/yougov/solr-doc-manager/blob/1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd/mongo_connector/doc_managers/solr_doc_manager.py#L329-L334
train
yougov/solr-doc-manager
mongo_connector/doc_managers/solr_doc_manager.py
DocManager.search
def search(self, start_ts, end_ts): """Called to query Solr for documents in a time range.""" query = '_ts: [%s TO %s]' % (start_ts, end_ts) return self._stream_search(query)
python
def search(self, start_ts, end_ts): """Called to query Solr for documents in a time range.""" query = '_ts: [%s TO %s]' % (start_ts, end_ts) return self._stream_search(query)
[ "def", "search", "(", "self", ",", "start_ts", ",", "end_ts", ")", ":", "query", "=", "'_ts: [%s TO %s]'", "%", "(", "start_ts", ",", "end_ts", ")", "return", "self", ".", "_stream_search", "(", "query", ")" ]
Called to query Solr for documents in a time range.
[ "Called", "to", "query", "Solr", "for", "documents", "in", "a", "time", "range", "." ]
1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd
https://github.com/yougov/solr-doc-manager/blob/1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd/mongo_connector/doc_managers/solr_doc_manager.py#L337-L340
train
yougov/solr-doc-manager
mongo_connector/doc_managers/solr_doc_manager.py
DocManager.get_last_doc
def get_last_doc(self): """Returns the last document stored in the Solr engine. """ #search everything, sort by descending timestamp, return 1 row try: result = self.solr.search('*:*', sort='_ts desc', rows=1) except ValueError: return None for r ...
python
def get_last_doc(self): """Returns the last document stored in the Solr engine. """ #search everything, sort by descending timestamp, return 1 row try: result = self.solr.search('*:*', sort='_ts desc', rows=1) except ValueError: return None for r ...
[ "def", "get_last_doc", "(", "self", ")", ":", "#search everything, sort by descending timestamp, return 1 row", "try", ":", "result", "=", "self", ".", "solr", ".", "search", "(", "'*:*'", ",", "sort", "=", "'_ts desc'", ",", "rows", "=", "1", ")", "except", "...
Returns the last document stored in the Solr engine.
[ "Returns", "the", "last", "document", "stored", "in", "the", "Solr", "engine", "." ]
1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd
https://github.com/yougov/solr-doc-manager/blob/1978bf6f3387b1afd6dd6b41a1bbaea9932d60fd/mongo_connector/doc_managers/solr_doc_manager.py#L348-L359
train
ricmoo/pyscrypt
pyscrypt/hash.py
pbkdf2_single
def pbkdf2_single(password, salt, key_length, prf): '''Returns the result of the Password-Based Key Derivation Function 2 with a single iteration (i.e. count = 1). prf - a psuedorandom function See http://en.wikipedia.org/wiki/PBKDF2 ''' block_number = 0 result = b'' # The i...
python
def pbkdf2_single(password, salt, key_length, prf): '''Returns the result of the Password-Based Key Derivation Function 2 with a single iteration (i.e. count = 1). prf - a psuedorandom function See http://en.wikipedia.org/wiki/PBKDF2 ''' block_number = 0 result = b'' # The i...
[ "def", "pbkdf2_single", "(", "password", ",", "salt", ",", "key_length", ",", "prf", ")", ":", "block_number", "=", "0", "result", "=", "b''", "# The iterations", "while", "len", "(", "result", ")", "<", "key_length", ":", "block_number", "+=", "1", "resul...
Returns the result of the Password-Based Key Derivation Function 2 with a single iteration (i.e. count = 1). prf - a psuedorandom function See http://en.wikipedia.org/wiki/PBKDF2
[ "Returns", "the", "result", "of", "the", "Password", "-", "Based", "Key", "Derivation", "Function", "2", "with", "a", "single", "iteration", "(", "i", ".", "e", ".", "count", "=", "1", ")", "." ]
131ca39acee4963afd704b4c4631497e4fe34c97
https://github.com/ricmoo/pyscrypt/blob/131ca39acee4963afd704b4c4631497e4fe34c97/pyscrypt/hash.py#L56-L73
train
ricmoo/pyscrypt
pyscrypt/hash.py
salsa20_8
def salsa20_8(B): '''Salsa 20/8 stream cypher; Used by BlockMix. See http://en.wikipedia.org/wiki/Salsa20''' # Create a working copy x = B[:] # Expanded form of this code. The expansion is significantly faster but # this is much easier to understand # ROUNDS = ( # (4, 0, 12, 7), (8, ...
python
def salsa20_8(B): '''Salsa 20/8 stream cypher; Used by BlockMix. See http://en.wikipedia.org/wiki/Salsa20''' # Create a working copy x = B[:] # Expanded form of this code. The expansion is significantly faster but # this is much easier to understand # ROUNDS = ( # (4, 0, 12, 7), (8, ...
[ "def", "salsa20_8", "(", "B", ")", ":", "# Create a working copy", "x", "=", "B", "[", ":", "]", "# Expanded form of this code. The expansion is significantly faster but", "# this is much easier to understand", "# ROUNDS = (", "# (4, 0, 12, 7), (8, 4, 0, 9), (12, 8, 4, 13), ...
Salsa 20/8 stream cypher; Used by BlockMix. See http://en.wikipedia.org/wiki/Salsa20
[ "Salsa", "20", "/", "8", "stream", "cypher", ";", "Used", "by", "BlockMix", ".", "See", "http", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "Salsa20" ]
131ca39acee4963afd704b4c4631497e4fe34c97
https://github.com/ricmoo/pyscrypt/blob/131ca39acee4963afd704b4c4631497e4fe34c97/pyscrypt/hash.py#L76-L167
train
ricmoo/pyscrypt
pyscrypt/hash.py
blockmix_salsa8
def blockmix_salsa8(BY, Yi, r): '''Blockmix; Used by SMix.''' start = (2 * r - 1) * 16 X = BY[start:start + 16] # BlockMix - 1 for i in xrange(0, 2 * r): # BlockMix - 2 for xi in xrange(0, 16): ...
python
def blockmix_salsa8(BY, Yi, r): '''Blockmix; Used by SMix.''' start = (2 * r - 1) * 16 X = BY[start:start + 16] # BlockMix - 1 for i in xrange(0, 2 * r): # BlockMix - 2 for xi in xrange(0, 16): ...
[ "def", "blockmix_salsa8", "(", "BY", ",", "Yi", ",", "r", ")", ":", "start", "=", "(", "2", "*", "r", "-", "1", ")", "*", "16", "X", "=", "BY", "[", "start", ":", "start", "+", "16", "]", "# BlockMix - 1", "for", "i", "in", "xrange", "(", "0"...
Blockmix; Used by SMix.
[ "Blockmix", ";", "Used", "by", "SMix", "." ]
131ca39acee4963afd704b4c4631497e4fe34c97
https://github.com/ricmoo/pyscrypt/blob/131ca39acee4963afd704b4c4631497e4fe34c97/pyscrypt/hash.py#L170-L193
train
ricmoo/pyscrypt
pyscrypt/hash.py
smix
def smix(B, Bi, r, N, V, X): '''SMix; a specific case of ROMix. See scrypt.pdf in the links above.''' X[:32 * r] = B[Bi:Bi + 32 * r] # ROMix - 1 for i in xrange(0, N): # ROMix - 2 aod = i * 32 * r # ROMix - 3 V[aod:aod...
python
def smix(B, Bi, r, N, V, X): '''SMix; a specific case of ROMix. See scrypt.pdf in the links above.''' X[:32 * r] = B[Bi:Bi + 32 * r] # ROMix - 1 for i in xrange(0, N): # ROMix - 2 aod = i * 32 * r # ROMix - 3 V[aod:aod...
[ "def", "smix", "(", "B", ",", "Bi", ",", "r", ",", "N", ",", "V", ",", "X", ")", ":", "X", "[", ":", "32", "*", "r", "]", "=", "B", "[", "Bi", ":", "Bi", "+", "32", "*", "r", "]", "# ROMix - 1", "for", "i", "in", "xrange", "(", "0", "...
SMix; a specific case of ROMix. See scrypt.pdf in the links above.
[ "SMix", ";", "a", "specific", "case", "of", "ROMix", ".", "See", "scrypt", ".", "pdf", "in", "the", "links", "above", "." ]
131ca39acee4963afd704b4c4631497e4fe34c97
https://github.com/ricmoo/pyscrypt/blob/131ca39acee4963afd704b4c4631497e4fe34c97/pyscrypt/hash.py#L196-L213
train
ricmoo/pyscrypt
pyscrypt/hash.py
hash
def hash(password, salt, N, r, p, dkLen): """Returns the result of the scrypt password-based key derivation function. Constraints: r * p < (2 ** 30) dkLen <= (((2 ** 32) - 1) * 32 N must be a power of 2 greater than 1 (eg. 2, 4, 8, 16, 32...) N, r, p must be positive ...
python
def hash(password, salt, N, r, p, dkLen): """Returns the result of the scrypt password-based key derivation function. Constraints: r * p < (2 ** 30) dkLen <= (((2 ** 32) - 1) * 32 N must be a power of 2 greater than 1 (eg. 2, 4, 8, 16, 32...) N, r, p must be positive ...
[ "def", "hash", "(", "password", ",", "salt", ",", "N", ",", "r", ",", "p", ",", "dkLen", ")", ":", "# This only matters to Python 3", "if", "not", "check_bytes", "(", "password", ")", ":", "raise", "ValueError", "(", "'password must be a byte array'", ")", "...
Returns the result of the scrypt password-based key derivation function. Constraints: r * p < (2 ** 30) dkLen <= (((2 ** 32) - 1) * 32 N must be a power of 2 greater than 1 (eg. 2, 4, 8, 16, 32...) N, r, p must be positive
[ "Returns", "the", "result", "of", "the", "scrypt", "password", "-", "based", "key", "derivation", "function", "." ]
131ca39acee4963afd704b4c4631497e4fe34c97
https://github.com/ricmoo/pyscrypt/blob/131ca39acee4963afd704b4c4631497e4fe34c97/pyscrypt/hash.py#L217-L258
train
ricmoo/pyscrypt
pyscrypt/file.py
ScryptFile._load_get_attr
def _load_get_attr(self, name): 'Return an internal attribute after ensuring the headers is loaded if necessary.' if self._mode in _allowed_read and self._N is None: self._read_header() return getattr(self, name)
python
def _load_get_attr(self, name): 'Return an internal attribute after ensuring the headers is loaded if necessary.' if self._mode in _allowed_read and self._N is None: self._read_header() return getattr(self, name)
[ "def", "_load_get_attr", "(", "self", ",", "name", ")", ":", "if", "self", ".", "_mode", "in", "_allowed_read", "and", "self", ".", "_N", "is", "None", ":", "self", ".", "_read_header", "(", ")", "return", "getattr", "(", "self", ",", "name", ")" ]
Return an internal attribute after ensuring the headers is loaded if necessary.
[ "Return", "an", "internal", "attribute", "after", "ensuring", "the", "headers", "is", "loaded", "if", "necessary", "." ]
131ca39acee4963afd704b4c4631497e4fe34c97
https://github.com/ricmoo/pyscrypt/blob/131ca39acee4963afd704b4c4631497e4fe34c97/pyscrypt/file.py#L190-L194
train
ricmoo/pyscrypt
pyscrypt/file.py
ScryptFile.close
def close(self): '''Close the underlying file. Sets data attribute .closed to True. A closed file cannot be used for further I/O operations. close() may be called more than once without error. Some kinds of file objects (for example, opened by popen()) may return an exit status ...
python
def close(self): '''Close the underlying file. Sets data attribute .closed to True. A closed file cannot be used for further I/O operations. close() may be called more than once without error. Some kinds of file objects (for example, opened by popen()) may return an exit status ...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_mode", "in", "_allowed_write", "and", "self", ".", "_valid", "is", "None", ":", "self", ".", "_finalize_write", "(", ")", "result", "=", "self", ".", "_fp", ".", "close", "(", ")", "self", ...
Close the underlying file. Sets data attribute .closed to True. A closed file cannot be used for further I/O operations. close() may be called more than once without error. Some kinds of file objects (for example, opened by popen()) may return an exit status upon closing.
[ "Close", "the", "underlying", "file", "." ]
131ca39acee4963afd704b4c4631497e4fe34c97
https://github.com/ricmoo/pyscrypt/blob/131ca39acee4963afd704b4c4631497e4fe34c97/pyscrypt/file.py#L241-L254
train
ricmoo/pyscrypt
pyscrypt/file.py
ScryptFile.verify_file
def verify_file(fp, password): 'Returns whether a scrypt encrypted file is valid.' sf = ScryptFile(fp = fp, password = password) for line in sf: pass sf.close() return sf.valid
python
def verify_file(fp, password): 'Returns whether a scrypt encrypted file is valid.' sf = ScryptFile(fp = fp, password = password) for line in sf: pass sf.close() return sf.valid
[ "def", "verify_file", "(", "fp", ",", "password", ")", ":", "sf", "=", "ScryptFile", "(", "fp", "=", "fp", ",", "password", "=", "password", ")", "for", "line", "in", "sf", ":", "pass", "sf", ".", "close", "(", ")", "return", "sf", ".", "valid" ]
Returns whether a scrypt encrypted file is valid.
[ "Returns", "whether", "a", "scrypt", "encrypted", "file", "is", "valid", "." ]
131ca39acee4963afd704b4c4631497e4fe34c97
https://github.com/ricmoo/pyscrypt/blob/131ca39acee4963afd704b4c4631497e4fe34c97/pyscrypt/file.py#L267-L273
train
ricmoo/pyscrypt
pyscrypt/file.py
ScryptFile.readline
def readline(self, size = None): '''Next line from the decrypted file, as a string. Retain newline. A non-negative size argument limits the maximum number of bytes to return (an incomplete line may be returned then). Return an empty string at EOF.''' if self.closed: raise Valu...
python
def readline(self, size = None): '''Next line from the decrypted file, as a string. Retain newline. A non-negative size argument limits the maximum number of bytes to return (an incomplete line may be returned then). Return an empty string at EOF.''' if self.closed: raise Valu...
[ "def", "readline", "(", "self", ",", "size", "=", "None", ")", ":", "if", "self", ".", "closed", ":", "raise", "ValueError", "(", "'file closed'", ")", "if", "self", ".", "_mode", "in", "_allowed_write", ":", "raise", "Exception", "(", "'file opened for wr...
Next line from the decrypted file, as a string. Retain newline. A non-negative size argument limits the maximum number of bytes to return (an incomplete line may be returned then). Return an empty string at EOF.
[ "Next", "line", "from", "the", "decrypted", "file", "as", "a", "string", "." ]
131ca39acee4963afd704b4c4631497e4fe34c97
https://github.com/ricmoo/pyscrypt/blob/131ca39acee4963afd704b4c4631497e4fe34c97/pyscrypt/file.py#L276-L291
train
ricmoo/pyscrypt
pyscrypt/file.py
ScryptFile._read_header
def _read_header(self): '''Read and parse the header and calculate derived keys.''' try: # Read the entire header header = self._fp.read(96) if len(header) != 96: raise InvalidScryptFileFormat("Incomplete header") # Magic number ...
python
def _read_header(self): '''Read and parse the header and calculate derived keys.''' try: # Read the entire header header = self._fp.read(96) if len(header) != 96: raise InvalidScryptFileFormat("Incomplete header") # Magic number ...
[ "def", "_read_header", "(", "self", ")", ":", "try", ":", "# Read the entire header", "header", "=", "self", ".", "_fp", ".", "read", "(", "96", ")", "if", "len", "(", "header", ")", "!=", "96", ":", "raise", "InvalidScryptFileFormat", "(", "\"Incomplete h...
Read and parse the header and calculate derived keys.
[ "Read", "and", "parse", "the", "header", "and", "calculate", "derived", "keys", "." ]
131ca39acee4963afd704b4c4631497e4fe34c97
https://github.com/ricmoo/pyscrypt/blob/131ca39acee4963afd704b4c4631497e4fe34c97/pyscrypt/file.py#L308-L358
train
ricmoo/pyscrypt
pyscrypt/file.py
ScryptFile.read
def read(self, size = None): '''Read at most size bytes, returned as a string. If the size argument is negative or omitted, read until EOF is reached. Notice that when in non-blocking mode, less data than what was requested may be returned, even if no size parameter was given.''' ...
python
def read(self, size = None): '''Read at most size bytes, returned as a string. If the size argument is negative or omitted, read until EOF is reached. Notice that when in non-blocking mode, less data than what was requested may be returned, even if no size parameter was given.''' ...
[ "def", "read", "(", "self", ",", "size", "=", "None", ")", ":", "if", "self", ".", "closed", ":", "raise", "ValueError", "(", "'File closed'", ")", "if", "self", ".", "_mode", "in", "_allowed_write", ":", "raise", "Exception", "(", "'File opened for write ...
Read at most size bytes, returned as a string. If the size argument is negative or omitted, read until EOF is reached. Notice that when in non-blocking mode, less data than what was requested may be returned, even if no size parameter was given.
[ "Read", "at", "most", "size", "bytes", "returned", "as", "a", "string", "." ]
131ca39acee4963afd704b4c4631497e4fe34c97
https://github.com/ricmoo/pyscrypt/blob/131ca39acee4963afd704b4c4631497e4fe34c97/pyscrypt/file.py#L366-L427
train
ricmoo/pyscrypt
pyscrypt/file.py
ScryptFile._write_header
def _write_header(self): 'Writes the header to the underlying file object.' header = b'scrypt' + CHR0 + struct.pack('>BII', int(math.log(self.N, 2)), self.r, self.p) + self.salt # Add the header checksum to the header checksum = hashlib.sha256(header).digest()[:16] header += ch...
python
def _write_header(self): 'Writes the header to the underlying file object.' header = b'scrypt' + CHR0 + struct.pack('>BII', int(math.log(self.N, 2)), self.r, self.p) + self.salt # Add the header checksum to the header checksum = hashlib.sha256(header).digest()[:16] header += ch...
[ "def", "_write_header", "(", "self", ")", ":", "header", "=", "b'scrypt'", "+", "CHR0", "+", "struct", ".", "pack", "(", "'>BII'", ",", "int", "(", "math", ".", "log", "(", "self", ".", "N", ",", "2", ")", ")", ",", "self", ".", "r", ",", "self...
Writes the header to the underlying file object.
[ "Writes", "the", "header", "to", "the", "underlying", "file", "object", "." ]
131ca39acee4963afd704b4c4631497e4fe34c97
https://github.com/ricmoo/pyscrypt/blob/131ca39acee4963afd704b4c4631497e4fe34c97/pyscrypt/file.py#L444-L466
train