repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
volafiled/python-volapi
volapi/multipart.py
escape_header
def escape_header(val): """Escapes a value so that it can be used in a mime header""" if val is None: return None try: return quote(val, encoding="ascii", safe="/ ") except ValueError: return "utf-8''" + quote(val, encoding="utf-8", safe="/ ")
python
def escape_header(val): """Escapes a value so that it can be used in a mime header""" if val is None: return None try: return quote(val, encoding="ascii", safe="/ ") except ValueError: return "utf-8''" + quote(val, encoding="utf-8", safe="/ ")
[ "def", "escape_header", "(", "val", ")", ":", "if", "val", "is", "None", ":", "return", "None", "try", ":", "return", "quote", "(", "val", ",", "encoding", "=", "\"ascii\"", ",", "safe", "=", "\"/ \"", ")", "except", "ValueError", ":", "return", "\"utf...
Escapes a value so that it can be used in a mime header
[ "Escapes", "a", "value", "so", "that", "it", "can", "be", "used", "in", "a", "mime", "header" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/multipart.py#L24-L32
volafiled/python-volapi
volapi/multipart.py
make_streams
def make_streams(name, value, boundary, encoding): """Generates one or more streams for each name, value pair""" filename = None mime = None # user passed in a special dict. if isinstance(value, collections.Mapping) and "name" in value and "value" in value: filename = value["name"] ...
python
def make_streams(name, value, boundary, encoding): """Generates one or more streams for each name, value pair""" filename = None mime = None # user passed in a special dict. if isinstance(value, collections.Mapping) and "name" in value and "value" in value: filename = value["name"] ...
[ "def", "make_streams", "(", "name", ",", "value", ",", "boundary", ",", "encoding", ")", ":", "filename", "=", "None", "mime", "=", "None", "# user passed in a special dict.", "if", "isinstance", "(", "value", ",", "collections", ".", "Mapping", ")", "and", ...
Generates one or more streams for each name, value pair
[ "Generates", "one", "or", "more", "streams", "for", "each", "name", "value", "pair" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/multipart.py#L35-L89
volafiled/python-volapi
volapi/multipart.py
Data.len
def len(self): """Length of the data stream""" # The len property is needed for requests. # requests checks __len__, then len # Since we cannot implement __len__ because python 32-bit uses 32-bit # sizes, we implement this instead. def stream_len(stream): """S...
python
def len(self): """Length of the data stream""" # The len property is needed for requests. # requests checks __len__, then len # Since we cannot implement __len__ because python 32-bit uses 32-bit # sizes, we implement this instead. def stream_len(stream): """S...
[ "def", "len", "(", "self", ")", ":", "# The len property is needed for requests.", "# requests checks __len__, then len", "# Since we cannot implement __len__ because python 32-bit uses 32-bit", "# sizes, we implement this instead.", "def", "stream_len", "(", "stream", ")", ":", "\"\...
Length of the data stream
[ "Length", "of", "the", "data", "stream" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/multipart.py#L132-L147
volafiled/python-volapi
volapi/multipart.py
Data.headers
def headers(self): """All headers needed to make a request""" return { "Content-Type": ("multipart/form-data; boundary={}".format(self.boundary)), "Content-Length": str(self.len), "Content-Encoding": self.encoding, }
python
def headers(self): """All headers needed to make a request""" return { "Content-Type": ("multipart/form-data; boundary={}".format(self.boundary)), "Content-Length": str(self.len), "Content-Encoding": self.encoding, }
[ "def", "headers", "(", "self", ")", ":", "return", "{", "\"Content-Type\"", ":", "(", "\"multipart/form-data; boundary={}\"", ".", "format", "(", "self", ".", "boundary", ")", ")", ",", "\"Content-Length\"", ":", "str", "(", "self", ".", "len", ")", ",", "...
All headers needed to make a request
[ "All", "headers", "needed", "to", "make", "a", "request" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/multipart.py#L150-L156
BeyondTheClouds/enoslib
enoslib/infra/utils.py
mk_pools
def mk_pools(things, keyfnc=lambda x: x): "Indexes a thing by the keyfnc to construct pools of things." pools = {} sthings = sorted(things, key=keyfnc) for key, thingz in groupby(sthings, key=keyfnc): pools.setdefault(key, []).extend(list(thingz)) return pools
python
def mk_pools(things, keyfnc=lambda x: x): "Indexes a thing by the keyfnc to construct pools of things." pools = {} sthings = sorted(things, key=keyfnc) for key, thingz in groupby(sthings, key=keyfnc): pools.setdefault(key, []).extend(list(thingz)) return pools
[ "def", "mk_pools", "(", "things", ",", "keyfnc", "=", "lambda", "x", ":", "x", ")", ":", "pools", "=", "{", "}", "sthings", "=", "sorted", "(", "things", ",", "key", "=", "keyfnc", ")", "for", "key", ",", "thingz", "in", "groupby", "(", "sthings", ...
Indexes a thing by the keyfnc to construct pools of things.
[ "Indexes", "a", "thing", "by", "the", "keyfnc", "to", "construct", "pools", "of", "things", "." ]
train
https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/utils.py#L6-L12
BeyondTheClouds/enoslib
enoslib/infra/utils.py
pick_things
def pick_things(pools, key, n): "Picks a maximum of n things in a dict of indexed pool of things." pool = pools.get(key) if not pool: return [] things = pool[:n] del pool[:n] return things
python
def pick_things(pools, key, n): "Picks a maximum of n things in a dict of indexed pool of things." pool = pools.get(key) if not pool: return [] things = pool[:n] del pool[:n] return things
[ "def", "pick_things", "(", "pools", ",", "key", ",", "n", ")", ":", "pool", "=", "pools", ".", "get", "(", "key", ")", "if", "not", "pool", ":", "return", "[", "]", "things", "=", "pool", "[", ":", "n", "]", "del", "pool", "[", ":", "n", "]",...
Picks a maximum of n things in a dict of indexed pool of things.
[ "Picks", "a", "maximum", "of", "n", "things", "in", "a", "dict", "of", "indexed", "pool", "of", "things", "." ]
train
https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/utils.py#L15-L22
volafiled/python-volapi
docs/examples/parrot.py
listen
def listen(room): """Open a volafile room and start listening to it""" def onmessage(m): """Print the new message and respond to it.""" print(m) if m.admin or m.nick == r.user.name: return if "parrot" in m.msg.lower(): r.post_chat("ayy lmao") elif ...
python
def listen(room): """Open a volafile room and start listening to it""" def onmessage(m): """Print the new message and respond to it.""" print(m) if m.admin or m.nick == r.user.name: return if "parrot" in m.msg.lower(): r.post_chat("ayy lmao") elif ...
[ "def", "listen", "(", "room", ")", ":", "def", "onmessage", "(", "m", ")", ":", "\"\"\"Print the new message and respond to it.\"\"\"", "print", "(", "m", ")", "if", "m", ".", "admin", "or", "m", ".", "nick", "==", "r", ".", "user", ".", "name", ":", "...
Open a volafile room and start listening to it
[ "Open", "a", "volafile", "room", "and", "start", "listening", "to", "it" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/docs/examples/parrot.py#L11-L28
guaix-ucm/pyemir
emirdrp/tools/nscan_minmax_frontiers.py
nscan_minmax_frontiers
def nscan_minmax_frontiers(y0_frontier_lower, y0_frontier_upper, resize=False): """Compute valid scan range for provided y0_frontier values. Parameters ---------- y0_frontier_lower : float Ordinate of the lower frontier. y0_frontier_upper : float Ordinate o...
python
def nscan_minmax_frontiers(y0_frontier_lower, y0_frontier_upper, resize=False): """Compute valid scan range for provided y0_frontier values. Parameters ---------- y0_frontier_lower : float Ordinate of the lower frontier. y0_frontier_upper : float Ordinate o...
[ "def", "nscan_minmax_frontiers", "(", "y0_frontier_lower", ",", "y0_frontier_upper", ",", "resize", "=", "False", ")", ":", "fraction_pixel", "=", "y0_frontier_lower", "-", "int", "(", "y0_frontier_lower", ")", "if", "fraction_pixel", ">", "0.0", ":", "nscan_min", ...
Compute valid scan range for provided y0_frontier values. Parameters ---------- y0_frontier_lower : float Ordinate of the lower frontier. y0_frontier_upper : float Ordinate of the upper frontier. resize : bool If True, when the limits are beyond the expected values [1...
[ "Compute", "valid", "scan", "range", "for", "provided", "y0_frontier", "values", ".", "Parameters", "----------", "y0_frontier_lower", ":", "float", "Ordinate", "of", "the", "lower", "frontier", ".", "y0_frontier_upper", ":", "float", "Ordinate", "of", "the", "upp...
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/tools/nscan_minmax_frontiers.py#L26-L69
guaix-ucm/pyemir
emirdrp/instrument/dtu_configuration.py
average_dtu_configurations
def average_dtu_configurations(list_of_objects): """Return DtuConfiguration instance with averaged values. Parameters ---------- list_of_objects : python list List of DtuConfiguration instances to be averaged. Returns ------- result : DtuConfiguration instance Object with a...
python
def average_dtu_configurations(list_of_objects): """Return DtuConfiguration instance with averaged values. Parameters ---------- list_of_objects : python list List of DtuConfiguration instances to be averaged. Returns ------- result : DtuConfiguration instance Object with a...
[ "def", "average_dtu_configurations", "(", "list_of_objects", ")", ":", "result", "=", "DtuConfiguration", "(", ")", "if", "len", "(", "list_of_objects", ")", "==", "0", ":", "return", "result", "list_of_members", "=", "result", ".", "__dict__", ".", "keys", "(...
Return DtuConfiguration instance with averaged values. Parameters ---------- list_of_objects : python list List of DtuConfiguration instances to be averaged. Returns ------- result : DtuConfiguration instance Object with averaged values.
[ "Return", "DtuConfiguration", "instance", "with", "averaged", "values", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/instrument/dtu_configuration.py#L208-L236
guaix-ucm/pyemir
emirdrp/instrument/dtu_configuration.py
maxdiff_dtu_configurations
def maxdiff_dtu_configurations(list_of_objects): """Return DtuConfiguration instance with maximum differences. Parameters ---------- list_of_objects : python list List of DtuConfiguration instances to be averaged. Returns ------- result : DtuConfiguration instance Object wi...
python
def maxdiff_dtu_configurations(list_of_objects): """Return DtuConfiguration instance with maximum differences. Parameters ---------- list_of_objects : python list List of DtuConfiguration instances to be averaged. Returns ------- result : DtuConfiguration instance Object wi...
[ "def", "maxdiff_dtu_configurations", "(", "list_of_objects", ")", ":", "result", "=", "DtuConfiguration", "(", ")", "if", "len", "(", "list_of_objects", ")", "==", "0", ":", "return", "result", "list_of_members", "=", "result", ".", "__dict__", ".", "keys", "(...
Return DtuConfiguration instance with maximum differences. Parameters ---------- list_of_objects : python list List of DtuConfiguration instances to be averaged. Returns ------- result : DtuConfiguration instance Object with averaged values.
[ "Return", "DtuConfiguration", "instance", "with", "maximum", "differences", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/instrument/dtu_configuration.py#L239-L270
guaix-ucm/pyemir
emirdrp/instrument/dtu_configuration.py
DtuConfiguration.define_from_fits
def define_from_fits(cls, fitsobj, extnum=0): """Define class object from header information in FITS file. Parameters ---------- fitsobj: file object FITS file whose header contains the DTU information needed to initialise the members of this class. extnu...
python
def define_from_fits(cls, fitsobj, extnum=0): """Define class object from header information in FITS file. Parameters ---------- fitsobj: file object FITS file whose header contains the DTU information needed to initialise the members of this class. extnu...
[ "def", "define_from_fits", "(", "cls", ",", "fitsobj", ",", "extnum", "=", "0", ")", ":", "# read input FITS file", "with", "fits", ".", "open", "(", "fitsobj", ")", "as", "hdulist", ":", "image_header", "=", "hdulist", "[", "extnum", "]", ".", "header", ...
Define class object from header information in FITS file. Parameters ---------- fitsobj: file object FITS file whose header contains the DTU information needed to initialise the members of this class. extnum : int Extension number (first extension is ...
[ "Define", "class", "object", "from", "header", "information", "in", "FITS", "file", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/instrument/dtu_configuration.py#L94-L110
guaix-ucm/pyemir
emirdrp/instrument/dtu_configuration.py
DtuConfiguration.define_from_dictionary
def define_from_dictionary(cls, inputdict): """Define class object from dictionary. Parameters ---------- inputdict : dictionary like object Dictionary like object defining each member of the class. """ self = DtuConfiguration() for item in self.__d...
python
def define_from_dictionary(cls, inputdict): """Define class object from dictionary. Parameters ---------- inputdict : dictionary like object Dictionary like object defining each member of the class. """ self = DtuConfiguration() for item in self.__d...
[ "def", "define_from_dictionary", "(", "cls", ",", "inputdict", ")", ":", "self", "=", "DtuConfiguration", "(", ")", "for", "item", "in", "self", ".", "__dict__", ":", "self", ".", "__dict__", "[", "item", "]", "=", "inputdict", "[", "item", "]", "return"...
Define class object from dictionary. Parameters ---------- inputdict : dictionary like object Dictionary like object defining each member of the class.
[ "Define", "class", "object", "from", "dictionary", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/instrument/dtu_configuration.py#L126-L139
guaix-ucm/pyemir
emirdrp/instrument/dtu_configuration.py
DtuConfiguration.define_from_values
def define_from_values(cls, xdtu, ydtu, zdtu, xdtu_0, ydtu_0, zdtu_0): """Define class object from from provided values. Parameters ---------- xdtu : float XDTU fits keyword value. ydtu : float YDTU fits keyword value. zdtu : float ZDT...
python
def define_from_values(cls, xdtu, ydtu, zdtu, xdtu_0, ydtu_0, zdtu_0): """Define class object from from provided values. Parameters ---------- xdtu : float XDTU fits keyword value. ydtu : float YDTU fits keyword value. zdtu : float ZDT...
[ "def", "define_from_values", "(", "cls", ",", "xdtu", ",", "ydtu", ",", "zdtu", ",", "xdtu_0", ",", "ydtu_0", ",", "zdtu_0", ")", ":", "self", "=", "DtuConfiguration", "(", ")", "# define DTU variables", "self", ".", "xdtu", "=", "xdtu", "self", ".", "yd...
Define class object from from provided values. Parameters ---------- xdtu : float XDTU fits keyword value. ydtu : float YDTU fits keyword value. zdtu : float ZDTU fits keyword value. xdtu_0 : float XDTU_0 fits keyword value...
[ "Define", "class", "object", "from", "from", "provided", "values", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/instrument/dtu_configuration.py#L142-L170
guaix-ucm/pyemir
emirdrp/instrument/dtu_configuration.py
DtuConfiguration.closeto
def closeto(self, other, abserror): """Check that all the members are equal within provided absolute error. Parameters ---------- other : DtuConfiguration object DTU configuration instance to be compared with self. abserror : float Absolute maximum allowe...
python
def closeto(self, other, abserror): """Check that all the members are equal within provided absolute error. Parameters ---------- other : DtuConfiguration object DTU configuration instance to be compared with self. abserror : float Absolute maximum allowe...
[ "def", "closeto", "(", "self", ",", "other", ",", "abserror", ")", ":", "result", "=", "(", "abs", "(", "self", ".", "xdtu", "-", "other", ".", "xdtu", ")", "<=", "abserror", ")", "and", "(", "abs", "(", "self", ".", "ydtu", "-", "other", ".", ...
Check that all the members are equal within provided absolute error. Parameters ---------- other : DtuConfiguration object DTU configuration instance to be compared with self. abserror : float Absolute maximum allowed error. Returns ------- ...
[ "Check", "that", "all", "the", "members", "are", "equal", "within", "provided", "absolute", "error", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/instrument/dtu_configuration.py#L172-L197
guaix-ucm/pyemir
emirdrp/instrument/dtu_configuration.py
DtuConfiguration.outdict
def outdict(self, ndigits=3): """Return dictionary structure rounded to a given precision.""" output = self.__dict__.copy() for item in output: output[item] = round(output[item], ndigits) return output
python
def outdict(self, ndigits=3): """Return dictionary structure rounded to a given precision.""" output = self.__dict__.copy() for item in output: output[item] = round(output[item], ndigits) return output
[ "def", "outdict", "(", "self", ",", "ndigits", "=", "3", ")", ":", "output", "=", "self", ".", "__dict__", ".", "copy", "(", ")", "for", "item", "in", "output", ":", "output", "[", "item", "]", "=", "round", "(", "output", "[", "item", "]", ",", ...
Return dictionary structure rounded to a given precision.
[ "Return", "dictionary", "structure", "rounded", "to", "a", "given", "precision", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/instrument/dtu_configuration.py#L199-L205
IdentityPython/oidcendpoint
src/oidcendpoint/util.py
build_endpoints
def build_endpoints(conf, endpoint_context, client_authn_method, issuer): """ conf typically contains:: 'provider_config': { 'path': '.well-known/openid-configuration', 'class': ProviderConfiguration, 'kwargs': {} }, :param conf: :param endpoint_cont...
python
def build_endpoints(conf, endpoint_context, client_authn_method, issuer): """ conf typically contains:: 'provider_config': { 'path': '.well-known/openid-configuration', 'class': ProviderConfiguration, 'kwargs': {} }, :param conf: :param endpoint_cont...
[ "def", "build_endpoints", "(", "conf", ",", "endpoint_context", ",", "client_authn_method", ",", "issuer", ")", ":", "if", "issuer", ".", "endswith", "(", "'/'", ")", ":", "_url", "=", "issuer", "[", ":", "-", "1", "]", "else", ":", "_url", "=", "issue...
conf typically contains:: 'provider_config': { 'path': '.well-known/openid-configuration', 'class': ProviderConfiguration, 'kwargs': {} }, :param conf: :param endpoint_context: :param client_authn_method: :param issuer: :return:
[ "conf", "typically", "contains", "::" ]
train
https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/util.py#L34-L84
IdentityPython/oidcendpoint
src/oidcendpoint/util.py
lv_pack
def lv_pack(*args): """ Serializes using length:value format :param args: values :return: string """ s = [] for a in args: s.append('{}:{}'.format(len(a), a)) return ''.join(s)
python
def lv_pack(*args): """ Serializes using length:value format :param args: values :return: string """ s = [] for a in args: s.append('{}:{}'.format(len(a), a)) return ''.join(s)
[ "def", "lv_pack", "(", "*", "args", ")", ":", "s", "=", "[", "]", "for", "a", "in", "args", ":", "s", ".", "append", "(", "'{}:{}'", ".", "format", "(", "len", "(", "a", ")", ",", "a", ")", ")", "return", "''", ".", "join", "(", "s", ")" ]
Serializes using length:value format :param args: values :return: string
[ "Serializes", "using", "length", ":", "value", "format" ]
train
https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/util.py#L106-L116
IdentityPython/oidcendpoint
src/oidcendpoint/util.py
lv_unpack
def lv_unpack(txt): """ Deserializes a string of the length:value format :param txt: The input string :return: a list og values """ txt = txt.strip() res = [] while txt: l, v = txt.split(':', 1) res.append(v[:int(l)]) txt = v[int(l):] return res
python
def lv_unpack(txt): """ Deserializes a string of the length:value format :param txt: The input string :return: a list og values """ txt = txt.strip() res = [] while txt: l, v = txt.split(':', 1) res.append(v[:int(l)]) txt = v[int(l):] return res
[ "def", "lv_unpack", "(", "txt", ")", ":", "txt", "=", "txt", ".", "strip", "(", ")", "res", "=", "[", "]", "while", "txt", ":", "l", ",", "v", "=", "txt", ".", "split", "(", "':'", ",", "1", ")", "res", ".", "append", "(", "v", "[", ":", ...
Deserializes a string of the length:value format :param txt: The input string :return: a list og values
[ "Deserializes", "a", "string", "of", "the", "length", ":", "value", "format" ]
train
https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/util.py#L119-L132
BeyondTheClouds/enoslib
enoslib/infra/enos_vagrant/provider.py
Enos_vagrant.init
def init(self, force_deploy=False): """Reserve and deploys the vagrant boxes. Args: force_deploy (bool): True iff new machines should be started """ machines = self.provider_conf.machines networks = self.provider_conf.networks _networks = [] for netwo...
python
def init(self, force_deploy=False): """Reserve and deploys the vagrant boxes. Args: force_deploy (bool): True iff new machines should be started """ machines = self.provider_conf.machines networks = self.provider_conf.networks _networks = [] for netwo...
[ "def", "init", "(", "self", ",", "force_deploy", "=", "False", ")", ":", "machines", "=", "self", ".", "provider_conf", ".", "machines", "networks", "=", "self", ".", "provider_conf", ".", "networks", "_networks", "=", "[", "]", "for", "network", "in", "...
Reserve and deploys the vagrant boxes. Args: force_deploy (bool): True iff new machines should be started
[ "Reserve", "and", "deploys", "the", "vagrant", "boxes", "." ]
train
https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_vagrant/provider.py#L22-L105
BeyondTheClouds/enoslib
enoslib/infra/enos_vagrant/provider.py
Enos_vagrant.destroy
def destroy(self): """Destroy all vagrant box involved in the deployment.""" v = vagrant.Vagrant(root=os.getcwd(), quiet_stdout=False, quiet_stderr=True) v.destroy()
python
def destroy(self): """Destroy all vagrant box involved in the deployment.""" v = vagrant.Vagrant(root=os.getcwd(), quiet_stdout=False, quiet_stderr=True) v.destroy()
[ "def", "destroy", "(", "self", ")", ":", "v", "=", "vagrant", ".", "Vagrant", "(", "root", "=", "os", ".", "getcwd", "(", ")", ",", "quiet_stdout", "=", "False", ",", "quiet_stderr", "=", "True", ")", "v", ".", "destroy", "(", ")" ]
Destroy all vagrant box involved in the deployment.
[ "Destroy", "all", "vagrant", "box", "involved", "in", "the", "deployment", "." ]
train
https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_vagrant/provider.py#L107-L112
Yelp/uwsgi_metrics
uwsgi_metrics/ewma.py
EWMA.tick
def tick(self): """Mark the passage of time and decay the current rate accordingly.""" instant_rate = self.count / float(self.tick_interval_s) self.count = 0 if self.initialized: self.rate += (self.alpha * (instant_rate - self.rate)) else: self.rate = inst...
python
def tick(self): """Mark the passage of time and decay the current rate accordingly.""" instant_rate = self.count / float(self.tick_interval_s) self.count = 0 if self.initialized: self.rate += (self.alpha * (instant_rate - self.rate)) else: self.rate = inst...
[ "def", "tick", "(", "self", ")", ":", "instant_rate", "=", "self", ".", "count", "/", "float", "(", "self", ".", "tick_interval_s", ")", "self", ".", "count", "=", "0", "if", "self", ".", "initialized", ":", "self", ".", "rate", "+=", "(", "self", ...
Mark the passage of time and decay the current rate accordingly.
[ "Mark", "the", "passage", "of", "time", "and", "decay", "the", "current", "rate", "accordingly", "." ]
train
https://github.com/Yelp/uwsgi_metrics/blob/534966fd461ff711aecd1e3d4caaafdc23ac33f0/uwsgi_metrics/ewma.py#L66-L74
guaix-ucm/pyemir
emirdrp/instrument/csu_configuration.py
merge_odd_even_csu_configurations
def merge_odd_even_csu_configurations(conf_odd, conf_even): """Merge CSU configuration using odd- and even-numbered values. The CSU returned CSU configuration include the odd-numbered values from 'conf_odd' and the even-numbered values from 'conf_even'. Parameters ---------- conf_odd : CsuConf...
python
def merge_odd_even_csu_configurations(conf_odd, conf_even): """Merge CSU configuration using odd- and even-numbered values. The CSU returned CSU configuration include the odd-numbered values from 'conf_odd' and the even-numbered values from 'conf_even'. Parameters ---------- conf_odd : CsuConf...
[ "def", "merge_odd_even_csu_configurations", "(", "conf_odd", ",", "conf_even", ")", ":", "# initialize resulting CsuConfiguration instance using one of the", "# input configuration corresponding to the odd-numbered slitlets", "merged_conf", "=", "deepcopy", "(", "conf_odd", ")", "# u...
Merge CSU configuration using odd- and even-numbered values. The CSU returned CSU configuration include the odd-numbered values from 'conf_odd' and the even-numbered values from 'conf_even'. Parameters ---------- conf_odd : CsuConfiguration instance CSU configuration corresponding to odd-n...
[ "Merge", "CSU", "configuration", "using", "odd", "-", "and", "even", "-", "numbered", "values", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/instrument/csu_configuration.py#L210-L247
guaix-ucm/pyemir
emirdrp/instrument/csu_configuration.py
CsuConfiguration.define_from_header
def define_from_header(cls, image_header): """Define class members directly from FITS header. Parameters ---------- image_header : instance of hdulist.header Header content from a FITS file. """ self = CsuConfiguration() # declare lists to store co...
python
def define_from_header(cls, image_header): """Define class members directly from FITS header. Parameters ---------- image_header : instance of hdulist.header Header content from a FITS file. """ self = CsuConfiguration() # declare lists to store co...
[ "def", "define_from_header", "(", "cls", ",", "image_header", ")", ":", "self", "=", "CsuConfiguration", "(", ")", "# declare lists to store configuration of CSU bars", "self", ".", "_csu_bar_left", "=", "[", "]", "self", ".", "_csu_bar_right", "=", "[", "]", "sel...
Define class members directly from FITS header. Parameters ---------- image_header : instance of hdulist.header Header content from a FITS file.
[ "Define", "class", "members", "directly", "from", "FITS", "header", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/instrument/csu_configuration.py#L100-L138
guaix-ucm/pyemir
emirdrp/instrument/csu_configuration.py
CsuConfiguration.outdict
def outdict(self, ndigits=3): """Return dictionary structure rounded to a given precision.""" outdict = {} for i in range(EMIR_NBARS): ibar = i + 1 cbar = 'slitlet' + str(ibar).zfill(2) outdict[cbar] = {} outdict[cbar]['_csu_bar_left'] = \ ...
python
def outdict(self, ndigits=3): """Return dictionary structure rounded to a given precision.""" outdict = {} for i in range(EMIR_NBARS): ibar = i + 1 cbar = 'slitlet' + str(ibar).zfill(2) outdict[cbar] = {} outdict[cbar]['_csu_bar_left'] = \ ...
[ "def", "outdict", "(", "self", ",", "ndigits", "=", "3", ")", ":", "outdict", "=", "{", "}", "for", "i", "in", "range", "(", "EMIR_NBARS", ")", ":", "ibar", "=", "i", "+", "1", "cbar", "=", "'slitlet'", "+", "str", "(", "ibar", ")", ".", "zfill...
Return dictionary structure rounded to a given precision.
[ "Return", "dictionary", "structure", "rounded", "to", "a", "given", "precision", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/instrument/csu_configuration.py#L160-L177
guaix-ucm/pyemir
emirdrp/instrument/csu_configuration.py
CsuConfiguration.widths_in_range_mm
def widths_in_range_mm( self, minwidth=EMIR_MINIMUM_SLITLET_WIDTH_MM, maxwidth=EMIR_MAXIMUM_SLITLET_WIDTH_MM ): """Return list of slitlets which width is within given range Parameters ---------- minwidth : float Minimum slit width (mm)...
python
def widths_in_range_mm( self, minwidth=EMIR_MINIMUM_SLITLET_WIDTH_MM, maxwidth=EMIR_MAXIMUM_SLITLET_WIDTH_MM ): """Return list of slitlets which width is within given range Parameters ---------- minwidth : float Minimum slit width (mm)...
[ "def", "widths_in_range_mm", "(", "self", ",", "minwidth", "=", "EMIR_MINIMUM_SLITLET_WIDTH_MM", ",", "maxwidth", "=", "EMIR_MAXIMUM_SLITLET_WIDTH_MM", ")", ":", "list_ok", "=", "[", "]", "for", "i", "in", "range", "(", "EMIR_NBARS", ")", ":", "slitlet_ok", "=",...
Return list of slitlets which width is within given range Parameters ---------- minwidth : float Minimum slit width (mm). maxwidth : float Maximum slit width (mm). Returns ------- list_ok : list List of booleans indicating whe...
[ "Return", "list", "of", "slitlets", "which", "width", "is", "within", "given", "range" ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/instrument/csu_configuration.py#L179-L207
guaix-ucm/pyemir
emirdrp/recipes/aiv/procedures.py
encloses_annulus
def encloses_annulus(x_min, x_max, y_min, y_max, nx, ny, r_in, r_out): '''Encloses function backported from old photutils''' gout = circular_overlap_grid(x_min, x_max, y_min, y_max, nx, ny, r_out, 1, 1) gin = circular_overlap_grid(x_min, x_max, y_min, y_max, nx, ny, r_in, 1, 1) return gout - gin
python
def encloses_annulus(x_min, x_max, y_min, y_max, nx, ny, r_in, r_out): '''Encloses function backported from old photutils''' gout = circular_overlap_grid(x_min, x_max, y_min, y_max, nx, ny, r_out, 1, 1) gin = circular_overlap_grid(x_min, x_max, y_min, y_max, nx, ny, r_in, 1, 1) return gout - gin
[ "def", "encloses_annulus", "(", "x_min", ",", "x_max", ",", "y_min", ",", "y_max", ",", "nx", ",", "ny", ",", "r_in", ",", "r_out", ")", ":", "gout", "=", "circular_overlap_grid", "(", "x_min", ",", "x_max", ",", "y_min", ",", "y_max", ",", "nx", ","...
Encloses function backported from old photutils
[ "Encloses", "function", "backported", "from", "old", "photutils" ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/recipes/aiv/procedures.py#L43-L48
guaix-ucm/pyemir
emirdrp/recipes/aiv/procedures.py
comp_back_with_annulus
def comp_back_with_annulus(img, xc, yc, r_in, r_out, frac=0.1): ''' center: [x,y], center of first pixel is [0,0] ''' x_min = -0.5 - xc x_max = img.shape[1] - 0.5 - xc y_min = -0.5 - yc y_max = img.shape[1] - 0.5 - yc mm = encloses_annulus(x_min, x_max, y_min, y_max, ...
python
def comp_back_with_annulus(img, xc, yc, r_in, r_out, frac=0.1): ''' center: [x,y], center of first pixel is [0,0] ''' x_min = -0.5 - xc x_max = img.shape[1] - 0.5 - xc y_min = -0.5 - yc y_max = img.shape[1] - 0.5 - yc mm = encloses_annulus(x_min, x_max, y_min, y_max, ...
[ "def", "comp_back_with_annulus", "(", "img", ",", "xc", ",", "yc", ",", "r_in", ",", "r_out", ",", "frac", "=", "0.1", ")", ":", "x_min", "=", "-", "0.5", "-", "xc", "x_max", "=", "img", ".", "shape", "[", "1", "]", "-", "0.5", "-", "xc", "y_mi...
center: [x,y], center of first pixel is [0,0]
[ "center", ":", "[", "x", "y", "]", "center", "of", "first", "pixel", "is", "[", "0", "0", "]" ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/recipes/aiv/procedures.py#L51-L73
guaix-ucm/pyemir
emirdrp/tools/rect_wpoly_for_mos.py
main
def main(args=None): # parse command-line options parser = argparse.ArgumentParser(prog='rect_wpoly_for_mos') # required arguments parser.add_argument("input_list", help="TXT file with list JSON files derived from " "longslit data") parser.add_ar...
python
def main(args=None): # parse command-line options parser = argparse.ArgumentParser(prog='rect_wpoly_for_mos') # required arguments parser.add_argument("input_list", help="TXT file with list JSON files derived from " "longslit data") parser.add_ar...
[ "def", "main", "(", "args", "=", "None", ")", ":", "# parse command-line options", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "'rect_wpoly_for_mos'", ")", "# required arguments", "parser", ".", "add_argument", "(", "\"input_list\"", ",", "...
with open(args.out_MOSlibrary.name + '_old', 'w') as fstream: json.dump(outdict, fstream, indent=2, sort_keys=True) print('>>> Saving file ' + args.out_MOSlibrary.name + '_old')
[ "with", "open", "(", "args", ".", "out_MOSlibrary", ".", "name", "+", "_old", "w", ")", "as", "fstream", ":", "json", ".", "dump", "(", "outdict", "fstream", "indent", "=", "2", "sort_keys", "=", "True", ")", "print", "(", ">>>", "Saving", "file", "+...
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/tools/rect_wpoly_for_mos.py#L65-L434
guaix-ucm/pyemir
emirdrp/tools/display_slitlet_arrangement.py
display_slitlet_arrangement
def display_slitlet_arrangement(fileobj, grism=None, spfilter=None, bbox=None, adjust=None, geometry=None, debugplot=0): """...
python
def display_slitlet_arrangement(fileobj, grism=None, spfilter=None, bbox=None, adjust=None, geometry=None, debugplot=0): """...
[ "def", "display_slitlet_arrangement", "(", "fileobj", ",", "grism", "=", "None", ",", "spfilter", "=", "None", ",", "bbox", "=", "None", ",", "adjust", "=", "None", ",", "geometry", "=", "None", ",", "debugplot", "=", "0", ")", ":", "if", "fileobj", "....
Display slitlet arrangment from CSUP keywords in FITS header. Parameters ---------- fileobj : file object FITS or TXT file object. grism : str Grism. grism : str Filter. bbox : tuple of 4 floats If not None, values for xmin, xmax, ymin and ymax. adjust : bool...
[ "Display", "slitlet", "arrangment", "from", "CSUP", "keywords", "in", "FITS", "header", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/tools/display_slitlet_arrangement.py#L42-L248
guaix-ucm/pyemir
emirdrp/processing/wavecal/slitlet2d.py
Slitlet2D.extract_slitlet2d
def extract_slitlet2d(self, image_2k2k): """Extract slitlet 2d image from image with original EMIR dimensions. Parameters ---------- image_2k2k : numpy array Original image (dimensions EMIR_NAXIS1 * EMIR_NAXIS2) Returns ------- slitlet2d : numpy arra...
python
def extract_slitlet2d(self, image_2k2k): """Extract slitlet 2d image from image with original EMIR dimensions. Parameters ---------- image_2k2k : numpy array Original image (dimensions EMIR_NAXIS1 * EMIR_NAXIS2) Returns ------- slitlet2d : numpy arra...
[ "def", "extract_slitlet2d", "(", "self", ",", "image_2k2k", ")", ":", "# protections", "naxis2", ",", "naxis1", "=", "image_2k2k", ".", "shape", "if", "naxis1", "!=", "EMIR_NAXIS1", ":", "raise", "ValueError", "(", "'Unexpected naxis1'", ")", "if", "naxis2", "...
Extract slitlet 2d image from image with original EMIR dimensions. Parameters ---------- image_2k2k : numpy array Original image (dimensions EMIR_NAXIS1 * EMIR_NAXIS2) Returns ------- slitlet2d : numpy array Image corresponding to the slitlet reg...
[ "Extract", "slitlet", "2d", "image", "from", "image", "with", "original", "EMIR", "dimensions", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/processing/wavecal/slitlet2d.py#L316-L351
guaix-ucm/pyemir
emirdrp/processing/wavecal/slitlet2d.py
Slitlet2D.rectify
def rectify(self, slitlet2d, resampling, inverse=False): """Rectify slitlet using computed transformation. Parameters ---------- slitlet2d : numpy array Image containing the 2d slitlet image. resampling : int 1: nearest neighbour, 2: flux preserving inter...
python
def rectify(self, slitlet2d, resampling, inverse=False): """Rectify slitlet using computed transformation. Parameters ---------- slitlet2d : numpy array Image containing the 2d slitlet image. resampling : int 1: nearest neighbour, 2: flux preserving inter...
[ "def", "rectify", "(", "self", ",", "slitlet2d", ",", "resampling", ",", "inverse", "=", "False", ")", ":", "if", "resampling", "not", "in", "[", "1", ",", "2", "]", ":", "raise", "ValueError", "(", "\"Unexpected resampling value=\"", "+", "str", "(", "r...
Rectify slitlet using computed transformation. Parameters ---------- slitlet2d : numpy array Image containing the 2d slitlet image. resampling : int 1: nearest neighbour, 2: flux preserving interpolation. inverse : bool If true, the inverse re...
[ "Rectify", "slitlet", "using", "computed", "transformation", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/processing/wavecal/slitlet2d.py#L353-L404
guaix-ucm/pyemir
emirdrp/processing/wavecal/slitlet2d.py
Slitlet2D.ximshow_unrectified
def ximshow_unrectified(self, slitlet2d): """Display unrectified image with spectrails and frontiers. Parameters ---------- slitlet2d : numpy array Array containing the unrectified slitlet image. """ title = "Slitlet#" + str(self.islitlet) ax = xims...
python
def ximshow_unrectified(self, slitlet2d): """Display unrectified image with spectrails and frontiers. Parameters ---------- slitlet2d : numpy array Array containing the unrectified slitlet image. """ title = "Slitlet#" + str(self.islitlet) ax = xims...
[ "def", "ximshow_unrectified", "(", "self", ",", "slitlet2d", ")", ":", "title", "=", "\"Slitlet#\"", "+", "str", "(", "self", ".", "islitlet", ")", "ax", "=", "ximshow", "(", "slitlet2d", ",", "title", "=", "title", ",", "first_pixel", "=", "(", "self", ...
Display unrectified image with spectrails and frontiers. Parameters ---------- slitlet2d : numpy array Array containing the unrectified slitlet image.
[ "Display", "unrectified", "image", "with", "spectrails", "and", "frontiers", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/processing/wavecal/slitlet2d.py#L406-L431
guaix-ucm/pyemir
emirdrp/processing/wavecal/slitlet2d.py
Slitlet2D.ximshow_rectified
def ximshow_rectified(self, slitlet2d_rect): """Display rectified image with spectrails and frontiers. Parameters ---------- slitlet2d_rect : numpy array Array containing the rectified slitlet image """ title = "Slitlet#" + str(self.islitlet) + " (rectify)"...
python
def ximshow_rectified(self, slitlet2d_rect): """Display rectified image with spectrails and frontiers. Parameters ---------- slitlet2d_rect : numpy array Array containing the rectified slitlet image """ title = "Slitlet#" + str(self.islitlet) + " (rectify)"...
[ "def", "ximshow_rectified", "(", "self", ",", "slitlet2d_rect", ")", ":", "title", "=", "\"Slitlet#\"", "+", "str", "(", "self", ".", "islitlet", ")", "+", "\" (rectify)\"", "ax", "=", "ximshow", "(", "slitlet2d_rect", ",", "title", "=", "title", ",", "fir...
Display rectified image with spectrails and frontiers. Parameters ---------- slitlet2d_rect : numpy array Array containing the rectified slitlet image
[ "Display", "rectified", "image", "with", "spectrails", "and", "frontiers", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/processing/wavecal/slitlet2d.py#L433-L461
IdentityPython/oidcendpoint
src/oidcendpoint/jwt_token.py
JWTToken.info
def info(self, token): """ Return type of Token (A=Access code, T=Token, R=Refresh token) and the session id. :param token: A token :return: tuple of token type and session id """ verifier = JWT(key_jar=self.key_jar, allowed_sign_algs=[self.alg]) _payload...
python
def info(self, token): """ Return type of Token (A=Access code, T=Token, R=Refresh token) and the session id. :param token: A token :return: tuple of token type and session id """ verifier = JWT(key_jar=self.key_jar, allowed_sign_algs=[self.alg]) _payload...
[ "def", "info", "(", "self", ",", "token", ")", ":", "verifier", "=", "JWT", "(", "key_jar", "=", "self", ".", "key_jar", ",", "allowed_sign_algs", "=", "[", "self", ".", "alg", "]", ")", "_payload", "=", "verifier", ".", "unpack", "(", "token", ")", ...
Return type of Token (A=Access code, T=Token, R=Refresh token) and the session id. :param token: A token :return: tuple of token type and session id
[ "Return", "type", "of", "Token", "(", "A", "=", "Access", "code", "T", "=", "Token", "R", "=", "Refresh", "token", ")", "and", "the", "session", "id", "." ]
train
https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/jwt_token.py#L53-L65
IdentityPython/oidcendpoint
src/oidcendpoint/jwt_token.py
JWTToken.is_expired
def is_expired(self, token, when=0): """ Evaluate whether the token has expired or not :param token: The token :param when: The time against which to check the expiration 0 means now. :return: True/False """ verifier = JWT(key_jar=self.key_jar, allowe...
python
def is_expired(self, token, when=0): """ Evaluate whether the token has expired or not :param token: The token :param when: The time against which to check the expiration 0 means now. :return: True/False """ verifier = JWT(key_jar=self.key_jar, allowe...
[ "def", "is_expired", "(", "self", ",", "token", ",", "when", "=", "0", ")", ":", "verifier", "=", "JWT", "(", "key_jar", "=", "self", ".", "key_jar", ",", "allowed_sign_algs", "=", "[", "self", ".", "alg", "]", ")", "_payload", "=", "verifier", ".", ...
Evaluate whether the token has expired or not :param token: The token :param when: The time against which to check the expiration 0 means now. :return: True/False
[ "Evaluate", "whether", "the", "token", "has", "expired", "or", "not" ]
train
https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/jwt_token.py#L67-L78
Fuyukai/asyncwebsockets
asyncwebsockets/client.py
open_websocket
async def open_websocket(url: str, headers: Optional[list] = None, subprotocols: Optional[list] = None): """ Opens a websocket. """ ws = await create_websocket( url, headers=headers, subprotocols=subprotocols) try: yield ws finall...
python
async def open_websocket(url: str, headers: Optional[list] = None, subprotocols: Optional[list] = None): """ Opens a websocket. """ ws = await create_websocket( url, headers=headers, subprotocols=subprotocols) try: yield ws finall...
[ "async", "def", "open_websocket", "(", "url", ":", "str", ",", "headers", ":", "Optional", "[", "list", "]", "=", "None", ",", "subprotocols", ":", "Optional", "[", "list", "]", "=", "None", ")", ":", "ws", "=", "await", "create_websocket", "(", "url",...
Opens a websocket.
[ "Opens", "a", "websocket", "." ]
train
https://github.com/Fuyukai/asyncwebsockets/blob/e33e75fd51ce5ae0feac244e8407d2672c5b4745/asyncwebsockets/client.py#L20-L31
Fuyukai/asyncwebsockets
asyncwebsockets/client.py
create_websocket
async def create_websocket(url: str, ssl: Optional[SSLContext] = None, headers: Optional[list] = None, subprotocols: Optional[list] = None): """ A more low-level form of open_websocket. You are responsible for closing this webs...
python
async def create_websocket(url: str, ssl: Optional[SSLContext] = None, headers: Optional[list] = None, subprotocols: Optional[list] = None): """ A more low-level form of open_websocket. You are responsible for closing this webs...
[ "async", "def", "create_websocket", "(", "url", ":", "str", ",", "ssl", ":", "Optional", "[", "SSLContext", "]", "=", "None", ",", "headers", ":", "Optional", "[", "list", "]", "=", "None", ",", "subprotocols", ":", "Optional", "[", "list", "]", "=", ...
A more low-level form of open_websocket. You are responsible for closing this websocket.
[ "A", "more", "low", "-", "level", "form", "of", "open_websocket", ".", "You", "are", "responsible", "for", "closing", "this", "websocket", "." ]
train
https://github.com/Fuyukai/asyncwebsockets/blob/e33e75fd51ce5ae0feac244e8407d2672c5b4745/asyncwebsockets/client.py#L34-L61
Fuyukai/asyncwebsockets
asyncwebsockets/client.py
open_websocket_client
async def open_websocket_client(sock: anyio.abc.SocketStream, addr, path: str, headers: Optional[list] = None, subprotocols: Optional[list] = None): """Create a websocket on top of a socke...
python
async def open_websocket_client(sock: anyio.abc.SocketStream, addr, path: str, headers: Optional[list] = None, subprotocols: Optional[list] = None): """Create a websocket on top of a socke...
[ "async", "def", "open_websocket_client", "(", "sock", ":", "anyio", ".", "abc", ".", "SocketStream", ",", "addr", ",", "path", ":", "str", ",", "headers", ":", "Optional", "[", "list", "]", "=", "None", ",", "subprotocols", ":", "Optional", "[", "list", ...
Create a websocket on top of a socket.
[ "Create", "a", "websocket", "on", "top", "of", "a", "socket", "." ]
train
https://github.com/Fuyukai/asyncwebsockets/blob/e33e75fd51ce5ae0feac244e8407d2672c5b4745/asyncwebsockets/client.py#L65-L76
Fuyukai/asyncwebsockets
asyncwebsockets/client.py
create_websocket_client
async def create_websocket_client(sock: anyio.abc.SocketStream, addr, path: str, headers: Optional[List] = None, subprotocols: Optional[List[str]] = None): """ A more low-level...
python
async def create_websocket_client(sock: anyio.abc.SocketStream, addr, path: str, headers: Optional[List] = None, subprotocols: Optional[List[str]] = None): """ A more low-level...
[ "async", "def", "create_websocket_client", "(", "sock", ":", "anyio", ".", "abc", ".", "SocketStream", ",", "addr", ",", "path", ":", "str", ",", "headers", ":", "Optional", "[", "List", "]", "=", "None", ",", "subprotocols", ":", "Optional", "[", "List"...
A more low-level form of create_websocket_client. You are responsible for closing this websocket.
[ "A", "more", "low", "-", "level", "form", "of", "create_websocket_client", ".", "You", "are", "responsible", "for", "closing", "this", "websocket", "." ]
train
https://github.com/Fuyukai/asyncwebsockets/blob/e33e75fd51ce5ae0feac244e8407d2672c5b4745/asyncwebsockets/client.py#L79-L91
BeyondTheClouds/enoslib
docs/tutorials/grid5000/virt/tuto_grid5000_virt.py
range_mac
def range_mac(mac_start, mac_end, step=1): """Iterate over mac addresses (given as string).""" start = int(EUI(mac_start)) end = int(EUI(mac_end)) for i_mac in range(start, end, step): mac = EUI(int(EUI(i_mac)) + 1) ip = ['10'] + [str(int(i, 2)) for i in mac.bits().split('-')[-3:]] ...
python
def range_mac(mac_start, mac_end, step=1): """Iterate over mac addresses (given as string).""" start = int(EUI(mac_start)) end = int(EUI(mac_end)) for i_mac in range(start, end, step): mac = EUI(int(EUI(i_mac)) + 1) ip = ['10'] + [str(int(i, 2)) for i in mac.bits().split('-')[-3:]] ...
[ "def", "range_mac", "(", "mac_start", ",", "mac_end", ",", "step", "=", "1", ")", ":", "start", "=", "int", "(", "EUI", "(", "mac_start", ")", ")", "end", "=", "int", "(", "EUI", "(", "mac_end", ")", ")", "for", "i_mac", "in", "range", "(", "star...
Iterate over mac addresses (given as string).
[ "Iterate", "over", "mac", "addresses", "(", "given", "as", "string", ")", "." ]
train
https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/docs/tutorials/grid5000/virt/tuto_grid5000_virt.py#L16-L23
meraki-analytics/cassiopeia-datastores
cassiopeia-sqlstore/cassiopeia_sqlstore/SQLStore.py
SQLStore._one
def _one(self, query): """Gets one row from the query. Raises NotFoundError if there isn't a row or if there are multiple rows""" try: result = query.one() if result.has_expired(self._expirations): raise NotFoundError return result except (NoRe...
python
def _one(self, query): """Gets one row from the query. Raises NotFoundError if there isn't a row or if there are multiple rows""" try: result = query.one() if result.has_expired(self._expirations): raise NotFoundError return result except (NoRe...
[ "def", "_one", "(", "self", ",", "query", ")", ":", "try", ":", "result", "=", "query", ".", "one", "(", ")", "if", "result", ".", "has_expired", "(", "self", ".", "_expirations", ")", ":", "raise", "NotFoundError", "return", "result", "except", "(", ...
Gets one row from the query. Raises NotFoundError if there isn't a row or if there are multiple rows
[ "Gets", "one", "row", "from", "the", "query", ".", "Raises", "NotFoundError", "if", "there", "isn", "t", "a", "row", "or", "if", "there", "are", "multiple", "rows" ]
train
https://github.com/meraki-analytics/cassiopeia-datastores/blob/1919b79b8b036d48818eb648e712df41f8a1299c/cassiopeia-sqlstore/cassiopeia_sqlstore/SQLStore.py#L112-L120
meraki-analytics/cassiopeia-datastores
cassiopeia-sqlstore/cassiopeia_sqlstore/SQLStore.py
SQLStore._first
def _first(self, query): """Gets the first row of the query. Raises NotFoundError if there isn't a row""" result = query.first() if result is None: raise NotFoundError else: if result.has_expired(self._expirations): raise NotFoundError ...
python
def _first(self, query): """Gets the first row of the query. Raises NotFoundError if there isn't a row""" result = query.first() if result is None: raise NotFoundError else: if result.has_expired(self._expirations): raise NotFoundError ...
[ "def", "_first", "(", "self", ",", "query", ")", ":", "result", "=", "query", ".", "first", "(", ")", "if", "result", "is", "None", ":", "raise", "NotFoundError", "else", ":", "if", "result", ".", "has_expired", "(", "self", ".", "_expirations", ")", ...
Gets the first row of the query. Raises NotFoundError if there isn't a row
[ "Gets", "the", "first", "row", "of", "the", "query", ".", "Raises", "NotFoundError", "if", "there", "isn", "t", "a", "row" ]
train
https://github.com/meraki-analytics/cassiopeia-datastores/blob/1919b79b8b036d48818eb648e712df41f8a1299c/cassiopeia-sqlstore/cassiopeia_sqlstore/SQLStore.py#L122-L130
meraki-analytics/cassiopeia-datastores
cassiopeia-sqlstore/cassiopeia_sqlstore/SQLStore.py
SQLStore._all
def _all(self, query): """Gets all rows of the query. Raises a NotFoundError if there are 0 rows""" if query.count() > 0: results = query.all() for result in results: if result.has_expired(self._expirations): raise NotFoundError ret...
python
def _all(self, query): """Gets all rows of the query. Raises a NotFoundError if there are 0 rows""" if query.count() > 0: results = query.all() for result in results: if result.has_expired(self._expirations): raise NotFoundError ret...
[ "def", "_all", "(", "self", ",", "query", ")", ":", "if", "query", ".", "count", "(", ")", ">", "0", ":", "results", "=", "query", ".", "all", "(", ")", "for", "result", "in", "results", ":", "if", "result", ".", "has_expired", "(", "self", ".", ...
Gets all rows of the query. Raises a NotFoundError if there are 0 rows
[ "Gets", "all", "rows", "of", "the", "query", ".", "Raises", "a", "NotFoundError", "if", "there", "are", "0", "rows" ]
train
https://github.com/meraki-analytics/cassiopeia-datastores/blob/1919b79b8b036d48818eb648e712df41f8a1299c/cassiopeia-sqlstore/cassiopeia_sqlstore/SQLStore.py#L132-L141
meraki-analytics/cassiopeia-datastores
cassiopeia-sqlstore/cassiopeia_sqlstore/SQLStore.py
SQLStore._put
def _put(self, item: SQLBaseObject): """Puts a item into the database. Updates lastUpdate column""" if item._dto_type in self._expirations and self._expirations[item._dto_type] == 0: # The expiration time has been set to 0 -> shoud not be cached return item.updated() ...
python
def _put(self, item: SQLBaseObject): """Puts a item into the database. Updates lastUpdate column""" if item._dto_type in self._expirations and self._expirations[item._dto_type] == 0: # The expiration time has been set to 0 -> shoud not be cached return item.updated() ...
[ "def", "_put", "(", "self", ",", "item", ":", "SQLBaseObject", ")", ":", "if", "item", ".", "_dto_type", "in", "self", ".", "_expirations", "and", "self", ".", "_expirations", "[", "item", ".", "_dto_type", "]", "==", "0", ":", "# The expiration time has b...
Puts a item into the database. Updates lastUpdate column
[ "Puts", "a", "item", "into", "the", "database", ".", "Updates", "lastUpdate", "column" ]
train
https://github.com/meraki-analytics/cassiopeia-datastores/blob/1919b79b8b036d48818eb648e712df41f8a1299c/cassiopeia-sqlstore/cassiopeia_sqlstore/SQLStore.py#L144-L150
meraki-analytics/cassiopeia-datastores
cassiopeia-sqlstore/cassiopeia_sqlstore/SQLStore.py
SQLStore._put_many
def _put_many(self, items: Iterable[DtoObject], cls): """Puts many items into the database. Updates lastUpdate column for each of them""" if cls._dto_type in self._expirations and self._expirations[cls._dto_type] == 0: # The expiration time has been set to 0 -> shoud not be cached ...
python
def _put_many(self, items: Iterable[DtoObject], cls): """Puts many items into the database. Updates lastUpdate column for each of them""" if cls._dto_type in self._expirations and self._expirations[cls._dto_type] == 0: # The expiration time has been set to 0 -> shoud not be cached ...
[ "def", "_put_many", "(", "self", ",", "items", ":", "Iterable", "[", "DtoObject", "]", ",", "cls", ")", ":", "if", "cls", ".", "_dto_type", "in", "self", ".", "_expirations", "and", "self", ".", "_expirations", "[", "cls", ".", "_dto_type", "]", "==", ...
Puts many items into the database. Updates lastUpdate column for each of them
[ "Puts", "many", "items", "into", "the", "database", ".", "Updates", "lastUpdate", "column", "for", "each", "of", "them" ]
train
https://github.com/meraki-analytics/cassiopeia-datastores/blob/1919b79b8b036d48818eb648e712df41f8a1299c/cassiopeia-sqlstore/cassiopeia_sqlstore/SQLStore.py#L153-L162
IdentityPython/oidcendpoint
src/oidcendpoint/user_info/__init__.py
UserInfo.filter
def filter(self, userinfo, user_info_claims=None): """ Return only those claims that are asked for. It's a best effort task; if essential claims are not present no error is flagged. :param userinfo: A dictionary containing the available info for one user :param user_info...
python
def filter(self, userinfo, user_info_claims=None): """ Return only those claims that are asked for. It's a best effort task; if essential claims are not present no error is flagged. :param userinfo: A dictionary containing the available info for one user :param user_info...
[ "def", "filter", "(", "self", ",", "userinfo", ",", "user_info_claims", "=", "None", ")", ":", "if", "user_info_claims", "is", "None", ":", "return", "copy", ".", "copy", "(", "userinfo", ")", "else", ":", "result", "=", "{", "}", "missing", "=", "[", ...
Return only those claims that are asked for. It's a best effort task; if essential claims are not present no error is flagged. :param userinfo: A dictionary containing the available info for one user :param user_info_claims: A dictionary specifying the asked for claims :return: ...
[ "Return", "only", "those", "claims", "that", "are", "asked", "for", ".", "It", "s", "a", "best", "effort", "task", ";", "if", "essential", "claims", "are", "not", "present", "no", "error", "is", "flagged", "." ]
train
https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/user_info/__init__.py#L41-L66
volafiled/python-volapi
volapi/chat.py
ChatMessage.from_data
def from_data(room, conn, data): """Construct a ChatMessage instance from raw protocol data""" files = list() rooms = dict() msg = str() for part in data["message"]: ptype = part["type"] if ptype == "text": val = part["value"] ...
python
def from_data(room, conn, data): """Construct a ChatMessage instance from raw protocol data""" files = list() rooms = dict() msg = str() for part in data["message"]: ptype = part["type"] if ptype == "text": val = part["value"] ...
[ "def", "from_data", "(", "room", ",", "conn", ",", "data", ")", ":", "files", "=", "list", "(", ")", "rooms", "=", "dict", "(", ")", "msg", "=", "str", "(", ")", "for", "part", "in", "data", "[", "\"message\"", "]", ":", "ptype", "=", "part", "...
Construct a ChatMessage instance from raw protocol data
[ "Construct", "a", "ChatMessage", "instance", "from", "raw", "protocol", "data" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/chat.py#L80-L129
guaix-ucm/pyemir
emirdrp/recipes/acquisition/maskcheck.py
create_rot2d
def create_rot2d(angle): """Create 2D rotation matrix""" ca = math.cos(angle) sa = math.sin(angle) return np.array([[ca, -sa], [sa, ca]])
python
def create_rot2d(angle): """Create 2D rotation matrix""" ca = math.cos(angle) sa = math.sin(angle) return np.array([[ca, -sa], [sa, ca]])
[ "def", "create_rot2d", "(", "angle", ")", ":", "ca", "=", "math", ".", "cos", "(", "angle", ")", "sa", "=", "math", ".", "sin", "(", "angle", ")", "return", "np", ".", "array", "(", "[", "[", "ca", ",", "-", "sa", "]", ",", "[", "sa", ",", ...
Create 2D rotation matrix
[ "Create", "2D", "rotation", "matrix" ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/recipes/acquisition/maskcheck.py#L47-L51
guaix-ucm/pyemir
emirdrp/recipes/acquisition/maskcheck.py
comp_centroid
def comp_centroid(data, bounding_box, debug_plot=False, plot_reference=None, logger=None): """Detect objects in a region and return the centroid of the brightest one""" from matplotlib.patches import Ellipse if logger is None: logger = logging.getLogger(__name__) region = bounding_box.slice ...
python
def comp_centroid(data, bounding_box, debug_plot=False, plot_reference=None, logger=None): """Detect objects in a region and return the centroid of the brightest one""" from matplotlib.patches import Ellipse if logger is None: logger = logging.getLogger(__name__) region = bounding_box.slice ...
[ "def", "comp_centroid", "(", "data", ",", "bounding_box", ",", "debug_plot", "=", "False", ",", "plot_reference", "=", "None", ",", "logger", "=", "None", ")", ":", "from", "matplotlib", ".", "patches", "import", "Ellipse", "if", "logger", "is", "None", ":...
Detect objects in a region and return the centroid of the brightest one
[ "Detect", "objects", "in", "a", "region", "and", "return", "the", "centroid", "of", "the", "brightest", "one" ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/recipes/acquisition/maskcheck.py#L63-L119
IdentityPython/oidcendpoint
src/oidcendpoint/id_token.py
IDToken.sign_encrypt
def sign_encrypt(self, session_info, client_id, code=None, access_token=None, user_info=None, sign=True, encrypt=False, extra_claims=None): """ Signed and or encrypt a IDToken :param session_info: Session information :param client_id: Client ID ...
python
def sign_encrypt(self, session_info, client_id, code=None, access_token=None, user_info=None, sign=True, encrypt=False, extra_claims=None): """ Signed and or encrypt a IDToken :param session_info: Session information :param client_id: Client ID ...
[ "def", "sign_encrypt", "(", "self", ",", "session_info", ",", "client_id", ",", "code", "=", "None", ",", "access_token", "=", "None", ",", "user_info", "=", "None", ",", "sign", "=", "True", ",", "encrypt", "=", "False", ",", "extra_claims", "=", "None"...
Signed and or encrypt a IDToken :param session_info: Session information :param client_id: Client ID :param code: Access grant :param access_token: Access Token :param user_info: User information :param sign: If the JWT should be signed :param encrypt: If the JWT...
[ "Signed", "and", "or", "encrypt", "a", "IDToken" ]
train
https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/id_token.py#L135-L171
BreakingBytes/simkit
simkit/core/layers.py
Layer.add
def add(self, src_cls, module, package=None): """ Add layer class to model. This method may be overloaded by layer. :param src_cls: layer class to add, should not start with underscores :type src_cls: str :param module: Python module that contains layer class :type modul...
python
def add(self, src_cls, module, package=None): """ Add layer class to model. This method may be overloaded by layer. :param src_cls: layer class to add, should not start with underscores :type src_cls: str :param module: Python module that contains layer class :type modul...
[ "def", "add", "(", "self", ",", "src_cls", ",", "module", ",", "package", "=", "None", ")", ":", "# import module containing the layer class", "mod", "=", "importlib", ".", "import_module", "(", "module", ",", "package", ")", "# get layer class definition from the m...
Add layer class to model. This method may be overloaded by layer. :param src_cls: layer class to add, should not start with underscores :type src_cls: str :param module: Python module that contains layer class :type module: str :param package: optional package containing module ...
[ "Add", "layer", "class", "to", "model", ".", "This", "method", "may", "be", "overloaded", "by", "layer", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/layers.py#L64-L79
BreakingBytes/simkit
simkit/core/layers.py
Data.add
def add(self, data_source, module, package=None): """ Add data_source to model. Tries to import module, then looks for data source class definition. :param data_source: Name of data source to add. :type data_source: str :param module: Module in which data source resides....
python
def add(self, data_source, module, package=None): """ Add data_source to model. Tries to import module, then looks for data source class definition. :param data_source: Name of data source to add. :type data_source: str :param module: Module in which data source resides....
[ "def", "add", "(", "self", ",", "data_source", ",", "module", ",", "package", "=", "None", ")", ":", "super", "(", "Data", ",", "self", ")", ".", "add", "(", "data_source", ",", "module", ",", "package", ")", "# only update layer info if it is missing!", "...
Add data_source to model. Tries to import module, then looks for data source class definition. :param data_source: Name of data source to add. :type data_source: str :param module: Module in which data source resides. Can be absolute or relative. See :func:`importlib.import_...
[ "Add", "data_source", "to", "model", ".", "Tries", "to", "import", "module", "then", "looks", "for", "data", "source", "class", "definition", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/layers.py#L125-L147
BreakingBytes/simkit
simkit/core/layers.py
Data.open
def open(self, data_source, *args, **kwargs): """ Open filename to get data for data_source. :param data_source: Data source for which the file contains data. :type data_source: str Positional and keyword arguments can contain either the data to use for the data source ...
python
def open(self, data_source, *args, **kwargs): """ Open filename to get data for data_source. :param data_source: Data source for which the file contains data. :type data_source: str Positional and keyword arguments can contain either the data to use for the data source ...
[ "def", "open", "(", "self", ",", "data_source", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "sources", "[", "data_source", "]", ".", "_meta", ".", "data_reader", ".", "is_file_reader", ":", "filename", "=", "kwargs", ".", ...
Open filename to get data for data_source. :param data_source: Data source for which the file contains data. :type data_source: str Positional and keyword arguments can contain either the data to use for the data source or the full path of the file which contains data for the d...
[ "Open", "filename", "to", "get", "data", "for", "data_source", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/layers.py#L149-L178
BreakingBytes/simkit
simkit/core/layers.py
Data.load
def load(self, rel_path=None): """ Add data_sources to layer and open files with data for the data_source. """ for k, v in self.layer.iteritems(): self.add(k, v['module'], v.get('package')) filename = v.get('filename') path = v.get('path') ...
python
def load(self, rel_path=None): """ Add data_sources to layer and open files with data for the data_source. """ for k, v in self.layer.iteritems(): self.add(k, v['module'], v.get('package')) filename = v.get('filename') path = v.get('path') ...
[ "def", "load", "(", "self", ",", "rel_path", "=", "None", ")", ":", "for", "k", ",", "v", "in", "self", ".", "layer", ".", "iteritems", "(", ")", ":", "self", ".", "add", "(", "k", ",", "v", "[", "'module'", "]", ",", "v", ".", "get", "(", ...
Add data_sources to layer and open files with data for the data_source.
[ "Add", "data_sources", "to", "layer", "and", "open", "files", "with", "data", "for", "the", "data_source", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/layers.py#L180-L201
BreakingBytes/simkit
simkit/core/layers.py
Data.edit
def edit(self, data_src, value): """ Edit data layer. :param data_src: Name of :class:`DataSource` to edit. :type data_src: str :param value: Values to edit. :type value: dict """ # check if opening file if 'filename' in value: items =...
python
def edit(self, data_src, value): """ Edit data layer. :param data_src: Name of :class:`DataSource` to edit. :type data_src: str :param value: Values to edit. :type value: dict """ # check if opening file if 'filename' in value: items =...
[ "def", "edit", "(", "self", ",", "data_src", ",", "value", ")", ":", "# check if opening file", "if", "'filename'", "in", "value", ":", "items", "=", "[", "k", "for", "k", ",", "v", "in", "self", ".", "reg", ".", "data_source", ".", "iteritems", "(", ...
Edit data layer. :param data_src: Name of :class:`DataSource` to edit. :type data_src: str :param value: Values to edit. :type value: dict
[ "Edit", "data", "layer", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/layers.py#L203-L219
BreakingBytes/simkit
simkit/core/layers.py
Data.delete
def delete(self, data_src): """ Delete data sources. """ items = self.objects[data_src].data.keys() # items to edit self.reg.unregister(items) # remove items from Registry self.layer.pop(data_src) # remove data source from layer self.objects.pop(data_src) # re...
python
def delete(self, data_src): """ Delete data sources. """ items = self.objects[data_src].data.keys() # items to edit self.reg.unregister(items) # remove items from Registry self.layer.pop(data_src) # remove data source from layer self.objects.pop(data_src) # re...
[ "def", "delete", "(", "self", ",", "data_src", ")", ":", "items", "=", "self", ".", "objects", "[", "data_src", "]", ".", "data", ".", "keys", "(", ")", "# items to edit", "self", ".", "reg", ".", "unregister", "(", "items", ")", "# remove items from Reg...
Delete data sources.
[ "Delete", "data", "sources", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/layers.py#L221-L229
BreakingBytes/simkit
simkit/core/layers.py
Formulas.add
def add(self, formula, module, package=None): """ Import module (from package) with formulas, import formulas and add them to formula registry. :param formula: Name of the formula source to add/open. :param module: Module containing formula source. :param package: [Optio...
python
def add(self, formula, module, package=None): """ Import module (from package) with formulas, import formulas and add them to formula registry. :param formula: Name of the formula source to add/open. :param module: Module containing formula source. :param package: [Optio...
[ "def", "add", "(", "self", ",", "formula", ",", "module", ",", "package", "=", "None", ")", ":", "super", "(", "Formulas", ",", "self", ")", ".", "add", "(", "formula", ",", "module", ",", "package", ")", "# only update layer info if it is missing!", "if",...
Import module (from package) with formulas, import formulas and add them to formula registry. :param formula: Name of the formula source to add/open. :param module: Module containing formula source. :param package: [Optional] Package of formula source module. .. seealso:: ...
[ "Import", "module", "(", "from", "package", ")", "with", "formulas", "import", "formulas", "and", "add", "them", "to", "formula", "registry", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/layers.py#L239-L260
BreakingBytes/simkit
simkit/core/layers.py
Formulas.load
def load(self, _=None): """ Add formulas to layer. """ for k, v in self.layer.iteritems(): self.add(k, v['module'], v.get('package'))
python
def load(self, _=None): """ Add formulas to layer. """ for k, v in self.layer.iteritems(): self.add(k, v['module'], v.get('package'))
[ "def", "load", "(", "self", ",", "_", "=", "None", ")", ":", "for", "k", ",", "v", "in", "self", ".", "layer", ".", "iteritems", "(", ")", ":", "self", ".", "add", "(", "k", ",", "v", "[", "'module'", "]", ",", "v", ".", "get", "(", "'packa...
Add formulas to layer.
[ "Add", "formulas", "to", "layer", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/layers.py#L265-L270
BreakingBytes/simkit
simkit/core/layers.py
Calculations.add
def add(self, calc, module, package=None): """ Add calc to layer. """ super(Calculations, self).add(calc, module, package) # only update layer info if it is missing! if calc not in self.layer: # copy calc source parameters to :attr:`Layer.layer` se...
python
def add(self, calc, module, package=None): """ Add calc to layer. """ super(Calculations, self).add(calc, module, package) # only update layer info if it is missing! if calc not in self.layer: # copy calc source parameters to :attr:`Layer.layer` se...
[ "def", "add", "(", "self", ",", "calc", ",", "module", ",", "package", "=", "None", ")", ":", "super", "(", "Calculations", ",", "self", ")", ".", "add", "(", "calc", ",", "module", ",", "package", ")", "# only update layer info if it is missing!", "if", ...
Add calc to layer.
[ "Add", "calc", "to", "layer", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/layers.py#L286-L300
BreakingBytes/simkit
simkit/core/layers.py
Outputs.add
def add(self, output, module, package=None): """ Add output to """ super(Outputs, self).add(output, module, package) # only update layer info if it is missing! if output not in self.layer: # copy output source parameters to :attr:`Layer.layer` self...
python
def add(self, output, module, package=None): """ Add output to """ super(Outputs, self).add(output, module, package) # only update layer info if it is missing! if output not in self.layer: # copy output source parameters to :attr:`Layer.layer` self...
[ "def", "add", "(", "self", ",", "output", ",", "module", ",", "package", "=", "None", ")", ":", "super", "(", "Outputs", ",", "self", ")", ".", "add", "(", "output", ",", "module", ",", "package", ")", "# only update layer info if it is missing!", "if", ...
Add output to
[ "Add", "output", "to" ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/layers.py#L326-L340
BreakingBytes/simkit
simkit/core/layers.py
Simulations.add
def add(self, sim, module, package=None): """ Add simulation to layer. """ super(Simulations, self).add(sim, module, package) # only update layer info if it is missing! if sim not in self.layer: # copy simulation source parameters to :attr:`Layer.layer` ...
python
def add(self, sim, module, package=None): """ Add simulation to layer. """ super(Simulations, self).add(sim, module, package) # only update layer info if it is missing! if sim not in self.layer: # copy simulation source parameters to :attr:`Layer.layer` ...
[ "def", "add", "(", "self", ",", "sim", ",", "module", ",", "package", "=", "None", ")", ":", "super", "(", "Simulations", ",", "self", ")", ".", "add", "(", "sim", ",", "module", ",", "package", ")", "# only update layer info if it is missing!", "if", "s...
Add simulation to layer.
[ "Add", "simulation", "to", "layer", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/layers.py#L366-L374
BreakingBytes/simkit
simkit/core/layers.py
Simulations.load
def load(self, rel_path=None): """ Add sim_src to layer. """ for k, v in self.layer.iteritems(): self.add(k, v['module'], v.get('package')) filename = v.get('filename') path = v.get('path') if filename: warnings.warn(Depreca...
python
def load(self, rel_path=None): """ Add sim_src to layer. """ for k, v in self.layer.iteritems(): self.add(k, v['module'], v.get('package')) filename = v.get('filename') path = v.get('path') if filename: warnings.warn(Depreca...
[ "def", "load", "(", "self", ",", "rel_path", "=", "None", ")", ":", "for", "k", ",", "v", "in", "self", ".", "layer", ".", "iteritems", "(", ")", ":", "self", ".", "add", "(", "k", ",", "v", "[", "'module'", "]", ",", "v", ".", "get", "(", ...
Add sim_src to layer.
[ "Add", "sim_src", "to", "layer", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/layers.py#L386-L402
BreakingBytes/simkit
examples/PVPower/pvpower/formulas/irradiance.py
f_solpos
def f_solpos(times, latitude, longitude): """ Calculate solar position for lat/long at times. :param times: Python :class:`datetime.datetime` object. :type times: list :param latitude: latitude [degrees] :type latitude: float :param longitude: longitude [degrees] :type longitude: float ...
python
def f_solpos(times, latitude, longitude): """ Calculate solar position for lat/long at times. :param times: Python :class:`datetime.datetime` object. :type times: list :param latitude: latitude [degrees] :type latitude: float :param longitude: longitude [degrees] :type longitude: float ...
[ "def", "f_solpos", "(", "times", ",", "latitude", ",", "longitude", ")", ":", "# pvlib converts Python datetime objects to pandas DatetimeIndex", "solpos", "=", "pvlib", ".", "solarposition", ".", "get_solarposition", "(", "times", ",", "latitude", ",", "longitude", "...
Calculate solar position for lat/long at times. :param times: Python :class:`datetime.datetime` object. :type times: list :param latitude: latitude [degrees] :type latitude: float :param longitude: longitude [degrees] :type longitude: float :returns: apparent zenith, azimuth
[ "Calculate", "solar", "position", "for", "lat", "/", "long", "at", "times", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/examples/PVPower/pvpower/formulas/irradiance.py#L25-L41
BreakingBytes/simkit
examples/PVPower/pvpower/formulas/irradiance.py
f_total_irrad
def f_total_irrad(times, surface_tilt, surface_azimuth, solar_zenith, solar_azimuth, dni, ghi, dhi, dni_extra, am_abs, model='haydavies'): """ Calculate total irradiance :param times: timestamps :param surface_tilt: panel tilt from horizontal [deg] :param surface...
python
def f_total_irrad(times, surface_tilt, surface_azimuth, solar_zenith, solar_azimuth, dni, ghi, dhi, dni_extra, am_abs, model='haydavies'): """ Calculate total irradiance :param times: timestamps :param surface_tilt: panel tilt from horizontal [deg] :param surface...
[ "def", "f_total_irrad", "(", "times", ",", "surface_tilt", ",", "surface_azimuth", ",", "solar_zenith", ",", "solar_azimuth", ",", "dni", ",", "ghi", ",", "dhi", ",", "dni_extra", ",", "am_abs", ",", "model", "=", "'haydavies'", ")", ":", "am_abs", "=", "a...
Calculate total irradiance :param times: timestamps :param surface_tilt: panel tilt from horizontal [deg] :param surface_azimuth: panel azimuth from north [deg] :param solar_zenith: refracted solar zenith angle [deg] :param solar_azimuth: solar azimuth [deg] :param dni: direct normal irradiance...
[ "Calculate", "total", "irradiance" ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/examples/PVPower/pvpower/formulas/irradiance.py#L63-L101
guaix-ucm/pyemir
emirdrp/processing/wavecal/rescale_array_z1z2.py
rescale_array_to_z1z2
def rescale_array_to_z1z2(array, z1z2=(-1.0, 1.0)): """Rescale the values in a numpy array to the [z1,z2] interval. The transformation is carried out following the relation array_rs = b_flux * array - c_flux as explained in Appendix B1 of Cardiel (2009, MNRAS, 396, 680) Parameters ---------- ...
python
def rescale_array_to_z1z2(array, z1z2=(-1.0, 1.0)): """Rescale the values in a numpy array to the [z1,z2] interval. The transformation is carried out following the relation array_rs = b_flux * array - c_flux as explained in Appendix B1 of Cardiel (2009, MNRAS, 396, 680) Parameters ---------- ...
[ "def", "rescale_array_to_z1z2", "(", "array", ",", "z1z2", "=", "(", "-", "1.0", ",", "1.0", ")", ")", ":", "if", "type", "(", "array", ")", "is", "not", "np", ".", "ndarray", ":", "raise", "ValueError", "(", "\"array=\"", "+", "str", "(", "array", ...
Rescale the values in a numpy array to the [z1,z2] interval. The transformation is carried out following the relation array_rs = b_flux * array - c_flux as explained in Appendix B1 of Cardiel (2009, MNRAS, 396, 680) Parameters ---------- array : numpy array Numpy array to be rescaled. ...
[ "Rescale", "the", "values", "in", "a", "numpy", "array", "to", "the", "[", "z1", "z2", "]", "interval", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/processing/wavecal/rescale_array_z1z2.py#L27-L64
guaix-ucm/pyemir
emirdrp/processing/wavecal/rescale_array_z1z2.py
rescale_array_from_z1z2
def rescale_array_from_z1z2(array_rs, coef_rs=None): """Restore the values in a numpy array rescaled to the [z1,z2] interval. The transformation is carried out following the relation array = (array_rs + c_flux)/b_flux as explained in Appendix B1 of Cardiel (2009, MNRAS, 396, 680) Parameters --...
python
def rescale_array_from_z1z2(array_rs, coef_rs=None): """Restore the values in a numpy array rescaled to the [z1,z2] interval. The transformation is carried out following the relation array = (array_rs + c_flux)/b_flux as explained in Appendix B1 of Cardiel (2009, MNRAS, 396, 680) Parameters --...
[ "def", "rescale_array_from_z1z2", "(", "array_rs", ",", "coef_rs", "=", "None", ")", ":", "if", "type", "(", "array_rs", ")", "is", "not", "np", ".", "ndarray", ":", "raise", "ValueError", "(", "\"array_rs=\"", "+", "str", "(", "array_rs", ")", "+", "\"m...
Restore the values in a numpy array rescaled to the [z1,z2] interval. The transformation is carried out following the relation array = (array_rs + c_flux)/b_flux as explained in Appendix B1 of Cardiel (2009, MNRAS, 396, 680) Parameters ---------- array_rs : numpy array Numpy array prev...
[ "Restore", "the", "values", "in", "a", "numpy", "array", "rescaled", "to", "the", "[", "z1", "z2", "]", "interval", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/processing/wavecal/rescale_array_z1z2.py#L67-L99
TriOptima/tri.declarative
lib/tri/declarative/__init__.py
with_meta
def with_meta(class_to_decorate=None, add_init_kwargs=True): """ Class decorator to enable a class (and it's sub-classes) to have a 'Meta' class attribute. :type class_to_decorate: class :param bool add_init_kwargs: Pass Meta class members to constructor :rtype: class """ ...
python
def with_meta(class_to_decorate=None, add_init_kwargs=True): """ Class decorator to enable a class (and it's sub-classes) to have a 'Meta' class attribute. :type class_to_decorate: class :param bool add_init_kwargs: Pass Meta class members to constructor :rtype: class """ ...
[ "def", "with_meta", "(", "class_to_decorate", "=", "None", ",", "add_init_kwargs", "=", "True", ")", ":", "if", "class_to_decorate", "is", "None", ":", "return", "functools", ".", "partial", "(", "with_meta", ",", "add_init_kwargs", "=", "add_init_kwargs", ")", ...
Class decorator to enable a class (and it's sub-classes) to have a 'Meta' class attribute. :type class_to_decorate: class :param bool add_init_kwargs: Pass Meta class members to constructor :rtype: class
[ "Class", "decorator", "to", "enable", "a", "class", "(", "and", "it", "s", "sub", "-", "classes", ")", "to", "have", "a", "Meta", "class", "attribute", "." ]
train
https://github.com/TriOptima/tri.declarative/blob/13d90d4c2a10934e37a4139e63d51a859fb3e303/lib/tri/declarative/__init__.py#L27-L48
TriOptima/tri.declarative
lib/tri/declarative/__init__.py
get_meta
def get_meta(cls): """ Collect all members of any contained :code:`Meta` class declarations from the given class or any of its base classes. (Sub class values take precedence.) :type cls: class :rtype: Struct """ merged_attributes = Struct() for class_ in reversed(cls.mr...
python
def get_meta(cls): """ Collect all members of any contained :code:`Meta` class declarations from the given class or any of its base classes. (Sub class values take precedence.) :type cls: class :rtype: Struct """ merged_attributes = Struct() for class_ in reversed(cls.mr...
[ "def", "get_meta", "(", "cls", ")", ":", "merged_attributes", "=", "Struct", "(", ")", "for", "class_", "in", "reversed", "(", "cls", ".", "mro", "(", ")", ")", ":", "if", "hasattr", "(", "class_", ",", "'Meta'", ")", ":", "for", "key", ",", "value...
Collect all members of any contained :code:`Meta` class declarations from the given class or any of its base classes. (Sub class values take precedence.) :type cls: class :rtype: Struct
[ "Collect", "all", "members", "of", "any", "contained", ":", "code", ":", "Meta", "class", "declarations", "from", "the", "given", "class", "or", "any", "of", "its", "base", "classes", ".", "(", "Sub", "class", "values", "take", "precedence", ".", ")" ]
train
https://github.com/TriOptima/tri.declarative/blob/13d90d4c2a10934e37a4139e63d51a859fb3e303/lib/tri/declarative/__init__.py#L51-L64
TriOptima/tri.declarative
lib/tri/declarative/__init__.py
creation_ordered
def creation_ordered(class_to_decorate): """ Class decorator that ensures that instances will be ordered after creation order when sorted. :type class_to_decorate: class :rtype: class """ next_index = functools.partial(next, itertools.count()) __init__orig = class_to_decorate....
python
def creation_ordered(class_to_decorate): """ Class decorator that ensures that instances will be ordered after creation order when sorted. :type class_to_decorate: class :rtype: class """ next_index = functools.partial(next, itertools.count()) __init__orig = class_to_decorate....
[ "def", "creation_ordered", "(", "class_to_decorate", ")", ":", "next_index", "=", "functools", ".", "partial", "(", "next", ",", "itertools", ".", "count", "(", ")", ")", "__init__orig", "=", "class_to_decorate", ".", "__init__", "@", "functools", ".", "wraps"...
Class decorator that ensures that instances will be ordered after creation order when sorted. :type class_to_decorate: class :rtype: class
[ "Class", "decorator", "that", "ensures", "that", "instances", "will", "be", "ordered", "after", "creation", "order", "when", "sorted", "." ]
train
https://github.com/TriOptima/tri.declarative/blob/13d90d4c2a10934e37a4139e63d51a859fb3e303/lib/tri/declarative/__init__.py#L67-L94
TriOptima/tri.declarative
lib/tri/declarative/__init__.py
get_members
def get_members(cls, member_class=None, is_member=None, sort_key=None, _parameter=None): """ Collect all class level attributes matching the given criteria. :param class member_class: Class(es) to collect :param is_member: Function to determine if an object should be collected :para...
python
def get_members(cls, member_class=None, is_member=None, sort_key=None, _parameter=None): """ Collect all class level attributes matching the given criteria. :param class member_class: Class(es) to collect :param is_member: Function to determine if an object should be collected :para...
[ "def", "get_members", "(", "cls", ",", "member_class", "=", "None", ",", "is_member", "=", "None", ",", "sort_key", "=", "None", ",", "_parameter", "=", "None", ")", ":", "if", "member_class", "is", "None", "and", "is_member", "is", "None", ":", "raise",...
Collect all class level attributes matching the given criteria. :param class member_class: Class(es) to collect :param is_member: Function to determine if an object should be collected :param sort_key: Function to invoke on members to obtain ordering (Default is to use ordering from `creation_o...
[ "Collect", "all", "class", "level", "attributes", "matching", "the", "given", "criteria", "." ]
train
https://github.com/TriOptima/tri.declarative/blob/13d90d4c2a10934e37a4139e63d51a859fb3e303/lib/tri/declarative/__init__.py#L102-L151
TriOptima/tri.declarative
lib/tri/declarative/__init__.py
declarative
def declarative(member_class=None, parameter='members', add_init_kwargs=True, sort_key=default_sort_key, is_member=None): """ Class decorator to enable classes to be defined in the style of django models. That is, @declarative classes will get an additional argument to constructor, containin...
python
def declarative(member_class=None, parameter='members', add_init_kwargs=True, sort_key=default_sort_key, is_member=None): """ Class decorator to enable classes to be defined in the style of django models. That is, @declarative classes will get an additional argument to constructor, containin...
[ "def", "declarative", "(", "member_class", "=", "None", ",", "parameter", "=", "'members'", ",", "add_init_kwargs", "=", "True", ",", "sort_key", "=", "default_sort_key", ",", "is_member", "=", "None", ")", ":", "if", "member_class", "is", "None", "and", "is...
Class decorator to enable classes to be defined in the style of django models. That is, @declarative classes will get an additional argument to constructor, containing an OrderedDict with all class members matching the specified type. :param class member_class: Class(es) to collect :par...
[ "Class", "decorator", "to", "enable", "classes", "to", "be", "defined", "in", "the", "style", "of", "django", "models", ".", "That", "is", "@declarative", "classes", "will", "get", "an", "additional", "argument", "to", "constructor", "containing", "an", "Order...
train
https://github.com/TriOptima/tri.declarative/blob/13d90d4c2a10934e37a4139e63d51a859fb3e303/lib/tri/declarative/__init__.py#L154-L209
TriOptima/tri.declarative
lib/tri/declarative/__init__.py
get_signature
def get_signature(func): """ :type func: Callable :rtype: str """ try: return object.__getattribute__(func, '__tri_declarative_signature') except AttributeError: pass try: if sys.version_info[0] < 3: # pragma: no mutate names, _, varkw, defaults ...
python
def get_signature(func): """ :type func: Callable :rtype: str """ try: return object.__getattribute__(func, '__tri_declarative_signature') except AttributeError: pass try: if sys.version_info[0] < 3: # pragma: no mutate names, _, varkw, defaults ...
[ "def", "get_signature", "(", "func", ")", ":", "try", ":", "return", "object", ".", "__getattribute__", "(", "func", ",", "'__tri_declarative_signature'", ")", "except", "AttributeError", ":", "pass", "try", ":", "if", "sys", ".", "version_info", "[", "0", "...
:type func: Callable :rtype: str
[ ":", "type", "func", ":", "Callable", ":", "rtype", ":", "str" ]
train
https://github.com/TriOptima/tri.declarative/blob/13d90d4c2a10934e37a4139e63d51a859fb3e303/lib/tri/declarative/__init__.py#L299-L336
TriOptima/tri.declarative
lib/tri/declarative/__init__.py
collect_namespaces
def collect_namespaces(values): """ Gather mappings with keys of the shape '<base_key>__<sub_key>' as new dicts under '<base_key>', indexed by '<sub_key>'. >>> foo = dict( ... foo__foo=1, ... foo__bar=2, ... bar__foo=3, ... bar__bar=4, ... foo_baz=5, ... baz=...
python
def collect_namespaces(values): """ Gather mappings with keys of the shape '<base_key>__<sub_key>' as new dicts under '<base_key>', indexed by '<sub_key>'. >>> foo = dict( ... foo__foo=1, ... foo__bar=2, ... bar__foo=3, ... bar__bar=4, ... foo_baz=5, ... baz=...
[ "def", "collect_namespaces", "(", "values", ")", ":", "namespaces", "=", "{", "}", "result", "=", "dict", "(", "values", ")", "for", "key", ",", "value", "in", "values", ".", "items", "(", ")", ":", "parts", "=", "key", ".", "split", "(", "'__'", "...
Gather mappings with keys of the shape '<base_key>__<sub_key>' as new dicts under '<base_key>', indexed by '<sub_key>'. >>> foo = dict( ... foo__foo=1, ... foo__bar=2, ... bar__foo=3, ... bar__bar=4, ... foo_baz=5, ... baz=6 ... ) >>> assert collect_namespac...
[ "Gather", "mappings", "with", "keys", "of", "the", "shape", "<base_key", ">", "__<sub_key", ">", "as", "new", "dicts", "under", "<base_key", ">", "indexed", "by", "<sub_key", ">", "." ]
train
https://github.com/TriOptima/tri.declarative/blob/13d90d4c2a10934e37a4139e63d51a859fb3e303/lib/tri/declarative/__init__.py#L440-L479
TriOptima/tri.declarative
lib/tri/declarative/__init__.py
extract_subkeys
def extract_subkeys(kwargs, prefix, defaults=None): """ Extract mappings of the shape '<base_key>__<sub_key>' to new mappings under '<sub_key>'. >>> foo = { ... 'foo__foo': 1, ... 'foo__bar': 2, ... 'baz': 3, ... } >>> assert extract_subkeys(foo, 'foo', defaults={'quux': 4})...
python
def extract_subkeys(kwargs, prefix, defaults=None): """ Extract mappings of the shape '<base_key>__<sub_key>' to new mappings under '<sub_key>'. >>> foo = { ... 'foo__foo': 1, ... 'foo__bar': 2, ... 'baz': 3, ... } >>> assert extract_subkeys(foo, 'foo', defaults={'quux': 4})...
[ "def", "extract_subkeys", "(", "kwargs", ",", "prefix", ",", "defaults", "=", "None", ")", ":", "prefix", "+=", "'__'", "result", "=", "{", "k", "[", "len", "(", "prefix", ")", ":", "]", ":", "v", "for", "k", ",", "v", "in", "kwargs", ".", "items...
Extract mappings of the shape '<base_key>__<sub_key>' to new mappings under '<sub_key>'. >>> foo = { ... 'foo__foo': 1, ... 'foo__bar': 2, ... 'baz': 3, ... } >>> assert extract_subkeys(foo, 'foo', defaults={'quux': 4}) == { ... 'foo': 1, ... 'bar': 2, ... 'q...
[ "Extract", "mappings", "of", "the", "shape", "<base_key", ">", "__<sub_key", ">", "to", "new", "mappings", "under", "<sub_key", ">", "." ]
train
https://github.com/TriOptima/tri.declarative/blob/13d90d4c2a10934e37a4139e63d51a859fb3e303/lib/tri/declarative/__init__.py#L482-L506
TriOptima/tri.declarative
lib/tri/declarative/__init__.py
setdefaults
def setdefaults(d, d2): """ :type d: dict :type d2: dict :rtype: dict """ for k, v in d2.items(): d.setdefault(k, v) return d
python
def setdefaults(d, d2): """ :type d: dict :type d2: dict :rtype: dict """ for k, v in d2.items(): d.setdefault(k, v) return d
[ "def", "setdefaults", "(", "d", ",", "d2", ")", ":", "for", "k", ",", "v", "in", "d2", ".", "items", "(", ")", ":", "d", ".", "setdefault", "(", "k", ",", "v", ")", "return", "d" ]
:type d: dict :type d2: dict :rtype: dict
[ ":", "type", "d", ":", "dict", ":", "type", "d2", ":", "dict", ":", "rtype", ":", "dict" ]
train
https://github.com/TriOptima/tri.declarative/blob/13d90d4c2a10934e37a4139e63d51a859fb3e303/lib/tri/declarative/__init__.py#L509-L517
TriOptima/tri.declarative
lib/tri/declarative/__init__.py
getattr_path
def getattr_path(obj, path): """ Get an attribute path, as defined by a string separated by '__'. getattr_path(foo, 'a__b__c') is roughly equivalent to foo.a.b.c but will short circuit to return None if something on the path is None. """ path = path.split('__') for name in path: obj ...
python
def getattr_path(obj, path): """ Get an attribute path, as defined by a string separated by '__'. getattr_path(foo, 'a__b__c') is roughly equivalent to foo.a.b.c but will short circuit to return None if something on the path is None. """ path = path.split('__') for name in path: obj ...
[ "def", "getattr_path", "(", "obj", ",", "path", ")", ":", "path", "=", "path", ".", "split", "(", "'__'", ")", "for", "name", "in", "path", ":", "obj", "=", "getattr", "(", "obj", ",", "name", ")", "if", "obj", "is", "None", ":", "return", "None"...
Get an attribute path, as defined by a string separated by '__'. getattr_path(foo, 'a__b__c') is roughly equivalent to foo.a.b.c but will short circuit to return None if something on the path is None.
[ "Get", "an", "attribute", "path", "as", "defined", "by", "a", "string", "separated", "by", "__", ".", "getattr_path", "(", "foo", "a__b__c", ")", "is", "roughly", "equivalent", "to", "foo", ".", "a", ".", "b", ".", "c", "but", "will", "short", "circuit...
train
https://github.com/TriOptima/tri.declarative/blob/13d90d4c2a10934e37a4139e63d51a859fb3e303/lib/tri/declarative/__init__.py#L704-L715
TriOptima/tri.declarative
lib/tri/declarative/__init__.py
setattr_path
def setattr_path(obj, path, value): """ Set an attribute path, as defined by a string separated by '__'. setattr_path(foo, 'a__b__c', value) is equivalent to "foo.a.b.c = value". """ path = path.split('__') o = obj for name in path[:-1]: o = getattr(o, name) setattr(o, path[-1], ...
python
def setattr_path(obj, path, value): """ Set an attribute path, as defined by a string separated by '__'. setattr_path(foo, 'a__b__c', value) is equivalent to "foo.a.b.c = value". """ path = path.split('__') o = obj for name in path[:-1]: o = getattr(o, name) setattr(o, path[-1], ...
[ "def", "setattr_path", "(", "obj", ",", "path", ",", "value", ")", ":", "path", "=", "path", ".", "split", "(", "'__'", ")", "o", "=", "obj", "for", "name", "in", "path", "[", ":", "-", "1", "]", ":", "o", "=", "getattr", "(", "o", ",", "name...
Set an attribute path, as defined by a string separated by '__'. setattr_path(foo, 'a__b__c', value) is equivalent to "foo.a.b.c = value".
[ "Set", "an", "attribute", "path", "as", "defined", "by", "a", "string", "separated", "by", "__", ".", "setattr_path", "(", "foo", "a__b__c", "value", ")", "is", "equivalent", "to", "foo", ".", "a", ".", "b", ".", "c", "=", "value", "." ]
train
https://github.com/TriOptima/tri.declarative/blob/13d90d4c2a10934e37a4139e63d51a859fb3e303/lib/tri/declarative/__init__.py#L718-L728
TriOptima/tri.declarative
lib/tri/declarative/__init__.py
generate_rst_docs
def generate_rst_docs(directory, classes, missing_objects=None): """ Generate documentation for tri.declarative APIs :param directory: directory to write the .rst files into :param classes: list of classes to generate documentation for :param missing_objects: tuple of objects to count as missing ma...
python
def generate_rst_docs(directory, classes, missing_objects=None): """ Generate documentation for tri.declarative APIs :param directory: directory to write the .rst files into :param classes: list of classes to generate documentation for :param missing_objects: tuple of objects to count as missing ma...
[ "def", "generate_rst_docs", "(", "directory", ",", "classes", ",", "missing_objects", "=", "None", ")", ":", "doc_by_filename", "=", "_generate_rst_docs", "(", "classes", "=", "classes", ",", "missing_objects", "=", "missing_objects", ")", "# pragma: no mutate", "fo...
Generate documentation for tri.declarative APIs :param directory: directory to write the .rst files into :param classes: list of classes to generate documentation for :param missing_objects: tuple of objects to count as missing markers, if applicable
[ "Generate", "documentation", "for", "tri", ".", "declarative", "APIs" ]
train
https://github.com/TriOptima/tri.declarative/blob/13d90d4c2a10934e37a4139e63d51a859fb3e303/lib/tri/declarative/__init__.py#L844-L856
BreakingBytes/simkit
simkit/contrib/lazy_looping_calculator.py
reg_copy
def reg_copy(reg, keys=None): """ Make a copy of a subset of a registry. :param reg: source registry :param keys: keys of registry items to copy :return: copied registry subset """ if keys is None: keys = reg.keys() reg_cls = type(reg) new_reg = reg_cls() mk = {} # empt...
python
def reg_copy(reg, keys=None): """ Make a copy of a subset of a registry. :param reg: source registry :param keys: keys of registry items to copy :return: copied registry subset """ if keys is None: keys = reg.keys() reg_cls = type(reg) new_reg = reg_cls() mk = {} # empt...
[ "def", "reg_copy", "(", "reg", ",", "keys", "=", "None", ")", ":", "if", "keys", "is", "None", ":", "keys", "=", "reg", ".", "keys", "(", ")", "reg_cls", "=", "type", "(", "reg", ")", "new_reg", "=", "reg_cls", "(", ")", "mk", "=", "{", "}", ...
Make a copy of a subset of a registry. :param reg: source registry :param keys: keys of registry items to copy :return: copied registry subset
[ "Make", "a", "copy", "of", "a", "subset", "of", "a", "registry", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/contrib/lazy_looping_calculator.py#L14-L43
BreakingBytes/simkit
simkit/contrib/lazy_looping_calculator.py
LazyLoopingCalculator.get_covariance
def get_covariance(datargs, outargs, vargs, datvar, outvar): """ Get covariance matrix. :param datargs: data arguments :param outargs: output arguments :param vargs: variable arguments :param datvar: variance of data arguments :param outvar: variance of output ar...
python
def get_covariance(datargs, outargs, vargs, datvar, outvar): """ Get covariance matrix. :param datargs: data arguments :param outargs: output arguments :param vargs: variable arguments :param datvar: variance of data arguments :param outvar: variance of output ar...
[ "def", "get_covariance", "(", "datargs", ",", "outargs", ",", "vargs", ",", "datvar", ",", "outvar", ")", ":", "# number of formula arguments that are not constant", "argn", "=", "len", "(", "vargs", ")", "# number of observations must be the same for all vargs", "nobs", ...
Get covariance matrix. :param datargs: data arguments :param outargs: output arguments :param vargs: variable arguments :param datvar: variance of data arguments :param outvar: variance of output arguments :return: covariance
[ "Get", "covariance", "matrix", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/contrib/lazy_looping_calculator.py#L64-L134
BreakingBytes/simkit
simkit/contrib/lazy_looping_calculator.py
LazyLoopingCalculator.calculate
def calculate(self, calc, formula_reg, data_reg, out_reg, timestep=None, idx=None): """ Calculate looping over specified repeat arguments. :param calc: Calculation to loop over. :param formula_reg: Formula registry :param data_reg: Data registry :param ...
python
def calculate(self, calc, formula_reg, data_reg, out_reg, timestep=None, idx=None): """ Calculate looping over specified repeat arguments. :param calc: Calculation to loop over. :param formula_reg: Formula registry :param data_reg: Data registry :param ...
[ "def", "calculate", "(", "self", ",", "calc", ",", "formula_reg", ",", "data_reg", ",", "out_reg", ",", "timestep", "=", "None", ",", "idx", "=", "None", ")", ":", "# the superclass Calculator.calculate() method", "base_calculator", "=", "super", "(", "LazyLoopi...
Calculate looping over specified repeat arguments. :param calc: Calculation to loop over. :param formula_reg: Formula registry :param data_reg: Data registry :param out_reg: Outputs registry :param timestep: timestep used for dynamic calcs :param idx: index used in dynam...
[ "Calculate", "looping", "over", "specified", "repeat", "arguments", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/contrib/lazy_looping_calculator.py#L136-L250
volafiled/python-volapi
volapi/volapi.py
listen_many
def listen_many(*rooms): """Listen for changes in all registered listeners in all specified rooms""" rooms = set(r.conn for r in rooms) for room in rooms: room.validate_listeners() with ARBITRATOR.condition: while any(r.connected for r in rooms): ARBITRATOR.condition.wait() ...
python
def listen_many(*rooms): """Listen for changes in all registered listeners in all specified rooms""" rooms = set(r.conn for r in rooms) for room in rooms: room.validate_listeners() with ARBITRATOR.condition: while any(r.connected for r in rooms): ARBITRATOR.condition.wait() ...
[ "def", "listen_many", "(", "*", "rooms", ")", ":", "rooms", "=", "set", "(", "r", ".", "conn", "for", "r", "in", "rooms", ")", "for", "room", "in", "rooms", ":", "room", ".", "validate_listeners", "(", ")", "with", "ARBITRATOR", ".", "condition", ":"...
Listen for changes in all registered listeners in all specified rooms
[ "Listen", "for", "changes", "in", "all", "registered", "listeners", "in", "all", "specified", "rooms" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L907-L918
volafiled/python-volapi
volapi/volapi.py
Connection.connect
def connect(self, username, checksum, password=None, key=None): """Connect to websocket through asyncio http interface""" ws_url = ( f"{BASE_WS_URL}?room={self.room.room_id}&cs={checksum}&nick={username}" f"&rn={random_id(6)}&t={int(time.time() * 1000)}&transport=websocket&EIO=3...
python
def connect(self, username, checksum, password=None, key=None): """Connect to websocket through asyncio http interface""" ws_url = ( f"{BASE_WS_URL}?room={self.room.room_id}&cs={checksum}&nick={username}" f"&rn={random_id(6)}&t={int(time.time() * 1000)}&transport=websocket&EIO=3...
[ "def", "connect", "(", "self", ",", "username", ",", "checksum", ",", "password", "=", "None", ",", "key", "=", "None", ")", ":", "ws_url", "=", "(", "f\"{BASE_WS_URL}?room={self.room.room_id}&cs={checksum}&nick={username}\"", "f\"&rn={random_id(6)}&t={int(time.time() * 1...
Connect to websocket through asyncio http interface
[ "Connect", "to", "websocket", "through", "asyncio", "http", "interface" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L74-L89
volafiled/python-volapi
volapi/volapi.py
Connection.send_ack
def send_ack(self): """Send an ack message""" if self.last_ack == self.proto.max_id: return LOGGER.debug("ack (%d)", self.proto.max_id) self.last_ack = self.proto.max_id self.send_message(f"4{to_json([self.proto.max_id])}")
python
def send_ack(self): """Send an ack message""" if self.last_ack == self.proto.max_id: return LOGGER.debug("ack (%d)", self.proto.max_id) self.last_ack = self.proto.max_id self.send_message(f"4{to_json([self.proto.max_id])}")
[ "def", "send_ack", "(", "self", ")", ":", "if", "self", ".", "last_ack", "==", "self", ".", "proto", ".", "max_id", ":", "return", "LOGGER", ".", "debug", "(", "\"ack (%d)\"", ",", "self", ".", "proto", ".", "max_id", ")", "self", ".", "last_ack", "=...
Send an ack message
[ "Send", "an", "ack", "message" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L112-L119
volafiled/python-volapi
volapi/volapi.py
Connection.make_call
def make_call(self, fun, *args): """Makes a regular API call""" obj = {"fn": fun, "args": list(args)} obj = [self.proto.max_id, [[0, ["call", obj]], self.proto.send_count]] self.send_message(f"4{to_json(obj)}") self.proto.send_count += 1
python
def make_call(self, fun, *args): """Makes a regular API call""" obj = {"fn": fun, "args": list(args)} obj = [self.proto.max_id, [[0, ["call", obj]], self.proto.send_count]] self.send_message(f"4{to_json(obj)}") self.proto.send_count += 1
[ "def", "make_call", "(", "self", ",", "fun", ",", "*", "args", ")", ":", "obj", "=", "{", "\"fn\"", ":", "fun", ",", "\"args\"", ":", "list", "(", "args", ")", "}", "obj", "=", "[", "self", ".", "proto", ".", "max_id", ",", "[", "[", "0", ","...
Makes a regular API call
[ "Makes", "a", "regular", "API", "call" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L121-L127
volafiled/python-volapi
volapi/volapi.py
Connection.make_call_with_cb
def make_call_with_cb(self, fun, *args): """Makes an API call with a callback to wait for""" cid, event = self.handler.register_callback() argscp = list(args) argscp.append(cid) self.make_call(fun, *argscp) return event
python
def make_call_with_cb(self, fun, *args): """Makes an API call with a callback to wait for""" cid, event = self.handler.register_callback() argscp = list(args) argscp.append(cid) self.make_call(fun, *argscp) return event
[ "def", "make_call_with_cb", "(", "self", ",", "fun", ",", "*", "args", ")", ":", "cid", ",", "event", "=", "self", ".", "handler", ".", "register_callback", "(", ")", "argscp", "=", "list", "(", "args", ")", "argscp", ".", "append", "(", "cid", ")", ...
Makes an API call with a callback to wait for
[ "Makes", "an", "API", "call", "with", "a", "callback", "to", "wait", "for" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L129-L136
volafiled/python-volapi
volapi/volapi.py
Connection.make_api_call
def make_api_call(self, call, params): """Make a REST API call""" if not isinstance(params, dict): raise ValueError("params argument must be a dictionary") kw = dict( params=params, headers={"Origin": BASE_URL, "Referer": f"{BASE_URL}/r/{self.room.name}"}, ...
python
def make_api_call(self, call, params): """Make a REST API call""" if not isinstance(params, dict): raise ValueError("params argument must be a dictionary") kw = dict( params=params, headers={"Origin": BASE_URL, "Referer": f"{BASE_URL}/r/{self.room.name}"}, ...
[ "def", "make_api_call", "(", "self", ",", "call", ",", "params", ")", ":", "if", "not", "isinstance", "(", "params", ",", "dict", ")", ":", "raise", "ValueError", "(", "\"params argument must be a dictionary\"", ")", "kw", "=", "dict", "(", "params", "=", ...
Make a REST API call
[ "Make", "a", "REST", "API", "call" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L138-L147
volafiled/python-volapi
volapi/volapi.py
Connection.reraise
def reraise(self, ex): """Reraise an exception passed by the event thread""" self.exception = ex self.process_queues(forced=True)
python
def reraise(self, ex): """Reraise an exception passed by the event thread""" self.exception = ex self.process_queues(forced=True)
[ "def", "reraise", "(", "self", ",", "ex", ")", ":", "self", ".", "exception", "=", "ex", "self", ".", "process_queues", "(", "forced", "=", "True", ")" ]
Reraise an exception passed by the event thread
[ "Reraise", "an", "exception", "passed", "by", "the", "event", "thread" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L149-L153
volafiled/python-volapi
volapi/volapi.py
Connection.close
def close(self): """Closes connection pair""" if self.connected: obj = [self.proto.max_id, [[2], self.proto.send_count]] ARBITRATOR.send_sync_message(self.proto, f"4{to_json(obj)}") self.proto.send_count += 1 ARBITRATOR.close(self.proto) self.list...
python
def close(self): """Closes connection pair""" if self.connected: obj = [self.proto.max_id, [[2], self.proto.send_count]] ARBITRATOR.send_sync_message(self.proto, f"4{to_json(obj)}") self.proto.send_count += 1 ARBITRATOR.close(self.proto) self.list...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "connected", ":", "obj", "=", "[", "self", ".", "proto", ".", "max_id", ",", "[", "[", "2", "]", ",", "self", ".", "proto", ".", "send_count", "]", "]", "ARBITRATOR", ".", "send_sync_message...
Closes connection pair
[ "Closes", "connection", "pair" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L155-L167
volafiled/python-volapi
volapi/volapi.py
Connection.on_open
async def on_open(self): """DingDongmaster the connection is open""" self.__ensure_barrier() while self.connected: try: if self.__lastping > self.__lastpong: raise IOError("Last ping remained unanswered") self.send_message("2") ...
python
async def on_open(self): """DingDongmaster the connection is open""" self.__ensure_barrier() while self.connected: try: if self.__lastping > self.__lastpong: raise IOError("Last ping remained unanswered") self.send_message("2") ...
[ "async", "def", "on_open", "(", "self", ")", ":", "self", ".", "__ensure_barrier", "(", ")", "while", "self", ".", "connected", ":", "try", ":", "if", "self", ".", "__lastping", ">", "self", ".", "__lastpong", ":", "raise", "IOError", "(", "\"Last ping r...
DingDongmaster the connection is open
[ "DingDongmaster", "the", "connection", "is", "open" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L174-L195
volafiled/python-volapi
volapi/volapi.py
Connection.on_message
def on_message(self, new_data): """Processes incoming messages according to engine-io rules""" # https://github.com/socketio/engine.io-protocol LOGGER.debug("new frame [%r]", new_data) try: what = int(new_data[0]) data = new_data[1:] data = data and f...
python
def on_message(self, new_data): """Processes incoming messages according to engine-io rules""" # https://github.com/socketio/engine.io-protocol LOGGER.debug("new frame [%r]", new_data) try: what = int(new_data[0]) data = new_data[1:] data = data and f...
[ "def", "on_message", "(", "self", ",", "new_data", ")", ":", "# https://github.com/socketio/engine.io-protocol", "LOGGER", ".", "debug", "(", "\"new frame [%r]\"", ",", "new_data", ")", "try", ":", "what", "=", "int", "(", "new_data", "[", "0", "]", ")", "data...
Processes incoming messages according to engine-io rules
[ "Processes", "incoming", "messages", "according", "to", "engine", "-", "io", "rules" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L232-L267
volafiled/python-volapi
volapi/volapi.py
Connection.add_listener
def add_listener(self, event_type, callback): """Add a listener for specific event type. You'll need to actually listen for changes using the listen method""" if not self.connected: # wait for errors set by reraise method time.sleep(1) if self.exception: ...
python
def add_listener(self, event_type, callback): """Add a listener for specific event type. You'll need to actually listen for changes using the listen method""" if not self.connected: # wait for errors set by reraise method time.sleep(1) if self.exception: ...
[ "def", "add_listener", "(", "self", ",", "event_type", ",", "callback", ")", ":", "if", "not", "self", ".", "connected", ":", "# wait for errors set by reraise method", "time", ".", "sleep", "(", "1", ")", "if", "self", ".", "exception", ":", "# pylint: disabl...
Add a listener for specific event type. You'll need to actually listen for changes using the listen method
[ "Add", "a", "listener", "for", "specific", "event", "type", ".", "You", "ll", "need", "to", "actually", "listen", "for", "changes", "using", "the", "listen", "method" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L269-L286
volafiled/python-volapi
volapi/volapi.py
Connection.enqueue_data
def enqueue_data(self, event_type, data): """Enqueue a data item for specific event type""" with self.lock: listeners = self.listeners.values() for listener in listeners: listener.enqueue(event_type, data) self.must_process = True
python
def enqueue_data(self, event_type, data): """Enqueue a data item for specific event type""" with self.lock: listeners = self.listeners.values() for listener in listeners: listener.enqueue(event_type, data) self.must_process = True
[ "def", "enqueue_data", "(", "self", ",", "event_type", ",", "data", ")", ":", "with", "self", ".", "lock", ":", "listeners", "=", "self", ".", "listeners", ".", "values", "(", ")", "for", "listener", "in", "listeners", ":", "listener", ".", "enqueue", ...
Enqueue a data item for specific event type
[ "Enqueue", "a", "data", "item", "for", "specific", "event", "type" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L288-L295
volafiled/python-volapi
volapi/volapi.py
Connection.process_queues
def process_queues(self, forced=False): """Process queues if any have data queued""" with self.lock: if (not forced and not self.must_process) or not self.queues_enabled: return self.must_process = False ARBITRATOR.awaken()
python
def process_queues(self, forced=False): """Process queues if any have data queued""" with self.lock: if (not forced and not self.must_process) or not self.queues_enabled: return self.must_process = False ARBITRATOR.awaken()
[ "def", "process_queues", "(", "self", ",", "forced", "=", "False", ")", ":", "with", "self", ".", "lock", ":", "if", "(", "not", "forced", "and", "not", "self", ".", "must_process", ")", "or", "not", "self", ".", "queues_enabled", ":", "return", "self"...
Process queues if any have data queued
[ "Process", "queues", "if", "any", "have", "data", "queued" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L310-L317
volafiled/python-volapi
volapi/volapi.py
Connection.__listeners_for_thread
def __listeners_for_thread(self): """All Listeners for the current thread""" thread = get_thread_ident() with self.lock: return [l for tid, l in self.listeners.items() if tid == thread]
python
def __listeners_for_thread(self): """All Listeners for the current thread""" thread = get_thread_ident() with self.lock: return [l for tid, l in self.listeners.items() if tid == thread]
[ "def", "__listeners_for_thread", "(", "self", ")", ":", "thread", "=", "get_thread_ident", "(", ")", "with", "self", ".", "lock", ":", "return", "[", "l", "for", "tid", ",", "l", "in", "self", ".", "listeners", ".", "items", "(", ")", "if", "tid", "=...
All Listeners for the current thread
[ "All", "Listeners", "for", "the", "current", "thread" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L320-L325
volafiled/python-volapi
volapi/volapi.py
Connection.validate_listeners
def validate_listeners(self): """Validates that some listeners are actually registered""" if self.exception: # pylint: disable=raising-bad-type raise self.exception listeners = self.__listeners_for_thread if not sum(len(l) for l in listeners): raise ...
python
def validate_listeners(self): """Validates that some listeners are actually registered""" if self.exception: # pylint: disable=raising-bad-type raise self.exception listeners = self.__listeners_for_thread if not sum(len(l) for l in listeners): raise ...
[ "def", "validate_listeners", "(", "self", ")", ":", "if", "self", ".", "exception", ":", "# pylint: disable=raising-bad-type", "raise", "self", ".", "exception", "listeners", "=", "self", ".", "__listeners_for_thread", "if", "not", "sum", "(", "len", "(", "l", ...
Validates that some listeners are actually registered
[ "Validates", "that", "some", "listeners", "are", "actually", "registered" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L327-L336
volafiled/python-volapi
volapi/volapi.py
Connection.listen
def listen(self): """Listen for changes in all registered listeners.""" self.validate_listeners() with ARBITRATOR.condition: while self.connected: ARBITRATOR.condition.wait() if not self.run_queues(): break
python
def listen(self): """Listen for changes in all registered listeners.""" self.validate_listeners() with ARBITRATOR.condition: while self.connected: ARBITRATOR.condition.wait() if not self.run_queues(): break
[ "def", "listen", "(", "self", ")", ":", "self", ".", "validate_listeners", "(", ")", "with", "ARBITRATOR", ".", "condition", ":", "while", "self", ".", "connected", ":", "ARBITRATOR", ".", "condition", ".", "wait", "(", ")", "if", "not", "self", ".", "...
Listen for changes in all registered listeners.
[ "Listen", "for", "changes", "in", "all", "registered", "listeners", "." ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L338-L346
volafiled/python-volapi
volapi/volapi.py
Connection.run_queues
def run_queues(self): """Run all queues that have data queued""" if self.exception: # pylint: disable=raising-bad-type raise self.exception listeners = self.__listeners_for_thread return sum(l.process() for l in listeners) > 0
python
def run_queues(self): """Run all queues that have data queued""" if self.exception: # pylint: disable=raising-bad-type raise self.exception listeners = self.__listeners_for_thread return sum(l.process() for l in listeners) > 0
[ "def", "run_queues", "(", "self", ")", ":", "if", "self", ".", "exception", ":", "# pylint: disable=raising-bad-type", "raise", "self", ".", "exception", "listeners", "=", "self", ".", "__listeners_for_thread", "return", "sum", "(", "l", ".", "process", "(", "...
Run all queues that have data queued
[ "Run", "all", "queues", "that", "have", "data", "queued" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L348-L355
volafiled/python-volapi
volapi/volapi.py
Room.__add_prop
def __add_prop(self, key, admin=False): """Add gettable and settable room config property during runtime""" def getter(self): return self.config[key] def setter(self, val): if admin and not self.admin: raise RuntimeError( f"You can't ...
python
def __add_prop(self, key, admin=False): """Add gettable and settable room config property during runtime""" def getter(self): return self.config[key] def setter(self, val): if admin and not self.admin: raise RuntimeError( f"You can't ...
[ "def", "__add_prop", "(", "self", ",", "key", ",", "admin", "=", "False", ")", ":", "def", "getter", "(", "self", ")", ":", "return", "self", ".", "config", "[", "key", "]", "def", "setter", "(", "self", ",", "val", ")", ":", "if", "admin", "and"...
Add gettable and settable room config property during runtime
[ "Add", "gettable", "and", "settable", "room", "config", "property", "during", "runtime" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L417-L430
volafiled/python-volapi
volapi/volapi.py
Room.__set_config_value
def __set_config_value(self, key, value): """Sets a value for a room config""" self.check_owner() params = {"room": self.room_id, "config": to_json({key: value})} resp = self.conn.make_api_call("setRoomConfig", params) if "error" in resp: raise RuntimeError(f"{resp['...
python
def __set_config_value(self, key, value): """Sets a value for a room config""" self.check_owner() params = {"room": self.room_id, "config": to_json({key: value})} resp = self.conn.make_api_call("setRoomConfig", params) if "error" in resp: raise RuntimeError(f"{resp['...
[ "def", "__set_config_value", "(", "self", ",", "key", ",", "value", ")", ":", "self", ".", "check_owner", "(", ")", "params", "=", "{", "\"room\"", ":", "self", ".", "room_id", ",", "\"config\"", ":", "to_json", "(", "{", "key", ":", "value", "}", ")...
Sets a value for a room config
[ "Sets", "a", "value", "for", "a", "room", "config" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L432-L440