repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Auth.connect
def connect(self): """|coro| Connect to ubisoft, automatically called when needed""" if time.time() < self._login_cooldown: raise FailedToConnect("login on cooldown") resp = yield from self.session.post("https://connect.ubi.com/ubiservices/v2/profiles/sessions", headers = {...
python
def connect(self): """|coro| Connect to ubisoft, automatically called when needed""" if time.time() < self._login_cooldown: raise FailedToConnect("login on cooldown") resp = yield from self.session.post("https://connect.ubi.com/ubiservices/v2/profiles/sessions", headers = {...
[ "def", "connect", "(", "self", ")", ":", "if", "time", ".", "time", "(", ")", "<", "self", ".", "_login_cooldown", ":", "raise", "FailedToConnect", "(", "\"login on cooldown\"", ")", "resp", "=", "yield", "from", "self", ".", "session", ".", "post", "(",...
|coro| Connect to ubisoft, automatically called when needed
[ "|coro|" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L378-L398
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Auth.get_players
def get_players(self, name=None, platform=None, uid=None): """|coro| get a list of players matching the term on that platform, exactly one of uid and name must be given, platform must be given, this list almost always has only 1 element, so it's easier to use get_player Paramet...
python
def get_players(self, name=None, platform=None, uid=None): """|coro| get a list of players matching the term on that platform, exactly one of uid and name must be given, platform must be given, this list almost always has only 1 element, so it's easier to use get_player Paramet...
[ "def", "get_players", "(", "self", ",", "name", "=", "None", ",", "platform", "=", "None", ",", "uid", "=", "None", ")", ":", "if", "name", "is", "None", "and", "uid", "is", "None", ":", "raise", "TypeError", "(", "\"name and uid are both None, exactly one...
|coro| get a list of players matching the term on that platform, exactly one of uid and name must be given, platform must be given, this list almost always has only 1 element, so it's easier to use get_player Parameters ---------- name : str the name of the ...
[ "|coro|" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L460-L515
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Auth.get_player
def get_player(self, name=None, platform=None, uid=None): """|coro| Calls get_players and returns the first element, exactly one of uid and name must be given, platform must be given Parameters ---------- name : str the name of the player you're searching fo...
python
def get_player(self, name=None, platform=None, uid=None): """|coro| Calls get_players and returns the first element, exactly one of uid and name must be given, platform must be given Parameters ---------- name : str the name of the player you're searching fo...
[ "def", "get_player", "(", "self", ",", "name", "=", "None", ",", "platform", "=", "None", ",", "uid", "=", "None", ")", ":", "results", "=", "yield", "from", "self", ".", "get_players", "(", "name", "=", "name", ",", "platform", "=", "platform", ",",...
|coro| Calls get_players and returns the first element, exactly one of uid and name must be given, platform must be given Parameters ---------- name : str the name of the player you're searching for platform : str the name of the platform you're ...
[ "|coro|" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L518-L539
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Auth.get_operator_definitions
def get_operator_definitions(self): """|coro| Retrieves a list of information about operators - their badge, unique statistic, etc. Returns ------- dict operators""" if self._op_definitions is not None: return self._op_definitions resp =...
python
def get_operator_definitions(self): """|coro| Retrieves a list of information about operators - their badge, unique statistic, etc. Returns ------- dict operators""" if self._op_definitions is not None: return self._op_definitions resp =...
[ "def", "get_operator_definitions", "(", "self", ")", ":", "if", "self", ".", "_op_definitions", "is", "not", "None", ":", "return", "self", ".", "_op_definitions", "resp", "=", "yield", "from", "self", ".", "session", ".", "get", "(", "\"https://game-rainbow6....
|coro| Retrieves a list of information about operators - their badge, unique statistic, etc. Returns ------- dict operators
[ "|coro|" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L542-L558
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Auth.get_operator_index
def get_operator_index(self, name): """|coro| Gets the operators index from the operator definitions dict Returns ------- str the operator index""" opdefs = yield from self.get_operator_definitions() name = name.lower() if name not in opdefs...
python
def get_operator_index(self, name): """|coro| Gets the operators index from the operator definitions dict Returns ------- str the operator index""" opdefs = yield from self.get_operator_definitions() name = name.lower() if name not in opdefs...
[ "def", "get_operator_index", "(", "self", ",", "name", ")", ":", "opdefs", "=", "yield", "from", "self", ".", "get_operator_definitions", "(", ")", "name", "=", "name", ".", "lower", "(", ")", "if", "name", "not", "in", "opdefs", ":", "return", "None", ...
|coro| Gets the operators index from the operator definitions dict Returns ------- str the operator index
[ "|coro|" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L561-L576
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Auth.get_operator_statistic
def get_operator_statistic(self, name): """|coro| Gets the operator unique statistic from the operator definitions dict Returns ------- str the name of the operator unique statistic""" opdefs = yield from self.get_operator_definitions() name = name....
python
def get_operator_statistic(self, name): """|coro| Gets the operator unique statistic from the operator definitions dict Returns ------- str the name of the operator unique statistic""" opdefs = yield from self.get_operator_definitions() name = name....
[ "def", "get_operator_statistic", "(", "self", ",", "name", ")", ":", "opdefs", "=", "yield", "from", "self", ".", "get_operator_definitions", "(", ")", "name", "=", "name", ".", "lower", "(", ")", "if", "name", "not", "in", "opdefs", ":", "return", "None...
|coro| Gets the operator unique statistic from the operator definitions dict Returns ------- str the name of the operator unique statistic
[ "|coro|" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L579-L598
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Auth.get_operator_badge
def get_operator_badge(self, name): """|coro| Gets the operator badge URL Returns ------- str the operators badge URL""" opdefs = yield from self.get_operator_definitions() name = name.lower() if name not in opdefs: return None ...
python
def get_operator_badge(self, name): """|coro| Gets the operator badge URL Returns ------- str the operators badge URL""" opdefs = yield from self.get_operator_definitions() name = name.lower() if name not in opdefs: return None ...
[ "def", "get_operator_badge", "(", "self", ",", "name", ")", ":", "opdefs", "=", "yield", "from", "self", ".", "get_operator_definitions", "(", ")", "name", "=", "name", ".", "lower", "(", ")", "if", "name", "not", "in", "opdefs", ":", "return", "None", ...
|coro| Gets the operator badge URL Returns ------- str the operators badge URL
[ "|coro|" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L601-L621
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Auth.get_definitions
def get_definitions(self): """|coro| Retrieves the list of api definitions, downloading it from Ubisoft if it hasn't been fetched all ready Primarily for internal use, but could contain useful information. Returns ------- dict definitions""" if self....
python
def get_definitions(self): """|coro| Retrieves the list of api definitions, downloading it from Ubisoft if it hasn't been fetched all ready Primarily for internal use, but could contain useful information. Returns ------- dict definitions""" if self....
[ "def", "get_definitions", "(", "self", ")", ":", "if", "self", ".", "_definitions", "is", "not", "None", ":", "return", "self", ".", "_definitions", "resp", "=", "yield", "from", "self", ".", "session", ".", "get", "(", "\"https://ubistatic-a.akamaihd.net/0058...
|coro| Retrieves the list of api definitions, downloading it from Ubisoft if it hasn't been fetched all ready Primarily for internal use, but could contain useful information. Returns ------- dict definitions
[ "|coro|" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L625-L642
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Auth.get_object_index
def get_object_index(self, key): """|coro| Mainly for internal use with get_operator, returns the "location" index for the key in the definitions Returns ------- str the object's location index""" defns = yield from self.get_definitions() fo...
python
def get_object_index(self, key): """|coro| Mainly for internal use with get_operator, returns the "location" index for the key in the definitions Returns ------- str the object's location index""" defns = yield from self.get_definitions() fo...
[ "def", "get_object_index", "(", "self", ",", "key", ")", ":", "defns", "=", "yield", "from", "self", ".", "get_definitions", "(", ")", "for", "x", "in", "defns", ":", "if", "key", "in", "x", "and", "\"objectIndex\"", "in", "defns", "[", "x", "]", ":"...
|coro| Mainly for internal use with get_operator, returns the "location" index for the key in the definitions Returns ------- str the object's location index
[ "|coro|" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L645-L661
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Rank.get_charm_url
def get_charm_url(self): """Get charm URL for the bracket this rank is in Returns ------- :class:`str` the URL for the charm """ if self.rank_id <= 4: return self.RANK_CHARMS[0] if self.rank_id <= 8: return self.RANK_CHARMS[1] if self.rank_id...
python
def get_charm_url(self): """Get charm URL for the bracket this rank is in Returns ------- :class:`str` the URL for the charm """ if self.rank_id <= 4: return self.RANK_CHARMS[0] if self.rank_id <= 8: return self.RANK_CHARMS[1] if self.rank_id...
[ "def", "get_charm_url", "(", "self", ")", ":", "if", "self", ".", "rank_id", "<=", "4", ":", "return", "self", ".", "RANK_CHARMS", "[", "0", "]", "if", "self", ".", "rank_id", "<=", "8", ":", "return", "self", ".", "RANK_CHARMS", "[", "1", "]", "if...
Get charm URL for the bracket this rank is in Returns ------- :class:`str` the URL for the charm
[ "Get", "charm", "URL", "for", "the", "bracket", "this", "rank", "is", "in" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L808-L822
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Player.load_level
def load_level(self): """|coro| Load the players XP and level""" data = yield from self.auth.get("https://public-ubiservices.ubi.com/v1/spaces/%s/sandboxes/%s/r6playerprofile/playerprofile/progressions?profile_ids=%s" % (self.spaceid, self.platform_url, self.id)) if "player_profiles" i...
python
def load_level(self): """|coro| Load the players XP and level""" data = yield from self.auth.get("https://public-ubiservices.ubi.com/v1/spaces/%s/sandboxes/%s/r6playerprofile/playerprofile/progressions?profile_ids=%s" % (self.spaceid, self.platform_url, self.id)) if "player_profiles" i...
[ "def", "load_level", "(", "self", ")", ":", "data", "=", "yield", "from", "self", ".", "auth", ".", "get", "(", "\"https://public-ubiservices.ubi.com/v1/spaces/%s/sandboxes/%s/r6playerprofile/playerprofile/progressions?profile_ids=%s\"", "%", "(", "self", ".", "spaceid", ...
|coro| Load the players XP and level
[ "|coro|" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L1093-L1103
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Player.load_rank
def load_rank(self, region, season=-1): """|coro| Loads the players rank for this region and season Parameters ---------- region : str the name of the region you want to get the rank for season : Optional[int] the season you want to get the rank f...
python
def load_rank(self, region, season=-1): """|coro| Loads the players rank for this region and season Parameters ---------- region : str the name of the region you want to get the rank for season : Optional[int] the season you want to get the rank f...
[ "def", "load_rank", "(", "self", ",", "region", ",", "season", "=", "-", "1", ")", ":", "data", "=", "yield", "from", "self", ".", "auth", ".", "get", "(", "\"https://public-ubiservices.ubi.com/v1/spaces/%s/sandboxes/%s/r6karma/players?board_id=pvp_ranked&profile_ids=%s...
|coro| Loads the players rank for this region and season Parameters ---------- region : str the name of the region you want to get the rank for season : Optional[int] the season you want to get the rank for (defaults to -1, latest season) Returns...
[ "|coro|", "Loads", "the", "players", "rank", "for", "this", "region", "and", "season" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L1114-L1136
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Player.get_rank
def get_rank(self, region, season=-1): """|coro| Checks the players rank for this region, only loading it if it hasn't already been found Parameters ---------- region : str the name of the region you want to get the rank for season : Optional[int] ...
python
def get_rank(self, region, season=-1): """|coro| Checks the players rank for this region, only loading it if it hasn't already been found Parameters ---------- region : str the name of the region you want to get the rank for season : Optional[int] ...
[ "def", "get_rank", "(", "self", ",", "region", ",", "season", "=", "-", "1", ")", ":", "cache_key", "=", "\"%s:%s\"", "%", "(", "region", ",", "season", ")", "if", "cache_key", "in", "self", ".", "ranks", ":", "return", "self", ".", "ranks", "[", "...
|coro| Checks the players rank for this region, only loading it if it hasn't already been found Parameters ---------- region : str the name of the region you want to get the rank for season : Optional[int] the season you want to get the rank for (default...
[ "|coro|" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L1139-L1160
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Player.load_all_operators
def load_all_operators(self): """|coro| Loads the player stats for all operators Returns ------- dict[:class:`Operator`] the dictionary of all operators found""" statistics = "operatorpvp_kills,operatorpvp_death,operatorpvp_roundwon,operatorpvp_roundlost,ope...
python
def load_all_operators(self): """|coro| Loads the player stats for all operators Returns ------- dict[:class:`Operator`] the dictionary of all operators found""" statistics = "operatorpvp_kills,operatorpvp_death,operatorpvp_roundwon,operatorpvp_roundlost,ope...
[ "def", "load_all_operators", "(", "self", ")", ":", "statistics", "=", "\"operatorpvp_kills,operatorpvp_death,operatorpvp_roundwon,operatorpvp_roundlost,operatorpvp_meleekills,operatorpvp_totalxp,operatorpvp_headshot,operatorpvp_timeplayed,operatorpvp_dbno\"", "for", "operator", "in", "Opera...
|coro| Loads the player stats for all operators Returns ------- dict[:class:`Operator`] the dictionary of all operators found
[ "|coro|" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L1163-L1195
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Player.get_all_operators
def get_all_operators(self): """|coro| Checks the player stats for all operators, loading them all again if any aren't found This is significantly more efficient than calling get_operator for every operator name. Returns ------- dict[:class:`Operator`] the d...
python
def get_all_operators(self): """|coro| Checks the player stats for all operators, loading them all again if any aren't found This is significantly more efficient than calling get_operator for every operator name. Returns ------- dict[:class:`Operator`] the d...
[ "def", "get_all_operators", "(", "self", ")", ":", "if", "len", "(", "self", ".", "operators", ")", ">=", "len", "(", "OperatorStatisticNames", ")", ":", "return", "self", ".", "operators", "result", "=", "yield", "from", "self", ".", "load_all_operators", ...
|coro| Checks the player stats for all operators, loading them all again if any aren't found This is significantly more efficient than calling get_operator for every operator name. Returns ------- dict[:class:`Operator`] the dictionary of all operators found
[ "|coro|" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L1198-L1212
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Player.load_operator
def load_operator(self, operator): """|coro| Loads the players stats for the operator Parameters ---------- operator : str the name of the operator Returns ------- :class:`Operator` the operator object found""" location =...
python
def load_operator(self, operator): """|coro| Loads the players stats for the operator Parameters ---------- operator : str the name of the operator Returns ------- :class:`Operator` the operator object found""" location =...
[ "def", "load_operator", "(", "self", ",", "operator", ")", ":", "location", "=", "yield", "from", "self", ".", "auth", ".", "get_operator_index", "(", "operator", ")", "if", "location", "is", "None", ":", "raise", "ValueError", "(", "\"invalid operator %s\"", ...
|coro| Loads the players stats for the operator Parameters ---------- operator : str the name of the operator Returns ------- :class:`Operator` the operator object found
[ "|coro|" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L1215-L1256
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Player.get_operator
def get_operator(self, operator): """|coro| Checks the players stats for this operator, only loading them if they haven't already been found Parameters ---------- operator : str the name of the operator Returns ------- :class:`Operator` ...
python
def get_operator(self, operator): """|coro| Checks the players stats for this operator, only loading them if they haven't already been found Parameters ---------- operator : str the name of the operator Returns ------- :class:`Operator` ...
[ "def", "get_operator", "(", "self", ",", "operator", ")", ":", "if", "operator", "in", "self", ".", "operators", ":", "return", "self", ".", "operators", "[", "operator", "]", "result", "=", "yield", "from", "self", ".", "load_operator", "(", "operator", ...
|coro| Checks the players stats for this operator, only loading them if they haven't already been found Parameters ---------- operator : str the name of the operator Returns ------- :class:`Operator` the operator object found
[ "|coro|" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L1259-L1277
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Player.load_weapons
def load_weapons(self): """|coro| Load the players weapon stats Returns ------- list[:class:`Weapon`] list of all the weapon objects found""" data = yield from self.auth.get("https://public-ubiservices.ubi.com/v1/spaces/%s/sandboxes/%s/playerstats2/statistic...
python
def load_weapons(self): """|coro| Load the players weapon stats Returns ------- list[:class:`Weapon`] list of all the weapon objects found""" data = yield from self.auth.get("https://public-ubiservices.ubi.com/v1/spaces/%s/sandboxes/%s/playerstats2/statistic...
[ "def", "load_weapons", "(", "self", ")", ":", "data", "=", "yield", "from", "self", ".", "auth", ".", "get", "(", "\"https://public-ubiservices.ubi.com/v1/spaces/%s/sandboxes/%s/playerstats2/statistics?populations=%s&statistics=weapontypepvp_kills,weapontypepvp_headshot,weapontypepvp...
|coro| Load the players weapon stats Returns ------- list[:class:`Weapon`] list of all the weapon objects found
[ "|coro|" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L1280-L1310
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Player.load_gamemodes
def load_gamemodes(self): """|coro| Loads the players gamemode stats Returns ------- dict dict of all the gamemodes found (gamemode_name: :class:`Gamemode`)""" stats = yield from self._fetch_statistics("secureareapvp_matchwon", "secureareapvp_matchlost", "s...
python
def load_gamemodes(self): """|coro| Loads the players gamemode stats Returns ------- dict dict of all the gamemodes found (gamemode_name: :class:`Gamemode`)""" stats = yield from self._fetch_statistics("secureareapvp_matchwon", "secureareapvp_matchlost", "s...
[ "def", "load_gamemodes", "(", "self", ")", ":", "stats", "=", "yield", "from", "self", ".", "_fetch_statistics", "(", "\"secureareapvp_matchwon\"", ",", "\"secureareapvp_matchlost\"", ",", "\"secureareapvp_matchplayed\"", ",", "\"secureareapvp_bestscore\"", ",", "\"rescue...
|coro| Loads the players gamemode stats Returns ------- dict dict of all the gamemodes found (gamemode_name: :class:`Gamemode`)
[ "|coro|" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L1327-L1363
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Player.load_general
def load_general(self): """|coro| Loads the players general stats""" stats = yield from self._fetch_statistics("generalpvp_timeplayed", "generalpvp_matchplayed", "generalpvp_matchwon", "generalpvp_matchlost", "generalpvp_kills", "generalpvp_dea...
python
def load_general(self): """|coro| Loads the players general stats""" stats = yield from self._fetch_statistics("generalpvp_timeplayed", "generalpvp_matchplayed", "generalpvp_matchwon", "generalpvp_matchlost", "generalpvp_kills", "generalpvp_dea...
[ "def", "load_general", "(", "self", ")", ":", "stats", "=", "yield", "from", "self", ".", "_fetch_statistics", "(", "\"generalpvp_timeplayed\"", ",", "\"generalpvp_matchplayed\"", ",", "\"generalpvp_matchwon\"", ",", "\"generalpvp_matchlost\"", ",", "\"generalpvp_kills\""...
|coro| Loads the players general stats
[ "|coro|" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L1380-L1418
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Player.load_queues
def load_queues(self): """|coro| Loads the players game queues""" stats = yield from self._fetch_statistics("casualpvp_matchwon", "casualpvp_matchlost", "casualpvp_timeplayed", "casualpvp_matchplayed", "casualpvp_kills", "casualpvp_death", ...
python
def load_queues(self): """|coro| Loads the players game queues""" stats = yield from self._fetch_statistics("casualpvp_matchwon", "casualpvp_matchlost", "casualpvp_timeplayed", "casualpvp_matchplayed", "casualpvp_kills", "casualpvp_death", ...
[ "def", "load_queues", "(", "self", ")", ":", "stats", "=", "yield", "from", "self", ".", "_fetch_statistics", "(", "\"casualpvp_matchwon\"", ",", "\"casualpvp_matchlost\"", ",", "\"casualpvp_timeplayed\"", ",", "\"casualpvp_matchplayed\"", ",", "\"casualpvp_kills\"", ",...
|coro| Loads the players game queues
[ "|coro|" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L1430-L1451
billy-yoyo/RainbowSixSiege-Python-API
r6sapi/r6sapi.py
Player.load_terrohunt
def load_terrohunt(self): """|coro| Loads the player's general stats for terrorist hunt""" stats = yield from self._fetch_statistics("generalpve_dbnoassists", "generalpve_death", "generalpve_revive", "generalpve_matchwon", "generalpve_suicide", ...
python
def load_terrohunt(self): """|coro| Loads the player's general stats for terrorist hunt""" stats = yield from self._fetch_statistics("generalpve_dbnoassists", "generalpve_death", "generalpve_revive", "generalpve_matchwon", "generalpve_suicide", ...
[ "def", "load_terrohunt", "(", "self", ")", ":", "stats", "=", "yield", "from", "self", ".", "_fetch_statistics", "(", "\"generalpve_dbnoassists\"", ",", "\"generalpve_death\"", ",", "\"generalpve_revive\"", ",", "\"generalpve_matchwon\"", ",", "\"generalpve_suicide\"", ...
|coro| Loads the player's general stats for terrorist hunt
[ "|coro|" ]
train
https://github.com/billy-yoyo/RainbowSixSiege-Python-API/blob/9860fdfd9a78aabd977eaa71b0a4ab4ed69e94d0/r6sapi/r6sapi.py#L1463-L1511
jepcastelein/marketo-rest-python
marketorestpython/client.py
MarketoClient.execute
def execute(self, method, *args, **kargs): result = None ''' max 10 rechecks ''' for i in range(0, 10): try: method_map = { 'get_lead_by_id': self.get_lead_by_id, 'get_multiple_leads_by_filter_type': self.g...
python
def execute(self, method, *args, **kargs): result = None ''' max 10 rechecks ''' for i in range(0, 10): try: method_map = { 'get_lead_by_id': self.get_lead_by_id, 'get_multiple_leads_by_filter_type': self.g...
[ "def", "execute", "(", "self", ",", "method", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "result", "=", "None", "for", "i", "in", "range", "(", "0", ",", "10", ")", ":", "try", ":", "method_map", "=", "{", "'get_lead_by_id'", ":", "self"...
max 10 rechecks
[ "max", "10", "rechecks" ]
train
https://github.com/jepcastelein/marketo-rest-python/blob/af9592b7f6dea8166dca1a0223ebc1066c25ca93/marketorestpython/client.py#L46-L280
NaturalHistoryMuseum/pylibdmtx
pylibdmtx/wrapper.py
load_libdmtx
def load_libdmtx(): """Loads the libdmtx shared library. Populates the globals LIBDMTX and EXTERNAL_DEPENDENCIES. """ global LIBDMTX global EXTERNAL_DEPENDENCIES if not LIBDMTX: LIBDMTX = dmtx_library.load() EXTERNAL_DEPENDENCIES = [LIBDMTX] return LIBDMTX
python
def load_libdmtx(): """Loads the libdmtx shared library. Populates the globals LIBDMTX and EXTERNAL_DEPENDENCIES. """ global LIBDMTX global EXTERNAL_DEPENDENCIES if not LIBDMTX: LIBDMTX = dmtx_library.load() EXTERNAL_DEPENDENCIES = [LIBDMTX] return LIBDMTX
[ "def", "load_libdmtx", "(", ")", ":", "global", "LIBDMTX", "global", "EXTERNAL_DEPENDENCIES", "if", "not", "LIBDMTX", ":", "LIBDMTX", "=", "dmtx_library", ".", "load", "(", ")", "EXTERNAL_DEPENDENCIES", "=", "[", "LIBDMTX", "]", "return", "LIBDMTX" ]
Loads the libdmtx shared library. Populates the globals LIBDMTX and EXTERNAL_DEPENDENCIES.
[ "Loads", "the", "libdmtx", "shared", "library", "." ]
train
https://github.com/NaturalHistoryMuseum/pylibdmtx/blob/a425ec36050500af4875bf94eda02feb26ea62ad/pylibdmtx/wrapper.py#L32-L43
NaturalHistoryMuseum/pylibdmtx
pylibdmtx/wrapper.py
libdmtx_function
def libdmtx_function(fname, restype, *args): """Returns a foreign function exported by `libdmtx`. Args: fname (:obj:`str`): Name of the exported function as string. restype (:obj:): Return type - one of the `ctypes` primitive C data types. *args: Arguments - a sequence of `ctype...
python
def libdmtx_function(fname, restype, *args): """Returns a foreign function exported by `libdmtx`. Args: fname (:obj:`str`): Name of the exported function as string. restype (:obj:): Return type - one of the `ctypes` primitive C data types. *args: Arguments - a sequence of `ctype...
[ "def", "libdmtx_function", "(", "fname", ",", "restype", ",", "*", "args", ")", ":", "prototype", "=", "CFUNCTYPE", "(", "restype", ",", "*", "args", ")", "return", "prototype", "(", "(", "fname", ",", "load_libdmtx", "(", ")", ")", ")" ]
Returns a foreign function exported by `libdmtx`. Args: fname (:obj:`str`): Name of the exported function as string. restype (:obj:): Return type - one of the `ctypes` primitive C data types. *args: Arguments - a sequence of `ctypes` primitive C data types. Returns: cdd...
[ "Returns", "a", "foreign", "function", "exported", "by", "libdmtx", "." ]
train
https://github.com/NaturalHistoryMuseum/pylibdmtx/blob/a425ec36050500af4875bf94eda02feb26ea62ad/pylibdmtx/wrapper.py#L46-L59
NaturalHistoryMuseum/pylibdmtx
pylibdmtx/dmtx_library.py
load
def load(): """Loads the libdmtx shared library. """ if 'Windows' == platform.system(): # Possible scenarios here # 1. Run from source, DLLs are in pylibdmtx directory # cdll.LoadLibrary() imports DLLs in repo root directory # 2. Wheel install into CPython installat...
python
def load(): """Loads the libdmtx shared library. """ if 'Windows' == platform.system(): # Possible scenarios here # 1. Run from source, DLLs are in pylibdmtx directory # cdll.LoadLibrary() imports DLLs in repo root directory # 2. Wheel install into CPython installat...
[ "def", "load", "(", ")", ":", "if", "'Windows'", "==", "platform", ".", "system", "(", ")", ":", "# Possible scenarios here", "# 1. Run from source, DLLs are in pylibdmtx directory", "# cdll.LoadLibrary() imports DLLs in repo root directory", "# 2. Wheel install into CPyt...
Loads the libdmtx shared library.
[ "Loads", "the", "libdmtx", "shared", "library", "." ]
train
https://github.com/NaturalHistoryMuseum/pylibdmtx/blob/a425ec36050500af4875bf94eda02feb26ea62ad/pylibdmtx/dmtx_library.py#L22-L50
NaturalHistoryMuseum/pylibdmtx
pylibdmtx/pylibdmtx.py
_image
def _image(pixels, width, height, pack): """A context manager for `DmtxImage`, created and destroyed by `dmtxImageCreate` and `dmtxImageDestroy`. Args: pixels (:obj:): width (int): height (int): pack (int): Yields: DmtxImage: The created image Raises: ...
python
def _image(pixels, width, height, pack): """A context manager for `DmtxImage`, created and destroyed by `dmtxImageCreate` and `dmtxImageDestroy`. Args: pixels (:obj:): width (int): height (int): pack (int): Yields: DmtxImage: The created image Raises: ...
[ "def", "_image", "(", "pixels", ",", "width", ",", "height", ",", "pack", ")", ":", "image", "=", "dmtxImageCreate", "(", "pixels", ",", "width", ",", "height", ",", "pack", ")", "if", "not", "image", ":", "raise", "PyLibDMTXError", "(", "'Could not crea...
A context manager for `DmtxImage`, created and destroyed by `dmtxImageCreate` and `dmtxImageDestroy`. Args: pixels (:obj:): width (int): height (int): pack (int): Yields: DmtxImage: The created image Raises: PyLibDMTXError: If the image could not be cre...
[ "A", "context", "manager", "for", "DmtxImage", "created", "and", "destroyed", "by", "dmtxImageCreate", "and", "dmtxImageDestroy", "." ]
train
https://github.com/NaturalHistoryMuseum/pylibdmtx/blob/a425ec36050500af4875bf94eda02feb26ea62ad/pylibdmtx/pylibdmtx.py#L57-L80
NaturalHistoryMuseum/pylibdmtx
pylibdmtx/pylibdmtx.py
_decoder
def _decoder(image, shrink): """A context manager for `DmtxDecode`, created and destroyed by `dmtxDecodeCreate` and `dmtxDecodeDestroy`. Args: image (POINTER(DmtxImage)): shrink (int): Yields: POINTER(DmtxDecode): The created decoder Raises: PyLibDMTXError: If the ...
python
def _decoder(image, shrink): """A context manager for `DmtxDecode`, created and destroyed by `dmtxDecodeCreate` and `dmtxDecodeDestroy`. Args: image (POINTER(DmtxImage)): shrink (int): Yields: POINTER(DmtxDecode): The created decoder Raises: PyLibDMTXError: If the ...
[ "def", "_decoder", "(", "image", ",", "shrink", ")", ":", "decoder", "=", "dmtxDecodeCreate", "(", "image", ",", "shrink", ")", "if", "not", "decoder", ":", "raise", "PyLibDMTXError", "(", "'Could not create decoder'", ")", "else", ":", "try", ":", "yield", ...
A context manager for `DmtxDecode`, created and destroyed by `dmtxDecodeCreate` and `dmtxDecodeDestroy`. Args: image (POINTER(DmtxImage)): shrink (int): Yields: POINTER(DmtxDecode): The created decoder Raises: PyLibDMTXError: If the decoder could not be created.
[ "A", "context", "manager", "for", "DmtxDecode", "created", "and", "destroyed", "by", "dmtxDecodeCreate", "and", "dmtxDecodeDestroy", "." ]
train
https://github.com/NaturalHistoryMuseum/pylibdmtx/blob/a425ec36050500af4875bf94eda02feb26ea62ad/pylibdmtx/pylibdmtx.py#L84-L105
NaturalHistoryMuseum/pylibdmtx
pylibdmtx/pylibdmtx.py
_region
def _region(decoder, timeout): """A context manager for `DmtxRegion`, created and destroyed by `dmtxRegionFindNext` and `dmtxRegionDestroy`. Args: decoder (POINTER(DmtxDecode)): timeout (int or None): Yields: DmtxRegion: The next region or None, if all regions have been found. ...
python
def _region(decoder, timeout): """A context manager for `DmtxRegion`, created and destroyed by `dmtxRegionFindNext` and `dmtxRegionDestroy`. Args: decoder (POINTER(DmtxDecode)): timeout (int or None): Yields: DmtxRegion: The next region or None, if all regions have been found. ...
[ "def", "_region", "(", "decoder", ",", "timeout", ")", ":", "region", "=", "dmtxRegionFindNext", "(", "decoder", ",", "timeout", ")", "try", ":", "yield", "region", "finally", ":", "if", "region", ":", "dmtxRegionDestroy", "(", "byref", "(", "region", ")",...
A context manager for `DmtxRegion`, created and destroyed by `dmtxRegionFindNext` and `dmtxRegionDestroy`. Args: decoder (POINTER(DmtxDecode)): timeout (int or None): Yields: DmtxRegion: The next region or None, if all regions have been found.
[ "A", "context", "manager", "for", "DmtxRegion", "created", "and", "destroyed", "by", "dmtxRegionFindNext", "and", "dmtxRegionDestroy", "." ]
train
https://github.com/NaturalHistoryMuseum/pylibdmtx/blob/a425ec36050500af4875bf94eda02feb26ea62ad/pylibdmtx/pylibdmtx.py#L109-L125
NaturalHistoryMuseum/pylibdmtx
pylibdmtx/pylibdmtx.py
_decoded_matrix_region
def _decoded_matrix_region(decoder, region, corrections): """A context manager for `DmtxMessage`, created and destoyed by `dmtxDecodeMatrixRegion` and `dmtxMessageDestroy`. Args: decoder (POINTER(DmtxDecode)): region (POINTER(DmtxRegion)): corrections (int): Yields: Dmt...
python
def _decoded_matrix_region(decoder, region, corrections): """A context manager for `DmtxMessage`, created and destoyed by `dmtxDecodeMatrixRegion` and `dmtxMessageDestroy`. Args: decoder (POINTER(DmtxDecode)): region (POINTER(DmtxRegion)): corrections (int): Yields: Dmt...
[ "def", "_decoded_matrix_region", "(", "decoder", ",", "region", ",", "corrections", ")", ":", "message", "=", "dmtxDecodeMatrixRegion", "(", "decoder", ",", "region", ",", "corrections", ")", "try", ":", "yield", "message", "finally", ":", "if", "message", ":"...
A context manager for `DmtxMessage`, created and destoyed by `dmtxDecodeMatrixRegion` and `dmtxMessageDestroy`. Args: decoder (POINTER(DmtxDecode)): region (POINTER(DmtxRegion)): corrections (int): Yields: DmtxMessage: The message.
[ "A", "context", "manager", "for", "DmtxMessage", "created", "and", "destoyed", "by", "dmtxDecodeMatrixRegion", "and", "dmtxMessageDestroy", "." ]
train
https://github.com/NaturalHistoryMuseum/pylibdmtx/blob/a425ec36050500af4875bf94eda02feb26ea62ad/pylibdmtx/pylibdmtx.py#L129-L146
NaturalHistoryMuseum/pylibdmtx
pylibdmtx/pylibdmtx.py
_decode_region
def _decode_region(decoder, region, corrections, shrink): """Decodes and returns the value in a region. Args: region (DmtxRegion): Yields: Decoded or None: The decoded value. """ with _decoded_matrix_region(decoder, region, corrections) as msg: if msg: # Coordin...
python
def _decode_region(decoder, region, corrections, shrink): """Decodes and returns the value in a region. Args: region (DmtxRegion): Yields: Decoded or None: The decoded value. """ with _decoded_matrix_region(decoder, region, corrections) as msg: if msg: # Coordin...
[ "def", "_decode_region", "(", "decoder", ",", "region", ",", "corrections", ",", "shrink", ")", ":", "with", "_decoded_matrix_region", "(", "decoder", ",", "region", ",", "corrections", ")", "as", "msg", ":", "if", "msg", ":", "# Coordinates", "p00", "=", ...
Decodes and returns the value in a region. Args: region (DmtxRegion): Yields: Decoded or None: The decoded value.
[ "Decodes", "and", "returns", "the", "value", "in", "a", "region", "." ]
train
https://github.com/NaturalHistoryMuseum/pylibdmtx/blob/a425ec36050500af4875bf94eda02feb26ea62ad/pylibdmtx/pylibdmtx.py#L149-L177
NaturalHistoryMuseum/pylibdmtx
pylibdmtx/pylibdmtx.py
_pixel_data
def _pixel_data(image): """Returns (pixels, width, height, bpp) Returns: :obj: `tuple` (pixels, width, height, bpp) """ # Test for PIL.Image and numpy.ndarray without requiring that cv2 or PIL # are installed. if 'PIL.' in str(type(image)): pixels = image.tobytes() width...
python
def _pixel_data(image): """Returns (pixels, width, height, bpp) Returns: :obj: `tuple` (pixels, width, height, bpp) """ # Test for PIL.Image and numpy.ndarray without requiring that cv2 or PIL # are installed. if 'PIL.' in str(type(image)): pixels = image.tobytes() width...
[ "def", "_pixel_data", "(", "image", ")", ":", "# Test for PIL.Image and numpy.ndarray without requiring that cv2 or PIL", "# are installed.", "if", "'PIL.'", "in", "str", "(", "type", "(", "image", ")", ")", ":", "pixels", "=", "image", ".", "tobytes", "(", ")", "...
Returns (pixels, width, height, bpp) Returns: :obj: `tuple` (pixels, width, height, bpp)
[ "Returns", "(", "pixels", "width", "height", "bpp", ")" ]
train
https://github.com/NaturalHistoryMuseum/pylibdmtx/blob/a425ec36050500af4875bf94eda02feb26ea62ad/pylibdmtx/pylibdmtx.py#L180-L223
NaturalHistoryMuseum/pylibdmtx
pylibdmtx/pylibdmtx.py
decode
def decode(image, timeout=None, gap_size=None, shrink=1, shape=None, deviation=None, threshold=None, min_edge=None, max_edge=None, corrections=None, max_count=None): """Decodes datamatrix barcodes in `image`. Args: image: `numpy.ndarray`, `PIL.Image` or tuple (pixels, width, heigh...
python
def decode(image, timeout=None, gap_size=None, shrink=1, shape=None, deviation=None, threshold=None, min_edge=None, max_edge=None, corrections=None, max_count=None): """Decodes datamatrix barcodes in `image`. Args: image: `numpy.ndarray`, `PIL.Image` or tuple (pixels, width, heigh...
[ "def", "decode", "(", "image", ",", "timeout", "=", "None", ",", "gap_size", "=", "None", ",", "shrink", "=", "1", ",", "shape", "=", "None", ",", "deviation", "=", "None", ",", "threshold", "=", "None", ",", "min_edge", "=", "None", ",", "max_edge",...
Decodes datamatrix barcodes in `image`. Args: image: `numpy.ndarray`, `PIL.Image` or tuple (pixels, width, height) timeout (int): milliseconds gap_size (int): shrink (int): shape (int): deviation (int): threshold (int): min_edge (int): max_edg...
[ "Decodes", "datamatrix", "barcodes", "in", "image", "." ]
train
https://github.com/NaturalHistoryMuseum/pylibdmtx/blob/a425ec36050500af4875bf94eda02feb26ea62ad/pylibdmtx/pylibdmtx.py#L226-L297
NaturalHistoryMuseum/pylibdmtx
pylibdmtx/pylibdmtx.py
encode
def encode(data, scheme=None, size=None): """ Encodes `data` in a DataMatrix image. For now bpp is the libdmtx default which is 24 Args: data: bytes instance scheme: encoding scheme - one of `ENCODING_SCHEME_NAMES`, or `None`. If `None`, defaults to 'Ascii'. size: i...
python
def encode(data, scheme=None, size=None): """ Encodes `data` in a DataMatrix image. For now bpp is the libdmtx default which is 24 Args: data: bytes instance scheme: encoding scheme - one of `ENCODING_SCHEME_NAMES`, or `None`. If `None`, defaults to 'Ascii'. size: i...
[ "def", "encode", "(", "data", ",", "scheme", "=", "None", ",", "size", "=", "None", ")", ":", "size", "=", "size", "if", "size", "else", "'ShapeAuto'", "size_name", "=", "'{0}{1}'", ".", "format", "(", "ENCODING_SIZE_PREFIX", ",", "size", ")", "if", "n...
Encodes `data` in a DataMatrix image. For now bpp is the libdmtx default which is 24 Args: data: bytes instance scheme: encoding scheme - one of `ENCODING_SCHEME_NAMES`, or `None`. If `None`, defaults to 'Ascii'. size: image dimensions - one of `ENCODING_SIZE_NAMES`, or `No...
[ "Encodes", "data", "in", "a", "DataMatrix", "image", "." ]
train
https://github.com/NaturalHistoryMuseum/pylibdmtx/blob/a425ec36050500af4875bf94eda02feb26ea62ad/pylibdmtx/pylibdmtx.py#L312-L378
GeoPyTool/GeoPyTool
geopytool/Stereo.py
Stereo.lines
def lines(self, Width=1, Color='k'): ''' read the Excel, then draw the wulf net and Plot points, job done~ ''' self.axes.clear() # self.axes.set_xlim(-90, 450) self.axes.set_ylim(0, 90) titles = list('NWSE') titles = ['N', '330', '300', 'W', '240', '210...
python
def lines(self, Width=1, Color='k'): ''' read the Excel, then draw the wulf net and Plot points, job done~ ''' self.axes.clear() # self.axes.set_xlim(-90, 450) self.axes.set_ylim(0, 90) titles = list('NWSE') titles = ['N', '330', '300', 'W', '240', '210...
[ "def", "lines", "(", "self", ",", "Width", "=", "1", ",", "Color", "=", "'k'", ")", ":", "self", ".", "axes", ".", "clear", "(", ")", "# self.axes.set_xlim(-90, 450)", "self", ".", "axes", ".", "set_ylim", "(", "0", ",", "90", ")", "titles", "=", "...
read the Excel, then draw the wulf net and Plot points, job done~
[ "read", "the", "Excel", "then", "draw", "the", "wulf", "net", "and", "Plot", "points", "job", "done~" ]
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/Stereo.py#L142-L222
GeoPyTool/GeoPyTool
Experimental/Alpah_Shape_2D.py
add_edge
def add_edge(edges, edge_points, coords, i, j): """ Add a line between the i-th and j-th points, if not in the list already """ if (i, j) in edges or (j, i) in edges: # already added return( edges.add((i, j)), edge_points.append(coords[[i, j]]))
python
def add_edge(edges, edge_points, coords, i, j): """ Add a line between the i-th and j-th points, if not in the list already """ if (i, j) in edges or (j, i) in edges: # already added return( edges.add((i, j)), edge_points.append(coords[[i, j]]))
[ "def", "add_edge", "(", "edges", ",", "edge_points", ",", "coords", ",", "i", ",", "j", ")", ":", "if", "(", "i", ",", "j", ")", "in", "edges", "or", "(", "j", ",", "i", ")", "in", "edges", ":", "# already added", "return", "(", "edges", ".", "...
Add a line between the i-th and j-th points, if not in the list already
[ "Add", "a", "line", "between", "the", "i", "-", "th", "and", "j", "-", "th", "points", "if", "not", "in", "the", "list", "already" ]
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/Experimental/Alpah_Shape_2D.py#L28-L35
GeoPyTool/GeoPyTool
Experimental/Alpah_Shape_2D.py
alpha_shape
def alpha_shape(points, alpha): """ Compute the alpha shape (concave hull) of a set of points. @param points: Iterable container of points. @param alpha: alpha value to influence the gooeyness of the border. Smaller numbers don't fall inward as much as larger numbers. Too lar...
python
def alpha_shape(points, alpha): """ Compute the alpha shape (concave hull) of a set of points. @param points: Iterable container of points. @param alpha: alpha value to influence the gooeyness of the border. Smaller numbers don't fall inward as much as larger numbers. Too lar...
[ "def", "alpha_shape", "(", "points", ",", "alpha", ")", ":", "if", "len", "(", "points", ")", "<", "4", ":", "# When you have a triangle, there is no sense", "# in computing an alpha shape.", "return", "geometry", ".", "MultiPoint", "(", "list", "(", "points", ")"...
Compute the alpha shape (concave hull) of a set of points. @param points: Iterable container of points. @param alpha: alpha value to influence the gooeyness of the border. Smaller numbers don't fall inward as much as larger numbers. Too large, and you lose everything!
[ "Compute", "the", "alpha", "shape", "(", "concave", "hull", ")", "of", "a", "set", "of", "points", "." ]
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/Experimental/Alpah_Shape_2D.py#L39-L89
GeoPyTool/GeoPyTool
geopytool/MyFA - Copy.py
MyFA.Distance_Calculation
def Distance_Calculation(self): print(self.whole_labels) distance_result={} #distance_result[self.whole_labels[i]] = [] print(distance_result) for i in range(len(self.whole_labels)): #print(self.whole_labels[i], self.fa_result[self.result_to_fit.index == self.whol...
python
def Distance_Calculation(self): print(self.whole_labels) distance_result={} #distance_result[self.whole_labels[i]] = [] print(distance_result) for i in range(len(self.whole_labels)): #print(self.whole_labels[i], self.fa_result[self.result_to_fit.index == self.whol...
[ "def", "Distance_Calculation", "(", "self", ")", ":", "print", "(", "self", ".", "whole_labels", ")", "distance_result", "=", "{", "}", "#distance_result[self.whole_labels[i]] = []", "print", "(", "distance_result", ")", "for", "i", "in", "range", "(", "len", "(...
for i in range(len(self.whole_labels)): for j in range(len(self.whole_labels)): if i ==j: pass else: distance_result[self.whole_labels[i] + ' to ' + self.whole_labels[j]] = [] self.fa_result[self.result_to_fit.index...
[ "for", "i", "in", "range", "(", "len", "(", "self", ".", "whole_labels", "))", ":", "for", "j", "in", "range", "(", "len", "(", "self", ".", "whole_labels", "))", ":", "if", "i", "==", "j", ":", "pass", "else", ":", "distance_result", "[", "self", ...
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/MyFA - Copy.py#L348-L395
GeoPyTool/GeoPyTool
geopytool/GLMultiDimension.py
GLMultiDimension.create_main_frame
def create_main_frame(self): self.main_frame = QWidget() #self.main_frame.setFixedSize(self.width(), self.width()) self.dpi = 128 self.ShapeGroups =200 self.view = gl.GLViewWidget() #self.view = pg.PlotWidget() #self.view.setFixedSize(self.width(),self.height(...
python
def create_main_frame(self): self.main_frame = QWidget() #self.main_frame.setFixedSize(self.width(), self.width()) self.dpi = 128 self.ShapeGroups =200 self.view = gl.GLViewWidget() #self.view = pg.PlotWidget() #self.view.setFixedSize(self.width(),self.height(...
[ "def", "create_main_frame", "(", "self", ")", ":", "self", ".", "main_frame", "=", "QWidget", "(", ")", "#self.main_frame.setFixedSize(self.width(), self.width())", "self", ".", "dpi", "=", "128", "self", ".", "ShapeGroups", "=", "200", "self", ".", "view", "=",...
for w in [self.fit_cb,self.fit_label, self.fit_seter,self.xlim_seter_left_label,self.xlim_seter_left,self.xlim_seter_right_label,self.xlim_seter_right,self.ylim_seter_down_label,self.ylim_seter_down,self.ylim_seter_up_label,self.ylim_seter_up,self.shape_cb]: self.hbox0.addWidget(w) self.hbox0.se...
[ "for", "w", "in", "[", "self", ".", "fit_cb", "self", ".", "fit_label", "self", ".", "fit_seter", "self", ".", "xlim_seter_left_label", "self", ".", "xlim_seter_left", "self", ".", "xlim_seter_right_label", "self", ".", "xlim_seter_right", "self", ".", "ylim_set...
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/GLMultiDimension.py#L125-L291
GeoPyTool/GeoPyTool
geopytool/GLMultiDimension.py
GLMultiDimension.Magic
def Magic(self): #self.view.setFixedSize(self.width(), self.width()) self.WholeData = [] self.x_scale = self.width_plot / self.width_load self.y_scale = self.height_plot / self.height_load self.z_scale = self.depth_plot / self.depth_load # print(self.x_scale,' and ...
python
def Magic(self): #self.view.setFixedSize(self.width(), self.width()) self.WholeData = [] self.x_scale = self.width_plot / self.width_load self.y_scale = self.height_plot / self.height_load self.z_scale = self.depth_plot / self.depth_load # print(self.x_scale,' and ...
[ "def", "Magic", "(", "self", ")", ":", "#self.view.setFixedSize(self.width(), self.width())", "self", ".", "WholeData", "=", "[", "]", "self", ".", "x_scale", "=", "self", ".", "width_plot", "/", "self", ".", "width_load", "self", ".", "y_scale", "=", "self", ...
xgrid.scale(12.8, 12.8, 12.8) ygrid.scale(12.8, 12.8, 12.8) zgrid.scale(12.8, 12.8, 12.8)
[ "xgrid", ".", "scale", "(", "12", ".", "8", "12", ".", "8", "12", ".", "8", ")", "ygrid", ".", "scale", "(", "12", ".", "8", "12", ".", "8", "12", ".", "8", ")", "zgrid", ".", "scale", "(", "12", ".", "8", "12", ".", "8", "12", ".", "8"...
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/GLMultiDimension.py#L507-L727
GeoPyTool/GeoPyTool
geopytool/XY.py
XY.create_main_frame
def create_main_frame(self): self.resize(800, 800) self.main_frame = QWidget() self.dpi = 128 self.fig = Figure((8.0, 8.0), dpi=self.dpi) self.fig.subplots_adjust(hspace=0.5, wspace=0.5, left=0.13, bottom=0.2, right=0.7, top=0.9) self.canvas = FigureCanvas(self.fig)...
python
def create_main_frame(self): self.resize(800, 800) self.main_frame = QWidget() self.dpi = 128 self.fig = Figure((8.0, 8.0), dpi=self.dpi) self.fig.subplots_adjust(hspace=0.5, wspace=0.5, left=0.13, bottom=0.2, right=0.7, top=0.9) self.canvas = FigureCanvas(self.fig)...
[ "def", "create_main_frame", "(", "self", ")", ":", "self", ".", "resize", "(", "800", ",", "800", ")", "self", ".", "main_frame", "=", "QWidget", "(", ")", "self", ".", "dpi", "=", "128", "self", ".", "fig", "=", "Figure", "(", "(", "8.0", ",", "...
self.save_plot_button.setFixedWidth(w/10) self.stat_button.setFixedWidth(w/10) self.load_data_button.setFixedWidth(w/4) self.save_predict_button_selected.setFixedWidth(w/4) self.save_predict_button.setFixedWidth(w/4)
[ "self", ".", "save_plot_button", ".", "setFixedWidth", "(", "w", "/", "10", ")", "self", ".", "stat_button", ".", "setFixedWidth", "(", "w", "/", "10", ")", "self", ".", "load_data_button", ".", "setFixedWidth", "(", "w", "/", "4", ")", "self", ".", "s...
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/XY.py#L176-L498
GeoPyTool/GeoPyTool
geopytool/QAPF.py
QAPF.create_main_frame
def create_main_frame(self): self.resize(800, 1000) self.main_frame = QWidget() self.dpi = 128 self.fig = Figure((12, 11), dpi=self.dpi) self.fig.subplots_adjust(hspace=0.5, wspace=0.5, left=0.1, bottom=0.2, right=0.7, top=0.9) # 8 * np.sqrt(3) self.canvas = Fig...
python
def create_main_frame(self): self.resize(800, 1000) self.main_frame = QWidget() self.dpi = 128 self.fig = Figure((12, 11), dpi=self.dpi) self.fig.subplots_adjust(hspace=0.5, wspace=0.5, left=0.1, bottom=0.2, right=0.7, top=0.9) # 8 * np.sqrt(3) self.canvas = Fig...
[ "def", "create_main_frame", "(", "self", ")", ":", "self", ".", "resize", "(", "800", ",", "1000", ")", "self", ".", "main_frame", "=", "QWidget", "(", ")", "self", ".", "dpi", "=", "128", "self", ".", "fig", "=", "Figure", "(", "(", "12", ",", "...
self.Tag_cb = QCheckBox('&Plutonic') self.Tag_cb.setChecked(True) self.Tag_cb.stateChanged.connect(self.QAPF) # int if (self.Tag_cb.isChecked()): self.Tag_cb.setText('&Plutonic') else: self.Tag_cb.setText('&Volcanic')
[ "self", ".", "Tag_cb", "=", "QCheckBox", "(", "&Plutonic", ")", "self", ".", "Tag_cb", ".", "setChecked", "(", "True", ")", "self", ".", "Tag_cb", ".", "stateChanged", ".", "connect", "(", "self", ".", "QAPF", ")", "#", "int", "if", "(", "self", ".",...
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/QAPF.py#L211-L303
GeoPyTool/GeoPyTool
geopytool/CustomClass.py
Tool.TriToBin
def TriToBin(self, x, y, z): ''' Turn an x-y-z triangular coord to an a-b coord. if z is negative, calc with its abs then return (a, -b). :param x,y,z: the three numbers of the triangular coord :type x,y,z: float or double are both OK, just numbers :return: the correspo...
python
def TriToBin(self, x, y, z): ''' Turn an x-y-z triangular coord to an a-b coord. if z is negative, calc with its abs then return (a, -b). :param x,y,z: the three numbers of the triangular coord :type x,y,z: float or double are both OK, just numbers :return: the correspo...
[ "def", "TriToBin", "(", "self", ",", "x", ",", "y", ",", "z", ")", ":", "if", "(", "z", ">=", "0", ")", ":", "if", "(", "x", "+", "y", "+", "z", "==", "0", ")", ":", "return", "(", "0", ",", "0", ")", "else", ":", "Sum", "=", "x", "+"...
Turn an x-y-z triangular coord to an a-b coord. if z is negative, calc with its abs then return (a, -b). :param x,y,z: the three numbers of the triangular coord :type x,y,z: float or double are both OK, just numbers :return: the corresponding a-b coord :rtype: a tuple consist ...
[ "Turn", "an", "x", "-", "y", "-", "z", "triangular", "coord", "to", "an", "a", "-", "b", "coord", ".", "if", "z", "is", "negative", "calc", "with", "its", "abs", "then", "return", "(", "a", "-", "b", ")", ".", ":", "param", "x", "y", "z", ":"...
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/CustomClass.py#L28-L67
GeoPyTool/GeoPyTool
geopytool/CustomClass.py
Tool.BinToTri
def BinToTri(self, a, b): ''' Turn an a-b coord to an x-y-z triangular coord . if z is negative, calc with its abs then return (a, -b). :param a,b: the numbers of the a-b coord :type a,b: float or double are both OK, just numbers :return: the corresponding x-y-z triangu...
python
def BinToTri(self, a, b): ''' Turn an a-b coord to an x-y-z triangular coord . if z is negative, calc with its abs then return (a, -b). :param a,b: the numbers of the a-b coord :type a,b: float or double are both OK, just numbers :return: the corresponding x-y-z triangu...
[ "def", "BinToTri", "(", "self", ",", "a", ",", "b", ")", ":", "if", "(", "b", ">=", "0", ")", ":", "y", "=", "a", "-", "b", "/", "np", ".", "sqrt", "(", "3", ")", "z", "=", "b", "*", "2", "/", "np", ".", "sqrt", "(", "3", ")", "x", ...
Turn an a-b coord to an x-y-z triangular coord . if z is negative, calc with its abs then return (a, -b). :param a,b: the numbers of the a-b coord :type a,b: float or double are both OK, just numbers :return: the corresponding x-y-z triangular coord :rtype: a tuple consist of ...
[ "Turn", "an", "a", "-", "b", "coord", "to", "an", "x", "-", "y", "-", "z", "triangular", "coord", ".", "if", "z", "is", "negative", "calc", "with", "its", "abs", "then", "return", "(", "a", "-", "b", ")", ".", ":", "param", "a", "b", ":", "th...
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/CustomClass.py#L69-L89
GeoPyTool/GeoPyTool
geopytool/CustomClass.py
Tool.Cross
def Cross(self, A=[(0, 0), (10, 10)], B=[(0, 10), (100, 0)]): ''' Return the crosspoint of two line A and B. :param A: first line :type A: a list consist of two tuples, beginning and end point of the line :param B: second line :type B: a list consist of two tuples, begin...
python
def Cross(self, A=[(0, 0), (10, 10)], B=[(0, 10), (100, 0)]): ''' Return the crosspoint of two line A and B. :param A: first line :type A: a list consist of two tuples, beginning and end point of the line :param B: second line :type B: a list consist of two tuples, begin...
[ "def", "Cross", "(", "self", ",", "A", "=", "[", "(", "0", ",", "0", ")", ",", "(", "10", ",", "10", ")", "]", ",", "B", "=", "[", "(", "0", ",", "10", ")", ",", "(", "100", ",", "0", ")", "]", ")", ":", "x0", ",", "y0", "=", "A", ...
Return the crosspoint of two line A and B. :param A: first line :type A: a list consist of two tuples, beginning and end point of the line :param B: second line :type B: a list consist of two tuples, beginning and end point of the line :return: the crosspoint of A and B :...
[ "Return", "the", "crosspoint", "of", "two", "line", "A", "and", "B", ".", ":", "param", "A", ":", "first", "line", ":", "type", "A", ":", "a", "list", "consist", "of", "two", "tuples", "beginning", "and", "end", "point", "of", "the", "line", ":", "...
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/CustomClass.py#L91-L116
GeoPyTool/GeoPyTool
geopytool/CustomClass.py
Tool.TriCross
def TriCross(self, A=[(100, 0, 0), (0, 50, 60)], B=[(50, 50, 0), (0, 0, 100)]): ''' Return the crosspoint of two line A and B in triangular coord. :param A: first line :type A: a list consist of two tuples, beginning and end point of the line :param B: second line :type ...
python
def TriCross(self, A=[(100, 0, 0), (0, 50, 60)], B=[(50, 50, 0), (0, 0, 100)]): ''' Return the crosspoint of two line A and B in triangular coord. :param A: first line :type A: a list consist of two tuples, beginning and end point of the line :param B: second line :type ...
[ "def", "TriCross", "(", "self", ",", "A", "=", "[", "(", "100", ",", "0", ",", "0", ")", ",", "(", "0", ",", "50", ",", "60", ")", "]", ",", "B", "=", "[", "(", "50", ",", "50", ",", "0", ")", ",", "(", "0", ",", "0", ",", "100", ")...
Return the crosspoint of two line A and B in triangular coord. :param A: first line :type A: a list consist of two tuples, beginning and end point of the line :param B: second line :type B: a list consist of two tuples, beginning and end point of the line :return: the crosspoint...
[ "Return", "the", "crosspoint", "of", "two", "line", "A", "and", "B", "in", "triangular", "coord", ".", ":", "param", "A", ":", "first", "line", ":", "type", "A", ":", "a", "list", "consist", "of", "two", "tuples", "beginning", "and", "end", "point", ...
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/CustomClass.py#L118-L144
GeoPyTool/GeoPyTool
geopytool/CustomClass.py
Tool.Fill
def Fill(self, P=[(100, 0), (85, 15), (0, 3)], Color='blue', Alpha=0.3): ''' Fill a region in planimetric rectangular coord. :param P: the peak points of the region in planimetric rectangular coord :type P: a list consist of at least three tuples, which are the points in planimetric rec...
python
def Fill(self, P=[(100, 0), (85, 15), (0, 3)], Color='blue', Alpha=0.3): ''' Fill a region in planimetric rectangular coord. :param P: the peak points of the region in planimetric rectangular coord :type P: a list consist of at least three tuples, which are the points in planimetric rec...
[ "def", "Fill", "(", "self", ",", "P", "=", "[", "(", "100", ",", "0", ")", ",", "(", "85", ",", "15", ")", ",", "(", "0", ",", "3", ")", "]", ",", "Color", "=", "'blue'", ",", "Alpha", "=", "0.3", ")", ":", "a", "=", "[", "]", "b", "=...
Fill a region in planimetric rectangular coord. :param P: the peak points of the region in planimetric rectangular coord :type P: a list consist of at least three tuples, which are the points in planimetric rectangular coord :param Color: the color used to fill the region :type Color: a ...
[ "Fill", "a", "region", "in", "planimetric", "rectangular", "coord", ".", ":", "param", "P", ":", "the", "peak", "points", "of", "the", "region", "in", "planimetric", "rectangular", "coord", ":", "type", "P", ":", "a", "list", "consist", "of", "at", "leas...
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/CustomClass.py#L146-L164
GeoPyTool/GeoPyTool
geopytool/CustomClass.py
Tool.TriFill
def TriFill(self, P=[(100, 0, 0), (85, 15, 0), (0, 3, 97)], Color='blue', Alpha=0.3): ''' Fill a region in triangular coord. :param P: the peak points of the region in triangular coord :type P: a list consist of at least three tuples, which are the points in triangular coord :p...
python
def TriFill(self, P=[(100, 0, 0), (85, 15, 0), (0, 3, 97)], Color='blue', Alpha=0.3): ''' Fill a region in triangular coord. :param P: the peak points of the region in triangular coord :type P: a list consist of at least three tuples, which are the points in triangular coord :p...
[ "def", "TriFill", "(", "self", ",", "P", "=", "[", "(", "100", ",", "0", ",", "0", ")", ",", "(", "85", ",", "15", ",", "0", ")", ",", "(", "0", ",", "3", ",", "97", ")", "]", ",", "Color", "=", "'blue'", ",", "Alpha", "=", "0.3", ")", ...
Fill a region in triangular coord. :param P: the peak points of the region in triangular coord :type P: a list consist of at least three tuples, which are the points in triangular coord :param Color: the color used to fill the region :type Color: a string; b: blue, g: green, r: red, c: c...
[ "Fill", "a", "region", "in", "triangular", "coord", ".", ":", "param", "P", ":", "the", "peak", "points", "of", "the", "region", "in", "triangular", "coord", ":", "type", "P", ":", "a", "list", "consist", "of", "at", "least", "three", "tuples", "which"...
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/CustomClass.py#L166-L185
GeoPyTool/GeoPyTool
geopytool/CustomClass.py
Line.sequence
def sequence(self): ''' sort the points in the line with given option ''' if (len(self.Points[0]) == 2): if (self.Sort == 'X' or self.Sort == 'x'): self.Points.sort(key=lambda x: x[0]) self.order(self.Points) elif (self.Sort == 'Y'...
python
def sequence(self): ''' sort the points in the line with given option ''' if (len(self.Points[0]) == 2): if (self.Sort == 'X' or self.Sort == 'x'): self.Points.sort(key=lambda x: x[0]) self.order(self.Points) elif (self.Sort == 'Y'...
[ "def", "sequence", "(", "self", ")", ":", "if", "(", "len", "(", "self", ".", "Points", "[", "0", "]", ")", "==", "2", ")", ":", "if", "(", "self", ".", "Sort", "==", "'X'", "or", "self", ".", "Sort", "==", "'x'", ")", ":", "self", ".", "Po...
sort the points in the line with given option
[ "sort", "the", "points", "in", "the", "line", "with", "given", "option" ]
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/CustomClass.py#L367-L394
GeoPyTool/GeoPyTool
geopytool/CustomClass.py
TableViewer.resizeEvent
def resizeEvent(self, evt=None): w = self.width() h = self.height() ''' if h<=360: h=360 self.resize(w,h) if w<=640: w = 640 self.resize(w, h) ''' step = (w * 94 / 100) / 5 foot = h * 3 / 48
python
def resizeEvent(self, evt=None): w = self.width() h = self.height() ''' if h<=360: h=360 self.resize(w,h) if w<=640: w = 640 self.resize(w, h) ''' step = (w * 94 / 100) / 5 foot = h * 3 / 48
[ "def", "resizeEvent", "(", "self", ",", "evt", "=", "None", ")", ":", "w", "=", "self", ".", "width", "(", ")", "h", "=", "self", ".", "height", "(", ")", "step", "=", "(", "w", "*", "94", "/", "100", ")", "/", "5", "foot", "=", "h", "*", ...
if h<=360: h=360 self.resize(w,h) if w<=640: w = 640 self.resize(w, h)
[ "if", "h<", "=", "360", ":", "h", "=", "360", "self", ".", "resize", "(", "w", "h", ")", "if", "w<", "=", "640", ":", "w", "=", "640", "self", ".", "resize", "(", "w", "h", ")" ]
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/CustomClass.py#L813-L827
GeoPyTool/GeoPyTool
geopytool/K2OSiO2.py
K2OSiO2.K2OSiO2
def K2OSiO2(self, Left=35, Right=79, X0=30, X1=90, X_Gap=7, Base=0, Top=19, Y0=1, Y1=19, Y_Gap=19, FontSize=12, xlabel=r'$SiO_2 wt\%$', ylabel=r'$K_2O wt\%$', width=12, height=12, dpi=300): self.setWindowTitle('K2OSiO2 diagram ') self.axes.clear() #self.axes.axis('off') ...
python
def K2OSiO2(self, Left=35, Right=79, X0=30, X1=90, X_Gap=7, Base=0, Top=19, Y0=1, Y1=19, Y_Gap=19, FontSize=12, xlabel=r'$SiO_2 wt\%$', ylabel=r'$K_2O wt\%$', width=12, height=12, dpi=300): self.setWindowTitle('K2OSiO2 diagram ') self.axes.clear() #self.axes.axis('off') ...
[ "def", "K2OSiO2", "(", "self", ",", "Left", "=", "35", ",", "Right", "=", "79", ",", "X0", "=", "30", ",", "X1", "=", "90", ",", "X_Gap", "=", "7", ",", "Base", "=", "0", ",", "Top", "=", "19", ",", "Y0", "=", "1", ",", "Y1", "=", "19", ...
self.axes.set_xticks([30,40,50,60,70,80,90]) self.axes.set_xticklabels([30,40,50,60,70,80,90]) self.axes.set_yticks([0, 5, 10, 15, 20]) self.axes.set_yticklabels([0, 5, 10, 15, 20]) self.axes.set_ylim(bottom=0)
[ "self", ".", "axes", ".", "set_xticks", "(", "[", "30", "40", "50", "60", "70", "80", "90", "]", ")", "self", ".", "axes", ".", "set_xticklabels", "(", "[", "30", "40", "50", "60", "70", "80", "90", "]", ")" ]
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/K2OSiO2.py#L122-L471
GeoPyTool/GeoPyTool
geopytool/REE.py
REE.REE
def REE(self, Left=0, Right=16, X0=1, X1=15, X_Gap=15, Base=-1, Top=6, Y0=-1, Y1=3, Y_Gap=5, FontSize=12, xLabel=r'$REE-Standardlized-Pattern$', yLabel='', width=12, height=12, dpi=300): self.axes.clear() self.axes.spines['right'].set_color('none') self.axes....
python
def REE(self, Left=0, Right=16, X0=1, X1=15, X_Gap=15, Base=-1, Top=6, Y0=-1, Y1=3, Y_Gap=5, FontSize=12, xLabel=r'$REE-Standardlized-Pattern$', yLabel='', width=12, height=12, dpi=300): self.axes.clear() self.axes.spines['right'].set_color('none') self.axes....
[ "def", "REE", "(", "self", ",", "Left", "=", "0", ",", "Right", "=", "16", ",", "X0", "=", "1", ",", "X1", "=", "15", ",", "X_Gap", "=", "15", ",", "Base", "=", "-", "1", ",", "Top", "=", "6", ",", "Y0", "=", "-", "1", ",", "Y1", "=", ...
self.LaPrDeltaCeList.append(firstCe) self.LaNdDeltaCeList.append(secondCe)
[ "self", ".", "LaPrDeltaCeList", ".", "append", "(", "firstCe", ")", "self", ".", "LaNdDeltaCeList", ".", "append", "(", "secondCe", ")" ]
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/REE.py#L252-L584
GeoPyTool/GeoPyTool
geopytool/NewCIPW.py
CIPW.create_main_frame
def create_main_frame(self): self.resize(800, 600) self.main_frame = QWidget() self.dpi = 128 self.save_button = QPushButton('&Save Result') self.save_button.clicked.connect(self.saveResult) self.qapf_button = QPushButton('&QAPF') self.qapf_button.clicked.con...
python
def create_main_frame(self): self.resize(800, 600) self.main_frame = QWidget() self.dpi = 128 self.save_button = QPushButton('&Save Result') self.save_button.clicked.connect(self.saveResult) self.qapf_button = QPushButton('&QAPF') self.qapf_button.clicked.con...
[ "def", "create_main_frame", "(", "self", ")", ":", "self", ".", "resize", "(", "800", ",", "600", ")", "self", ".", "main_frame", "=", "QWidget", "(", ")", "self", ".", "dpi", "=", "128", "self", ".", "save_button", "=", "QPushButton", "(", "'&Save Res...
self.tableView = CustomQTableView(self.main_frame) self.tableView.setObjectName('tableView') self.tableView.setSortingEnabled(True)
[ "self", ".", "tableView", "=", "CustomQTableView", "(", "self", ".", "main_frame", ")", "self", ".", "tableView", ".", "setObjectName", "(", "tableView", ")", "self", ".", "tableView", ".", "setSortingEnabled", "(", "True", ")" ]
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/NewCIPW.py#L162-L221
GeoPyTool/GeoPyTool
geopytool/NewCIPW.py
CIPW.singleCalc
def singleCalc(self, m={'Al2O3': 13.01, 'Alpha': 0.6, 'Ba': 188.0, 'Be': 0.85, 'CaO': 8.35, 'Ce': 28.2, 'Co': 45.2, 'Cr': 117.0, 'Cs': 0.83, 'Cu': 53.5, 'Dy': 5.58, 'Er': 2.96, 'Eu': 1.79, 'Fe2O3': 14.47, 'FeO': 5.51, 'Ga': 19.4, 'Gd': 5.24, 'Hf': 3.38, 'Ho...
python
def singleCalc(self, m={'Al2O3': 13.01, 'Alpha': 0.6, 'Ba': 188.0, 'Be': 0.85, 'CaO': 8.35, 'Ce': 28.2, 'Co': 45.2, 'Cr': 117.0, 'Cs': 0.83, 'Cu': 53.5, 'Dy': 5.58, 'Er': 2.96, 'Eu': 1.79, 'Fe2O3': 14.47, 'FeO': 5.51, 'Ga': 19.4, 'Gd': 5.24, 'Hf': 3.38, 'Ho...
[ "def", "singleCalc", "(", "self", ",", "m", "=", "{", "'Al2O3'", ":", "13.01", ",", "'Alpha'", ":", "0.6", ",", "'Ba'", ":", "188.0", ",", "'Be'", ":", "0.85", ",", "'CaO'", ":", "8.35", ",", "'Ce'", ":", "28.2", ",", "'Co'", ":", "45.2", ",", ...
Seem like should be =IF(AD7>0,IF(AD12>AD7,'Anorthite','Corundum'),'None') If Al2O3 is left after alloting orthoclase and albite, then: Anorthite = Al2O3, CaO = CaO - Al2O3, SiO2 = SiO2 - 2 Al2O3, Al2O3 = 0 If Al2O3 exceeds CaO in the preceding calculation, then: Anorthite = CaO, Al2O3 =...
[ "Seem", "like", "should", "be", "=", "IF", "(", "AD7", ">", "0", "IF", "(", "AD12", ">", "AD7", "Anorthite", "Corundum", ")", "None", ")" ]
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/NewCIPW.py#L307-L1492
GeoPyTool/GeoPyTool
geopytool/__init__.py
Ui_MainWindow.retranslateUi
def retranslateUi(self): _translate = QtCore.QCoreApplication.translate self.talk= _translate('MainWindow','You are using GeoPyTool ') + version +'\n'+ _translate('MainWindow','released on ') + date + '\n' self.menuFile.setTitle(_translate('MainWindow', u'Data File')) self.menuGeoChem....
python
def retranslateUi(self): _translate = QtCore.QCoreApplication.translate self.talk= _translate('MainWindow','You are using GeoPyTool ') + version +'\n'+ _translate('MainWindow','released on ') + date + '\n' self.menuFile.setTitle(_translate('MainWindow', u'Data File')) self.menuGeoChem....
[ "def", "retranslateUi", "(", "self", ")", ":", "_translate", "=", "QtCore", ".", "QCoreApplication", ".", "translate", "self", ".", "talk", "=", "_translate", "(", "'MainWindow'", ",", "'You are using GeoPyTool '", ")", "+", "version", "+", "'\\n'", "+", "_tra...
self.actionCnS.setText(_translate('MainWindow',u'Simplified Chinese')) self.actionCnT.setText(_translate('MainWindow', u'Traditional Chinese')) self.actionEn.setText(_translate('MainWindow',u'English'))
[ "self", ".", "actionCnS", ".", "setText", "(", "_translate", "(", "MainWindow", "u", "Simplified", "Chinese", "))", "self", ".", "actionCnT", ".", "setText", "(", "_translate", "(", "MainWindow", "u", "Traditional", "Chinese", "))", "self", ".", "actionEn", ...
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/__init__.py#L580-L675
GeoPyTool/GeoPyTool
geopytool/Rose.py
Rose.singlerose
def singlerose(self, Width=1, Color=['red']): ''' draw the rose map of single sample with different items~ ''' self.chooser_label.setText(self.ChooseItems[self.chooser.value() - 1]) self.MultipleRoseName = self.ChooseItems[self.chooser.value() - 1] self.SingleRoseName =...
python
def singlerose(self, Width=1, Color=['red']): ''' draw the rose map of single sample with different items~ ''' self.chooser_label.setText(self.ChooseItems[self.chooser.value() - 1]) self.MultipleRoseName = self.ChooseItems[self.chooser.value() - 1] self.SingleRoseName =...
[ "def", "singlerose", "(", "self", ",", "Width", "=", "1", ",", "Color", "=", "[", "'red'", "]", ")", ":", "self", ".", "chooser_label", ".", "setText", "(", "self", ".", "ChooseItems", "[", "self", ".", "chooser", ".", "value", "(", ")", "-", "1", ...
draw the rose map of single sample with different items~
[ "draw", "the", "rose", "map", "of", "single", "sample", "with", "different", "items~" ]
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/Rose.py#L154-L265
GeoPyTool/GeoPyTool
geopytool/Rose.py
Rose.multirose
def multirose(self, Width=1, Name='Dip'): ''' draw the rose map of multiple samples~ ''' Name = self.MultipleRoseName self.axes.clear() # self.axes.set_xlim(-90, 450) # self.axes.set_ylim(0, 90) titles = list('NWSE') titles = ['N', '330', '300'...
python
def multirose(self, Width=1, Name='Dip'): ''' draw the rose map of multiple samples~ ''' Name = self.MultipleRoseName self.axes.clear() # self.axes.set_xlim(-90, 450) # self.axes.set_ylim(0, 90) titles = list('NWSE') titles = ['N', '330', '300'...
[ "def", "multirose", "(", "self", ",", "Width", "=", "1", ",", "Name", "=", "'Dip'", ")", ":", "Name", "=", "self", ".", "MultipleRoseName", "self", ".", "axes", ".", "clear", "(", ")", "# self.axes.set_xlim(-90, 450)", "# self.axes.set_ylim(0, 90)", "titles", ...
draw the rose map of multiple samples~
[ "draw", "the", "rose", "map", "of", "multiple", "samples~" ]
train
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/Rose.py#L267-L365
HDI-Project/MLPrimitives
mlprimitives/adapters/pandas.py
resample
def resample(df, rule, time_index, groupby=None, aggregation='mean'): """pd.DataFrame.resample adapter. Call the `df.resample` method on the given time_index and afterwards call the indicated aggregation. Optionally group the dataframe by the indicated columns before performing the resampling. ...
python
def resample(df, rule, time_index, groupby=None, aggregation='mean'): """pd.DataFrame.resample adapter. Call the `df.resample` method on the given time_index and afterwards call the indicated aggregation. Optionally group the dataframe by the indicated columns before performing the resampling. ...
[ "def", "resample", "(", "df", ",", "rule", ",", "time_index", ",", "groupby", "=", "None", ",", "aggregation", "=", "'mean'", ")", ":", "if", "groupby", ":", "df", "=", "df", ".", "groupby", "(", "groupby", ")", "df", "=", "df", ".", "resample", "(...
pd.DataFrame.resample adapter. Call the `df.resample` method on the given time_index and afterwards call the indicated aggregation. Optionally group the dataframe by the indicated columns before performing the resampling. If groupby option is used, the result is a multi-index datagrame. Args...
[ "pd", ".", "DataFrame", ".", "resample", "adapter", "." ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/adapters/pandas.py#L1-L30
HDI-Project/MLPrimitives
mlprimitives/adapters/pandas.py
_join_names
def _join_names(names): """Join the names of a multi-level index with an underscore.""" levels = (str(name) for name in names if name != '') return '_'.join(levels)
python
def _join_names(names): """Join the names of a multi-level index with an underscore.""" levels = (str(name) for name in names if name != '') return '_'.join(levels)
[ "def", "_join_names", "(", "names", ")", ":", "levels", "=", "(", "str", "(", "name", ")", "for", "name", "in", "names", "if", "name", "!=", "''", ")", "return", "'_'", ".", "join", "(", "levels", ")" ]
Join the names of a multi-level index with an underscore.
[ "Join", "the", "names", "of", "a", "multi", "-", "level", "index", "with", "an", "underscore", "." ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/adapters/pandas.py#L33-L37
HDI-Project/MLPrimitives
mlprimitives/adapters/pandas.py
unstack
def unstack(df, level=-1, reset_index=True): """pd.DataFrame.unstack adapter. Call the `df.unstack` method using the indicated level and afterwards join the column names using an underscore. Args: df (pandas.DataFrame): DataFrame to unstack. level (str, int or list): Level(s) of index ...
python
def unstack(df, level=-1, reset_index=True): """pd.DataFrame.unstack adapter. Call the `df.unstack` method using the indicated level and afterwards join the column names using an underscore. Args: df (pandas.DataFrame): DataFrame to unstack. level (str, int or list): Level(s) of index ...
[ "def", "unstack", "(", "df", ",", "level", "=", "-", "1", ",", "reset_index", "=", "True", ")", ":", "df", "=", "df", ".", "unstack", "(", "level", "=", "level", ")", "if", "reset_index", ":", "df", "=", "df", ".", "reset_index", "(", ")", "df", ...
pd.DataFrame.unstack adapter. Call the `df.unstack` method using the indicated level and afterwards join the column names using an underscore. Args: df (pandas.DataFrame): DataFrame to unstack. level (str, int or list): Level(s) of index to unstack, can pass level name reset_index ...
[ "pd", ".", "DataFrame", ".", "unstack", "adapter", "." ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/adapters/pandas.py#L40-L59
HDI-Project/MLPrimitives
mlprimitives/candidates/dsp.py
next_power_of_2
def next_power_of_2(x): """Finds the next power of 2 value Args: x: Input value Returns: power_of_2: Next power of 2 value """ power_of_2 = 1 if x == 0 else 2 ** np.ceil(np.log2(x)) return power_of_2
python
def next_power_of_2(x): """Finds the next power of 2 value Args: x: Input value Returns: power_of_2: Next power of 2 value """ power_of_2 = 1 if x == 0 else 2 ** np.ceil(np.log2(x)) return power_of_2
[ "def", "next_power_of_2", "(", "x", ")", ":", "power_of_2", "=", "1", "if", "x", "==", "0", "else", "2", "**", "np", ".", "ceil", "(", "np", ".", "log2", "(", "x", ")", ")", "return", "power_of_2" ]
Finds the next power of 2 value Args: x: Input value Returns: power_of_2: Next power of 2 value
[ "Finds", "the", "next", "power", "of", "2", "value", "Args", ":", "x", ":", "Input", "value", "Returns", ":", "power_of_2", ":", "Next", "power", "of", "2", "value" ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/candidates/dsp.py#L4-L16
HDI-Project/MLPrimitives
mlprimitives/candidates/dsp.py
SpectralMask.window_design
def window_design(self, window_length, beta): """Kaiser window design Args: window_length: Length of the window in number of samples beta: Beta value for Kaiser window design Returns: window: Window designed using the beta and length provided as inpu...
python
def window_design(self, window_length, beta): """Kaiser window design Args: window_length: Length of the window in number of samples beta: Beta value for Kaiser window design Returns: window: Window designed using the beta and length provided as inpu...
[ "def", "window_design", "(", "self", ",", "window_length", ",", "beta", ")", ":", "self", ".", "window", "=", "np", ".", "kaiser", "(", "window_length", ",", "beta", ")", "return", "self", ".", "window" ]
Kaiser window design Args: window_length: Length of the window in number of samples beta: Beta value for Kaiser window design Returns: window: Window designed using the beta and length provided as inputs
[ "Kaiser", "window", "design", "Args", ":", "window_length", ":", "Length", "of", "the", "window", "in", "number", "of", "samples", "beta", ":", "Beta", "value", "for", "Kaiser", "window", "design", "Returns", ":", "window", ":", "Window", "designed", "using"...
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/candidates/dsp.py#L44-L58
HDI-Project/MLPrimitives
mlprimitives/candidates/dsp.py
SpectralMask.fit
def fit(self, X): """Defines a spectral mask based on training data Args: X: Training data """ training_signal = X self.window_design(self.window_length, self.beta) if self.method == 'std_dev': self.fit_freq_std_dev(training_signa...
python
def fit(self, X): """Defines a spectral mask based on training data Args: X: Training data """ training_signal = X self.window_design(self.window_length, self.beta) if self.method == 'std_dev': self.fit_freq_std_dev(training_signa...
[ "def", "fit", "(", "self", ",", "X", ")", ":", "training_signal", "=", "X", "self", ".", "window_design", "(", "self", ".", "window_length", ",", "self", ".", "beta", ")", "if", "self", ".", "method", "==", "'std_dev'", ":", "self", ".", "fit_freq_std_...
Defines a spectral mask based on training data Args: X: Training data
[ "Defines", "a", "spectral", "mask", "based", "on", "training", "data", "Args", ":", "X", ":", "Training", "data" ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/candidates/dsp.py#L60-L77
HDI-Project/MLPrimitives
mlprimitives/candidates/dsp.py
SpectralMask.fit_freq_min_max
def fit_freq_min_max(self, training_signal): """Defines a spectral mask based on training data using min and max values of each frequency component Args: training_signal: Training data """ window_length = len(self.window) window_weight = sum(...
python
def fit_freq_min_max(self, training_signal): """Defines a spectral mask based on training data using min and max values of each frequency component Args: training_signal: Training data """ window_length = len(self.window) window_weight = sum(...
[ "def", "fit_freq_min_max", "(", "self", ",", "training_signal", ")", ":", "window_length", "=", "len", "(", "self", ".", "window", ")", "window_weight", "=", "sum", "(", "self", ".", "window", ")", "max_mask", "=", "np", ".", "zeros", "(", "int", "(", ...
Defines a spectral mask based on training data using min and max values of each frequency component Args: training_signal: Training data
[ "Defines", "a", "spectral", "mask", "based", "on", "training", "data", "using", "min", "and", "max", "values", "of", "each", "frequency", "component", "Args", ":", "training_signal", ":", "Training", "data" ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/candidates/dsp.py#L79-L100
HDI-Project/MLPrimitives
mlprimitives/candidates/dsp.py
SpectralMask.fit_freq_std_dev
def fit_freq_std_dev(self, training_signal): """Defines a spectral mask based on training data using the standard deviation values of each frequency component Args: training_signal: Training data """ window_length = len(self.window) window_we...
python
def fit_freq_std_dev(self, training_signal): """Defines a spectral mask based on training data using the standard deviation values of each frequency component Args: training_signal: Training data """ window_length = len(self.window) window_we...
[ "def", "fit_freq_std_dev", "(", "self", ",", "training_signal", ")", ":", "window_length", "=", "len", "(", "self", ".", "window", ")", "window_weight", "=", "sum", "(", "self", ".", "window", ")", "num_of_windows", "=", "len", "(", "training_signal", ")", ...
Defines a spectral mask based on training data using the standard deviation values of each frequency component Args: training_signal: Training data
[ "Defines", "a", "spectral", "mask", "based", "on", "training", "data", "using", "the", "standard", "deviation", "values", "of", "each", "frequency", "component", "Args", ":", "training_signal", ":", "Training", "data" ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/candidates/dsp.py#L102-L134
HDI-Project/MLPrimitives
mlprimitives/candidates/dsp.py
SpectralMask.produce
def produce(self, X): """Detects anomalies in telemetry data based on its power spectral density Args: X: Telemetry data Returns: anomalies: Data vector consisting of the anomalies detected in the telemetry data """ signal = X win...
python
def produce(self, X): """Detects anomalies in telemetry data based on its power spectral density Args: X: Telemetry data Returns: anomalies: Data vector consisting of the anomalies detected in the telemetry data """ signal = X win...
[ "def", "produce", "(", "self", ",", "X", ")", ":", "signal", "=", "X", "window_length", "=", "len", "(", "self", ".", "window", ")", "anomalies", "=", "np", ".", "zeros", "(", "len", "(", "signal", ")", ")", "window_weight", "=", "sum", "(", "self"...
Detects anomalies in telemetry data based on its power spectral density Args: X: Telemetry data Returns: anomalies: Data vector consisting of the anomalies detected in the telemetry data
[ "Detects", "anomalies", "in", "telemetry", "data", "based", "on", "its", "power", "spectral", "density", "Args", ":", "X", ":", "Telemetry", "data", "Returns", ":", "anomalies", ":", "Data", "vector", "consisting", "of", "the", "anomalies", "detected", "in", ...
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/candidates/dsp.py#L136-L161
HDI-Project/MLPrimitives
mlprimitives/datasets.py
load_boston_multitask
def load_boston_multitask(): """Boston House Prices Dataset with a synthetic multitask output. The multitask output is obtained by applying a linear transformation to the original y and adding it as a second output column. """ dataset = datasets.load_boston() y = dataset.target target = np....
python
def load_boston_multitask(): """Boston House Prices Dataset with a synthetic multitask output. The multitask output is obtained by applying a linear transformation to the original y and adding it as a second output column. """ dataset = datasets.load_boston() y = dataset.target target = np....
[ "def", "load_boston_multitask", "(", ")", ":", "dataset", "=", "datasets", ".", "load_boston", "(", ")", "y", "=", "dataset", ".", "target", "target", "=", "np", ".", "column_stack", "(", "[", "y", ",", "2", "*", "y", "+", "5", "]", ")", "return", ...
Boston House Prices Dataset with a synthetic multitask output. The multitask output is obtained by applying a linear transformation to the original y and adding it as a second output column.
[ "Boston", "House", "Prices", "Dataset", "with", "a", "synthetic", "multitask", "output", "." ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/datasets.py#L482-L491
HDI-Project/MLPrimitives
mlprimitives/candidates/audio_featurization.py
energy
def energy(data): """Computes signal energy of data""" data = np.mean(data, axis=1) return np.sum(data ** 2) / np.float64(len(data))
python
def energy(data): """Computes signal energy of data""" data = np.mean(data, axis=1) return np.sum(data ** 2) / np.float64(len(data))
[ "def", "energy", "(", "data", ")", ":", "data", "=", "np", ".", "mean", "(", "data", ",", "axis", "=", "1", ")", "return", "np", ".", "sum", "(", "data", "**", "2", ")", "/", "np", ".", "float64", "(", "len", "(", "data", ")", ")" ]
Computes signal energy of data
[ "Computes", "signal", "energy", "of", "data" ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/candidates/audio_featurization.py#L10-L13
HDI-Project/MLPrimitives
mlprimitives/candidates/audio_featurization.py
spectral_entropy
def spectral_entropy(data, numOfShortBlocks=10): """Computes the spectral entropy""" data = np.mean(data, axis=1) nFFT = len(data) // 2 X = FFT(data, nFFT) L = len(X) # number of frame data Eol = np.sum(X ** 2) # total spectral energy subWinLength = int(n...
python
def spectral_entropy(data, numOfShortBlocks=10): """Computes the spectral entropy""" data = np.mean(data, axis=1) nFFT = len(data) // 2 X = FFT(data, nFFT) L = len(X) # number of frame data Eol = np.sum(X ** 2) # total spectral energy subWinLength = int(n...
[ "def", "spectral_entropy", "(", "data", ",", "numOfShortBlocks", "=", "10", ")", ":", "data", "=", "np", ".", "mean", "(", "data", ",", "axis", "=", "1", ")", "nFFT", "=", "len", "(", "data", ")", "//", "2", "X", "=", "FFT", "(", "data", ",", "...
Computes the spectral entropy
[ "Computes", "the", "spectral", "entropy" ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/candidates/audio_featurization.py#L22-L42
HDI-Project/MLPrimitives
mlprimitives/candidates/audio_featurization.py
zcr
def zcr(data): """Computes zero crossing rate of segment""" data = np.mean(data, axis=1) count = len(data) countZ = np.sum(np.abs(np.diff(np.sign(data)))) / 2 return (np.float64(countZ) / np.float64(count - 1.0))
python
def zcr(data): """Computes zero crossing rate of segment""" data = np.mean(data, axis=1) count = len(data) countZ = np.sum(np.abs(np.diff(np.sign(data)))) / 2 return (np.float64(countZ) / np.float64(count - 1.0))
[ "def", "zcr", "(", "data", ")", ":", "data", "=", "np", ".", "mean", "(", "data", ",", "axis", "=", "1", ")", "count", "=", "len", "(", "data", ")", "countZ", "=", "np", ".", "sum", "(", "np", ".", "abs", "(", "np", ".", "diff", "(", "np", ...
Computes zero crossing rate of segment
[ "Computes", "zero", "crossing", "rate", "of", "segment" ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/candidates/audio_featurization.py#L51-L57
HDI-Project/MLPrimitives
mlprimitives/candidates/audio_featurization.py
spectral_flux
def spectral_flux(d0, d1): """ Computes the spectral flux feature of the current frame """ # compute the spectral flux as the sum of square distances: d0 = np.mean(d0, axis=1) d1 = np.mean(d1, axis=1) nFFT = min(len(d0) // 2, len(d1) // 2) X = FFT(d0, nFFT) Xprev = FFT(d1, nFFT) ...
python
def spectral_flux(d0, d1): """ Computes the spectral flux feature of the current frame """ # compute the spectral flux as the sum of square distances: d0 = np.mean(d0, axis=1) d1 = np.mean(d1, axis=1) nFFT = min(len(d0) // 2, len(d1) // 2) X = FFT(d0, nFFT) Xprev = FFT(d1, nFFT) ...
[ "def", "spectral_flux", "(", "d0", ",", "d1", ")", ":", "# compute the spectral flux as the sum of square distances:", "d0", "=", "np", ".", "mean", "(", "d0", ",", "axis", "=", "1", ")", "d1", "=", "np", ".", "mean", "(", "d1", ",", "axis", "=", "1", ...
Computes the spectral flux feature of the current frame
[ "Computes", "the", "spectral", "flux", "feature", "of", "the", "current", "frame" ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/candidates/audio_featurization.py#L60-L75
HDI-Project/MLPrimitives
mlprimitives/candidates/audio_featurization.py
energy_entropy
def energy_entropy(data, fs, numOfShortBlocks=10): """Computes entropy of energy""" data = np.mean(data, axis=1) Eol = np.sum(data ** 2) # total data energy L = len(data) subWinLength = int(np.floor(L / numOfShortBlocks)) if L != subWinLength * numOfShortBlocks: data = data[0:subWinL...
python
def energy_entropy(data, fs, numOfShortBlocks=10): """Computes entropy of energy""" data = np.mean(data, axis=1) Eol = np.sum(data ** 2) # total data energy L = len(data) subWinLength = int(np.floor(L / numOfShortBlocks)) if L != subWinLength * numOfShortBlocks: data = data[0:subWinL...
[ "def", "energy_entropy", "(", "data", ",", "fs", ",", "numOfShortBlocks", "=", "10", ")", ":", "data", "=", "np", ".", "mean", "(", "data", ",", "axis", "=", "1", ")", "Eol", "=", "np", ".", "sum", "(", "data", "**", "2", ")", "# total data energy"...
Computes entropy of energy
[ "Computes", "entropy", "of", "energy" ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/candidates/audio_featurization.py#L78-L96
HDI-Project/MLPrimitives
mlprimitives/candidates/audio_featurization.py
spectral_centroid_and_spread
def spectral_centroid_and_spread(data, fs): """Computes spectral centroid of frame (given abs(FFT))""" data = np.mean(data, axis=1) nFFT = len(data) // 2 X = FFT(data, nFFT) ind = (np.arange(1, len(X) + 1)) * (fs / (2.0 * len(X))) Xt = X.copy() Xt = Xt / Xt.max() NUM = np.sum(ind * Xt...
python
def spectral_centroid_and_spread(data, fs): """Computes spectral centroid of frame (given abs(FFT))""" data = np.mean(data, axis=1) nFFT = len(data) // 2 X = FFT(data, nFFT) ind = (np.arange(1, len(X) + 1)) * (fs / (2.0 * len(X))) Xt = X.copy() Xt = Xt / Xt.max() NUM = np.sum(ind * Xt...
[ "def", "spectral_centroid_and_spread", "(", "data", ",", "fs", ")", ":", "data", "=", "np", ".", "mean", "(", "data", ",", "axis", "=", "1", ")", "nFFT", "=", "len", "(", "data", ")", "//", "2", "X", "=", "FFT", "(", "data", ",", "nFFT", ")", "...
Computes spectral centroid of frame (given abs(FFT))
[ "Computes", "spectral", "centroid", "of", "frame", "(", "given", "abs", "(", "FFT", "))" ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/candidates/audio_featurization.py#L99-L123
HDI-Project/MLPrimitives
mlprimitives/candidates/audio_featurization.py
spectral_rolloff
def spectral_rolloff(data, coeff): """Computes spectral roll-off""" data = np.mean(data, axis=1) nFFT = len(data) // 2 X = FFT(data, nFFT) totalEnergy = np.sum(X ** 2) fftLength = len(X) Thres = coeff * totalEnergy # Find the spectral rolloff as the frequency position where the # r...
python
def spectral_rolloff(data, coeff): """Computes spectral roll-off""" data = np.mean(data, axis=1) nFFT = len(data) // 2 X = FFT(data, nFFT) totalEnergy = np.sum(X ** 2) fftLength = len(X) Thres = coeff * totalEnergy # Find the spectral rolloff as the frequency position where the # r...
[ "def", "spectral_rolloff", "(", "data", ",", "coeff", ")", ":", "data", "=", "np", ".", "mean", "(", "data", ",", "axis", "=", "1", ")", "nFFT", "=", "len", "(", "data", ")", "//", "2", "X", "=", "FFT", "(", "data", ",", "nFFT", ")", "totalEner...
Computes spectral roll-off
[ "Computes", "spectral", "roll", "-", "off" ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/candidates/audio_featurization.py#L126-L145
HDI-Project/MLPrimitives
mlprimitives/custom/timeseries_preprocessing.py
rolling_window_sequences
def rolling_window_sequences(X, index, window_size, target_size, target_column): """Create rolling window sequences out of timeseries data.""" out_X = list() out_y = list() X_index = list() y_index = list() target = X[:, target_column] for start in range(len(X) - window_size - target_size ...
python
def rolling_window_sequences(X, index, window_size, target_size, target_column): """Create rolling window sequences out of timeseries data.""" out_X = list() out_y = list() X_index = list() y_index = list() target = X[:, target_column] for start in range(len(X) - window_size - target_size ...
[ "def", "rolling_window_sequences", "(", "X", ",", "index", ",", "window_size", ",", "target_size", ",", "target_column", ")", ":", "out_X", "=", "list", "(", ")", "out_y", "=", "list", "(", ")", "X_index", "=", "list", "(", ")", "y_index", "=", "list", ...
Create rolling window sequences out of timeseries data.
[ "Create", "rolling", "window", "sequences", "out", "of", "timeseries", "data", "." ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/custom/timeseries_preprocessing.py#L7-L23
HDI-Project/MLPrimitives
mlprimitives/custom/timeseries_preprocessing.py
time_segments_average
def time_segments_average(X, interval, time_column): """Compute average of values over fixed length time segments.""" warnings.warn(_TIME_SEGMENTS_AVERAGE_DEPRECATION_WARNING, DeprecationWarning) if isinstance(X, np.ndarray): X = pd.DataFrame(X) X = X.sort_values(time_column).set_index(time_co...
python
def time_segments_average(X, interval, time_column): """Compute average of values over fixed length time segments.""" warnings.warn(_TIME_SEGMENTS_AVERAGE_DEPRECATION_WARNING, DeprecationWarning) if isinstance(X, np.ndarray): X = pd.DataFrame(X) X = X.sort_values(time_column).set_index(time_co...
[ "def", "time_segments_average", "(", "X", ",", "interval", ",", "time_column", ")", ":", "warnings", ".", "warn", "(", "_TIME_SEGMENTS_AVERAGE_DEPRECATION_WARNING", ",", "DeprecationWarning", ")", "if", "isinstance", "(", "X", ",", "np", ".", "ndarray", ")", ":"...
Compute average of values over fixed length time segments.
[ "Compute", "average", "of", "values", "over", "fixed", "length", "time", "segments", "." ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/custom/timeseries_preprocessing.py#L33-L55
HDI-Project/MLPrimitives
mlprimitives/custom/timeseries_preprocessing.py
time_segments_aggregate
def time_segments_aggregate(X, interval, time_column, method=['mean']): """Aggregate values over fixed length time segments.""" if isinstance(X, np.ndarray): X = pd.DataFrame(X) X = X.sort_values(time_column).set_index(time_column) if isinstance(method, str): method = [method] sta...
python
def time_segments_aggregate(X, interval, time_column, method=['mean']): """Aggregate values over fixed length time segments.""" if isinstance(X, np.ndarray): X = pd.DataFrame(X) X = X.sort_values(time_column).set_index(time_column) if isinstance(method, str): method = [method] sta...
[ "def", "time_segments_aggregate", "(", "X", ",", "interval", ",", "time_column", ",", "method", "=", "[", "'mean'", "]", ")", ":", "if", "isinstance", "(", "X", ",", "np", ".", "ndarray", ")", ":", "X", "=", "pd", ".", "DataFrame", "(", "X", ")", "...
Aggregate values over fixed length time segments.
[ "Aggregate", "values", "over", "fixed", "length", "time", "segments", "." ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/custom/timeseries_preprocessing.py#L58-L84
HDI-Project/MLPrimitives
mlprimitives/utils.py
image_transform
def image_transform(X, function, reshape_before=False, reshape_after=False, width=None, height=None, **kwargs): """Apply a function image by image. Args: reshape_before: whether 1d array needs to be reshaped to a 2d image reshape_after: whether the returned values need to be...
python
def image_transform(X, function, reshape_before=False, reshape_after=False, width=None, height=None, **kwargs): """Apply a function image by image. Args: reshape_before: whether 1d array needs to be reshaped to a 2d image reshape_after: whether the returned values need to be...
[ "def", "image_transform", "(", "X", ",", "function", ",", "reshape_before", "=", "False", ",", "reshape_after", "=", "False", ",", "width", "=", "None", ",", "height", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "callable", "(", "funct...
Apply a function image by image. Args: reshape_before: whether 1d array needs to be reshaped to a 2d image reshape_after: whether the returned values need to be reshaped back to a 1d array width: image width used to rebuild the 2d images. Required if the image is not square. height:...
[ "Apply", "a", "function", "image", "by", "image", "." ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/utils.py#L18-L65
HDI-Project/MLPrimitives
mlprimitives/custom/timeseries_anomalies.py
regression_errors
def regression_errors(y, y_hat, smoothing_window=0.01, smooth=True): """Compute an array of absolute errors comparing predictions and expected output. If smooth is True, apply EWMA to the resulting array of errors. Args: y (array): Ground truth. y_hat (array): Predictions array. sm...
python
def regression_errors(y, y_hat, smoothing_window=0.01, smooth=True): """Compute an array of absolute errors comparing predictions and expected output. If smooth is True, apply EWMA to the resulting array of errors. Args: y (array): Ground truth. y_hat (array): Predictions array. sm...
[ "def", "regression_errors", "(", "y", ",", "y_hat", ",", "smoothing_window", "=", "0.01", ",", "smooth", "=", "True", ")", ":", "errors", "=", "np", ".", "abs", "(", "y", "-", "y_hat", ")", "[", ":", ",", "0", "]", "if", "not", "smooth", ":", "re...
Compute an array of absolute errors comparing predictions and expected output. If smooth is True, apply EWMA to the resulting array of errors. Args: y (array): Ground truth. y_hat (array): Predictions array. smoothing_window (float): Size of the smoothing window, expressed as a proport...
[ "Compute", "an", "array", "of", "absolute", "errors", "comparing", "predictions", "and", "expected", "output", "." ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/custom/timeseries_anomalies.py#L11-L33
HDI-Project/MLPrimitives
mlprimitives/custom/timeseries_anomalies.py
deltas
def deltas(errors, epsilon, mean, std): """Compute mean and std deltas. delta_mean = mean(errors) - mean(all errors below epsilon) delta_std = std(errors) - std(all errors below epsilon) """ below = errors[errors <= epsilon] if not len(below): return 0, 0 return mean - below.mean()...
python
def deltas(errors, epsilon, mean, std): """Compute mean and std deltas. delta_mean = mean(errors) - mean(all errors below epsilon) delta_std = std(errors) - std(all errors below epsilon) """ below = errors[errors <= epsilon] if not len(below): return 0, 0 return mean - below.mean()...
[ "def", "deltas", "(", "errors", ",", "epsilon", ",", "mean", ",", "std", ")", ":", "below", "=", "errors", "[", "errors", "<=", "epsilon", "]", "if", "not", "len", "(", "below", ")", ":", "return", "0", ",", "0", "return", "mean", "-", "below", "...
Compute mean and std deltas. delta_mean = mean(errors) - mean(all errors below epsilon) delta_std = std(errors) - std(all errors below epsilon)
[ "Compute", "mean", "and", "std", "deltas", "." ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/custom/timeseries_anomalies.py#L36-L46
HDI-Project/MLPrimitives
mlprimitives/custom/timeseries_anomalies.py
count_above
def count_above(errors, epsilon): """Count number of errors and continuous sequences above epsilon. Continuous sequences are counted by shifting and counting the number of positions where there was a change and the original value was true, which means that a sequence started at that position. """ ...
python
def count_above(errors, epsilon): """Count number of errors and continuous sequences above epsilon. Continuous sequences are counted by shifting and counting the number of positions where there was a change and the original value was true, which means that a sequence started at that position. """ ...
[ "def", "count_above", "(", "errors", ",", "epsilon", ")", ":", "above", "=", "errors", ">", "epsilon", "total_above", "=", "len", "(", "errors", "[", "above", "]", ")", "above", "=", "pd", ".", "Series", "(", "above", ")", "shift", "=", "above", ".",...
Count number of errors and continuous sequences above epsilon. Continuous sequences are counted by shifting and counting the number of positions where there was a change and the original value was true, which means that a sequence started at that position.
[ "Count", "number", "of", "errors", "and", "continuous", "sequences", "above", "epsilon", "." ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/custom/timeseries_anomalies.py#L49-L65
HDI-Project/MLPrimitives
mlprimitives/custom/timeseries_anomalies.py
z_cost
def z_cost(z, errors, mean, std): """Compute how bad a z value is. The original formula is:: (delta_mean/mean) + (delta_std/std) ------------------------------------------------------ number of errors above + (number of sequences above)^2 which computes the "goodness" of ...
python
def z_cost(z, errors, mean, std): """Compute how bad a z value is. The original formula is:: (delta_mean/mean) + (delta_std/std) ------------------------------------------------------ number of errors above + (number of sequences above)^2 which computes the "goodness" of ...
[ "def", "z_cost", "(", "z", ",", "errors", ",", "mean", ",", "std", ")", ":", "epsilon", "=", "mean", "+", "z", "*", "std", "delta_mean", ",", "delta_std", "=", "deltas", "(", "errors", ",", "epsilon", ",", "mean", ",", "std", ")", "above", ",", "...
Compute how bad a z value is. The original formula is:: (delta_mean/mean) + (delta_std/std) ------------------------------------------------------ number of errors above + (number of sequences above)^2 which computes the "goodness" of `z`, meaning that the higher the value ...
[ "Compute", "how", "bad", "a", "z", "value", "is", "." ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/custom/timeseries_anomalies.py#L68-L95
HDI-Project/MLPrimitives
mlprimitives/custom/timeseries_anomalies.py
find_threshold
def find_threshold(errors, z_range=(0, 10)): """Find the ideal threshold. The ideal threshold is the one that minimizes the z_cost function. """ mean = errors.mean() std = errors.std() min_z, max_z = z_range best_z = min_z best_cost = np.inf for z in range(min_z, max_z): b...
python
def find_threshold(errors, z_range=(0, 10)): """Find the ideal threshold. The ideal threshold is the one that minimizes the z_cost function. """ mean = errors.mean() std = errors.std() min_z, max_z = z_range best_z = min_z best_cost = np.inf for z in range(min_z, max_z): b...
[ "def", "find_threshold", "(", "errors", ",", "z_range", "=", "(", "0", ",", "10", ")", ")", ":", "mean", "=", "errors", ".", "mean", "(", ")", "std", "=", "errors", ".", "std", "(", ")", "min_z", ",", "max_z", "=", "z_range", "best_z", "=", "min_...
Find the ideal threshold. The ideal threshold is the one that minimizes the z_cost function.
[ "Find", "the", "ideal", "threshold", "." ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/custom/timeseries_anomalies.py#L98-L116
HDI-Project/MLPrimitives
mlprimitives/custom/timeseries_anomalies.py
find_sequences
def find_sequences(errors, epsilon): """Find sequences of values that are above epsilon. This is done following this steps: * create a boolean mask that indicates which value are above epsilon. * shift this mask by one place, filing the empty gap with a False * compare the shifted mask...
python
def find_sequences(errors, epsilon): """Find sequences of values that are above epsilon. This is done following this steps: * create a boolean mask that indicates which value are above epsilon. * shift this mask by one place, filing the empty gap with a False * compare the shifted mask...
[ "def", "find_sequences", "(", "errors", ",", "epsilon", ")", ":", "above", "=", "pd", ".", "Series", "(", "errors", ">", "epsilon", ")", "shift", "=", "above", ".", "shift", "(", "1", ")", ".", "fillna", "(", "False", ")", "change", "=", "above", "...
Find sequences of values that are above epsilon. This is done following this steps: * create a boolean mask that indicates which value are above epsilon. * shift this mask by one place, filing the empty gap with a False * compare the shifted mask with the original one to see if there are c...
[ "Find", "sequences", "of", "values", "that", "are", "above", "epsilon", "." ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/custom/timeseries_anomalies.py#L119-L140
HDI-Project/MLPrimitives
mlprimitives/custom/timeseries_anomalies.py
find_anomalies
def find_anomalies(errors, index, z_range=(0, 10)): """Find sequences of values that are anomalous. We first find the ideal threshold for the set of errors that we have, and then find the sequences of values that are above this threshold. Lastly, we compute a score proportional to the maximum error in...
python
def find_anomalies(errors, index, z_range=(0, 10)): """Find sequences of values that are anomalous. We first find the ideal threshold for the set of errors that we have, and then find the sequences of values that are above this threshold. Lastly, we compute a score proportional to the maximum error in...
[ "def", "find_anomalies", "(", "errors", ",", "index", ",", "z_range", "=", "(", "0", ",", "10", ")", ")", ":", "threshold", "=", "find_threshold", "(", "errors", ",", "z_range", ")", "sequences", "=", "find_sequences", "(", "errors", ",", "threshold", ")...
Find sequences of values that are anomalous. We first find the ideal threshold for the set of errors that we have, and then find the sequences of values that are above this threshold. Lastly, we compute a score proportional to the maximum error in the sequence, and finally return the index pairs that ...
[ "Find", "sequences", "of", "values", "that", "are", "anomalous", "." ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/custom/timeseries_anomalies.py#L143-L164
HDI-Project/MLPrimitives
mlprimitives/adapters/cv2.py
GaussianBlur
def GaussianBlur(X, ksize_width, ksize_height, sigma_x, sigma_y): """Apply Gaussian blur to the given data. Args: X: data to blur kernel_size: Gaussian kernel size stddev: Gaussian kernel standard deviation (in both X and Y directions) """ return image_transform( X, ...
python
def GaussianBlur(X, ksize_width, ksize_height, sigma_x, sigma_y): """Apply Gaussian blur to the given data. Args: X: data to blur kernel_size: Gaussian kernel size stddev: Gaussian kernel standard deviation (in both X and Y directions) """ return image_transform( X, ...
[ "def", "GaussianBlur", "(", "X", ",", "ksize_width", ",", "ksize_height", ",", "sigma_x", ",", "sigma_y", ")", ":", "return", "image_transform", "(", "X", ",", "cv2", ".", "GaussianBlur", ",", "ksize", "=", "(", "ksize_width", ",", "ksize_height", ")", ","...
Apply Gaussian blur to the given data. Args: X: data to blur kernel_size: Gaussian kernel size stddev: Gaussian kernel standard deviation (in both X and Y directions)
[ "Apply", "Gaussian", "blur", "to", "the", "given", "data", "." ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/adapters/cv2.py#L8-L22
HDI-Project/MLPrimitives
mlprimitives/candidates/timeseries.py
rolling_window_sequences
def rolling_window_sequences(X, window_size, target_size, value_column, time_column): """ Function that takes in a pandas.DataFrame and a window_size then creates output arrays that correspond to a timeseries sequence with window_size overlap. The output arrays can be fed into a time...
python
def rolling_window_sequences(X, window_size, target_size, value_column, time_column): """ Function that takes in a pandas.DataFrame and a window_size then creates output arrays that correspond to a timeseries sequence with window_size overlap. The output arrays can be fed into a time...
[ "def", "rolling_window_sequences", "(", "X", ",", "window_size", ",", "target_size", ",", "value_column", ",", "time_column", ")", ":", "output_X", "=", "[", "]", "y", "=", "[", "]", "time", "=", "[", "]", "for", "start", "in", "range", "(", "len", "("...
Function that takes in a pandas.DataFrame and a window_size then creates output arrays that correspond to a timeseries sequence with window_size overlap. The output arrays can be fed into a timeseries forecasting model. Assumes the input is timeseries sorted. Args: ...
[ "Function", "that", "takes", "in", "a", "pandas", ".", "DataFrame", "and", "a", "window_size", "then", "creates", "output", "arrays", "that", "correspond", "to", "a", "timeseries", "sequence", "with", "window_size", "overlap", ".", "The", "output", "arrays", "...
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/candidates/timeseries.py#L5-L34
HDI-Project/MLPrimitives
mlprimitives/candidates/timeseries.py
time_segments_average
def time_segments_average(X, interval, value_column, time_column): """ function that aggregates data in a pandas dataframe by averaging over a given interval. it starts averaging from the smallest timestamp in the dataframe and ends at the largest timestamp. assumes the input is time...
python
def time_segments_average(X, interval, value_column, time_column): """ function that aggregates data in a pandas dataframe by averaging over a given interval. it starts averaging from the smallest timestamp in the dataframe and ends at the largest timestamp. assumes the input is time...
[ "def", "time_segments_average", "(", "X", ",", "interval", ",", "value_column", ",", "time_column", ")", ":", "start_ts", "=", "X", "[", "time_column", "]", ".", "iloc", "[", "0", "]", "# min value", "end_time", "=", "X", "[", "time_column", "]", ".", "i...
function that aggregates data in a pandas dataframe by averaging over a given interval. it starts averaging from the smallest timestamp in the dataframe and ends at the largest timestamp. assumes the input is timeseries sorted. args: X (pandas.dataframe): a pandas dataframe w...
[ "function", "that", "aggregates", "data", "in", "a", "pandas", "dataframe", "by", "averaging", "over", "a", "given", "interval", ".", "it", "starts", "averaging", "from", "the", "smallest", "timestamp", "in", "the", "dataframe", "and", "ends", "at", "the", "...
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/candidates/timeseries.py#L37-L67
HDI-Project/MLPrimitives
mlprimitives/candidates/timeseries_errors.py
get_forecast_errors
def get_forecast_errors(y_hat, y_true, window_size=5, batch_size=30, smoothing_percent=0.05, smoothed=True): """ Calculates the forecasting error for two arrays of data. If smoothed errors des...
python
def get_forecast_errors(y_hat, y_true, window_size=5, batch_size=30, smoothing_percent=0.05, smoothed=True): """ Calculates the forecasting error for two arrays of data. If smoothed errors des...
[ "def", "get_forecast_errors", "(", "y_hat", ",", "y_true", ",", "window_size", "=", "5", ",", "batch_size", "=", "30", ",", "smoothing_percent", "=", "0.05", ",", "smoothed", "=", "True", ")", ":", "errors", "=", "[", "abs", "(", "y_h", "-", "y_t", ")"...
Calculates the forecasting error for two arrays of data. If smoothed errors desired, runs EWMA. Args: y_hat (list): forecasted values. len(y_hat)==len(y_true). y_true (list): true values. len(y_hat)==len(y_true). window_size (int): batch_size (int): smoothing_percent ...
[ "Calculates", "the", "forecasting", "error", "for", "two", "arrays", "of", "data", ".", "If", "smoothed", "errors", "desired", "runs", "EWMA", ".", "Args", ":", "y_hat", "(", "list", ")", ":", "forecasted", "values", ".", "len", "(", "y_hat", ")", "==", ...
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/candidates/timeseries_errors.py#L8-L45
HDI-Project/MLPrimitives
mlprimitives/candidates/timeseries_errors.py
extract_anomalies
def extract_anomalies(y_true, smoothed_errors, window_size, batch_size, error_buffer): """ Extracts anomalies from the errors. Args: y_true (): smoothed_errors (): window_size (int): batch_size (int): error_buffer (int): Returns: ...
python
def extract_anomalies(y_true, smoothed_errors, window_size, batch_size, error_buffer): """ Extracts anomalies from the errors. Args: y_true (): smoothed_errors (): window_size (int): batch_size (int): error_buffer (int): Returns: ...
[ "def", "extract_anomalies", "(", "y_true", ",", "smoothed_errors", ",", "window_size", ",", "batch_size", ",", "error_buffer", ")", ":", "if", "len", "(", "y_true", ")", "<=", "batch_size", "*", "window_size", ":", "raise", "ValueError", "(", "\"Window size (%s)...
Extracts anomalies from the errors. Args: y_true (): smoothed_errors (): window_size (int): batch_size (int): error_buffer (int): Returns:
[ "Extracts", "anomalies", "from", "the", "errors", ".", "Args", ":", "y_true", "()", ":", "smoothed_errors", "()", ":", "window_size", "(", "int", ")", ":", "batch_size", "(", "int", ")", ":", "error_buffer", "(", "int", ")", ":", "Returns", ":" ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/candidates/timeseries_errors.py#L48-L125
HDI-Project/MLPrimitives
mlprimitives/candidates/timeseries_errors.py
compute_threshold
def compute_threshold(smoothed_errors, error_buffer, sd_limit=12.0): """Helper method for `extract_anomalies` method. Calculates the epsilon (threshold) for anomalies. """ mu = np.mean(smoothed_errors) sigma = np.std(smoothed_errors) max_epsilon = 0 sd_threshold = sd_limit # The tresho...
python
def compute_threshold(smoothed_errors, error_buffer, sd_limit=12.0): """Helper method for `extract_anomalies` method. Calculates the epsilon (threshold) for anomalies. """ mu = np.mean(smoothed_errors) sigma = np.std(smoothed_errors) max_epsilon = 0 sd_threshold = sd_limit # The tresho...
[ "def", "compute_threshold", "(", "smoothed_errors", ",", "error_buffer", ",", "sd_limit", "=", "12.0", ")", ":", "mu", "=", "np", ".", "mean", "(", "smoothed_errors", ")", "sigma", "=", "np", ".", "std", "(", "smoothed_errors", ")", "max_epsilon", "=", "0"...
Helper method for `extract_anomalies` method. Calculates the epsilon (threshold) for anomalies.
[ "Helper", "method", "for", "extract_anomalies", "method", ".", "Calculates", "the", "epsilon", "(", "threshold", ")", "for", "anomalies", "." ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/candidates/timeseries_errors.py#L128-L183
HDI-Project/MLPrimitives
mlprimitives/candidates/timeseries_errors.py
get_anomalies
def get_anomalies(smoothed_errors, y_true, z, window, all_anomalies, error_buffer): """ Helper method to get anomalies. """ mu = np.mean(smoothed_errors) sigma = np.std(smoothed_errors) epsilon = mu + (z * sigma) # compare to epsilon errors_seq, anomaly_indices, max_error_below_e ...
python
def get_anomalies(smoothed_errors, y_true, z, window, all_anomalies, error_buffer): """ Helper method to get anomalies. """ mu = np.mean(smoothed_errors) sigma = np.std(smoothed_errors) epsilon = mu + (z * sigma) # compare to epsilon errors_seq, anomaly_indices, max_error_below_e ...
[ "def", "get_anomalies", "(", "smoothed_errors", ",", "y_true", ",", "z", ",", "window", ",", "all_anomalies", ",", "error_buffer", ")", ":", "mu", "=", "np", ".", "mean", "(", "smoothed_errors", ")", "sigma", "=", "np", ".", "std", "(", "smoothed_errors", ...
Helper method to get anomalies.
[ "Helper", "method", "to", "get", "anomalies", "." ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/candidates/timeseries_errors.py#L186-L214
HDI-Project/MLPrimitives
mlprimitives/candidates/timeseries_errors.py
prune_anomalies
def prune_anomalies(e_seq, smoothed_errors, max_error_below_e, anomaly_indices): """ Helper method that removes anomalies which don't meet a minimum separation from next anomaly. """ # min accepted perc decrease btwn max errors in anomalous sequences MIN_PERCENT_DECREASE = 0.05 e_seq_max, sm...
python
def prune_anomalies(e_seq, smoothed_errors, max_error_below_e, anomaly_indices): """ Helper method that removes anomalies which don't meet a minimum separation from next anomaly. """ # min accepted perc decrease btwn max errors in anomalous sequences MIN_PERCENT_DECREASE = 0.05 e_seq_max, sm...
[ "def", "prune_anomalies", "(", "e_seq", ",", "smoothed_errors", ",", "max_error_below_e", ",", "anomaly_indices", ")", ":", "# min accepted perc decrease btwn max errors in anomalous sequences", "MIN_PERCENT_DECREASE", "=", "0.05", "e_seq_max", ",", "smoothed_errors_max", "=", ...
Helper method that removes anomalies which don't meet a minimum separation from next anomaly.
[ "Helper", "method", "that", "removes", "anomalies", "which", "don", "t", "meet", "a", "minimum", "separation", "from", "next", "anomaly", "." ]
train
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/candidates/timeseries_errors.py#L262-L299
ultrabug/uhashring
uhashring/ring.py
HashRing._configure_nodes
def _configure_nodes(self, nodes): """Parse and set up the given nodes. :param nodes: nodes used to create the continuum (see doc for format). """ if isinstance(nodes, str): nodes = [nodes] elif not isinstance(nodes, (dict, list)): raise ValueError( ...
python
def _configure_nodes(self, nodes): """Parse and set up the given nodes. :param nodes: nodes used to create the continuum (see doc for format). """ if isinstance(nodes, str): nodes = [nodes] elif not isinstance(nodes, (dict, list)): raise ValueError( ...
[ "def", "_configure_nodes", "(", "self", ",", "nodes", ")", ":", "if", "isinstance", "(", "nodes", ",", "str", ")", ":", "nodes", "=", "[", "nodes", "]", "elif", "not", "isinstance", "(", "nodes", ",", "(", "dict", ",", "list", ")", ")", ":", "raise...
Parse and set up the given nodes. :param nodes: nodes used to create the continuum (see doc for format).
[ "Parse", "and", "set", "up", "the", "given", "nodes", "." ]
train
https://github.com/ultrabug/uhashring/blob/2297471a392e28ed913b3276c2f48d0c01523375/uhashring/ring.py#L44-L94
ultrabug/uhashring
uhashring/ring.py
HashRing._get_pos
def _get_pos(self, key): """Get the index of the given key in the sorted key list. We return the position with the nearest hash based on the provided key unless we reach the end of the continuum/ring in which case we return the 0 (beginning) index position. :param key: the key ...
python
def _get_pos(self, key): """Get the index of the given key in the sorted key list. We return the position with the nearest hash based on the provided key unless we reach the end of the continuum/ring in which case we return the 0 (beginning) index position. :param key: the key ...
[ "def", "_get_pos", "(", "self", ",", "key", ")", ":", "p", "=", "bisect", "(", "self", ".", "runtime", ".", "_keys", ",", "self", ".", "hashi", "(", "key", ")", ")", "if", "p", "==", "len", "(", "self", ".", "runtime", ".", "_keys", ")", ":", ...
Get the index of the given key in the sorted key list. We return the position with the nearest hash based on the provided key unless we reach the end of the continuum/ring in which case we return the 0 (beginning) index position. :param key: the key to hash and look for.
[ "Get", "the", "index", "of", "the", "given", "key", "in", "the", "sorted", "key", "list", "." ]
train
https://github.com/ultrabug/uhashring/blob/2297471a392e28ed913b3276c2f48d0c01523375/uhashring/ring.py#L125-L138
ultrabug/uhashring
uhashring/ring.py
HashRing._get
def _get(self, key, what): """Generic getter magic method. The node with the nearest but not less hash value is returned. :param key: the key to look for. :param what: the information to look for in, allowed values: - instance (default): associated node instance ...
python
def _get(self, key, what): """Generic getter magic method. The node with the nearest but not less hash value is returned. :param key: the key to look for. :param what: the information to look for in, allowed values: - instance (default): associated node instance ...
[ "def", "_get", "(", "self", ",", "key", ",", "what", ")", ":", "if", "not", "self", ".", "runtime", ".", "_ring", ":", "return", "None", "pos", "=", "self", ".", "_get_pos", "(", "key", ")", "if", "what", "==", "'pos'", ":", "return", "pos", "nod...
Generic getter magic method. The node with the nearest but not less hash value is returned. :param key: the key to look for. :param what: the information to look for in, allowed values: - instance (default): associated node instance - nodename: node name - p...
[ "Generic", "getter", "magic", "method", "." ]
train
https://github.com/ultrabug/uhashring/blob/2297471a392e28ed913b3276c2f48d0c01523375/uhashring/ring.py#L140-L168
ultrabug/uhashring
uhashring/ring.py
HashRing.get_instances
def get_instances(self): """Returns a list of the instances of all the configured nodes. """ return [c.get('instance') for c in self.runtime._nodes.values() if c.get('instance')]
python
def get_instances(self): """Returns a list of the instances of all the configured nodes. """ return [c.get('instance') for c in self.runtime._nodes.values() if c.get('instance')]
[ "def", "get_instances", "(", "self", ")", ":", "return", "[", "c", ".", "get", "(", "'instance'", ")", "for", "c", "in", "self", ".", "runtime", ".", "_nodes", ".", "values", "(", ")", "if", "c", ".", "get", "(", "'instance'", ")", "]" ]
Returns a list of the instances of all the configured nodes.
[ "Returns", "a", "list", "of", "the", "instances", "of", "all", "the", "configured", "nodes", "." ]
train
https://github.com/ultrabug/uhashring/blob/2297471a392e28ed913b3276c2f48d0c01523375/uhashring/ring.py#L177-L181
ultrabug/uhashring
uhashring/ring.py
HashRing.get_points
def get_points(self): """Returns a ketama compatible list of (position, nodename) tuples. """ return [(k, self.runtime._ring[k]) for k in self.runtime._keys]
python
def get_points(self): """Returns a ketama compatible list of (position, nodename) tuples. """ return [(k, self.runtime._ring[k]) for k in self.runtime._keys]
[ "def", "get_points", "(", "self", ")", ":", "return", "[", "(", "k", ",", "self", ".", "runtime", ".", "_ring", "[", "k", "]", ")", "for", "k", "in", "self", ".", "runtime", ".", "_keys", "]" ]
Returns a ketama compatible list of (position, nodename) tuples.
[ "Returns", "a", "ketama", "compatible", "list", "of", "(", "position", "nodename", ")", "tuples", "." ]
train
https://github.com/ultrabug/uhashring/blob/2297471a392e28ed913b3276c2f48d0c01523375/uhashring/ring.py#L232-L235
ultrabug/uhashring
uhashring/ring.py
HashRing.iterate_nodes
def iterate_nodes(self, key, distinct=True): """hash_ring compatibility implementation. Given a string key it returns the nodes as a generator that can hold the key. The generator iterates one time through the ring starting at the correct position. if `distinct` is set, ...
python
def iterate_nodes(self, key, distinct=True): """hash_ring compatibility implementation. Given a string key it returns the nodes as a generator that can hold the key. The generator iterates one time through the ring starting at the correct position. if `distinct` is set, ...
[ "def", "iterate_nodes", "(", "self", ",", "key", ",", "distinct", "=", "True", ")", ":", "if", "not", "self", ".", "runtime", ".", "_ring", ":", "yield", "None", "else", ":", "for", "node", "in", "self", ".", "range", "(", "key", ",", "unique", "="...
hash_ring compatibility implementation. Given a string key it returns the nodes as a generator that can hold the key. The generator iterates one time through the ring starting at the correct position. if `distinct` is set, then the nodes returned will be unique, i.e. no ...
[ "hash_ring", "compatibility", "implementation", "." ]
train
https://github.com/ultrabug/uhashring/blob/2297471a392e28ed913b3276c2f48d0c01523375/uhashring/ring.py#L244-L258
ultrabug/uhashring
uhashring/ring.py
HashRing.print_continuum
def print_continuum(self): """Prints a ketama compatible continuum report. """ numpoints = len(self.runtime._keys) if numpoints: print('Numpoints in continuum: {}'.format(numpoints)) else: print('Continuum empty') for p in self.get_points(): ...
python
def print_continuum(self): """Prints a ketama compatible continuum report. """ numpoints = len(self.runtime._keys) if numpoints: print('Numpoints in continuum: {}'.format(numpoints)) else: print('Continuum empty') for p in self.get_points(): ...
[ "def", "print_continuum", "(", "self", ")", ":", "numpoints", "=", "len", "(", "self", ".", "runtime", ".", "_keys", ")", "if", "numpoints", ":", "print", "(", "'Numpoints in continuum: {}'", ".", "format", "(", "numpoints", ")", ")", "else", ":", "print",...
Prints a ketama compatible continuum report.
[ "Prints", "a", "ketama", "compatible", "continuum", "report", "." ]
train
https://github.com/ultrabug/uhashring/blob/2297471a392e28ed913b3276c2f48d0c01523375/uhashring/ring.py#L260-L270