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 |
|---|---|---|---|---|---|---|---|---|---|---|
guaix-ucm/pyemir | emirdrp/util/sexcatalog.py | SExtractorfile.read | def read(self):
"""
Read the file until EOF and return a list of dictionaries.
"""
__result = []
__ll = self.readline()
while __ll:
__result.append(__ll)
__ll = self.readline()
return list(__result) | python | def read(self):
"""
Read the file until EOF and return a list of dictionaries.
"""
__result = []
__ll = self.readline()
while __ll:
__result.append(__ll)
__ll = self.readline()
return list(__result) | [
"def",
"read",
"(",
"self",
")",
":",
"__result",
"=",
"[",
"]",
"__ll",
"=",
"self",
".",
"readline",
"(",
")",
"while",
"__ll",
":",
"__result",
".",
"append",
"(",
"__ll",
")",
"__ll",
"=",
"self",
".",
"readline",
"(",
")",
"return",
"list",
... | Read the file until EOF and return a list of dictionaries. | [
"Read",
"the",
"file",
"until",
"EOF",
"and",
"return",
"a",
"list",
"of",
"dictionaries",
"."
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/util/sexcatalog.py#L761-L772 |
guaix-ucm/pyemir | emirdrp/util/sexcatalog.py | SExtractorfile.close | def close(self):
"""
Close the SExtractor file.
"""
if self._file:
if not(self._file.closed):
self._file.close()
self.closed = True | python | def close(self):
"""
Close the SExtractor file.
"""
if self._file:
if not(self._file.closed):
self._file.close()
self.closed = True | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_file",
":",
"if",
"not",
"(",
"self",
".",
"_file",
".",
"closed",
")",
":",
"self",
".",
"_file",
".",
"close",
"(",
")",
"self",
".",
"closed",
"=",
"True"
] | Close the SExtractor file. | [
"Close",
"the",
"SExtractor",
"file",
"."
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/util/sexcatalog.py#L777-L784 |
BeyondTheClouds/enoslib | enoslib/infra/enos_g5k/driver.py | get_driver | def get_driver(configuration):
"""Build an instance of the driver to interact with G5K
"""
resources = configuration["resources"]
machines = resources["machines"]
networks = resources["networks"]
oargrid_jobids = configuration.get("oargrid_jobids")
if oargrid_jobids:
logger.debug("L... | python | def get_driver(configuration):
"""Build an instance of the driver to interact with G5K
"""
resources = configuration["resources"]
machines = resources["machines"]
networks = resources["networks"]
oargrid_jobids = configuration.get("oargrid_jobids")
if oargrid_jobids:
logger.debug("L... | [
"def",
"get_driver",
"(",
"configuration",
")",
":",
"resources",
"=",
"configuration",
"[",
"\"resources\"",
"]",
"machines",
"=",
"resources",
"[",
"\"machines\"",
"]",
"networks",
"=",
"resources",
"[",
"\"networks\"",
"]",
"oargrid_jobids",
"=",
"configuration... | Build an instance of the driver to interact with G5K | [
"Build",
"an",
"instance",
"of",
"the",
"driver",
"to",
"interact",
"with",
"G5K"
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/driver.py#L18-L48 |
IdentityPython/oidcendpoint | src/oidcendpoint/cookie.py | ver_dec_content | def ver_dec_content(parts, sign_key=None, enc_key=None, sign_alg='SHA256'):
"""
Verifies the value of a cookie
:param parts: The parts of the payload
:param sign_key: A :py:class:`cryptojwt.jwk.hmac.SYMKey` instance
:param enc_key: A :py:class:`cryptojwt.jwk.hmac.SYMKey` instance
:param sign_al... | python | def ver_dec_content(parts, sign_key=None, enc_key=None, sign_alg='SHA256'):
"""
Verifies the value of a cookie
:param parts: The parts of the payload
:param sign_key: A :py:class:`cryptojwt.jwk.hmac.SYMKey` instance
:param enc_key: A :py:class:`cryptojwt.jwk.hmac.SYMKey` instance
:param sign_al... | [
"def",
"ver_dec_content",
"(",
"parts",
",",
"sign_key",
"=",
"None",
",",
"enc_key",
"=",
"None",
",",
"sign_alg",
"=",
"'SHA256'",
")",
":",
"if",
"parts",
"is",
"None",
":",
"return",
"None",
"elif",
"len",
"(",
"parts",
")",
"==",
"3",
":",
"# ve... | Verifies the value of a cookie
:param parts: The parts of the payload
:param sign_key: A :py:class:`cryptojwt.jwk.hmac.SYMKey` instance
:param enc_key: A :py:class:`cryptojwt.jwk.hmac.SYMKey` instance
:param sign_alg: Which signing algorithm to was used
:return: A tuple with basic information and a... | [
"Verifies",
"the",
"value",
"of",
"a",
"cookie"
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/cookie.py#L88-L129 |
IdentityPython/oidcendpoint | src/oidcendpoint/cookie.py | make_cookie_content | def make_cookie_content(name, load, sign_key, domain=None, path=None,
timestamp="", enc_key=None, max_age=0,
sign_alg='SHA256'):
"""
Create and return a cookies content
If you only provide a `seed`, a HMAC gets added to the cookies value
and this is check... | python | def make_cookie_content(name, load, sign_key, domain=None, path=None,
timestamp="", enc_key=None, max_age=0,
sign_alg='SHA256'):
"""
Create and return a cookies content
If you only provide a `seed`, a HMAC gets added to the cookies value
and this is check... | [
"def",
"make_cookie_content",
"(",
"name",
",",
"load",
",",
"sign_key",
",",
"domain",
"=",
"None",
",",
"path",
"=",
"None",
",",
"timestamp",
"=",
"\"\"",
",",
"enc_key",
"=",
"None",
",",
"max_age",
"=",
"0",
",",
"sign_alg",
"=",
"'SHA256'",
")",
... | Create and return a cookies content
If you only provide a `seed`, a HMAC gets added to the cookies value
and this is checked, when the cookie is parsed again.
If you provide both `seed` and `enc_key`, the cookie gets protected
by using AEAD encryption. This provides both a MAC over the whole cookie
... | [
"Create",
"and",
"return",
"a",
"cookies",
"content"
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/cookie.py#L132-L181 |
IdentityPython/oidcendpoint | src/oidcendpoint/cookie.py | cookie_parts | def cookie_parts(name, kaka):
"""
Give me the parts of the cookie payload
:param name: A name of a cookie object
:param kaka: The cookie
:return: A list of parts or None if there is no cookie object with the
given name
"""
cookie_obj = SimpleCookie(as_unicode(kaka))
morsel = coo... | python | def cookie_parts(name, kaka):
"""
Give me the parts of the cookie payload
:param name: A name of a cookie object
:param kaka: The cookie
:return: A list of parts or None if there is no cookie object with the
given name
"""
cookie_obj = SimpleCookie(as_unicode(kaka))
morsel = coo... | [
"def",
"cookie_parts",
"(",
"name",
",",
"kaka",
")",
":",
"cookie_obj",
"=",
"SimpleCookie",
"(",
"as_unicode",
"(",
"kaka",
")",
")",
"morsel",
"=",
"cookie_obj",
".",
"get",
"(",
"name",
")",
"if",
"morsel",
":",
"return",
"morsel",
".",
"value",
".... | Give me the parts of the cookie payload
:param name: A name of a cookie object
:param kaka: The cookie
:return: A list of parts or None if there is no cookie object with the
given name | [
"Give",
"me",
"the",
"parts",
"of",
"the",
"cookie",
"payload"
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/cookie.py#L201-L215 |
IdentityPython/oidcendpoint | src/oidcendpoint/cookie.py | parse_cookie | def parse_cookie(name, sign_key, kaka, enc_key=None, sign_alg='SHA256'):
"""Parses and verifies a cookie value
Parses a cookie created by `make_cookie` and verifies
it has not been tampered with.
You need to provide the same `sign_key` and `enc_key`
used when creating the cookie, otherwise the ver... | python | def parse_cookie(name, sign_key, kaka, enc_key=None, sign_alg='SHA256'):
"""Parses and verifies a cookie value
Parses a cookie created by `make_cookie` and verifies
it has not been tampered with.
You need to provide the same `sign_key` and `enc_key`
used when creating the cookie, otherwise the ver... | [
"def",
"parse_cookie",
"(",
"name",
",",
"sign_key",
",",
"kaka",
",",
"enc_key",
"=",
"None",
",",
"sign_alg",
"=",
"'SHA256'",
")",
":",
"if",
"not",
"kaka",
":",
"return",
"None",
"parts",
"=",
"cookie_parts",
"(",
"name",
",",
"kaka",
")",
"return"... | Parses and verifies a cookie value
Parses a cookie created by `make_cookie` and verifies
it has not been tampered with.
You need to provide the same `sign_key` and `enc_key`
used when creating the cookie, otherwise the verification
fails. See `make_cookie` for details about the verification.
... | [
"Parses",
"and",
"verifies",
"a",
"cookie",
"value"
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/cookie.py#L218-L241 |
IdentityPython/oidcendpoint | src/oidcendpoint/cookie.py | CookieDealer.delete_cookie | def delete_cookie(self, cookie_name=None):
"""
Create a cookie that will immediately expire when it hits the other
side.
:param cookie_name: Name of the cookie
:return: A tuple to be added to headers
"""
if cookie_name is None:
cookie_name = self.defa... | python | def delete_cookie(self, cookie_name=None):
"""
Create a cookie that will immediately expire when it hits the other
side.
:param cookie_name: Name of the cookie
:return: A tuple to be added to headers
"""
if cookie_name is None:
cookie_name = self.defa... | [
"def",
"delete_cookie",
"(",
"self",
",",
"cookie_name",
"=",
"None",
")",
":",
"if",
"cookie_name",
"is",
"None",
":",
"cookie_name",
"=",
"self",
".",
"default_value",
"[",
"'name'",
"]",
"return",
"self",
".",
"create_cookie",
"(",
"\"\"",
",",
"\"\"",
... | Create a cookie that will immediately expire when it hits the other
side.
:param cookie_name: Name of the cookie
:return: A tuple to be added to headers | [
"Create",
"a",
"cookie",
"that",
"will",
"immediately",
"expire",
"when",
"it",
"hits",
"the",
"other",
"side",
"."
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/cookie.py#L286-L297 |
IdentityPython/oidcendpoint | src/oidcendpoint/cookie.py | CookieDealer.get_cookie_value | def get_cookie_value(self, cookie=None, cookie_name=None):
"""
Return information stored in a Cookie
:param cookie: A cookie instance
:param cookie_name: The name of the cookie I'm looking for
:return: tuple (value, timestamp, type)
"""
if cookie_name is None:
... | python | def get_cookie_value(self, cookie=None, cookie_name=None):
"""
Return information stored in a Cookie
:param cookie: A cookie instance
:param cookie_name: The name of the cookie I'm looking for
:return: tuple (value, timestamp, type)
"""
if cookie_name is None:
... | [
"def",
"get_cookie_value",
"(",
"self",
",",
"cookie",
"=",
"None",
",",
"cookie_name",
"=",
"None",
")",
":",
"if",
"cookie_name",
"is",
"None",
":",
"cookie_name",
"=",
"self",
".",
"default_value",
"[",
"'name'",
"]",
"if",
"cookie",
"is",
"None",
"or... | Return information stored in a Cookie
:param cookie: A cookie instance
:param cookie_name: The name of the cookie I'm looking for
:return: tuple (value, timestamp, type) | [
"Return",
"information",
"stored",
"in",
"a",
"Cookie"
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/cookie.py#L344-L367 |
IdentityPython/oidcendpoint | src/oidcendpoint/cookie.py | CookieDealer.append_cookie | def append_cookie(self, cookie, name, payload, typ, domain=None, path=None,
timestamp="", max_age=0):
"""
Adds a cookie to a SimpleCookie instance
:param cookie:
:param name:
:param payload:
:param typ:
:param domain:
:param path:
... | python | def append_cookie(self, cookie, name, payload, typ, domain=None, path=None,
timestamp="", max_age=0):
"""
Adds a cookie to a SimpleCookie instance
:param cookie:
:param name:
:param payload:
:param typ:
:param domain:
:param path:
... | [
"def",
"append_cookie",
"(",
"self",
",",
"cookie",
",",
"name",
",",
"payload",
",",
"typ",
",",
"domain",
"=",
"None",
",",
"path",
"=",
"None",
",",
"timestamp",
"=",
"\"\"",
",",
"max_age",
"=",
"0",
")",
":",
"timestamp",
"=",
"str",
"(",
"int... | Adds a cookie to a SimpleCookie instance
:param cookie:
:param name:
:param payload:
:param typ:
:param domain:
:param path:
:param timestamp:
:param max_age:
:return: | [
"Adds",
"a",
"cookie",
"to",
"a",
"SimpleCookie",
"instance"
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/cookie.py#L369-L404 |
BreakingBytes/simkit | examples/PVPower/pvpower/formulas/performance.py | f_ac_power | def f_ac_power(inverter, v_mp, p_mp):
"""
Calculate AC power
:param inverter:
:param v_mp:
:param p_mp:
:return: AC power [W]
"""
return pvlib.pvsystem.snlinverter(v_mp, p_mp, inverter).flatten() | python | def f_ac_power(inverter, v_mp, p_mp):
"""
Calculate AC power
:param inverter:
:param v_mp:
:param p_mp:
:return: AC power [W]
"""
return pvlib.pvsystem.snlinverter(v_mp, p_mp, inverter).flatten() | [
"def",
"f_ac_power",
"(",
"inverter",
",",
"v_mp",
",",
"p_mp",
")",
":",
"return",
"pvlib",
".",
"pvsystem",
".",
"snlinverter",
"(",
"v_mp",
",",
"p_mp",
",",
"inverter",
")",
".",
"flatten",
"(",
")"
] | Calculate AC power
:param inverter:
:param v_mp:
:param p_mp:
:return: AC power [W] | [
"Calculate",
"AC",
"power"
] | train | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/examples/PVPower/pvpower/formulas/performance.py#L10-L19 |
BreakingBytes/simkit | examples/PVPower/pvpower/formulas/performance.py | f_dc_power | def f_dc_power(effective_irradiance, cell_temp, module):
"""
Calculate DC power using Sandia Performance model
:param effective_irradiance: effective irradiance [suns]
:param cell_temp: PV cell temperature [degC]
:param module: PV module dictionary or pandas data frame
:returns: i_sc, i_mp, v_o... | python | def f_dc_power(effective_irradiance, cell_temp, module):
"""
Calculate DC power using Sandia Performance model
:param effective_irradiance: effective irradiance [suns]
:param cell_temp: PV cell temperature [degC]
:param module: PV module dictionary or pandas data frame
:returns: i_sc, i_mp, v_o... | [
"def",
"f_dc_power",
"(",
"effective_irradiance",
",",
"cell_temp",
",",
"module",
")",
":",
"dc",
"=",
"pvlib",
".",
"pvsystem",
".",
"sapm",
"(",
"effective_irradiance",
",",
"cell_temp",
",",
"module",
")",
"fields",
"=",
"(",
"'i_sc'",
",",
"'i_mp'",
"... | Calculate DC power using Sandia Performance model
:param effective_irradiance: effective irradiance [suns]
:param cell_temp: PV cell temperature [degC]
:param module: PV module dictionary or pandas data frame
:returns: i_sc, i_mp, v_oc, v_mp, p_mp | [
"Calculate",
"DC",
"power",
"using",
"Sandia",
"Performance",
"model"
] | train | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/examples/PVPower/pvpower/formulas/performance.py#L22-L33 |
BreakingBytes/simkit | examples/PVPower/pvpower/formulas/performance.py | f_effective_irradiance | def f_effective_irradiance(poa_direct, poa_diffuse, am_abs, aoi, module):
"""
Calculate effective irradiance for Sandia Performance model
:param poa_direct: plane of array direct irradiance [W/m**2]
:param poa_diffuse: plane of array diffuse irradiance [W/m**2]
:param am_abs: absolute air mass [dim... | python | def f_effective_irradiance(poa_direct, poa_diffuse, am_abs, aoi, module):
"""
Calculate effective irradiance for Sandia Performance model
:param poa_direct: plane of array direct irradiance [W/m**2]
:param poa_diffuse: plane of array diffuse irradiance [W/m**2]
:param am_abs: absolute air mass [dim... | [
"def",
"f_effective_irradiance",
"(",
"poa_direct",
",",
"poa_diffuse",
",",
"am_abs",
",",
"aoi",
",",
"module",
")",
":",
"Ee",
"=",
"pvlib",
".",
"pvsystem",
".",
"sapm_effective_irradiance",
"(",
"poa_direct",
",",
"poa_diffuse",
",",
"am_abs",
",",
"aoi",... | Calculate effective irradiance for Sandia Performance model
:param poa_direct: plane of array direct irradiance [W/m**2]
:param poa_diffuse: plane of array diffuse irradiance [W/m**2]
:param am_abs: absolute air mass [dimensionless]
:param aoi: angle of incidence [degrees]
:param module: PV module ... | [
"Calculate",
"effective",
"irradiance",
"for",
"Sandia",
"Performance",
"model"
] | train | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/examples/PVPower/pvpower/formulas/performance.py#L36-L49 |
BreakingBytes/simkit | examples/PVPower/pvpower/formulas/performance.py | f_cell_temp | def f_cell_temp(poa_global, wind_speed, air_temp):
"""
Calculate cell temperature.
:param poa_global: plane of array global irradiance [W/m**2]
:param wind_speed: wind speed [m/s]
:param air_temp: ambient dry bulb air temperature [degC]
:return: cell temperature [degC]
"""
temps = pvlib... | python | def f_cell_temp(poa_global, wind_speed, air_temp):
"""
Calculate cell temperature.
:param poa_global: plane of array global irradiance [W/m**2]
:param wind_speed: wind speed [m/s]
:param air_temp: ambient dry bulb air temperature [degC]
:return: cell temperature [degC]
"""
temps = pvlib... | [
"def",
"f_cell_temp",
"(",
"poa_global",
",",
"wind_speed",
",",
"air_temp",
")",
":",
"temps",
"=",
"pvlib",
".",
"pvsystem",
".",
"sapm_celltemp",
"(",
"poa_global",
",",
"wind_speed",
",",
"air_temp",
")",
"return",
"temps",
"[",
"'temp_cell'",
"]",
".",
... | Calculate cell temperature.
:param poa_global: plane of array global irradiance [W/m**2]
:param wind_speed: wind speed [m/s]
:param air_temp: ambient dry bulb air temperature [degC]
:return: cell temperature [degC] | [
"Calculate",
"cell",
"temperature",
"."
] | train | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/examples/PVPower/pvpower/formulas/performance.py#L52-L62 |
BreakingBytes/simkit | examples/PVPower/pvpower/formulas/performance.py | f_aoi | def f_aoi(surface_tilt, surface_azimuth, solar_zenith, solar_azimuth):
"""
Calculate angle of incidence
:param surface_tilt:
:param surface_azimuth:
:param solar_zenith:
:param solar_azimuth:
:return: angle of incidence [deg]
"""
return pvlib.irradiance.aoi(surface_tilt, surface_azi... | python | def f_aoi(surface_tilt, surface_azimuth, solar_zenith, solar_azimuth):
"""
Calculate angle of incidence
:param surface_tilt:
:param surface_azimuth:
:param solar_zenith:
:param solar_azimuth:
:return: angle of incidence [deg]
"""
return pvlib.irradiance.aoi(surface_tilt, surface_azi... | [
"def",
"f_aoi",
"(",
"surface_tilt",
",",
"surface_azimuth",
",",
"solar_zenith",
",",
"solar_azimuth",
")",
":",
"return",
"pvlib",
".",
"irradiance",
".",
"aoi",
"(",
"surface_tilt",
",",
"surface_azimuth",
",",
"solar_zenith",
",",
"solar_azimuth",
")"
] | Calculate angle of incidence
:param surface_tilt:
:param surface_azimuth:
:param solar_zenith:
:param solar_azimuth:
:return: angle of incidence [deg] | [
"Calculate",
"angle",
"of",
"incidence"
] | train | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/examples/PVPower/pvpower/formulas/performance.py#L65-L76 |
volafiled/python-volapi | setup.py | find_version | def find_version(filename):
"""
Search for assignment of __version__ string in given file and
return what it is assigned to.
"""
with open(filename, "r") as filep:
version_file = filep.read()
version_match = re.search(
r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, ... | python | def find_version(filename):
"""
Search for assignment of __version__ string in given file and
return what it is assigned to.
"""
with open(filename, "r") as filep:
version_file = filep.read()
version_match = re.search(
r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, ... | [
"def",
"find_version",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"\"r\"",
")",
"as",
"filep",
":",
"version_file",
"=",
"filep",
".",
"read",
"(",
")",
"version_match",
"=",
"re",
".",
"search",
"(",
"r\"^__version__ = ['\\\"]([^'\\\"]... | Search for assignment of __version__ string in given file and
return what it is assigned to. | [
"Search",
"for",
"assignment",
"of",
"__version__",
"string",
"in",
"given",
"file",
"and",
"return",
"what",
"it",
"is",
"assigned",
"to",
"."
] | train | https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/setup.py#L22-L34 |
guaix-ucm/pyemir | emirdrp/tools/save_ndarray_to_fits.py | save_ndarray_to_fits | def save_ndarray_to_fits(array=None, file_name=None,
main_header=None,
cast_to_float=True,
crpix1=None, crval1=None, cdelt1=None,
overwrite=True):
"""Save numpy array(s) into a FITS file with the provided filename.
... | python | def save_ndarray_to_fits(array=None, file_name=None,
main_header=None,
cast_to_float=True,
crpix1=None, crval1=None, cdelt1=None,
overwrite=True):
"""Save numpy array(s) into a FITS file with the provided filename.
... | [
"def",
"save_ndarray_to_fits",
"(",
"array",
"=",
"None",
",",
"file_name",
"=",
"None",
",",
"main_header",
"=",
"None",
",",
"cast_to_float",
"=",
"True",
",",
"crpix1",
"=",
"None",
",",
"crval1",
"=",
"None",
",",
"cdelt1",
"=",
"None",
",",
"overwri... | Save numpy array(s) into a FITS file with the provided filename.
Parameters
----------
array : numpy array or list of numpy arrays
Array(s) to be exported as the FITS file. If the input is
a list, a multi-extension FITS file is generated assuming
that the list contains a list of arr... | [
"Save",
"numpy",
"array",
"(",
"s",
")",
"into",
"a",
"FITS",
"file",
"with",
"the",
"provided",
"filename",
"."
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/tools/save_ndarray_to_fits.py#L27-L145 |
guaix-ucm/pyemir | emirdrp/processing/bardetect.py | find_position | def find_position(edges, prow, bstart, bend, total=5):
"""Find a EMIR CSU bar position in a edge image.
Parameters
==========
edges; ndarray,
a 2d image with 1 where is a border, 0 otherwise
prow: int,
reference 'row' of the bars
bstart: int,
minimum 'x' position of a ba... | python | def find_position(edges, prow, bstart, bend, total=5):
"""Find a EMIR CSU bar position in a edge image.
Parameters
==========
edges; ndarray,
a 2d image with 1 where is a border, 0 otherwise
prow: int,
reference 'row' of the bars
bstart: int,
minimum 'x' position of a ba... | [
"def",
"find_position",
"(",
"edges",
",",
"prow",
",",
"bstart",
",",
"bend",
",",
"total",
"=",
"5",
")",
":",
"nt",
"=",
"total",
"//",
"2",
"# This bar is too near the border",
"if",
"prow",
"-",
"nt",
"<",
"0",
"or",
"prow",
"+",
"nt",
">=",
"ed... | Find a EMIR CSU bar position in a edge image.
Parameters
==========
edges; ndarray,
a 2d image with 1 where is a border, 0 otherwise
prow: int,
reference 'row' of the bars
bstart: int,
minimum 'x' position of a bar (0-based)
bend: int
maximum 'x' position of a ba... | [
"Find",
"a",
"EMIR",
"CSU",
"bar",
"position",
"in",
"a",
"edge",
"image",
"."
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/processing/bardetect.py#L38-L77 |
guaix-ucm/pyemir | emirdrp/processing/bardetect.py | calc_fwhm | def calc_fwhm(img, region, fexpand=3, axis=0):
"""Compute the FWHM in the direction given by axis"""
# We compute know the FWHM of the slit
# Given the computed position of the slit
# Expand 'fexpand' pixels around
# and cut an slice in the median filtered image
xpregion = expand_region(region... | python | def calc_fwhm(img, region, fexpand=3, axis=0):
"""Compute the FWHM in the direction given by axis"""
# We compute know the FWHM of the slit
# Given the computed position of the slit
# Expand 'fexpand' pixels around
# and cut an slice in the median filtered image
xpregion = expand_region(region... | [
"def",
"calc_fwhm",
"(",
"img",
",",
"region",
",",
"fexpand",
"=",
"3",
",",
"axis",
"=",
"0",
")",
":",
"# We compute know the FWHM of the slit",
"# Given the computed position of the slit",
"# Expand 'fexpand' pixels around",
"# and cut an slice in the median filtered image"... | Compute the FWHM in the direction given by axis | [
"Compute",
"the",
"FWHM",
"in",
"the",
"direction",
"given",
"by",
"axis"
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/processing/bardetect.py#L80-L107 |
guaix-ucm/pyemir | emirdrp/processing/bardetect.py | simple_prot | def simple_prot(x, start):
"""Find the first peak to the right of start"""
# start must b >= 1
for i in range(start,len(x)-1):
a,b,c = x[i-1], x[i], x[i+1]
if b - a > 0 and b -c >= 0:
return i
else:
return None | python | def simple_prot(x, start):
"""Find the first peak to the right of start"""
# start must b >= 1
for i in range(start,len(x)-1):
a,b,c = x[i-1], x[i], x[i+1]
if b - a > 0 and b -c >= 0:
return i
else:
return None | [
"def",
"simple_prot",
"(",
"x",
",",
"start",
")",
":",
"# start must b >= 1",
"for",
"i",
"in",
"range",
"(",
"start",
",",
"len",
"(",
"x",
")",
"-",
"1",
")",
":",
"a",
",",
"b",
",",
"c",
"=",
"x",
"[",
"i",
"-",
"1",
"]",
",",
"x",
"["... | Find the first peak to the right of start | [
"Find",
"the",
"first",
"peak",
"to",
"the",
"right",
"of",
"start"
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/processing/bardetect.py#L110-L120 |
guaix-ucm/pyemir | emirdrp/processing/bardetect.py | position_half_h | def position_half_h(pslit, cpix, backw=4):
"""Find the position where the value is half of the peak"""
# Find the first peak to the right of cpix
next_peak = simple_prot(pslit, cpix)
if next_peak is None:
raise ValueError
dis_peak = next_peak - cpix
wpos2 = cpix - dis_peak
wpos1 ... | python | def position_half_h(pslit, cpix, backw=4):
"""Find the position where the value is half of the peak"""
# Find the first peak to the right of cpix
next_peak = simple_prot(pslit, cpix)
if next_peak is None:
raise ValueError
dis_peak = next_peak - cpix
wpos2 = cpix - dis_peak
wpos1 ... | [
"def",
"position_half_h",
"(",
"pslit",
",",
"cpix",
",",
"backw",
"=",
"4",
")",
":",
"# Find the first peak to the right of cpix",
"next_peak",
"=",
"simple_prot",
"(",
"pslit",
",",
"cpix",
")",
"if",
"next_peak",
"is",
"None",
":",
"raise",
"ValueError",
"... | Find the position where the value is half of the peak | [
"Find",
"the",
"position",
"where",
"the",
"value",
"is",
"half",
"of",
"the",
"peak"
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/processing/bardetect.py#L123-L155 |
guaix-ucm/pyemir | emirdrp/processing/bardetect.py | locate_bar_l | def locate_bar_l(icut, epos):
"""Fine position of the left CSU bar"""
def swap_coor(x):
return x
def swap_line(tab):
return tab
return _locate_bar_gen(icut, epos,
transform1=swap_coor,
transform2=swap_line
... | python | def locate_bar_l(icut, epos):
"""Fine position of the left CSU bar"""
def swap_coor(x):
return x
def swap_line(tab):
return tab
return _locate_bar_gen(icut, epos,
transform1=swap_coor,
transform2=swap_line
... | [
"def",
"locate_bar_l",
"(",
"icut",
",",
"epos",
")",
":",
"def",
"swap_coor",
"(",
"x",
")",
":",
"return",
"x",
"def",
"swap_line",
"(",
"tab",
")",
":",
"return",
"tab",
"return",
"_locate_bar_gen",
"(",
"icut",
",",
"epos",
",",
"transform1",
"=",
... | Fine position of the left CSU bar | [
"Fine",
"position",
"of",
"the",
"left",
"CSU",
"bar"
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/processing/bardetect.py#L158-L169 |
guaix-ucm/pyemir | emirdrp/processing/bardetect.py | locate_bar_r | def locate_bar_r(icut, epos):
"""Fine position of the right CSU bar"""
sm = len(icut)
def swap_coor(x):
return sm - 1 - x
def swap_line(tab):
return tab[::-1]
return _locate_bar_gen(icut, epos, transform1=swap_coor,
transform2=swap_line) | python | def locate_bar_r(icut, epos):
"""Fine position of the right CSU bar"""
sm = len(icut)
def swap_coor(x):
return sm - 1 - x
def swap_line(tab):
return tab[::-1]
return _locate_bar_gen(icut, epos, transform1=swap_coor,
transform2=swap_line) | [
"def",
"locate_bar_r",
"(",
"icut",
",",
"epos",
")",
":",
"sm",
"=",
"len",
"(",
"icut",
")",
"def",
"swap_coor",
"(",
"x",
")",
":",
"return",
"sm",
"-",
"1",
"-",
"x",
"def",
"swap_line",
"(",
"tab",
")",
":",
"return",
"tab",
"[",
":",
":",... | Fine position of the right CSU bar | [
"Fine",
"position",
"of",
"the",
"right",
"CSU",
"bar"
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/processing/bardetect.py#L172-L183 |
guaix-ucm/pyemir | emirdrp/processing/bardetect.py | _locate_bar_gen | def _locate_bar_gen(icut, epos, transform1, transform2):
"""Generic function for the fine position of the CSU"""
epos_pix = coor_to_pix_1d(epos)
# transform ->
epos_pix_s = transform1(epos_pix)
icut2 = transform2(icut)
#
try:
res = position_half_h(icut2, epos_pix_s)
xint_... | python | def _locate_bar_gen(icut, epos, transform1, transform2):
"""Generic function for the fine position of the CSU"""
epos_pix = coor_to_pix_1d(epos)
# transform ->
epos_pix_s = transform1(epos_pix)
icut2 = transform2(icut)
#
try:
res = position_half_h(icut2, epos_pix_s)
xint_... | [
"def",
"_locate_bar_gen",
"(",
"icut",
",",
"epos",
",",
"transform1",
",",
"transform2",
")",
":",
"epos_pix",
"=",
"coor_to_pix_1d",
"(",
"epos",
")",
"# transform ->",
"epos_pix_s",
"=",
"transform1",
"(",
"epos_pix",
")",
"icut2",
"=",
"transform2",
"(",
... | Generic function for the fine position of the CSU | [
"Generic",
"function",
"for",
"the",
"fine",
"position",
"of",
"the",
"CSU"
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/processing/bardetect.py#L186-L211 |
guaix-ucm/pyemir | emirdrp/processing/bardetect.py | overlap | def overlap(intv1, intv2):
"""Overlaping of two intervals"""
return max(0, min(intv1[1], intv2[1]) - max(intv1[0], intv2[0])) | python | def overlap(intv1, intv2):
"""Overlaping of two intervals"""
return max(0, min(intv1[1], intv2[1]) - max(intv1[0], intv2[0])) | [
"def",
"overlap",
"(",
"intv1",
",",
"intv2",
")",
":",
"return",
"max",
"(",
"0",
",",
"min",
"(",
"intv1",
"[",
"1",
"]",
",",
"intv2",
"[",
"1",
"]",
")",
"-",
"max",
"(",
"intv1",
"[",
"0",
"]",
",",
"intv2",
"[",
"0",
"]",
")",
")"
] | Overlaping of two intervals | [
"Overlaping",
"of",
"two",
"intervals"
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/processing/bardetect.py#L430-L432 |
guaix-ucm/pyemir | emirdrp/tools/fit_boundaries.py | integrity_check | def integrity_check(bounddict, max_dtu_offset):
"""Integrity check of 'bounddict' content.
Parameters
----------
bounddict : JSON structure
Structure employed to store bounddict information.
max_dtu_offset : float
Maximum allowed difference in DTU location (mm) for each
para... | python | def integrity_check(bounddict, max_dtu_offset):
"""Integrity check of 'bounddict' content.
Parameters
----------
bounddict : JSON structure
Structure employed to store bounddict information.
max_dtu_offset : float
Maximum allowed difference in DTU location (mm) for each
para... | [
"def",
"integrity_check",
"(",
"bounddict",
",",
"max_dtu_offset",
")",
":",
"if",
"'meta_info'",
"not",
"in",
"bounddict",
".",
"keys",
"(",
")",
":",
"raise",
"ValueError",
"(",
"'\"meta_info\" not found in JSON file'",
")",
"if",
"'description'",
"not",
"in",
... | Integrity check of 'bounddict' content.
Parameters
----------
bounddict : JSON structure
Structure employed to store bounddict information.
max_dtu_offset : float
Maximum allowed difference in DTU location (mm) for each
parameter | [
"Integrity",
"check",
"of",
"bounddict",
"content",
"."
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/tools/fit_boundaries.py#L63-L197 |
guaix-ucm/pyemir | emirdrp/tools/fit_boundaries.py | exvp_scalar | def exvp_scalar(x, y, x0, y0, c2, c4, theta0, ff):
"""Convert virtual pixel to real pixel.
Parameters
----------
x : array-like of floats
X coordinate (pixel).
y : array-like of floats
Y coordinate (pixel).
x0 : float
X coordinate of reference pixel, in units of 1E3.
... | python | def exvp_scalar(x, y, x0, y0, c2, c4, theta0, ff):
"""Convert virtual pixel to real pixel.
Parameters
----------
x : array-like of floats
X coordinate (pixel).
y : array-like of floats
Y coordinate (pixel).
x0 : float
X coordinate of reference pixel, in units of 1E3.
... | [
"def",
"exvp_scalar",
"(",
"x",
",",
"y",
",",
"x0",
",",
"y0",
",",
"c2",
",",
"c4",
",",
"theta0",
",",
"ff",
")",
":",
"# plate scale: 0.1944 arcsec/pixel",
"# conversion factor (in radian/pixel)",
"factor",
"=",
"0.1944",
"*",
"np",
".",
"pi",
"/",
"("... | Convert virtual pixel to real pixel.
Parameters
----------
x : array-like of floats
X coordinate (pixel).
y : array-like of floats
Y coordinate (pixel).
x0 : float
X coordinate of reference pixel, in units of 1E3.
y0 : float
Y coordinate of reference pixel, in un... | [
"Convert",
"virtual",
"pixel",
"to",
"real",
"pixel",
"."
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/tools/fit_boundaries.py#L200-L253 |
guaix-ucm/pyemir | emirdrp/tools/fit_boundaries.py | exvp | def exvp(x, y, x0, y0, c2, c4, theta0, ff):
"""Convert virtual pixel(s) to real pixel(s).
This function makes use of exvp_scalar(), which performs the
conversion for a single point (x, y), over an array of X and Y
values.
Parameters
----------
x : array-like
X coordinate (pixel).
... | python | def exvp(x, y, x0, y0, c2, c4, theta0, ff):
"""Convert virtual pixel(s) to real pixel(s).
This function makes use of exvp_scalar(), which performs the
conversion for a single point (x, y), over an array of X and Y
values.
Parameters
----------
x : array-like
X coordinate (pixel).
... | [
"def",
"exvp",
"(",
"x",
",",
"y",
",",
"x0",
",",
"y0",
",",
"c2",
",",
"c4",
",",
"theta0",
",",
"ff",
")",
":",
"if",
"all",
"(",
"[",
"np",
".",
"isscalar",
"(",
"x",
")",
",",
"np",
".",
"isscalar",
"(",
"y",
")",
"]",
")",
":",
"x... | Convert virtual pixel(s) to real pixel(s).
This function makes use of exvp_scalar(), which performs the
conversion for a single point (x, y), over an array of X and Y
values.
Parameters
----------
x : array-like
X coordinate (pixel).
y : array-like
Y coordinate (pixel).
... | [
"Convert",
"virtual",
"pixel",
"(",
"s",
")",
"to",
"real",
"pixel",
"(",
"s",
")",
"."
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/tools/fit_boundaries.py#L256-L305 |
guaix-ucm/pyemir | emirdrp/tools/fit_boundaries.py | return_params | def return_params(islitlet, csu_bar_slit_center, params, parmodel):
"""Return individual model parameters from object of type Parameters.
Parameters
----------
islitlet : int
Number of slitlet.
csu_bar_slit_center : float
CSU bar slit center, in mm.
params : :class:`~lmfit.param... | python | def return_params(islitlet, csu_bar_slit_center, params, parmodel):
"""Return individual model parameters from object of type Parameters.
Parameters
----------
islitlet : int
Number of slitlet.
csu_bar_slit_center : float
CSU bar slit center, in mm.
params : :class:`~lmfit.param... | [
"def",
"return_params",
"(",
"islitlet",
",",
"csu_bar_slit_center",
",",
"params",
",",
"parmodel",
")",
":",
"if",
"parmodel",
"==",
"\"longslit\"",
":",
"# set each variable in EXPECTED_PARAMETER_LIST to the value",
"# transferred through 'params'",
"c2",
"=",
"params",
... | Return individual model parameters from object of type Parameters.
Parameters
----------
islitlet : int
Number of slitlet.
csu_bar_slit_center : float
CSU bar slit center, in mm.
params : :class:`~lmfit.parameter.Parameters`
Parameters to be employed in the prediction of the... | [
"Return",
"individual",
"model",
"parameters",
"from",
"object",
"of",
"type",
"Parameters",
"."
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/tools/fit_boundaries.py#L308-L438 |
guaix-ucm/pyemir | emirdrp/tools/fit_boundaries.py | expected_distorted_boundaries | def expected_distorted_boundaries(islitlet, csu_bar_slit_center,
borderlist, params, parmodel,
numpts, deg, debugplot=0):
"""Return expected SpectrumTrail instances associated to a given slitlet.
Several SpectrumTrail objects can be computed f... | python | def expected_distorted_boundaries(islitlet, csu_bar_slit_center,
borderlist, params, parmodel,
numpts, deg, debugplot=0):
"""Return expected SpectrumTrail instances associated to a given slitlet.
Several SpectrumTrail objects can be computed f... | [
"def",
"expected_distorted_boundaries",
"(",
"islitlet",
",",
"csu_bar_slit_center",
",",
"borderlist",
",",
"params",
",",
"parmodel",
",",
"numpts",
",",
"deg",
",",
"debugplot",
"=",
"0",
")",
":",
"c2",
",",
"c4",
",",
"ff",
",",
"slit_gap",
",",
"slit... | Return expected SpectrumTrail instances associated to a given slitlet.
Several SpectrumTrail objects can be computed for the considered
slitlet. The parameter borderlist is a list of floats, ranging
from 0 to 1, indicating the spatial location of the spectrum trail
within the slitlet: 0 means the lower... | [
"Return",
"expected",
"SpectrumTrail",
"instances",
"associated",
"to",
"a",
"given",
"slitlet",
"."
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/tools/fit_boundaries.py#L441-L509 |
guaix-ucm/pyemir | emirdrp/tools/fit_boundaries.py | fun_residuals | def fun_residuals(params, parmodel, bounddict,
shrinking_factor, numresolution,
islitmin, islitmax, debugplot):
"""Function to be minimised.
Parameters
----------
params : :class:`~lmfit.parameter.Parameters`
Parameters to be employed in the prediction of the... | python | def fun_residuals(params, parmodel, bounddict,
shrinking_factor, numresolution,
islitmin, islitmax, debugplot):
"""Function to be minimised.
Parameters
----------
params : :class:`~lmfit.parameter.Parameters`
Parameters to be employed in the prediction of the... | [
"def",
"fun_residuals",
"(",
"params",
",",
"parmodel",
",",
"bounddict",
",",
"shrinking_factor",
",",
"numresolution",
",",
"islitmin",
",",
"islitmax",
",",
"debugplot",
")",
":",
"global",
"FUNCTION_EVALUATIONS",
"global_residual",
"=",
"0.0",
"nsummed",
"=",
... | Function to be minimised.
Parameters
----------
params : :class:`~lmfit.parameter.Parameters`
Parameters to be employed in the prediction of the distorted
boundaries.
parmodel : str
Model to be assumed. Allowed values are 'longslit' and
'multislit'.
bounddict : JSON ... | [
"Function",
"to",
"be",
"minimised",
"."
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/tools/fit_boundaries.py#L578-L677 |
guaix-ucm/pyemir | emirdrp/tools/fit_boundaries.py | overplot_boundaries_from_bounddict | def overplot_boundaries_from_bounddict(ax, bounddict, micolors, linetype='-'):
"""Overplot boundaries on current plot.
Parameters
----------
ax : matplotlib axes
Current plot axes.
bounddict : JSON structure
Structure employed to store bounddict information.
micolors : list of c... | python | def overplot_boundaries_from_bounddict(ax, bounddict, micolors, linetype='-'):
"""Overplot boundaries on current plot.
Parameters
----------
ax : matplotlib axes
Current plot axes.
bounddict : JSON structure
Structure employed to store bounddict information.
micolors : list of c... | [
"def",
"overplot_boundaries_from_bounddict",
"(",
"ax",
",",
"bounddict",
",",
"micolors",
",",
"linetype",
"=",
"'-'",
")",
":",
"for",
"islitlet",
"in",
"range",
"(",
"1",
",",
"EMIR_NBARS",
"+",
"1",
")",
":",
"tmpcolor",
"=",
"micolors",
"[",
"islitlet... | Overplot boundaries on current plot.
Parameters
----------
ax : matplotlib axes
Current plot axes.
bounddict : JSON structure
Structure employed to store bounddict information.
micolors : list of char
List with two characters corresponding to alternating colors
for o... | [
"Overplot",
"boundaries",
"on",
"current",
"plot",
"."
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/tools/fit_boundaries.py#L680-L716 |
guaix-ucm/pyemir | emirdrp/tools/fit_boundaries.py | overplot_boundaries_from_params | def overplot_boundaries_from_params(ax, params, parmodel,
list_islitlet,
list_csu_bar_slit_center,
micolors=('m', 'c'), linetype='--',
labels=True, alpha_fill=None,
... | python | def overplot_boundaries_from_params(ax, params, parmodel,
list_islitlet,
list_csu_bar_slit_center,
micolors=('m', 'c'), linetype='--',
labels=True, alpha_fill=None,
... | [
"def",
"overplot_boundaries_from_params",
"(",
"ax",
",",
"params",
",",
"parmodel",
",",
"list_islitlet",
",",
"list_csu_bar_slit_center",
",",
"micolors",
"=",
"(",
"'m'",
",",
"'c'",
")",
",",
"linetype",
"=",
"'--'",
",",
"labels",
"=",
"True",
",",
"alp... | Overplot boundaries computed from fitted parameters.
Parameters
----------
ax : matplotlib axes
Current plot axes.
params : :class:`~lmfit.parameter.Parameters`
Parameters to be employed in the prediction of the distorted
boundaries.
parmodel : str
Model to be assume... | [
"Overplot",
"boundaries",
"computed",
"from",
"fitted",
"parameters",
"."
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/tools/fit_boundaries.py#L719-L811 |
guaix-ucm/pyemir | emirdrp/tools/fit_boundaries.py | save_boundaries_from_bounddict_ds9 | def save_boundaries_from_bounddict_ds9(bounddict, ds9_filename, numpix=100):
"""Export to ds9 region file the boundaries in bounddict.
Parameters
----------
bounddict : JSON structure
Structure employed to store bounddict information.
ds9_filename : str
Output file name for the ds9 ... | python | def save_boundaries_from_bounddict_ds9(bounddict, ds9_filename, numpix=100):
"""Export to ds9 region file the boundaries in bounddict.
Parameters
----------
bounddict : JSON structure
Structure employed to store bounddict information.
ds9_filename : str
Output file name for the ds9 ... | [
"def",
"save_boundaries_from_bounddict_ds9",
"(",
"bounddict",
",",
"ds9_filename",
",",
"numpix",
"=",
"100",
")",
":",
"ds9_file",
"=",
"open",
"(",
"ds9_filename",
",",
"'w'",
")",
"ds9_file",
".",
"write",
"(",
"'# Region file format: DS9 version 4.1\\n'",
")",
... | Export to ds9 region file the boundaries in bounddict.
Parameters
----------
bounddict : JSON structure
Structure employed to store bounddict information.
ds9_filename : str
Output file name for the ds9 region file.
numpix : int
Number of points in which the X-range interval... | [
"Export",
"to",
"ds9",
"region",
"file",
"the",
"boundaries",
"in",
"bounddict",
"."
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/tools/fit_boundaries.py#L907-L992 |
guaix-ucm/pyemir | emirdrp/tools/fit_boundaries.py | save_boundaries_from_params_ds9 | def save_boundaries_from_params_ds9(params, parmodel,
list_islitlet,
list_csu_bar_slit_center,
uuid, grism, spfilter,
ds9_filename, numpix=100,
... | python | def save_boundaries_from_params_ds9(params, parmodel,
list_islitlet,
list_csu_bar_slit_center,
uuid, grism, spfilter,
ds9_filename, numpix=100,
... | [
"def",
"save_boundaries_from_params_ds9",
"(",
"params",
",",
"parmodel",
",",
"list_islitlet",
",",
"list_csu_bar_slit_center",
",",
"uuid",
",",
"grism",
",",
"spfilter",
",",
"ds9_filename",
",",
"numpix",
"=",
"100",
",",
"global_offset_x_pix",
"=",
"0",
",",
... | Export to ds9 region file the boundaries parametrised with params.
Parameters
----------
params : :class:`~lmfit.parameter.Parameters`
Parameters to be employed in the prediction of the distorted
boundaries.
parmodel : str
Model to be assumed. Allowed values are 'longslit' and
... | [
"Export",
"to",
"ds9",
"region",
"file",
"the",
"boundaries",
"parametrised",
"with",
"params",
"."
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/tools/fit_boundaries.py#L995-L1114 |
guaix-ucm/pyemir | emirdrp/tools/fit_boundaries.py | bound_params_from_dict | def bound_params_from_dict(bound_param_dict):
"""Define `~lmfit.parameter.Parameters` object from dictionary.
Parameters
----------
bound_param_dict : dictionary
Dictionary containing the JSON contents of a boundary
parameter file.
Returns
-------
params : :class:`~lmfit.pa... | python | def bound_params_from_dict(bound_param_dict):
"""Define `~lmfit.parameter.Parameters` object from dictionary.
Parameters
----------
bound_param_dict : dictionary
Dictionary containing the JSON contents of a boundary
parameter file.
Returns
-------
params : :class:`~lmfit.pa... | [
"def",
"bound_params_from_dict",
"(",
"bound_param_dict",
")",
":",
"params",
"=",
"Parameters",
"(",
")",
"for",
"mainpar",
"in",
"EXPECTED_PARAMETER_LIST",
":",
"if",
"mainpar",
"not",
"in",
"bound_param_dict",
"[",
"'contents'",
"]",
".",
"keys",
"(",
")",
... | Define `~lmfit.parameter.Parameters` object from dictionary.
Parameters
----------
bound_param_dict : dictionary
Dictionary containing the JSON contents of a boundary
parameter file.
Returns
-------
params : :class:`~lmfit.parameter.Parameters`
Parameters object. | [
"Define",
"~lmfit",
".",
"parameter",
".",
"Parameters",
"object",
"from",
"dictionary",
"."
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/tools/fit_boundaries.py#L1237-L1273 |
guaix-ucm/pyemir | emirdrp/recipes/image/stare.py | StareImageRecipe2.set_base_headers | def set_base_headers(self, hdr):
"""Set metadata in FITS headers."""
hdr = super(StareImageRecipe2, self).set_base_headers(hdr)
# Set EXP to 0
hdr['EXP'] = 0
return hdr | python | def set_base_headers(self, hdr):
"""Set metadata in FITS headers."""
hdr = super(StareImageRecipe2, self).set_base_headers(hdr)
# Set EXP to 0
hdr['EXP'] = 0
return hdr | [
"def",
"set_base_headers",
"(",
"self",
",",
"hdr",
")",
":",
"hdr",
"=",
"super",
"(",
"StareImageRecipe2",
",",
"self",
")",
".",
"set_base_headers",
"(",
"hdr",
")",
"# Set EXP to 0",
"hdr",
"[",
"'EXP'",
"]",
"=",
"0",
"return",
"hdr"
] | Set metadata in FITS headers. | [
"Set",
"metadata",
"in",
"FITS",
"headers",
"."
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/recipes/image/stare.py#L82-L87 |
guaix-ucm/pyemir | emirdrp/recipes/image/stare.py | StareImageBaseRecipe.set_base_headers | def set_base_headers(self, hdr):
"""Set metadata in FITS headers."""
hdr = super(StareImageBaseRecipe, self).set_base_headers(hdr)
# Update EXP to 0
hdr['EXP'] = 0
return hdr | python | def set_base_headers(self, hdr):
"""Set metadata in FITS headers."""
hdr = super(StareImageBaseRecipe, self).set_base_headers(hdr)
# Update EXP to 0
hdr['EXP'] = 0
return hdr | [
"def",
"set_base_headers",
"(",
"self",
",",
"hdr",
")",
":",
"hdr",
"=",
"super",
"(",
"StareImageBaseRecipe",
",",
"self",
")",
".",
"set_base_headers",
"(",
"hdr",
")",
"# Update EXP to 0",
"hdr",
"[",
"'EXP'",
"]",
"=",
"0",
"return",
"hdr"
] | Set metadata in FITS headers. | [
"Set",
"metadata",
"in",
"FITS",
"headers",
"."
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/recipes/image/stare.py#L135-L140 |
guaix-ucm/pyemir | emirdrp/processing/wavecal/apply_rectwv_coeff.py | apply_rectwv_coeff | def apply_rectwv_coeff(reduced_image,
rectwv_coeff,
args_resampling=2,
args_ignore_dtu_configuration=True,
debugplot=0):
"""Compute rectification and wavelength calibration coefficients.
Parameters
----------
re... | python | def apply_rectwv_coeff(reduced_image,
rectwv_coeff,
args_resampling=2,
args_ignore_dtu_configuration=True,
debugplot=0):
"""Compute rectification and wavelength calibration coefficients.
Parameters
----------
re... | [
"def",
"apply_rectwv_coeff",
"(",
"reduced_image",
",",
"rectwv_coeff",
",",
"args_resampling",
"=",
"2",
",",
"args_ignore_dtu_configuration",
"=",
"True",
",",
"debugplot",
"=",
"0",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
... | Compute rectification and wavelength calibration coefficients.
Parameters
----------
reduced_image : HDUList object
Image with preliminary basic reduction: bpm, bias, dark and
flatfield.
rectwv_coeff : RectWaveCoeff instance
Rectification and wavelength calibration coefficients ... | [
"Compute",
"rectification",
"and",
"wavelength",
"calibration",
"coefficients",
"."
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/processing/wavecal/apply_rectwv_coeff.py#L48-L273 |
Jaymon/prom | prom/interface/base.py | Connection.transaction_start | def transaction_start(self, name):
"""
start a transaction
this will increment transaction semaphore and pass it to _transaction_start()
"""
if not name:
raise ValueError("Transaction name cannot be empty")
#uid = id(self)
self.transaction_count ... | python | def transaction_start(self, name):
"""
start a transaction
this will increment transaction semaphore and pass it to _transaction_start()
"""
if not name:
raise ValueError("Transaction name cannot be empty")
#uid = id(self)
self.transaction_count ... | [
"def",
"transaction_start",
"(",
"self",
",",
"name",
")",
":",
"if",
"not",
"name",
":",
"raise",
"ValueError",
"(",
"\"Transaction name cannot be empty\"",
")",
"#uid = id(self)",
"self",
".",
"transaction_count",
"+=",
"1",
"logger",
".",
"debug",
"(",
"\"{}.... | start a transaction
this will increment transaction semaphore and pass it to _transaction_start() | [
"start",
"a",
"transaction"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L43-L60 |
Jaymon/prom | prom/interface/base.py | Connection.transaction_stop | def transaction_stop(self):
"""stop/commit a transaction if ready"""
if self.transaction_count > 0:
logger.debug("{}. Stop transaction".format(self.transaction_count))
if self.transaction_count == 1:
self._transaction_stop()
self.transaction_count -= ... | python | def transaction_stop(self):
"""stop/commit a transaction if ready"""
if self.transaction_count > 0:
logger.debug("{}. Stop transaction".format(self.transaction_count))
if self.transaction_count == 1:
self._transaction_stop()
self.transaction_count -= ... | [
"def",
"transaction_stop",
"(",
"self",
")",
":",
"if",
"self",
".",
"transaction_count",
">",
"0",
":",
"logger",
".",
"debug",
"(",
"\"{}. Stop transaction\"",
".",
"format",
"(",
"self",
".",
"transaction_count",
")",
")",
"if",
"self",
".",
"transaction_... | stop/commit a transaction if ready | [
"stop",
"/",
"commit",
"a",
"transaction",
"if",
"ready"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L66-L75 |
Jaymon/prom | prom/interface/base.py | Connection.transaction_fail | def transaction_fail(self, name):
"""
rollback a transaction if currently in one
e -- Exception() -- if passed in, bubble up the exception by re-raising it
"""
if not name:
raise ValueError("Transaction name cannot be empty")
if self.transaction_count > 0:
... | python | def transaction_fail(self, name):
"""
rollback a transaction if currently in one
e -- Exception() -- if passed in, bubble up the exception by re-raising it
"""
if not name:
raise ValueError("Transaction name cannot be empty")
if self.transaction_count > 0:
... | [
"def",
"transaction_fail",
"(",
"self",
",",
"name",
")",
":",
"if",
"not",
"name",
":",
"raise",
"ValueError",
"(",
"\"Transaction name cannot be empty\"",
")",
"if",
"self",
".",
"transaction_count",
">",
"0",
":",
"logger",
".",
"debug",
"(",
"\"{}. Failing... | rollback a transaction if currently in one
e -- Exception() -- if passed in, bubble up the exception by re-raising it | [
"rollback",
"a",
"transaction",
"if",
"currently",
"in",
"one"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L79-L95 |
Jaymon/prom | prom/interface/base.py | Interface.connect | def connect(self, connection_config=None, *args, **kwargs):
"""
connect to the interface
this will set the raw db connection to self.connection
*args -- anything you want that will help the db connect
**kwargs -- anything you want that the backend db connection will need to act... | python | def connect(self, connection_config=None, *args, **kwargs):
"""
connect to the interface
this will set the raw db connection to self.connection
*args -- anything you want that will help the db connect
**kwargs -- anything you want that the backend db connection will need to act... | [
"def",
"connect",
"(",
"self",
",",
"connection_config",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"connected",
":",
"return",
"self",
".",
"connected",
"if",
"connection_config",
":",
"self",
".",
"connection_c... | connect to the interface
this will set the raw db connection to self.connection
*args -- anything you want that will help the db connect
**kwargs -- anything you want that the backend db connection will need to actually connect | [
"connect",
"to",
"the",
"interface"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L153-L175 |
Jaymon/prom | prom/interface/base.py | Interface.close | def close(self):
"""close an open connection"""
if not self.connected: return True
self._close()
self.connected = False
self.log("Closed Connection {}", self.connection_config.interface_name)
return True | python | def close(self):
"""close an open connection"""
if not self.connected: return True
self._close()
self.connected = False
self.log("Closed Connection {}", self.connection_config.interface_name)
return True | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"connected",
":",
"return",
"True",
"self",
".",
"_close",
"(",
")",
"self",
".",
"connected",
"=",
"False",
"self",
".",
"log",
"(",
"\"Closed Connection {}\"",
",",
"self",
".",
"connec... | close an open connection | [
"close",
"an",
"open",
"connection"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L206-L213 |
Jaymon/prom | prom/interface/base.py | Interface.query | def query(self, query_str, *query_args, **query_options):
"""
run a raw query on the db
query_str -- string -- the query to run
*query_args -- if the query_str is a formatting string, pass the values in this
**query_options -- any query options can be passed in by using key=val ... | python | def query(self, query_str, *query_args, **query_options):
"""
run a raw query on the db
query_str -- string -- the query to run
*query_args -- if the query_str is a formatting string, pass the values in this
**query_options -- any query options can be passed in by using key=val ... | [
"def",
"query",
"(",
"self",
",",
"query_str",
",",
"*",
"query_args",
",",
"*",
"*",
"query_options",
")",
":",
"with",
"self",
".",
"connection",
"(",
"*",
"*",
"query_options",
")",
"as",
"connection",
":",
"query_options",
"[",
"'connection'",
"]",
"... | run a raw query on the db
query_str -- string -- the query to run
*query_args -- if the query_str is a formatting string, pass the values in this
**query_options -- any query options can be passed in by using key=val syntax | [
"run",
"a",
"raw",
"query",
"on",
"the",
"db"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L217-L227 |
Jaymon/prom | prom/interface/base.py | Interface.transaction | def transaction(self, connection=None, **kwargs):
"""
a simple context manager useful for when you want to wrap a bunch of db calls in a transaction
http://docs.python.org/2/library/contextlib.html
http://docs.python.org/release/2.5/whatsnew/pep-343.html
example --
w... | python | def transaction(self, connection=None, **kwargs):
"""
a simple context manager useful for when you want to wrap a bunch of db calls in a transaction
http://docs.python.org/2/library/contextlib.html
http://docs.python.org/release/2.5/whatsnew/pep-343.html
example --
w... | [
"def",
"transaction",
"(",
"self",
",",
"connection",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"self",
".",
"connection",
"(",
"connection",
")",
"as",
"connection",
":",
"name",
"=",
"connection",
".",
"transaction_name",
"(",
")",
"conne... | a simple context manager useful for when you want to wrap a bunch of db calls in a transaction
http://docs.python.org/2/library/contextlib.html
http://docs.python.org/release/2.5/whatsnew/pep-343.html
example --
with self.transaction()
# do a bunch of calls
... | [
"a",
"simple",
"context",
"manager",
"useful",
"for",
"when",
"you",
"want",
"to",
"wrap",
"a",
"bunch",
"of",
"db",
"calls",
"in",
"a",
"transaction",
"http",
":",
"//",
"docs",
".",
"python",
".",
"org",
"/",
"2",
"/",
"library",
"/",
"contextlib",
... | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L233-L253 |
Jaymon/prom | prom/interface/base.py | Interface.set_table | def set_table(self, schema, **kwargs):
"""
add the table to the db
schema -- Schema() -- contains all the information about the table
"""
with self.connection(**kwargs) as connection:
kwargs['connection'] = connection
if self.has_table(str(schema), **kwar... | python | def set_table(self, schema, **kwargs):
"""
add the table to the db
schema -- Schema() -- contains all the information about the table
"""
with self.connection(**kwargs) as connection:
kwargs['connection'] = connection
if self.has_table(str(schema), **kwar... | [
"def",
"set_table",
"(",
"self",
",",
"schema",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"self",
".",
"connection",
"(",
"*",
"*",
"kwargs",
")",
"as",
"connection",
":",
"kwargs",
"[",
"'connection'",
"]",
"=",
"connection",
"if",
"self",
".",
"ha... | add the table to the db
schema -- Schema() -- contains all the information about the table | [
"add",
"the",
"table",
"to",
"the",
"db"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L255-L282 |
Jaymon/prom | prom/interface/base.py | Interface.has_table | def has_table(self, table_name, **kwargs):
"""
check to see if a table is in the db
table_name -- string -- the table to check
return -- boolean -- True if the table exists, false otherwise
"""
with self.connection(kwargs.get('connection', None)) as connection:
... | python | def has_table(self, table_name, **kwargs):
"""
check to see if a table is in the db
table_name -- string -- the table to check
return -- boolean -- True if the table exists, false otherwise
"""
with self.connection(kwargs.get('connection', None)) as connection:
... | [
"def",
"has_table",
"(",
"self",
",",
"table_name",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"self",
".",
"connection",
"(",
"kwargs",
".",
"get",
"(",
"'connection'",
",",
"None",
")",
")",
"as",
"connection",
":",
"kwargs",
"[",
"'connection'",
"]"... | check to see if a table is in the db
table_name -- string -- the table to check
return -- boolean -- True if the table exists, false otherwise | [
"check",
"to",
"see",
"if",
"a",
"table",
"is",
"in",
"the",
"db"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L286-L296 |
Jaymon/prom | prom/interface/base.py | Interface.get_tables | def get_tables(self, table_name="", **kwargs):
"""
get all the tables of the currently connected db
table_name -- string -- if you would like to filter the tables list to only include matches with this name
return -- list -- a list of table names
"""
with self.connection... | python | def get_tables(self, table_name="", **kwargs):
"""
get all the tables of the currently connected db
table_name -- string -- if you would like to filter the tables list to only include matches with this name
return -- list -- a list of table names
"""
with self.connection... | [
"def",
"get_tables",
"(",
"self",
",",
"table_name",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"self",
".",
"connection",
"(",
"*",
"*",
"kwargs",
")",
"as",
"connection",
":",
"kwargs",
"[",
"'connection'",
"]",
"=",
"connection",
"retur... | get all the tables of the currently connected db
table_name -- string -- if you would like to filter the tables list to only include matches with this name
return -- list -- a list of table names | [
"get",
"all",
"the",
"tables",
"of",
"the",
"currently",
"connected",
"db"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L298-L307 |
Jaymon/prom | prom/interface/base.py | Interface.delete_table | def delete_table(self, schema, **kwargs):
"""
remove a table matching schema from the db
schema -- Schema()
"""
with self.connection(**kwargs) as connection:
kwargs['connection'] = connection
if not self.has_table(str(schema), **kwargs): return True
... | python | def delete_table(self, schema, **kwargs):
"""
remove a table matching schema from the db
schema -- Schema()
"""
with self.connection(**kwargs) as connection:
kwargs['connection'] = connection
if not self.has_table(str(schema), **kwargs): return True
... | [
"def",
"delete_table",
"(",
"self",
",",
"schema",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"self",
".",
"connection",
"(",
"*",
"*",
"kwargs",
")",
"as",
"connection",
":",
"kwargs",
"[",
"'connection'",
"]",
"=",
"connection",
"if",
"not",
"self",
... | remove a table matching schema from the db
schema -- Schema() | [
"remove",
"a",
"table",
"matching",
"schema",
"from",
"the",
"db"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L311-L323 |
Jaymon/prom | prom/interface/base.py | Interface.delete_tables | def delete_tables(self, **kwargs):
"""
removes all the tables from the db
this is, obviously, very bad if you didn't mean to call this, because of that, you
have to pass in disable_protection=True, if it doesn't get that passed in, it won't
run this method
"""
if... | python | def delete_tables(self, **kwargs):
"""
removes all the tables from the db
this is, obviously, very bad if you didn't mean to call this, because of that, you
have to pass in disable_protection=True, if it doesn't get that passed in, it won't
run this method
"""
if... | [
"def",
"delete_tables",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"kwargs",
".",
"get",
"(",
"'disable_protection'",
",",
"False",
")",
":",
"raise",
"ValueError",
"(",
"'In order to delete all the tables, pass in disable_protection=True'",
")",
... | removes all the tables from the db
this is, obviously, very bad if you didn't mean to call this, because of that, you
have to pass in disable_protection=True, if it doesn't get that passed in, it won't
run this method | [
"removes",
"all",
"the",
"tables",
"from",
"the",
"db"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L327-L340 |
Jaymon/prom | prom/interface/base.py | Interface.get_indexes | def get_indexes(self, schema, **kwargs):
"""
get all the indexes
schema -- Schema()
return -- dict -- the indexes in {indexname: fields} format
"""
with self.connection(**kwargs) as connection:
kwargs['connection'] = connection
return self._get_i... | python | def get_indexes(self, schema, **kwargs):
"""
get all the indexes
schema -- Schema()
return -- dict -- the indexes in {indexname: fields} format
"""
with self.connection(**kwargs) as connection:
kwargs['connection'] = connection
return self._get_i... | [
"def",
"get_indexes",
"(",
"self",
",",
"schema",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"self",
".",
"connection",
"(",
"*",
"*",
"kwargs",
")",
"as",
"connection",
":",
"kwargs",
"[",
"'connection'",
"]",
"=",
"connection",
"return",
"self",
".",... | get all the indexes
schema -- Schema()
return -- dict -- the indexes in {indexname: fields} format | [
"get",
"all",
"the",
"indexes"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L351-L361 |
Jaymon/prom | prom/interface/base.py | Interface.set_index | def set_index(self, schema, name, fields, **index_options):
"""
add an index to the table
schema -- Schema()
name -- string -- the name of the index
fields -- array -- the fields the index should be on
**index_options -- dict -- any index options that might be useful to ... | python | def set_index(self, schema, name, fields, **index_options):
"""
add an index to the table
schema -- Schema()
name -- string -- the name of the index
fields -- array -- the fields the index should be on
**index_options -- dict -- any index options that might be useful to ... | [
"def",
"set_index",
"(",
"self",
",",
"schema",
",",
"name",
",",
"fields",
",",
"*",
"*",
"index_options",
")",
":",
"with",
"self",
".",
"transaction",
"(",
"*",
"*",
"index_options",
")",
"as",
"connection",
":",
"index_options",
"[",
"'connection'",
... | add an index to the table
schema -- Schema()
name -- string -- the name of the index
fields -- array -- the fields the index should be on
**index_options -- dict -- any index options that might be useful to create the index | [
"add",
"an",
"index",
"to",
"the",
"table"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L365-L378 |
Jaymon/prom | prom/interface/base.py | Interface.insert | def insert(self, schema, fields, **kwargs):
"""
Persist d into the db
schema -- Schema()
fields -- dict -- the values to persist
return -- int -- the primary key of the row just inserted
"""
r = 0
with self.connection(**kwargs) as connection:
... | python | def insert(self, schema, fields, **kwargs):
"""
Persist d into the db
schema -- Schema()
fields -- dict -- the values to persist
return -- int -- the primary key of the row just inserted
"""
r = 0
with self.connection(**kwargs) as connection:
... | [
"def",
"insert",
"(",
"self",
",",
"schema",
",",
"fields",
",",
"*",
"*",
"kwargs",
")",
":",
"r",
"=",
"0",
"with",
"self",
".",
"connection",
"(",
"*",
"*",
"kwargs",
")",
"as",
"connection",
":",
"kwargs",
"[",
"'connection'",
"]",
"=",
"connec... | Persist d into the db
schema -- Schema()
fields -- dict -- the values to persist
return -- int -- the primary key of the row just inserted | [
"Persist",
"d",
"into",
"the",
"db"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L384-L408 |
Jaymon/prom | prom/interface/base.py | Interface.update | def update(self, schema, fields, query, **kwargs):
"""
Persist the query.fields into the db that match query.fields_where
schema -- Schema()
fields -- dict -- the values to persist
query -- Query() -- will be used to create the where clause
return -- int -- how many row... | python | def update(self, schema, fields, query, **kwargs):
"""
Persist the query.fields into the db that match query.fields_where
schema -- Schema()
fields -- dict -- the values to persist
query -- Query() -- will be used to create the where clause
return -- int -- how many row... | [
"def",
"update",
"(",
"self",
",",
"schema",
",",
"fields",
",",
"query",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"self",
".",
"connection",
"(",
"*",
"*",
"kwargs",
")",
"as",
"connection",
":",
"kwargs",
"[",
"'connection'",
"]",
"=",
"connectio... | Persist the query.fields into the db that match query.fields_where
schema -- Schema()
fields -- dict -- the values to persist
query -- Query() -- will be used to create the where clause
return -- int -- how many rows where updated | [
"Persist",
"the",
"query",
".",
"fields",
"into",
"the",
"db",
"that",
"match",
"query",
".",
"fields_where"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L413-L436 |
Jaymon/prom | prom/interface/base.py | Interface._get_query | def _get_query(self, callback, schema, query=None, *args, **kwargs):
"""this is just a common wrapper around all the get queries since they are
all really similar in how they execute"""
if not query: query = Query()
ret = None
with self.connection(**kwargs) as connection:
... | python | def _get_query(self, callback, schema, query=None, *args, **kwargs):
"""this is just a common wrapper around all the get queries since they are
all really similar in how they execute"""
if not query: query = Query()
ret = None
with self.connection(**kwargs) as connection:
... | [
"def",
"_get_query",
"(",
"self",
",",
"callback",
",",
"schema",
",",
"query",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"query",
":",
"query",
"=",
"Query",
"(",
")",
"ret",
"=",
"None",
"with",
"self",
".",... | this is just a common wrapper around all the get queries since they are
all really similar in how they execute | [
"this",
"is",
"just",
"a",
"common",
"wrapper",
"around",
"all",
"the",
"get",
"queries",
"since",
"they",
"are",
"all",
"really",
"similar",
"in",
"how",
"they",
"execute"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L441-L468 |
Jaymon/prom | prom/interface/base.py | Interface.get_one | def get_one(self, schema, query=None, **kwargs):
"""
get one row from the db matching filters set in query
schema -- Schema()
query -- Query()
return -- dict -- the matching row
"""
ret = self._get_query(self._get_one, schema, query, **kwargs)
if not ret... | python | def get_one(self, schema, query=None, **kwargs):
"""
get one row from the db matching filters set in query
schema -- Schema()
query -- Query()
return -- dict -- the matching row
"""
ret = self._get_query(self._get_one, schema, query, **kwargs)
if not ret... | [
"def",
"get_one",
"(",
"self",
",",
"schema",
",",
"query",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"self",
".",
"_get_query",
"(",
"self",
".",
"_get_one",
",",
"schema",
",",
"query",
",",
"*",
"*",
"kwargs",
")",
"if",
"not... | get one row from the db matching filters set in query
schema -- Schema()
query -- Query()
return -- dict -- the matching row | [
"get",
"one",
"row",
"from",
"the",
"db",
"matching",
"filters",
"set",
"in",
"query"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L470-L481 |
Jaymon/prom | prom/interface/base.py | Interface.get | def get(self, schema, query=None, **kwargs):
"""
get matching rows from the db matching filters set in query
schema -- Schema()
query -- Query()
return -- list -- a list of matching dicts
"""
ret = self._get_query(self._get, schema, query, **kwargs)
if n... | python | def get(self, schema, query=None, **kwargs):
"""
get matching rows from the db matching filters set in query
schema -- Schema()
query -- Query()
return -- list -- a list of matching dicts
"""
ret = self._get_query(self._get, schema, query, **kwargs)
if n... | [
"def",
"get",
"(",
"self",
",",
"schema",
",",
"query",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"self",
".",
"_get_query",
"(",
"self",
".",
"_get",
",",
"schema",
",",
"query",
",",
"*",
"*",
"kwargs",
")",
"if",
"not",
"re... | get matching rows from the db matching filters set in query
schema -- Schema()
query -- Query()
return -- list -- a list of matching dicts | [
"get",
"matching",
"rows",
"from",
"the",
"db",
"matching",
"filters",
"set",
"in",
"query"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L485-L496 |
Jaymon/prom | prom/interface/base.py | Interface.log | def log(self, format_str, *format_args, **log_options):
"""
wrapper around the module's logger
format_str -- string -- the message to log
*format_args -- list -- if format_str is a string containing {}, then format_str.format(*format_args) is ran
**log_options --
le... | python | def log(self, format_str, *format_args, **log_options):
"""
wrapper around the module's logger
format_str -- string -- the message to log
*format_args -- list -- if format_str is a string containing {}, then format_str.format(*format_args) is ran
**log_options --
le... | [
"def",
"log",
"(",
"self",
",",
"format_str",
",",
"*",
"format_args",
",",
"*",
"*",
"log_options",
")",
":",
"if",
"isinstance",
"(",
"format_str",
",",
"Exception",
")",
":",
"logger",
".",
"exception",
"(",
"format_str",
",",
"*",
"format_args",
")",... | wrapper around the module's logger
format_str -- string -- the message to log
*format_args -- list -- if format_str is a string containing {}, then format_str.format(*format_args) is ran
**log_options --
level -- something like logging.DEBUG | [
"wrapper",
"around",
"the",
"module",
"s",
"logger"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L536-L553 |
Jaymon/prom | prom/interface/base.py | Interface.raise_error | def raise_error(self, e, exc_info=None):
"""this is just a wrapper to make the passed in exception an InterfaceError"""
if not exc_info:
exc_info = sys.exc_info()
if not isinstance(e, InterfaceError):
# allow python's built in errors to filter up through
# ht... | python | def raise_error(self, e, exc_info=None):
"""this is just a wrapper to make the passed in exception an InterfaceError"""
if not exc_info:
exc_info = sys.exc_info()
if not isinstance(e, InterfaceError):
# allow python's built in errors to filter up through
# ht... | [
"def",
"raise_error",
"(",
"self",
",",
"e",
",",
"exc_info",
"=",
"None",
")",
":",
"if",
"not",
"exc_info",
":",
"exc_info",
"=",
"sys",
".",
"exc_info",
"(",
")",
"if",
"not",
"isinstance",
"(",
"e",
",",
"InterfaceError",
")",
":",
"# allow python'... | this is just a wrapper to make the passed in exception an InterfaceError | [
"this",
"is",
"just",
"a",
"wrapper",
"to",
"make",
"the",
"passed",
"in",
"exception",
"an",
"InterfaceError"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L555-L567 |
Jaymon/prom | prom/interface/base.py | SQLInterface._query | def _query(self, query_str, query_args=None, **query_options):
"""
**query_options -- dict
ignore_result -- boolean -- true to not attempt to fetch results
fetchone -- boolean -- true to only fetch one result
count_result -- boolean -- true to return the int count of ... | python | def _query(self, query_str, query_args=None, **query_options):
"""
**query_options -- dict
ignore_result -- boolean -- true to not attempt to fetch results
fetchone -- boolean -- true to only fetch one result
count_result -- boolean -- true to return the int count of ... | [
"def",
"_query",
"(",
"self",
",",
"query_str",
",",
"query_args",
"=",
"None",
",",
"*",
"*",
"query_options",
")",
":",
"ret",
"=",
"True",
"# http://stackoverflow.com/questions/6739355/dictcursor-doesnt-seem-to-work-under-psycopg2",
"connection",
"=",
"query_options",
... | **query_options -- dict
ignore_result -- boolean -- true to not attempt to fetch results
fetchone -- boolean -- true to only fetch one result
count_result -- boolean -- true to return the int count of rows affected | [
"**",
"query_options",
"--",
"dict",
"ignore_result",
"--",
"boolean",
"--",
"true",
"to",
"not",
"attempt",
"to",
"fetch",
"results",
"fetchone",
"--",
"boolean",
"--",
"true",
"to",
"only",
"fetch",
"one",
"result",
"count_result",
"--",
"boolean",
"--",
"... | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L599-L639 |
Jaymon/prom | prom/interface/base.py | SQLInterface.get_SQL | def get_SQL(self, schema, query, **sql_options):
"""
convert the query instance into SQL
this is the glue method that translates the generic Query() instance to
the SQL specific query, this is where the magic happens
**sql_options -- dict
count_query -- boolean -- t... | python | def get_SQL(self, schema, query, **sql_options):
"""
convert the query instance into SQL
this is the glue method that translates the generic Query() instance to
the SQL specific query, this is where the magic happens
**sql_options -- dict
count_query -- boolean -- t... | [
"def",
"get_SQL",
"(",
"self",
",",
"schema",
",",
"query",
",",
"*",
"*",
"sql_options",
")",
":",
"only_where_clause",
"=",
"sql_options",
".",
"get",
"(",
"'only_where_clause'",
",",
"False",
")",
"symbol_map",
"=",
"{",
"'in'",
":",
"{",
"'symbol'",
... | convert the query instance into SQL
this is the glue method that translates the generic Query() instance to
the SQL specific query, this is where the magic happens
**sql_options -- dict
count_query -- boolean -- true if this is a count query SELECT
only_where_clause -- ... | [
"convert",
"the",
"query",
"instance",
"into",
"SQL"
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L733-L830 |
Jaymon/prom | prom/interface/base.py | SQLInterface._set_all_tables | def _set_all_tables(self, schema, **kwargs):
"""
You can run into a problem when you are trying to set a table and it has a
foreign key to a table that doesn't exist, so this method will go through
all fk refs and make sure the tables exist
"""
with self.transaction(**k... | python | def _set_all_tables(self, schema, **kwargs):
"""
You can run into a problem when you are trying to set a table and it has a
foreign key to a table that doesn't exist, so this method will go through
all fk refs and make sure the tables exist
"""
with self.transaction(**k... | [
"def",
"_set_all_tables",
"(",
"self",
",",
"schema",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"self",
".",
"transaction",
"(",
"*",
"*",
"kwargs",
")",
"as",
"connection",
":",
"kwargs",
"[",
"'connection'",
"]",
"=",
"connection",
"# go through and mak... | You can run into a problem when you are trying to set a table and it has a
foreign key to a table that doesn't exist, so this method will go through
all fk refs and make sure the tables exist | [
"You",
"can",
"run",
"into",
"a",
"problem",
"when",
"you",
"are",
"trying",
"to",
"set",
"a",
"table",
"and",
"it",
"has",
"a",
"foreign",
"key",
"to",
"a",
"table",
"that",
"doesn",
"t",
"exist",
"so",
"this",
"method",
"will",
"go",
"through",
"al... | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L856-L873 |
Jaymon/prom | prom/interface/base.py | SQLInterface._set_all_fields | def _set_all_fields(self, schema, **kwargs):
"""
this will add fields that don't exist in the table if they can be set to NULL,
the reason they have to be NULL is adding fields to Postgres that can be NULL
is really light, but if they have a default value, then it can be costly
"... | python | def _set_all_fields(self, schema, **kwargs):
"""
this will add fields that don't exist in the table if they can be set to NULL,
the reason they have to be NULL is adding fields to Postgres that can be NULL
is really light, but if they have a default value, then it can be costly
"... | [
"def",
"_set_all_fields",
"(",
"self",
",",
"schema",
",",
"*",
"*",
"kwargs",
")",
":",
"current_fields",
"=",
"self",
".",
"get_fields",
"(",
"schema",
",",
"*",
"*",
"kwargs",
")",
"for",
"field_name",
",",
"field",
"in",
"schema",
".",
"fields",
".... | this will add fields that don't exist in the table if they can be set to NULL,
the reason they have to be NULL is adding fields to Postgres that can be NULL
is really light, but if they have a default value, then it can be costly | [
"this",
"will",
"add",
"fields",
"that",
"don",
"t",
"exist",
"in",
"the",
"table",
"if",
"they",
"can",
"be",
"set",
"to",
"NULL",
"the",
"reason",
"they",
"have",
"to",
"be",
"NULL",
"is",
"adding",
"fields",
"to",
"Postgres",
"that",
"can",
"be",
... | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/base.py#L912-L933 |
thorgate/tg-utils | tg_utils/files.py | random_path | def random_path(instance, filename):
""" Random path generator for uploads, specify this for upload_to= argument of FileFields
"""
# Split the uuid into two parts so that we won't run into subdirectory count limits. First part has 3 hex chars,
# thus 4k possible values.
uuid_hex = get_uuid()
re... | python | def random_path(instance, filename):
""" Random path generator for uploads, specify this for upload_to= argument of FileFields
"""
# Split the uuid into two parts so that we won't run into subdirectory count limits. First part has 3 hex chars,
# thus 4k possible values.
uuid_hex = get_uuid()
re... | [
"def",
"random_path",
"(",
"instance",
",",
"filename",
")",
":",
"# Split the uuid into two parts so that we won't run into subdirectory count limits. First part has 3 hex chars,",
"# thus 4k possible values.",
"uuid_hex",
"=",
"get_uuid",
"(",
")",
"return",
"os",
".",
"path",... | Random path generator for uploads, specify this for upload_to= argument of FileFields | [
"Random",
"path",
"generator",
"for",
"uploads",
"specify",
"this",
"for",
"upload_to",
"=",
"argument",
"of",
"FileFields"
] | train | https://github.com/thorgate/tg-utils/blob/81e404e837334b241686d9159cc3eb44de509a88/tg_utils/files.py#L6-L12 |
Yelp/uwsgi_metrics | uwsgi_metrics/metrics.py | initialize | def initialize(signal_number=DEFAULT_TIMER_SIGNAL_NUMBER,
update_period_s=DEFAULT_UPDATE_PERIOD_S):
"""Initialize metrics, must be invoked at least once prior to invoking any
other method."""
global initialized
if initialized:
return
initialized = True
uwsgi.add_timer(sign... | python | def initialize(signal_number=DEFAULT_TIMER_SIGNAL_NUMBER,
update_period_s=DEFAULT_UPDATE_PERIOD_S):
"""Initialize metrics, must be invoked at least once prior to invoking any
other method."""
global initialized
if initialized:
return
initialized = True
uwsgi.add_timer(sign... | [
"def",
"initialize",
"(",
"signal_number",
"=",
"DEFAULT_TIMER_SIGNAL_NUMBER",
",",
"update_period_s",
"=",
"DEFAULT_UPDATE_PERIOD_S",
")",
":",
"global",
"initialized",
"if",
"initialized",
":",
"return",
"initialized",
"=",
"True",
"uwsgi",
".",
"add_timer",
"(",
... | Initialize metrics, must be invoked at least once prior to invoking any
other method. | [
"Initialize",
"metrics",
"must",
"be",
"invoked",
"at",
"least",
"once",
"prior",
"to",
"invoking",
"any",
"other",
"method",
"."
] | train | https://github.com/Yelp/uwsgi_metrics/blob/534966fd461ff711aecd1e3d4caaafdc23ac33f0/uwsgi_metrics/metrics.py#L91-L100 |
Yelp/uwsgi_metrics | uwsgi_metrics/metrics.py | emit | def emit(_):
"""Serialize metrics to the memory mapped buffer."""
if not initialized:
raise NotInitialized
view = {
'version': __version__,
'counters': {},
'gauges': {},
'histograms': {},
'meters': {},
'timers': {},
}
for (ty, module, name), ... | python | def emit(_):
"""Serialize metrics to the memory mapped buffer."""
if not initialized:
raise NotInitialized
view = {
'version': __version__,
'counters': {},
'gauges': {},
'histograms': {},
'meters': {},
'timers': {},
}
for (ty, module, name), ... | [
"def",
"emit",
"(",
"_",
")",
":",
"if",
"not",
"initialized",
":",
"raise",
"NotInitialized",
"view",
"=",
"{",
"'version'",
":",
"__version__",
",",
"'counters'",
":",
"{",
"}",
",",
"'gauges'",
":",
"{",
"}",
",",
"'histograms'",
":",
"{",
"}",
",... | Serialize metrics to the memory mapped buffer. | [
"Serialize",
"metrics",
"to",
"the",
"memory",
"mapped",
"buffer",
"."
] | train | https://github.com/Yelp/uwsgi_metrics/blob/534966fd461ff711aecd1e3d4caaafdc23ac33f0/uwsgi_metrics/metrics.py#L110-L142 |
Yelp/uwsgi_metrics | uwsgi_metrics/metrics.py | view | def view():
"""Get a dictionary representation of current metrics."""
if not initialized:
raise NotInitialized
marshalled_metrics_mmap.seek(0)
try:
uwsgi.lock()
marshalled_view = marshalled_metrics_mmap.read(
MAX_MARSHALLED_VIEW_SIZE)
finally:
uwsgi.unloc... | python | def view():
"""Get a dictionary representation of current metrics."""
if not initialized:
raise NotInitialized
marshalled_metrics_mmap.seek(0)
try:
uwsgi.lock()
marshalled_view = marshalled_metrics_mmap.read(
MAX_MARSHALLED_VIEW_SIZE)
finally:
uwsgi.unloc... | [
"def",
"view",
"(",
")",
":",
"if",
"not",
"initialized",
":",
"raise",
"NotInitialized",
"marshalled_metrics_mmap",
".",
"seek",
"(",
"0",
")",
"try",
":",
"uwsgi",
".",
"lock",
"(",
")",
"marshalled_view",
"=",
"marshalled_metrics_mmap",
".",
"read",
"(",
... | Get a dictionary representation of current metrics. | [
"Get",
"a",
"dictionary",
"representation",
"of",
"current",
"metrics",
"."
] | train | https://github.com/Yelp/uwsgi_metrics/blob/534966fd461ff711aecd1e3d4caaafdc23ac33f0/uwsgi_metrics/metrics.py#L145-L157 |
Yelp/uwsgi_metrics | uwsgi_metrics/metrics.py | timing | def timing(module, name):
"""
Context manager to time a section of code::
with timing(__name__, 'my_timer'):
do_some_operation()
"""
start_time_s = time.time()
try:
yield
finally:
end_time_s = time.time()
delta_s = end_time_s - start_time_s
de... | python | def timing(module, name):
"""
Context manager to time a section of code::
with timing(__name__, 'my_timer'):
do_some_operation()
"""
start_time_s = time.time()
try:
yield
finally:
end_time_s = time.time()
delta_s = end_time_s - start_time_s
de... | [
"def",
"timing",
"(",
"module",
",",
"name",
")",
":",
"start_time_s",
"=",
"time",
".",
"time",
"(",
")",
"try",
":",
"yield",
"finally",
":",
"end_time_s",
"=",
"time",
".",
"time",
"(",
")",
"delta_s",
"=",
"end_time_s",
"-",
"start_time_s",
"delta_... | Context manager to time a section of code::
with timing(__name__, 'my_timer'):
do_some_operation() | [
"Context",
"manager",
"to",
"time",
"a",
"section",
"of",
"code",
"::"
] | train | https://github.com/Yelp/uwsgi_metrics/blob/534966fd461ff711aecd1e3d4caaafdc23ac33f0/uwsgi_metrics/metrics.py#L161-L175 |
Yelp/uwsgi_metrics | uwsgi_metrics/metrics.py | timer | def timer(module, name, delta, duration_units='milliseconds'):
"""
Record a timing delta:
::
start_time_s = time.time()
do_some_operation()
end_time_s = time.time()
delta_s = end_time_s - start_time_s
delta_ms = delta_s * 1000
timer(__name__, 'my_timer', delt... | python | def timer(module, name, delta, duration_units='milliseconds'):
"""
Record a timing delta:
::
start_time_s = time.time()
do_some_operation()
end_time_s = time.time()
delta_s = end_time_s - start_time_s
delta_ms = delta_s * 1000
timer(__name__, 'my_timer', delt... | [
"def",
"timer",
"(",
"module",
",",
"name",
",",
"delta",
",",
"duration_units",
"=",
"'milliseconds'",
")",
":",
"timer",
"=",
"get_metric",
"(",
"'timers'",
",",
"module",
",",
"name",
",",
"Timer",
"(",
"duration_units",
")",
")",
"timer",
".",
"updat... | Record a timing delta:
::
start_time_s = time.time()
do_some_operation()
end_time_s = time.time()
delta_s = end_time_s - start_time_s
delta_ms = delta_s * 1000
timer(__name__, 'my_timer', delta_ms) | [
"Record",
"a",
"timing",
"delta",
":",
"::"
] | train | https://github.com/Yelp/uwsgi_metrics/blob/534966fd461ff711aecd1e3d4caaafdc23ac33f0/uwsgi_metrics/metrics.py#L179-L192 |
Yelp/uwsgi_metrics | uwsgi_metrics/metrics.py | histogram | def histogram(module, name, value):
"""
Record a value in a histogram:
::
histogram(__name__, 'my_histogram', len(queue))
"""
histogram = get_metric('histograms', module, name, Histogram())
histogram.update(value) | python | def histogram(module, name, value):
"""
Record a value in a histogram:
::
histogram(__name__, 'my_histogram', len(queue))
"""
histogram = get_metric('histograms', module, name, Histogram())
histogram.update(value) | [
"def",
"histogram",
"(",
"module",
",",
"name",
",",
"value",
")",
":",
"histogram",
"=",
"get_metric",
"(",
"'histograms'",
",",
"module",
",",
"name",
",",
"Histogram",
"(",
")",
")",
"histogram",
".",
"update",
"(",
"value",
")"
] | Record a value in a histogram:
::
histogram(__name__, 'my_histogram', len(queue)) | [
"Record",
"a",
"value",
"in",
"a",
"histogram",
":",
"::"
] | train | https://github.com/Yelp/uwsgi_metrics/blob/534966fd461ff711aecd1e3d4caaafdc23ac33f0/uwsgi_metrics/metrics.py#L196-L204 |
Yelp/uwsgi_metrics | uwsgi_metrics/metrics.py | counter | def counter(module, name, count=1):
"""
Record an event's occurence in a counter:
::
counter(__name__, 'my_counter')
"""
counter = get_metric('counters', module, name, Counter())
counter.inc(count) | python | def counter(module, name, count=1):
"""
Record an event's occurence in a counter:
::
counter(__name__, 'my_counter')
"""
counter = get_metric('counters', module, name, Counter())
counter.inc(count) | [
"def",
"counter",
"(",
"module",
",",
"name",
",",
"count",
"=",
"1",
")",
":",
"counter",
"=",
"get_metric",
"(",
"'counters'",
",",
"module",
",",
"name",
",",
"Counter",
"(",
")",
")",
"counter",
".",
"inc",
"(",
"count",
")"
] | Record an event's occurence in a counter:
::
counter(__name__, 'my_counter') | [
"Record",
"an",
"event",
"s",
"occurence",
"in",
"a",
"counter",
":",
"::"
] | train | https://github.com/Yelp/uwsgi_metrics/blob/534966fd461ff711aecd1e3d4caaafdc23ac33f0/uwsgi_metrics/metrics.py#L208-L216 |
Yelp/uwsgi_metrics | uwsgi_metrics/metrics.py | meter | def meter(module, name, count=1):
"""
Record an event rate:
::
meter(__name__, 'my_meter', 'event_type')
"""
meter = get_metric('meters', module, name, Meter())
meter.mark(count) | python | def meter(module, name, count=1):
"""
Record an event rate:
::
meter(__name__, 'my_meter', 'event_type')
"""
meter = get_metric('meters', module, name, Meter())
meter.mark(count) | [
"def",
"meter",
"(",
"module",
",",
"name",
",",
"count",
"=",
"1",
")",
":",
"meter",
"=",
"get_metric",
"(",
"'meters'",
",",
"module",
",",
"name",
",",
"Meter",
"(",
")",
")",
"meter",
".",
"mark",
"(",
"count",
")"
] | Record an event rate:
::
meter(__name__, 'my_meter', 'event_type') | [
"Record",
"an",
"event",
"rate",
":",
"::"
] | train | https://github.com/Yelp/uwsgi_metrics/blob/534966fd461ff711aecd1e3d4caaafdc23ac33f0/uwsgi_metrics/metrics.py#L220-L228 |
BeyondTheClouds/enoslib | enoslib/infra/enos_g5k/remote.py | exec_command_on_nodes | def exec_command_on_nodes(nodes, cmd, label, conn_params=None):
"""Execute a command on a node (id or hostname) or on a set of nodes.
:param nodes: list of targets of the command cmd. Each must be an
execo.Host.
:param cmd: string representing the command to run on the... | python | def exec_command_on_nodes(nodes, cmd, label, conn_params=None):
"""Execute a command on a node (id or hostname) or on a set of nodes.
:param nodes: list of targets of the command cmd. Each must be an
execo.Host.
:param cmd: string representing the command to run on the... | [
"def",
"exec_command_on_nodes",
"(",
"nodes",
",",
"cmd",
",",
"label",
",",
"conn_params",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"nodes",
",",
"BASESTRING",
")",
":",
"nodes",
"=",
"[",
"nodes",
"]",
"if",
"conn_params",
"is",
"None",
":",
"... | Execute a command on a node (id or hostname) or on a set of nodes.
:param nodes: list of targets of the command cmd. Each must be an
execo.Host.
:param cmd: string representing the command to run on the
remote nodes.
:param label: string f... | [
"Execute",
"a",
"command",
"on",
"a",
"node",
"(",
"id",
"or",
"hostname",
")",
"or",
"on",
"a",
"set",
"of",
"nodes",
"."
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_g5k/remote.py#L17-L40 |
guaix-ucm/pyemir | emirdrp/products.py | ProcessedImageProduct.convert_out | def convert_out(self, obj):
"""Write EMIRUUID header on reduction"""
newobj = super(ProcessedImageProduct, self).convert_out(obj)
if newobj:
hdulist = newobj.open()
hdr = hdulist[0].header
if 'EMIRUUID' not in hdr:
hdr['EMIRUUID'] = str(uuid.uu... | python | def convert_out(self, obj):
"""Write EMIRUUID header on reduction"""
newobj = super(ProcessedImageProduct, self).convert_out(obj)
if newobj:
hdulist = newobj.open()
hdr = hdulist[0].header
if 'EMIRUUID' not in hdr:
hdr['EMIRUUID'] = str(uuid.uu... | [
"def",
"convert_out",
"(",
"self",
",",
"obj",
")",
":",
"newobj",
"=",
"super",
"(",
"ProcessedImageProduct",
",",
"self",
")",
".",
"convert_out",
"(",
"obj",
")",
"if",
"newobj",
":",
"hdulist",
"=",
"newobj",
".",
"open",
"(",
")",
"hdr",
"=",
"h... | Write EMIRUUID header on reduction | [
"Write",
"EMIRUUID",
"header",
"on",
"reduction"
] | train | https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/products.py#L97-L105 |
IdentityPython/oidcendpoint | src/oidcendpoint/client_authn.py | verify_client | def verify_client(endpoint_context, request, authorization_info):
"""
Initiated Guessing !
:param endpoint_context: SrvInfo instance
:param request: The request
:param authorization_info: Client authentication information
:return: dictionary containing client id, client authentication method an... | python | def verify_client(endpoint_context, request, authorization_info):
"""
Initiated Guessing !
:param endpoint_context: SrvInfo instance
:param request: The request
:param authorization_info: Client authentication information
:return: dictionary containing client id, client authentication method an... | [
"def",
"verify_client",
"(",
"endpoint_context",
",",
"request",
",",
"authorization_info",
")",
":",
"if",
"not",
"authorization_info",
":",
"if",
"'client_id'",
"in",
"request",
"and",
"'client_secret'",
"in",
"request",
":",
"auth_info",
"=",
"ClientSecretPost",
... | Initiated Guessing !
:param endpoint_context: SrvInfo instance
:param request: The request
:param authorization_info: Client authentication information
:return: dictionary containing client id, client authentication method and
possibly access token. | [
"Initiated",
"Guessing",
"!"
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/client_authn.py#L194-L272 |
IdentityPython/oidcendpoint | src/oidcendpoint/oidc/refresh_token.py | RefreshAccessToken._post_parse_request | def _post_parse_request(self, request, client_id='', **kwargs):
"""
This is where clients come to refresh their access tokens
:param request: The request
:param authn: Authentication info, comes from HTTP header
:returns:
"""
request = RefreshAccessTokenRequest(... | python | def _post_parse_request(self, request, client_id='', **kwargs):
"""
This is where clients come to refresh their access tokens
:param request: The request
:param authn: Authentication info, comes from HTTP header
:returns:
"""
request = RefreshAccessTokenRequest(... | [
"def",
"_post_parse_request",
"(",
"self",
",",
"request",
",",
"client_id",
"=",
"''",
",",
"*",
"*",
"kwargs",
")",
":",
"request",
"=",
"RefreshAccessTokenRequest",
"(",
"*",
"*",
"request",
".",
"to_dict",
"(",
")",
")",
"try",
":",
"keyjar",
"=",
... | This is where clients come to refresh their access tokens
:param request: The request
:param authn: Authentication info, comes from HTTP header
:returns: | [
"This",
"is",
"where",
"clients",
"come",
"to",
"refresh",
"their",
"access",
"tokens"
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/oidc/refresh_token.py#L77-L100 |
volafiled/python-volapi | volapi/utils.py | random_id | def random_id(length):
"""Generates a random ID of given length"""
def char():
"""Generate single random char"""
return random.choice(string.ascii_letters + string.digits)
return "".join(char() for _ in range(length)) | python | def random_id(length):
"""Generates a random ID of given length"""
def char():
"""Generate single random char"""
return random.choice(string.ascii_letters + string.digits)
return "".join(char() for _ in range(length)) | [
"def",
"random_id",
"(",
"length",
")",
":",
"def",
"char",
"(",
")",
":",
"\"\"\"Generate single random char\"\"\"",
"return",
"random",
".",
"choice",
"(",
"string",
".",
"ascii_letters",
"+",
"string",
".",
"digits",
")",
"return",
"\"\"",
".",
"join",
"(... | Generates a random ID of given length | [
"Generates",
"a",
"random",
"ID",
"of",
"given",
"length"
] | train | https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/utils.py#L39-L47 |
volafiled/python-volapi | volapi/utils.py | delayed_close | def delayed_close(closable):
"""Delay close until this contextmanager dies"""
close = getattr(closable, "close", None)
if close:
# we do not want the library to close file in case we need to
# resume, hence make close a no-op
# pylint: disable=unused-argument
def replacement... | python | def delayed_close(closable):
"""Delay close until this contextmanager dies"""
close = getattr(closable, "close", None)
if close:
# we do not want the library to close file in case we need to
# resume, hence make close a no-op
# pylint: disable=unused-argument
def replacement... | [
"def",
"delayed_close",
"(",
"closable",
")",
":",
"close",
"=",
"getattr",
"(",
"closable",
",",
"\"close\"",
",",
"None",
")",
"if",
"close",
":",
"# we do not want the library to close file in case we need to",
"# resume, hence make close a no-op",
"# pylint: disable=unu... | Delay close until this contextmanager dies | [
"Delay",
"close",
"until",
"this",
"contextmanager",
"dies"
] | train | https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/utils.py#L63-L82 |
IdentityPython/oidcendpoint | src/oidcendpoint/sso_db.py | SSODb.map_sid2uid | def map_sid2uid(self, sid, uid):
"""
Store the connection between a Session ID and a User ID
:param sid: Session ID
:param uid: User ID
"""
self.set('sid2uid', sid, uid)
self.set('uid2sid', uid, sid) | python | def map_sid2uid(self, sid, uid):
"""
Store the connection between a Session ID and a User ID
:param sid: Session ID
:param uid: User ID
"""
self.set('sid2uid', sid, uid)
self.set('uid2sid', uid, sid) | [
"def",
"map_sid2uid",
"(",
"self",
",",
"sid",
",",
"uid",
")",
":",
"self",
".",
"set",
"(",
"'sid2uid'",
",",
"sid",
",",
"uid",
")",
"self",
".",
"set",
"(",
"'uid2sid'",
",",
"uid",
",",
"sid",
")"
] | Store the connection between a Session ID and a User ID
:param sid: Session ID
:param uid: User ID | [
"Store",
"the",
"connection",
"between",
"a",
"Session",
"ID",
"and",
"a",
"User",
"ID"
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/sso_db.py#L52-L60 |
IdentityPython/oidcendpoint | src/oidcendpoint/sso_db.py | SSODb.map_sid2sub | def map_sid2sub(self, sid, sub):
"""
Store the connection between a Session ID and a subject ID.
:param sid: Session ID
:param sub: subject ID
"""
self.set('sid2sub', sid, sub)
self.set('sub2sid', sub, sid) | python | def map_sid2sub(self, sid, sub):
"""
Store the connection between a Session ID and a subject ID.
:param sid: Session ID
:param sub: subject ID
"""
self.set('sid2sub', sid, sub)
self.set('sub2sid', sub, sid) | [
"def",
"map_sid2sub",
"(",
"self",
",",
"sid",
",",
"sub",
")",
":",
"self",
".",
"set",
"(",
"'sid2sub'",
",",
"sid",
",",
"sub",
")",
"self",
".",
"set",
"(",
"'sub2sid'",
",",
"sub",
",",
"sid",
")"
] | Store the connection between a Session ID and a subject ID.
:param sid: Session ID
:param sub: subject ID | [
"Store",
"the",
"connection",
"between",
"a",
"Session",
"ID",
"and",
"a",
"subject",
"ID",
"."
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/sso_db.py#L62-L70 |
IdentityPython/oidcendpoint | src/oidcendpoint/sso_db.py | SSODb.get_subs_by_uid | def get_subs_by_uid(self, uid):
"""
Find all subject identifiers that is connected to a User ID.
:param uid: A User ID
:return: A set of subject identifiers
"""
res = set()
for sid in self.get('uid2sid', uid):
res |= set(self.get('sid2sub', sid))
... | python | def get_subs_by_uid(self, uid):
"""
Find all subject identifiers that is connected to a User ID.
:param uid: A User ID
:return: A set of subject identifiers
"""
res = set()
for sid in self.get('uid2sid', uid):
res |= set(self.get('sid2sub', sid))
... | [
"def",
"get_subs_by_uid",
"(",
"self",
",",
"uid",
")",
":",
"res",
"=",
"set",
"(",
")",
"for",
"sid",
"in",
"self",
".",
"get",
"(",
"'uid2sid'",
",",
"uid",
")",
":",
"res",
"|=",
"set",
"(",
"self",
".",
"get",
"(",
"'sid2sub'",
",",
"sid",
... | Find all subject identifiers that is connected to a User ID.
:param uid: A User ID
:return: A set of subject identifiers | [
"Find",
"all",
"subject",
"identifiers",
"that",
"is",
"connected",
"to",
"a",
"User",
"ID",
"."
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/sso_db.py#L104-L114 |
IdentityPython/oidcendpoint | src/oidcendpoint/sso_db.py | SSODb.remove_sid2sub | def remove_sid2sub(self, sid, sub):
"""
Remove the connection between a session ID and a Subject
:param sid: Session ID
:param sub: Subject identifier
´ """
self.remove('sub2sid', sub, sid)
self.remove('sid2sub', sid, sub) | python | def remove_sid2sub(self, sid, sub):
"""
Remove the connection between a session ID and a Subject
:param sid: Session ID
:param sub: Subject identifier
´ """
self.remove('sub2sid', sub, sid)
self.remove('sid2sub', sid, sub) | [
"def",
"remove_sid2sub",
"(",
"self",
",",
"sid",
",",
"sub",
")",
":",
"self",
".",
"remove",
"(",
"'sub2sid'",
",",
"sub",
",",
"sid",
")",
"self",
".",
"remove",
"(",
"'sid2sub'",
",",
"sid",
",",
"sub",
")"
] | Remove the connection between a session ID and a Subject
:param sid: Session ID
:param sub: Subject identifier
´ | [
"Remove",
"the",
"connection",
"between",
"a",
"session",
"ID",
"and",
"a",
"Subject"
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/sso_db.py#L116-L124 |
IdentityPython/oidcendpoint | src/oidcendpoint/sso_db.py | SSODb.remove_sid2uid | def remove_sid2uid(self, sid, uid):
"""
Remove the connection between a session ID and a Subject
:param sid: Session ID
:param uid: User identifier
´ """
self.remove('uid2sid', uid, sid)
self.remove('sid2uid', sid, uid) | python | def remove_sid2uid(self, sid, uid):
"""
Remove the connection between a session ID and a Subject
:param sid: Session ID
:param uid: User identifier
´ """
self.remove('uid2sid', uid, sid)
self.remove('sid2uid', sid, uid) | [
"def",
"remove_sid2uid",
"(",
"self",
",",
"sid",
",",
"uid",
")",
":",
"self",
".",
"remove",
"(",
"'uid2sid'",
",",
"uid",
",",
"sid",
")",
"self",
".",
"remove",
"(",
"'sid2uid'",
",",
"sid",
",",
"uid",
")"
] | Remove the connection between a session ID and a Subject
:param sid: Session ID
:param uid: User identifier
´ | [
"Remove",
"the",
"connection",
"between",
"a",
"session",
"ID",
"and",
"a",
"Subject"
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/sso_db.py#L126-L134 |
IdentityPython/oidcendpoint | src/oidcendpoint/sso_db.py | SSODb.remove_session_id | def remove_session_id(self, sid):
"""
Remove all references to a specific Session ID
:param sid: A Session ID
"""
for uid in self.get('sid2uid', sid):
self.remove('uid2sid', uid, sid)
self.delete('sid2uid', sid)
for sub in self.get('sid2sub', sid):
... | python | def remove_session_id(self, sid):
"""
Remove all references to a specific Session ID
:param sid: A Session ID
"""
for uid in self.get('sid2uid', sid):
self.remove('uid2sid', uid, sid)
self.delete('sid2uid', sid)
for sub in self.get('sid2sub', sid):
... | [
"def",
"remove_session_id",
"(",
"self",
",",
"sid",
")",
":",
"for",
"uid",
"in",
"self",
".",
"get",
"(",
"'sid2uid'",
",",
"sid",
")",
":",
"self",
".",
"remove",
"(",
"'uid2sid'",
",",
"uid",
",",
"sid",
")",
"self",
".",
"delete",
"(",
"'sid2u... | Remove all references to a specific Session ID
:param sid: A Session ID | [
"Remove",
"all",
"references",
"to",
"a",
"specific",
"Session",
"ID"
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/sso_db.py#L136-L148 |
IdentityPython/oidcendpoint | src/oidcendpoint/sso_db.py | SSODb.remove_uid | def remove_uid(self, uid):
"""
Remove all references to a specific User ID
:param uid: A User ID
"""
for sid in self.get('uid2sid', uid):
self.remove('sid2uid', sid, uid)
self.delete('uid2sid', uid) | python | def remove_uid(self, uid):
"""
Remove all references to a specific User ID
:param uid: A User ID
"""
for sid in self.get('uid2sid', uid):
self.remove('sid2uid', sid, uid)
self.delete('uid2sid', uid) | [
"def",
"remove_uid",
"(",
"self",
",",
"uid",
")",
":",
"for",
"sid",
"in",
"self",
".",
"get",
"(",
"'uid2sid'",
",",
"uid",
")",
":",
"self",
".",
"remove",
"(",
"'sid2uid'",
",",
"sid",
",",
"uid",
")",
"self",
".",
"delete",
"(",
"'uid2sid'",
... | Remove all references to a specific User ID
:param uid: A User ID | [
"Remove",
"all",
"references",
"to",
"a",
"specific",
"User",
"ID"
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/sso_db.py#L150-L158 |
IdentityPython/oidcendpoint | src/oidcendpoint/sso_db.py | SSODb.remove_sub | def remove_sub(self, sub):
"""
Remove all references to a specific Subject ID
:param sub: A Subject ID
"""
for _sid in self.get('sub2sid', sub):
self.remove('sid2sub', _sid, sub)
self.delete('sub2sid', sub) | python | def remove_sub(self, sub):
"""
Remove all references to a specific Subject ID
:param sub: A Subject ID
"""
for _sid in self.get('sub2sid', sub):
self.remove('sid2sub', _sid, sub)
self.delete('sub2sid', sub) | [
"def",
"remove_sub",
"(",
"self",
",",
"sub",
")",
":",
"for",
"_sid",
"in",
"self",
".",
"get",
"(",
"'sub2sid'",
",",
"sub",
")",
":",
"self",
".",
"remove",
"(",
"'sid2sub'",
",",
"_sid",
",",
"sub",
")",
"self",
".",
"delete",
"(",
"'sub2sid'",... | Remove all references to a specific Subject ID
:param sub: A Subject ID | [
"Remove",
"all",
"references",
"to",
"a",
"specific",
"Subject",
"ID"
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/sso_db.py#L160-L168 |
BeyondTheClouds/enoslib | docs/tutorials/using-tasks/step2.py | up | def up(force=True, env=None, **kwargs):
"Starts a new experiment"
inventory = os.path.join(os.getcwd(), "hosts")
conf = Configuration.from_dictionnary(provider_conf)
provider = Enos_vagrant(conf)
roles, networks = provider.init()
check_networks(roles, networks)
env["roles"] = roles
env["... | python | def up(force=True, env=None, **kwargs):
"Starts a new experiment"
inventory = os.path.join(os.getcwd(), "hosts")
conf = Configuration.from_dictionnary(provider_conf)
provider = Enos_vagrant(conf)
roles, networks = provider.init()
check_networks(roles, networks)
env["roles"] = roles
env["... | [
"def",
"up",
"(",
"force",
"=",
"True",
",",
"env",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"inventory",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"getcwd",
"(",
")",
",",
"\"hosts\"",
")",
"conf",
"=",
"Configuration",
".",
... | Starts a new experiment | [
"Starts",
"a",
"new",
"experiment"
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/docs/tutorials/using-tasks/step2.py#L32-L40 |
BreakingBytes/simkit | simkit/core/__init__.py | convert_args | def convert_args(test_fcn, *test_args):
"""
Decorator to be using in formulas to convert ``test_args`` depending on
the ``test_fcn``.
:param test_fcn: A test function that converts arguments.
:type test_fcn: function
:param test_args: Names of args to convert using ``test_fcn``.
:type test_... | python | def convert_args(test_fcn, *test_args):
"""
Decorator to be using in formulas to convert ``test_args`` depending on
the ``test_fcn``.
:param test_fcn: A test function that converts arguments.
:type test_fcn: function
:param test_args: Names of args to convert using ``test_fcn``.
:type test_... | [
"def",
"convert_args",
"(",
"test_fcn",
",",
"*",
"test_args",
")",
":",
"def",
"wrapper",
"(",
"origfcn",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"origfcn",
")",
"def",
"newfcn",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"argspec",... | Decorator to be using in formulas to convert ``test_args`` depending on
the ``test_fcn``.
:param test_fcn: A test function that converts arguments.
:type test_fcn: function
:param test_args: Names of args to convert using ``test_fcn``.
:type test_args: str
The following test functions are avai... | [
"Decorator",
"to",
"be",
"using",
"in",
"formulas",
"to",
"convert",
"test_args",
"depending",
"on",
"the",
"test_fcn",
"."
] | train | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/__init__.py#L157-L192 |
BreakingBytes/simkit | simkit/core/__init__.py | get_public_attributes | def get_public_attributes(cls, as_list=True):
"""
Return class attributes that are neither private nor magic.
:param cls: class
:param as_list: [True] set to False to return generator
:return: only public attributes of class
"""
attrs = (a for a in dir(cls) if not a.startswith('_'))
if ... | python | def get_public_attributes(cls, as_list=True):
"""
Return class attributes that are neither private nor magic.
:param cls: class
:param as_list: [True] set to False to return generator
:return: only public attributes of class
"""
attrs = (a for a in dir(cls) if not a.startswith('_'))
if ... | [
"def",
"get_public_attributes",
"(",
"cls",
",",
"as_list",
"=",
"True",
")",
":",
"attrs",
"=",
"(",
"a",
"for",
"a",
"in",
"dir",
"(",
"cls",
")",
"if",
"not",
"a",
".",
"startswith",
"(",
"'_'",
")",
")",
"if",
"as_list",
":",
"return",
"list",
... | Return class attributes that are neither private nor magic.
:param cls: class
:param as_list: [True] set to False to return generator
:return: only public attributes of class | [
"Return",
"class",
"attributes",
"that",
"are",
"neither",
"private",
"nor",
"magic",
"."
] | train | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/__init__.py#L226-L237 |
BreakingBytes/simkit | simkit/core/__init__.py | Registry.register | def register(self, newitems, *args, **kwargs):
"""
Register newitems in registry.
:param newitems: New items to add to registry. When registering new
items, keys are not allowed to override existing keys in the
registry.
:type newitems: mapping
:param arg... | python | def register(self, newitems, *args, **kwargs):
"""
Register newitems in registry.
:param newitems: New items to add to registry. When registering new
items, keys are not allowed to override existing keys in the
registry.
:type newitems: mapping
:param arg... | [
"def",
"register",
"(",
"self",
",",
"newitems",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"newkeys",
"=",
"newitems",
".",
"viewkeys",
"(",
")",
"# set of the new item keys",
"if",
"any",
"(",
"self",
".",
"viewkeys",
"(",
")",
"&",
"newkey... | Register newitems in registry.
:param newitems: New items to add to registry. When registering new
items, keys are not allowed to override existing keys in the
registry.
:type newitems: mapping
:param args: Positional arguments with meta data corresponding to order
... | [
"Register",
"newitems",
"in",
"registry",
"."
] | train | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/__init__.py#L103-L130 |
BreakingBytes/simkit | simkit/core/__init__.py | Registry.unregister | def unregister(self, items):
"""
Remove items from registry.
:param items:
"""
items = _listify(items)
# get all members of Registry except private, special or class
meta_names = (m for m in vars(self).iterkeys()
if (not m.startswith('_') an... | python | def unregister(self, items):
"""
Remove items from registry.
:param items:
"""
items = _listify(items)
# get all members of Registry except private, special or class
meta_names = (m for m in vars(self).iterkeys()
if (not m.startswith('_') an... | [
"def",
"unregister",
"(",
"self",
",",
"items",
")",
":",
"items",
"=",
"_listify",
"(",
"items",
")",
"# get all members of Registry except private, special or class",
"meta_names",
"=",
"(",
"m",
"for",
"m",
"in",
"vars",
"(",
"self",
")",
".",
"iterkeys",
"... | Remove items from registry.
:param items: | [
"Remove",
"items",
"from",
"registry",
"."
] | train | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/__init__.py#L132-L153 |
BreakingBytes/simkit | simkit/core/__init__.py | SimKitJSONEncoder.default | def default(self, o):
"""
JSONEncoder default method that converts NumPy arrays and quantities
objects to lists.
"""
if isinstance(o, Q_):
return o.magnitude
elif isinstance(o, np.ndarray):
return o.tolist()
else:
# raise TypeEr... | python | def default(self, o):
"""
JSONEncoder default method that converts NumPy arrays and quantities
objects to lists.
"""
if isinstance(o, Q_):
return o.magnitude
elif isinstance(o, np.ndarray):
return o.tolist()
else:
# raise TypeEr... | [
"def",
"default",
"(",
"self",
",",
"o",
")",
":",
"if",
"isinstance",
"(",
"o",
",",
"Q_",
")",
":",
"return",
"o",
".",
"magnitude",
"elif",
"isinstance",
"(",
"o",
",",
"np",
".",
"ndarray",
")",
":",
"return",
"o",
".",
"tolist",
"(",
")",
... | JSONEncoder default method that converts NumPy arrays and quantities
objects to lists. | [
"JSONEncoder",
"default",
"method",
"that",
"converts",
"NumPy",
"arrays",
"and",
"quantities",
"objects",
"to",
"lists",
"."
] | train | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/__init__.py#L212-L223 |
BreakingBytes/simkit | simkit/core/__init__.py | CommonBase.set_meta | def set_meta(mcs, bases, attr):
"""
Get all of the ``Meta`` classes from bases and combine them with this
class.
Pops or creates ``Meta`` from attributes, combines all bases, adds
``_meta`` to attributes with all meta
:param bases: bases of this class
:param att... | python | def set_meta(mcs, bases, attr):
"""
Get all of the ``Meta`` classes from bases and combine them with this
class.
Pops or creates ``Meta`` from attributes, combines all bases, adds
``_meta`` to attributes with all meta
:param bases: bases of this class
:param att... | [
"def",
"set_meta",
"(",
"mcs",
",",
"bases",
",",
"attr",
")",
":",
"# pop the meta class from the attributes",
"meta",
"=",
"attr",
".",
"pop",
"(",
"mcs",
".",
"_meta_cls",
",",
"types",
".",
"ClassType",
"(",
"mcs",
".",
"_meta_cls",
",",
"(",
")",
",... | Get all of the ``Meta`` classes from bases and combine them with this
class.
Pops or creates ``Meta`` from attributes, combines all bases, adds
``_meta`` to attributes with all meta
:param bases: bases of this class
:param attr: class attributes
:return: attributes with... | [
"Get",
"all",
"of",
"the",
"Meta",
"classes",
"from",
"bases",
"and",
"combine",
"them",
"with",
"this",
"class",
"."
] | train | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/__init__.py#L267-L297 |
BreakingBytes/simkit | simkit/core/__init__.py | CommonBase.set_param_file_or_parameters | def set_param_file_or_parameters(mcs, attr):
"""
Set parameters from class attributes that are instances of
:class:`~simkit.core.Parameter` or from a parameter file.
Any class attributes that are instances of
:class:`~simkit.core.Parameter` are popped from the class and added to... | python | def set_param_file_or_parameters(mcs, attr):
"""
Set parameters from class attributes that are instances of
:class:`~simkit.core.Parameter` or from a parameter file.
Any class attributes that are instances of
:class:`~simkit.core.Parameter` are popped from the class and added to... | [
"def",
"set_param_file_or_parameters",
"(",
"mcs",
",",
"attr",
")",
":",
"meta",
"=",
"attr",
"[",
"mcs",
".",
"_meta_attr",
"]",
"# look for parameter file path in meta",
"cls_path",
"=",
"getattr",
"(",
"meta",
",",
"mcs",
".",
"_path_attr",
",",
"None",
")... | Set parameters from class attributes that are instances of
:class:`~simkit.core.Parameter` or from a parameter file.
Any class attributes that are instances of
:class:`~simkit.core.Parameter` are popped from the class and added to
a the ``parameters`` attribute, which is a dictionary of... | [
"Set",
"parameters",
"from",
"class",
"attributes",
"that",
"are",
"instances",
"of",
":",
"class",
":",
"~simkit",
".",
"core",
".",
"Parameter",
"or",
"from",
"a",
"parameter",
"file",
"."
] | train | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/__init__.py#L300-L339 |
IdentityPython/oidcendpoint | src/oidcendpoint/user_authn/user.py | factory | def factory(cls, **kwargs):
"""
Factory method that can be used to easily instantiate a class instance
:param cls: The name of the class
:param kwargs: Keyword arguments
:return: An instance of the class or None if the name doesn't match any
known class.
"""
for name, obj in inspect... | python | def factory(cls, **kwargs):
"""
Factory method that can be used to easily instantiate a class instance
:param cls: The name of the class
:param kwargs: Keyword arguments
:return: An instance of the class or None if the name doesn't match any
known class.
"""
for name, obj in inspect... | [
"def",
"factory",
"(",
"cls",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"name",
",",
"obj",
"in",
"inspect",
".",
"getmembers",
"(",
"sys",
".",
"modules",
"[",
"__name__",
"]",
")",
":",
"if",
"inspect",
".",
"isclass",
"(",
"obj",
")",
"and",
"... | Factory method that can be used to easily instantiate a class instance
:param cls: The name of the class
:param kwargs: Keyword arguments
:return: An instance of the class or None if the name doesn't match any
known class. | [
"Factory",
"method",
"that",
"can",
"be",
"used",
"to",
"easily",
"instantiate",
"a",
"class",
"instance"
] | train | https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/user_authn/user.py#L301-L316 |
BreakingBytes/simkit | simkit/core/formulas.py | FormulaRegistry.register | def register(self, new_formulas, *args, **kwargs):
"""
Register formula and meta data.
* ``islinear`` - ``True`` if formula is linear, ``False`` if non-linear.
* ``args`` - position of arguments
* ``units`` - units of returns and arguments as pair of tuples
* ``isconstan... | python | def register(self, new_formulas, *args, **kwargs):
"""
Register formula and meta data.
* ``islinear`` - ``True`` if formula is linear, ``False`` if non-linear.
* ``args`` - position of arguments
* ``units`` - units of returns and arguments as pair of tuples
* ``isconstan... | [
"def",
"register",
"(",
"self",
",",
"new_formulas",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"zip",
"(",
"self",
".",
"meta_names",
",",
"args",
")",
")",
"# call super method, meta must be passed as kwargs!",
"supe... | Register formula and meta data.
* ``islinear`` - ``True`` if formula is linear, ``False`` if non-linear.
* ``args`` - position of arguments
* ``units`` - units of returns and arguments as pair of tuples
* ``isconstant`` - constant arguments not included in covariance
:param new... | [
"Register",
"formula",
"and",
"meta",
"data",
"."
] | train | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/formulas.py#L35-L48 |
BreakingBytes/simkit | simkit/core/formulas.py | PyModuleImporter.import_formulas | def import_formulas(self):
"""
Import formulas specified in :attr:`parameters`.
:returns: formulas
:rtype: dict
"""
# TODO: unit tests!
# TODO: move this to somewhere else and call it "importy", maybe
# core.__init__.py since a lot of modules might use it... | python | def import_formulas(self):
"""
Import formulas specified in :attr:`parameters`.
:returns: formulas
:rtype: dict
"""
# TODO: unit tests!
# TODO: move this to somewhere else and call it "importy", maybe
# core.__init__.py since a lot of modules might use it... | [
"def",
"import_formulas",
"(",
"self",
")",
":",
"# TODO: unit tests!",
"# TODO: move this to somewhere else and call it \"importy\", maybe",
"# core.__init__.py since a lot of modules might use it.",
"module",
"=",
"self",
".",
"meta",
".",
"module",
"# module read from parameters",... | Import formulas specified in :attr:`parameters`.
:returns: formulas
:rtype: dict | [
"Import",
"formulas",
"specified",
"in",
":",
"attr",
":",
"parameters",
"."
] | train | https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/formulas.py#L82-L165 |
BeyondTheClouds/enoslib | enoslib/infra/enos_chameleonbaremetal/provider.py | create_blazar_client | def create_blazar_client(config, session):
"""Check the reservation, creates a new one if nescessary."""
return blazar_client.Client(session=session,
service_type="reservation",
region_name=os.environ["OS_REGION_NAME"]) | python | def create_blazar_client(config, session):
"""Check the reservation, creates a new one if nescessary."""
return blazar_client.Client(session=session,
service_type="reservation",
region_name=os.environ["OS_REGION_NAME"]) | [
"def",
"create_blazar_client",
"(",
"config",
",",
"session",
")",
":",
"return",
"blazar_client",
".",
"Client",
"(",
"session",
"=",
"session",
",",
"service_type",
"=",
"\"reservation\"",
",",
"region_name",
"=",
"os",
".",
"environ",
"[",
"\"OS_REGION_NAME\"... | Check the reservation, creates a new one if nescessary. | [
"Check",
"the",
"reservation",
"creates",
"a",
"new",
"one",
"if",
"nescessary",
"."
] | train | https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/infra/enos_chameleonbaremetal/provider.py#L46-L50 |
Jaymon/prom | prom/decorators.py | reconnecting | def reconnecting(count=None, backoff=None):
"""this is a very specific decorator meant to be used on Interface classes.
It will attempt to reconnect if the connection is closed and run the same
method again.
TODO -- I think this will have issues with transactions using passed in
connections, ie, y... | python | def reconnecting(count=None, backoff=None):
"""this is a very specific decorator meant to be used on Interface classes.
It will attempt to reconnect if the connection is closed and run the same
method again.
TODO -- I think this will have issues with transactions using passed in
connections, ie, y... | [
"def",
"reconnecting",
"(",
"count",
"=",
"None",
",",
"backoff",
"=",
"None",
")",
":",
"# we get trixxy here so we can manipulate these values in the wrapped function,",
"# this is one of the first times I wish we were on Python 3",
"# http://stackoverflow.com/a/9264845/5006",
"recon... | this is a very specific decorator meant to be used on Interface classes.
It will attempt to reconnect if the connection is closed and run the same
method again.
TODO -- I think this will have issues with transactions using passed in
connections, ie, you pass in a transacting connection to the insert()... | [
"this",
"is",
"a",
"very",
"specific",
"decorator",
"meant",
"to",
"be",
"used",
"on",
"Interface",
"classes",
".",
"It",
"will",
"attempt",
"to",
"reconnect",
"if",
"the",
"connection",
"is",
"closed",
"and",
"run",
"the",
"same",
"method",
"again",
"."
] | train | https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/decorators.py#L13-L81 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.