repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
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
A list of available streams
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
Show the help for a given stream.
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
Print a coloured help for a given tuple of stream parameters.
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", "k...
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
Get the data for a given stream manually
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", ")", ":", "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
Return a dict for given parameter
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
Generate unit conversion function for given parameter
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", ")", ":", "parameter", "=", "self", ".", "_get_parameter_name", "(", "parameter", ")", ".", "lower", "(", ")", "return", "self", ".", "_parameters", "[", "parameter", "]", "[", "'Unit'", "]" ]
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
Get the unit for given parameter
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", ")", ":", "if", "not", "self", ".", "_oid_lookup", ":", "for", "name", ",", "data", "in", "self", ".", "_parameters", ".", "items", "(", ")", ":", "self", ".", "_oid_lookup", "[", "data", "[", "'OID'", "]...
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
Look up the parameter name for a given OID
tamasgal/km3pipe
km3pipe/db.py
DOMContainer.via_omkey
def via_omkey(self, omkey, det_id): """Return DOM for given OMkey (DU, floor)""" du, floor = omkey try: return DOM.from_json([ d for d in self._json if d["DU"] == du and d["Floor"] == floor and d["DetOID"] == det_id ][0]) except Ind...
python
def via_omkey(self, omkey, det_id): """Return DOM for given OMkey (DU, floor)""" du, floor = omkey try: return DOM.from_json([ d for d in self._json if d["DU"] == du and d["Floor"] == floor and d["DetOID"] == det_id ][0]) except Ind...
[ "def", "via_omkey", "(", "self", ",", "omkey", ",", "det_id", ")", ":", "du", ",", "floor", "=", "omkey", "try", ":", "return", "DOM", ".", "from_json", "(", "[", "d", "for", "d", "in", "self", ".", "_json", "if", "d", "[", "\"DU\"", "]", "==", ...
Return DOM for given OMkey (DU, floor)
[ "Return", "DOM", "for", "given", "OMkey", "(", "DU", "floor", ")" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/db.py#L702-L715
train
Return a DOM object for given OMKey and DetOID.
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
Return a DOM object for given dom_id and det_id
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
return DOM for given CLB UPI
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
A dict of CLBs with UPI as key
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
A dict of CLBs with DOM ID as key
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
Return the base CLB for a given DU
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
Get the results for a given stream
IRC-SPHERE/HyperStream
hyperstream/channels/database_channel.py
DatabaseChannel.purge_stream
def purge_stream(self, stream_id, remove_definition=False, sandbox=None): """ Purge the stream :param stream_id: The stream identifier :param remove_definition: Whether to remove the stream definition as well :param sandbox: The sandbox for this stream :return: None ...
python
def purge_stream(self, stream_id, remove_definition=False, sandbox=None): """ Purge the stream :param stream_id: The stream identifier :param remove_definition: Whether to remove the stream definition as well :param sandbox: The sandbox for this stream :return: None ...
[ "def", "purge_stream", "(", "self", ",", "stream_id", ",", "remove_definition", "=", "False", ",", "sandbox", "=", "None", ")", ":", "# TODO: Add time interval to this", "if", "sandbox", "is", "not", "None", ":", "raise", "NotImplementedError", "if", "stream_id", ...
Purge the stream :param stream_id: The stream identifier :param remove_definition: Whether to remove the stream definition as well :param sandbox: The sandbox for this stream :return: None :raises: NotImplementedError
[ "Purge", "the", "stream" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/channels/database_channel.py#L91-L121
train
Purges the given stream.
IRC-SPHERE/HyperStream
hyperstream/channels/database_channel.py
DatabaseChannel.get_stream_writer
def get_stream_writer(self, stream): """ Gets the database channel writer The mongoengine model checks whether a stream_id/datetime pair already exists in the DB (unique pairs) Should be overridden by users' personal channels - allows for non-mongo outputs. :param stream: The st...
python
def get_stream_writer(self, stream): """ Gets the database channel writer The mongoengine model checks whether a stream_id/datetime pair already exists in the DB (unique pairs) Should be overridden by users' personal channels - allows for non-mongo outputs. :param stream: The st...
[ "def", "get_stream_writer", "(", "self", ",", "stream", ")", ":", "def", "writer", "(", "document_collection", ")", ":", "with", "switch_db", "(", "StreamInstanceModel", ",", "'hyperstream'", ")", ":", "if", "isinstance", "(", "document_collection", ",", "Stream...
Gets the database channel writer The mongoengine model checks whether a stream_id/datetime pair already exists in the DB (unique pairs) Should be overridden by users' personal channels - allows for non-mongo outputs. :param stream: The stream :return: The stream writer function
[ "Gets", "the", "database", "channel", "writer", "The", "mongoengine", "model", "checks", "whether", "a", "stream_id", "/", "datetime", "pair", "already", "exists", "in", "the", "DB", "(", "unique", "pairs", ")", "Should", "be", "overridden", "by", "users", "...
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/channels/database_channel.py#L123-L155
train
Returns the function that creates a new stream instance with the given stream_id and datetime pair.
IRC-SPHERE/HyperStream
hyperstream/session.py
Session.clear_sessions
def clear_sessions(hyperstream, inactive_only=True, clear_history=False): """ Clear all (inactive) sessions and (optionally) their history :param hyperstream: The hyperstream object :param inactive_only: Whether to only clear inactive sessions (active sessions may be owned by an...
python
def clear_sessions(hyperstream, inactive_only=True, clear_history=False): """ Clear all (inactive) sessions and (optionally) their history :param hyperstream: The hyperstream object :param inactive_only: Whether to only clear inactive sessions (active sessions may be owned by an...
[ "def", "clear_sessions", "(", "hyperstream", ",", "inactive_only", "=", "True", ",", "clear_history", "=", "False", ")", ":", "query", "=", "dict", "(", ")", "if", "inactive_only", ":", "query", "[", "'active'", "]", "=", "False", "if", "hyperstream", ".",...
Clear all (inactive) sessions and (optionally) their history :param hyperstream: The hyperstream object :param inactive_only: Whether to only clear inactive sessions (active sessions may be owned by another process) :param clear_history: Whether to clear the history of the session. Note...
[ "Clear", "all", "(", "inactive", ")", "sessions", "and", "(", "optionally", ")", "their", "history", ":", "param", "hyperstream", ":", "The", "hyperstream", "object", ":", "param", "inactive_only", ":", "Whether", "to", "only", "clear", "inactive", "sessions",...
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/session.py#L120-L146
train
Clears all inactive and active sessions and their history edition of the current session.
IRC-SPHERE/HyperStream
hyperstream/session.py
Session.close
def close(self): """ Close the current session """ self.active = False self.end = utcnow() self._model.save()
python
def close(self): """ Close the current session """ self.active = False self.end = utcnow() self._model.save()
[ "def", "close", "(", "self", ")", ":", "self", ".", "active", "=", "False", "self", ".", "end", "=", "utcnow", "(", ")", "self", ".", "_model", ".", "save", "(", ")" ]
Close the current session
[ "Close", "the", "current", "session" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/session.py#L160-L166
train
Close the current session
tamasgal/km3pipe
km3pipe/io/clb.py
CLBPump.determine_packet_positions
def determine_packet_positions(self): """Record the file pointer position of each frame""" print("Analysing file...") self.rewind_file() with ignored(struct.error): while True: pointer_position = self.blob_file.tell() length = struct.unpack('<i...
python
def determine_packet_positions(self): """Record the file pointer position of each frame""" print("Analysing file...") self.rewind_file() with ignored(struct.error): while True: pointer_position = self.blob_file.tell() length = struct.unpack('<i...
[ "def", "determine_packet_positions", "(", "self", ")", ":", "print", "(", "\"Analysing file...\"", ")", "self", ".", "rewind_file", "(", ")", "with", "ignored", "(", "struct", ".", "error", ")", ":", "while", "True", ":", "pointer_position", "=", "self", "."...
Record the file pointer position of each frame
[ "Record", "the", "file", "pointer", "position", "of", "each", "frame" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/clb.py#L46-L57
train
Determine the file pointer position of each frame of each CLB UDP packet.
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
Move file pointer to the packet with given index.
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
Generate next blob in file
tamasgal/km3pipe
km3pipe/io/clb.py
CLBHeader._parse_byte_data
def _parse_byte_data(self, byte_data): """Extract the values from byte string.""" self.data_type = b''.join(unpack('cccc', byte_data[:4])).decode() self.run = unpack('>i', byte_data[4:8])[0] self.udp_sequence = unpack('>i', byte_data[8:12])[0] self.timestamp, self.ns_ticks = unpa...
python
def _parse_byte_data(self, byte_data): """Extract the values from byte string.""" self.data_type = b''.join(unpack('cccc', byte_data[:4])).decode() self.run = unpack('>i', byte_data[4:8])[0] self.udp_sequence = unpack('>i', byte_data[8:12])[0] self.timestamp, self.ns_ticks = unpa...
[ "def", "_parse_byte_data", "(", "self", ",", "byte_data", ")", ":", "self", ".", "data_type", "=", "b''", ".", "join", "(", "unpack", "(", "'cccc'", ",", "byte_data", "[", ":", "4", "]", ")", ")", ".", "decode", "(", ")", "self", ".", "run", "=", ...
Extract the values from byte string.
[ "Extract", "the", "values", "from", "byte", "string", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/clb.py#L153-L166
train
Extracts the values from the byte string.
NaPs/Kolekto
kolekto/datasources/tmdb.py
TmdbDatasource.refresh
def refresh(self, movie): """ Try to refresh metadata of the movie through the datasource. """ if '_tmdb_id' in movie: tmdb_id = movie['_tmdb_id'] details = self._tmdb_get(tmdb_id) cast = self._tmdb_cast(tmdb_id) alternatives = self._tmdb_alt(tmdb_...
python
def refresh(self, movie): """ Try to refresh metadata of the movie through the datasource. """ if '_tmdb_id' in movie: tmdb_id = movie['_tmdb_id'] details = self._tmdb_get(tmdb_id) cast = self._tmdb_cast(tmdb_id) alternatives = self._tmdb_alt(tmdb_...
[ "def", "refresh", "(", "self", ",", "movie", ")", ":", "if", "'_tmdb_id'", "in", "movie", ":", "tmdb_id", "=", "movie", "[", "'_tmdb_id'", "]", "details", "=", "self", ".", "_tmdb_get", "(", "tmdb_id", ")", "cast", "=", "self", ".", "_tmdb_cast", "(", ...
Try to refresh metadata of the movie through the datasource.
[ "Try", "to", "refresh", "metadata", "of", "the", "movie", "through", "the", "datasource", "." ]
29c5469da8782780a06bf9a76c59414bb6fd8fe3
https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/datasources/tmdb.py#L101-L125
train
Refresh the metadata of the movie.
NaPs/Kolekto
kolekto/datasources/tmdb.py
TmdbTVSeriesDatasource.refresh
def refresh(self, movie): """ Try to refresh metadata of the movie through the datasource. """ if '_tmdbtv_id' in movie: refreshed = {'_Datasource': self.name} tvseries_id = movie['_tmdbtv_id'] series = self._tmdb_series(tvseries_id) alternatives =...
python
def refresh(self, movie): """ Try to refresh metadata of the movie through the datasource. """ if '_tmdbtv_id' in movie: refreshed = {'_Datasource': self.name} tvseries_id = movie['_tmdbtv_id'] series = self._tmdb_series(tvseries_id) alternatives =...
[ "def", "refresh", "(", "self", ",", "movie", ")", ":", "if", "'_tmdbtv_id'", "in", "movie", ":", "refreshed", "=", "{", "'_Datasource'", ":", "self", ".", "name", "}", "tvseries_id", "=", "movie", "[", "'_tmdbtv_id'", "]", "series", "=", "self", ".", "...
Try to refresh metadata of the movie through the datasource.
[ "Try", "to", "refresh", "metadata", "of", "the", "movie", "through", "the", "datasource", "." ]
29c5469da8782780a06bf9a76c59414bb6fd8fe3
https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/datasources/tmdb.py#L213-L242
train
Refreshes the metadata of the movie.
NaPs/Kolekto
kolekto/datasources/tmdb.py
TmdbProxyDatasource.refresh
def refresh(self, movie): """ Try to refresh metadata of the movie through the datasource. """ if '_tmdb_id' in movie: tmdb_id = movie['_tmdb_id'] movie = self._get('/1/movie/%s' % tmdb_id) return movie['movie']
python
def refresh(self, movie): """ Try to refresh metadata of the movie through the datasource. """ if '_tmdb_id' in movie: tmdb_id = movie['_tmdb_id'] movie = self._get('/1/movie/%s' % tmdb_id) return movie['movie']
[ "def", "refresh", "(", "self", ",", "movie", ")", ":", "if", "'_tmdb_id'", "in", "movie", ":", "tmdb_id", "=", "movie", "[", "'_tmdb_id'", "]", "movie", "=", "self", ".", "_get", "(", "'/1/movie/%s'", "%", "tmdb_id", ")", "return", "movie", "[", "'movi...
Try to refresh metadata of the movie through the datasource.
[ "Try", "to", "refresh", "metadata", "of", "the", "movie", "through", "the", "datasource", "." ]
29c5469da8782780a06bf9a76c59414bb6fd8fe3
https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/datasources/tmdb.py#L292-L298
train
Refresh the metadata of the movie.
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", ")", ":", "# variables", "kt", "=", "0", "list1", "=", "myResponse", ".", "values", "(", ")", "list2", "=", "otherResponse", ".", "values", "(", ")", "if", "len", "(", "list1", ")", "<...
Returns the Kendall Tau Score
[ "Returns", "the", "Kendall", "Tau", "Score" ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L580-L606
train
Returns the Kendall Tau Score for the given response and other response.
PrefPy/prefpy
prefpy/mechanism.py
MechanismPosScoring.getScoringVector
def getScoringVector(self, profile): """ Returns the scoring vector. This function is called by getCandScoresMap(). :ivar Profile profile: A Profile object that represents an election profile. """ # Check to make sure that the scoring vector contains a score for every possible ...
python
def getScoringVector(self, profile): """ Returns the scoring vector. This function is called by getCandScoresMap(). :ivar Profile profile: A Profile object that represents an election profile. """ # Check to make sure that the scoring vector contains a score for every possible ...
[ "def", "getScoringVector", "(", "self", ",", "profile", ")", ":", "# Check to make sure that the scoring vector contains a score for every possible rank in a", "# ranking.", "if", "len", "(", "self", ".", "scoringVector", ")", "!=", "profile", ".", "numCands", ":", "print...
Returns the scoring vector. This function is called by getCandScoresMap(). :ivar Profile profile: A Profile object that represents an election profile.
[ "Returns", "the", "scoring", "vector", ".", "This", "function", "is", "called", "by", "getCandScoresMap", "()", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L113-L126
train
Returns the scoring vector for the given election profile.
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", ")", ":", "# from . import mov", "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
Returns an integer that is equal to the margin of victory of the election profile.
PrefPy/prefpy
prefpy/mechanism.py
MechanismPlurality.getScoringVector
def getScoringVector(self, profile): """ Returns the scoring vector [1,0,0,...,0]. This function is called by getCandScoresMap() which is implemented in the parent class. :ivar Profile profile: A Profile object that represents an election profile. """ scoringVector = []...
python
def getScoringVector(self, profile): """ Returns the scoring vector [1,0,0,...,0]. This function is called by getCandScoresMap() which is implemented in the parent class. :ivar Profile profile: A Profile object that represents an election profile. """ scoringVector = []...
[ "def", "getScoringVector", "(", "self", ",", "profile", ")", ":", "scoringVector", "=", "[", "]", "scoringVector", ".", "append", "(", "1", ")", "for", "i", "in", "range", "(", "1", ",", "profile", ".", "numCands", ")", ":", "scoringVector", ".", "appe...
Returns the scoring vector [1,0,0,...,0]. This function is called by getCandScoresMap() which is implemented in the parent class. :ivar Profile profile: A Profile object that represents an election profile.
[ "Returns", "the", "scoring", "vector", "[", "1", "0", "0", "...", "0", "]", ".", "This", "function", "is", "called", "by", "getCandScoresMap", "()", "which", "is", "implemented", "in", "the", "parent", "class", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L213-L225
train
Returns the scoring vector for a given profile.
PrefPy/prefpy
prefpy/mechanism.py
MechanismBorda.getScoringVector
def getScoringVector(self, profile): """ Returns the scoring vector [m-1,m-2,m-3,...,0] where m is the number of candidates in the election profile. This function is called by getCandScoresMap() which is implemented in the parent class. :ivar Profile profile: A Profile object th...
python
def getScoringVector(self, profile): """ Returns the scoring vector [m-1,m-2,m-3,...,0] where m is the number of candidates in the election profile. This function is called by getCandScoresMap() which is implemented in the parent class. :ivar Profile profile: A Profile object th...
[ "def", "getScoringVector", "(", "self", ",", "profile", ")", ":", "scoringVector", "=", "[", "]", "score", "=", "profile", ".", "numCands", "-", "1", "for", "i", "in", "range", "(", "0", ",", "profile", ".", "numCands", ")", ":", "scoringVector", ".", ...
Returns the scoring vector [m-1,m-2,m-3,...,0] where m is the number of candidates in the election profile. This function is called by getCandScoresMap() which is implemented in the parent class. :ivar Profile profile: A Profile object that represents an election profile.
[ "Returns", "the", "scoring", "vector", "[", "m", "-", "1", "m", "-", "2", "m", "-", "3", "...", "0", "]", "where", "m", "is", "the", "number", "of", "candidates", "in", "the", "election", "profile", ".", "This", "function", "is", "called", "by", "g...
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L279-L293
train
Returns the scoring vector for the given profile.
PrefPy/prefpy
prefpy/mechanism.py
MechanismKApproval.getScoringVector
def getScoringVector(self, profile): """ Returns a scoring vector such that the first k candidates recieve 1 point and all others recive 0 This function is called by getCandScoresMap() which is implemented in the parent class. :ivar Profile profile: A Profile object that repres...
python
def getScoringVector(self, profile): """ Returns a scoring vector such that the first k candidates recieve 1 point and all others recive 0 This function is called by getCandScoresMap() which is implemented in the parent class. :ivar Profile profile: A Profile object that repres...
[ "def", "getScoringVector", "(", "self", ",", "profile", ")", ":", "if", "self", ".", "k", ">", "profile", ".", "numCands", ":", "self", ".", "k", "=", "profile", ".", "numCands", "scoringVector", "=", "[", "]", "for", "i", "in", "range", "(", "0", ...
Returns a scoring vector such that the first k candidates recieve 1 point and all others recive 0 This function is called by getCandScoresMap() which is implemented in the parent class. :ivar Profile profile: A Profile object that represents an election profile.
[ "Returns", "a", "scoring", "vector", "such", "that", "the", "first", "k", "candidates", "recieve", "1", "point", "and", "all", "others", "recive", "0", "This", "function", "is", "called", "by", "getCandScoresMap", "()", "which", "is", "implemented", "in", "t...
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L307-L324
train
Returns a scoring vector such that the first k candidates recieve 1 point and all others recieve 0.
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", ")", ":", "# Currently, we expect the profile to contain complete ordering over candidates.", "elecType", "=", "profile", ".", "getElecType", "(", ")", "if", "elecType", "!=", "\"soc\"", "and", "elecType", "!=", "\...
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
Returns a dictionary that associates integer representations of each candidate with their Bucklin score.
PrefPy/prefpy
prefpy/mechanism.py
MechanismCopeland.getCandScoresMap
def getCandScoresMap(self, profile): """ Returns a dictionary that associates integer representations of each candidate with their Copeland score. :ivar Profile profile: A Profile object that represents an election profile. """ # Currently, we expect the profile to cont...
python
def getCandScoresMap(self, profile): """ Returns a dictionary that associates integer representations of each candidate with their Copeland score. :ivar Profile profile: A Profile object that represents an election profile. """ # Currently, we expect the profile to cont...
[ "def", "getCandScoresMap", "(", "self", ",", "profile", ")", ":", "# Currently, we expect the profile to contain complete ordering over candidates. Ties are", "# allowed however.", "elecType", "=", "profile", ".", "getElecType", "(", ")", "if", "elecType", "!=", "\"soc\"", ...
Returns a dictionary that associates integer representations of each candidate with their Copeland score. :ivar Profile profile: A Profile object that represents an election profile.
[ "Returns", "a", "dictionary", "that", "associates", "integer", "representations", "of", "each", "candidate", "with", "their", "Copeland", "score", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L389-L425
train
Returns a dictionary that associates integer representations of each candidate with their Copeland score.
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", ")", ":", "# Currently, we expect the profile to contain complete ordering over candidates. Ties are", "# allowed however.", "elecType", "=", "profile", ".", "getElecType", "(", ")", "if", "elecType", "!=", "\"soc\"", ...
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
Returns a dictionary that associates integer representations of each candidate with their maximin score.
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", ")", "# Initialize the two-dimensional dictionary that will hold ...
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
Computes the strongest paths between the candidates cand1 and cand2.
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", "(", ")", "# Initialize the two-dimensional dictionary that will hold our pairwise preferences.", "pairwisePreferences", "=", "dict", "(", ")"...
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
Computes the pairwise preferences for each pair of candidates cand1 and cand2.
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
Returns a dictionary that associates integer representations of each candidate with the number of other candidates for which the strongest path to the other candidate is greater than the other candidate s stronget path to her.
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
Returns a list of all possible winners of a profile under STV rule.
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
Returns a list of all possible winners of a profile under baldwin rule.
PrefPy/prefpy
prefpy/mechanism.py
MechanismCoombs.coombs_winners
def coombs_winners(self, profile): """ Returns an integer list that represents all possible winners of a profile under Coombs rule. :ivar Profile profile: A Profile object that represents an election profile. """ elecType = profile.getElecType() if elecType == "soc" or e...
python
def coombs_winners(self, profile): """ Returns an integer list that represents all possible winners of a profile under Coombs rule. :ivar Profile profile: A Profile object that represents an election profile. """ elecType = profile.getElecType() if elecType == "soc" or e...
[ "def", "coombs_winners", "(", "self", ",", "profile", ")", ":", "elecType", "=", "profile", ".", "getElecType", "(", ")", "if", "elecType", "==", "\"soc\"", "or", "elecType", "==", "\"csv\"", ":", "return", "self", ".", "coombssoc_winners", "(", "profile", ...
Returns an integer list that represents all possible winners of a profile under Coombs 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", "Coombs", "rule", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L1012-L1025
train
Returns an integer list that represents all possible winners of a profile under Coombs rule.
PrefPy/prefpy
prefpy/mechanism.py
MechanismCoombs.coombstoc_winners
def coombstoc_winners(self, profile): """ Returns an integer list that represents all possible winners of a profile under Coombs rule. :ivar Profile profile: A Profile object that represents an election profile. """ ordering = profile.getOrderVectors() m = profile.numCan...
python
def coombstoc_winners(self, profile): """ Returns an integer list that represents all possible winners of a profile under Coombs rule. :ivar Profile profile: A Profile object that represents an election profile. """ ordering = profile.getOrderVectors() m = profile.numCan...
[ "def", "coombstoc_winners", "(", "self", ",", "profile", ")", ":", "ordering", "=", "profile", ".", "getOrderVectors", "(", ")", "m", "=", "profile", ".", "numCands", "prefcounts", "=", "profile", ".", "getPreferenceCounts", "(", ")", "rankmaps", "=", "profi...
Returns an integer list that represents all possible winners of a profile under Coombs 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", "Coombs", "rule", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L1096-L1155
train
Returns a list of all possible winners of a profile under Coombs rule.
PrefPy/prefpy
prefpy/mechanism.py
MechanismRankedPairs.add_winners
def add_winners(self, G, I, known_winners, stats, possible_winners = None): """ Adds the winners of completed RP graph G :param G: networkx graph, should be final resulting graph after running RP :param I: list of all nodes :param known_winners: list of winners found so far, will...
python
def add_winners(self, G, I, known_winners, stats, possible_winners = None): """ Adds the winners of completed RP graph G :param G: networkx graph, should be final resulting graph after running RP :param I: list of all nodes :param known_winners: list of winners found so far, will...
[ "def", "add_winners", "(", "self", ",", "G", ",", "I", ",", "known_winners", ",", "stats", ",", "possible_winners", "=", "None", ")", ":", "if", "possible_winners", "is", "None", ":", "G_in_degree", "=", "G", ".", "in_degree", "(", "I", ")", "to_be_added...
Adds the winners of completed RP graph G :param G: networkx graph, should be final resulting graph after running RP :param I: list of all nodes :param known_winners: list of winners found so far, will be updated :param stats: Stats class storing run statistics :param possible_win...
[ "Adds", "the", "winners", "of", "completed", "RP", "graph", "G", ":", "param", "G", ":", "networkx", "graph", "should", "be", "final", "resulting", "graph", "after", "running", "RP", ":", "param", "I", ":", "list", "of", "all", "nodes", ":", "param", "...
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L1231-L1251
train
Adds the winners of completed RP graph G I to known_winners.
PrefPy/prefpy
prefpy/mechanism.py
MechanismRankedPairs.stop_conditions
def stop_conditions(self, G, E, I, known_winners, stats): """ Determines if G, E state can be ended early :param G: networkx DiGraph of the current representation of "locked in" edges in RP :param E: networkx DiGraph of the remaining edges not yet considered :param I: list of all...
python
def stop_conditions(self, G, E, I, known_winners, stats): """ Determines if G, E state can be ended early :param G: networkx DiGraph of the current representation of "locked in" edges in RP :param E: networkx DiGraph of the remaining edges not yet considered :param I: list of all...
[ "def", "stop_conditions", "(", "self", ",", "G", ",", "E", ",", "I", ",", "known_winners", ",", "stats", ")", ":", "in_deg", "=", "G", ".", "in_degree", "(", "I", ")", "possible_winners", "=", "[", "x", "[", "0", "]", "for", "x", "in", "in_deg", ...
Determines if G, E state can be ended early :param G: networkx DiGraph of the current representation of "locked in" edges in RP :param E: networkx DiGraph of the remaining edges not yet considered :param I: list of all nodes :param known_winners: list of currently known PUT-winners ...
[ "Determines", "if", "G", "E", "state", "can", "be", "ended", "early", ":", "param", "G", ":", "networkx", "DiGraph", "of", "the", "current", "representation", "of", "locked", "in", "edges", "in", "RP", ":", "param", "E", ":", "networkx", "DiGraph", "of",...
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L1253-L1291
train
Determines if the stop condition met for the current state of the current edge G and E.
PrefPy/prefpy
prefpy/mechanism.py
MechanismRankedPairs.find_max_children_scc_decomposition
def find_max_children_scc_decomposition(self, G, tier, scc, bridges, I, known_winners, stats): ''' Finds the maximal children of G when tier is added using SCC decomposition :param G: Networkx DiGraph of edges "locked in" so far :param tier: List of edges in the current tier to be added ...
python
def find_max_children_scc_decomposition(self, G, tier, scc, bridges, I, known_winners, stats): ''' Finds the maximal children of G when tier is added using SCC decomposition :param G: Networkx DiGraph of edges "locked in" so far :param tier: List of edges in the current tier to be added ...
[ "def", "find_max_children_scc_decomposition", "(", "self", ",", "G", ",", "tier", ",", "scc", ",", "bridges", ",", "I", ",", "known_winners", ",", "stats", ")", ":", "if", "len", "(", "scc", ")", "==", "1", ":", "children", "=", "self", ".", "explore_m...
Finds the maximal children of G when tier is added using SCC decomposition :param G: Networkx DiGraph of edges "locked in" so far :param tier: List of edges in the current tier to be added with equal weight :param scc: List of the strongly connected components of G U tier, each being a list of e...
[ "Finds", "the", "maximal", "children", "of", "G", "when", "tier", "is", "added", "using", "SCC", "decomposition", ":", "param", "G", ":", "Networkx", "DiGraph", "of", "edges", "locked", "in", "so", "far", ":", "param", "tier", ":", "List", "of", "edges",...
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L1467-L1493
train
Finds the maximal children of G when tier is added using SCC decomposition.
PrefPy/prefpy
prefpy/mechanism.py
MechanismRankedPairs.explore_max_children_lp
def explore_max_children_lp(self, G, tier, I, known_winners, stats, f_scc = 0): """ Computes the maximal children of G when tier is added :param G: DiGraph, A directed graph :param tier: list of tuples which correspond to multiple edges with same max weight. e.g. edge...
python
def explore_max_children_lp(self, G, tier, I, known_winners, stats, f_scc = 0): """ Computes the maximal children of G when tier is added :param G: DiGraph, A directed graph :param tier: list of tuples which correspond to multiple edges with same max weight. e.g. edge...
[ "def", "explore_max_children_lp", "(", "self", ",", "G", ",", "tier", ",", "I", ",", "known_winners", ",", "stats", ",", "f_scc", "=", "0", ")", ":", "# self.output_graph(G)", "# self.output_graph(nx.DiGraph(tier))", "max_children", "=", "[", "]", "cstack", "=",...
Computes the maximal children of G when tier is added :param G: DiGraph, A directed graph :param tier: list of tuples which correspond to multiple edges with same max weight. e.g. edges = [x for x in wmg2.keys() if wmg2[x] == max_weight] :param I: all nodes in G :para...
[ "Computes", "the", "maximal", "children", "of", "G", "when", "tier", "is", "added", ":", "param", "G", ":", "DiGraph", "A", "directed", "graph", ":", "param", "tier", ":", "list", "of", "tuples", "which", "correspond", "to", "multiple", "edges", "with", ...
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L1495-L1696
train
This function calculates the maximum children of a given tier.
PrefPy/prefpy
prefpy/mechanism.py
MechanismRankedPairs.sample
def sample(self, E, I, known_winners, stats): ''' Using random tie-breaking, run through one procedure of RP and add resulting winner to known_winners :param E: DiGraph, All postive edges in the wmg :param I: List of all nodes in E :param known_winners: Set of already-discovered ...
python
def sample(self, E, I, known_winners, stats): ''' Using random tie-breaking, run through one procedure of RP and add resulting winner to known_winners :param E: DiGraph, All postive edges in the wmg :param I: List of all nodes in E :param known_winners: Set of already-discovered ...
[ "def", "sample", "(", "self", ",", "E", ",", "I", ",", "known_winners", ",", "stats", ")", ":", "G", "=", "nx", ".", "DiGraph", "(", ")", "G", ".", "add_nodes_from", "(", "I", ")", "Ec", "=", "E", ".", "copy", "(", ")", "while", "len", "(", "...
Using random tie-breaking, run through one procedure of RP and add resulting winner to known_winners :param E: DiGraph, All postive edges in the wmg :param I: List of all nodes in E :param known_winners: Set of already-discovered PUT-winners to be added to :param stats: Stats object stor...
[ "Using", "random", "tie", "-", "breaking", "run", "through", "one", "procedure", "of", "RP", "and", "add", "resulting", "winner", "to", "known_winners", ":", "param", "E", ":", "DiGraph", "All", "postive", "edges", "in", "the", "wmg", ":", "param", "I", ...
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L1698-L1739
train
This method is used to sample from the given set of known winners.
PrefPy/prefpy
prefpy/mechanism.py
MechanismBlack.black_winner
def black_winner(self, profile): """ Returns a number or a list that associates the winner(s) of a profile under black rule. :ivar Profile profile: A Profile object that represents an election profile. """ # Currently, we expect the profile to contain complete ordering over can...
python
def black_winner(self, profile): """ Returns a number or a list that associates the winner(s) of a profile under black rule. :ivar Profile profile: A Profile object that represents an election profile. """ # Currently, we expect the profile to contain complete ordering over can...
[ "def", "black_winner", "(", "self", ",", "profile", ")", ":", "# Currently, we expect the profile to contain complete ordering over candidates. Ties are", "# allowed however.", "elecType", "=", "profile", ".", "getElecType", "(", ")", "if", "elecType", "!=", "\"soc\"", "and...
Returns a number or a list that associates the winner(s) of a profile under black rule. :ivar Profile profile: A Profile object that represents an election profile.
[ "Returns", "a", "number", "or", "a", "list", "that", "associates", "the", "winner", "(", "s", ")", "of", "a", "profile", "under", "black", "rule", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L1747-L1772
train
Returns a number or a list that associates the winner of a profile under black rule.
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", ")", ":", "# Currently, we expect the profile to contain complete ordering over candidates. Ties are", "# allowed however.", "elecType", "=", "profile", ".", "getElecType", "(", ")", "if", "elecType", "!=", "\"soc...
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
This function returns the number that associates the winner of a profile under Plurality with Runoff rule.
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", ")", ":", "# Currently, we expect the profile to contain complete ordering over candidates. Ties are", "# allowed however.", "elecType", "=", "profile", ".", "getElecType", "(", ")", "if", "elecType", "!=", "\"soc\"",...
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
Returns a list of all the winners of a profile under Plurality with Runoff rule.
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", ")", ":", "# Currently, we expect the profile to contain complete ordering over candidates. Ties are", "# allowed however.", "elecType", "=", "profile", ".", "getElecType", "(", ")", "if", "elecType", "!=", "\"...
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
Returns a list that associates all the winners of a profile under Single non - transferable vote rule.
PrefPy/prefpy
prefpy/mechanism.py
MechanismChamberlin_Courant.single_peaked_winners
def single_peaked_winners(self, profile, d=1, K=3, funcType='Borda', scoringVector=[]): """ Returns a list that associates all the winners of a profile under The Chamberlin–Courant rule. :ivar Profile profile: A Profile object that represents an election profile. """ # Currentl...
python
def single_peaked_winners(self, profile, d=1, K=3, funcType='Borda', scoringVector=[]): """ Returns a list that associates all the winners of a profile under The Chamberlin–Courant rule. :ivar Profile profile: A Profile object that represents an election profile. """ # Currentl...
[ "def", "single_peaked_winners", "(", "self", ",", "profile", ",", "d", "=", "1", ",", "K", "=", "3", ",", "funcType", "=", "'Borda'", ",", "scoringVector", "=", "[", "]", ")", ":", "# Currently, we expect the profile to contain complete ordering over candidates. Tie...
Returns a list that associates all the winners of a profile under The Chamberlin–Courant 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", "Chamberlin–Courant", "rule", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L1939-L2006
train
Returns a list of all the winners of a profile under the Chamberlin–Courant rule.
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
Returns a list that associates all the winners of a profile under The Borda - mean rule.
PrefPy/prefpy
prefpy/mechanism.py
MechanismBordaMean._build_mat
def _build_mat(self, ranks, n_candidates, prefcounts): """ Builds mxm matrix. Entry at i,j has #i>j - #i<j :param ranks: :return: mxm matrix """ mat = zeros((n_candidates, n_candidates)) for i, j in itertools.combinations(range(n_candidates), 2): pre...
python
def _build_mat(self, ranks, n_candidates, prefcounts): """ Builds mxm matrix. Entry at i,j has #i>j - #i<j :param ranks: :return: mxm matrix """ mat = zeros((n_candidates, n_candidates)) for i, j in itertools.combinations(range(n_candidates), 2): pre...
[ "def", "_build_mat", "(", "self", ",", "ranks", ",", "n_candidates", ",", "prefcounts", ")", ":", "mat", "=", "zeros", "(", "(", "n_candidates", ",", "n_candidates", ")", ")", "for", "i", ",", "j", "in", "itertools", ".", "combinations", "(", "range", ...
Builds mxm matrix. Entry at i,j has #i>j - #i<j :param ranks: :return: mxm matrix
[ "Builds", "mxm", "matrix", ".", "Entry", "at", "i", "j", "has", "#i", ">", "j", "-", "#i<j", ":", "param", "ranks", ":", ":", "return", ":", "mxm", "matrix" ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanism.py#L2070-L2084
train
Builds the mxm matrix. Entry at i j has i > j - i < j
tamasgal/km3pipe
km3pipe/calib.py
apply_t0_nb
def apply_t0_nb(times, dom_ids, channel_ids, lookup_tables): """Apply t0s using a lookup table of tuples (dom_id, calib)""" dom_id = 0 lookup = np.empty((31, 9)) for i in range(len(times)): cur_dom_id = dom_ids[i] if cur_dom_id != dom_id: dom_id = cur_dom_id for (...
python
def apply_t0_nb(times, dom_ids, channel_ids, lookup_tables): """Apply t0s using a lookup table of tuples (dom_id, calib)""" dom_id = 0 lookup = np.empty((31, 9)) for i in range(len(times)): cur_dom_id = dom_ids[i] if cur_dom_id != dom_id: dom_id = cur_dom_id for (...
[ "def", "apply_t0_nb", "(", "times", ",", "dom_ids", ",", "channel_ids", ",", "lookup_tables", ")", ":", "dom_id", "=", "0", "lookup", "=", "np", ".", "empty", "(", "(", "31", ",", "9", ")", ")", "for", "i", "in", "range", "(", "len", "(", "times", ...
Apply t0s using a lookup table of tuples (dom_id, calib)
[ "Apply", "t0s", "using", "a", "lookup", "table", "of", "tuples", "(", "dom_id", "calib", ")" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/calib.py#L267-L279
train
Apply t0s using a lookup table of tuples ( dom_id calib
tamasgal/km3pipe
km3pipe/calib.py
_get_calibration_for_hits
def _get_calibration_for_hits(hits, lookup): """Append the position, direction and t0 columns and add t0 to time""" n = len(hits) cal = np.empty((n, 9)) for i in range(n): calib = lookup[hits['dom_id'][i]][hits['channel_id'][i]] cal[i] = calib dir_x = cal[:, 3] dir_y = cal[:, 4] ...
python
def _get_calibration_for_hits(hits, lookup): """Append the position, direction and t0 columns and add t0 to time""" n = len(hits) cal = np.empty((n, 9)) for i in range(n): calib = lookup[hits['dom_id'][i]][hits['channel_id'][i]] cal[i] = calib dir_x = cal[:, 3] dir_y = cal[:, 4] ...
[ "def", "_get_calibration_for_hits", "(", "hits", ",", "lookup", ")", ":", "n", "=", "len", "(", "hits", ")", "cal", "=", "np", ".", "empty", "(", "(", "n", ",", "9", ")", ")", "for", "i", "in", "range", "(", "n", ")", ":", "calib", "=", "lookup...
Append the position, direction and t0 columns and add t0 to time
[ "Append", "the", "position", "direction", "and", "t0", "columns", "and", "add", "t0", "to", "time" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/calib.py#L283-L301
train
Return the calibration for a given list of hits.
tamasgal/km3pipe
km3pipe/calib.py
_get_calibration_for_mchits
def _get_calibration_for_mchits(hits, lookup): """Append the position, direction and t0 columns and add t0 to time""" n_hits = len(hits) cal = np.empty((n_hits, 9)) for i in range(n_hits): cal[i] = lookup[hits['pmt_id'][i]] dir_x = cal[:, 3] dir_y = cal[:, 4] dir_z = cal[:, 5] du...
python
def _get_calibration_for_mchits(hits, lookup): """Append the position, direction and t0 columns and add t0 to time""" n_hits = len(hits) cal = np.empty((n_hits, 9)) for i in range(n_hits): cal[i] = lookup[hits['pmt_id'][i]] dir_x = cal[:, 3] dir_y = cal[:, 4] dir_z = cal[:, 5] du...
[ "def", "_get_calibration_for_mchits", "(", "hits", ",", "lookup", ")", ":", "n_hits", "=", "len", "(", "hits", ")", "cal", "=", "np", ".", "empty", "(", "(", "n_hits", ",", "9", ")", ")", "for", "i", "in", "range", "(", "n_hits", ")", ":", "cal", ...
Append the position, direction and t0 columns and add t0 to time
[ "Append", "the", "position", "direction", "and", "t0", "columns", "and", "add", "t0", "to", "time" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/calib.py#L305-L321
train
Return the calibration for the given list of hits.
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
Apply only t0s
tamasgal/km3pipe
km3pipe/calib.py
Calibration.apply
def apply(self, hits, no_copy=False): """Add x, y, z, t0 (and du, floor if DataFrame) columns to the hits. """ if not no_copy: hits = hits.copy() if istype(hits, 'DataFrame'): # do we ever see McHits here? hits = Table.from_template(hits, 'Hits') ...
python
def apply(self, hits, no_copy=False): """Add x, y, z, t0 (and du, floor if DataFrame) columns to the hits. """ if not no_copy: hits = hits.copy() if istype(hits, 'DataFrame'): # do we ever see McHits here? hits = Table.from_template(hits, 'Hits') ...
[ "def", "apply", "(", "self", ",", "hits", ",", "no_copy", "=", "False", ")", ":", "if", "not", "no_copy", ":", "hits", "=", "hits", ".", "copy", "(", ")", "if", "istype", "(", "hits", ",", "'DataFrame'", ")", ":", "# do we ever see McHits here?", "hits...
Add x, y, z, t0 (and du, floor if DataFrame) columns to the hits.
[ "Add", "x", "y", "z", "t0", "(", "and", "du", "floor", "if", "DataFrame", ")", "columns", "to", "the", "hits", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/calib.py#L132-L214
train
Applies the calibration to the given DataFrame.
tamasgal/km3pipe
km3pipe/io/evt.py
parse_corant
def parse_corant(blob): """Creates new blob entries for the given blob keys""" if 'track_seamuon' in blob.keys(): muon = blob['track_seamuon'] blob['Muon'] = Table({ 'id': np.array(muon)[:, 0].astype(int), 'pos_x': np.array(muon)[:, 1], 'pos_y': np.array(mu...
python
def parse_corant(blob): """Creates new blob entries for the given blob keys""" if 'track_seamuon' in blob.keys(): muon = blob['track_seamuon'] blob['Muon'] = Table({ 'id': np.array(muon)[:, 0].astype(int), 'pos_x': np.array(muon)[:, 1], 'pos_y': np.array(mu...
[ "def", "parse_corant", "(", "blob", ")", ":", "if", "'track_seamuon'", "in", "blob", ".", "keys", "(", ")", ":", "muon", "=", "blob", "[", "'track_seamuon'", "]", "blob", "[", "'Muon'", "]", "=", "Table", "(", "{", "'id'", ":", "np", ".", "array", ...
Creates new blob entries for the given blob keys
[ "Creates", "new", "blob", "entries", "for", "the", "given", "blob", "keys" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/evt.py#L487-L572
train
Parses the corpus blob and returns a new blob entries for the given keys
tamasgal/km3pipe
km3pipe/io/evt.py
EvtPump._reset
def _reset(self): """Clear the cache.""" self.log.info("Clearing the cache, resetting event offsets") self.raw_header = None self.event_offsets = [] self.index = 0
python
def _reset(self): """Clear the cache.""" self.log.info("Clearing the cache, resetting event offsets") self.raw_header = None self.event_offsets = [] self.index = 0
[ "def", "_reset", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "\"Clearing the cache, resetting event offsets\"", ")", "self", ".", "raw_header", "=", "None", "self", ".", "event_offsets", "=", "[", "]", "self", ".", "index", "=", "0" ]
Clear the cache.
[ "Clear", "the", "cache", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/evt.py#L149-L154
train
Clear the cache.
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
Create a string out of the current file index
tamasgal/km3pipe
km3pipe/io/evt.py
EvtPump.prepare_blobs
def prepare_blobs(self): """Populate the blobs""" self.raw_header = self.extract_header() if self.cache_enabled: self._cache_offsets()
python
def prepare_blobs(self): """Populate the blobs""" self.raw_header = self.extract_header() if self.cache_enabled: self._cache_offsets()
[ "def", "prepare_blobs", "(", "self", ")", ":", "self", ".", "raw_header", "=", "self", ".", "extract_header", "(", ")", "if", "self", ".", "cache_enabled", ":", "self", ".", "_cache_offsets", "(", ")" ]
Populate the blobs
[ "Populate", "the", "blobs" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/evt.py#L163-L167
train
Populate the blobs
tamasgal/km3pipe
km3pipe/io/evt.py
EvtPump.extract_header
def extract_header(self): """Create a dictionary with the EVT header information""" self.log.info("Extracting the header") raw_header = self.raw_header = defaultdict(list) first_line = self.blob_file.readline() first_line = try_decode_string(first_line) self.blob_file.see...
python
def extract_header(self): """Create a dictionary with the EVT header information""" self.log.info("Extracting the header") raw_header = self.raw_header = defaultdict(list) first_line = self.blob_file.readline() first_line = try_decode_string(first_line) self.blob_file.see...
[ "def", "extract_header", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "\"Extracting the header\"", ")", "raw_header", "=", "self", ".", "raw_header", "=", "defaultdict", "(", "list", ")", "first_line", "=", "self", ".", "blob_file", ".", "r...
Create a dictionary with the EVT header information
[ "Create", "a", "dictionary", "with", "the", "EVT", "header", "information" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/evt.py#L169-L193
train
Extracts the EVT header information from the file and returns the dictionary with the EVT header information.
tamasgal/km3pipe
km3pipe/io/evt.py
EvtPump.get_blob
def get_blob(self, index): """Return a blob with the event at the given index""" self.log.info("Retrieving blob #{}".format(index)) if index > len(self.event_offsets) - 1: self.log.info("Index not in cache, caching offsets") self._cache_offsets(index, verbose=False) ...
python
def get_blob(self, index): """Return a blob with the event at the given index""" self.log.info("Retrieving blob #{}".format(index)) if index > len(self.event_offsets) - 1: self.log.info("Index not in cache, caching offsets") self._cache_offsets(index, verbose=False) ...
[ "def", "get_blob", "(", "self", ",", "index", ")", ":", "self", ".", "log", ".", "info", "(", "\"Retrieving blob #{}\"", ".", "format", "(", "index", ")", ")", "if", "index", ">", "len", "(", "self", ".", "event_offsets", ")", "-", "1", ":", "self", ...
Return a blob with the event at the given index
[ "Return", "a", "blob", "with", "the", "event", "at", "the", "given", "index" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/evt.py#L195-L211
train
Return a blob with the event at the given index
tamasgal/km3pipe
km3pipe/io/evt.py
EvtPump.process
def process(self, blob=None): """Pump the next blob to the modules""" try: blob = self.get_blob(self.index) except IndexError: self.log.info("Got an IndexError, trying the next file") if (self.basename or self.filenames) and self.file_inde...
python
def process(self, blob=None): """Pump the next blob to the modules""" try: blob = self.get_blob(self.index) except IndexError: self.log.info("Got an IndexError, trying the next file") if (self.basename or self.filenames) and self.file_inde...
[ "def", "process", "(", "self", ",", "blob", "=", "None", ")", ":", "try", ":", "blob", "=", "self", ".", "get_blob", "(", "self", ".", "index", ")", "except", "IndexError", ":", "self", ".", "log", ".", "info", "(", "\"Got an IndexError, trying the next ...
Pump the next blob to the modules
[ "Pump", "the", "next", "blob", "to", "the", "modules" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/evt.py#L213-L250
train
Pump the next blob to the modules
tamasgal/km3pipe
km3pipe/io/evt.py
EvtPump._cache_offsets
def _cache_offsets(self, up_to_index=None, verbose=True): """Cache all event offsets.""" if not up_to_index: if verbose: self.print("Caching event file offsets, this may take a bit.") self.blob_file.seek(0, 0) self.event_offsets = [] if not...
python
def _cache_offsets(self, up_to_index=None, verbose=True): """Cache all event offsets.""" if not up_to_index: if verbose: self.print("Caching event file offsets, this may take a bit.") self.blob_file.seek(0, 0) self.event_offsets = [] if not...
[ "def", "_cache_offsets", "(", "self", ",", "up_to_index", "=", "None", ",", "verbose", "=", "True", ")", ":", "if", "not", "up_to_index", ":", "if", "verbose", ":", "self", ".", "print", "(", "\"Caching event file offsets, this may take a bit.\"", ")", "self", ...
Cache all event offsets.
[ "Cache", "all", "event", "offsets", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/evt.py#L252-L276
train
Cache all event offsets.
tamasgal/km3pipe
km3pipe/io/evt.py
EvtPump._record_offset
def _record_offset(self): """Stores the current file pointer position""" offset = self.blob_file.tell() self.event_offsets.append(offset)
python
def _record_offset(self): """Stores the current file pointer position""" offset = self.blob_file.tell() self.event_offsets.append(offset)
[ "def", "_record_offset", "(", "self", ")", ":", "offset", "=", "self", ".", "blob_file", ".", "tell", "(", ")", "self", ".", "event_offsets", ".", "append", "(", "offset", ")" ]
Stores the current file pointer position
[ "Stores", "the", "current", "file", "pointer", "position" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/evt.py#L278-L281
train
Stores the current file pointer position
tamasgal/km3pipe
km3pipe/io/evt.py
EvtPump._create_blob
def _create_blob(self): """Parse the next event from the current file position""" blob = None for line in self.blob_file: line = try_decode_string(line) line = line.strip() if line == '': self.log.info("Ignoring empty line...") ...
python
def _create_blob(self): """Parse the next event from the current file position""" blob = None for line in self.blob_file: line = try_decode_string(line) line = line.strip() if line == '': self.log.info("Ignoring empty line...") ...
[ "def", "_create_blob", "(", "self", ")", ":", "blob", "=", "None", "for", "line", "in", "self", ".", "blob_file", ":", "line", "=", "try_decode_string", "(", "line", ")", "line", "=", "line", ".", "strip", "(", ")", "if", "line", "==", "''", ":", "...
Parse the next event from the current file position
[ "Parse", "the", "next", "event", "from", "the", "current", "file", "position" ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/io/evt.py#L283-L310
train
Parse the next event from the current file position
abiiranathan/db2
db2/__main__.py
runserver
def runserver(project_name): ''' Runs a python cgi server in a subprocess. ''' DIR = os.listdir(project_name) if 'settings.py' not in DIR: raise NotImplementedError('No file called: settings.py found in %s'%project_name) CGI_BIN_FOLDER = os.path.join(project_name, 'cgi', 'cgi-bin') CGI_FOLDER = os.path.join(...
python
def runserver(project_name): ''' Runs a python cgi server in a subprocess. ''' DIR = os.listdir(project_name) if 'settings.py' not in DIR: raise NotImplementedError('No file called: settings.py found in %s'%project_name) CGI_BIN_FOLDER = os.path.join(project_name, 'cgi', 'cgi-bin') CGI_FOLDER = os.path.join(...
[ "def", "runserver", "(", "project_name", ")", ":", "DIR", "=", "os", ".", "listdir", "(", "project_name", ")", "if", "'settings.py'", "not", "in", "DIR", ":", "raise", "NotImplementedError", "(", "'No file called: settings.py found in %s'", "%", "project_name", ")...
Runs a python cgi server in a subprocess.
[ "Runs", "a", "python", "cgi", "server", "in", "a", "subprocess", "." ]
347319e421921517bcae7639f524c3c3eb5446e6
https://github.com/abiiranathan/db2/blob/347319e421921517bcae7639f524c3c3eb5446e6/db2/__main__.py#L44-L59
train
Runs a python cgi server in a subprocess.
PrefPy/prefpy
prefpy/utilityFunction.py
UtilityFunction.getUtility
def getUtility(self, decision, sample, aggregationMode = "avg"): """ Get the utility of a given decision given a preference. :ivar list<int> decision: Contains a list of integer representations of candidates in the current decision. :ivar sample: A representation of a pref...
python
def getUtility(self, decision, sample, aggregationMode = "avg"): """ Get the utility of a given decision given a preference. :ivar list<int> decision: Contains a list of integer representations of candidates in the current decision. :ivar sample: A representation of a pref...
[ "def", "getUtility", "(", "self", ",", "decision", ",", "sample", ",", "aggregationMode", "=", "\"avg\"", ")", ":", "utilities", "=", "self", ".", "getUtilities", "(", "decision", ",", "sample", ")", "if", "aggregationMode", "==", "\"avg\"", ":", "utility", ...
Get the utility of a given decision given a preference. :ivar list<int> decision: Contains a list of integer representations of candidates in the current decision. :ivar sample: A representation of a preference. We do not assume that it is of a certain type here and merely pa...
[ "Get", "the", "utility", "of", "a", "given", "decision", "given", "a", "preference", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/utilityFunction.py#L13-L37
train
Get the utility function of a given decision and sample.
PrefPy/prefpy
prefpy/utilityFunction.py
UtilityFunctionMallowsPosScoring.getUtilities
def getUtilities(self, decision, orderVector): """ Returns a floats that contains the utilities of every candidate in the decision. :ivar list<int> decision: Contains a list of integer representations of candidates in the current decision. :ivar list<int> orderVector: A lis...
python
def getUtilities(self, decision, orderVector): """ Returns a floats that contains the utilities of every candidate in the decision. :ivar list<int> decision: Contains a list of integer representations of candidates in the current decision. :ivar list<int> orderVector: A lis...
[ "def", "getUtilities", "(", "self", ",", "decision", ",", "orderVector", ")", ":", "scoringVector", "=", "self", ".", "getScoringVector", "(", "orderVector", ")", "utilities", "=", "[", "]", "for", "alt", "in", "decision", ":", "altPosition", "=", "orderVect...
Returns a floats that contains the utilities of every candidate in the decision. :ivar list<int> decision: Contains a list of integer representations of candidates in the current decision. :ivar list<int> orderVector: A list of integer representations for each candidate ordered ...
[ "Returns", "a", "floats", "that", "contains", "the", "utilities", "of", "every", "candidate", "in", "the", "decision", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/utilityFunction.py#L59-L77
train
Returns a list of floats that contains the utilities of every candidate in the current decision.
PrefPy/prefpy
prefpy/utilityFunction.py
UtilityFunctionMallowsTopK.getScoringVector
def getScoringVector(self, orderVector): """ Returns a scoring vector such that the first k candidates recieve 1 point and all others recive 0 This function is called by getUtilities() which is implemented in the parent class. :ivar list<int> orderVector: A list of integer rep...
python
def getScoringVector(self, orderVector): """ Returns a scoring vector such that the first k candidates recieve 1 point and all others recive 0 This function is called by getUtilities() which is implemented in the parent class. :ivar list<int> orderVector: A list of integer rep...
[ "def", "getScoringVector", "(", "self", ",", "orderVector", ")", ":", "scoringVector", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "self", ".", "k", ")", ":", "scoringVector", ".", "append", "(", "1", ")", "for", "i", "in", "range", "(...
Returns a scoring vector such that the first k candidates recieve 1 point and all others recive 0 This function is called by getUtilities() which is implemented in the parent class. :ivar list<int> orderVector: A list of integer representations for each candidate ordered from most...
[ "Returns", "a", "scoring", "vector", "such", "that", "the", "first", "k", "candidates", "recieve", "1", "point", "and", "all", "others", "recive", "0", "This", "function", "is", "called", "by", "getUtilities", "()", "which", "is", "implemented", "in", "the",...
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/utilityFunction.py#L89-L104
train
Returns a scoring vector such that the first k candidates recieve 1 point and all others recive 0.
PrefPy/prefpy
prefpy/utilityFunction.py
UtilityFunctionMallowsZeroOne.getScoringVector
def getScoringVector(self, orderVector): """ Returns the scoring vector [1,0,0,...,0]. This function is called by getUtilities() which is implemented in the parent class. :ivar list<int> orderVector: A list of integer representations for each candidate ordered from most pre...
python
def getScoringVector(self, orderVector): """ Returns the scoring vector [1,0,0,...,0]. This function is called by getUtilities() which is implemented in the parent class. :ivar list<int> orderVector: A list of integer representations for each candidate ordered from most pre...
[ "def", "getScoringVector", "(", "self", ",", "orderVector", ")", ":", "scoringVector", "=", "[", "]", "scoringVector", ".", "append", "(", "1", ")", "for", "i", "in", "range", "(", "1", ",", "len", "(", "orderVector", ")", ")", ":", "scoringVector", "....
Returns the scoring vector [1,0,0,...,0]. This function is called by getUtilities() which is implemented in the parent class. :ivar list<int> orderVector: A list of integer representations for each candidate ordered from most preferred to least.
[ "Returns", "the", "scoring", "vector", "[", "1", "0", "0", "...", "0", "]", ".", "This", "function", "is", "called", "by", "getUtilities", "()", "which", "is", "implemented", "in", "the", "parent", "class", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/utilityFunction.py#L115-L128
train
Returns the scoring vector for the given orderVector.
PrefPy/prefpy
prefpy/utilityFunction.py
UtilityFunctionCondorcetTopK.getUtilities
def getUtilities(self, decision, binaryRelations): """ Returns a floats that contains the utilities of every candidate in the decision. This was adapted from code written by Lirong Xia. :ivar list<int> decision: Contains a list of integer representations of candidates in the ...
python
def getUtilities(self, decision, binaryRelations): """ Returns a floats that contains the utilities of every candidate in the decision. This was adapted from code written by Lirong Xia. :ivar list<int> decision: Contains a list of integer representations of candidates in the ...
[ "def", "getUtilities", "(", "self", ",", "decision", ",", "binaryRelations", ")", ":", "m", "=", "len", "(", "binaryRelations", ")", "utilities", "=", "[", "]", "for", "cand", "in", "decision", ":", "tops", "=", "[", "cand", "-", "1", "]", "index", "...
Returns a floats that contains the utilities of every candidate in the decision. This was adapted from code written by Lirong Xia. :ivar list<int> decision: Contains a list of integer representations of candidates in the current decision. :ivar list<list,int> binaryRelations: A tw...
[ "Returns", "a", "floats", "that", "contains", "the", "utilities", "of", "every", "candidate", "in", "the", "decision", ".", "This", "was", "adapted", "from", "code", "written", "by", "Lirong", "Xia", "." ]
f395ba3782f05684fa5de0cece387a6da9391d02
https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/utilityFunction.py#L140-L174
train
Returns a list of floats that contains the utilities of every candidate in the current decision.
tamasgal/km3pipe
km3pipe/config.py
Config.db_credentials
def db_credentials(self): """Return username and password for the KM3NeT WebDB.""" try: username = self.config.get('DB', 'username') password = self.config.get('DB', 'password') except Error: username = input("Please enter your KM3NeT DB username: ") ...
python
def db_credentials(self): """Return username and password for the KM3NeT WebDB.""" try: username = self.config.get('DB', 'username') password = self.config.get('DB', 'password') except Error: username = input("Please enter your KM3NeT DB username: ") ...
[ "def", "db_credentials", "(", "self", ")", ":", "try", ":", "username", "=", "self", ".", "config", ".", "get", "(", "'DB'", ",", "'username'", ")", "password", "=", "self", ".", "config", ".", "get", "(", "'DB'", ",", "'password'", ")", "except", "E...
Return username and password for the KM3NeT WebDB.
[ "Return", "username", "and", "password", "for", "the", "KM3NeT", "WebDB", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/config.py#L104-L112
train
Return username and password for the KM3NeT WebDB.
lexibank/pylexibank
src/pylexibank/__main__.py
get_path
def get_path(src): # pragma: no cover """ Prompts the user to input a local path. :param src: github repository name :return: Absolute local path """ res = None while not res: if res is False: print(colored('You must provide a path to an existing directory!', 'red')) ...
python
def get_path(src): # pragma: no cover """ Prompts the user to input a local path. :param src: github repository name :return: Absolute local path """ res = None while not res: if res is False: print(colored('You must provide a path to an existing directory!', 'red')) ...
[ "def", "get_path", "(", "src", ")", ":", "# pragma: no cover", "res", "=", "None", "while", "not", "res", ":", "if", "res", "is", "False", ":", "print", "(", "colored", "(", "'You must provide a path to an existing directory!'", ",", "'red'", ")", ")", "print"...
Prompts the user to input a local path. :param src: github repository name :return: Absolute local path
[ "Prompts", "the", "user", "to", "input", "a", "local", "path", "." ]
c28e7f122f20de1232623dd7003cb5b01535e581
https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/__main__.py#L53-L69
train
Prompts the user to input a local path.
lexibank/pylexibank
src/pylexibank/__main__.py
configure
def configure(cfgpath=None): """ Configure lexibank. :return: a pair (config, logger) """ cfgpath = Path(cfgpath) \ if cfgpath else Path(user_config_dir(pylexibank.__name__)) / 'config.ini' if not cfgpath.exists(): print(""" {0} You seem to be running lexibank for the first tim...
python
def configure(cfgpath=None): """ Configure lexibank. :return: a pair (config, logger) """ cfgpath = Path(cfgpath) \ if cfgpath else Path(user_config_dir(pylexibank.__name__)) / 'config.ini' if not cfgpath.exists(): print(""" {0} You seem to be running lexibank for the first tim...
[ "def", "configure", "(", "cfgpath", "=", "None", ")", ":", "cfgpath", "=", "Path", "(", "cfgpath", ")", "if", "cfgpath", "else", "Path", "(", "user_config_dir", "(", "pylexibank", ".", "__name__", ")", ")", "/", "'config.ini'", "if", "not", "cfgpath", "....
Configure lexibank. :return: a pair (config, logger)
[ "Configure", "lexibank", "." ]
c28e7f122f20de1232623dd7003cb5b01535e581
https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/__main__.py#L88-L128
train
Configure the lexibank with the given configuration file.
tamasgal/km3pipe
km3modules/fit.py
fit_delta_ts
def fit_delta_ts(data, time_s): """Fits gaussians to delta t for each PMT pair. Parameters ---------- data: 2d np.array: x = PMT combinations (465), y = time, entry = frequency time_s: length of data taking in seconds Returns ------- numpy arrays with rates and means for all PMT combin...
python
def fit_delta_ts(data, time_s): """Fits gaussians to delta t for each PMT pair. Parameters ---------- data: 2d np.array: x = PMT combinations (465), y = time, entry = frequency time_s: length of data taking in seconds Returns ------- numpy arrays with rates and means for all PMT combin...
[ "def", "fit_delta_ts", "(", "data", ",", "time_s", ")", ":", "data", "=", "data", "/", "time_s", "xs", "=", "np", ".", "arange", "(", "-", "20", ",", "21", ")", "def", "gaussian", "(", "x", ",", "mean", ",", "sigma", ",", "rate", ",", "offset", ...
Fits gaussians to delta t for each PMT pair. Parameters ---------- data: 2d np.array: x = PMT combinations (465), y = time, entry = frequency time_s: length of data taking in seconds Returns ------- numpy arrays with rates and means for all PMT combinations
[ "Fits", "gaussians", "to", "delta", "t", "for", "each", "PMT", "pair", "." ]
7a9b59ac899a28775b5bdc5d391d9a5340d08040
https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3modules/fit.py#L14-L46
train
Fits gaussians to delta t for each PMT pair.
IRC-SPHERE/HyperStream
hyperstream/workflow/workflow_manager.py
WorkflowManager.load_workflow
def load_workflow(self, workflow_id): """ Load workflow from the database and store in memory :param workflow_id: The workflow id :return: The workflow """ with switch_db(WorkflowDefinitionModel, db_alias='hyperstream'): workflow_definition = WorkflowDefinitio...
python
def load_workflow(self, workflow_id): """ Load workflow from the database and store in memory :param workflow_id: The workflow id :return: The workflow """ with switch_db(WorkflowDefinitionModel, db_alias='hyperstream'): workflow_definition = WorkflowDefinitio...
[ "def", "load_workflow", "(", "self", ",", "workflow_id", ")", ":", "with", "switch_db", "(", "WorkflowDefinitionModel", ",", "db_alias", "=", "'hyperstream'", ")", ":", "workflow_definition", "=", "WorkflowDefinitionModel", ".", "objects", ".", "get", "(", "workfl...
Load workflow from the database and store in memory :param workflow_id: The workflow id :return: The workflow
[ "Load", "workflow", "from", "the", "database", "and", "store", "in", "memory", ":", "param", "workflow_id", ":", "The", "workflow", "id", ":", "return", ":", "The", "workflow" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow_manager.py#L81-L191
train
Load a workflow from the database and store in memory.
IRC-SPHERE/HyperStream
hyperstream/workflow/workflow_manager.py
WorkflowManager.add_workflow
def add_workflow(self, workflow, commit=False): """ Add a new workflow and optionally commit it to the database :param workflow: The workflow :param commit: Whether to commit the workflow to the database :type workflow: Workflow :type commit: bool :return: None ...
python
def add_workflow(self, workflow, commit=False): """ Add a new workflow and optionally commit it to the database :param workflow: The workflow :param commit: Whether to commit the workflow to the database :type workflow: Workflow :type commit: bool :return: None ...
[ "def", "add_workflow", "(", "self", ",", "workflow", ",", "commit", "=", "False", ")", ":", "if", "workflow", ".", "workflow_id", "in", "self", ".", "workflows", ":", "raise", "KeyError", "(", "\"Workflow with id {} already exists\"", ".", "format", "(", "work...
Add a new workflow and optionally commit it to the database :param workflow: The workflow :param commit: Whether to commit the workflow to the database :type workflow: Workflow :type commit: bool :return: None
[ "Add", "a", "new", "workflow", "and", "optionally", "commit", "it", "to", "the", "database", ":", "param", "workflow", ":", "The", "workflow", ":", "param", "commit", ":", "Whether", "to", "commit", "the", "workflow", "to", "the", "database", ":", "type", ...
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow_manager.py#L193-L212
train
Adds a new workflow to the database and optionally commits it to the database.
IRC-SPHERE/HyperStream
hyperstream/workflow/workflow_manager.py
WorkflowManager.delete_workflow
def delete_workflow(self, workflow_id): """ Delete a workflow from the database :param workflow_id: :return: None """ deleted = False with switch_db(WorkflowDefinitionModel, "hyperstream"): workflows = WorkflowDefinitionModel.objects(workflow_id=workf...
python
def delete_workflow(self, workflow_id): """ Delete a workflow from the database :param workflow_id: :return: None """ deleted = False with switch_db(WorkflowDefinitionModel, "hyperstream"): workflows = WorkflowDefinitionModel.objects(workflow_id=workf...
[ "def", "delete_workflow", "(", "self", ",", "workflow_id", ")", ":", "deleted", "=", "False", "with", "switch_db", "(", "WorkflowDefinitionModel", ",", "\"hyperstream\"", ")", ":", "workflows", "=", "WorkflowDefinitionModel", ".", "objects", "(", "workflow_id", "=...
Delete a workflow from the database :param workflow_id: :return: None
[ "Delete", "a", "workflow", "from", "the", "database", ":", "param", "workflow_id", ":", ":", "return", ":", "None" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow_manager.py#L214-L243
train
Delete a workflow from the database.
IRC-SPHERE/HyperStream
hyperstream/workflow/workflow_manager.py
WorkflowManager.commit_workflow
def commit_workflow(self, workflow_id): """ Commit the workflow to the database :param workflow_id: The workflow id :return: None """ # TODO: We should also be committing the Stream definitions if there are new ones workflow = self.workflows[workflow_id] ...
python
def commit_workflow(self, workflow_id): """ Commit the workflow to the database :param workflow_id: The workflow id :return: None """ # TODO: We should also be committing the Stream definitions if there are new ones workflow = self.workflows[workflow_id] ...
[ "def", "commit_workflow", "(", "self", ",", "workflow_id", ")", ":", "# TODO: We should also be committing the Stream definitions if there are new ones", "workflow", "=", "self", ".", "workflows", "[", "workflow_id", "]", "with", "switch_db", "(", "WorkflowDefinitionModel", ...
Commit the workflow to the database :param workflow_id: The workflow id :return: None
[ "Commit", "the", "workflow", "to", "the", "database", ":", "param", "workflow_id", ":", "The", "workflow", "id", ":", "return", ":", "None" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow_manager.py#L245-L340
train
Commits the workflow to the database.
IRC-SPHERE/HyperStream
hyperstream/workflow/workflow_manager.py
WorkflowManager.execute_all
def execute_all(self): """ Execute all workflows """ for workflow_id in self.workflows: if self.workflows[workflow_id].online: for interval in self.workflows[workflow_id].requested_intervals: logging.info("Executing workflow {} over interva...
python
def execute_all(self): """ Execute all workflows """ for workflow_id in self.workflows: if self.workflows[workflow_id].online: for interval in self.workflows[workflow_id].requested_intervals: logging.info("Executing workflow {} over interva...
[ "def", "execute_all", "(", "self", ")", ":", "for", "workflow_id", "in", "self", ".", "workflows", ":", "if", "self", ".", "workflows", "[", "workflow_id", "]", ".", "online", ":", "for", "interval", "in", "self", ".", "workflows", "[", "workflow_id", "]...
Execute all workflows
[ "Execute", "all", "workflows" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow_manager.py#L350-L358
train
Execute all workflows
IRC-SPHERE/HyperStream
hyperstream/workflow/workflow_manager.py
WorkflowManager.set_requested_intervals
def set_requested_intervals(self, workflow_id, requested_intervals): """ Sets the requested intervals for a given workflow :param workflow_id: The workflow id :param requested_intervals: The requested intervals :return: None :type requested_intervals: TimeIntervals ...
python
def set_requested_intervals(self, workflow_id, requested_intervals): """ Sets the requested intervals for a given workflow :param workflow_id: The workflow id :param requested_intervals: The requested intervals :return: None :type requested_intervals: TimeIntervals ...
[ "def", "set_requested_intervals", "(", "self", ",", "workflow_id", ",", "requested_intervals", ")", ":", "if", "workflow_id", "not", "in", "self", ".", "workflows", ":", "raise", "ValueError", "(", "\"Workflow {} not found\"", ".", "format", "(", "workflow_id", ")...
Sets the requested intervals for a given workflow :param workflow_id: The workflow id :param requested_intervals: The requested intervals :return: None :type requested_intervals: TimeIntervals
[ "Sets", "the", "requested", "intervals", "for", "a", "given", "workflow", ":", "param", "workflow_id", ":", "The", "workflow", "id", ":", "param", "requested_intervals", ":", "The", "requested", "intervals", ":", "return", ":", "None", ":", "type", "requested_...
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow_manager.py#L361-L372
train
Sets the requested intervals for a given workflow.
IRC-SPHERE/HyperStream
hyperstream/workflow/workflow_manager.py
WorkflowManager.set_all_requested_intervals
def set_all_requested_intervals(self, requested_intervals): """ Sets the requested intervals for all workflow :param requested_intervals: The requested intervals :return: None :type requested_intervals: TimeIntervals """ for workflow_id in self.workflows: ...
python
def set_all_requested_intervals(self, requested_intervals): """ Sets the requested intervals for all workflow :param requested_intervals: The requested intervals :return: None :type requested_intervals: TimeIntervals """ for workflow_id in self.workflows: ...
[ "def", "set_all_requested_intervals", "(", "self", ",", "requested_intervals", ")", ":", "for", "workflow_id", "in", "self", ".", "workflows", ":", "if", "self", ".", "workflows", "[", "workflow_id", "]", ".", "online", ":", "self", ".", "workflows", "[", "w...
Sets the requested intervals for all workflow :param requested_intervals: The requested intervals :return: None :type requested_intervals: TimeIntervals
[ "Sets", "the", "requested", "intervals", "for", "all", "workflow", ":", "param", "requested_intervals", ":", "The", "requested", "intervals", ":", "return", ":", "None", ":", "type", "requested_intervals", ":", "TimeIntervals" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/workflow/workflow_manager.py#L374-L383
train
Sets the requested intervals for all workflowCOOKIEs.
IRC-SPHERE/HyperStream
hyperstream/tool/tool.py
Tool.execute
def execute(self, sources, sink, interval, alignment_stream=None): """ Execute the tool over the given time interval. If an alignment stream is given, the output instances will be aligned to this stream :param sources: The source streams (possibly None) :param sink: The sink str...
python
def execute(self, sources, sink, interval, alignment_stream=None): """ Execute the tool over the given time interval. If an alignment stream is given, the output instances will be aligned to this stream :param sources: The source streams (possibly None) :param sink: The sink str...
[ "def", "execute", "(", "self", ",", "sources", ",", "sink", ",", "interval", ",", "alignment_stream", "=", "None", ")", ":", "if", "not", "isinstance", "(", "interval", ",", "TimeInterval", ")", ":", "raise", "TypeError", "(", "'Expected TimeInterval, got {}'"...
Execute the tool over the given time interval. If an alignment stream is given, the output instances will be aligned to this stream :param sources: The source streams (possibly None) :param sink: The sink stream :param alignment_stream: The alignment stream :param interval: The ...
[ "Execute", "the", "tool", "over", "the", "given", "time", "interval", ".", "If", "an", "alignment", "stream", "is", "given", "the", "output", "instances", "will", "be", "aligned", "to", "this", "stream" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/tool/tool.py#L49-L97
train
Execute the tool over the given time interval.
IRC-SPHERE/HyperStream
hyperstream/channels/memory_channel.py
MemoryChannel.create_stream
def create_stream(self, stream_id, sandbox=None): """ Must be overridden by deriving classes, must create the stream according to the tool and return its unique identifier stream_id """ if stream_id in self.streams: raise StreamAlreadyExistsError("Stream with id '{}' ...
python
def create_stream(self, stream_id, sandbox=None): """ Must be overridden by deriving classes, must create the stream according to the tool and return its unique identifier stream_id """ if stream_id in self.streams: raise StreamAlreadyExistsError("Stream with id '{}' ...
[ "def", "create_stream", "(", "self", ",", "stream_id", ",", "sandbox", "=", "None", ")", ":", "if", "stream_id", "in", "self", ".", "streams", ":", "raise", "StreamAlreadyExistsError", "(", "\"Stream with id '{}' already exists\"", ".", "format", "(", "stream_id",...
Must be overridden by deriving classes, must create the stream according to the tool and return its unique identifier stream_id
[ "Must", "be", "overridden", "by", "deriving", "classes", "must", "create", "the", "stream", "according", "to", "the", "tool", "and", "return", "its", "unique", "identifier", "stream_id" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/channels/memory_channel.py#L44-L59
train
Create a new stream with the given id and return its unique version of the stream.
IRC-SPHERE/HyperStream
hyperstream/channels/memory_channel.py
MemoryChannel.purge_all
def purge_all(self, remove_definitions=False): """ Clears all streams in the channel - use with caution! :return: None """ for stream_id in list(self.streams.keys()): self.purge_stream(stream_id, remove_definition=remove_definitions)
python
def purge_all(self, remove_definitions=False): """ Clears all streams in the channel - use with caution! :return: None """ for stream_id in list(self.streams.keys()): self.purge_stream(stream_id, remove_definition=remove_definitions)
[ "def", "purge_all", "(", "self", ",", "remove_definitions", "=", "False", ")", ":", "for", "stream_id", "in", "list", "(", "self", ".", "streams", ".", "keys", "(", ")", ")", ":", "self", ".", "purge_stream", "(", "stream_id", ",", "remove_definition", "...
Clears all streams in the channel - use with caution! :return: None
[ "Clears", "all", "streams", "in", "the", "channel", "-", "use", "with", "caution!" ]
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/channels/memory_channel.py#L61-L68
train
Clears all streams in the channel - use with caution!
IRC-SPHERE/HyperStream
hyperstream/channels/memory_channel.py
MemoryChannel.purge_stream
def purge_stream(self, stream_id, remove_definition=False, sandbox=None): """ Clears all the data in a given stream and the calculated intervals :param stream_id: The stream id :param remove_definition: Whether to remove the stream definition as well :param sandbox: The ...
python
def purge_stream(self, stream_id, remove_definition=False, sandbox=None): """ Clears all the data in a given stream and the calculated intervals :param stream_id: The stream id :param remove_definition: Whether to remove the stream definition as well :param sandbox: The ...
[ "def", "purge_stream", "(", "self", ",", "stream_id", ",", "remove_definition", "=", "False", ",", "sandbox", "=", "None", ")", ":", "if", "sandbox", "is", "not", "None", ":", "raise", "NotImplementedError", "if", "stream_id", "not", "in", "self", ".", "st...
Clears all the data in a given stream and the calculated intervals :param stream_id: The stream id :param remove_definition: Whether to remove the stream definition as well :param sandbox: The sandbox id :return: None
[ "Clears", "all", "the", "data", "in", "a", "given", "stream", "and", "the", "calculated", "intervals", ":", "param", "stream_id", ":", "The", "stream", "id", ":", "param", "remove_definition", ":", "Whether", "to", "remove", "the", "stream", "definition", "a...
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/channels/memory_channel.py#L76-L97
train
Clears all the data in a given stream and the calculated intervals in the given sandbox.
IRC-SPHERE/HyperStream
hyperstream/channels/memory_channel.py
MemoryChannel.get_results
def get_results(self, stream, time_interval): """ Calculates/receives the documents in the stream interval determined by the stream :param stream: The stream reference :param time_interval: The time interval :return: The sorted data items """ return [StreamInstanc...
python
def get_results(self, stream, time_interval): """ Calculates/receives the documents in the stream interval determined by the stream :param stream: The stream reference :param time_interval: The time interval :return: The sorted data items """ return [StreamInstanc...
[ "def", "get_results", "(", "self", ",", "stream", ",", "time_interval", ")", ":", "return", "[", "StreamInstance", "(", "t", ",", "self", ".", "data", "[", "stream", ".", "stream_id", "]", "[", "t", "]", ")", "for", "t", "in", "sorted", "(", "self", ...
Calculates/receives the documents in the stream interval determined by the stream :param stream: The stream reference :param time_interval: The time interval :return: The sorted data items
[ "Calculates", "/", "receives", "the", "documents", "in", "the", "stream", "interval", "determined", "by", "the", "stream", ":", "param", "stream", ":", "The", "stream", "reference", ":", "param", "time_interval", ":", "The", "time", "interval", ":", "return", ...
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/channels/memory_channel.py#L99-L107
train
Calculates the items in the time interval determined by the stream
IRC-SPHERE/HyperStream
hyperstream/channels/memory_channel.py
ReadOnlyMemoryChannel.update_state
def update_state(self, up_to_timestamp): """ Call this function to ensure that the channel is up to date at the time of timestamp. I.e., all the streams that have been created before or at that timestamp are calculated exactly until up_to_timestamp. """ for stream_id in s...
python
def update_state(self, up_to_timestamp): """ Call this function to ensure that the channel is up to date at the time of timestamp. I.e., all the streams that have been created before or at that timestamp are calculated exactly until up_to_timestamp. """ for stream_id in s...
[ "def", "update_state", "(", "self", ",", "up_to_timestamp", ")", ":", "for", "stream_id", "in", "self", ".", "streams", ":", "self", ".", "streams", "[", "stream_id", "]", ".", "calculated_intervals", "=", "TimeIntervals", "(", "[", "(", "MIN_DATE", ",", "...
Call this function to ensure that the channel is up to date at the time of timestamp. I.e., all the streams that have been created before or at that timestamp are calculated exactly until up_to_timestamp.
[ "Call", "this", "function", "to", "ensure", "that", "the", "channel", "is", "up", "to", "date", "at", "the", "time", "of", "timestamp", ".", "I", ".", "e", ".", "all", "the", "streams", "that", "have", "been", "created", "before", "or", "at", "that", ...
98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780
https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/channels/memory_channel.py#L158-L166
train
Update the state of the channel to up to date.
finklabs/korg
korg/pattern.py
PatternRepo.compile_regex
def compile_regex(self, pattern, flags=0): """Compile regex from pattern and pattern_dict""" pattern_re = regex.compile('(?P<substr>%\{(?P<fullname>(?P<patname>\w+)(?::(?P<subname>\w+))?)\})') while 1: matches = [md.groupdict() for md in pattern_re.finditer(pattern)] if l...
python
def compile_regex(self, pattern, flags=0): """Compile regex from pattern and pattern_dict""" pattern_re = regex.compile('(?P<substr>%\{(?P<fullname>(?P<patname>\w+)(?::(?P<subname>\w+))?)\})') while 1: matches = [md.groupdict() for md in pattern_re.finditer(pattern)] if l...
[ "def", "compile_regex", "(", "self", ",", "pattern", ",", "flags", "=", "0", ")", ":", "pattern_re", "=", "regex", ".", "compile", "(", "'(?P<substr>%\\{(?P<fullname>(?P<patname>\\w+)(?::(?P<subname>\\w+))?)\\})'", ")", "while", "1", ":", "matches", "=", "[", "md"...
Compile regex from pattern and pattern_dict
[ "Compile", "regex", "from", "pattern", "and", "pattern_dict" ]
e931a673ce4bc79cdf26cb4f697fa23fa8a72e4f
https://github.com/finklabs/korg/blob/e931a673ce4bc79cdf26cb4f697fa23fa8a72e4f/korg/pattern.py#L27-L56
train
Compile regex from pattern and pattern_dict
finklabs/korg
korg/pattern.py
PatternRepo._load_patterns
def _load_patterns(self, folders, pattern_dict=None): """Load all pattern from all the files in folders""" if pattern_dict is None: pattern_dict = {} for folder in folders: for file in os.listdir(folder): if regex.match('^[\w-]+$', file): ...
python
def _load_patterns(self, folders, pattern_dict=None): """Load all pattern from all the files in folders""" if pattern_dict is None: pattern_dict = {} for folder in folders: for file in os.listdir(folder): if regex.match('^[\w-]+$', file): ...
[ "def", "_load_patterns", "(", "self", ",", "folders", ",", "pattern_dict", "=", "None", ")", ":", "if", "pattern_dict", "is", "None", ":", "pattern_dict", "=", "{", "}", "for", "folder", "in", "folders", ":", "for", "file", "in", "os", ".", "listdir", ...
Load all pattern from all the files in folders
[ "Load", "all", "pattern", "from", "all", "the", "files", "in", "folders" ]
e931a673ce4bc79cdf26cb4f697fa23fa8a72e4f
https://github.com/finklabs/korg/blob/e931a673ce4bc79cdf26cb4f697fa23fa8a72e4f/korg/pattern.py#L73-L81
train
Load all pattern from all the files in folders
astooke/gtimer
gtimer/public/io.py
get_times
def get_times(): """ Produce a deepcopy of the current timing data (no risk of interference with active timing or other operaitons). Returns: Times: gtimer timing data structure object. """ if f.root.stopped: return copy.deepcopy(f.root.times) else: t = timer() ...
python
def get_times(): """ Produce a deepcopy of the current timing data (no risk of interference with active timing or other operaitons). Returns: Times: gtimer timing data structure object. """ if f.root.stopped: return copy.deepcopy(f.root.times) else: t = timer() ...
[ "def", "get_times", "(", ")", ":", "if", "f", ".", "root", ".", "stopped", ":", "return", "copy", ".", "deepcopy", "(", "f", ".", "root", ".", "times", ")", "else", ":", "t", "=", "timer", "(", ")", "times", "=", "collapse", ".", "collapse_times", ...
Produce a deepcopy of the current timing data (no risk of interference with active timing or other operaitons). Returns: Times: gtimer timing data structure object.
[ "Produce", "a", "deepcopy", "of", "the", "current", "timing", "data", "(", "no", "risk", "of", "interference", "with", "active", "timing", "or", "other", "operaitons", ")", "." ]
2146dab459e5d959feb291821733d3d3ba7c523c
https://github.com/astooke/gtimer/blob/2146dab459e5d959feb291821733d3d3ba7c523c/gtimer/public/io.py#L25-L39
train
Produce a deepcopy of the current timing data structure.
astooke/gtimer
gtimer/public/io.py
attach_par_subdivision
def attach_par_subdivision(par_name, par_times): """ Manual assignment of a collection of (stopped) Times objects as a parallel subdivision of a running timer. Notes: An example sequence of proper usage: 1. Stamp in master process. 2. Run timed sub-processes. ...
python
def attach_par_subdivision(par_name, par_times): """ Manual assignment of a collection of (stopped) Times objects as a parallel subdivision of a running timer. Notes: An example sequence of proper usage: 1. Stamp in master process. 2. Run timed sub-processes. ...
[ "def", "attach_par_subdivision", "(", "par_name", ",", "par_times", ")", ":", "t", "=", "timer", "(", ")", "if", "not", "isinstance", "(", "par_times", ",", "(", "list", ",", "tuple", ")", ")", ":", "raise", "TypeError", "(", "\"Expected list or tuple for pa...
Manual assignment of a collection of (stopped) Times objects as a parallel subdivision of a running timer. Notes: An example sequence of proper usage: 1. Stamp in master process. 2. Run timed sub-processes. 3. Get timing data from sub-processes into master. ...
[ "Manual", "assignment", "of", "a", "collection", "of", "(", "stopped", ")", "Times", "objects", "as", "a", "parallel", "subdivision", "of", "a", "running", "timer", "." ]
2146dab459e5d959feb291821733d3d3ba7c523c
https://github.com/astooke/gtimer/blob/2146dab459e5d959feb291821733d3d3ba7c523c/gtimer/public/io.py#L42-L99
train
This function is used to attach a set of times to a master process.
astooke/gtimer
gtimer/public/io.py
attach_subdivision
def attach_subdivision(times): """ Manual assignment of a (stopped) times object as a subdivision of running timer. Use cases are expected to be very limited (mainly provided as a one-Times variant of attach_par_subdivision). Notes: As with any subdivision, the interval in the receiving ti...
python
def attach_subdivision(times): """ Manual assignment of a (stopped) times object as a subdivision of running timer. Use cases are expected to be very limited (mainly provided as a one-Times variant of attach_par_subdivision). Notes: As with any subdivision, the interval in the receiving ti...
[ "def", "attach_subdivision", "(", "times", ")", ":", "t", "=", "timer", "(", ")", "if", "not", "isinstance", "(", "times", ",", "Times", ")", ":", "raise", "TypeError", "(", "\"Expected Times object for param 'times'.\"", ")", "assert", "times", ".", "total", ...
Manual assignment of a (stopped) times object as a subdivision of running timer. Use cases are expected to be very limited (mainly provided as a one-Times variant of attach_par_subdivision). Notes: As with any subdivision, the interval in the receiving timer is assumed to totally subsume t...
[ "Manual", "assignment", "of", "a", "(", "stopped", ")", "times", "object", "as", "a", "subdivision", "of", "running", "timer", ".", "Use", "cases", "are", "expected", "to", "be", "very", "limited", "(", "mainly", "provided", "as", "a", "one", "-", "Times...
2146dab459e5d959feb291821733d3d3ba7c523c
https://github.com/astooke/gtimer/blob/2146dab459e5d959feb291821733d3d3ba7c523c/gtimer/public/io.py#L102-L131
train
This function is used to attach a new subdivision to a running n - times object.
astooke/gtimer
gtimer/public/io.py
save_pkl
def save_pkl(filename=None, times=None): """ Serialize and / or save a Times data object using pickle (cPickle). Args: filename (None, optional): Filename to dump to. If not provided, returns serialized object. times (None, optional): object to dump. If non provided, uses ...
python
def save_pkl(filename=None, times=None): """ Serialize and / or save a Times data object using pickle (cPickle). Args: filename (None, optional): Filename to dump to. If not provided, returns serialized object. times (None, optional): object to dump. If non provided, uses ...
[ "def", "save_pkl", "(", "filename", "=", "None", ",", "times", "=", "None", ")", ":", "if", "times", "is", "None", ":", "if", "not", "f", ".", "root", ".", "stopped", ":", "times", "=", "collapse", ".", "collapse_times", "(", ")", "else", ":", "tim...
Serialize and / or save a Times data object using pickle (cPickle). Args: filename (None, optional): Filename to dump to. If not provided, returns serialized object. times (None, optional): object to dump. If non provided, uses current root. Returns: pkl: Pickl...
[ "Serialize", "and", "/", "or", "save", "a", "Times", "data", "object", "using", "pickle", "(", "cPickle", ")", "." ]
2146dab459e5d959feb291821733d3d3ba7c523c
https://github.com/astooke/gtimer/blob/2146dab459e5d959feb291821733d3d3ba7c523c/gtimer/public/io.py#L134-L167
train
Serialize and / or save a Times object using pickle.
astooke/gtimer
gtimer/public/io.py
load_pkl
def load_pkl(filenames): """ Unpickle file contents. Args: filenames (str): Can be one or a list or tuple of filenames to retrieve. Returns: Times: A single object, or from a collection of filenames, a list of Times objects. Raises: TypeError: If any loaded object is not a...
python
def load_pkl(filenames): """ Unpickle file contents. Args: filenames (str): Can be one or a list or tuple of filenames to retrieve. Returns: Times: A single object, or from a collection of filenames, a list of Times objects. Raises: TypeError: If any loaded object is not a...
[ "def", "load_pkl", "(", "filenames", ")", ":", "if", "not", "isinstance", "(", "filenames", ",", "(", "list", ",", "tuple", ")", ")", ":", "filenames", "=", "[", "filenames", "]", "times", "=", "[", "]", "for", "name", "in", "filenames", ":", "name",...
Unpickle file contents. Args: filenames (str): Can be one or a list or tuple of filenames to retrieve. Returns: Times: A single object, or from a collection of filenames, a list of Times objects. Raises: TypeError: If any loaded object is not a Times object.
[ "Unpickle", "file", "contents", "." ]
2146dab459e5d959feb291821733d3d3ba7c523c
https://github.com/astooke/gtimer/blob/2146dab459e5d959feb291821733d3d3ba7c523c/gtimer/public/io.py#L170-L193
train
Loads a single or multiple Times objects from a list of filenames.
dgomes/pyipma
pyipma/api.py
IPMA_API.retrieve
async def retrieve(self, url, **kwargs): """Issue API requests.""" try: async with self.websession.request('GET', url, **kwargs) as res: if res.status != 200: raise Exception("Could not retrieve information from API") if res.content_type ==...
python
async def retrieve(self, url, **kwargs): """Issue API requests.""" try: async with self.websession.request('GET', url, **kwargs) as res: if res.status != 200: raise Exception("Could not retrieve information from API") if res.content_type ==...
[ "async", "def", "retrieve", "(", "self", ",", "url", ",", "*", "*", "kwargs", ")", ":", "try", ":", "async", "with", "self", ".", "websession", ".", "request", "(", "'GET'", ",", "url", ",", "*", "*", "kwargs", ")", "as", "res", ":", "if", "res",...
Issue API requests.
[ "Issue", "API", "requests", "." ]
cd808abeb70dca0e336afdf55bef3f73973eaa71
https://github.com/dgomes/pyipma/blob/cd808abeb70dca0e336afdf55bef3f73973eaa71/pyipma/api.py#L22-L32
train
Issue API requests.