partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
Channels
Returns the channels contained in the given K2 module.
everest/missions/k2/utils.py
def Channels(module): ''' Returns the channels contained in the given K2 module. ''' nums = {2: 1, 3: 5, 4: 9, 6: 13, 7: 17, 8: 21, 9: 25, 10: 29, 11: 33, 12: 37, 13: 41, 14: 45, 15: 49, 16: 53, 17: 57, 18: 61, 19: 65, 20: 69, 22: 73, 23: 77, 24: 81} if module ...
def Channels(module): ''' Returns the channels contained in the given K2 module. ''' nums = {2: 1, 3: 5, 4: 9, 6: 13, 7: 17, 8: 21, 9: 25, 10: 29, 11: 33, 12: 37, 13: 41, 14: 45, 15: 49, 16: 53, 17: 57, 18: 61, 19: 65, 20: 69, 22: 73, 23: 77, 24: 81} if module ...
[ "Returns", "the", "channels", "contained", "in", "the", "given", "K2", "module", "." ]
rodluger/everest
python
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L334-L349
[ "def", "Channels", "(", "module", ")", ":", "nums", "=", "{", "2", ":", "1", ",", "3", ":", "5", ",", "4", ":", "9", ",", "6", ":", "13", ",", "7", ":", "17", ",", "8", ":", "21", ",", "9", ":", "25", ",", "10", ":", "29", ",", "11", ...
6779591f9f8b3556847e2fbf761bdfac7520eaea
train
KepMag
Returns the *Kepler* magnitude for a given EPIC target.
everest/missions/k2/utils.py
def KepMag(EPIC, campaign=None): ''' Returns the *Kepler* magnitude for a given EPIC target. ''' if campaign is None: campaign = Campaign(EPIC) if hasattr(campaign, '__len__'): raise AttributeError( "Please choose a campaign/season for this target: %s." % campaign) ...
def KepMag(EPIC, campaign=None): ''' Returns the *Kepler* magnitude for a given EPIC target. ''' if campaign is None: campaign = Campaign(EPIC) if hasattr(campaign, '__len__'): raise AttributeError( "Please choose a campaign/season for this target: %s." % campaign) ...
[ "Returns", "the", "*", "Kepler", "*", "magnitude", "for", "a", "given", "EPIC", "target", "." ]
rodluger/everest
python
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L352-L365
[ "def", "KepMag", "(", "EPIC", ",", "campaign", "=", "None", ")", ":", "if", "campaign", "is", "None", ":", "campaign", "=", "Campaign", "(", "EPIC", ")", "if", "hasattr", "(", "campaign", ",", "'__len__'", ")", ":", "raise", "AttributeError", "(", "\"P...
6779591f9f8b3556847e2fbf761bdfac7520eaea
train
RemoveBackground
Returns :py:obj:`True` or :py:obj:`False`, indicating whether or not to remove the background flux for the target. If ``campaign < 3``, returns :py:obj:`True`, otherwise returns :py:obj:`False`.
everest/missions/k2/utils.py
def RemoveBackground(EPIC, campaign=None): ''' Returns :py:obj:`True` or :py:obj:`False`, indicating whether or not to remove the background flux for the target. If ``campaign < 3``, returns :py:obj:`True`, otherwise returns :py:obj:`False`. ''' if campaign is None: campaign = Campaign...
def RemoveBackground(EPIC, campaign=None): ''' Returns :py:obj:`True` or :py:obj:`False`, indicating whether or not to remove the background flux for the target. If ``campaign < 3``, returns :py:obj:`True`, otherwise returns :py:obj:`False`. ''' if campaign is None: campaign = Campaign...
[ "Returns", ":", "py", ":", "obj", ":", "True", "or", ":", "py", ":", "obj", ":", "False", "indicating", "whether", "or", "not", "to", "remove", "the", "background", "flux", "for", "the", "target", ".", "If", "campaign", "<", "3", "returns", ":", "py"...
rodluger/everest
python
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L368-L384
[ "def", "RemoveBackground", "(", "EPIC", ",", "campaign", "=", "None", ")", ":", "if", "campaign", "is", "None", ":", "campaign", "=", "Campaign", "(", "EPIC", ")", "if", "hasattr", "(", "campaign", ",", "'__len__'", ")", ":", "raise", "AttributeError", "...
6779591f9f8b3556847e2fbf761bdfac7520eaea
train
GetNeighboringChannels
Returns all channels on the same module as :py:obj:`channel`.
everest/missions/k2/utils.py
def GetNeighboringChannels(channel): ''' Returns all channels on the same module as :py:obj:`channel`. ''' x = divmod(channel - 1, 4)[1] return channel + np.array(range(-x, -x + 4), dtype=int)
def GetNeighboringChannels(channel): ''' Returns all channels on the same module as :py:obj:`channel`. ''' x = divmod(channel - 1, 4)[1] return channel + np.array(range(-x, -x + 4), dtype=int)
[ "Returns", "all", "channels", "on", "the", "same", "module", "as", ":", "py", ":", "obj", ":", "channel", "." ]
rodluger/everest
python
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L387-L394
[ "def", "GetNeighboringChannels", "(", "channel", ")", ":", "x", "=", "divmod", "(", "channel", "-", "1", ",", "4", ")", "[", "1", "]", "return", "channel", "+", "np", ".", "array", "(", "range", "(", "-", "x", ",", "-", "x", "+", "4", ")", ",",...
6779591f9f8b3556847e2fbf761bdfac7520eaea
train
MASTRADec
Detector location retrieval based upon RA and Dec. Adapted from `PyKE <http://keplergo.arc.nasa.gov/PyKE.shtml>`_.
everest/missions/k2/utils.py
def MASTRADec(ra, dec, darcsec, stars_only=False): ''' Detector location retrieval based upon RA and Dec. Adapted from `PyKE <http://keplergo.arc.nasa.gov/PyKE.shtml>`_. ''' # coordinate limits darcsec /= 3600.0 ra1 = ra - darcsec / np.cos(dec * np.pi / 180) ra2 = ra + darcsec / np.cos...
def MASTRADec(ra, dec, darcsec, stars_only=False): ''' Detector location retrieval based upon RA and Dec. Adapted from `PyKE <http://keplergo.arc.nasa.gov/PyKE.shtml>`_. ''' # coordinate limits darcsec /= 3600.0 ra1 = ra - darcsec / np.cos(dec * np.pi / 180) ra2 = ra + darcsec / np.cos...
[ "Detector", "location", "retrieval", "based", "upon", "RA", "and", "Dec", ".", "Adapted", "from", "PyKE", "<http", ":", "//", "keplergo", ".", "arc", ".", "nasa", ".", "gov", "/", "PyKE", ".", "shtml", ">", "_", "." ]
rodluger/everest
python
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L397-L454
[ "def", "MASTRADec", "(", "ra", ",", "dec", ",", "darcsec", ",", "stars_only", "=", "False", ")", ":", "# coordinate limits", "darcsec", "/=", "3600.0", "ra1", "=", "ra", "-", "darcsec", "/", "np", ".", "cos", "(", "dec", "*", "np", ".", "pi", "/", ...
6779591f9f8b3556847e2fbf761bdfac7520eaea
train
sex2dec
Convert sexadecimal hours to decimal degrees. Adapted from `PyKE <http://keplergo.arc.nasa.gov/PyKE.shtml>`_. :param float ra: The right ascension :param float dec: The declination :returns: The same values, but in decimal degrees
everest/missions/k2/utils.py
def sex2dec(ra, dec): ''' Convert sexadecimal hours to decimal degrees. Adapted from `PyKE <http://keplergo.arc.nasa.gov/PyKE.shtml>`_. :param float ra: The right ascension :param float dec: The declination :returns: The same values, but in decimal degrees ''' ra = re.sub('\s+', '|',...
def sex2dec(ra, dec): ''' Convert sexadecimal hours to decimal degrees. Adapted from `PyKE <http://keplergo.arc.nasa.gov/PyKE.shtml>`_. :param float ra: The right ascension :param float dec: The declination :returns: The same values, but in decimal degrees ''' ra = re.sub('\s+', '|',...
[ "Convert", "sexadecimal", "hours", "to", "decimal", "degrees", ".", "Adapted", "from", "PyKE", "<http", ":", "//", "keplergo", ".", "arc", ".", "nasa", ".", "gov", "/", "PyKE", ".", "shtml", ">", "_", "." ]
rodluger/everest
python
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L457-L488
[ "def", "sex2dec", "(", "ra", ",", "dec", ")", ":", "ra", "=", "re", ".", "sub", "(", "'\\s+'", ",", "'|'", ",", "ra", ".", "strip", "(", ")", ")", "ra", "=", "re", ".", "sub", "(", "':'", ",", "'|'", ",", "ra", ".", "strip", "(", ")", ")"...
6779591f9f8b3556847e2fbf761bdfac7520eaea
train
GetSources
Grabs the EPIC coordinates from the TPF and searches MAST for other EPIC targets within the same aperture. :param int ID: The 9-digit :py:obj:`EPIC` number of the target :param float darcsec: The search radius in arcseconds. \ Default is four times the largest dimension of the aperture. :par...
everest/missions/k2/utils.py
def GetSources(ID, darcsec=None, stars_only=False): ''' Grabs the EPIC coordinates from the TPF and searches MAST for other EPIC targets within the same aperture. :param int ID: The 9-digit :py:obj:`EPIC` number of the target :param float darcsec: The search radius in arcseconds. \ Defau...
def GetSources(ID, darcsec=None, stars_only=False): ''' Grabs the EPIC coordinates from the TPF and searches MAST for other EPIC targets within the same aperture. :param int ID: The 9-digit :py:obj:`EPIC` number of the target :param float darcsec: The search radius in arcseconds. \ Defau...
[ "Grabs", "the", "EPIC", "coordinates", "from", "the", "TPF", "and", "searches", "MAST", "for", "other", "EPIC", "targets", "within", "the", "same", "aperture", "." ]
rodluger/everest
python
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L491-L542
[ "def", "GetSources", "(", "ID", ",", "darcsec", "=", "None", ",", "stars_only", "=", "False", ")", ":", "client", "=", "kplr", ".", "API", "(", ")", "star", "=", "client", ".", "k2_star", "(", "ID", ")", "tpf", "=", "star", ".", "get_target_pixel_fil...
6779591f9f8b3556847e2fbf761bdfac7520eaea
train
GetHiResImage
Queries the Palomar Observatory Sky Survey II catalog to obtain a higher resolution optical image of the star with EPIC number :py:obj:`ID`.
everest/missions/k2/utils.py
def GetHiResImage(ID): ''' Queries the Palomar Observatory Sky Survey II catalog to obtain a higher resolution optical image of the star with EPIC number :py:obj:`ID`. ''' # Get the TPF info client = kplr.API() star = client.k2_star(ID) k2ra = star.k2_ra k2dec = star.k2_dec ...
def GetHiResImage(ID): ''' Queries the Palomar Observatory Sky Survey II catalog to obtain a higher resolution optical image of the star with EPIC number :py:obj:`ID`. ''' # Get the TPF info client = kplr.API() star = client.k2_star(ID) k2ra = star.k2_ra k2dec = star.k2_dec ...
[ "Queries", "the", "Palomar", "Observatory", "Sky", "Survey", "II", "catalog", "to", "obtain", "a", "higher", "resolution", "optical", "image", "of", "the", "star", "with", "EPIC", "number", ":", "py", ":", "obj", ":", "ID", "." ]
rodluger/everest
python
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L545-L615
[ "def", "GetHiResImage", "(", "ID", ")", ":", "# Get the TPF info", "client", "=", "kplr", ".", "API", "(", ")", "star", "=", "client", ".", "k2_star", "(", "ID", ")", "k2ra", "=", "star", ".", "k2_ra", "k2dec", "=", "star", ".", "k2_dec", "tpf", "=",...
6779591f9f8b3556847e2fbf761bdfac7520eaea
train
SaturationFlux
Returns the well depth for the target. If any of the target's pixels have flux larger than this value, they are likely to be saturated and cause charge bleeding. The well depths were obtained from Table 13 of the Kepler instrument handbook. We assume an exposure time of 6.02s.
everest/missions/k2/utils.py
def SaturationFlux(EPIC, campaign=None, **kwargs): ''' Returns the well depth for the target. If any of the target's pixels have flux larger than this value, they are likely to be saturated and cause charge bleeding. The well depths were obtained from Table 13 of the Kepler instrument handbook. We a...
def SaturationFlux(EPIC, campaign=None, **kwargs): ''' Returns the well depth for the target. If any of the target's pixels have flux larger than this value, they are likely to be saturated and cause charge bleeding. The well depths were obtained from Table 13 of the Kepler instrument handbook. We a...
[ "Returns", "the", "well", "depth", "for", "the", "target", ".", "If", "any", "of", "the", "target", "s", "pixels", "have", "flux", "larger", "than", "this", "value", "they", "are", "likely", "to", "be", "saturated", "and", "cause", "charge", "bleeding", ...
rodluger/everest
python
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/utils.py#L627-L641
[ "def", "SaturationFlux", "(", "EPIC", ",", "campaign", "=", "None", ",", "*", "*", "kwargs", ")", ":", "channel", ",", "well_depth", "=", "np", ".", "loadtxt", "(", "os", ".", "path", ".", "join", "(", "EVEREST_SRC", ",", "'missions'", ",", "'k2'", "...
6779591f9f8b3556847e2fbf761bdfac7520eaea
train
GetChunk
Returns the indices corresponding to a given light curve chunk. :param int b: The index of the chunk to return
everest/missions/k2/sysrem.py
def GetChunk(time, breakpoints, b, mask=[]): ''' Returns the indices corresponding to a given light curve chunk. :param int b: The index of the chunk to return ''' M = np.delete(np.arange(len(time)), mask, axis=0) if b > 0: res = M[(M > breakpoints[b - 1]) & (M <= breakpoints[b])] ...
def GetChunk(time, breakpoints, b, mask=[]): ''' Returns the indices corresponding to a given light curve chunk. :param int b: The index of the chunk to return ''' M = np.delete(np.arange(len(time)), mask, axis=0) if b > 0: res = M[(M > breakpoints[b - 1]) & (M <= breakpoints[b])] ...
[ "Returns", "the", "indices", "corresponding", "to", "a", "given", "light", "curve", "chunk", "." ]
rodluger/everest
python
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/sysrem.py#L25-L38
[ "def", "GetChunk", "(", "time", ",", "breakpoints", ",", "b", ",", "mask", "=", "[", "]", ")", ":", "M", "=", "np", ".", "delete", "(", "np", ".", "arange", "(", "len", "(", "time", ")", ")", ",", "mask", ",", "axis", "=", "0", ")", "if", "...
6779591f9f8b3556847e2fbf761bdfac7520eaea
train
GetStars
Returns de-trended light curves for all stars on a given module in a given campaign.
everest/missions/k2/sysrem.py
def GetStars(campaign, module, model='nPLD', **kwargs): ''' Returns de-trended light curves for all stars on a given module in a given campaign. ''' # Get the channel numbers channels = Channels(module) assert channels is not None, "No channels available on this module." # Get the EPI...
def GetStars(campaign, module, model='nPLD', **kwargs): ''' Returns de-trended light curves for all stars on a given module in a given campaign. ''' # Get the channel numbers channels = Channels(module) assert channels is not None, "No channels available on this module." # Get the EPI...
[ "Returns", "de", "-", "trended", "light", "curves", "for", "all", "stars", "on", "a", "given", "module", "in", "a", "given", "campaign", "." ]
rodluger/everest
python
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/sysrem.py#L41-L102
[ "def", "GetStars", "(", "campaign", ",", "module", ",", "model", "=", "'nPLD'", ",", "*", "*", "kwargs", ")", ":", "# Get the channel numbers", "channels", "=", "Channels", "(", "module", ")", "assert", "channels", "is", "not", "None", ",", "\"No channels av...
6779591f9f8b3556847e2fbf761bdfac7520eaea
train
SysRem
Applies :py:obj:`SysRem` to a given set of light curves. :param array_like time: The time array for all of the light curves :param array_like flux: A 2D array of the fluxes for each of the light \ curves, shape `(nfluxes, ntime)` :param array_like err: A 2D array of the flux errors for each of t...
everest/missions/k2/sysrem.py
def SysRem(time, flux, err, ncbv=5, niter=50, sv_win=999, sv_order=3, **kwargs): ''' Applies :py:obj:`SysRem` to a given set of light curves. :param array_like time: The time array for all of the light curves :param array_like flux: A 2D array of the fluxes for each of the light \ ...
def SysRem(time, flux, err, ncbv=5, niter=50, sv_win=999, sv_order=3, **kwargs): ''' Applies :py:obj:`SysRem` to a given set of light curves. :param array_like time: The time array for all of the light curves :param array_like flux: A 2D array of the fluxes for each of the light \ ...
[ "Applies", ":", "py", ":", "obj", ":", "SysRem", "to", "a", "given", "set", "of", "light", "curves", "." ]
rodluger/everest
python
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/sysrem.py#L105-L162
[ "def", "SysRem", "(", "time", ",", "flux", ",", "err", ",", "ncbv", "=", "5", ",", "niter", "=", "50", ",", "sv_win", "=", "999", ",", "sv_order", "=", "3", ",", "*", "*", "kwargs", ")", ":", "nflx", ",", "tlen", "=", "flux", ".", "shape", "#...
6779591f9f8b3556847e2fbf761bdfac7520eaea
train
GetCBVs
Computes the CBVs for a given campaign. :param int campaign: The campaign number :param str model: The name of the :py:obj:`everest` model. Default `nPLD` :param bool clobber: Overwrite existing files? Default `False`
everest/missions/k2/sysrem.py
def GetCBVs(campaign, model='nPLD', clobber=False, **kwargs): ''' Computes the CBVs for a given campaign. :param int campaign: The campaign number :param str model: The name of the :py:obj:`everest` model. Default `nPLD` :param bool clobber: Overwrite existing files? Default `False` ''' #...
def GetCBVs(campaign, model='nPLD', clobber=False, **kwargs): ''' Computes the CBVs for a given campaign. :param int campaign: The campaign number :param str model: The name of the :py:obj:`everest` model. Default `nPLD` :param bool clobber: Overwrite existing files? Default `False` ''' #...
[ "Computes", "the", "CBVs", "for", "a", "given", "campaign", "." ]
rodluger/everest
python
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/everest/missions/k2/sysrem.py#L165-L263
[ "def", "GetCBVs", "(", "campaign", ",", "model", "=", "'nPLD'", ",", "clobber", "=", "False", ",", "*", "*", "kwargs", ")", ":", "# Initialize logging?", "if", "len", "(", "logging", ".", "getLogger", "(", ")", ".", "handlers", ")", "==", "0", ":", "...
6779591f9f8b3556847e2fbf761bdfac7520eaea
train
read_lua_file
Load lua script from the stdnet/lib/lua directory
stdnet/backends/redisb/client/extensions.py
def read_lua_file(dotted_module, path=None, context=None): '''Load lua script from the stdnet/lib/lua directory''' path = path or DEFAULT_LUA_PATH bits = dotted_module.split('.') bits[-1] += '.lua' name = os.path.join(path, *bits) with open(name) as f: data = f.read() if cont...
def read_lua_file(dotted_module, path=None, context=None): '''Load lua script from the stdnet/lib/lua directory''' path = path or DEFAULT_LUA_PATH bits = dotted_module.split('.') bits[-1] += '.lua' name = os.path.join(path, *bits) with open(name) as f: data = f.read() if cont...
[ "Load", "lua", "script", "from", "the", "stdnet", "/", "lib", "/", "lua", "directory" ]
lsbardel/python-stdnet
python
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/client/extensions.py#L46-L56
[ "def", "read_lua_file", "(", "dotted_module", ",", "path", "=", "None", ",", "context", "=", "None", ")", ":", "path", "=", "path", "or", "DEFAULT_LUA_PATH", "bits", "=", "dotted_module", ".", "split", "(", "'.'", ")", "bits", "[", "-", "1", "]", "+=",...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
train
parse_info
Parse the response of Redis's INFO command into a Python dict. In doing so, convert byte data into unicode.
stdnet/backends/redisb/client/extensions.py
def parse_info(response): '''Parse the response of Redis's INFO command into a Python dict. In doing so, convert byte data into unicode.''' info = {} response = response.decode('utf-8') def get_value(value): if ',' and '=' not in value: return value sub_dict = {} ...
def parse_info(response): '''Parse the response of Redis's INFO command into a Python dict. In doing so, convert byte data into unicode.''' info = {} response = response.decode('utf-8') def get_value(value): if ',' and '=' not in value: return value sub_dict = {} ...
[ "Parse", "the", "response", "of", "Redis", "s", "INFO", "command", "into", "a", "Python", "dict", ".", "In", "doing", "so", "convert", "byte", "data", "into", "unicode", "." ]
lsbardel/python-stdnet
python
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/client/extensions.py#L59-L88
[ "def", "parse_info", "(", "response", ")", ":", "info", "=", "{", "}", "response", "=", "response", ".", "decode", "(", "'utf-8'", ")", "def", "get_value", "(", "value", ")", ":", "if", "','", "and", "'='", "not", "in", "value", ":", "return", "value...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
train
RedisExtensionsMixin.zdiffstore
Compute the difference of multiple sorted. The difference of sets specified by ``keys`` into a new sorted set in ``dest``.
stdnet/backends/redisb/client/extensions.py
def zdiffstore(self, dest, keys, withscores=False): '''Compute the difference of multiple sorted. The difference of sets specified by ``keys`` into a new sorted set in ``dest``. ''' keys = (dest,) + tuple(keys) wscores = 'withscores' if withscores else '' ...
def zdiffstore(self, dest, keys, withscores=False): '''Compute the difference of multiple sorted. The difference of sets specified by ``keys`` into a new sorted set in ``dest``. ''' keys = (dest,) + tuple(keys) wscores = 'withscores' if withscores else '' ...
[ "Compute", "the", "difference", "of", "multiple", "sorted", ".", "The", "difference", "of", "sets", "specified", "by", "keys", "into", "a", "new", "sorted", "set", "in", "dest", "." ]
lsbardel/python-stdnet
python
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/client/extensions.py#L156-L165
[ "def", "zdiffstore", "(", "self", ",", "dest", ",", "keys", ",", "withscores", "=", "False", ")", ":", "keys", "=", "(", "dest", ",", ")", "+", "tuple", "(", "keys", ")", "wscores", "=", "'withscores'", "if", "withscores", "else", "''", "return", "se...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
train
RedisExtensionsMixin.zpopbyrank
Pop a range by rank.
stdnet/backends/redisb/client/extensions.py
def zpopbyrank(self, name, start, stop=None, withscores=False, desc=False): '''Pop a range by rank. ''' stop = stop if stop is not None else start return self.execute_script('zpop', (name,), 'rank', start, stop, int(desc), int(withscores), ...
def zpopbyrank(self, name, start, stop=None, withscores=False, desc=False): '''Pop a range by rank. ''' stop = stop if stop is not None else start return self.execute_script('zpop', (name,), 'rank', start, stop, int(desc), int(withscores), ...
[ "Pop", "a", "range", "by", "rank", "." ]
lsbardel/python-stdnet
python
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/client/extensions.py#L167-L173
[ "def", "zpopbyrank", "(", "self", ",", "name", ",", "start", ",", "stop", "=", "None", ",", "withscores", "=", "False", ",", "desc", "=", "False", ")", ":", "stop", "=", "stop", "if", "stop", "is", "not", "None", "else", "start", "return", "self", ...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
train
RedisDbManager.delete
Delete an instance
stdnet/backends/redisb/client/extensions.py
def delete(self, instance): '''Delete an instance''' flushdb(self.client) if flushdb else self.client.flushdb()
def delete(self, instance): '''Delete an instance''' flushdb(self.client) if flushdb else self.client.flushdb()
[ "Delete", "an", "instance" ]
lsbardel/python-stdnet
python
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/backends/redisb/client/extensions.py#L432-L434
[ "def", "delete", "(", "self", ",", "instance", ")", ":", "flushdb", "(", "self", ".", "client", ")", "if", "flushdb", "else", "self", ".", "client", ".", "flushdb", "(", ")" ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
train
lnprior
Return the log prior given parameter vector `x`.
docs/mcmc.py
def lnprior(x): """Return the log prior given parameter vector `x`.""" per, t0, b = x if b < -1 or b > 1: return -np.inf elif per < 7 or per > 10: return -np.inf elif t0 < 1978 or t0 > 1979: return -np.inf else: return 0.
def lnprior(x): """Return the log prior given parameter vector `x`.""" per, t0, b = x if b < -1 or b > 1: return -np.inf elif per < 7 or per > 10: return -np.inf elif t0 < 1978 or t0 > 1979: return -np.inf else: return 0.
[ "Return", "the", "log", "prior", "given", "parameter", "vector", "x", "." ]
rodluger/everest
python
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/docs/mcmc.py#L11-L21
[ "def", "lnprior", "(", "x", ")", ":", "per", ",", "t0", ",", "b", "=", "x", "if", "b", "<", "-", "1", "or", "b", ">", "1", ":", "return", "-", "np", ".", "inf", "elif", "per", "<", "7", "or", "per", ">", "10", ":", "return", "-", "np", ...
6779591f9f8b3556847e2fbf761bdfac7520eaea
train
lnlike
Return the log likelihood given parameter vector `x`.
docs/mcmc.py
def lnlike(x, star): """Return the log likelihood given parameter vector `x`.""" ll = lnprior(x) if np.isinf(ll): return ll, (np.nan, np.nan) per, t0, b = x model = TransitModel('b', per=per, t0=t0, b=b, rhos=10.)(star.time) like, d, vard = star.lnlike(model, full_output=True) ll += ...
def lnlike(x, star): """Return the log likelihood given parameter vector `x`.""" ll = lnprior(x) if np.isinf(ll): return ll, (np.nan, np.nan) per, t0, b = x model = TransitModel('b', per=per, t0=t0, b=b, rhos=10.)(star.time) like, d, vard = star.lnlike(model, full_output=True) ll += ...
[ "Return", "the", "log", "likelihood", "given", "parameter", "vector", "x", "." ]
rodluger/everest
python
https://github.com/rodluger/everest/blob/6779591f9f8b3556847e2fbf761bdfac7520eaea/docs/mcmc.py#L24-L33
[ "def", "lnlike", "(", "x", ",", "star", ")", ":", "ll", "=", "lnprior", "(", "x", ")", "if", "np", ".", "isinf", "(", "ll", ")", ":", "return", "ll", ",", "(", "np", ".", "nan", ",", "np", ".", "nan", ")", "per", ",", "t0", ",", "b", "=",...
6779591f9f8b3556847e2fbf761bdfac7520eaea
train
GroupManager.check_user
username and email (if provided) must be unique.
examples/permissions.py
def check_user(self, username, email): '''username and email (if provided) must be unique.''' users = self.router.user avail = yield users.filter(username=username).count() if avail: raise FieldError('Username %s not available' % username) if email: avail ...
def check_user(self, username, email): '''username and email (if provided) must be unique.''' users = self.router.user avail = yield users.filter(username=username).count() if avail: raise FieldError('Username %s not available' % username) if email: avail ...
[ "username", "and", "email", "(", "if", "provided", ")", "must", "be", "unique", "." ]
lsbardel/python-stdnet
python
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/examples/permissions.py#L150-L159
[ "def", "check_user", "(", "self", ",", "username", ",", "email", ")", ":", "users", "=", "self", ".", "router", ".", "user", "avail", "=", "yield", "users", ".", "filter", "(", "username", "=", "username", ")", ".", "count", "(", ")", "if", "avail", ...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
train
GroupManager.permitted_query
Change the ``query`` so that only instances for which ``group`` has roles with permission on ``operations`` are returned.
examples/permissions.py
def permitted_query(self, query, group, operations): '''Change the ``query`` so that only instances for which ``group`` has roles with permission on ``operations`` are returned.''' session = query.session models = session.router user = group.user if user.is_superuser: # super-u...
def permitted_query(self, query, group, operations): '''Change the ``query`` so that only instances for which ``group`` has roles with permission on ``operations`` are returned.''' session = query.session models = session.router user = group.user if user.is_superuser: # super-u...
[ "Change", "the", "query", "so", "that", "only", "instances", "for", "which", "group", "has", "roles", "with", "permission", "on", "operations", "are", "returned", "." ]
lsbardel/python-stdnet
python
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/examples/permissions.py#L168-L202
[ "def", "permitted_query", "(", "self", ",", "query", ",", "group", ",", "operations", ")", ":", "session", "=", "query", ".", "session", "models", "=", "session", ".", "router", "user", "=", "group", ".", "user", "if", "user", ".", "is_superuser", ":", ...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
train
Subject.create_role
Create a new :class:`Role` owned by this :class:`Subject`
examples/permissions.py
def create_role(self, name): '''Create a new :class:`Role` owned by this :class:`Subject`''' models = self.session.router return models.role.new(name=name, owner=self)
def create_role(self, name): '''Create a new :class:`Role` owned by this :class:`Subject`''' models = self.session.router return models.role.new(name=name, owner=self)
[ "Create", "a", "new", ":", "class", ":", "Role", "owned", "by", "this", ":", "class", ":", "Subject" ]
lsbardel/python-stdnet
python
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/examples/permissions.py#L208-L211
[ "def", "create_role", "(", "self", ",", "name", ")", ":", "models", "=", "self", ".", "session", ".", "router", "return", "models", ".", "role", ".", "new", "(", "name", "=", "name", ",", "owner", "=", "self", ")" ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
train
Subject.assign
Assign :class:`Role` ``role`` to this :class:`Subject`. If this :class:`Subject` is the :attr:`Role.owner`, this method does nothing.
examples/permissions.py
def assign(self, role): '''Assign :class:`Role` ``role`` to this :class:`Subject`. If this :class:`Subject` is the :attr:`Role.owner`, this method does nothing.''' if role.owner_id != self.id: return self.roles.add(role)
def assign(self, role): '''Assign :class:`Role` ``role`` to this :class:`Subject`. If this :class:`Subject` is the :attr:`Role.owner`, this method does nothing.''' if role.owner_id != self.id: return self.roles.add(role)
[ "Assign", ":", "class", ":", "Role", "role", "to", "this", ":", "class", ":", "Subject", ".", "If", "this", ":", "class", ":", "Subject", "is", "the", ":", "attr", ":", "Role", ".", "owner", "this", "method", "does", "nothing", "." ]
lsbardel/python-stdnet
python
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/examples/permissions.py#L213-L217
[ "def", "assign", "(", "self", ",", "role", ")", ":", "if", "role", ".", "owner_id", "!=", "self", ".", "id", ":", "return", "self", ".", "roles", ".", "add", "(", "role", ")" ]
78db5320bdedc3f28c5e4f38cda13a4469e35db7
train
Subject.has_permissions
Check if this :class:`Subject` has permissions for ``operations`` on an ``object``. It returns the number of valid permissions.
examples/permissions.py
def has_permissions(self, object, group, operations): '''Check if this :class:`Subject` has permissions for ``operations`` on an ``object``. It returns the number of valid permissions.''' if self.is_superuser: return 1 else: models = self.session.router # vali...
def has_permissions(self, object, group, operations): '''Check if this :class:`Subject` has permissions for ``operations`` on an ``object``. It returns the number of valid permissions.''' if self.is_superuser: return 1 else: models = self.session.router # vali...
[ "Check", "if", "this", ":", "class", ":", "Subject", "has", "permissions", "for", "operations", "on", "an", "object", ".", "It", "returns", "the", "number", "of", "valid", "permissions", "." ]
lsbardel/python-stdnet
python
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/examples/permissions.py#L219-L230
[ "def", "has_permissions", "(", "self", ",", "object", ",", "group", ",", "operations", ")", ":", "if", "self", ".", "is_superuser", ":", "return", "1", "else", ":", "models", "=", "self", ".", "session", ".", "router", "# valid permissions", "query", "=", ...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
train
Role.add_permission
Add a new :class:`Permission` for ``resource`` to perform an ``operation``. The resource can be either an object or a model.
examples/permissions.py
def add_permission(self, resource, operation): '''Add a new :class:`Permission` for ``resource`` to perform an ``operation``. The resource can be either an object or a model.''' if isclass(resource): model_type = resource pk = '' else: model_type = resource.__...
def add_permission(self, resource, operation): '''Add a new :class:`Permission` for ``resource`` to perform an ``operation``. The resource can be either an object or a model.''' if isclass(resource): model_type = resource pk = '' else: model_type = resource.__...
[ "Add", "a", "new", ":", "class", ":", "Permission", "for", "resource", "to", "perform", "an", "operation", ".", "The", "resource", "can", "be", "either", "an", "object", "or", "a", "model", "." ]
lsbardel/python-stdnet
python
https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/examples/permissions.py#L305-L325
[ "def", "add_permission", "(", "self", ",", "resource", ",", "operation", ")", ":", "if", "isclass", "(", "resource", ")", ":", "model_type", "=", "resource", "pk", "=", "''", "else", ":", "model_type", "=", "resource", ".", "__class__", "pk", "=", "resou...
78db5320bdedc3f28c5e4f38cda13a4469e35db7
train
Snow.init_app
Initializes snow extension Set config default and find out which client type to use :param app: App passed from constructor or directly to init_app (factory) :param session: requests-compatible session to pass along to init_app :param parameters: `ParamsBuilder` object passed to `Clien...
flask_snow/__init__.py
def init_app(self, app, session=None, parameters=None): """Initializes snow extension Set config default and find out which client type to use :param app: App passed from constructor or directly to init_app (factory) :param session: requests-compatible session to pass along to init_app...
def init_app(self, app, session=None, parameters=None): """Initializes snow extension Set config default and find out which client type to use :param app: App passed from constructor or directly to init_app (factory) :param session: requests-compatible session to pass along to init_app...
[ "Initializes", "snow", "extension" ]
rbw/flask-snow
python
https://github.com/rbw/flask-snow/blob/8efae4c276c95044e67e41bccba1f24f9f8ef75e/flask_snow/__init__.py#L43-L74
[ "def", "init_app", "(", "self", ",", "app", ",", "session", "=", "None", ",", "parameters", "=", "None", ")", ":", "if", "parameters", "is", "not", "None", "and", "not", "isinstance", "(", "parameters", ",", "ParamsBuilder", ")", ":", "raise", "InvalidUs...
8efae4c276c95044e67e41bccba1f24f9f8ef75e
train
Snow.connection
Snow connection instance, stores a `pysnow.Client` instance and `pysnow.Resource` instances Creates a new :class:`pysnow.Client` object if it doesn't exist in the app slice of the context stack :returns: :class:`pysnow.Client` object
flask_snow/__init__.py
def connection(self): """Snow connection instance, stores a `pysnow.Client` instance and `pysnow.Resource` instances Creates a new :class:`pysnow.Client` object if it doesn't exist in the app slice of the context stack :returns: :class:`pysnow.Client` object """ ctx = stack.to...
def connection(self): """Snow connection instance, stores a `pysnow.Client` instance and `pysnow.Resource` instances Creates a new :class:`pysnow.Client` object if it doesn't exist in the app slice of the context stack :returns: :class:`pysnow.Client` object """ ctx = stack.to...
[ "Snow", "connection", "instance", "stores", "a", "pysnow", ".", "Client", "instance", "and", "pysnow", ".", "Resource", "instances" ]
rbw/flask-snow
python
https://github.com/rbw/flask-snow/blob/8efae4c276c95044e67e41bccba1f24f9f8ef75e/flask_snow/__init__.py#L126-L151
[ "def", "connection", "(", "self", ")", ":", "ctx", "=", "stack", ".", "top", ".", "app", "if", "ctx", "is", "not", "None", ":", "if", "not", "hasattr", "(", "ctx", ",", "'snow'", ")", ":", "if", "self", ".", "_client_type_oauth", ":", "if", "not", ...
8efae4c276c95044e67e41bccba1f24f9f8ef75e
train
usage
Print out a usage message
behave2cucumber/__main__.py
def usage(): """Print out a usage message""" global options l = len(options['long']) options['shortlist'] = [s for s in options['short'] if s is not ":"] print("python -m behave2cucumber [-h] [-d level|--debug=level]") for i in range(l): print(" -{0}|--{1:20} {2}".format(options['sh...
def usage(): """Print out a usage message""" global options l = len(options['long']) options['shortlist'] = [s for s in options['short'] if s is not ":"] print("python -m behave2cucumber [-h] [-d level|--debug=level]") for i in range(l): print(" -{0}|--{1:20} {2}".format(options['sh...
[ "Print", "out", "a", "usage", "message" ]
behalf-oss/behave2cucumber
python
https://github.com/behalf-oss/behave2cucumber/blob/a0ce3ebb8b2cd9bff5ba14c81e73dba7be36e657/behave2cucumber/__main__.py#L44-L53
[ "def", "usage", "(", ")", ":", "global", "options", "l", "=", "len", "(", "options", "[", "'long'", "]", ")", "options", "[", "'shortlist'", "]", "=", "[", "s", "for", "s", "in", "options", "[", "'short'", "]", "if", "s", "is", "not", "\":\"", "]...
a0ce3ebb8b2cd9bff5ba14c81e73dba7be36e657
train
main
Main
behave2cucumber/__main__.py
def main(argv): """Main""" global options opts = None try: opts, args = getopt.getopt(argv, options['short'], options['long']) except getopt.GetoptError: usage() exit(2) for opt, arg in opts: if opt in ("-h", "--help"): usage() exit() ...
def main(argv): """Main""" global options opts = None try: opts, args = getopt.getopt(argv, options['short'], options['long']) except getopt.GetoptError: usage() exit(2) for opt, arg in opts: if opt in ("-h", "--help"): usage() exit() ...
[ "Main" ]
behalf-oss/behave2cucumber
python
https://github.com/behalf-oss/behave2cucumber/blob/a0ce3ebb8b2cd9bff5ba14c81e73dba7be36e657/behave2cucumber/__main__.py#L56-L123
[ "def", "main", "(", "argv", ")", ":", "global", "options", "opts", "=", "None", "try", ":", "opts", ",", "args", "=", "getopt", ".", "getopt", "(", "argv", ",", "options", "[", "'short'", "]", ",", "options", "[", "'long'", "]", ")", "except", "get...
a0ce3ebb8b2cd9bff5ba14c81e73dba7be36e657
train
direction
Return the direction vector of a cylinder defined by the spherical coordinates theta and phi.
cylinder_fitting/fitting.py
def direction(theta, phi): '''Return the direction vector of a cylinder defined by the spherical coordinates theta and phi. ''' return np.array([np.cos(phi) * np.sin(theta), np.sin(phi) * np.sin(theta), np.cos(theta)])
def direction(theta, phi): '''Return the direction vector of a cylinder defined by the spherical coordinates theta and phi. ''' return np.array([np.cos(phi) * np.sin(theta), np.sin(phi) * np.sin(theta), np.cos(theta)])
[ "Return", "the", "direction", "vector", "of", "a", "cylinder", "defined", "by", "the", "spherical", "coordinates", "theta", "and", "phi", "." ]
xingjiepan/cylinder_fitting
python
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/fitting.py#L4-L9
[ "def", "direction", "(", "theta", ",", "phi", ")", ":", "return", "np", ".", "array", "(", "[", "np", ".", "cos", "(", "phi", ")", "*", "np", ".", "sin", "(", "theta", ")", ",", "np", ".", "sin", "(", "phi", ")", "*", "np", ".", "sin", "(",...
f96d79732bc49cbc0cb4b39f008af7ce42aeb213
train
projection_matrix
Return the projection matrix of a direction w.
cylinder_fitting/fitting.py
def projection_matrix(w): '''Return the projection matrix of a direction w.''' return np.identity(3) - np.dot(np.reshape(w, (3,1)), np.reshape(w, (1, 3)))
def projection_matrix(w): '''Return the projection matrix of a direction w.''' return np.identity(3) - np.dot(np.reshape(w, (3,1)), np.reshape(w, (1, 3)))
[ "Return", "the", "projection", "matrix", "of", "a", "direction", "w", "." ]
xingjiepan/cylinder_fitting
python
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/fitting.py#L11-L13
[ "def", "projection_matrix", "(", "w", ")", ":", "return", "np", ".", "identity", "(", "3", ")", "-", "np", ".", "dot", "(", "np", ".", "reshape", "(", "w", ",", "(", "3", ",", "1", ")", ")", ",", "np", ".", "reshape", "(", "w", ",", "(", "1...
f96d79732bc49cbc0cb4b39f008af7ce42aeb213
train
skew_matrix
Return the skew matrix of a direction w.
cylinder_fitting/fitting.py
def skew_matrix(w): '''Return the skew matrix of a direction w.''' return np.array([[0, -w[2], w[1]], [w[2], 0, -w[0]], [-w[1], w[0], 0]])
def skew_matrix(w): '''Return the skew matrix of a direction w.''' return np.array([[0, -w[2], w[1]], [w[2], 0, -w[0]], [-w[1], w[0], 0]])
[ "Return", "the", "skew", "matrix", "of", "a", "direction", "w", "." ]
xingjiepan/cylinder_fitting
python
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/fitting.py#L15-L19
[ "def", "skew_matrix", "(", "w", ")", ":", "return", "np", ".", "array", "(", "[", "[", "0", ",", "-", "w", "[", "2", "]", ",", "w", "[", "1", "]", "]", ",", "[", "w", "[", "2", "]", ",", "0", ",", "-", "w", "[", "0", "]", "]", ",", ...
f96d79732bc49cbc0cb4b39f008af7ce42aeb213
train
calc_A
Return the matrix A from a list of Y vectors.
cylinder_fitting/fitting.py
def calc_A(Ys): '''Return the matrix A from a list of Y vectors.''' return sum(np.dot(np.reshape(Y, (3,1)), np.reshape(Y, (1, 3))) for Y in Ys)
def calc_A(Ys): '''Return the matrix A from a list of Y vectors.''' return sum(np.dot(np.reshape(Y, (3,1)), np.reshape(Y, (1, 3))) for Y in Ys)
[ "Return", "the", "matrix", "A", "from", "a", "list", "of", "Y", "vectors", "." ]
xingjiepan/cylinder_fitting
python
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/fitting.py#L21-L24
[ "def", "calc_A", "(", "Ys", ")", ":", "return", "sum", "(", "np", ".", "dot", "(", "np", ".", "reshape", "(", "Y", ",", "(", "3", ",", "1", ")", ")", ",", "np", ".", "reshape", "(", "Y", ",", "(", "1", ",", "3", ")", ")", ")", "for", "Y...
f96d79732bc49cbc0cb4b39f008af7ce42aeb213
train
calc_A_hat
Return the A_hat matrix of A given the skew matrix S
cylinder_fitting/fitting.py
def calc_A_hat(A, S): '''Return the A_hat matrix of A given the skew matrix S''' return np.dot(S, np.dot(A, np.transpose(S)))
def calc_A_hat(A, S): '''Return the A_hat matrix of A given the skew matrix S''' return np.dot(S, np.dot(A, np.transpose(S)))
[ "Return", "the", "A_hat", "matrix", "of", "A", "given", "the", "skew", "matrix", "S" ]
xingjiepan/cylinder_fitting
python
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/fitting.py#L26-L28
[ "def", "calc_A_hat", "(", "A", ",", "S", ")", ":", "return", "np", ".", "dot", "(", "S", ",", "np", ".", "dot", "(", "A", ",", "np", ".", "transpose", "(", "S", ")", ")", ")" ]
f96d79732bc49cbc0cb4b39f008af7ce42aeb213
train
preprocess_data
Translate the center of mass (COM) of the data to the origin. Return the prossed data and the shift of the COM
cylinder_fitting/fitting.py
def preprocess_data(Xs_raw): '''Translate the center of mass (COM) of the data to the origin. Return the prossed data and the shift of the COM''' n = len(Xs_raw) Xs_raw_mean = sum(X for X in Xs_raw) / n return [X - Xs_raw_mean for X in Xs_raw], Xs_raw_mean
def preprocess_data(Xs_raw): '''Translate the center of mass (COM) of the data to the origin. Return the prossed data and the shift of the COM''' n = len(Xs_raw) Xs_raw_mean = sum(X for X in Xs_raw) / n return [X - Xs_raw_mean for X in Xs_raw], Xs_raw_mean
[ "Translate", "the", "center", "of", "mass", "(", "COM", ")", "of", "the", "data", "to", "the", "origin", ".", "Return", "the", "prossed", "data", "and", "the", "shift", "of", "the", "COM" ]
xingjiepan/cylinder_fitting
python
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/fitting.py#L30-L36
[ "def", "preprocess_data", "(", "Xs_raw", ")", ":", "n", "=", "len", "(", "Xs_raw", ")", "Xs_raw_mean", "=", "sum", "(", "X", "for", "X", "in", "Xs_raw", ")", "/", "n", "return", "[", "X", "-", "Xs_raw_mean", "for", "X", "in", "Xs_raw", "]", ",", ...
f96d79732bc49cbc0cb4b39f008af7ce42aeb213
train
G
Calculate the G function given a cylinder direction w and a list of data points Xs to be fitted.
cylinder_fitting/fitting.py
def G(w, Xs): '''Calculate the G function given a cylinder direction w and a list of data points Xs to be fitted.''' n = len(Xs) P = projection_matrix(w) Ys = [np.dot(P, X) for X in Xs] A = calc_A(Ys) A_hat = calc_A_hat(A, skew_matrix(w)) u = sum(np.dot(Y, Y) for Y in Ys) / n v...
def G(w, Xs): '''Calculate the G function given a cylinder direction w and a list of data points Xs to be fitted.''' n = len(Xs) P = projection_matrix(w) Ys = [np.dot(P, X) for X in Xs] A = calc_A(Ys) A_hat = calc_A_hat(A, skew_matrix(w)) u = sum(np.dot(Y, Y) for Y in Ys) / n v...
[ "Calculate", "the", "G", "function", "given", "a", "cylinder", "direction", "w", "and", "a", "list", "of", "data", "points", "Xs", "to", "be", "fitted", "." ]
xingjiepan/cylinder_fitting
python
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/fitting.py#L38-L51
[ "def", "G", "(", "w", ",", "Xs", ")", ":", "n", "=", "len", "(", "Xs", ")", "P", "=", "projection_matrix", "(", "w", ")", "Ys", "=", "[", "np", ".", "dot", "(", "P", ",", "X", ")", "for", "X", "in", "Xs", "]", "A", "=", "calc_A", "(", "...
f96d79732bc49cbc0cb4b39f008af7ce42aeb213
train
C
Calculate the cylinder center given the cylinder direction and a list of data points.
cylinder_fitting/fitting.py
def C(w, Xs): '''Calculate the cylinder center given the cylinder direction and a list of data points. ''' n = len(Xs) P = projection_matrix(w) Ys = [np.dot(P, X) for X in Xs] A = calc_A(Ys) A_hat = calc_A_hat(A, skew_matrix(w)) return np.dot(A_hat, sum(np.dot(Y, Y) * Y for Y in Ys...
def C(w, Xs): '''Calculate the cylinder center given the cylinder direction and a list of data points. ''' n = len(Xs) P = projection_matrix(w) Ys = [np.dot(P, X) for X in Xs] A = calc_A(Ys) A_hat = calc_A_hat(A, skew_matrix(w)) return np.dot(A_hat, sum(np.dot(Y, Y) * Y for Y in Ys...
[ "Calculate", "the", "cylinder", "center", "given", "the", "cylinder", "direction", "and", "a", "list", "of", "data", "points", "." ]
xingjiepan/cylinder_fitting
python
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/fitting.py#L53-L63
[ "def", "C", "(", "w", ",", "Xs", ")", ":", "n", "=", "len", "(", "Xs", ")", "P", "=", "projection_matrix", "(", "w", ")", "Ys", "=", "[", "np", ".", "dot", "(", "P", ",", "X", ")", "for", "X", "in", "Xs", "]", "A", "=", "calc_A", "(", "...
f96d79732bc49cbc0cb4b39f008af7ce42aeb213
train
r
Calculate the radius given the cylinder direction and a list of data points.
cylinder_fitting/fitting.py
def r(w, Xs): '''Calculate the radius given the cylinder direction and a list of data points. ''' n = len(Xs) P = projection_matrix(w) c = C(w, Xs) return np.sqrt(sum(np.dot(c - X, np.dot(P, c - X)) for X in Xs) / n)
def r(w, Xs): '''Calculate the radius given the cylinder direction and a list of data points. ''' n = len(Xs) P = projection_matrix(w) c = C(w, Xs) return np.sqrt(sum(np.dot(c - X, np.dot(P, c - X)) for X in Xs) / n)
[ "Calculate", "the", "radius", "given", "the", "cylinder", "direction", "and", "a", "list", "of", "data", "points", "." ]
xingjiepan/cylinder_fitting
python
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/fitting.py#L65-L73
[ "def", "r", "(", "w", ",", "Xs", ")", ":", "n", "=", "len", "(", "Xs", ")", "P", "=", "projection_matrix", "(", "w", ")", "c", "=", "C", "(", "w", ",", "Xs", ")", "return", "np", ".", "sqrt", "(", "sum", "(", "np", ".", "dot", "(", "c", ...
f96d79732bc49cbc0cb4b39f008af7ce42aeb213
train
fit
Fit a list of data points to a cylinder surface. The algorithm implemented here is from David Eberly's paper "Fitting 3D Data with a Cylinder" from https://www.geometrictools.com/Documentation/CylinderFitting.pdf Arguments: data - A list of 3D data points to be fitted. guess_angles[0] - Gu...
cylinder_fitting/fitting.py
def fit(data, guess_angles=None): '''Fit a list of data points to a cylinder surface. The algorithm implemented here is from David Eberly's paper "Fitting 3D Data with a Cylinder" from https://www.geometrictools.com/Documentation/CylinderFitting.pdf Arguments: data - A list of 3D data points t...
def fit(data, guess_angles=None): '''Fit a list of data points to a cylinder surface. The algorithm implemented here is from David Eberly's paper "Fitting 3D Data with a Cylinder" from https://www.geometrictools.com/Documentation/CylinderFitting.pdf Arguments: data - A list of 3D data points t...
[ "Fit", "a", "list", "of", "data", "points", "to", "a", "cylinder", "surface", ".", "The", "algorithm", "implemented", "here", "is", "from", "David", "Eberly", "s", "paper", "Fitting", "3D", "Data", "with", "a", "Cylinder", "from", "https", ":", "//", "ww...
xingjiepan/cylinder_fitting
python
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/fitting.py#L75-L114
[ "def", "fit", "(", "data", ",", "guess_angles", "=", "None", ")", ":", "Xs", ",", "t", "=", "preprocess_data", "(", "data", ")", "# Set the start points", "start_points", "=", "[", "(", "0", ",", "0", ")", ",", "(", "np", ".", "pi", "/", "2", ",", ...
f96d79732bc49cbc0cb4b39f008af7ce42aeb213
train
Producer.connect_producer
A Kafka client that publishes records to the Kafka cluster. Keyword Arguments: - ``bootstrap_servers``: 'host[:port]' string (or list of 'host[:port]' strings) that the producer should contact to bootstrap initial cluster metadata. This does not have to be the full node list. ...
KafkaLibrary/Producer.py
def connect_producer(self, bootstrap_servers='127.0.0.1:9092', client_id='Robot', **kwargs): """A Kafka client that publishes records to the Kafka cluster. Keyword Arguments: - ``bootstrap_servers``: 'host[:port]' string (or list of 'host[:port]' strings) that the producer should ...
def connect_producer(self, bootstrap_servers='127.0.0.1:9092', client_id='Robot', **kwargs): """A Kafka client that publishes records to the Kafka cluster. Keyword Arguments: - ``bootstrap_servers``: 'host[:port]' string (or list of 'host[:port]' strings) that the producer should ...
[ "A", "Kafka", "client", "that", "publishes", "records", "to", "the", "Kafka", "cluster", ".", "Keyword", "Arguments", ":", "-", "bootstrap_servers", ":", "host", "[", ":", "port", "]", "string", "(", "or", "list", "of", "host", "[", ":", "port", "]", "...
s4int/robotframework-KafkaLibrary
python
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Producer.py#L7-L25
[ "def", "connect_producer", "(", "self", ",", "bootstrap_servers", "=", "'127.0.0.1:9092'", ",", "client_id", "=", "'Robot'", ",", "*", "*", "kwargs", ")", ":", "self", ".", "producer", "=", "KafkaProducer", "(", "bootstrap_servers", "=", "bootstrap_servers", ","...
1f05193958488a5d2e5de19a398ada9edab30d87
train
Producer.send
Publish a message to a topic. - ``topic`` (str): topic where the message will be published - ``value``: message value. Must be type bytes, or be serializable to bytes via configured value_serializer. If value is None, key is required and message acts as a `delete`. - ``timeout`` ...
KafkaLibrary/Producer.py
def send(self, topic, value=None, timeout=60, key=None, partition=None, timestamp_ms=None): """Publish a message to a topic. - ``topic`` (str): topic where the message will be published - ``value``: message value. Must be type bytes, or be serializable to bytes via configured value_serializer. ...
def send(self, topic, value=None, timeout=60, key=None, partition=None, timestamp_ms=None): """Publish a message to a topic. - ``topic`` (str): topic where the message will be published - ``value``: message value. Must be type bytes, or be serializable to bytes via configured value_serializer. ...
[ "Publish", "a", "message", "to", "a", "topic", "." ]
s4int/robotframework-KafkaLibrary
python
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Producer.py#L27-L44
[ "def", "send", "(", "self", ",", "topic", ",", "value", "=", "None", ",", "timeout", "=", "60", ",", "key", "=", "None", ",", "partition", "=", "None", ",", "timestamp_ms", "=", "None", ")", ":", "future", "=", "self", ".", "producer", ".", "send",...
1f05193958488a5d2e5de19a398ada9edab30d87
train
Consumer.connect_consumer
Connect kafka consumer. Keyword Arguments: - ``bootstrap_servers``: 'host[:port]' string (or list of 'host[:port]' strings) that the consumer should contact to bootstrap initial cluster metadata. This does not have to be the full node list. It just needs to have ...
KafkaLibrary/Consumer.py
def connect_consumer( self, bootstrap_servers='127.0.0.1:9092', client_id='Robot', group_id=None, auto_offset_reset='latest', enable_auto_commit=True, **kwargs ): """Connect kafka consumer. Keyword Arguments: ...
def connect_consumer( self, bootstrap_servers='127.0.0.1:9092', client_id='Robot', group_id=None, auto_offset_reset='latest', enable_auto_commit=True, **kwargs ): """Connect kafka consumer. Keyword Arguments: ...
[ "Connect", "kafka", "consumer", ".", "Keyword", "Arguments", ":", "-", "bootstrap_servers", ":", "host", "[", ":", "port", "]", "string", "(", "or", "list", "of", "host", "[", ":", "port", "]", "strings", ")", "that", "the", "consumer", "should", "contac...
s4int/robotframework-KafkaLibrary
python
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Consumer.py#L7-L53
[ "def", "connect_consumer", "(", "self", ",", "bootstrap_servers", "=", "'127.0.0.1:9092'", ",", "client_id", "=", "'Robot'", ",", "group_id", "=", "None", ",", "auto_offset_reset", "=", "'latest'", ",", "enable_auto_commit", "=", "True", ",", "*", "*", "kwargs",...
1f05193958488a5d2e5de19a398ada9edab30d87
train
Consumer.assign_to_topic_partition
Assign a list of TopicPartitions to this consumer. - ``partitions`` (list of `TopicPartition`): Assignment for this instance.
KafkaLibrary/Consumer.py
def assign_to_topic_partition(self, topic_partition=None): """Assign a list of TopicPartitions to this consumer. - ``partitions`` (list of `TopicPartition`): Assignment for this instance. """ if isinstance(topic_partition, TopicPartition): topic_partition = [topic_p...
def assign_to_topic_partition(self, topic_partition=None): """Assign a list of TopicPartitions to this consumer. - ``partitions`` (list of `TopicPartition`): Assignment for this instance. """ if isinstance(topic_partition, TopicPartition): topic_partition = [topic_p...
[ "Assign", "a", "list", "of", "TopicPartitions", "to", "this", "consumer", ".", "-", "partitions", "(", "list", "of", "TopicPartition", ")", ":", "Assignment", "for", "this", "instance", "." ]
s4int/robotframework-KafkaLibrary
python
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Consumer.py#L75-L84
[ "def", "assign_to_topic_partition", "(", "self", ",", "topic_partition", "=", "None", ")", ":", "if", "isinstance", "(", "topic_partition", ",", "TopicPartition", ")", ":", "topic_partition", "=", "[", "topic_partition", "]", "if", "not", "self", ".", "_is_assig...
1f05193958488a5d2e5de19a398ada9edab30d87
train
Consumer.subscribe_topic
Subscribe to a list of topics, or a topic regex pattern. - ``topics`` (list): List of topics for subscription. - ``pattern`` (str): Pattern to match available topics. You must provide either topics or pattern, but not both.
KafkaLibrary/Consumer.py
def subscribe_topic(self, topics=[], pattern=None): """Subscribe to a list of topics, or a topic regex pattern. - ``topics`` (list): List of topics for subscription. - ``pattern`` (str): Pattern to match available topics. You must provide either topics or pattern, but not both...
def subscribe_topic(self, topics=[], pattern=None): """Subscribe to a list of topics, or a topic regex pattern. - ``topics`` (list): List of topics for subscription. - ``pattern`` (str): Pattern to match available topics. You must provide either topics or pattern, but not both...
[ "Subscribe", "to", "a", "list", "of", "topics", "or", "a", "topic", "regex", "pattern", ".", "-", "topics", "(", "list", ")", ":", "List", "of", "topics", "for", "subscription", ".", "-", "pattern", "(", "str", ")", ":", "Pattern", "to", "match", "av...
s4int/robotframework-KafkaLibrary
python
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Consumer.py#L86-L96
[ "def", "subscribe_topic", "(", "self", ",", "topics", "=", "[", "]", ",", "pattern", "=", "None", ")", ":", "if", "not", "isinstance", "(", "topics", ",", "list", ")", ":", "topics", "=", "[", "topics", "]", "self", ".", "consumer", ".", "subscribe",...
1f05193958488a5d2e5de19a398ada9edab30d87
train
Consumer.get_position
Return offset of the next record that will be fetched. - ``topic_partition`` (TopicPartition): Partition to check
KafkaLibrary/Consumer.py
def get_position(self, topic_partition=None): """Return offset of the next record that will be fetched. - ``topic_partition`` (TopicPartition): Partition to check """ if isinstance(topic_partition, TopicPartition): return self.consumer.position(topic_partition) ...
def get_position(self, topic_partition=None): """Return offset of the next record that will be fetched. - ``topic_partition`` (TopicPartition): Partition to check """ if isinstance(topic_partition, TopicPartition): return self.consumer.position(topic_partition) ...
[ "Return", "offset", "of", "the", "next", "record", "that", "will", "be", "fetched", ".", "-", "topic_partition", "(", "TopicPartition", ")", ":", "Partition", "to", "check" ]
s4int/robotframework-KafkaLibrary
python
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Consumer.py#L98-L107
[ "def", "get_position", "(", "self", ",", "topic_partition", "=", "None", ")", ":", "if", "isinstance", "(", "topic_partition", ",", "TopicPartition", ")", ":", "return", "self", ".", "consumer", ".", "position", "(", "topic_partition", ")", "else", ":", "rai...
1f05193958488a5d2e5de19a398ada9edab30d87
train
Consumer.seek
Manually specify the fetch offset for a TopicPartition. - ``offset``: Message offset in partition - ``topic_partition`` (`TopicPartition`): Partition for seek operation
KafkaLibrary/Consumer.py
def seek(self, offset, topic_partition=None): """Manually specify the fetch offset for a TopicPartition. - ``offset``: Message offset in partition - ``topic_partition`` (`TopicPartition`): Partition for seek operation """ if isinstance(topic_partition, TopicPartition): ...
def seek(self, offset, topic_partition=None): """Manually specify the fetch offset for a TopicPartition. - ``offset``: Message offset in partition - ``topic_partition`` (`TopicPartition`): Partition for seek operation """ if isinstance(topic_partition, TopicPartition): ...
[ "Manually", "specify", "the", "fetch", "offset", "for", "a", "TopicPartition", ".", "-", "offset", ":", "Message", "offset", "in", "partition", "-", "topic_partition", "(", "TopicPartition", ")", ":", "Partition", "for", "seek", "operation" ]
s4int/robotframework-KafkaLibrary
python
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Consumer.py#L109-L119
[ "def", "seek", "(", "self", ",", "offset", ",", "topic_partition", "=", "None", ")", ":", "if", "isinstance", "(", "topic_partition", ",", "TopicPartition", ")", ":", "self", ".", "consumer", ".", "seek", "(", "topic_partition", ",", "offset", "=", "offset...
1f05193958488a5d2e5de19a398ada9edab30d87
train
Consumer.seek_to_beginning
Seek to the oldest available offset for partitions. - ``topic_partition``: Optionally provide specific TopicPartitions, otherwise default to all assigned partitions.
KafkaLibrary/Consumer.py
def seek_to_beginning(self, topic_partition=None): """Seek to the oldest available offset for partitions. - ``topic_partition``: Optionally provide specific TopicPartitions, otherwise default to all assigned partitions. """ if isinstance(topic_partition, TopicPartitio...
def seek_to_beginning(self, topic_partition=None): """Seek to the oldest available offset for partitions. - ``topic_partition``: Optionally provide specific TopicPartitions, otherwise default to all assigned partitions. """ if isinstance(topic_partition, TopicPartitio...
[ "Seek", "to", "the", "oldest", "available", "offset", "for", "partitions", ".", "-", "topic_partition", ":", "Optionally", "provide", "specific", "TopicPartitions", "otherwise", "default", "to", "all", "assigned", "partitions", "." ]
s4int/robotframework-KafkaLibrary
python
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Consumer.py#L121-L131
[ "def", "seek_to_beginning", "(", "self", ",", "topic_partition", "=", "None", ")", ":", "if", "isinstance", "(", "topic_partition", ",", "TopicPartition", ")", ":", "self", ".", "consumer", ".", "seek_to_beginning", "(", "topic_partition", ")", "else", ":", "r...
1f05193958488a5d2e5de19a398ada9edab30d87
train
Consumer.seek_to_end
Seek to the most recent available offset for partitions. - ``topic_partition``: Optionally provide specific `TopicPartitions`, otherwise default to all assigned partitions.
KafkaLibrary/Consumer.py
def seek_to_end(self, topic_partition=None): """Seek to the most recent available offset for partitions. - ``topic_partition``: Optionally provide specific `TopicPartitions`, otherwise default to all assigned partitions. """ if isinstance(topic_partition, TopicPartiti...
def seek_to_end(self, topic_partition=None): """Seek to the most recent available offset for partitions. - ``topic_partition``: Optionally provide specific `TopicPartitions`, otherwise default to all assigned partitions. """ if isinstance(topic_partition, TopicPartiti...
[ "Seek", "to", "the", "most", "recent", "available", "offset", "for", "partitions", ".", "-", "topic_partition", ":", "Optionally", "provide", "specific", "TopicPartitions", "otherwise", "default", "to", "all", "assigned", "partitions", "." ]
s4int/robotframework-KafkaLibrary
python
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Consumer.py#L133-L143
[ "def", "seek_to_end", "(", "self", ",", "topic_partition", "=", "None", ")", ":", "if", "isinstance", "(", "topic_partition", ",", "TopicPartition", ")", ":", "self", ".", "consumer", ".", "seek_to_end", "(", "topic_partition", ")", "else", ":", "raise", "Ty...
1f05193958488a5d2e5de19a398ada9edab30d87
train
Consumer.get_number_of_messages_in_topics
Retrun number of messages in topics. - ``topics`` (list): list of topics.
KafkaLibrary/Consumer.py
def get_number_of_messages_in_topics(self, topics): """Retrun number of messages in topics. - ``topics`` (list): list of topics. """ if not isinstance(topics, list): topics = [topics] number_of_messages = 0 for t in topics: part = self.g...
def get_number_of_messages_in_topics(self, topics): """Retrun number of messages in topics. - ``topics`` (list): list of topics. """ if not isinstance(topics, list): topics = [topics] number_of_messages = 0 for t in topics: part = self.g...
[ "Retrun", "number", "of", "messages", "in", "topics", ".", "-", "topics", "(", "list", ")", ":", "list", "of", "topics", "." ]
s4int/robotframework-KafkaLibrary
python
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Consumer.py#L150-L165
[ "def", "get_number_of_messages_in_topics", "(", "self", ",", "topics", ")", ":", "if", "not", "isinstance", "(", "topics", ",", "list", ")", ":", "topics", "=", "[", "topics", "]", "number_of_messages", "=", "0", "for", "t", "in", "topics", ":", "part", ...
1f05193958488a5d2e5de19a398ada9edab30d87
train
Consumer.get_number_of_messages_in_topicpartition
Return number of messages in TopicPartition. - ``topic_partition`` (list of TopicPartition)
KafkaLibrary/Consumer.py
def get_number_of_messages_in_topicpartition(self, topic_partition=None): """Return number of messages in TopicPartition. - ``topic_partition`` (list of TopicPartition) """ if isinstance(topic_partition, TopicPartition): topic_partition = [topic_partition] ...
def get_number_of_messages_in_topicpartition(self, topic_partition=None): """Return number of messages in TopicPartition. - ``topic_partition`` (list of TopicPartition) """ if isinstance(topic_partition, TopicPartition): topic_partition = [topic_partition] ...
[ "Return", "number", "of", "messages", "in", "TopicPartition", ".", "-", "topic_partition", "(", "list", "of", "TopicPartition", ")" ]
s4int/robotframework-KafkaLibrary
python
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Consumer.py#L167-L194
[ "def", "get_number_of_messages_in_topicpartition", "(", "self", ",", "topic_partition", "=", "None", ")", ":", "if", "isinstance", "(", "topic_partition", ",", "TopicPartition", ")", ":", "topic_partition", "=", "[", "topic_partition", "]", "number_of_messages", "=", ...
1f05193958488a5d2e5de19a398ada9edab30d87
train
Consumer.poll
Fetch data from assigned topics / partitions. - ``max_records`` (int): maximum number of records to poll. Default: Inherit value from max_poll_records. - ``timeout_ms`` (int): Milliseconds spent waiting in poll if data is not available in the buffer. If 0, returns immediately with any...
KafkaLibrary/Consumer.py
def poll(self, timeout_ms=0, max_records=None): """Fetch data from assigned topics / partitions. - ``max_records`` (int): maximum number of records to poll. Default: Inherit value from max_poll_records. - ``timeout_ms`` (int): Milliseconds spent waiting in poll if data is not available ...
def poll(self, timeout_ms=0, max_records=None): """Fetch data from assigned topics / partitions. - ``max_records`` (int): maximum number of records to poll. Default: Inherit value from max_poll_records. - ``timeout_ms`` (int): Milliseconds spent waiting in poll if data is not available ...
[ "Fetch", "data", "from", "assigned", "topics", "/", "partitions", ".", "-", "max_records", "(", "int", ")", ":", "maximum", "number", "of", "records", "to", "poll", ".", "Default", ":", "Inherit", "value", "from", "max_poll_records", ".", "-", "timeout_ms", ...
s4int/robotframework-KafkaLibrary
python
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/Consumer.py#L196-L211
[ "def", "poll", "(", "self", ",", "timeout_ms", "=", "0", ",", "max_records", "=", "None", ")", ":", "messages", "=", "self", ".", "consumer", ".", "poll", "(", "timeout_ms", "=", "timeout_ms", ",", "max_records", "=", "max_records", ")", "result", "=", ...
1f05193958488a5d2e5de19a398ada9edab30d87
train
EmailView.get
Validate an email with the given key
colab/accounts/views.py
def get(self, request, key): """Validate an email with the given key""" try: email_val = EmailAddressValidation.objects.get(validation_key=key) except EmailAddressValidation.DoesNotExist: messages.error(request, _('The email address you are trying to ' ...
def get(self, request, key): """Validate an email with the given key""" try: email_val = EmailAddressValidation.objects.get(validation_key=key) except EmailAddressValidation.DoesNotExist: messages.error(request, _('The email address you are trying to ' ...
[ "Validate", "an", "email", "with", "the", "given", "key" ]
colab/colab
python
https://github.com/colab/colab/blob/2ad099231e620bec647363b27d38006eca71e13b/colab/accounts/views.py#L91-L123
[ "def", "get", "(", "self", ",", "request", ",", "key", ")", ":", "try", ":", "email_val", "=", "EmailAddressValidation", ".", "objects", ".", "get", "(", "validation_key", "=", "key", ")", "except", "EmailAddressValidation", ".", "DoesNotExist", ":", "messag...
2ad099231e620bec647363b27d38006eca71e13b
train
EmailView.delete
Remove an email address, validated or not.
colab/accounts/views.py
def delete(self, request, key): """Remove an email address, validated or not.""" request.DELETE = http.QueryDict(request.body) email_addr = request.DELETE.get('email') user_id = request.DELETE.get('user') if not email_addr: return http.HttpResponseBadRequest() ...
def delete(self, request, key): """Remove an email address, validated or not.""" request.DELETE = http.QueryDict(request.body) email_addr = request.DELETE.get('email') user_id = request.DELETE.get('user') if not email_addr: return http.HttpResponseBadRequest() ...
[ "Remove", "an", "email", "address", "validated", "or", "not", "." ]
colab/colab
python
https://github.com/colab/colab/blob/2ad099231e620bec647363b27d38006eca71e13b/colab/accounts/views.py#L151-L178
[ "def", "delete", "(", "self", ",", "request", ",", "key", ")", ":", "request", ".", "DELETE", "=", "http", ".", "QueryDict", "(", "request", ".", "body", ")", "email_addr", "=", "request", ".", "DELETE", ".", "get", "(", "'email'", ")", "user_id", "=...
2ad099231e620bec647363b27d38006eca71e13b
train
EmailView.update
Set an email address as primary address.
colab/accounts/views.py
def update(self, request, key): """Set an email address as primary address.""" request.UPDATE = http.QueryDict(request.body) email_addr = request.UPDATE.get('email') user_id = request.UPDATE.get('user') if not email_addr: return http.HttpResponseBadRequest() ...
def update(self, request, key): """Set an email address as primary address.""" request.UPDATE = http.QueryDict(request.body) email_addr = request.UPDATE.get('email') user_id = request.UPDATE.get('user') if not email_addr: return http.HttpResponseBadRequest() ...
[ "Set", "an", "email", "address", "as", "primary", "address", "." ]
colab/colab
python
https://github.com/colab/colab/blob/2ad099231e620bec647363b27d38006eca71e13b/colab/accounts/views.py#L181-L199
[ "def", "update", "(", "self", ",", "request", ",", "key", ")", ":", "request", ".", "UPDATE", "=", "http", ".", "QueryDict", "(", "request", ".", "body", ")", "email_addr", "=", "request", ".", "UPDATE", ".", "get", "(", "'email'", ")", "user_id", "=...
2ad099231e620bec647363b27d38006eca71e13b
train
SignupView.is_logged
Check if a logged user is trying to access the register page. If so, redirect him/her to his/her profile
colab/accounts/views.py
def is_logged(self, user): """Check if a logged user is trying to access the register page. If so, redirect him/her to his/her profile""" response = None if user.is_authenticated(): if not user.needs_update: response = redirect('user_profile', username=use...
def is_logged(self, user): """Check if a logged user is trying to access the register page. If so, redirect him/her to his/her profile""" response = None if user.is_authenticated(): if not user.needs_update: response = redirect('user_profile', username=use...
[ "Check", "if", "a", "logged", "user", "is", "trying", "to", "access", "the", "register", "page", ".", "If", "so", "redirect", "him", "/", "her", "to", "his", "/", "her", "profile" ]
colab/colab
python
https://github.com/colab/colab/blob/2ad099231e620bec647363b27d38006eca71e13b/colab/accounts/views.py#L227-L236
[ "def", "is_logged", "(", "self", ",", "user", ")", ":", "response", "=", "None", "if", "user", ".", "is_authenticated", "(", ")", ":", "if", "not", "user", ".", "needs_update", ":", "response", "=", "redirect", "(", "'user_profile'", ",", "username", "="...
2ad099231e620bec647363b27d38006eca71e13b
train
get_env_setting
Get the environment setting or return exception
colab/settings.py
def get_env_setting(setting): """ Get the environment setting or return exception """ try: return os.environ[setting] except KeyError: error_msg = "Set the %s env variable" % setting raise ImproperlyConfigured(error_msg)
def get_env_setting(setting): """ Get the environment setting or return exception """ try: return os.environ[setting] except KeyError: error_msg = "Set the %s env variable" % setting raise ImproperlyConfigured(error_msg)
[ "Get", "the", "environment", "setting", "or", "return", "exception" ]
colab/colab
python
https://github.com/colab/colab/blob/2ad099231e620bec647363b27d38006eca71e13b/colab/settings.py#L101-L107
[ "def", "get_env_setting", "(", "setting", ")", ":", "try", ":", "return", "os", ".", "environ", "[", "setting", "]", "except", "KeyError", ":", "error_msg", "=", "\"Set the %s env variable\"", "%", "setting", "raise", "ImproperlyConfigured", "(", "error_msg", ")...
2ad099231e620bec647363b27d38006eca71e13b
train
parse_json
This function will use the custom JsonDecoder and the conventions.mappers to recreate your custom object in the parse json string state just call this method with the json_string your complete object_type and with your mappers dict. the mappers dict must contain in the key the object_type (ex. User) and the...
pyravendb/tools/custom_decoder.py
def parse_json(json_string, object_type, mappers): """ This function will use the custom JsonDecoder and the conventions.mappers to recreate your custom object in the parse json string state just call this method with the json_string your complete object_type and with your mappers dict. the mappers ...
def parse_json(json_string, object_type, mappers): """ This function will use the custom JsonDecoder and the conventions.mappers to recreate your custom object in the parse json string state just call this method with the json_string your complete object_type and with your mappers dict. the mappers ...
[ "This", "function", "will", "use", "the", "custom", "JsonDecoder", "and", "the", "conventions", ".", "mappers", "to", "recreate", "your", "custom", "object", "in", "the", "parse", "json", "string", "state", "just", "call", "this", "method", "with", "the", "j...
ravendb/ravendb-python-client
python
https://github.com/ravendb/ravendb-python-client/blob/383739db2594303e3cc469134aa16156f6f80acd/pyravendb/tools/custom_decoder.py#L28-L49
[ "def", "parse_json", "(", "json_string", ",", "object_type", ",", "mappers", ")", ":", "obj", "=", "json", ".", "loads", "(", "json_string", ",", "cls", "=", "JsonDecoder", ",", "object_mapper", "=", "mappers", ".", "get", "(", "object_type", ",", "None", ...
383739db2594303e3cc469134aa16156f6f80acd
train
validate_social_account
Verifies if a social account is valid. Examples: >>> validate_social_account('seocam', 'http://twitter.com') True >>> validate_social_account('seocam-fake-should-fail', 'http://twitter.com') False
colab/accounts/utils/validators.py
def validate_social_account(account, url): """Verifies if a social account is valid. Examples: >>> validate_social_account('seocam', 'http://twitter.com') True >>> validate_social_account('seocam-fake-should-fail', 'http://twitter.com') False """ requ...
def validate_social_account(account, url): """Verifies if a social account is valid. Examples: >>> validate_social_account('seocam', 'http://twitter.com') True >>> validate_social_account('seocam-fake-should-fail', 'http://twitter.com') False """ requ...
[ "Verifies", "if", "a", "social", "account", "is", "valid", "." ]
colab/colab
python
https://github.com/colab/colab/blob/2ad099231e620bec647363b27d38006eca71e13b/colab/accounts/utils/validators.py#L6-L28
[ "def", "validate_social_account", "(", "account", ",", "url", ")", ":", "request", "=", "urllib2", ".", "Request", "(", "urlparse", ".", "urljoin", "(", "url", ",", "account", ")", ")", "request", ".", "get_method", "=", "lambda", ":", "'HEAD'", "try", "...
2ad099231e620bec647363b27d38006eca71e13b
train
fitting_rmsd
Calculate the RMSD of fitting.
cylinder_fitting/analysis.py
def fitting_rmsd(w_fit, C_fit, r_fit, Xs): '''Calculate the RMSD of fitting.''' return np.sqrt(sum((geometry.point_line_distance(p, C_fit, w_fit) - r_fit) ** 2 for p in Xs) / len(Xs))
def fitting_rmsd(w_fit, C_fit, r_fit, Xs): '''Calculate the RMSD of fitting.''' return np.sqrt(sum((geometry.point_line_distance(p, C_fit, w_fit) - r_fit) ** 2 for p in Xs) / len(Xs))
[ "Calculate", "the", "RMSD", "of", "fitting", "." ]
xingjiepan/cylinder_fitting
python
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/analysis.py#L6-L9
[ "def", "fitting_rmsd", "(", "w_fit", ",", "C_fit", ",", "r_fit", ",", "Xs", ")", ":", "return", "np", ".", "sqrt", "(", "sum", "(", "(", "geometry", ".", "point_line_distance", "(", "p", ",", "C_fit", ",", "w_fit", ")", "-", "r_fit", ")", "**", "2"...
f96d79732bc49cbc0cb4b39f008af7ce42aeb213
train
IncrementalJsonParser.basic_parse
Iterator yielding unprefixed events. Parameters: - response: a stream response from requests
pyravendb/store/stream.py
def basic_parse(response, buf_size=ijson.backend.BUFSIZE): """ Iterator yielding unprefixed events. Parameters: - response: a stream response from requests """ lexer = iter(IncrementalJsonParser.lexer(response, buf_size)) for value in ijson.backend.parse_value(l...
def basic_parse(response, buf_size=ijson.backend.BUFSIZE): """ Iterator yielding unprefixed events. Parameters: - response: a stream response from requests """ lexer = iter(IncrementalJsonParser.lexer(response, buf_size)) for value in ijson.backend.parse_value(l...
[ "Iterator", "yielding", "unprefixed", "events", "." ]
ravendb/ravendb-python-client
python
https://github.com/ravendb/ravendb-python-client/blob/383739db2594303e3cc469134aa16156f6f80acd/pyravendb/store/stream.py#L13-L29
[ "def", "basic_parse", "(", "response", ",", "buf_size", "=", "ijson", ".", "backend", ".", "BUFSIZE", ")", ":", "lexer", "=", "iter", "(", "IncrementalJsonParser", ".", "lexer", "(", "response", ",", "buf_size", ")", ")", "for", "value", "in", "ijson", "...
383739db2594303e3cc469134aa16156f6f80acd
train
KafkaLibrary.connect_to_kafka
Connect to kafka - ``bootstrap_servers``: default 127.0.0.1:9092 - ``client_id``: default: Robot
KafkaLibrary/__init__.py
def connect_to_kafka(self, bootstrap_servers='127.0.0.1:9092', auto_offset_reset='latest', client_id='Robot', **kwargs ): """Connect to kafka - ``bootstrap_servers``: default 127.0.0.1:9092 - ``cl...
def connect_to_kafka(self, bootstrap_servers='127.0.0.1:9092', auto_offset_reset='latest', client_id='Robot', **kwargs ): """Connect to kafka - ``bootstrap_servers``: default 127.0.0.1:9092 - ``cl...
[ "Connect", "to", "kafka", "-", "bootstrap_servers", ":", "default", "127", ".", "0", ".", "0", ".", "1", ":", "9092", "-", "client_id", ":", "default", ":", "Robot" ]
s4int/robotframework-KafkaLibrary
python
https://github.com/s4int/robotframework-KafkaLibrary/blob/1f05193958488a5d2e5de19a398ada9edab30d87/KafkaLibrary/__init__.py#L14-L30
[ "def", "connect_to_kafka", "(", "self", ",", "bootstrap_servers", "=", "'127.0.0.1:9092'", ",", "auto_offset_reset", "=", "'latest'", ",", "client_id", "=", "'Robot'", ",", "*", "*", "kwargs", ")", ":", "self", ".", "connect_consumer", "(", "bootstrap_servers", ...
1f05193958488a5d2e5de19a398ada9edab30d87
train
DocumentSubscriptions.drop_connection
Force server to close current client subscription connection to the server @param str name: The name of the subscription @param str database: The name of the database
pyravendb/subscriptions/document_subscriptions.py
def drop_connection(self, name, database=None): """ Force server to close current client subscription connection to the server @param str name: The name of the subscription @param str database: The name of the database """ request_executor = self._store.get_request_execut...
def drop_connection(self, name, database=None): """ Force server to close current client subscription connection to the server @param str name: The name of the subscription @param str database: The name of the database """ request_executor = self._store.get_request_execut...
[ "Force", "server", "to", "close", "current", "client", "subscription", "connection", "to", "the", "server" ]
ravendb/ravendb-python-client
python
https://github.com/ravendb/ravendb-python-client/blob/383739db2594303e3cc469134aa16156f6f80acd/pyravendb/subscriptions/document_subscriptions.py#L64-L72
[ "def", "drop_connection", "(", "self", ",", "name", ",", "database", "=", "None", ")", ":", "request_executor", "=", "self", ".", "_store", ".", "get_request_executor", "(", "database", ")", "command", "=", "DropSubscriptionConnectionCommand", "(", "name", ")", ...
383739db2594303e3cc469134aa16156f6f80acd
train
execute_from_command_line
A simple method that runs a ManagementUtility.
colab/utils/runner.py
def execute_from_command_line(argv=None): """ A simple method that runs a ManagementUtility. """ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "colab.settings") from django.conf import settings if not hasattr(settings, 'SECRET_KEY') and 'initconfig' in sys.argv: command = initconfig.C...
def execute_from_command_line(argv=None): """ A simple method that runs a ManagementUtility. """ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "colab.settings") from django.conf import settings if not hasattr(settings, 'SECRET_KEY') and 'initconfig' in sys.argv: command = initconfig.C...
[ "A", "simple", "method", "that", "runs", "a", "ManagementUtility", "." ]
colab/colab
python
https://github.com/colab/colab/blob/2ad099231e620bec647363b27d38006eca71e13b/colab/utils/runner.py#L9-L21
[ "def", "execute_from_command_line", "(", "argv", "=", "None", ")", ":", "os", ".", "environ", ".", "setdefault", "(", "\"DJANGO_SETTINGS_MODULE\"", ",", "\"colab.settings\"", ")", "from", "django", ".", "conf", "import", "settings", "if", "not", "hasattr", "(", ...
2ad099231e620bec647363b27d38006eca71e13b
train
dashboard
Dashboard page
colab/home/views.py
def dashboard(request): """Dashboard page""" user = None if request.user.is_authenticated(): user = User.objects.get(username=request.user) latest_results, count_types = get_collaboration_data(user) latest_results.sort(key=lambda elem: elem.modified, reverse=True) context = { ...
def dashboard(request): """Dashboard page""" user = None if request.user.is_authenticated(): user = User.objects.get(username=request.user) latest_results, count_types = get_collaboration_data(user) latest_results.sort(key=lambda elem: elem.modified, reverse=True) context = { ...
[ "Dashboard", "page" ]
colab/colab
python
https://github.com/colab/colab/blob/2ad099231e620bec647363b27d38006eca71e13b/colab/home/views.py#L9-L23
[ "def", "dashboard", "(", "request", ")", ":", "user", "=", "None", "if", "request", ".", "user", ".", "is_authenticated", "(", ")", ":", "user", "=", "User", ".", "objects", ".", "get", "(", "username", "=", "request", ".", "user", ")", "latest_results...
2ad099231e620bec647363b27d38006eca71e13b
train
normalize
Normalize a vector based on its 2 norm.
cylinder_fitting/geometry.py
def normalize(v): '''Normalize a vector based on its 2 norm.''' if 0 == np.linalg.norm(v): return v return v / np.linalg.norm(v)
def normalize(v): '''Normalize a vector based on its 2 norm.''' if 0 == np.linalg.norm(v): return v return v / np.linalg.norm(v)
[ "Normalize", "a", "vector", "based", "on", "its", "2", "norm", "." ]
xingjiepan/cylinder_fitting
python
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/geometry.py#L4-L8
[ "def", "normalize", "(", "v", ")", ":", "if", "0", "==", "np", ".", "linalg", ".", "norm", "(", "v", ")", ":", "return", "v", "return", "v", "/", "np", ".", "linalg", ".", "norm", "(", "v", ")" ]
f96d79732bc49cbc0cb4b39f008af7ce42aeb213
train
rotation_matrix_from_axis_and_angle
Calculate a rotation matrix from an axis and an angle.
cylinder_fitting/geometry.py
def rotation_matrix_from_axis_and_angle(u, theta): '''Calculate a rotation matrix from an axis and an angle.''' x = u[0] y = u[1] z = u[2] s = np.sin(theta) c = np.cos(theta) return np.array([[c + x**2 * (1 - c), x * y * (1 - c) - z * s, x * z * (1 - c) + y * s], ...
def rotation_matrix_from_axis_and_angle(u, theta): '''Calculate a rotation matrix from an axis and an angle.''' x = u[0] y = u[1] z = u[2] s = np.sin(theta) c = np.cos(theta) return np.array([[c + x**2 * (1 - c), x * y * (1 - c) - z * s, x * z * (1 - c) + y * s], ...
[ "Calculate", "a", "rotation", "matrix", "from", "an", "axis", "and", "an", "angle", "." ]
xingjiepan/cylinder_fitting
python
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/geometry.py#L10-L21
[ "def", "rotation_matrix_from_axis_and_angle", "(", "u", ",", "theta", ")", ":", "x", "=", "u", "[", "0", "]", "y", "=", "u", "[", "1", "]", "z", "=", "u", "[", "2", "]", "s", "=", "np", ".", "sin", "(", "theta", ")", "c", "=", "np", ".", "c...
f96d79732bc49cbc0cb4b39f008af7ce42aeb213
train
point_line_distance
Calculate the distance between a point and a line defined by a point and a direction vector.
cylinder_fitting/geometry.py
def point_line_distance(p, l_p, l_v): '''Calculate the distance between a point and a line defined by a point and a direction vector. ''' l_v = normalize(l_v) u = p - l_p return np.linalg.norm(u - np.dot(u, l_v) * l_v)
def point_line_distance(p, l_p, l_v): '''Calculate the distance between a point and a line defined by a point and a direction vector. ''' l_v = normalize(l_v) u = p - l_p return np.linalg.norm(u - np.dot(u, l_v) * l_v)
[ "Calculate", "the", "distance", "between", "a", "point", "and", "a", "line", "defined", "by", "a", "point", "and", "a", "direction", "vector", "." ]
xingjiepan/cylinder_fitting
python
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/geometry.py#L23-L29
[ "def", "point_line_distance", "(", "p", ",", "l_p", ",", "l_v", ")", ":", "l_v", "=", "normalize", "(", "l_v", ")", "u", "=", "p", "-", "l_p", "return", "np", ".", "linalg", ".", "norm", "(", "u", "-", "np", ".", "dot", "(", "u", ",", "l_v", ...
f96d79732bc49cbc0cb4b39f008af7ce42aeb213
train
Query.raw_query
To get all the document that equal to the query @param str query: The rql query @param dict query_parameters: Add query parameters to the query {key : value}
pyravendb/store/session_query.py
def raw_query(self, query, query_parameters=None): """ To get all the document that equal to the query @param str query: The rql query @param dict query_parameters: Add query parameters to the query {key : value} """ self.assert_no_raw_query() if len(self._where...
def raw_query(self, query, query_parameters=None): """ To get all the document that equal to the query @param str query: The rql query @param dict query_parameters: Add query parameters to the query {key : value} """ self.assert_no_raw_query() if len(self._where...
[ "To", "get", "all", "the", "document", "that", "equal", "to", "the", "query" ]
ravendb/ravendb-python-client
python
https://github.com/ravendb/ravendb-python-client/blob/383739db2594303e3cc469134aa16156f6f80acd/pyravendb/store/session_query.py#L383-L401
[ "def", "raw_query", "(", "self", ",", "query", ",", "query_parameters", "=", "None", ")", ":", "self", ".", "assert_no_raw_query", "(", ")", "if", "len", "(", "self", ".", "_where_tokens", ")", "!=", "0", "or", "len", "(", "self", ".", "_select_tokens", ...
383739db2594303e3cc469134aa16156f6f80acd
train
Query.where_equals
To get all the document that equal to the value in the given field_name @param str field_name: The field name in the index you want to query. @param value: The value will be the fields value you want to query @param bool exact: If True getting exact match of the query
pyravendb/store/session_query.py
def where_equals(self, field_name, value, exact=False): """ To get all the document that equal to the value in the given field_name @param str field_name: The field name in the index you want to query. @param value: The value will be the fields value you want to query @param boo...
def where_equals(self, field_name, value, exact=False): """ To get all the document that equal to the value in the given field_name @param str field_name: The field name in the index you want to query. @param value: The value will be the fields value you want to query @param boo...
[ "To", "get", "all", "the", "document", "that", "equal", "to", "the", "value", "in", "the", "given", "field_name" ]
ravendb/ravendb-python-client
python
https://github.com/ravendb/ravendb-python-client/blob/383739db2594303e3cc469134aa16156f6f80acd/pyravendb/store/session_query.py#L403-L427
[ "def", "where_equals", "(", "self", ",", "field_name", ",", "value", ",", "exact", "=", "False", ")", ":", "if", "field_name", "is", "None", ":", "raise", "ValueError", "(", "\"None field_name is invalid\"", ")", "field_name", "=", "Query", ".", "escape_if_nee...
383739db2594303e3cc469134aa16156f6f80acd
train
Query.where
To get all the document that equal to the value within kwargs with the specific key @param bool exact: If True getting exact match of the query @param kwargs: the keys of the kwargs will be the fields name in the index you want to query. The value will be the the fields value you want to query ...
pyravendb/store/session_query.py
def where(self, exact=False, **kwargs): """ To get all the document that equal to the value within kwargs with the specific key @param bool exact: If True getting exact match of the query @param kwargs: the keys of the kwargs will be the fields name in the index you want to query. ...
def where(self, exact=False, **kwargs): """ To get all the document that equal to the value within kwargs with the specific key @param bool exact: If True getting exact match of the query @param kwargs: the keys of the kwargs will be the fields name in the index you want to query. ...
[ "To", "get", "all", "the", "document", "that", "equal", "to", "the", "value", "within", "kwargs", "with", "the", "specific", "key" ]
ravendb/ravendb-python-client
python
https://github.com/ravendb/ravendb-python-client/blob/383739db2594303e3cc469134aa16156f6f80acd/pyravendb/store/session_query.py#L449-L463
[ "def", "where", "(", "self", ",", "exact", "=", "False", ",", "*", "*", "kwargs", ")", ":", "for", "field_name", "in", "kwargs", ":", "if", "isinstance", "(", "kwargs", "[", "field_name", "]", ",", "list", ")", ":", "self", ".", "where_in", "(", "f...
383739db2594303e3cc469134aa16156f6f80acd
train
Query.search
For more complex text searching @param str field_name: The field name in the index you want to query. :type str @param str search_terms: The terms you want to query @param QueryOperator operator: OR or AND
pyravendb/store/session_query.py
def search(self, field_name, search_terms, operator=QueryOperator.OR): """ For more complex text searching @param str field_name: The field name in the index you want to query. :type str @param str search_terms: The terms you want to query @param QueryOperator operator: ...
def search(self, field_name, search_terms, operator=QueryOperator.OR): """ For more complex text searching @param str field_name: The field name in the index you want to query. :type str @param str search_terms: The terms you want to query @param QueryOperator operator: ...
[ "For", "more", "complex", "text", "searching" ]
ravendb/ravendb-python-client
python
https://github.com/ravendb/ravendb-python-client/blob/383739db2594303e3cc469134aa16156f6f80acd/pyravendb/store/session_query.py#L465-L487
[ "def", "search", "(", "self", ",", "field_name", ",", "search_terms", ",", "operator", "=", "QueryOperator", ".", "OR", ")", ":", "if", "field_name", "is", "None", ":", "raise", "ValueError", "(", "\"None field_name is invalid\"", ")", "field_name", "=", "Quer...
383739db2594303e3cc469134aa16156f6f80acd
train
Query.where_ends_with
To get all the document that ends with the value in the giving field_name @param str field_name:The field name in the index you want to query. @param str value: The value will be the fields value you want to query
pyravendb/store/session_query.py
def where_ends_with(self, field_name, value): """ To get all the document that ends with the value in the giving field_name @param str field_name:The field name in the index you want to query. @param str value: The value will be the fields value you want to query """ if ...
def where_ends_with(self, field_name, value): """ To get all the document that ends with the value in the giving field_name @param str field_name:The field name in the index you want to query. @param str value: The value will be the fields value you want to query """ if ...
[ "To", "get", "all", "the", "document", "that", "ends", "with", "the", "value", "in", "the", "giving", "field_name" ]
ravendb/ravendb-python-client
python
https://github.com/ravendb/ravendb-python-client/blob/383739db2594303e3cc469134aa16156f6f80acd/pyravendb/store/session_query.py#L489-L508
[ "def", "where_ends_with", "(", "self", ",", "field_name", ",", "value", ")", ":", "if", "field_name", "is", "None", ":", "raise", "ValueError", "(", "\"None field_name is invalid\"", ")", "field_name", "=", "Query", ".", "escape_if_needed", "(", "field_name", ")...
383739db2594303e3cc469134aa16156f6f80acd
train
Query.where_in
Check that the field has one of the specified values @param str field_name: Name of the field @param str values: The values we wish to query @param bool exact: Getting the exact query (ex. case sensitive)
pyravendb/store/session_query.py
def where_in(self, field_name, values, exact=False): """ Check that the field has one of the specified values @param str field_name: Name of the field @param str values: The values we wish to query @param bool exact: Getting the exact query (ex. case sensitive) """ ...
def where_in(self, field_name, values, exact=False): """ Check that the field has one of the specified values @param str field_name: Name of the field @param str values: The values we wish to query @param bool exact: Getting the exact query (ex. case sensitive) """ ...
[ "Check", "that", "the", "field", "has", "one", "of", "the", "specified", "values" ]
ravendb/ravendb-python-client
python
https://github.com/ravendb/ravendb-python-client/blob/383739db2594303e3cc469134aa16156f6f80acd/pyravendb/store/session_query.py#L531-L548
[ "def", "where_in", "(", "self", ",", "field_name", ",", "values", ",", "exact", "=", "False", ")", ":", "field_name", "=", "Query", ".", "escape_if_needed", "(", "field_name", ")", "self", ".", "_add_operator_if_needed", "(", ")", "self", ".", "negate_if_nee...
383739db2594303e3cc469134aa16156f6f80acd
train
Query.to_facets
Query the facets results for this query using the specified list of facets with the given start and pageSize @param List[Facet] facets: List of facets @param int start: Start index for paging @param page_size: Paging PageSize. If set, overrides Facet.max_result
pyravendb/store/session_query.py
def to_facets(self, facets, start=0, page_size=None): """ Query the facets results for this query using the specified list of facets with the given start and pageSize @param List[Facet] facets: List of facets @param int start: Start index for paging @param page_size: Paging Pag...
def to_facets(self, facets, start=0, page_size=None): """ Query the facets results for this query using the specified list of facets with the given start and pageSize @param List[Facet] facets: List of facets @param int start: Start index for paging @param page_size: Paging Pag...
[ "Query", "the", "facets", "results", "for", "this", "query", "using", "the", "specified", "list", "of", "facets", "with", "the", "given", "start", "and", "pageSize" ]
ravendb/ravendb-python-client
python
https://github.com/ravendb/ravendb-python-client/blob/383739db2594303e3cc469134aa16156f6f80acd/pyravendb/store/session_query.py#L747-L764
[ "def", "to_facets", "(", "self", ",", "facets", ",", "start", "=", "0", ",", "page_size", "=", "None", ")", ":", "if", "len", "(", "facets", ")", "==", "0", ":", "raise", "ValueError", "(", "\"Facets must contain at least one entry\"", ",", "\"facets\"", "...
383739db2594303e3cc469134aa16156f6f80acd
train
show_G_distribution
Show the distribution of the G function.
cylinder_fitting/visualize.py
def show_G_distribution(data): '''Show the distribution of the G function.''' Xs, t = fitting.preprocess_data(data) Theta, Phi = np.meshgrid(np.linspace(0, np.pi, 50), np.linspace(0, 2 * np.pi, 50)) G = [] for i in range(len(Theta)): G.append([]) for j in range(len(Theta[i])): ...
def show_G_distribution(data): '''Show the distribution of the G function.''' Xs, t = fitting.preprocess_data(data) Theta, Phi = np.meshgrid(np.linspace(0, np.pi, 50), np.linspace(0, 2 * np.pi, 50)) G = [] for i in range(len(Theta)): G.append([]) for j in range(len(Theta[i])): ...
[ "Show", "the", "distribution", "of", "the", "G", "function", "." ]
xingjiepan/cylinder_fitting
python
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/visualize.py#L11-L25
[ "def", "show_G_distribution", "(", "data", ")", ":", "Xs", ",", "t", "=", "fitting", ".", "preprocess_data", "(", "data", ")", "Theta", ",", "Phi", "=", "np", ".", "meshgrid", "(", "np", ".", "linspace", "(", "0", ",", "np", ".", "pi", ",", "50", ...
f96d79732bc49cbc0cb4b39f008af7ce42aeb213
train
show_fit
Plot the fitting given the fitted axis direction, the fitted center, the fitted radius and the data points.
cylinder_fitting/visualize.py
def show_fit(w_fit, C_fit, r_fit, Xs): '''Plot the fitting given the fitted axis direction, the fitted center, the fitted radius and the data points. ''' fig = plt.figure() ax = fig.gca(projection='3d') # Plot the data points ax.scatter([X[0] for X in Xs], [X[1] for X in Xs], [X[2...
def show_fit(w_fit, C_fit, r_fit, Xs): '''Plot the fitting given the fitted axis direction, the fitted center, the fitted radius and the data points. ''' fig = plt.figure() ax = fig.gca(projection='3d') # Plot the data points ax.scatter([X[0] for X in Xs], [X[1] for X in Xs], [X[2...
[ "Plot", "the", "fitting", "given", "the", "fitted", "axis", "direction", "the", "fitted", "center", "the", "fitted", "radius", "and", "the", "data", "points", "." ]
xingjiepan/cylinder_fitting
python
https://github.com/xingjiepan/cylinder_fitting/blob/f96d79732bc49cbc0cb4b39f008af7ce42aeb213/cylinder_fitting/visualize.py#L27-L72
[ "def", "show_fit", "(", "w_fit", ",", "C_fit", ",", "r_fit", ",", "Xs", ")", ":", "fig", "=", "plt", ".", "figure", "(", ")", "ax", "=", "fig", ".", "gca", "(", "projection", "=", "'3d'", ")", "# Plot the data points", "ax", ".", "scatter", "(", "[...
f96d79732bc49cbc0cb4b39f008af7ce42aeb213
train
ColabHighlighter.find_window
Getting the HIGHLIGHT_NUM_CHARS_BEFORE_MATCH setting to find how many characters before the first word found should be removed from the window
colab/utils/highlighting.py
def find_window(self, highlight_locations): """Getting the HIGHLIGHT_NUM_CHARS_BEFORE_MATCH setting to find how many characters before the first word found should be removed from the window """ if len(self.text_block) <= self.max_length: return (0, self.max_length) ...
def find_window(self, highlight_locations): """Getting the HIGHLIGHT_NUM_CHARS_BEFORE_MATCH setting to find how many characters before the first word found should be removed from the window """ if len(self.text_block) <= self.max_length: return (0, self.max_length) ...
[ "Getting", "the", "HIGHLIGHT_NUM_CHARS_BEFORE_MATCH", "setting", "to", "find", "how", "many", "characters", "before", "the", "first", "word", "found", "should", "be", "removed", "from", "the", "window" ]
colab/colab
python
https://github.com/colab/colab/blob/2ad099231e620bec647363b27d38006eca71e13b/colab/utils/highlighting.py#L13-L38
[ "def", "find_window", "(", "self", ",", "highlight_locations", ")", ":", "if", "len", "(", "self", ".", "text_block", ")", "<=", "self", ".", "max_length", ":", "return", "(", "0", ",", "self", ".", "max_length", ")", "num_chars_before", "=", "getattr", ...
2ad099231e620bec647363b27d38006eca71e13b
train
CookieHandler.__set
Private method for setting a cookie's value
colab/middlewares/cookie_middleware.py
def __set(self, key, real_value, coded_value): """Private method for setting a cookie's value""" morse_set = self.get(key, StringMorsel()) morse_set.set(key, real_value, coded_value) dict.__setitem__(self, key, morse_set)
def __set(self, key, real_value, coded_value): """Private method for setting a cookie's value""" morse_set = self.get(key, StringMorsel()) morse_set.set(key, real_value, coded_value) dict.__setitem__(self, key, morse_set)
[ "Private", "method", "for", "setting", "a", "cookie", "s", "value" ]
colab/colab
python
https://github.com/colab/colab/blob/2ad099231e620bec647363b27d38006eca71e13b/colab/middlewares/cookie_middleware.py#L67-L71
[ "def", "__set", "(", "self", ",", "key", ",", "real_value", ",", "coded_value", ")", ":", "morse_set", "=", "self", ".", "get", "(", "key", ",", "StringMorsel", "(", ")", ")", "morse_set", ".", "set", "(", "key", ",", "real_value", ",", "coded_value", ...
2ad099231e620bec647363b27d38006eca71e13b
train
FritzBox.login
Try to login and set the internal session id. Please note: - Any failed login resets all existing session ids, even of other users. - SIDs expire after some time
fritzhome/fritz.py
def login(self): """ Try to login and set the internal session id. Please note: - Any failed login resets all existing session ids, even of other users. - SIDs expire after some time """ response = self.session.get(self.base_url + '/login_sid.lua', time...
def login(self): """ Try to login and set the internal session id. Please note: - Any failed login resets all existing session ids, even of other users. - SIDs expire after some time """ response = self.session.get(self.base_url + '/login_sid.lua', time...
[ "Try", "to", "login", "and", "set", "the", "internal", "session", "id", "." ]
DerMitch/fritzbox-smarthome
python
https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/fritz.py#L53-L81
[ "def", "login", "(", "self", ")", ":", "response", "=", "self", ".", "session", ".", "get", "(", "self", ".", "base_url", "+", "'/login_sid.lua'", ",", "timeout", "=", "10", ")", "xml", "=", "ET", ".", "fromstring", "(", "response", ".", "text", ")",...
84cbd7c1b33e6256add041b0395ff5fccc01f103
train
FritzBox.calculate_response
Calculate response for the challenge-response authentication
fritzhome/fritz.py
def calculate_response(self, challenge, password): """Calculate response for the challenge-response authentication""" to_hash = (challenge + "-" + password).encode("UTF-16LE") hashed = hashlib.md5(to_hash).hexdigest() return "{0}-{1}".format(challenge, hashed)
def calculate_response(self, challenge, password): """Calculate response for the challenge-response authentication""" to_hash = (challenge + "-" + password).encode("UTF-16LE") hashed = hashlib.md5(to_hash).hexdigest() return "{0}-{1}".format(challenge, hashed)
[ "Calculate", "response", "for", "the", "challenge", "-", "response", "authentication" ]
DerMitch/fritzbox-smarthome
python
https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/fritz.py#L83-L87
[ "def", "calculate_response", "(", "self", ",", "challenge", ",", "password", ")", ":", "to_hash", "=", "(", "challenge", "+", "\"-\"", "+", "password", ")", ".", "encode", "(", "\"UTF-16LE\"", ")", "hashed", "=", "hashlib", ".", "md5", "(", "to_hash", ")...
84cbd7c1b33e6256add041b0395ff5fccc01f103
train
FritzBox.get_actors
Returns a list of Actor objects for querying SmartHome devices. This is currently the only working method for getting temperature data.
fritzhome/fritz.py
def get_actors(self): """ Returns a list of Actor objects for querying SmartHome devices. This is currently the only working method for getting temperature data. """ devices = self.homeautoswitch("getdevicelistinfos") xml = ET.fromstring(devices) actors = [] ...
def get_actors(self): """ Returns a list of Actor objects for querying SmartHome devices. This is currently the only working method for getting temperature data. """ devices = self.homeautoswitch("getdevicelistinfos") xml = ET.fromstring(devices) actors = [] ...
[ "Returns", "a", "list", "of", "Actor", "objects", "for", "querying", "SmartHome", "devices", "." ]
DerMitch/fritzbox-smarthome
python
https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/fritz.py#L93-L106
[ "def", "get_actors", "(", "self", ")", ":", "devices", "=", "self", ".", "homeautoswitch", "(", "\"getdevicelistinfos\"", ")", "xml", "=", "ET", ".", "fromstring", "(", "devices", ")", "actors", "=", "[", "]", "for", "device", "in", "xml", ".", "findall"...
84cbd7c1b33e6256add041b0395ff5fccc01f103
train
FritzBox.get_actor_by_ain
Return a actor identified by it's ain or return None
fritzhome/fritz.py
def get_actor_by_ain(self, ain): """ Return a actor identified by it's ain or return None """ for actor in self.get_actors(): if actor.actor_id == ain: return actor
def get_actor_by_ain(self, ain): """ Return a actor identified by it's ain or return None """ for actor in self.get_actors(): if actor.actor_id == ain: return actor
[ "Return", "a", "actor", "identified", "by", "it", "s", "ain", "or", "return", "None" ]
DerMitch/fritzbox-smarthome
python
https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/fritz.py#L108-L114
[ "def", "get_actor_by_ain", "(", "self", ",", "ain", ")", ":", "for", "actor", "in", "self", ".", "get_actors", "(", ")", ":", "if", "actor", ".", "actor_id", "==", "ain", ":", "return", "actor" ]
84cbd7c1b33e6256add041b0395ff5fccc01f103
train
FritzBox.homeautoswitch
Call a switch method. Should only be used by internal library functions.
fritzhome/fritz.py
def homeautoswitch(self, cmd, ain=None, param=None): """ Call a switch method. Should only be used by internal library functions. """ assert self.sid, "Not logged in" params = { 'switchcmd': cmd, 'sid': self.sid, } if param is not N...
def homeautoswitch(self, cmd, ain=None, param=None): """ Call a switch method. Should only be used by internal library functions. """ assert self.sid, "Not logged in" params = { 'switchcmd': cmd, 'sid': self.sid, } if param is not N...
[ "Call", "a", "switch", "method", ".", "Should", "only", "be", "used", "by", "internal", "library", "functions", "." ]
DerMitch/fritzbox-smarthome
python
https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/fritz.py#L120-L138
[ "def", "homeautoswitch", "(", "self", ",", "cmd", ",", "ain", "=", "None", ",", "param", "=", "None", ")", ":", "assert", "self", ".", "sid", ",", "\"Not logged in\"", "params", "=", "{", "'switchcmd'", ":", "cmd", ",", "'sid'", ":", "self", ".", "si...
84cbd7c1b33e6256add041b0395ff5fccc01f103
train
FritzBox.get_switch_actors
Get information about all actors This needs 1+(5n) requests where n = number of actors registered Deprecated, use get_actors instead. Returns a dict: [ain] = { 'name': Name of actor, 'state': Powerstate (boolean) 'present': Connected to server? (boo...
fritzhome/fritz.py
def get_switch_actors(self): """ Get information about all actors This needs 1+(5n) requests where n = number of actors registered Deprecated, use get_actors instead. Returns a dict: [ain] = { 'name': Name of actor, 'state': Powerstate (boolean)...
def get_switch_actors(self): """ Get information about all actors This needs 1+(5n) requests where n = number of actors registered Deprecated, use get_actors instead. Returns a dict: [ain] = { 'name': Name of actor, 'state': Powerstate (boolean)...
[ "Get", "information", "about", "all", "actors" ]
DerMitch/fritzbox-smarthome
python
https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/fritz.py#L140-L168
[ "def", "get_switch_actors", "(", "self", ")", ":", "actors", "=", "{", "}", "for", "ain", "in", "self", ".", "homeautoswitch", "(", "\"getswitchlist\"", ")", ".", "split", "(", "','", ")", ":", "actors", "[", "ain", "]", "=", "{", "'name'", ":", "sel...
84cbd7c1b33e6256add041b0395ff5fccc01f103
train
FritzBox.get_devices
Return a list of devices. Deprecated, use get_actors instead.
fritzhome/fritz.py
def get_devices(self): """ Return a list of devices. Deprecated, use get_actors instead. """ url = self.base_url + '/net/home_auto_query.lua' response = self.session.get(url, params={ 'sid': self.sid, 'command': 'AllOutletStates', 'xhr'...
def get_devices(self): """ Return a list of devices. Deprecated, use get_actors instead. """ url = self.base_url + '/net/home_auto_query.lua' response = self.session.get(url, params={ 'sid': self.sid, 'command': 'AllOutletStates', 'xhr'...
[ "Return", "a", "list", "of", "devices", ".", "Deprecated", "use", "get_actors", "instead", "." ]
DerMitch/fritzbox-smarthome
python
https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/fritz.py#L189-L211
[ "def", "get_devices", "(", "self", ")", ":", "url", "=", "self", ".", "base_url", "+", "'/net/home_auto_query.lua'", "response", "=", "self", ".", "session", ".", "get", "(", "url", ",", "params", "=", "{", "'sid'", ":", "self", ".", "sid", ",", "'comm...
84cbd7c1b33e6256add041b0395ff5fccc01f103
train
FritzBox.get_consumption
Return all available energy consumption data for the device. You need to divice watt_values by 100 and volt_values by 1000 to get the "real" values. :return: dict
fritzhome/fritz.py
def get_consumption(self, deviceid, timerange="10"): """ Return all available energy consumption data for the device. You need to divice watt_values by 100 and volt_values by 1000 to get the "real" values. :return: dict """ tranges = ("10", "24h", "month", "year"...
def get_consumption(self, deviceid, timerange="10"): """ Return all available energy consumption data for the device. You need to divice watt_values by 100 and volt_values by 1000 to get the "real" values. :return: dict """ tranges = ("10", "24h", "month", "year"...
[ "Return", "all", "available", "energy", "consumption", "data", "for", "the", "device", ".", "You", "need", "to", "divice", "watt_values", "by", "100", "and", "volt_values", "by", "1000", "to", "get", "the", "real", "values", "." ]
DerMitch/fritzbox-smarthome
python
https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/fritz.py#L213-L268
[ "def", "get_consumption", "(", "self", ",", "deviceid", ",", "timerange", "=", "\"10\"", ")", ":", "tranges", "=", "(", "\"10\"", ",", "\"24h\"", ",", "\"month\"", ",", "\"year\"", ")", "if", "timerange", "not", "in", "tranges", ":", "raise", "ValueError",...
84cbd7c1b33e6256add041b0395ff5fccc01f103
train
FritzBox.get_logs
Return the system logs since the last reboot.
fritzhome/fritz.py
def get_logs(self): """ Return the system logs since the last reboot. """ assert BeautifulSoup, "Please install bs4 to use this method" url = self.base_url + "/system/syslog.lua" response = self.session.get(url, params={ 'sid': self.sid, 'stylemod...
def get_logs(self): """ Return the system logs since the last reboot. """ assert BeautifulSoup, "Please install bs4 to use this method" url = self.base_url + "/system/syslog.lua" response = self.session.get(url, params={ 'sid': self.sid, 'stylemod...
[ "Return", "the", "system", "logs", "since", "the", "last", "reboot", "." ]
DerMitch/fritzbox-smarthome
python
https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/fritz.py#L270-L295
[ "def", "get_logs", "(", "self", ")", ":", "assert", "BeautifulSoup", ",", "\"Please install bs4 to use this method\"", "url", "=", "self", ".", "base_url", "+", "\"/system/syslog.lua\"", "response", "=", "self", ".", "session", ".", "get", "(", "url", ",", "para...
84cbd7c1b33e6256add041b0395ff5fccc01f103
train
seen_nonce
Returns True if the Hawk nonce has been seen already.
hawkrest/__init__.py
def seen_nonce(id, nonce, timestamp): """ Returns True if the Hawk nonce has been seen already. """ key = '{id}:{n}:{ts}'.format(id=id, n=nonce, ts=timestamp) if cache.get(key): log.warning('replay attack? already processed nonce {k}' .format(k=key)) return True ...
def seen_nonce(id, nonce, timestamp): """ Returns True if the Hawk nonce has been seen already. """ key = '{id}:{n}:{ts}'.format(id=id, n=nonce, ts=timestamp) if cache.get(key): log.warning('replay attack? already processed nonce {k}' .format(k=key)) return True ...
[ "Returns", "True", "if", "the", "Hawk", "nonce", "has", "been", "seen", "already", "." ]
kumar303/hawkrest
python
https://github.com/kumar303/hawkrest/blob/df4de1a068dc2624bf716ed244ab55e8ad4fef7e/hawkrest/__init__.py#L187-L203
[ "def", "seen_nonce", "(", "id", ",", "nonce", ",", "timestamp", ")", ":", "key", "=", "'{id}:{n}:{ts}'", ".", "format", "(", "id", "=", "id", ",", "n", "=", "nonce", ",", "ts", "=", "timestamp", ")", "if", "cache", ".", "get", "(", "key", ")", ":...
df4de1a068dc2624bf716ed244ab55e8ad4fef7e
train
cli
FritzBox SmartHome Tool \b Provides the following functions: - A easy to use library for querying SmartHome actors - This CLI tool for testing - A carbon client for pipeing data into graphite
fritzhome/__main__.py
def cli(context, host, username, password): """ FritzBox SmartHome Tool \b Provides the following functions: - A easy to use library for querying SmartHome actors - This CLI tool for testing - A carbon client for pipeing data into graphite """ context.obj = FritzBox(host, username, ...
def cli(context, host, username, password): """ FritzBox SmartHome Tool \b Provides the following functions: - A easy to use library for querying SmartHome actors - This CLI tool for testing - A carbon client for pipeing data into graphite """ context.obj = FritzBox(host, username, ...
[ "FritzBox", "SmartHome", "Tool" ]
DerMitch/fritzbox-smarthome
python
https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/__main__.py#L25-L35
[ "def", "cli", "(", "context", ",", "host", ",", "username", ",", "password", ")", ":", "context", ".", "obj", "=", "FritzBox", "(", "host", ",", "username", ",", "password", ")" ]
84cbd7c1b33e6256add041b0395ff5fccc01f103
train
actors
Display a list of actors
fritzhome/__main__.py
def actors(context): """Display a list of actors""" fritz = context.obj fritz.login() for actor in fritz.get_actors(): click.echo("{} ({} {}; AIN {} )".format( actor.name, actor.manufacturer, actor.productname, actor.actor_id, )) i...
def actors(context): """Display a list of actors""" fritz = context.obj fritz.login() for actor in fritz.get_actors(): click.echo("{} ({} {}; AIN {} )".format( actor.name, actor.manufacturer, actor.productname, actor.actor_id, )) i...
[ "Display", "a", "list", "of", "actors" ]
DerMitch/fritzbox-smarthome
python
https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/__main__.py#L40-L62
[ "def", "actors", "(", "context", ")", ":", "fritz", "=", "context", ".", "obj", "fritz", ".", "login", "(", ")", "for", "actor", "in", "fritz", ".", "get_actors", "(", ")", ":", "click", ".", "echo", "(", "\"{} ({} {}; AIN {} )\"", ".", "format", "(", ...
84cbd7c1b33e6256add041b0395ff5fccc01f103
train
energy
Display energy stats of all actors
fritzhome/__main__.py
def energy(context, features): """Display energy stats of all actors""" fritz = context.obj fritz.login() for actor in fritz.get_actors(): if actor.temperature is not None: click.echo("{} ({}): {:.2f} Watt current, {:.3f} wH total, {:.2f} °C".format( actor.name.encod...
def energy(context, features): """Display energy stats of all actors""" fritz = context.obj fritz.login() for actor in fritz.get_actors(): if actor.temperature is not None: click.echo("{} ({}): {:.2f} Watt current, {:.3f} wH total, {:.2f} °C".format( actor.name.encod...
[ "Display", "energy", "stats", "of", "all", "actors" ]
DerMitch/fritzbox-smarthome
python
https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/__main__.py#L68-L92
[ "def", "energy", "(", "context", ",", "features", ")", ":", "fritz", "=", "context", ".", "obj", "fritz", ".", "login", "(", ")", "for", "actor", "in", "fritz", ".", "get_actors", "(", ")", ":", "if", "actor", ".", "temperature", "is", "not", "None",...
84cbd7c1b33e6256add041b0395ff5fccc01f103
train
graphite
Display energy stats of all actors
fritzhome/__main__.py
def graphite(context, server, port, interval, prefix): """Display energy stats of all actors""" fritz = context.obj fritz.login() sid_ttl = time.time() + 600 # Find actors and create carbon keys click.echo(" * Requesting actors list") simple_chars = re.compile('[^A-Za-z0-9]+') actors = ...
def graphite(context, server, port, interval, prefix): """Display energy stats of all actors""" fritz = context.obj fritz.login() sid_ttl = time.time() + 600 # Find actors and create carbon keys click.echo(" * Requesting actors list") simple_chars = re.compile('[^A-Za-z0-9]+') actors = ...
[ "Display", "energy", "stats", "of", "all", "actors" ]
DerMitch/fritzbox-smarthome
python
https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/__main__.py#L101-L157
[ "def", "graphite", "(", "context", ",", "server", ",", "port", ",", "interval", ",", "prefix", ")", ":", "fritz", "=", "context", ".", "obj", "fritz", ".", "login", "(", ")", "sid_ttl", "=", "time", ".", "time", "(", ")", "+", "600", "# Find actors a...
84cbd7c1b33e6256add041b0395ff5fccc01f103
train
switch_on
Switch an actor's power to ON
fritzhome/__main__.py
def switch_on(context, ain): """Switch an actor's power to ON""" context.obj.login() actor = context.obj.get_actor_by_ain(ain) if actor: click.echo("Switching {} on".format(actor.name)) actor.switch_on() else: click.echo("Actor not found: {}".format(ain))
def switch_on(context, ain): """Switch an actor's power to ON""" context.obj.login() actor = context.obj.get_actor_by_ain(ain) if actor: click.echo("Switching {} on".format(actor.name)) actor.switch_on() else: click.echo("Actor not found: {}".format(ain))
[ "Switch", "an", "actor", "s", "power", "to", "ON" ]
DerMitch/fritzbox-smarthome
python
https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/__main__.py#L163-L171
[ "def", "switch_on", "(", "context", ",", "ain", ")", ":", "context", ".", "obj", ".", "login", "(", ")", "actor", "=", "context", ".", "obj", ".", "get_actor_by_ain", "(", "ain", ")", "if", "actor", ":", "click", ".", "echo", "(", "\"Switching {} on\""...
84cbd7c1b33e6256add041b0395ff5fccc01f103
train
switch_state
Get an actor's power state
fritzhome/__main__.py
def switch_state(context, ain): """Get an actor's power state""" context.obj.login() actor = context.obj.get_actor_by_ain(ain) if actor: click.echo("State for {} is: {}".format(ain,'ON' if actor.get_state() else 'OFF')) else: click.echo("Actor not found: {}".format(ain))
def switch_state(context, ain): """Get an actor's power state""" context.obj.login() actor = context.obj.get_actor_by_ain(ain) if actor: click.echo("State for {} is: {}".format(ain,'ON' if actor.get_state() else 'OFF')) else: click.echo("Actor not found: {}".format(ain))
[ "Get", "an", "actor", "s", "power", "state" ]
DerMitch/fritzbox-smarthome
python
https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/__main__.py#L191-L198
[ "def", "switch_state", "(", "context", ",", "ain", ")", ":", "context", ".", "obj", ".", "login", "(", ")", "actor", "=", "context", ".", "obj", ".", "get_actor_by_ain", "(", "ain", ")", "if", "actor", ":", "click", ".", "echo", "(", "\"State for {} is...
84cbd7c1b33e6256add041b0395ff5fccc01f103
train
switch_toggle
Toggle an actor's power state
fritzhome/__main__.py
def switch_toggle(context, ain): """Toggle an actor's power state""" context.obj.login() actor = context.obj.get_actor_by_ain(ain) if actor: if actor.get_state(): actor.switch_off() click.echo("State for {} is now OFF".format(ain)) else: actor.switch_o...
def switch_toggle(context, ain): """Toggle an actor's power state""" context.obj.login() actor = context.obj.get_actor_by_ain(ain) if actor: if actor.get_state(): actor.switch_off() click.echo("State for {} is now OFF".format(ain)) else: actor.switch_o...
[ "Toggle", "an", "actor", "s", "power", "state" ]
DerMitch/fritzbox-smarthome
python
https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/__main__.py#L204-L216
[ "def", "switch_toggle", "(", "context", ",", "ain", ")", ":", "context", ".", "obj", ".", "login", "(", ")", "actor", "=", "context", ".", "obj", ".", "get_actor_by_ain", "(", "ain", ")", "if", "actor", ":", "if", "actor", ".", "get_state", "(", ")",...
84cbd7c1b33e6256add041b0395ff5fccc01f103
train
logs
Show system logs since last reboot
fritzhome/__main__.py
def logs(context, format): """Show system logs since last reboot""" fritz = context.obj fritz.login() messages = fritz.get_logs() if format == "plain": for msg in messages: merged = "{} {} {}".format(msg.date, msg.time, msg.message.encode("UTF-8")) click.echo(merged)...
def logs(context, format): """Show system logs since last reboot""" fritz = context.obj fritz.login() messages = fritz.get_logs() if format == "plain": for msg in messages: merged = "{} {} {}".format(msg.date, msg.time, msg.message.encode("UTF-8")) click.echo(merged)...
[ "Show", "system", "logs", "since", "last", "reboot" ]
DerMitch/fritzbox-smarthome
python
https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/__main__.py#L223-L238
[ "def", "logs", "(", "context", ",", "format", ")", ":", "fritz", "=", "context", ".", "obj", "fritz", ".", "login", "(", ")", "messages", "=", "fritz", ".", "get_logs", "(", ")", "if", "format", "==", "\"plain\"", ":", "for", "msg", "in", "messages",...
84cbd7c1b33e6256add041b0395ff5fccc01f103
train
Actor.get_power
Returns the current power usage in milliWatts. Attention: Returns None if the value can't be queried or is unknown.
fritzhome/actor.py
def get_power(self): """ Returns the current power usage in milliWatts. Attention: Returns None if the value can't be queried or is unknown. """ value = self.box.homeautoswitch("getswitchpower", self.actor_id) return int(value) if value.isdigit() else None
def get_power(self): """ Returns the current power usage in milliWatts. Attention: Returns None if the value can't be queried or is unknown. """ value = self.box.homeautoswitch("getswitchpower", self.actor_id) return int(value) if value.isdigit() else None
[ "Returns", "the", "current", "power", "usage", "in", "milliWatts", ".", "Attention", ":", "Returns", "None", "if", "the", "value", "can", "t", "be", "queried", "or", "is", "unknown", "." ]
DerMitch/fritzbox-smarthome
python
https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/actor.py#L83-L89
[ "def", "get_power", "(", "self", ")", ":", "value", "=", "self", ".", "box", ".", "homeautoswitch", "(", "\"getswitchpower\"", ",", "self", ".", "actor_id", ")", "return", "int", "(", "value", ")", "if", "value", ".", "isdigit", "(", ")", "else", "None...
84cbd7c1b33e6256add041b0395ff5fccc01f103
train
Actor.get_energy
Returns the consumed energy since the start of the statistics in Wh. Attention: Returns None if the value can't be queried or is unknown.
fritzhome/actor.py
def get_energy(self): """ Returns the consumed energy since the start of the statistics in Wh. Attention: Returns None if the value can't be queried or is unknown. """ value = self.box.homeautoswitch("getswitchenergy", self.actor_id) return int(value) if value.isdigit() e...
def get_energy(self): """ Returns the consumed energy since the start of the statistics in Wh. Attention: Returns None if the value can't be queried or is unknown. """ value = self.box.homeautoswitch("getswitchenergy", self.actor_id) return int(value) if value.isdigit() e...
[ "Returns", "the", "consumed", "energy", "since", "the", "start", "of", "the", "statistics", "in", "Wh", ".", "Attention", ":", "Returns", "None", "if", "the", "value", "can", "t", "be", "queried", "or", "is", "unknown", "." ]
DerMitch/fritzbox-smarthome
python
https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/actor.py#L91-L97
[ "def", "get_energy", "(", "self", ")", ":", "value", "=", "self", ".", "box", ".", "homeautoswitch", "(", "\"getswitchenergy\"", ",", "self", ".", "actor_id", ")", "return", "int", "(", "value", ")", "if", "value", ".", "isdigit", "(", ")", "else", "No...
84cbd7c1b33e6256add041b0395ff5fccc01f103
train
Actor.get_temperature
Returns the current environment temperature. Attention: Returns None if the value can't be queried or is unknown.
fritzhome/actor.py
def get_temperature(self): """ Returns the current environment temperature. Attention: Returns None if the value can't be queried or is unknown. """ #raise NotImplementedError("This should work according to the AVM docs, but don't...") value = self.box.homeautoswitch("get...
def get_temperature(self): """ Returns the current environment temperature. Attention: Returns None if the value can't be queried or is unknown. """ #raise NotImplementedError("This should work according to the AVM docs, but don't...") value = self.box.homeautoswitch("get...
[ "Returns", "the", "current", "environment", "temperature", ".", "Attention", ":", "Returns", "None", "if", "the", "value", "can", "t", "be", "queried", "or", "is", "unknown", "." ]
DerMitch/fritzbox-smarthome
python
https://github.com/DerMitch/fritzbox-smarthome/blob/84cbd7c1b33e6256add041b0395ff5fccc01f103/fritzhome/actor.py#L99-L110
[ "def", "get_temperature", "(", "self", ")", ":", "#raise NotImplementedError(\"This should work according to the AVM docs, but don't...\")", "value", "=", "self", ".", "box", ".", "homeautoswitch", "(", "\"gettemperature\"", ",", "self", ".", "actor_id", ")", "if", "value...
84cbd7c1b33e6256add041b0395ff5fccc01f103