repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
NaPs/Kolekto
kolekto/commands/importer.py
copy
def copy(tree, source_filename): """ Copy file in tree, show a progress bar during operations, and return the sha1 sum of copied file. """ #_, ext = os.path.splitext(source_filename) filehash = sha1() with printer.progress(os.path.getsize(source_filename)) as update: with open(source...
python
def copy(tree, source_filename): """ Copy file in tree, show a progress bar during operations, and return the sha1 sum of copied file. """ #_, ext = os.path.splitext(source_filename) filehash = sha1() with printer.progress(os.path.getsize(source_filename)) as update: with open(source...
[ "def", "copy", "(", "tree", ",", "source_filename", ")", ":", "filehash", "=", "sha1", "(", ")", "with", "printer", ".", "progress", "(", "os", ".", "path", ".", "getsize", "(", "source_filename", ")", ")", "as", "update", ":", "with", "open", "(", "...
Copy file in tree, show a progress bar during operations, and return the sha1 sum of copied file.
[ "Copy", "file", "in", "tree", "show", "a", "progress", "bar", "during", "operations", "and", "return", "the", "sha1", "sum", "of", "copied", "file", "." ]
29c5469da8782780a06bf9a76c59414bb6fd8fe3
https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/commands/importer.py#L36-L60
train
NaPs/Kolekto
kolekto/commands/importer.py
list_attachments
def list_attachments(fullname): """ List attachment for the specified fullname. """ parent, filename = os.path.split(fullname) filename_without_ext, ext = os.path.splitext(filename) attachments = [] for found_filename in os.listdir(parent): found_filename_without_ext, _ = os.path.splitex...
python
def list_attachments(fullname): """ List attachment for the specified fullname. """ parent, filename = os.path.split(fullname) filename_without_ext, ext = os.path.splitext(filename) attachments = [] for found_filename in os.listdir(parent): found_filename_without_ext, _ = os.path.splitex...
[ "def", "list_attachments", "(", "fullname", ")", ":", "parent", ",", "filename", "=", "os", ".", "path", ".", "split", "(", "fullname", ")", "filename_without_ext", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "attachments", ...
List attachment for the specified fullname.
[ "List", "attachment", "for", "the", "specified", "fullname", "." ]
29c5469da8782780a06bf9a76c59414bb6fd8fe3
https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/commands/importer.py#L88-L98
train
IRC-SPHERE/HyperStream
hyperstream/channels/assets_channel.py
AssetsChannel.write_to_stream
def write_to_stream(self, stream_id, data, sandbox=None): """ Write to the stream :param stream_id: The stream identifier :param data: The stream instances :param sandbox: The sandbox for this stream :type stream_id: StreamId :return: None :raises: NotImp...
python
def write_to_stream(self, stream_id, data, sandbox=None): """ Write to the stream :param stream_id: The stream identifier :param data: The stream instances :param sandbox: The sandbox for this stream :type stream_id: StreamId :return: None :raises: NotImp...
[ "def", "write_to_stream", "(", "self", ",", "stream_id", ",", "data", ",", "sandbox", "=", "None", ")", ":", "if", "sandbox", "is", "not", "None", ":", "raise", "NotImplementedError", "if", "stream_id", "not", "in", "self", ".", "streams", ":", "raise", ...
Write to the stream :param stream_id: The stream identifier :param data: The stream instances :param sandbox: The sandbox for this stream :type stream_id: StreamId :return: None :raises: NotImplementedError
[ "Write", "to", "the", "stream" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/channels/assets_channel.py#L82-L107
train
dsoprea/PySchedules
pyschedules/xml_callbacks.py
XmlCallbacks._startXTVDNode
def _startXTVDNode(self, name, attrs): """Process the start of the top-level xtvd node""" schemaVersion = attrs.get('schemaVersion') validFrom = self._parseDateTime(attrs.get('from')) validTo = self._parseDateTime(attrs.get('to')) self._progress.printMsg('Parsing version %s data...
python
def _startXTVDNode(self, name, attrs): """Process the start of the top-level xtvd node""" schemaVersion = attrs.get('schemaVersion') validFrom = self._parseDateTime(attrs.get('from')) validTo = self._parseDateTime(attrs.get('to')) self._progress.printMsg('Parsing version %s data...
[ "def", "_startXTVDNode", "(", "self", ",", "name", ",", "attrs", ")", ":", "schemaVersion", "=", "attrs", ".", "get", "(", "'schemaVersion'", ")", "validFrom", "=", "self", ".", "_parseDateTime", "(", "attrs", ".", "get", "(", "'from'", ")", ")", "validT...
Process the start of the top-level xtvd node
[ "Process", "the", "start", "of", "the", "top", "-", "level", "xtvd", "node" ]
e5aae988fad90217f72db45f93bf69839f4d75e7
https://github.com/dsoprea/PySchedules/blob/e5aae988fad90217f72db45f93bf69839f4d75e7/pyschedules/xml_callbacks.py#L68-L77
train
dsoprea/PySchedules
pyschedules/xml_callbacks.py
XmlCallbacks.startElement
def startElement(self, name, attrs): """Callback run at the start of each XML element""" self._contextStack.append(self._context) self._contentList = [] if name in self._statusDict: self._itemTag, itemType = self._statusDict[name] self._progress.startItem(itemTy...
python
def startElement(self, name, attrs): """Callback run at the start of each XML element""" self._contextStack.append(self._context) self._contentList = [] if name in self._statusDict: self._itemTag, itemType = self._statusDict[name] self._progress.startItem(itemTy...
[ "def", "startElement", "(", "self", ",", "name", ",", "attrs", ")", ":", "self", ".", "_contextStack", ".", "append", "(", "self", ".", "_context", ")", "self", ".", "_contentList", "=", "[", "]", "if", "name", "in", "self", ".", "_statusDict", ":", ...
Callback run at the start of each XML element
[ "Callback", "run", "at", "the", "start", "of", "each", "XML", "element" ]
e5aae988fad90217f72db45f93bf69839f4d75e7
https://github.com/dsoprea/PySchedules/blob/e5aae988fad90217f72db45f93bf69839f4d75e7/pyschedules/xml_callbacks.py#L289-L323
train
dsoprea/PySchedules
pyschedules/xml_callbacks.py
XmlCallbacks.endElement
def endElement(self, name): """Callback run at the end of each XML element""" content = ''.join(self._contentList) if name == 'xtvd': self._progress.endItems() else: try: if self._context == 'stations': self._endStationsNode(n...
python
def endElement(self, name): """Callback run at the end of each XML element""" content = ''.join(self._contentList) if name == 'xtvd': self._progress.endItems() else: try: if self._context == 'stations': self._endStationsNode(n...
[ "def", "endElement", "(", "self", ",", "name", ")", ":", "content", "=", "''", ".", "join", "(", "self", ".", "_contentList", ")", "if", "name", "==", "'xtvd'", ":", "self", ".", "_progress", ".", "endItems", "(", ")", "else", ":", "try", ":", "if"...
Callback run at the end of each XML element
[ "Callback", "run", "at", "the", "end", "of", "each", "XML", "element" ]
e5aae988fad90217f72db45f93bf69839f4d75e7
https://github.com/dsoprea/PySchedules/blob/e5aae988fad90217f72db45f93bf69839f4d75e7/pyschedules/xml_callbacks.py#L330-L355
train
dsoprea/PySchedules
pyschedules/xml_callbacks.py
XmlCallbacks.error
def error(self, msg): """Callback run when a recoverable parsing error occurs""" self._error = True self._progress.printMsg('XML parse error: %s' % msg, error=True)
python
def error(self, msg): """Callback run when a recoverable parsing error occurs""" self._error = True self._progress.printMsg('XML parse error: %s' % msg, error=True)
[ "def", "error", "(", "self", ",", "msg", ")", ":", "self", ".", "_error", "=", "True", "self", ".", "_progress", ".", "printMsg", "(", "'XML parse error: %s'", "%", "msg", ",", "error", "=", "True", ")" ]
Callback run when a recoverable parsing error occurs
[ "Callback", "run", "when", "a", "recoverable", "parsing", "error", "occurs" ]
e5aae988fad90217f72db45f93bf69839f4d75e7
https://github.com/dsoprea/PySchedules/blob/e5aae988fad90217f72db45f93bf69839f4d75e7/pyschedules/xml_callbacks.py#L357-L361
train
NaPs/Kolekto
kolekto/commands/link.py
format_all
def format_all(format_string, env): """ Format the input string using each possible combination of lists in the provided environment. Returns a list of formated strings. """ prepared_env = parse_pattern(format_string, env, lambda x, y: [FormatWrapper(x, z) for z in y]) # Generate each possible ...
python
def format_all(format_string, env): """ Format the input string using each possible combination of lists in the provided environment. Returns a list of formated strings. """ prepared_env = parse_pattern(format_string, env, lambda x, y: [FormatWrapper(x, z) for z in y]) # Generate each possible ...
[ "def", "format_all", "(", "format_string", ",", "env", ")", ":", "prepared_env", "=", "parse_pattern", "(", "format_string", ",", "env", ",", "lambda", "x", ",", "y", ":", "[", "FormatWrapper", "(", "x", ",", "z", ")", "for", "z", "in", "y", "]", ")"...
Format the input string using each possible combination of lists in the provided environment. Returns a list of formated strings.
[ "Format", "the", "input", "string", "using", "each", "possible", "combination", "of", "lists", "in", "the", "provided", "environment", ".", "Returns", "a", "list", "of", "formated", "strings", "." ]
29c5469da8782780a06bf9a76c59414bb6fd8fe3
https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/commands/link.py#L26-L36
train
tamasgal/km3pipe
km3pipe/utils/rba.py
RBAPrompt.preloop
def preloop(self): """Initialization before prompting user for commands. Despite the claims in the Cmd documentaion, Cmd.preloop() is not a stub """ Cmd.preloop(self) # sets up command completion self._hist = [] # No history yet self._locals = {} # Initialize ex...
python
def preloop(self): """Initialization before prompting user for commands. Despite the claims in the Cmd documentaion, Cmd.preloop() is not a stub """ Cmd.preloop(self) # sets up command completion self._hist = [] # No history yet self._locals = {} # Initialize ex...
[ "def", "preloop", "(", "self", ")", ":", "Cmd", ".", "preloop", "(", "self", ")", "self", ".", "_hist", "=", "[", "]", "self", ".", "_locals", "=", "{", "}", "self", ".", "_globals", "=", "{", "}" ]
Initialization before prompting user for commands. Despite the claims in the Cmd documentaion, Cmd.preloop() is not a stub
[ "Initialization", "before", "prompting", "user", "for", "commands", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/utils/rba.py#L46-L54
train
IRC-SPHERE/HyperStream
hyperstream/channels/base_channel.py
BaseChannel.execute_tool
def execute_tool(self, stream, interval): """ Executes the stream's tool over the given time interval :param stream: the stream reference :param interval: the time interval :return: None """ if interval.end > self.up_to_timestamp: raise ValueError( ...
python
def execute_tool(self, stream, interval): """ Executes the stream's tool over the given time interval :param stream: the stream reference :param interval: the time interval :return: None """ if interval.end > self.up_to_timestamp: raise ValueError( ...
[ "def", "execute_tool", "(", "self", ",", "stream", ",", "interval", ")", ":", "if", "interval", ".", "end", ">", "self", ".", "up_to_timestamp", ":", "raise", "ValueError", "(", "'The stream is not available after '", "+", "str", "(", "self", ".", "up_to_times...
Executes the stream's tool over the given time interval :param stream: the stream reference :param interval: the time interval :return: None
[ "Executes", "the", "stream", "s", "tool", "over", "the", "given", "time", "interval" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/channels/base_channel.py#L46-L65
train
IRC-SPHERE/HyperStream
hyperstream/channels/base_channel.py
BaseChannel.get_or_create_stream
def get_or_create_stream(self, stream_id, try_create=True): """ Helper function to get a stream or create one if it's not already defined :param stream_id: The stream id :param try_create: Whether to try to create the stream if not found :return: The stream object """ ...
python
def get_or_create_stream(self, stream_id, try_create=True): """ Helper function to get a stream or create one if it's not already defined :param stream_id: The stream id :param try_create: Whether to try to create the stream if not found :return: The stream object """ ...
[ "def", "get_or_create_stream", "(", "self", ",", "stream_id", ",", "try_create", "=", "True", ")", ":", "stream_id", "=", "get_stream_id", "(", "stream_id", ")", "if", "stream_id", "in", "self", ".", "streams", ":", "logging", ".", "debug", "(", "\"found {}\...
Helper function to get a stream or create one if it's not already defined :param stream_id: The stream id :param try_create: Whether to try to create the stream if not found :return: The stream object
[ "Helper", "function", "to", "get", "a", "stream", "or", "create", "one", "if", "it", "s", "not", "already", "defined" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/channels/base_channel.py#L76-L91
train
IRC-SPHERE/HyperStream
hyperstream/channels/base_channel.py
BaseChannel.find_streams
def find_streams(self, **kwargs): """ Finds streams with the given meta data values. Useful for debugging purposes. :param kwargs: The meta data as keyword arguments :return: The streams found """ found = {} if 'name' in kwargs: name = kwargs.pop('na...
python
def find_streams(self, **kwargs): """ Finds streams with the given meta data values. Useful for debugging purposes. :param kwargs: The meta data as keyword arguments :return: The streams found """ found = {} if 'name' in kwargs: name = kwargs.pop('na...
[ "def", "find_streams", "(", "self", ",", "**", "kwargs", ")", ":", "found", "=", "{", "}", "if", "'name'", "in", "kwargs", ":", "name", "=", "kwargs", ".", "pop", "(", "'name'", ")", "else", ":", "name", "=", "None", "for", "stream_id", ",", "strea...
Finds streams with the given meta data values. Useful for debugging purposes. :param kwargs: The meta data as keyword arguments :return: The streams found
[ "Finds", "streams", "with", "the", "given", "meta", "data", "values", ".", "Useful", "for", "debugging", "purposes", "." ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/channels/base_channel.py#L100-L121
train
IRC-SPHERE/HyperStream
hyperstream/channels/base_channel.py
BaseChannel.find_stream
def find_stream(self, **kwargs): """ Finds a single stream with the given meta data values. Useful for debugging purposes. :param kwargs: The meta data as keyword arguments :return: The stream found """ found = list(self.find_streams(**kwargs).values()) if not fo...
python
def find_stream(self, **kwargs): """ Finds a single stream with the given meta data values. Useful for debugging purposes. :param kwargs: The meta data as keyword arguments :return: The stream found """ found = list(self.find_streams(**kwargs).values()) if not fo...
[ "def", "find_stream", "(", "self", ",", "**", "kwargs", ")", ":", "found", "=", "list", "(", "self", ".", "find_streams", "(", "**", "kwargs", ")", ".", "values", "(", ")", ")", "if", "not", "found", ":", "raise", "StreamNotFoundError", "(", "kwargs", ...
Finds a single stream with the given meta data values. Useful for debugging purposes. :param kwargs: The meta data as keyword arguments :return: The stream found
[ "Finds", "a", "single", "stream", "with", "the", "given", "meta", "data", "values", ".", "Useful", "for", "debugging", "purposes", "." ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/channels/base_channel.py#L123-L135
train
tamasgal/km3pipe
km3pipe/io/daq.py
DAQPump.next_blob
def next_blob(self): """Get the next frame from file""" blob_file = self.blob_file try: preamble = DAQPreamble(file_obj=blob_file) except struct.error: raise StopIteration try: data_type = DATA_TYPES[preamble.data_type] except KeyError...
python
def next_blob(self): """Get the next frame from file""" blob_file = self.blob_file try: preamble = DAQPreamble(file_obj=blob_file) except struct.error: raise StopIteration try: data_type = DATA_TYPES[preamble.data_type] except KeyError...
[ "def", "next_blob", "(", "self", ")", ":", "blob_file", "=", "self", ".", "blob_file", "try", ":", "preamble", "=", "DAQPreamble", "(", "file_obj", "=", "blob_file", ")", "except", "struct", ".", "error", ":", "raise", "StopIteration", "try", ":", "data_ty...
Get the next frame from file
[ "Get", "the", "next", "frame", "from", "file" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/daq.py#L145-L179
train
tamasgal/km3pipe
km3pipe/io/daq.py
DAQPump.seek_to_frame
def seek_to_frame(self, index): """Move file pointer to the frame with given index.""" pointer_position = self.frame_positions[index] self.blob_file.seek(pointer_position, 0)
python
def seek_to_frame(self, index): """Move file pointer to the frame with given index.""" pointer_position = self.frame_positions[index] self.blob_file.seek(pointer_position, 0)
[ "def", "seek_to_frame", "(", "self", ",", "index", ")", ":", "pointer_position", "=", "self", ".", "frame_positions", "[", "index", "]", "self", ".", "blob_file", ".", "seek", "(", "pointer_position", ",", "0", ")" ]
Move file pointer to the frame with given index.
[ "Move", "file", "pointer", "to", "the", "frame", "with", "given", "index", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/daq.py#L181-L184
train
tamasgal/km3pipe
km3pipe/io/daq.py
DAQPreamble._parse_file
def _parse_file(self, file_obj): """Directly read from file handler. Note that this will move the file pointer. """ byte_data = file_obj.read(self.size) self._parse_byte_data(byte_data)
python
def _parse_file(self, file_obj): """Directly read from file handler. Note that this will move the file pointer. """ byte_data = file_obj.read(self.size) self._parse_byte_data(byte_data)
[ "def", "_parse_file", "(", "self", ",", "file_obj", ")", ":", "byte_data", "=", "file_obj", ".", "read", "(", "self", ".", "size", ")", "self", ".", "_parse_byte_data", "(", "byte_data", ")" ]
Directly read from file handler. Note that this will move the file pointer.
[ "Directly", "read", "from", "file", "handler", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/daq.py#L409-L416
train
tamasgal/km3pipe
km3pipe/io/daq.py
DAQSummaryslice._parse_summary_frames
def _parse_summary_frames(self, file_obj): """Iterate through the byte data and fill the summary_frames""" for _ in range(self.n_summary_frames): dom_id = unpack('<i', file_obj.read(4))[0] dq_status = file_obj.read(4) # probably dom status? # noqa dom_status = unpa...
python
def _parse_summary_frames(self, file_obj): """Iterate through the byte data and fill the summary_frames""" for _ in range(self.n_summary_frames): dom_id = unpack('<i', file_obj.read(4))[0] dq_status = file_obj.read(4) # probably dom status? # noqa dom_status = unpa...
[ "def", "_parse_summary_frames", "(", "self", ",", "file_obj", ")", ":", "for", "_", "in", "range", "(", "self", ".", "n_summary_frames", ")", ":", "dom_id", "=", "unpack", "(", "'<i'", ",", "file_obj", ".", "read", "(", "4", ")", ")", "[", "0", "]", ...
Iterate through the byte data and fill the summary_frames
[ "Iterate", "through", "the", "byte", "data", "and", "fill", "the", "summary_frames" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/daq.py#L499-L510
train
tamasgal/km3pipe
km3pipe/io/daq.py
DAQSummaryslice._get_rate
def _get_rate(self, value): """Return the rate in Hz from the short int value""" if value == 0: return 0 else: return MINIMAL_RATE_HZ * math.exp(value * self._get_factor())
python
def _get_rate(self, value): """Return the rate in Hz from the short int value""" if value == 0: return 0 else: return MINIMAL_RATE_HZ * math.exp(value * self._get_factor())
[ "def", "_get_rate", "(", "self", ",", "value", ")", ":", "if", "value", "==", "0", ":", "return", "0", "else", ":", "return", "MINIMAL_RATE_HZ", "*", "math", ".", "exp", "(", "value", "*", "self", ".", "_get_factor", "(", ")", ")" ]
Return the rate in Hz from the short int value
[ "Return", "the", "rate", "in", "Hz", "from", "the", "short", "int", "value" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/daq.py#L512-L517
train
tamasgal/km3pipe
km3pipe/io/daq.py
DAQEvent._parse_triggered_hits
def _parse_triggered_hits(self, file_obj): """Parse and store triggered hits.""" for _ in range(self.n_triggered_hits): dom_id, pmt_id = unpack('<ib', file_obj.read(5)) tdc_time = unpack('>I', file_obj.read(4))[0] tot = unpack('<b', file_obj.read(1))[0] tr...
python
def _parse_triggered_hits(self, file_obj): """Parse and store triggered hits.""" for _ in range(self.n_triggered_hits): dom_id, pmt_id = unpack('<ib', file_obj.read(5)) tdc_time = unpack('>I', file_obj.read(4))[0] tot = unpack('<b', file_obj.read(1))[0] tr...
[ "def", "_parse_triggered_hits", "(", "self", ",", "file_obj", ")", ":", "for", "_", "in", "range", "(", "self", ".", "n_triggered_hits", ")", ":", "dom_id", ",", "pmt_id", "=", "unpack", "(", "'<ib'", ",", "file_obj", ".", "read", "(", "5", ")", ")", ...
Parse and store triggered hits.
[ "Parse", "and", "store", "triggered", "hits", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/daq.py#L556-L565
train
tamasgal/km3pipe
km3pipe/io/daq.py
DAQEvent._parse_snapshot_hits
def _parse_snapshot_hits(self, file_obj): """Parse and store snapshot hits.""" for _ in range(self.n_snapshot_hits): dom_id, pmt_id = unpack('<ib', file_obj.read(5)) tdc_time = unpack('>I', file_obj.read(4))[0] tot = unpack('<b', file_obj.read(1))[0] self....
python
def _parse_snapshot_hits(self, file_obj): """Parse and store snapshot hits.""" for _ in range(self.n_snapshot_hits): dom_id, pmt_id = unpack('<ib', file_obj.read(5)) tdc_time = unpack('>I', file_obj.read(4))[0] tot = unpack('<b', file_obj.read(1))[0] self....
[ "def", "_parse_snapshot_hits", "(", "self", ",", "file_obj", ")", ":", "for", "_", "in", "range", "(", "self", ".", "n_snapshot_hits", ")", ":", "dom_id", ",", "pmt_id", "=", "unpack", "(", "'<ib'", ",", "file_obj", ".", "read", "(", "5", ")", ")", "...
Parse and store snapshot hits.
[ "Parse", "and", "store", "snapshot", "hits", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/daq.py#L567-L573
train
tamasgal/km3pipe
km3pipe/utils/runtable.py
runtable
def runtable(det_id, n=5, run_range=None, compact=False, sep='\t', regex=None): """Print the run table of the last `n` runs for given detector""" db = kp.db.DBManager() df = db.run_table(det_id) if run_range is not None: try: from_run, to_run = [int(r) for r in run_range.split('-')]...
python
def runtable(det_id, n=5, run_range=None, compact=False, sep='\t', regex=None): """Print the run table of the last `n` runs for given detector""" db = kp.db.DBManager() df = db.run_table(det_id) if run_range is not None: try: from_run, to_run = [int(r) for r in run_range.split('-')]...
[ "def", "runtable", "(", "det_id", ",", "n", "=", "5", ",", "run_range", "=", "None", ",", "compact", "=", "False", ",", "sep", "=", "'\\t'", ",", "regex", "=", "None", ")", ":", "db", "=", "kp", ".", "db", ".", "DBManager", "(", ")", "df", "=",...
Print the run table of the last `n` runs for given detector
[ "Print", "the", "run", "table", "of", "the", "last", "n", "runs", "for", "given", "detector" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/utils/runtable.py#L35-L65
train
tamasgal/km3pipe
km3modules/ahrs.py
_extract_calibration
def _extract_calibration(xroot): """Extract AHRS calibration information from XML root. Parameters ---------- xroot: XML root Returns ------- Aoff: numpy.array with shape(3,) Arot: numpy.array with shape(3,3) Hoff: numpy.array with shape(3,) Hrot: numpy.array with shape(3,3) ...
python
def _extract_calibration(xroot): """Extract AHRS calibration information from XML root. Parameters ---------- xroot: XML root Returns ------- Aoff: numpy.array with shape(3,) Arot: numpy.array with shape(3,3) Hoff: numpy.array with shape(3,) Hrot: numpy.array with shape(3,3) ...
[ "def", "_extract_calibration", "(", "xroot", ")", ":", "names", "=", "[", "c", ".", "text", "for", "c", "in", "xroot", ".", "findall", "(", "\".//Name\"", ")", "]", "val", "=", "[", "[", "i", ".", "text", "for", "i", "in", "c", "]", "for", "c", ...
Extract AHRS calibration information from XML root. Parameters ---------- xroot: XML root Returns ------- Aoff: numpy.array with shape(3,) Arot: numpy.array with shape(3,3) Hoff: numpy.array with shape(3,) Hrot: numpy.array with shape(3,3)
[ "Extract", "AHRS", "calibration", "information", "from", "XML", "root", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3modules/ahrs.py#L207-L256
train
tamasgal/km3pipe
km3modules/ahrs.py
AHRSCalibrator.calibrate
def calibrate(self): """Calculate yaw, pitch and roll from the median of A and H. After successful calibration, the `self.A` and `self.H` are reset. DOMs with missing AHRS pre-calibration data are skipped. Returns ------- dict: key=dom_id, value=tuple: (timestamp, du, f...
python
def calibrate(self): """Calculate yaw, pitch and roll from the median of A and H. After successful calibration, the `self.A` and `self.H` are reset. DOMs with missing AHRS pre-calibration data are skipped. Returns ------- dict: key=dom_id, value=tuple: (timestamp, du, f...
[ "def", "calibrate", "(", "self", ")", ":", "now", "=", "time", ".", "time", "(", ")", "dom_ids", "=", "self", ".", "A", ".", "keys", "(", ")", "print", "(", "\"Calibrating AHRS from median A and H for {} DOMs.\"", ".", "format", "(", "len", "(", "dom_ids",...
Calculate yaw, pitch and roll from the median of A and H. After successful calibration, the `self.A` and `self.H` are reset. DOMs with missing AHRS pre-calibration data are skipped. Returns ------- dict: key=dom_id, value=tuple: (timestamp, du, floor, yaw, pitch, roll)
[ "Calculate", "yaw", "pitch", "and", "roll", "from", "the", "median", "of", "A", "and", "H", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3modules/ahrs.py#L75-L109
train
NaPs/Kolekto
kolekto/commands/stats.py
humanize_filesize
def humanize_filesize(value): """ Return an humanized file size. """ value = float(value) if value == 1: return '1 Byte' elif value < 1024: return '%d Bytes' % value elif value < 1024: return '%dB' % value for i, s in enumerate(SUFFIXES): unit = 1024 ** (i ...
python
def humanize_filesize(value): """ Return an humanized file size. """ value = float(value) if value == 1: return '1 Byte' elif value < 1024: return '%d Bytes' % value elif value < 1024: return '%dB' % value for i, s in enumerate(SUFFIXES): unit = 1024 ** (i ...
[ "def", "humanize_filesize", "(", "value", ")", ":", "value", "=", "float", "(", "value", ")", "if", "value", "==", "1", ":", "return", "'1 Byte'", "elif", "value", "<", "1024", ":", "return", "'%d Bytes'", "%", "value", "elif", "value", "<", "1024", ":...
Return an humanized file size.
[ "Return", "an", "humanized", "file", "size", "." ]
29c5469da8782780a06bf9a76c59414bb6fd8fe3
https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/commands/stats.py#L14-L31
train
NaPs/Kolekto
kolekto/commands/stats.py
format_top
def format_top(counter, top=3): """ Format a top. """ items = islice(reversed(sorted(counter.iteritems(), key=lambda x: x[1])), 0, top) return u'; '.join(u'{g} ({nb})'.format(g=g, nb=nb) for g, nb in items)
python
def format_top(counter, top=3): """ Format a top. """ items = islice(reversed(sorted(counter.iteritems(), key=lambda x: x[1])), 0, top) return u'; '.join(u'{g} ({nb})'.format(g=g, nb=nb) for g, nb in items)
[ "def", "format_top", "(", "counter", ",", "top", "=", "3", ")", ":", "items", "=", "islice", "(", "reversed", "(", "sorted", "(", "counter", ".", "iteritems", "(", ")", ",", "key", "=", "lambda", "x", ":", "x", "[", "1", "]", ")", ")", ",", "0"...
Format a top.
[ "Format", "a", "top", "." ]
29c5469da8782780a06bf9a76c59414bb6fd8fe3
https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/commands/stats.py#L34-L38
train
IRC-SPHERE/HyperStream
hyperstream/utils/decorators.py
check_input_stream_count
def check_input_stream_count(expected_number_of_streams): """ Decorator for Tool._execute that checks the number of input streams :param expected_number_of_streams: The expected number of streams :return: the decorator """ def stream_count_decorator(func): def func_wrapper(*args, **kwa...
python
def check_input_stream_count(expected_number_of_streams): """ Decorator for Tool._execute that checks the number of input streams :param expected_number_of_streams: The expected number of streams :return: the decorator """ def stream_count_decorator(func): def func_wrapper(*args, **kwa...
[ "def", "check_input_stream_count", "(", "expected_number_of_streams", ")", ":", "def", "stream_count_decorator", "(", "func", ")", ":", "def", "func_wrapper", "(", "*", "args", ",", "**", "kwargs", ")", ":", "self", "=", "args", "[", "0", "]", "sources", "="...
Decorator for Tool._execute that checks the number of input streams :param expected_number_of_streams: The expected number of streams :return: the decorator
[ "Decorator", "for", "Tool", ".", "_execute", "that", "checks", "the", "number", "of", "input", "streams" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/utils/decorators.py#L69-L93
train
tamasgal/km3pipe
km3pipe/utils/ligiermirror.py
main
def main(): """The main script""" from docopt import docopt args = docopt(__doc__, version=kp.version) kp.logger.set_level("km3pipe", args['-d']) pipe = kp.Pipeline() pipe.attach( kp.io.ch.CHPump, host=args['SOURCE_IP'], port=int(args['-p']), tags=args['-m'], ...
python
def main(): """The main script""" from docopt import docopt args = docopt(__doc__, version=kp.version) kp.logger.set_level("km3pipe", args['-d']) pipe = kp.Pipeline() pipe.attach( kp.io.ch.CHPump, host=args['SOURCE_IP'], port=int(args['-p']), tags=args['-m'], ...
[ "def", "main", "(", ")", ":", "from", "docopt", "import", "docopt", "args", "=", "docopt", "(", "__doc__", ",", "version", "=", "kp", ".", "version", ")", "kp", ".", "logger", ".", "set_level", "(", "\"km3pipe\"", ",", "args", "[", "'-d'", "]", ")", ...
The main script
[ "The", "main", "script" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/utils/ligiermirror.py#L44-L61
train
nsfmc/swatch
swatch/__init__.py
parse
def parse(filename): """parses a .ase file and returns a list of colors and color groups `swatch.parse` reads in an ase file and converts it to a list of colors and palettes. colors are simple dicts of the form ```json { 'name': u'color name', 'type': u'Process', 'data': { ...
python
def parse(filename): """parses a .ase file and returns a list of colors and color groups `swatch.parse` reads in an ase file and converts it to a list of colors and palettes. colors are simple dicts of the form ```json { 'name': u'color name', 'type': u'Process', 'data': { ...
[ "def", "parse", "(", "filename", ")", ":", "with", "open", "(", "filename", ",", "\"rb\"", ")", "as", "data", ":", "header", ",", "v_major", ",", "v_minor", ",", "chunk_count", "=", "struct", ".", "unpack", "(", "\"!4sHHI\"", ",", "data", ".", "read", ...
parses a .ase file and returns a list of colors and color groups `swatch.parse` reads in an ase file and converts it to a list of colors and palettes. colors are simple dicts of the form ```json { 'name': u'color name', 'type': u'Process', 'data': { 'mode': u'RGB', ...
[ "parses", "a", ".", "ase", "file", "and", "returns", "a", "list", "of", "colors", "and", "color", "groups" ]
8654edf4f1aeef37d42211ff3fe6a3e9e4325859
https://github.com/nsfmc/swatch/blob/8654edf4f1aeef37d42211ff3fe6a3e9e4325859/swatch/__init__.py#L27-L106
train
nsfmc/swatch
swatch/__init__.py
dumps
def dumps(obj): """converts a swatch to bytes suitable for writing""" header = b'ASEF' v_major, v_minor = 1, 0 chunk_count = writer.chunk_count(obj) head = struct.pack('!4sHHI', header, v_major, v_minor, chunk_count) body = b''.join([writer.chunk_for_object(c) for c in obj]) return head + b...
python
def dumps(obj): """converts a swatch to bytes suitable for writing""" header = b'ASEF' v_major, v_minor = 1, 0 chunk_count = writer.chunk_count(obj) head = struct.pack('!4sHHI', header, v_major, v_minor, chunk_count) body = b''.join([writer.chunk_for_object(c) for c in obj]) return head + b...
[ "def", "dumps", "(", "obj", ")", ":", "header", "=", "b'ASEF'", "v_major", ",", "v_minor", "=", "1", ",", "0", "chunk_count", "=", "writer", ".", "chunk_count", "(", "obj", ")", "head", "=", "struct", ".", "pack", "(", "'!4sHHI'", ",", "header", ",",...
converts a swatch to bytes suitable for writing
[ "converts", "a", "swatch", "to", "bytes", "suitable", "for", "writing" ]
8654edf4f1aeef37d42211ff3fe6a3e9e4325859
https://github.com/nsfmc/swatch/blob/8654edf4f1aeef37d42211ff3fe6a3e9e4325859/swatch/__init__.py#L108-L116
train
PrefPy/prefpy
prefpy/preference.py
Preference.isFullPreferenceOrder
def isFullPreferenceOrder(self, candList): """ Returns True if the underlying weighted majority graph contains a comparision between every pair of candidate and returns False otherwise. :ivar list<int> candList: Contains integer representations of each candidate. """ # ...
python
def isFullPreferenceOrder(self, candList): """ Returns True if the underlying weighted majority graph contains a comparision between every pair of candidate and returns False otherwise. :ivar list<int> candList: Contains integer representations of each candidate. """ # ...
[ "def", "isFullPreferenceOrder", "(", "self", ",", "candList", ")", ":", "for", "cand1", "in", "candList", ":", "if", "cand1", "not", "in", "self", ".", "wmgMap", ".", "keys", "(", ")", ":", "return", "False", "for", "cand2", "in", "candList", ":", "if"...
Returns True if the underlying weighted majority graph contains a comparision between every pair of candidate and returns False otherwise. :ivar list<int> candList: Contains integer representations of each candidate.
[ "Returns", "True", "if", "the", "underlying", "weighted", "majority", "graph", "contains", "a", "comparision", "between", "every", "pair", "of", "candidate", "and", "returns", "False", "otherwise", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/preference.py#L21-L39
train
PrefPy/prefpy
prefpy/preference.py
Preference.containsTie
def containsTie(self): """ Returns True if the underlying weighted majority graph contains a tie between any pair of candidates and returns False otherwise. """ # If a value of 0 is present in the wmgMap, we assume that it represents a tie. for cand in self.wmgMap.keys()...
python
def containsTie(self): """ Returns True if the underlying weighted majority graph contains a tie between any pair of candidates and returns False otherwise. """ # If a value of 0 is present in the wmgMap, we assume that it represents a tie. for cand in self.wmgMap.keys()...
[ "def", "containsTie", "(", "self", ")", ":", "for", "cand", "in", "self", ".", "wmgMap", ".", "keys", "(", ")", ":", "if", "0", "in", "self", ".", "wmgMap", "[", "cand", "]", ".", "values", "(", ")", ":", "return", "True", "return", "False" ]
Returns True if the underlying weighted majority graph contains a tie between any pair of candidates and returns False otherwise.
[ "Returns", "True", "if", "the", "underlying", "weighted", "majority", "graph", "contains", "a", "tie", "between", "any", "pair", "of", "candidates", "and", "returns", "False", "otherwise", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/preference.py#L41-L51
train
PrefPy/prefpy
prefpy/preference.py
Preference.getIncEdgesMap
def getIncEdgesMap(self): """ Returns a dictionary that associates numbers of incoming edges in the weighted majority graph with the candidates that have that number of incoming edges. """ # We calculate the number of incoming edges for each candidate and store it into a diction...
python
def getIncEdgesMap(self): """ Returns a dictionary that associates numbers of incoming edges in the weighted majority graph with the candidates that have that number of incoming edges. """ # We calculate the number of incoming edges for each candidate and store it into a diction...
[ "def", "getIncEdgesMap", "(", "self", ")", ":", "incEdgesMap", "=", "dict", "(", ")", "for", "cand1", "in", "self", ".", "wmgMap", ".", "keys", "(", ")", ":", "incEdgesSum", "=", "0", "for", "cand2", "in", "self", ".", "wmgMap", "[", "cand1", "]", ...
Returns a dictionary that associates numbers of incoming edges in the weighted majority graph with the candidates that have that number of incoming edges.
[ "Returns", "a", "dictionary", "that", "associates", "numbers", "of", "incoming", "edges", "in", "the", "weighted", "majority", "graph", "with", "the", "candidates", "that", "have", "that", "number", "of", "incoming", "edges", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/preference.py#L53-L74
train
PrefPy/prefpy
prefpy/preference.py
Preference.getRankMap
def getRankMap(self): """ Returns a dictionary that associates the integer representation of each candidate with its position in the ranking, starting from 1. """ # We sort the candidates based on the number of incoming edges they have in the graph. If # two candidates ...
python
def getRankMap(self): """ Returns a dictionary that associates the integer representation of each candidate with its position in the ranking, starting from 1. """ # We sort the candidates based on the number of incoming edges they have in the graph. If # two candidates ...
[ "def", "getRankMap", "(", "self", ")", ":", "incEdgesMap", "=", "self", ".", "getIncEdgesMap", "(", ")", "sortedKeys", "=", "sorted", "(", "incEdgesMap", ".", "keys", "(", ")", ",", "reverse", "=", "True", ")", "rankMap", "=", "dict", "(", ")", "pos", ...
Returns a dictionary that associates the integer representation of each candidate with its position in the ranking, starting from 1.
[ "Returns", "a", "dictionary", "that", "associates", "the", "integer", "representation", "of", "each", "candidate", "with", "its", "position", "in", "the", "ranking", "starting", "from", "1", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/preference.py#L76-L93
train
PrefPy/prefpy
prefpy/preference.py
Preference.getReverseRankMap
def getReverseRankMap(self): """ Returns a dictionary that associates each position in the ranking with a list of integer representations of the candidates ranked at that position. """ # We sort the candidates based on the number of incoming edges they have in the graph...
python
def getReverseRankMap(self): """ Returns a dictionary that associates each position in the ranking with a list of integer representations of the candidates ranked at that position. """ # We sort the candidates based on the number of incoming edges they have in the graph...
[ "def", "getReverseRankMap", "(", "self", ")", ":", "incEdgesMap", "=", "self", ".", "getIncEdgesMap", "(", ")", "sortedKeys", "=", "sorted", "(", "incEdgesMap", ".", "keys", "(", ")", ",", "reverse", "=", "True", ")", "reverseRankMap", "=", "dict", "(", ...
Returns a dictionary that associates each position in the ranking with a list of integer representations of the candidates ranked at that position.
[ "Returns", "a", "dictionary", "that", "associates", "each", "position", "in", "the", "ranking", "with", "a", "list", "of", "integer", "representations", "of", "the", "candidates", "ranked", "at", "that", "position", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/preference.py#L95-L111
train
IRC-SPHERE/HyperStream
hyperstream/utils/statistics/histogram.py
histogram
def histogram(a, bins): """ Compute the histogram of a set of data. :param a: Input data :param bins: int or sequence of scalars or str, optional :type a: list | tuple :type bins: int | list[int] | list[str] :return: """ if any(map(lambda x: x < 0, diff(bins))): raise ValueE...
python
def histogram(a, bins): """ Compute the histogram of a set of data. :param a: Input data :param bins: int or sequence of scalars or str, optional :type a: list | tuple :type bins: int | list[int] | list[str] :return: """ if any(map(lambda x: x < 0, diff(bins))): raise ValueE...
[ "def", "histogram", "(", "a", ",", "bins", ")", ":", "if", "any", "(", "map", "(", "lambda", "x", ":", "x", "<", "0", ",", "diff", "(", "bins", ")", ")", ")", ":", "raise", "ValueError", "(", "'bins must increase monotonically.'", ")", "try", ":", ...
Compute the histogram of a set of data. :param a: Input data :param bins: int or sequence of scalars or str, optional :type a: list | tuple :type bins: int | list[int] | list[str] :return:
[ "Compute", "the", "histogram", "of", "a", "set", "of", "data", "." ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/utils/statistics/histogram.py#L68-L115
train
tamasgal/km3pipe
km3pipe/logger.py
deprecation
def deprecation(self, message, *args, **kws): """Show a deprecation warning.""" self._log(DEPRECATION, message, args, **kws)
python
def deprecation(self, message, *args, **kws): """Show a deprecation warning.""" self._log(DEPRECATION, message, args, **kws)
[ "def", "deprecation", "(", "self", ",", "message", ",", "*", "args", ",", "**", "kws", ")", ":", "self", ".", "_log", "(", "DEPRECATION", ",", "message", ",", "args", ",", "**", "kws", ")" ]
Show a deprecation warning.
[ "Show", "a", "deprecation", "warning", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/logger.py#L33-L35
train
tamasgal/km3pipe
km3pipe/logger.py
once
def once(self, message, *args, **kws): """Show a message only once, determined by position in source or identifer. This will not work in IPython or Jupyter notebooks if no identifier is specified, since then the determined position in source contains the execution number of the input (cell), which chan...
python
def once(self, message, *args, **kws): """Show a message only once, determined by position in source or identifer. This will not work in IPython or Jupyter notebooks if no identifier is specified, since then the determined position in source contains the execution number of the input (cell), which chan...
[ "def", "once", "(", "self", ",", "message", ",", "*", "args", ",", "**", "kws", ")", ":", "identifier", "=", "kws", ".", "pop", "(", "'identifier'", ",", "None", ")", "if", "identifier", "is", "None", ":", "caller", "=", "getframeinfo", "(", "stack",...
Show a message only once, determined by position in source or identifer. This will not work in IPython or Jupyter notebooks if no identifier is specified, since then the determined position in source contains the execution number of the input (cell), which changes every time. Set a unique identifier, o...
[ "Show", "a", "message", "only", "once", "determined", "by", "position", "in", "source", "or", "identifer", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/logger.py#L38-L59
train
tamasgal/km3pipe
km3pipe/logger.py
get_logger
def get_logger(name): """Helper function to get a logger""" if name in loggers: return loggers[name] logger = logging.getLogger(name) logger.propagate = False pre1, suf1 = hash_coloured_escapes(name) if supports_color() else ('', '') pre2, suf2 = hash_coloured_escapes(name + 'salt') \ ...
python
def get_logger(name): """Helper function to get a logger""" if name in loggers: return loggers[name] logger = logging.getLogger(name) logger.propagate = False pre1, suf1 = hash_coloured_escapes(name) if supports_color() else ('', '') pre2, suf2 = hash_coloured_escapes(name + 'salt') \ ...
[ "def", "get_logger", "(", "name", ")", ":", "if", "name", "in", "loggers", ":", "return", "loggers", "[", "name", "]", "logger", "=", "logging", ".", "getLogger", "(", "name", ")", "logger", ".", "propagate", "=", "False", "pre1", ",", "suf1", "=", "...
Helper function to get a logger
[ "Helper", "function", "to", "get", "a", "logger" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/logger.py#L119-L139
train
tamasgal/km3pipe
km3pipe/logger.py
get_printer
def get_printer(name, color=None, ansi_code=None, force_color=False): """Return a function which prints a message with a coloured name prefix""" if force_color or supports_color(): if color is None and ansi_code is None: cpre_1, csuf_1 = hash_coloured_escapes(name) cpre_2, csuf_...
python
def get_printer(name, color=None, ansi_code=None, force_color=False): """Return a function which prints a message with a coloured name prefix""" if force_color or supports_color(): if color is None and ansi_code is None: cpre_1, csuf_1 = hash_coloured_escapes(name) cpre_2, csuf_...
[ "def", "get_printer", "(", "name", ",", "color", "=", "None", ",", "ansi_code", "=", "None", ",", "force_color", "=", "False", ")", ":", "if", "force_color", "or", "supports_color", "(", ")", ":", "if", "color", "is", "None", "and", "ansi_code", "is", ...
Return a function which prints a message with a coloured name prefix
[ "Return", "a", "function", "which", "prints", "a", "message", "with", "a", "coloured", "name", "prefix" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/logger.py#L152-L168
train
tamasgal/km3pipe
km3pipe/logger.py
hash_coloured
def hash_coloured(text): """Return a ANSI coloured text based on its hash""" ansi_code = int(sha256(text.encode('utf-8')).hexdigest(), 16) % 230 return colored(text, ansi_code=ansi_code)
python
def hash_coloured(text): """Return a ANSI coloured text based on its hash""" ansi_code = int(sha256(text.encode('utf-8')).hexdigest(), 16) % 230 return colored(text, ansi_code=ansi_code)
[ "def", "hash_coloured", "(", "text", ")", ":", "ansi_code", "=", "int", "(", "sha256", "(", "text", ".", "encode", "(", "'utf-8'", ")", ")", ".", "hexdigest", "(", ")", ",", "16", ")", "%", "230", "return", "colored", "(", "text", ",", "ansi_code", ...
Return a ANSI coloured text based on its hash
[ "Return", "a", "ANSI", "coloured", "text", "based", "on", "its", "hash" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/logger.py#L171-L174
train
tamasgal/km3pipe
km3pipe/logger.py
hash_coloured_escapes
def hash_coloured_escapes(text): """Return the ANSI hash colour prefix and suffix for a given text""" ansi_code = int(sha256(text.encode('utf-8')).hexdigest(), 16) % 230 prefix, suffix = colored('SPLIT', ansi_code=ansi_code).split('SPLIT') return prefix, suffix
python
def hash_coloured_escapes(text): """Return the ANSI hash colour prefix and suffix for a given text""" ansi_code = int(sha256(text.encode('utf-8')).hexdigest(), 16) % 230 prefix, suffix = colored('SPLIT', ansi_code=ansi_code).split('SPLIT') return prefix, suffix
[ "def", "hash_coloured_escapes", "(", "text", ")", ":", "ansi_code", "=", "int", "(", "sha256", "(", "text", ".", "encode", "(", "'utf-8'", ")", ")", ".", "hexdigest", "(", ")", ",", "16", ")", "%", "230", "prefix", ",", "suffix", "=", "colored", "(",...
Return the ANSI hash colour prefix and suffix for a given text
[ "Return", "the", "ANSI", "hash", "colour", "prefix", "and", "suffix", "for", "a", "given", "text" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/logger.py#L177-L181
train
tamasgal/km3pipe
km3pipe/time.py
tai_timestamp
def tai_timestamp(): """Return current TAI timestamp.""" timestamp = time.time() date = datetime.utcfromtimestamp(timestamp) if date.year < 1972: return timestamp offset = 10 + timestamp leap_seconds = [ (1972, 1, 1), (1972, 7, 1), (1973, 1, 1), (1974, 1, ...
python
def tai_timestamp(): """Return current TAI timestamp.""" timestamp = time.time() date = datetime.utcfromtimestamp(timestamp) if date.year < 1972: return timestamp offset = 10 + timestamp leap_seconds = [ (1972, 1, 1), (1972, 7, 1), (1973, 1, 1), (1974, 1, ...
[ "def", "tai_timestamp", "(", ")", ":", "timestamp", "=", "time", ".", "time", "(", ")", "date", "=", "datetime", ".", "utcfromtimestamp", "(", "timestamp", ")", "if", "date", ".", "year", "<", "1972", ":", "return", "timestamp", "offset", "=", "10", "+...
Return current TAI timestamp.
[ "Return", "current", "TAI", "timestamp", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/time.py#L102-L142
train
tamasgal/km3pipe
km3pipe/time.py
Cuckoo.msg
def msg(self, *args, **kwargs): "Only execute callback when interval is reached." if self.timestamp is None or self._interval_reached(): self.callback(*args, **kwargs) self.reset()
python
def msg(self, *args, **kwargs): "Only execute callback when interval is reached." if self.timestamp is None or self._interval_reached(): self.callback(*args, **kwargs) self.reset()
[ "def", "msg", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "\"Only execute callback when interval is reached.\"", "if", "self", ".", "timestamp", "is", "None", "or", "self", ".", "_interval_reached", "(", ")", ":", "self", ".", "callback", "...
Only execute callback when interval is reached.
[ "Only", "execute", "callback", "when", "interval", "is", "reached", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/time.py#L83-L87
train
thebigmunch/google-music-utils
src/google_music_utils/compare.py
_gather_field_values
def _gather_field_values( item, *, fields=None, field_map=FIELD_MAP, normalize_values=False, normalize_func=normalize_value): """Create a tuple of normalized metadata field values. Parameter: item (~collections.abc.Mapping, str, os.PathLike): Item dict or filepath. fields (list): A list of fields used to compa...
python
def _gather_field_values( item, *, fields=None, field_map=FIELD_MAP, normalize_values=False, normalize_func=normalize_value): """Create a tuple of normalized metadata field values. Parameter: item (~collections.abc.Mapping, str, os.PathLike): Item dict or filepath. fields (list): A list of fields used to compa...
[ "def", "_gather_field_values", "(", "item", ",", "*", ",", "fields", "=", "None", ",", "field_map", "=", "FIELD_MAP", ",", "normalize_values", "=", "False", ",", "normalize_func", "=", "normalize_value", ")", ":", "it", "=", "get_item_tags", "(", "item", ")"...
Create a tuple of normalized metadata field values. Parameter: item (~collections.abc.Mapping, str, os.PathLike): Item dict or filepath. fields (list): A list of fields used to compare item dicts. field_map (~collections.abc.Mapping): A mapping field name aliases. Default: :data:`~google_music_utils.constant...
[ "Create", "a", "tuple", "of", "normalized", "metadata", "field", "values", "." ]
2e8873defe7d5aab7321b9d5ec8a80d72687578e
https://github.com/thebigmunch/google-music-utils/blob/2e8873defe7d5aab7321b9d5ec8a80d72687578e/src/google_music_utils/compare.py#L12-L50
train
thebigmunch/google-music-utils
src/google_music_utils/compare.py
find_existing_items
def find_existing_items( src, dst, *, fields=None, field_map=None, normalize_values=False, normalize_func=normalize_value): """Find items from an item collection that are in another item collection. Parameters: src (list): A list of item dicts or filepaths. dst (list): A list of item dicts or filepaths. fiel...
python
def find_existing_items( src, dst, *, fields=None, field_map=None, normalize_values=False, normalize_func=normalize_value): """Find items from an item collection that are in another item collection. Parameters: src (list): A list of item dicts or filepaths. dst (list): A list of item dicts or filepaths. fiel...
[ "def", "find_existing_items", "(", "src", ",", "dst", ",", "*", ",", "fields", "=", "None", ",", "field_map", "=", "None", ",", "normalize_values", "=", "False", ",", "normalize_func", "=", "normalize_value", ")", ":", "if", "field_map", "is", "None", ":",...
Find items from an item collection that are in another item collection. Parameters: src (list): A list of item dicts or filepaths. dst (list): A list of item dicts or filepaths. fields (list): A list of fields used to compare item dicts. field_map (~collections.abc.Mapping): A mapping field name aliases. D...
[ "Find", "items", "from", "an", "item", "collection", "that", "are", "in", "another", "item", "collection", "." ]
2e8873defe7d5aab7321b9d5ec8a80d72687578e
https://github.com/thebigmunch/google-music-utils/blob/2e8873defe7d5aab7321b9d5ec8a80d72687578e/src/google_music_utils/compare.py#L53-L89
train
IRC-SPHERE/HyperStream
hyperstream/utils/hyperstream_logger.py
monitor
def monitor(self, message, *args, **kws): """ Define a monitoring logger that will be added to Logger :param self: The logging object :param message: The logging message :param args: Positional arguments :param kws: Keyword arguments :return: """ if self.isEnabledFor(MON): #...
python
def monitor(self, message, *args, **kws): """ Define a monitoring logger that will be added to Logger :param self: The logging object :param message: The logging message :param args: Positional arguments :param kws: Keyword arguments :return: """ if self.isEnabledFor(MON): #...
[ "def", "monitor", "(", "self", ",", "message", ",", "*", "args", ",", "**", "kws", ")", ":", "if", "self", ".", "isEnabledFor", "(", "MON", ")", ":", "self", ".", "_log", "(", "MON", ",", "message", ",", "args", ",", "**", "kws", ")" ]
Define a monitoring logger that will be added to Logger :param self: The logging object :param message: The logging message :param args: Positional arguments :param kws: Keyword arguments :return:
[ "Define", "a", "monitoring", "logger", "that", "will", "be", "added", "to", "Logger" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/utils/hyperstream_logger.py#L160-L172
train
IRC-SPHERE/HyperStream
hyperstream/utils/hyperstream_logger.py
monitor
def monitor(msg, *args, **kwargs): """ Log a message with severity 'MON' on the root logger. """ if len(logging.root.handlers) == 0: logging.basicConfig() logging.root.monitor(msg, *args, **kwargs)
python
def monitor(msg, *args, **kwargs): """ Log a message with severity 'MON' on the root logger. """ if len(logging.root.handlers) == 0: logging.basicConfig() logging.root.monitor(msg, *args, **kwargs)
[ "def", "monitor", "(", "msg", ",", "*", "args", ",", "**", "kwargs", ")", ":", "if", "len", "(", "logging", ".", "root", ".", "handlers", ")", "==", "0", ":", "logging", ".", "basicConfig", "(", ")", "logging", ".", "root", ".", "monitor", "(", "...
Log a message with severity 'MON' on the root logger.
[ "Log", "a", "message", "with", "severity", "MON", "on", "the", "root", "logger", "." ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/utils/hyperstream_logger.py#L178-L184
train
IRC-SPHERE/HyperStream
hyperstream/utils/hyperstream_logger.py
SenMLFormatter.format
def format(self, record): """ The formatting function :param record: The record object :return: The string representation of the record """ try: n = record.n except AttributeError: n = 'default' try: message = record....
python
def format(self, record): """ The formatting function :param record: The record object :return: The string representation of the record """ try: n = record.n except AttributeError: n = 'default' try: message = record....
[ "def", "format", "(", "self", ",", "record", ")", ":", "try", ":", "n", "=", "record", ".", "n", "except", "AttributeError", ":", "n", "=", "'default'", "try", ":", "message", "=", "record", ".", "message", "except", "AttributeError", ":", "message", "...
The formatting function :param record: The record object :return: The string representation of the record
[ "The", "formatting", "function" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/utils/hyperstream_logger.py#L197-L222
train
wtsi-hgi/consul-lock
consullock/managers.py
ConsulLockManager.teardown
def teardown(self): """ Tears down the instance, removing any remaining sessions that this instance has created. The instance must not be used after this method has been called. """ with self._teardown_lock: if not self._teardown_called: self._teardow...
python
def teardown(self): """ Tears down the instance, removing any remaining sessions that this instance has created. The instance must not be used after this method has been called. """ with self._teardown_lock: if not self._teardown_called: self._teardow...
[ "def", "teardown", "(", "self", ")", ":", "with", "self", ".", "_teardown_lock", ":", "if", "not", "self", ".", "_teardown_called", ":", "self", ".", "_teardown_called", "=", "True", "if", "len", "(", "self", ".", "_acquiring_session_ids", ")", ">", "0", ...
Tears down the instance, removing any remaining sessions that this instance has created. The instance must not be used after this method has been called.
[ "Tears", "down", "the", "instance", "removing", "any", "remaining", "sessions", "that", "this", "instance", "has", "created", "." ]
deb07ab41dabbb49f4d0bbc062bc3b4b6e5d71b2
https://github.com/wtsi-hgi/consul-lock/blob/deb07ab41dabbb49f4d0bbc062bc3b4b6e5d71b2/consullock/managers.py#L356-L375
train
tamasgal/km3pipe
km3pipe/db.py
we_are_in_lyon
def we_are_in_lyon(): """Check if we are on a Lyon machine""" import socket try: hostname = socket.gethostname() ip = socket.gethostbyname(hostname) except socket.gaierror: return False return ip.startswith("134.158.")
python
def we_are_in_lyon(): """Check if we are on a Lyon machine""" import socket try: hostname = socket.gethostname() ip = socket.gethostbyname(hostname) except socket.gaierror: return False return ip.startswith("134.158.")
[ "def", "we_are_in_lyon", "(", ")", ":", "import", "socket", "try", ":", "hostname", "=", "socket", ".", "gethostname", "(", ")", "ip", "=", "socket", ".", "gethostbyname", "(", "hostname", ")", "except", "socket", ".", "gaierror", ":", "return", "False", ...
Check if we are on a Lyon machine
[ "Check", "if", "we", "are", "on", "a", "Lyon", "machine" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L62-L70
train
tamasgal/km3pipe
km3pipe/db.py
read_csv
def read_csv(text, sep="\t"): """Create a DataFrame from CSV text""" import pandas as pd # no top level load to make a faster import of db return pd.read_csv(StringIO(text), sep="\t")
python
def read_csv(text, sep="\t"): """Create a DataFrame from CSV text""" import pandas as pd # no top level load to make a faster import of db return pd.read_csv(StringIO(text), sep="\t")
[ "def", "read_csv", "(", "text", ",", "sep", "=", "\"\\t\"", ")", ":", "import", "pandas", "as", "pd", "return", "pd", ".", "read_csv", "(", "StringIO", "(", "text", ")", ",", "sep", "=", "\"\\t\"", ")" ]
Create a DataFrame from CSV text
[ "Create", "a", "DataFrame", "from", "CSV", "text" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L73-L76
train
tamasgal/km3pipe
km3pipe/db.py
add_datetime
def add_datetime(dataframe, timestamp_key='UNIXTIME'): """Add an additional DATETIME column with standar datetime format. This currently manipulates the incoming DataFrame! """ def convert_data(timestamp): return datetime.fromtimestamp(float(timestamp) / 1e3, UTC_TZ) try: log.debu...
python
def add_datetime(dataframe, timestamp_key='UNIXTIME'): """Add an additional DATETIME column with standar datetime format. This currently manipulates the incoming DataFrame! """ def convert_data(timestamp): return datetime.fromtimestamp(float(timestamp) / 1e3, UTC_TZ) try: log.debu...
[ "def", "add_datetime", "(", "dataframe", ",", "timestamp_key", "=", "'UNIXTIME'", ")", ":", "def", "convert_data", "(", "timestamp", ")", ":", "return", "datetime", ".", "fromtimestamp", "(", "float", "(", "timestamp", ")", "/", "1e3", ",", "UTC_TZ", ")", ...
Add an additional DATETIME column with standar datetime format. This currently manipulates the incoming DataFrame!
[ "Add", "an", "additional", "DATETIME", "column", "with", "standar", "datetime", "format", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L488-L502
train
tamasgal/km3pipe
km3pipe/db.py
show_ahrs_calibration
def show_ahrs_calibration(clb_upi, version='3'): """Show AHRS calibration data for given `clb_upi`.""" db = DBManager() ahrs_upi = clbupi2ahrsupi(clb_upi) print("AHRS UPI: {}".format(ahrs_upi)) content = db._get_content("show_product_test.htm?upi={0}&" "testtype=AHRS-CA...
python
def show_ahrs_calibration(clb_upi, version='3'): """Show AHRS calibration data for given `clb_upi`.""" db = DBManager() ahrs_upi = clbupi2ahrsupi(clb_upi) print("AHRS UPI: {}".format(ahrs_upi)) content = db._get_content("show_product_test.htm?upi={0}&" "testtype=AHRS-CA...
[ "def", "show_ahrs_calibration", "(", "clb_upi", ",", "version", "=", "'3'", ")", ":", "db", "=", "DBManager", "(", ")", "ahrs_upi", "=", "clbupi2ahrsupi", "(", "clb_upi", ")", "print", "(", "\"AHRS UPI: {}\"", ".", "format", "(", "ahrs_upi", ")", ")", "con...
Show AHRS calibration data for given `clb_upi`.
[ "Show", "AHRS", "calibration", "data", "for", "given", "clb_upi", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L826-L848
train
tamasgal/km3pipe
km3pipe/db.py
DBManager._datalog
def _datalog(self, parameter, run, maxrun, det_id): "Extract data from database" values = { 'parameter_name': parameter, 'minrun': run, 'maxrun': maxrun, 'detid': det_id, } data = urlencode(values) content = self._get_content('strea...
python
def _datalog(self, parameter, run, maxrun, det_id): "Extract data from database" values = { 'parameter_name': parameter, 'minrun': run, 'maxrun': maxrun, 'detid': det_id, } data = urlencode(values) content = self._get_content('strea...
[ "def", "_datalog", "(", "self", ",", "parameter", ",", "run", ",", "maxrun", ",", "det_id", ")", ":", "\"Extract data from database\"", "values", "=", "{", "'parameter_name'", ":", "parameter", ",", "'minrun'", ":", "run", ",", "'maxrun'", ":", "maxrun", ","...
Extract data from database
[ "Extract", "data", "from", "database" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L134-L162
train
tamasgal/km3pipe
km3pipe/db.py
DBManager._add_converted_units
def _add_converted_units(self, dataframe, parameter, key='VALUE'): """Add an additional DATA_VALUE column with converted VALUEs""" convert_unit = self.parameters.get_converter(parameter) try: log.debug("Adding unit converted DATA_VALUE to the data") dataframe[key] = dataf...
python
def _add_converted_units(self, dataframe, parameter, key='VALUE'): """Add an additional DATA_VALUE column with converted VALUEs""" convert_unit = self.parameters.get_converter(parameter) try: log.debug("Adding unit converted DATA_VALUE to the data") dataframe[key] = dataf...
[ "def", "_add_converted_units", "(", "self", ",", "dataframe", ",", "parameter", ",", "key", "=", "'VALUE'", ")", ":", "convert_unit", "=", "self", ".", "parameters", ".", "get_converter", "(", "parameter", ")", "try", ":", "log", ".", "debug", "(", "\"Addi...
Add an additional DATA_VALUE column with converted VALUEs
[ "Add", "an", "additional", "DATA_VALUE", "column", "with", "converted", "VALUEs" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L178-L187
train
tamasgal/km3pipe
km3pipe/db.py
DBManager.to_det_id
def to_det_id(self, det_id_or_det_oid): """Convert det ID or OID to det ID""" try: int(det_id_or_det_oid) except ValueError: return self.get_det_id(det_id_or_det_oid) else: return det_id_or_det_oid
python
def to_det_id(self, det_id_or_det_oid): """Convert det ID or OID to det ID""" try: int(det_id_or_det_oid) except ValueError: return self.get_det_id(det_id_or_det_oid) else: return det_id_or_det_oid
[ "def", "to_det_id", "(", "self", ",", "det_id_or_det_oid", ")", ":", "try", ":", "int", "(", "det_id_or_det_oid", ")", "except", "ValueError", ":", "return", "self", ".", "get_det_id", "(", "det_id_or_det_oid", ")", "else", ":", "return", "det_id_or_det_oid" ]
Convert det ID or OID to det ID
[ "Convert", "det", "ID", "or", "OID", "to", "det", "ID" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L223-L230
train
tamasgal/km3pipe
km3pipe/db.py
DBManager.to_det_oid
def to_det_oid(self, det_id_or_det_oid): """Convert det OID or ID to det OID""" try: int(det_id_or_det_oid) except ValueError: return det_id_or_det_oid else: return self.get_det_oid(det_id_or_det_oid)
python
def to_det_oid(self, det_id_or_det_oid): """Convert det OID or ID to det OID""" try: int(det_id_or_det_oid) except ValueError: return det_id_or_det_oid else: return self.get_det_oid(det_id_or_det_oid)
[ "def", "to_det_oid", "(", "self", ",", "det_id_or_det_oid", ")", ":", "try", ":", "int", "(", "det_id_or_det_oid", ")", "except", "ValueError", ":", "return", "det_id_or_det_oid", "else", ":", "return", "self", ".", "get_det_oid", "(", "det_id_or_det_oid", ")" ]
Convert det OID or ID to det OID
[ "Convert", "det", "OID", "or", "ID", "to", "det", "OID" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L232-L239
train
tamasgal/km3pipe
km3pipe/db.py
DBManager._load_parameters
def _load_parameters(self): "Retrieve a list of available parameters from the database" parameters = self._get_json('allparam/s') data = {} for parameter in parameters: # There is a case-chaos in the DB data[parameter['Name'].lower()] = parameter self._parameters =...
python
def _load_parameters(self): "Retrieve a list of available parameters from the database" parameters = self._get_json('allparam/s') data = {} for parameter in parameters: # There is a case-chaos in the DB data[parameter['Name'].lower()] = parameter self._parameters =...
[ "def", "_load_parameters", "(", "self", ")", ":", "\"Retrieve a list of available parameters from the database\"", "parameters", "=", "self", ".", "_get_json", "(", "'allparam/s'", ")", "data", "=", "{", "}", "for", "parameter", "in", "parameters", ":", "data", "[",...
Retrieve a list of available parameters from the database
[ "Retrieve", "a", "list", "of", "available", "parameters", "from", "the", "database" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L248-L254
train
tamasgal/km3pipe
km3pipe/db.py
DBManager.trigger_setup
def trigger_setup(self, runsetup_oid): "Retrieve the trigger setup for a given runsetup OID" r = self._get_content( "jsonds/rslite/s?rs_oid={}&upifilter=1.1.2.2.3/*". format(runsetup_oid) ) data = json.loads(r)['Data'] if not data: log.error("E...
python
def trigger_setup(self, runsetup_oid): "Retrieve the trigger setup for a given runsetup OID" r = self._get_content( "jsonds/rslite/s?rs_oid={}&upifilter=1.1.2.2.3/*". format(runsetup_oid) ) data = json.loads(r)['Data'] if not data: log.error("E...
[ "def", "trigger_setup", "(", "self", ",", "runsetup_oid", ")", ":", "\"Retrieve the trigger setup for a given runsetup OID\"", "r", "=", "self", ".", "_get_content", "(", "\"jsonds/rslite/s?rs_oid={}&upifilter=1.1.2.2.3/*\"", ".", "format", "(", "runsetup_oid", ")", ")", ...
Retrieve the trigger setup for a given runsetup OID
[ "Retrieve", "the", "trigger", "setup", "for", "a", "given", "runsetup", "OID" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L256-L298
train
tamasgal/km3pipe
km3pipe/db.py
DBManager.detx
def detx(self, det_id, t0set=None, calibration=None): """Retrieve the detector file for given detector id If t0set is given, append the calibration data. """ url = 'detx/{0}?'.format(det_id) # '?' since it's ignored if no args if t0set is not None: url += '&t0set=...
python
def detx(self, det_id, t0set=None, calibration=None): """Retrieve the detector file for given detector id If t0set is given, append the calibration data. """ url = 'detx/{0}?'.format(det_id) # '?' since it's ignored if no args if t0set is not None: url += '&t0set=...
[ "def", "detx", "(", "self", ",", "det_id", ",", "t0set", "=", "None", ",", "calibration", "=", "None", ")", ":", "url", "=", "'detx/{0}?'", ".", "format", "(", "det_id", ")", "if", "t0set", "is", "not", "None", ":", "url", "+=", "'&t0set='", "+", "...
Retrieve the detector file for given detector id If t0set is given, append the calibration data.
[ "Retrieve", "the", "detector", "file", "for", "given", "detector", "id" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L311-L323
train
tamasgal/km3pipe
km3pipe/db.py
DBManager._get_json
def _get_json(self, url): "Get JSON-type content" content = self._get_content('jsonds/' + url) try: json_content = json.loads(content.decode()) except AttributeError: json_content = json.loads(content) if json_content['Comment']: log.warning(js...
python
def _get_json(self, url): "Get JSON-type content" content = self._get_content('jsonds/' + url) try: json_content = json.loads(content.decode()) except AttributeError: json_content = json.loads(content) if json_content['Comment']: log.warning(js...
[ "def", "_get_json", "(", "self", ",", "url", ")", ":", "\"Get JSON-type content\"", "content", "=", "self", ".", "_get_content", "(", "'jsonds/'", "+", "url", ")", "try", ":", "json_content", "=", "json", ".", "loads", "(", "content", ".", "decode", "(", ...
Get JSON-type content
[ "Get", "JSON", "-", "type", "content" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L356-L367
train
tamasgal/km3pipe
km3pipe/db.py
DBManager._get_content
def _get_content(self, url): "Get HTML content" target_url = self._db_url + '/' + unquote(url) # .encode('utf-8')) log.debug("Opening '{0}'".format(target_url)) try: f = self.opener.open(target_url) except HTTPError as e: log.error("HTTP error, your ses...
python
def _get_content(self, url): "Get HTML content" target_url = self._db_url + '/' + unquote(url) # .encode('utf-8')) log.debug("Opening '{0}'".format(target_url)) try: f = self.opener.open(target_url) except HTTPError as e: log.error("HTTP error, your ses...
[ "def", "_get_content", "(", "self", ",", "url", ")", ":", "\"Get HTML content\"", "target_url", "=", "self", ".", "_db_url", "+", "'/'", "+", "unquote", "(", "url", ")", "log", ".", "debug", "(", "\"Opening '{0}'\"", ".", "format", "(", "target_url", ")", ...
Get HTML content
[ "Get", "HTML", "content" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L369-L393
train
tamasgal/km3pipe
km3pipe/db.py
DBManager.opener
def opener(self): "A reusable connection manager" if self._opener is None: log.debug("Creating connection handler") opener = build_opener() if self._cookies: log.debug("Appending cookies") else: log.debug("No cookies to appe...
python
def opener(self): "A reusable connection manager" if self._opener is None: log.debug("Creating connection handler") opener = build_opener() if self._cookies: log.debug("Appending cookies") else: log.debug("No cookies to appe...
[ "def", "opener", "(", "self", ")", ":", "\"A reusable connection manager\"", "if", "self", ".", "_opener", "is", "None", ":", "log", ".", "debug", "(", "\"Creating connection handler\"", ")", "opener", "=", "build_opener", "(", ")", "if", "self", ".", "_cookie...
A reusable connection manager
[ "A", "reusable", "connection", "manager" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L396-L411
train
tamasgal/km3pipe
km3pipe/db.py
DBManager.request_sid_cookie
def request_sid_cookie(self, username, password): """Request cookie for permanent session token.""" log.debug("Requesting SID cookie") target_url = self._login_url + '?usr={0}&pwd={1}&persist=y'.format( username, password ) cookie = urlopen(target_url).read() ...
python
def request_sid_cookie(self, username, password): """Request cookie for permanent session token.""" log.debug("Requesting SID cookie") target_url = self._login_url + '?usr={0}&pwd={1}&persist=y'.format( username, password ) cookie = urlopen(target_url).read() ...
[ "def", "request_sid_cookie", "(", "self", ",", "username", ",", "password", ")", ":", "log", ".", "debug", "(", "\"Requesting SID cookie\"", ")", "target_url", "=", "self", ".", "_login_url", "+", "'?usr={0}&pwd={1}&persist=y'", ".", "format", "(", "username", "...
Request cookie for permanent session token.
[ "Request", "cookie", "for", "permanent", "session", "token", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L413-L420
train
tamasgal/km3pipe
km3pipe/db.py
DBManager.restore_session
def restore_session(self, cookie): """Establish databse connection using permanent session cookie""" log.debug("Restoring session from cookie: {}".format(cookie)) opener = build_opener() opener.addheaders.append(('Cookie', cookie)) self._opener = opener
python
def restore_session(self, cookie): """Establish databse connection using permanent session cookie""" log.debug("Restoring session from cookie: {}".format(cookie)) opener = build_opener() opener.addheaders.append(('Cookie', cookie)) self._opener = opener
[ "def", "restore_session", "(", "self", ",", "cookie", ")", ":", "log", ".", "debug", "(", "\"Restoring session from cookie: {}\"", ".", "format", "(", "cookie", ")", ")", "opener", "=", "build_opener", "(", ")", "opener", ".", "addheaders", ".", "append", "(...
Establish databse connection using permanent session cookie
[ "Establish", "databse", "connection", "using", "permanent", "session", "cookie" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L422-L427
train
tamasgal/km3pipe
km3pipe/db.py
DBManager.login
def login(self, username, password): "Login to the database and store cookies for upcoming requests." log.debug("Logging in to the DB") opener = self._build_opener() values = {'usr': username, 'pwd': password} req = self._make_request(self._login_url, values) try: ...
python
def login(self, username, password): "Login to the database and store cookies for upcoming requests." log.debug("Logging in to the DB") opener = self._build_opener() values = {'usr': username, 'pwd': password} req = self._make_request(self._login_url, values) try: ...
[ "def", "login", "(", "self", ",", "username", ",", "password", ")", ":", "\"Login to the database and store cookies for upcoming requests.\"", "log", ".", "debug", "(", "\"Logging in to the DB\"", ")", "opener", "=", "self", ".", "_build_opener", "(", ")", "values", ...
Login to the database and store cookies for upcoming requests.
[ "Login", "to", "the", "database", "and", "store", "cookies", "for", "upcoming", "requests", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L449-L467
train
tamasgal/km3pipe
km3pipe/db.py
StreamDS._update_streams
def _update_streams(self): """Update the list of available straems""" content = self._db._get_content("streamds") self._stream_df = read_csv(content).sort_values("STREAM") self._streams = None for stream in self.streams: setattr(self, stream, self.__getattr__(stream))
python
def _update_streams(self): """Update the list of available straems""" content = self._db._get_content("streamds") self._stream_df = read_csv(content).sort_values("STREAM") self._streams = None for stream in self.streams: setattr(self, stream, self.__getattr__(stream))
[ "def", "_update_streams", "(", "self", ")", ":", "content", "=", "self", ".", "_db", ".", "_get_content", "(", "\"streamds\"", ")", "self", ".", "_stream_df", "=", "read_csv", "(", "content", ")", ".", "sort_values", "(", "\"STREAM\"", ")", "self", ".", ...
Update the list of available straems
[ "Update", "the", "list", "of", "available", "straems" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L517-L523
train
tamasgal/km3pipe
km3pipe/db.py
StreamDS.streams
def streams(self): """A list of available streams""" if self._streams is None: self._streams = list(self._stream_df["STREAM"].values) return self._streams
python
def streams(self): """A list of available streams""" if self._streams is None: self._streams = list(self._stream_df["STREAM"].values) return self._streams
[ "def", "streams", "(", "self", ")", ":", "if", "self", ".", "_streams", "is", "None", ":", "self", ".", "_streams", "=", "list", "(", "self", ".", "_stream_df", "[", "\"STREAM\"", "]", ".", "values", ")", "return", "self", ".", "_streams" ]
A list of available streams
[ "A", "list", "of", "available", "streams" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L553-L557
train
tamasgal/km3pipe
km3pipe/db.py
StreamDS.help
def help(self, stream): """Show the help for a given stream.""" if stream not in self.streams: log.error("Stream '{}' not found in the database.".format(stream)) params = self._stream_df[self._stream_df['STREAM'] == stream].values[0] self._print_stream_parameters(params)
python
def help(self, stream): """Show the help for a given stream.""" if stream not in self.streams: log.error("Stream '{}' not found in the database.".format(stream)) params = self._stream_df[self._stream_df['STREAM'] == stream].values[0] self._print_stream_parameters(params)
[ "def", "help", "(", "self", ",", "stream", ")", ":", "if", "stream", "not", "in", "self", ".", "streams", ":", "log", ".", "error", "(", "\"Stream '{}' not found in the database.\"", ".", "format", "(", "stream", ")", ")", "params", "=", "self", ".", "_s...
Show the help for a given stream.
[ "Show", "the", "help", "for", "a", "given", "stream", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L574-L579
train
tamasgal/km3pipe
km3pipe/db.py
StreamDS._print_stream_parameters
def _print_stream_parameters(self, values): """Print a coloured help for a given tuple of stream parameters.""" cprint("{0}".format(*values), "magenta", attrs=["bold"]) print("{4}".format(*values)) cprint(" available formats: {1}".format(*values), "blue") cprint(" mandatory s...
python
def _print_stream_parameters(self, values): """Print a coloured help for a given tuple of stream parameters.""" cprint("{0}".format(*values), "magenta", attrs=["bold"]) print("{4}".format(*values)) cprint(" available formats: {1}".format(*values), "blue") cprint(" mandatory s...
[ "def", "_print_stream_parameters", "(", "self", ",", "values", ")", ":", "cprint", "(", "\"{0}\"", ".", "format", "(", "*", "values", ")", ",", "\"magenta\"", ",", "attrs", "=", "[", "\"bold\"", "]", ")", "print", "(", "\"{4}\"", ".", "format", "(", "*...
Print a coloured help for a given tuple of stream parameters.
[ "Print", "a", "coloured", "help", "for", "a", "given", "tuple", "of", "stream", "parameters", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L586-L593
train
tamasgal/km3pipe
km3pipe/db.py
StreamDS.get
def get(self, stream, fmt='txt', **kwargs): """Get the data for a given stream manually""" sel = ''.join(["&{0}={1}".format(k, v) for (k, v) in kwargs.items()]) url = "streamds/{0}.{1}?{2}".format(stream, fmt, sel[1:]) data = self._db._get_content(url) if not data: lo...
python
def get(self, stream, fmt='txt', **kwargs): """Get the data for a given stream manually""" sel = ''.join(["&{0}={1}".format(k, v) for (k, v) in kwargs.items()]) url = "streamds/{0}.{1}?{2}".format(stream, fmt, sel[1:]) data = self._db._get_content(url) if not data: lo...
[ "def", "get", "(", "self", ",", "stream", ",", "fmt", "=", "'txt'", ",", "**", "kwargs", ")", ":", "sel", "=", "''", ".", "join", "(", "[", "\"&{0}={1}\"", ".", "format", "(", "k", ",", "v", ")", "for", "(", "k", ",", "v", ")", "in", "kwargs"...
Get the data for a given stream manually
[ "Get", "the", "data", "for", "a", "given", "stream", "manually" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L595-L608
train
tamasgal/km3pipe
km3pipe/db.py
ParametersContainer.get_parameter
def get_parameter(self, parameter): "Return a dict for given parameter" parameter = self._get_parameter_name(parameter) return self._parameters[parameter]
python
def get_parameter(self, parameter): "Return a dict for given parameter" parameter = self._get_parameter_name(parameter) return self._parameters[parameter]
[ "def", "get_parameter", "(", "self", ",", "parameter", ")", ":", "\"Return a dict for given parameter\"", "parameter", "=", "self", ".", "_get_parameter_name", "(", "parameter", ")", "return", "self", ".", "_parameters", "[", "parameter", "]" ]
Return a dict for given parameter
[ "Return", "a", "dict", "for", "given", "parameter" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L624-L627
train
tamasgal/km3pipe
km3pipe/db.py
ParametersContainer.get_converter
def get_converter(self, parameter): """Generate unit conversion function for given parameter""" if parameter not in self._converters: param = self.get_parameter(parameter) try: scale = float(param['Scale']) except KeyError: scale = 1 ...
python
def get_converter(self, parameter): """Generate unit conversion function for given parameter""" if parameter not in self._converters: param = self.get_parameter(parameter) try: scale = float(param['Scale']) except KeyError: scale = 1 ...
[ "def", "get_converter", "(", "self", ",", "parameter", ")", ":", "if", "parameter", "not", "in", "self", ".", "_converters", ":", "param", "=", "self", ".", "get_parameter", "(", "parameter", ")", "try", ":", "scale", "=", "float", "(", "param", "[", "...
Generate unit conversion function for given parameter
[ "Generate", "unit", "conversion", "function", "for", "given", "parameter" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L629-L643
train
tamasgal/km3pipe
km3pipe/db.py
ParametersContainer.unit
def unit(self, parameter): "Get the unit for given parameter" parameter = self._get_parameter_name(parameter).lower() return self._parameters[parameter]['Unit']
python
def unit(self, parameter): "Get the unit for given parameter" parameter = self._get_parameter_name(parameter).lower() return self._parameters[parameter]['Unit']
[ "def", "unit", "(", "self", ",", "parameter", ")", ":", "\"Get the unit for given parameter\"", "parameter", "=", "self", ".", "_get_parameter_name", "(", "parameter", ")", ".", "lower", "(", ")", "return", "self", ".", "_parameters", "[", "parameter", "]", "[...
Get the unit for given parameter
[ "Get", "the", "unit", "for", "given", "parameter" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L645-L648
train
tamasgal/km3pipe
km3pipe/db.py
ParametersContainer.oid2name
def oid2name(self, oid): "Look up the parameter name for a given OID" if not self._oid_lookup: for name, data in self._parameters.items(): self._oid_lookup[data['OID']] = data['Name'] return self._oid_lookup[oid]
python
def oid2name(self, oid): "Look up the parameter name for a given OID" if not self._oid_lookup: for name, data in self._parameters.items(): self._oid_lookup[data['OID']] = data['Name'] return self._oid_lookup[oid]
[ "def", "oid2name", "(", "self", ",", "oid", ")", ":", "\"Look up the parameter name for a given OID\"", "if", "not", "self", ".", "_oid_lookup", ":", "for", "name", ",", "data", "in", "self", ".", "_parameters", ".", "items", "(", ")", ":", "self", ".", "_...
Look up the parameter name for a given OID
[ "Look", "up", "the", "parameter", "name", "for", "a", "given", "OID" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L650-L655
train
tamasgal/km3pipe
km3pipe/db.py
DOMContainer.via_dom_id
def via_dom_id(self, dom_id, det_id): """Return DOM for given dom_id""" try: return DOM.from_json([ d for d in self._json if d["DOMId"] == dom_id and d["DetOID"] == det_id ][0]) except IndexError: log.critical("No DOM found for ...
python
def via_dom_id(self, dom_id, det_id): """Return DOM for given dom_id""" try: return DOM.from_json([ d for d in self._json if d["DOMId"] == dom_id and d["DetOID"] == det_id ][0]) except IndexError: log.critical("No DOM found for ...
[ "def", "via_dom_id", "(", "self", ",", "dom_id", ",", "det_id", ")", ":", "try", ":", "return", "DOM", ".", "from_json", "(", "[", "d", "for", "d", "in", "self", ".", "_json", "if", "d", "[", "\"DOMId\"", "]", "==", "dom_id", "and", "d", "[", "\"...
Return DOM for given dom_id
[ "Return", "DOM", "for", "given", "dom_id" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L717-L725
train
tamasgal/km3pipe
km3pipe/db.py
DOMContainer.via_clb_upi
def via_clb_upi(self, clb_upi, det_id): """return DOM for given CLB UPI""" try: return DOM.from_json([ d for d in self._json if d["CLBUPI"] == clb_upi and d["DetOID"] == det_id ][0]) except IndexError: log.critical("No DOM found...
python
def via_clb_upi(self, clb_upi, det_id): """return DOM for given CLB UPI""" try: return DOM.from_json([ d for d in self._json if d["CLBUPI"] == clb_upi and d["DetOID"] == det_id ][0]) except IndexError: log.critical("No DOM found...
[ "def", "via_clb_upi", "(", "self", ",", "clb_upi", ",", "det_id", ")", ":", "try", ":", "return", "DOM", ".", "from_json", "(", "[", "d", "for", "d", "in", "self", ".", "_json", "if", "d", "[", "\"CLBUPI\"", "]", "==", "clb_upi", "and", "d", "[", ...
return DOM for given CLB UPI
[ "return", "DOM", "for", "given", "CLB", "UPI" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L727-L735
train
tamasgal/km3pipe
km3pipe/db.py
CLBMap.upi
def upi(self): """A dict of CLBs with UPI as key""" parameter = 'UPI' if parameter not in self._by: self._populate(by=parameter) return self._by[parameter]
python
def upi(self): """A dict of CLBs with UPI as key""" parameter = 'UPI' if parameter not in self._by: self._populate(by=parameter) return self._by[parameter]
[ "def", "upi", "(", "self", ")", ":", "parameter", "=", "'UPI'", "if", "parameter", "not", "in", "self", ".", "_by", ":", "self", ".", "_populate", "(", "by", "=", "parameter", ")", "return", "self", ".", "_by", "[", "parameter", "]" ]
A dict of CLBs with UPI as key
[ "A", "dict", "of", "CLBs", "with", "UPI", "as", "key" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L879-L884
train
tamasgal/km3pipe
km3pipe/db.py
CLBMap.dom_id
def dom_id(self): """A dict of CLBs with DOM ID as key""" parameter = 'DOMID' if parameter not in self._by: self._populate(by=parameter) return self._by[parameter]
python
def dom_id(self): """A dict of CLBs with DOM ID as key""" parameter = 'DOMID' if parameter not in self._by: self._populate(by=parameter) return self._by[parameter]
[ "def", "dom_id", "(", "self", ")", ":", "parameter", "=", "'DOMID'", "if", "parameter", "not", "in", "self", ".", "_by", ":", "self", ".", "_populate", "(", "by", "=", "parameter", ")", "return", "self", ".", "_by", "[", "parameter", "]" ]
A dict of CLBs with DOM ID as key
[ "A", "dict", "of", "CLBs", "with", "DOM", "ID", "as", "key" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L887-L892
train
tamasgal/km3pipe
km3pipe/db.py
CLBMap.base
def base(self, du): """Return the base CLB for a given DU""" parameter = 'base' if parameter not in self._by: self._by[parameter] = {} for clb in self.upi.values(): if clb.floor == 0: self._by[parameter][clb.du] = clb return sel...
python
def base(self, du): """Return the base CLB for a given DU""" parameter = 'base' if parameter not in self._by: self._by[parameter] = {} for clb in self.upi.values(): if clb.floor == 0: self._by[parameter][clb.du] = clb return sel...
[ "def", "base", "(", "self", ",", "du", ")", ":", "parameter", "=", "'base'", "if", "parameter", "not", "in", "self", ".", "_by", ":", "self", ".", "_by", "[", "parameter", "]", "=", "{", "}", "for", "clb", "in", "self", ".", "upi", ".", "values",...
Return the base CLB for a given DU
[ "Return", "the", "base", "CLB", "for", "a", "given", "DU" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L894-L902
train
IRC-SPHERE/HyperStream
hyperstream/channels/database_channel.py
DatabaseChannel.get_results
def get_results(self, stream, time_interval): """ Get the results for a given stream :param time_interval: The time interval :param stream: The stream object :return: A generator over stream instances """ query = stream.stream_id.as_raw() query['datetime'...
python
def get_results(self, stream, time_interval): """ Get the results for a given stream :param time_interval: The time interval :param stream: The stream object :return: A generator over stream instances """ query = stream.stream_id.as_raw() query['datetime'...
[ "def", "get_results", "(", "self", ",", "stream", ",", "time_interval", ")", ":", "query", "=", "stream", ".", "stream_id", ".", "as_raw", "(", ")", "query", "[", "'datetime'", "]", "=", "{", "'$gt'", ":", "time_interval", ".", "start", ",", "'$lte'", ...
Get the results for a given stream :param time_interval: The time interval :param stream: The stream object :return: A generator over stream instances
[ "Get", "the", "results", "for", "a", "given", "stream" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/channels/database_channel.py#L57-L69
train
tamasgal/km3pipe
km3pipe/io/clb.py
CLBPump.seek_to_packet
def seek_to_packet(self, index): """Move file pointer to the packet with given index.""" pointer_position = self.packet_positions[index] self.blob_file.seek(pointer_position, 0)
python
def seek_to_packet(self, index): """Move file pointer to the packet with given index.""" pointer_position = self.packet_positions[index] self.blob_file.seek(pointer_position, 0)
[ "def", "seek_to_packet", "(", "self", ",", "index", ")", ":", "pointer_position", "=", "self", ".", "packet_positions", "[", "index", "]", "self", ".", "blob_file", ".", "seek", "(", "pointer_position", ",", "0", ")" ]
Move file pointer to the packet with given index.
[ "Move", "file", "pointer", "to", "the", "packet", "with", "given", "index", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/clb.py#L59-L62
train
tamasgal/km3pipe
km3pipe/io/clb.py
CLBPump.next_blob
def next_blob(self): """Generate next blob in file""" try: length = struct.unpack('<i', self.blob_file.read(4))[0] except struct.error: raise StopIteration header = CLBHeader(file_obj=self.blob_file) blob = {'CLBHeader': header} remaining_length = ...
python
def next_blob(self): """Generate next blob in file""" try: length = struct.unpack('<i', self.blob_file.read(4))[0] except struct.error: raise StopIteration header = CLBHeader(file_obj=self.blob_file) blob = {'CLBHeader': header} remaining_length = ...
[ "def", "next_blob", "(", "self", ")", ":", "try", ":", "length", "=", "struct", ".", "unpack", "(", "'<i'", ",", "self", ".", "blob_file", ".", "read", "(", "4", ")", ")", "[", "0", "]", "except", "struct", ".", "error", ":", "raise", "StopIteratio...
Generate next blob in file
[ "Generate", "next", "blob", "in", "file" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/clb.py#L64-L83
train
PrefPy/prefpy
prefpy/mechanism.py
getKendallTauScore
def getKendallTauScore(myResponse, otherResponse): """ Returns the Kendall Tau Score """ # variables kt = 0 list1 = myResponse.values() list2 = otherResponse.values() if len(list1) <= 1: return kt # runs through list1 for itr1 in range(0, len(list1) - 1): # runs...
python
def getKendallTauScore(myResponse, otherResponse): """ Returns the Kendall Tau Score """ # variables kt = 0 list1 = myResponse.values() list2 = otherResponse.values() if len(list1) <= 1: return kt # runs through list1 for itr1 in range(0, len(list1) - 1): # runs...
[ "def", "getKendallTauScore", "(", "myResponse", ",", "otherResponse", ")", ":", "kt", "=", "0", "list1", "=", "myResponse", ".", "values", "(", ")", "list2", "=", "otherResponse", ".", "values", "(", ")", "if", "len", "(", "list1", ")", "<=", "1", ":",...
Returns the Kendall Tau Score
[ "Returns", "the", "Kendall", "Tau", "Score" ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L580-L606
train
PrefPy/prefpy
prefpy/mechanism.py
MechanismPosScoring.getCandScoresMap
def getCandScoresMap(self, profile): """ Returns a dictonary that associates the integer representation of each candidate with the score they recieved in the profile. :ivar Profile profile: A Profile object that represents an election profile. """ # Currently, we expect...
python
def getCandScoresMap(self, profile): """ Returns a dictonary that associates the integer representation of each candidate with the score they recieved in the profile. :ivar Profile profile: A Profile object that represents an election profile. """ # Currently, we expect...
[ "def", "getCandScoresMap", "(", "self", ",", "profile", ")", ":", "elecType", "=", "profile", ".", "getElecType", "(", ")", "if", "elecType", "!=", "\"soc\"", "and", "elecType", "!=", "\"toc\"", ":", "print", "(", "\"ERROR: unsupported election type\"", ")", "...
Returns a dictonary that associates the integer representation of each candidate with the score they recieved in the profile. :ivar Profile profile: A Profile object that represents an election profile.
[ "Returns", "a", "dictonary", "that", "associates", "the", "integer", "representation", "of", "each", "candidate", "with", "the", "score", "they", "recieved", "in", "the", "profile", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L128-L159
train
PrefPy/prefpy
prefpy/mechanism.py
MechanismPosScoring.getMov
def getMov(self, profile): """ Returns an integer that is equal to the margin of victory of the election profile. :ivar Profile profile: A Profile object that represents an election profile. """ # from . import mov import mov return mov.MoVScoring(profile, self.g...
python
def getMov(self, profile): """ Returns an integer that is equal to the margin of victory of the election profile. :ivar Profile profile: A Profile object that represents an election profile. """ # from . import mov import mov return mov.MoVScoring(profile, self.g...
[ "def", "getMov", "(", "self", ",", "profile", ")", ":", "import", "mov", "return", "mov", ".", "MoVScoring", "(", "profile", ",", "self", ".", "getScoringVector", "(", "profile", ")", ")" ]
Returns an integer that is equal to the margin of victory of the election profile. :ivar Profile profile: A Profile object that represents an election profile.
[ "Returns", "an", "integer", "that", "is", "equal", "to", "the", "margin", "of", "victory", "of", "the", "election", "profile", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L161-L169
train
PrefPy/prefpy
prefpy/mechanism.py
MechanismSimplifiedBucklin.getCandScoresMap
def getCandScoresMap(self, profile): """ Returns a dictionary that associates integer representations of each candidate with their Bucklin score. :ivar Profile profile: A Profile object that represents an election profile. """ # Currently, we expect the profile to conta...
python
def getCandScoresMap(self, profile): """ Returns a dictionary that associates integer representations of each candidate with their Bucklin score. :ivar Profile profile: A Profile object that represents an election profile. """ # Currently, we expect the profile to conta...
[ "def", "getCandScoresMap", "(", "self", ",", "profile", ")", ":", "elecType", "=", "profile", ".", "getElecType", "(", ")", "if", "elecType", "!=", "\"soc\"", "and", "elecType", "!=", "\"toc\"", ":", "print", "(", "\"ERROR: unsupported profile type\"", ")", "e...
Returns a dictionary that associates integer representations of each candidate with their Bucklin score. :ivar Profile profile: A Profile object that represents an election profile.
[ "Returns", "a", "dictionary", "that", "associates", "integer", "representations", "of", "each", "candidate", "with", "their", "Bucklin", "score", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L335-L367
train
PrefPy/prefpy
prefpy/mechanism.py
MechanismMaximin.getCandScoresMap
def getCandScoresMap(self, profile): """ Returns a dictionary that associates integer representations of each candidate with their maximin score. :ivar Profile profile: A Profile object that represents an election profile. """ # Currently, we expect the profile to conta...
python
def getCandScoresMap(self, profile): """ Returns a dictionary that associates integer representations of each candidate with their maximin score. :ivar Profile profile: A Profile object that represents an election profile. """ # Currently, we expect the profile to conta...
[ "def", "getCandScoresMap", "(", "self", ",", "profile", ")", ":", "elecType", "=", "profile", ".", "getElecType", "(", ")", "if", "elecType", "!=", "\"soc\"", "and", "elecType", "!=", "\"toc\"", ":", "print", "(", "\"ERROR: unsupported election type\"", ")", "...
Returns a dictionary that associates integer representations of each candidate with their maximin score. :ivar Profile profile: A Profile object that represents an election profile.
[ "Returns", "a", "dictionary", "that", "associates", "integer", "representations", "of", "each", "candidate", "with", "their", "maximin", "score", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L436-L464
train
PrefPy/prefpy
prefpy/mechanism.py
MechanismSchulze.computeStrongestPaths
def computeStrongestPaths(self, profile, pairwisePreferences): """ Returns a two-dimensional dictionary that associates every pair of candidates, cand1 and cand2, with the strongest path from cand1 to cand2. :ivar Profile profile: A Profile object that represents an election profile. ...
python
def computeStrongestPaths(self, profile, pairwisePreferences): """ Returns a two-dimensional dictionary that associates every pair of candidates, cand1 and cand2, with the strongest path from cand1 to cand2. :ivar Profile profile: A Profile object that represents an election profile. ...
[ "def", "computeStrongestPaths", "(", "self", ",", "profile", ",", "pairwisePreferences", ")", ":", "cands", "=", "profile", ".", "candMap", ".", "keys", "(", ")", "numCands", "=", "len", "(", "cands", ")", "strongestPaths", "=", "dict", "(", ")", "for", ...
Returns a two-dimensional dictionary that associates every pair of candidates, cand1 and cand2, with the strongest path from cand1 to cand2. :ivar Profile profile: A Profile object that represents an election profile. :ivar dict<int,dict<int,int>> pairwisePreferences: A two-dimensional dictiona...
[ "Returns", "a", "two", "-", "dimensional", "dictionary", "that", "associates", "every", "pair", "of", "candidates", "cand1", "and", "cand2", "with", "the", "strongest", "path", "from", "cand1", "to", "cand2", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L475-L511
train
PrefPy/prefpy
prefpy/mechanism.py
MechanismSchulze.computePairwisePreferences
def computePairwisePreferences(self, profile): """ Returns a two-dimensional dictionary that associates every pair of candidates, cand1 and cand2, with number of voters who prefer cand1 to cand2. :ivar Profile profile: A Profile object that represents an election profile. """ ...
python
def computePairwisePreferences(self, profile): """ Returns a two-dimensional dictionary that associates every pair of candidates, cand1 and cand2, with number of voters who prefer cand1 to cand2. :ivar Profile profile: A Profile object that represents an election profile. """ ...
[ "def", "computePairwisePreferences", "(", "self", ",", "profile", ")", ":", "cands", "=", "profile", ".", "candMap", ".", "keys", "(", ")", "pairwisePreferences", "=", "dict", "(", ")", "for", "cand", "in", "cands", ":", "pairwisePreferences", "[", "cand", ...
Returns a two-dimensional dictionary that associates every pair of candidates, cand1 and cand2, with number of voters who prefer cand1 to cand2. :ivar Profile profile: A Profile object that represents an election profile.
[ "Returns", "a", "two", "-", "dimensional", "dictionary", "that", "associates", "every", "pair", "of", "candidates", "cand1", "and", "cand2", "with", "number", "of", "voters", "who", "prefer", "cand1", "to", "cand2", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L513-L550
train
PrefPy/prefpy
prefpy/mechanism.py
MechanismSchulze.getCandScoresMap
def getCandScoresMap(self, profile): """ Returns a dictionary that associates integer representations of each candidate with the number of other candidates for which her strongest path to the other candidate is greater than the other candidate's stronget path to her. :ivar Profi...
python
def getCandScoresMap(self, profile): """ Returns a dictionary that associates integer representations of each candidate with the number of other candidates for which her strongest path to the other candidate is greater than the other candidate's stronget path to her. :ivar Profi...
[ "def", "getCandScoresMap", "(", "self", ",", "profile", ")", ":", "cands", "=", "profile", ".", "candMap", ".", "keys", "(", ")", "pairwisePreferences", "=", "self", ".", "computePairwisePreferences", "(", "profile", ")", "strongestPaths", "=", "self", ".", ...
Returns a dictionary that associates integer representations of each candidate with the number of other candidates for which her strongest path to the other candidate is greater than the other candidate's stronget path to her. :ivar Profile profile: A Profile object that represents an election ...
[ "Returns", "a", "dictionary", "that", "associates", "integer", "representations", "of", "each", "candidate", "with", "the", "number", "of", "other", "candidates", "for", "which", "her", "strongest", "path", "to", "the", "other", "candidate", "is", "greater", "th...
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L552-L577
train
PrefPy/prefpy
prefpy/mechanism.py
MechanismSTV.STVsocwinners
def STVsocwinners(self, profile): """ Returns an integer list that represents all possible winners of a profile under STV rule. :ivar Profile profile: A Profile object that represents an election profile. """ ordering = profile.getOrderVectors() prefcounts = profile.getP...
python
def STVsocwinners(self, profile): """ Returns an integer list that represents all possible winners of a profile under STV rule. :ivar Profile profile: A Profile object that represents an election profile. """ ordering = profile.getOrderVectors() prefcounts = profile.getP...
[ "def", "STVsocwinners", "(", "self", ",", "profile", ")", ":", "ordering", "=", "profile", ".", "getOrderVectors", "(", ")", "prefcounts", "=", "profile", ".", "getPreferenceCounts", "(", ")", "m", "=", "profile", ".", "numCands", "if", "min", "(", "orderi...
Returns an integer list that represents all possible winners of a profile under STV rule. :ivar Profile profile: A Profile object that represents an election profile.
[ "Returns", "an", "integer", "list", "that", "represents", "all", "possible", "winners", "of", "a", "profile", "under", "STV", "rule", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L624-L680
train
PrefPy/prefpy
prefpy/mechanism.py
MechanismBaldwin.baldwinsoc_winners
def baldwinsoc_winners(self, profile): """ Returns an integer list that represents all possible winners of a profile under baldwin rule. :ivar Profile profile: A Profile object that represents an election profile. """ ordering = profile.getOrderVectors() m = profile.numC...
python
def baldwinsoc_winners(self, profile): """ Returns an integer list that represents all possible winners of a profile under baldwin rule. :ivar Profile profile: A Profile object that represents an election profile. """ ordering = profile.getOrderVectors() m = profile.numC...
[ "def", "baldwinsoc_winners", "(", "self", ",", "profile", ")", ":", "ordering", "=", "profile", ".", "getOrderVectors", "(", ")", "m", "=", "profile", ".", "numCands", "prefcounts", "=", "profile", ".", "getPreferenceCounts", "(", ")", "if", "min", "(", "o...
Returns an integer list that represents all possible winners of a profile under baldwin rule. :ivar Profile profile: A Profile object that represents an election profile.
[ "Returns", "an", "integer", "list", "that", "represents", "all", "possible", "winners", "of", "a", "profile", "under", "baldwin", "rule", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L801-L861
train
PrefPy/prefpy
prefpy/mechanism.py
MechanismBaldwin.getWmg2
def getWmg2(self, prefcounts, ordering, state, normalize=False): """ Generate a weighted majority graph that represents the whole profile. The function will return a two-dimensional dictionary that associates integer representations of each pair of candidates, cand1 and cand2, with the n...
python
def getWmg2(self, prefcounts, ordering, state, normalize=False): """ Generate a weighted majority graph that represents the whole profile. The function will return a two-dimensional dictionary that associates integer representations of each pair of candidates, cand1 and cand2, with the n...
[ "def", "getWmg2", "(", "self", ",", "prefcounts", ",", "ordering", ",", "state", ",", "normalize", "=", "False", ")", ":", "wmgMap", "=", "dict", "(", ")", "for", "cand", "in", "state", ":", "wmgMap", "[", "cand", "]", "=", "dict", "(", ")", "for",...
Generate a weighted majority graph that represents the whole profile. The function will return a two-dimensional dictionary that associates integer representations of each pair of candidates, cand1 and cand2, with the number of times cand1 is ranked above cand2 minus the number of times cand2 is...
[ "Generate", "a", "weighted", "majority", "graph", "that", "represents", "the", "whole", "profile", ".", "The", "function", "will", "return", "a", "two", "-", "dimensional", "dictionary", "that", "associates", "integer", "representations", "of", "each", "pair", "...
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L927-L963
train
PrefPy/prefpy
prefpy/mechanism.py
MechanismPluralityRunOff.PluRunOff_single_winner
def PluRunOff_single_winner(self, profile): """ Returns a number that associates the winner of a profile under Plurality with Runoff rule. :ivar Profile profile: A Profile object that represents an election profile. """ # Currently, we expect the profile to contain complete ord...
python
def PluRunOff_single_winner(self, profile): """ Returns a number that associates the winner of a profile under Plurality with Runoff rule. :ivar Profile profile: A Profile object that represents an election profile. """ # Currently, we expect the profile to contain complete ord...
[ "def", "PluRunOff_single_winner", "(", "self", ",", "profile", ")", ":", "elecType", "=", "profile", ".", "getElecType", "(", ")", "if", "elecType", "!=", "\"soc\"", "and", "elecType", "!=", "\"toc\"", "and", "elecType", "!=", "\"csv\"", ":", "print", "(", ...
Returns a number that associates the winner of a profile under Plurality with Runoff rule. :ivar Profile profile: A Profile object that represents an election profile.
[ "Returns", "a", "number", "that", "associates", "the", "winner", "of", "a", "profile", "under", "Plurality", "with", "Runoff", "rule", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L1780-L1825
train
PrefPy/prefpy
prefpy/mechanism.py
MechanismPluralityRunOff.PluRunOff_cowinners
def PluRunOff_cowinners(self, profile): """ Returns a list that associates all the winners of a profile under Plurality with Runoff rule. :ivar Profile profile: A Profile object that represents an election profile. """ # Currently, we expect the profile to contain complete orde...
python
def PluRunOff_cowinners(self, profile): """ Returns a list that associates all the winners of a profile under Plurality with Runoff rule. :ivar Profile profile: A Profile object that represents an election profile. """ # Currently, we expect the profile to contain complete orde...
[ "def", "PluRunOff_cowinners", "(", "self", ",", "profile", ")", ":", "elecType", "=", "profile", ".", "getElecType", "(", ")", "if", "elecType", "!=", "\"soc\"", "and", "elecType", "!=", "\"toc\"", "and", "elecType", "!=", "\"csv\"", ":", "print", "(", "\"...
Returns a list that associates all the winners of a profile under Plurality with Runoff rule. :ivar Profile profile: A Profile object that represents an election profile.
[ "Returns", "a", "list", "that", "associates", "all", "the", "winners", "of", "a", "profile", "under", "Plurality", "with", "Runoff", "rule", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L1827-L1876
train
PrefPy/prefpy
prefpy/mechanism.py
MechanismSNTV.SNTV_winners
def SNTV_winners(self, profile, K): """ Returns a list that associates all the winners of a profile under Single non-transferable vote rule. :ivar Profile profile: A Profile object that represents an election profile. """ # Currently, we expect the profile to contain complete o...
python
def SNTV_winners(self, profile, K): """ Returns a list that associates all the winners of a profile under Single non-transferable vote rule. :ivar Profile profile: A Profile object that represents an election profile. """ # Currently, we expect the profile to contain complete o...
[ "def", "SNTV_winners", "(", "self", ",", "profile", ",", "K", ")", ":", "elecType", "=", "profile", ".", "getElecType", "(", ")", "if", "elecType", "!=", "\"soc\"", "and", "elecType", "!=", "\"toc\"", "and", "elecType", "!=", "\"csv\"", ":", "print", "("...
Returns a list that associates all the winners of a profile under Single non-transferable vote rule. :ivar Profile profile: A Profile object that represents an election profile.
[ "Returns", "a", "list", "that", "associates", "all", "the", "winners", "of", "a", "profile", "under", "Single", "non", "-", "transferable", "vote", "rule", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L1899-L1921
train
PrefPy/prefpy
prefpy/mechanism.py
MechanismBordaMean.Borda_mean_winners
def Borda_mean_winners(self, profile): """ Returns a list that associates all the winners of a profile under The Borda-mean rule. :ivar Profile profile: A Profile object that represents an election profile. """ n_candidates = profile.numCands prefcounts = profile.getPref...
python
def Borda_mean_winners(self, profile): """ Returns a list that associates all the winners of a profile under The Borda-mean rule. :ivar Profile profile: A Profile object that represents an election profile. """ n_candidates = profile.numCands prefcounts = profile.getPref...
[ "def", "Borda_mean_winners", "(", "self", ",", "profile", ")", ":", "n_candidates", "=", "profile", ".", "numCands", "prefcounts", "=", "profile", ".", "getPreferenceCounts", "(", ")", "len_prefcounts", "=", "len", "(", "prefcounts", ")", "rankmaps", "=", "pro...
Returns a list that associates all the winners of a profile under The Borda-mean rule. :ivar Profile profile: A Profile object that represents an election profile.
[ "Returns", "a", "list", "that", "associates", "all", "the", "winners", "of", "a", "profile", "under", "The", "Borda", "-", "mean", "rule", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L2043-L2068
train
tamasgal/km3pipe
km3pipe/calib.py
Calibration.apply_t0
def apply_t0(self, hits): """Apply only t0s""" if HAVE_NUMBA: apply_t0_nb( hits.time, hits.dom_id, hits.channel_id, self._lookup_tables ) else: n = len(hits) cal = np.empty(n) lookup = self._calib_by_dom_and_channel ...
python
def apply_t0(self, hits): """Apply only t0s""" if HAVE_NUMBA: apply_t0_nb( hits.time, hits.dom_id, hits.channel_id, self._lookup_tables ) else: n = len(hits) cal = np.empty(n) lookup = self._calib_by_dom_and_channel ...
[ "def", "apply_t0", "(", "self", ",", "hits", ")", ":", "if", "HAVE_NUMBA", ":", "apply_t0_nb", "(", "hits", ".", "time", ",", "hits", ".", "dom_id", ",", "hits", ".", "channel_id", ",", "self", ".", "_lookup_tables", ")", "else", ":", "n", "=", "len"...
Apply only t0s
[ "Apply", "only", "t0s" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/calib.py#L116-L130
train
tamasgal/km3pipe
km3pipe/io/evt.py
EvtPump._get_file_index_str
def _get_file_index_str(self): """Create a string out of the current file_index""" file_index = str(self.file_index) if self.n_digits is not None: file_index = file_index.zfill(self.n_digits) return file_index
python
def _get_file_index_str(self): """Create a string out of the current file_index""" file_index = str(self.file_index) if self.n_digits is not None: file_index = file_index.zfill(self.n_digits) return file_index
[ "def", "_get_file_index_str", "(", "self", ")", ":", "file_index", "=", "str", "(", "self", ".", "file_index", ")", "if", "self", ".", "n_digits", "is", "not", "None", ":", "file_index", "=", "file_index", ".", "zfill", "(", "self", ".", "n_digits", ")",...
Create a string out of the current file_index
[ "Create", "a", "string", "out", "of", "the", "current", "file_index" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/evt.py#L156-L161
train