Unnamed: 0
int64
0
10k
repository_name
stringlengths
7
54
func_path_in_repository
stringlengths
5
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
100
30.3k
language
stringclasses
1 value
func_code_string
stringlengths
100
30.3k
func_code_tokens
stringlengths
138
33.2k
func_documentation_string
stringlengths
1
15k
func_documentation_tokens
stringlengths
5
5.14k
split_name
stringclasses
1 value
func_code_url
stringlengths
91
315
9,900
ggaughan/pipe2py
pipe2py/lib/utils.py
get_input
def get_input(context, conf): """Gets a user parameter, either from the console or from an outer submodule/system Assumes conf has name, default, prompt and debug """ name = conf['name']['value'] prompt = conf['prompt']['value'] default = conf['default']['value'] or conf['debug']['va...
python
def get_input(context, conf): """Gets a user parameter, either from the console or from an outer submodule/system Assumes conf has name, default, prompt and debug """ name = conf['name']['value'] prompt = conf['prompt']['value'] default = conf['default']['value'] or conf['debug']['va...
['def', 'get_input', '(', 'context', ',', 'conf', ')', ':', 'name', '=', 'conf', '[', "'name'", ']', '[', "'value'", ']', 'prompt', '=', 'conf', '[', "'prompt'", ']', '[', "'value'", ']', 'default', '=', 'conf', '[', "'default'", ']', '[', "'value'", ']', 'or', 'conf', '[', "'debug'", ']', '[', "'value'", ']', 'if', 'c...
Gets a user parameter, either from the console or from an outer submodule/system Assumes conf has name, default, prompt and debug
['Gets', 'a', 'user', 'parameter', 'either', 'from', 'the', 'console', 'or', 'from', 'an', 'outer', 'submodule', '/', 'system']
train
https://github.com/ggaughan/pipe2py/blob/4767d6d1fd354d2a35e6528594b8deb8a033eed4/pipe2py/lib/utils.py#L295-L314
9,901
asweigart/pyautogui
pyautogui/_pyautogui_win.py
_scroll
def _scroll(clicks, x=None, y=None): """Send the mouse vertical scroll event to Windows by calling the mouse_event() win32 function. Args: clicks (int): The amount of scrolling to do. A positive value is the mouse wheel moving forward (scrolling up), a negative value is backwards (down). ...
python
def _scroll(clicks, x=None, y=None): """Send the mouse vertical scroll event to Windows by calling the mouse_event() win32 function. Args: clicks (int): The amount of scrolling to do. A positive value is the mouse wheel moving forward (scrolling up), a negative value is backwards (down). ...
['def', '_scroll', '(', 'clicks', ',', 'x', '=', 'None', ',', 'y', '=', 'None', ')', ':', 'startx', ',', 'starty', '=', '_position', '(', ')', 'width', ',', 'height', '=', '_size', '(', ')', 'if', 'x', 'is', 'None', ':', 'x', '=', 'startx', 'else', ':', 'if', 'x', '<', '0', ':', 'x', '=', '0', 'elif', 'x', '>=', 'width...
Send the mouse vertical scroll event to Windows by calling the mouse_event() win32 function. Args: clicks (int): The amount of scrolling to do. A positive value is the mouse wheel moving forward (scrolling up), a negative value is backwards (down). x (int): The x position of the mouse event. ...
['Send', 'the', 'mouse', 'vertical', 'scroll', 'event', 'to', 'Windows', 'by', 'calling', 'the', 'mouse_event', '()', 'win32', 'function', '.']
train
https://github.com/asweigart/pyautogui/blob/77524bd47334a89024013fd48e05151c3ac9289a/pyautogui/_pyautogui_win.py#L520-L554
9,902
deepmind/pysc2
pysc2/env/lan_sc2_env.py
tcp_client
def tcp_client(tcp_addr): """Connect to the tcp server, and return the settings.""" family = socket.AF_INET6 if ":" in tcp_addr.ip else socket.AF_INET sock = socket.socket(family, socket.SOCK_STREAM, socket.IPPROTO_TCP) for i in range(300): logging.info("Connecting to: %s, attempt %d", tcp_addr, i) try:...
python
def tcp_client(tcp_addr): """Connect to the tcp server, and return the settings.""" family = socket.AF_INET6 if ":" in tcp_addr.ip else socket.AF_INET sock = socket.socket(family, socket.SOCK_STREAM, socket.IPPROTO_TCP) for i in range(300): logging.info("Connecting to: %s, attempt %d", tcp_addr, i) try:...
['def', 'tcp_client', '(', 'tcp_addr', ')', ':', 'family', '=', 'socket', '.', 'AF_INET6', 'if', '":"', 'in', 'tcp_addr', '.', 'ip', 'else', 'socket', '.', 'AF_INET', 'sock', '=', 'socket', '.', 'socket', '(', 'family', ',', 'socket', '.', 'SOCK_STREAM', ',', 'socket', '.', 'IPPROTO_TCP', ')', 'for', 'i', 'in', 'range'...
Connect to the tcp server, and return the settings.
['Connect', 'to', 'the', 'tcp', 'server', 'and', 'return', 'the', 'settings', '.']
train
https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/env/lan_sc2_env.py#L83-L106
9,903
f3at/feat
src/feat/extern/log/log.py
init
def init(envVarName, enableColorOutput=False): """ Initialize the logging system and parse the environment variable of the given name. Needs to be called before starting the actual application. """ global _initialized if _initialized: return global _ENV_VAR_NAME _ENV_VAR_NA...
python
def init(envVarName, enableColorOutput=False): """ Initialize the logging system and parse the environment variable of the given name. Needs to be called before starting the actual application. """ global _initialized if _initialized: return global _ENV_VAR_NAME _ENV_VAR_NA...
['def', 'init', '(', 'envVarName', ',', 'enableColorOutput', '=', 'False', ')', ':', 'global', '_initialized', 'if', '_initialized', ':', 'return', 'global', '_ENV_VAR_NAME', '_ENV_VAR_NAME', '=', 'envVarName', 'if', 'enableColorOutput', ':', '_preformatLevels', '(', 'envVarName', '+', '"_NO_COLOR"', ')', 'else', ':', ...
Initialize the logging system and parse the environment variable of the given name. Needs to be called before starting the actual application.
['Initialize', 'the', 'logging', 'system', 'and', 'parse', 'the', 'environment', 'variable', 'of', 'the', 'given', 'name', '.', 'Needs', 'to', 'be', 'called', 'before', 'starting', 'the', 'actual', 'application', '.']
train
https://github.com/f3at/feat/blob/15da93fc9d6ec8154f52a9172824e25821195ef8/src/feat/extern/log/log.py#L484-L508
9,904
totalgood/twip
twip/nlp.py
make_named_stemmer
def make_named_stemmer(stem=None, min_len=3): """Construct a callable object and a string sufficient to reconstruct it later (unpickling) >>> make_named_stemmer('str_lower') ('str_lower', <function str_lower at ...>) >>> make_named_stemmer('Lancaster') ('lancaster', <Stemmer object at ...>) """...
python
def make_named_stemmer(stem=None, min_len=3): """Construct a callable object and a string sufficient to reconstruct it later (unpickling) >>> make_named_stemmer('str_lower') ('str_lower', <function str_lower at ...>) >>> make_named_stemmer('Lancaster') ('lancaster', <Stemmer object at ...>) """...
['def', 'make_named_stemmer', '(', 'stem', '=', 'None', ',', 'min_len', '=', '3', ')', ':', 'name', ',', 'stem', '=', 'stringify', '(', 'stem', ')', ',', 'make_stemmer', '(', 'stem', '=', 'stem', ',', 'min_len', '=', 'min_len', ')', 'if', 'hasattr', '(', 'stem', ',', "'__name__'", ')', ':', 'return', 'stem', '.', '__na...
Construct a callable object and a string sufficient to reconstruct it later (unpickling) >>> make_named_stemmer('str_lower') ('str_lower', <function str_lower at ...>) >>> make_named_stemmer('Lancaster') ('lancaster', <Stemmer object at ...>)
['Construct', 'a', 'callable', 'object', 'and', 'a', 'string', 'sufficient', 'to', 'reconstruct', 'it', 'later', '(', 'unpickling', ')']
train
https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/nlp.py#L297-L312
9,905
ThreatConnect-Inc/tcex
tcex/tcex_ti_indicator.py
Indicator.data
def data(self): """Return Indicator data.""" # add attributes if self._attributes: self._indicator_data['attribute'] = [] for attr in self._attributes: if attr.valid: self._indicator_data['attribute'].append(attr.data) # add fil...
python
def data(self): """Return Indicator data.""" # add attributes if self._attributes: self._indicator_data['attribute'] = [] for attr in self._attributes: if attr.valid: self._indicator_data['attribute'].append(attr.data) # add fil...
['def', 'data', '(', 'self', ')', ':', '# add attributes', 'if', 'self', '.', '_attributes', ':', 'self', '.', '_indicator_data', '[', "'attribute'", ']', '=', '[', ']', 'for', 'attr', 'in', 'self', '.', '_attributes', ':', 'if', 'attr', '.', 'valid', ':', 'self', '.', '_indicator_data', '[', "'attribute'", ']', '.', '...
Return Indicator data.
['Return', 'Indicator', 'data', '.']
train
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_ti_indicator.py#L218-L248
9,906
welbornprod/colr
colr/__main__.py
print_err
def print_err(*args, **kwargs): """ A wrapper for print() that uses stderr by default. """ if kwargs.get('file', None) is None: kwargs['file'] = sys.stderr color = dict_pop_or(kwargs, 'color', True) # Use color if asked, but only if the file is a tty. if color and kwargs['file'].isatty(): ...
python
def print_err(*args, **kwargs): """ A wrapper for print() that uses stderr by default. """ if kwargs.get('file', None) is None: kwargs['file'] = sys.stderr color = dict_pop_or(kwargs, 'color', True) # Use color if asked, but only if the file is a tty. if color and kwargs['file'].isatty(): ...
['def', 'print_err', '(', '*', 'args', ',', '*', '*', 'kwargs', ')', ':', 'if', 'kwargs', '.', 'get', '(', "'file'", ',', 'None', ')', 'is', 'None', ':', 'kwargs', '[', "'file'", ']', '=', 'sys', '.', 'stderr', 'color', '=', 'dict_pop_or', '(', 'kwargs', ',', "'color'", ',', 'True', ')', '# Use color if asked, but only...
A wrapper for print() that uses stderr by default.
['A', 'wrapper', 'for', 'print', '()', 'that', 'uses', 'stderr', 'by', 'default', '.']
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/__main__.py#L425-L447
9,907
bskinn/opan
opan/xyz.py
OpanXYZ.angle_single
def angle_single(self, g_num, at_1, at_2, at_3): """ Spanning angle among three atoms. The indices `at_1` and `at_3` can be the same (yielding a trivial zero angle), but `at_2` must be different from both `at_1` and `at_3`. Parameters ---------- g_num ...
python
def angle_single(self, g_num, at_1, at_2, at_3): """ Spanning angle among three atoms. The indices `at_1` and `at_3` can be the same (yielding a trivial zero angle), but `at_2` must be different from both `at_1` and `at_3`. Parameters ---------- g_num ...
['def', 'angle_single', '(', 'self', ',', 'g_num', ',', 'at_1', ',', 'at_2', ',', 'at_3', ')', ':', '# Imports', 'import', 'numpy', 'as', 'np', 'from', '.', 'utils', 'import', 'safe_cast', 'as', 'scast', 'from', '.', 'utils', '.', 'vector', 'import', 'vec_angle', '# The below errors are explicitly thrown since they are...
Spanning angle among three atoms. The indices `at_1` and `at_3` can be the same (yielding a trivial zero angle), but `at_2` must be different from both `at_1` and `at_3`. Parameters ---------- g_num |int| -- Index of the desired geometry ...
['Spanning', 'angle', 'among', 'three', 'atoms', '.']
train
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/xyz.py#L919-L1010
9,908
awslabs/sockeye
sockeye/data_io.py
ParallelDataSet.load
def load(fname: str) -> 'ParallelDataSet': """ Loads a dataset from a binary .npy file. """ data = mx.nd.load(fname) n = len(data) // 3 source = data[:n] target = data[n:2 * n] label = data[2 * n:] assert len(source) == len(target) == len(label) ...
python
def load(fname: str) -> 'ParallelDataSet': """ Loads a dataset from a binary .npy file. """ data = mx.nd.load(fname) n = len(data) // 3 source = data[:n] target = data[n:2 * n] label = data[2 * n:] assert len(source) == len(target) == len(label) ...
['def', 'load', '(', 'fname', ':', 'str', ')', '->', "'ParallelDataSet'", ':', 'data', '=', 'mx', '.', 'nd', '.', 'load', '(', 'fname', ')', 'n', '=', 'len', '(', 'data', ')', '//', '3', 'source', '=', 'data', '[', ':', 'n', ']', 'target', '=', 'data', '[', 'n', ':', '2', '*', 'n', ']', 'label', '=', 'data', '[', '2', ...
Loads a dataset from a binary .npy file.
['Loads', 'a', 'dataset', 'from', 'a', 'binary', '.', 'npy', 'file', '.']
train
https://github.com/awslabs/sockeye/blob/5d64a1ee1ef3cbba17c6d1d94bc061020c43f6ab/sockeye/data_io.py#L1373-L1383
9,909
Microsoft/azure-devops-python-api
azure-devops/azure/devops/v5_1/work_item_tracking/work_item_tracking_client.py
WorkItemTrackingClient.delete_field
def delete_field(self, field_name_or_ref_name, project=None): """DeleteField. [Preview API] Deletes the field. :param str field_name_or_ref_name: Field simple name or reference name :param str project: Project ID or project name """ route_values = {} if project is...
python
def delete_field(self, field_name_or_ref_name, project=None): """DeleteField. [Preview API] Deletes the field. :param str field_name_or_ref_name: Field simple name or reference name :param str project: Project ID or project name """ route_values = {} if project is...
['def', 'delete_field', '(', 'self', ',', 'field_name_or_ref_name', ',', 'project', '=', 'None', ')', ':', 'route_values', '=', '{', '}', 'if', 'project', 'is', 'not', 'None', ':', 'route_values', '[', "'project'", ']', '=', 'self', '.', '_serialize', '.', 'url', '(', "'project'", ',', 'project', ',', "'str'", ')', 'if...
DeleteField. [Preview API] Deletes the field. :param str field_name_or_ref_name: Field simple name or reference name :param str project: Project ID or project name
['DeleteField', '.', '[', 'Preview', 'API', ']', 'Deletes', 'the', 'field', '.', ':', 'param', 'str', 'field_name_or_ref_name', ':', 'Field', 'simple', 'name', 'or', 'reference', 'name', ':', 'param', 'str', 'project', ':', 'Project', 'ID', 'or', 'project', 'name']
train
https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_1/work_item_tracking/work_item_tracking_client.py#L626-L640
9,910
brndnmtthws/dragon-rest
dragon_rest/dragons.py
DragonAPI.auth
def auth(self): """Authenticate with the miner and obtain a JSON web token (JWT).""" response = requests.post( parse.urljoin(self.base_url, '/api/auth'), timeout=self.timeout, data={'username': self.username, 'password': self.password}) response.raise_for_stat...
python
def auth(self): """Authenticate with the miner and obtain a JSON web token (JWT).""" response = requests.post( parse.urljoin(self.base_url, '/api/auth'), timeout=self.timeout, data={'username': self.username, 'password': self.password}) response.raise_for_stat...
['def', 'auth', '(', 'self', ')', ':', 'response', '=', 'requests', '.', 'post', '(', 'parse', '.', 'urljoin', '(', 'self', '.', 'base_url', ',', "'/api/auth'", ')', ',', 'timeout', '=', 'self', '.', 'timeout', ',', 'data', '=', '{', "'username'", ':', 'self', '.', 'username', ',', "'password'", ':', 'self', '.', 'pass...
Authenticate with the miner and obtain a JSON web token (JWT).
['Authenticate', 'with', 'the', 'miner', 'and', 'obtain', 'a', 'JSON', 'web', 'token', '(', 'JWT', ')', '.']
train
https://github.com/brndnmtthws/dragon-rest/blob/10ea09a6203c0cbfeeeb854702764bd778769887/dragon_rest/dragons.py#L118-L129
9,911
peo3/cgroup-utils
cgutils/cgroup.py
walk_cgroups
def walk_cgroups(cgroup, action, opaque): """ The function applies the action function with the opaque object to each control group under the cgroup recursively. """ action(cgroup, opaque) for child in cgroup.childs: walk_cgroups(child, action, opaque)
python
def walk_cgroups(cgroup, action, opaque): """ The function applies the action function with the opaque object to each control group under the cgroup recursively. """ action(cgroup, opaque) for child in cgroup.childs: walk_cgroups(child, action, opaque)
['def', 'walk_cgroups', '(', 'cgroup', ',', 'action', ',', 'opaque', ')', ':', 'action', '(', 'cgroup', ',', 'opaque', ')', 'for', 'child', 'in', 'cgroup', '.', 'childs', ':', 'walk_cgroups', '(', 'child', ',', 'action', ',', 'opaque', ')']
The function applies the action function with the opaque object to each control group under the cgroup recursively.
['The', 'function', 'applies', 'the', 'action', 'function', 'with', 'the', 'opaque', 'object', 'to', 'each', 'control', 'group', 'under', 'the', 'cgroup', 'recursively', '.']
train
https://github.com/peo3/cgroup-utils/blob/fd7e99f438ce334bac5669fba0d08a6502fd7a82/cgutils/cgroup.py#L938-L945
9,912
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/scene/widgets/console.py
ConsoleVisual.write
def write(self, text='', wrap=True): """Write text and scroll Parameters ---------- text : str Text to write. ``''`` can be used for a blank line, as a newline is automatically added to the end of each line. wrap : str If True, long messages w...
python
def write(self, text='', wrap=True): """Write text and scroll Parameters ---------- text : str Text to write. ``''`` can be used for a blank line, as a newline is automatically added to the end of each line. wrap : str If True, long messages w...
['def', 'write', '(', 'self', ',', 'text', '=', "''", ',', 'wrap', '=', 'True', ')', ':', '# Clear line', 'if', 'not', 'isinstance', '(', 'text', ',', 'string_types', ')', ':', 'raise', 'TypeError', '(', "'text must be a string'", ')', '# ensure we only have ASCII chars', 'text', '=', 'text', '.', 'encode', '(', "'utf-...
Write text and scroll Parameters ---------- text : str Text to write. ``''`` can be used for a blank line, as a newline is automatically added to the end of each line. wrap : str If True, long messages will be wrapped to span multiple lines.
['Write', 'text', 'and', 'scroll']
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/widgets/console.py#L300-L317
9,913
ThreatConnect-Inc/tcex
tcex/tcex.py
TcEx._logger_api
def _logger_api(self): """Add API logging handler.""" from .tcex_logger import TcExLogHandler, TcExLogFormatter api = TcExLogHandler(self.session) api.set_name('api') api.setLevel(logging.DEBUG) api.setFormatter(TcExLogFormatter()) self.log.addHandler(api)
python
def _logger_api(self): """Add API logging handler.""" from .tcex_logger import TcExLogHandler, TcExLogFormatter api = TcExLogHandler(self.session) api.set_name('api') api.setLevel(logging.DEBUG) api.setFormatter(TcExLogFormatter()) self.log.addHandler(api)
['def', '_logger_api', '(', 'self', ')', ':', 'from', '.', 'tcex_logger', 'import', 'TcExLogHandler', ',', 'TcExLogFormatter', 'api', '=', 'TcExLogHandler', '(', 'self', '.', 'session', ')', 'api', '.', 'set_name', '(', "'api'", ')', 'api', '.', 'setLevel', '(', 'logging', '.', 'DEBUG', ')', 'api', '.', 'setFormatter',...
Add API logging handler.
['Add', 'API', 'logging', 'handler', '.']
train
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L186-L194
9,914
linuxsoftware/ls.joyous
ls/joyous/models/events.py
RecurringEventPage._getFromTime
def _getFromTime(self, atDate=None): """ What was the time of this event? Due to time zones that depends what day we are talking about. If no day is given, assume today. """ if atDate is None: atDate = timezone.localdate(timezone=self.tz) return getLocalTime...
python
def _getFromTime(self, atDate=None): """ What was the time of this event? Due to time zones that depends what day we are talking about. If no day is given, assume today. """ if atDate is None: atDate = timezone.localdate(timezone=self.tz) return getLocalTime...
['def', '_getFromTime', '(', 'self', ',', 'atDate', '=', 'None', ')', ':', 'if', 'atDate', 'is', 'None', ':', 'atDate', '=', 'timezone', '.', 'localdate', '(', 'timezone', '=', 'self', '.', 'tz', ')', 'return', 'getLocalTime', '(', 'atDate', ',', 'self', '.', 'time_from', ',', 'self', '.', 'tz', ')']
What was the time of this event? Due to time zones that depends what day we are talking about. If no day is given, assume today.
['What', 'was', 'the', 'time', 'of', 'this', 'event?', 'Due', 'to', 'time', 'zones', 'that', 'depends', 'what', 'day', 'we', 'are', 'talking', 'about', '.', 'If', 'no', 'day', 'is', 'given', 'assume', 'today', '.']
train
https://github.com/linuxsoftware/ls.joyous/blob/316283140ca5171a68ad3170a5964fdc89be0b56/ls/joyous/models/events.py#L1074-L1081
9,915
ssato/python-anyconfig
src/anyconfig/processors.py
find_by_type_or_id
def find_by_type_or_id(type_or_id, prs): """ :param type_or_id: Type of the data to process or ID of the processor class :param prs: A list of :class:`anyconfig.models.processor.Processor` classes :return: A list of processor classes to process files of given data type or processor 'type...
python
def find_by_type_or_id(type_or_id, prs): """ :param type_or_id: Type of the data to process or ID of the processor class :param prs: A list of :class:`anyconfig.models.processor.Processor` classes :return: A list of processor classes to process files of given data type or processor 'type...
['def', 'find_by_type_or_id', '(', 'type_or_id', ',', 'prs', ')', ':', 'def', 'pred', '(', 'pcls', ')', ':', '"""Predicate"""', 'return', 'pcls', '.', 'cid', '(', ')', '==', 'type_or_id', 'or', 'pcls', '.', 'type', '(', ')', '==', 'type_or_id', 'pclss', '=', 'findall_with_pred', '(', 'pred', ',', 'prs', ')', 'if', 'not...
:param type_or_id: Type of the data to process or ID of the processor class :param prs: A list of :class:`anyconfig.models.processor.Processor` classes :return: A list of processor classes to process files of given data type or processor 'type_or_id' found by its ID :raises: UnknownProcessor...
[':', 'param', 'type_or_id', ':', 'Type', 'of', 'the', 'data', 'to', 'process', 'or', 'ID', 'of', 'the', 'processor', 'class', ':', 'param', 'prs', ':', 'A', 'list', 'of', ':', 'class', ':', 'anyconfig', '.', 'models', '.', 'processor', '.', 'Processor', 'classes', ':', 'return', ':', 'A', 'list', 'of', 'processor', 'c...
train
https://github.com/ssato/python-anyconfig/blob/f2f4fb8d8e232aadea866c202e1dd7a5967e2877/src/anyconfig/processors.py#L122-L139
9,916
trailofbits/protofuzz
protofuzz/gen.py
Permuter._resolve_child
def _resolve_child(self, path): 'Return a member generator by a dot-delimited path' obj = self for component in path.split('.'): ptr = obj if not isinstance(ptr, Permuter): raise self.MessageNotFound("Bad element path [wrong type]") # pylint:...
python
def _resolve_child(self, path): 'Return a member generator by a dot-delimited path' obj = self for component in path.split('.'): ptr = obj if not isinstance(ptr, Permuter): raise self.MessageNotFound("Bad element path [wrong type]") # pylint:...
['def', '_resolve_child', '(', 'self', ',', 'path', ')', ':', 'obj', '=', 'self', 'for', 'component', 'in', 'path', '.', 'split', '(', "'.'", ')', ':', 'ptr', '=', 'obj', 'if', 'not', 'isinstance', '(', 'ptr', ',', 'Permuter', ')', ':', 'raise', 'self', '.', 'MessageNotFound', '(', '"Bad element path [wrong type]"', ')...
Return a member generator by a dot-delimited path
['Return', 'a', 'member', 'generator', 'by', 'a', 'dot', '-', 'delimited', 'path']
train
https://github.com/trailofbits/protofuzz/blob/589492d34de9a0da6cc5554094e2588b893b2fd8/protofuzz/gen.py#L111-L128
9,917
elehcimd/pynb
pynb/notebook.py
Notebook.process
def process(self, uid, add_footer=False, no_exec=False, disable_cache=False, ignore_cache=False): """ Execute notebook :return: self """ self.exec_begin = time.perf_counter() self.exec_begin_dt = datetime.datetime.now() ep = CachedExecutePreprocessor(timeout=Non...
python
def process(self, uid, add_footer=False, no_exec=False, disable_cache=False, ignore_cache=False): """ Execute notebook :return: self """ self.exec_begin = time.perf_counter() self.exec_begin_dt = datetime.datetime.now() ep = CachedExecutePreprocessor(timeout=Non...
['def', 'process', '(', 'self', ',', 'uid', ',', 'add_footer', '=', 'False', ',', 'no_exec', '=', 'False', ',', 'disable_cache', '=', 'False', ',', 'ignore_cache', '=', 'False', ')', ':', 'self', '.', 'exec_begin', '=', 'time', '.', 'perf_counter', '(', ')', 'self', '.', 'exec_begin_dt', '=', 'datetime', '.', 'datetime...
Execute notebook :return: self
['Execute', 'notebook', ':', 'return', ':', 'self']
train
https://github.com/elehcimd/pynb/blob/a32af1f0e574f880eccda4a46aede6d65151f8c9/pynb/notebook.py#L340-L371
9,918
dswah/pyGAM
pygam/pygam.py
LogisticGAM.accuracy
def accuracy(self, X=None, y=None, mu=None): """ computes the accuracy of the LogisticGAM Parameters ---------- note: X or mu must be defined. defaults to mu X : array-like of shape (n_samples, m_features), optional (default=None) containing input data ...
python
def accuracy(self, X=None, y=None, mu=None): """ computes the accuracy of the LogisticGAM Parameters ---------- note: X or mu must be defined. defaults to mu X : array-like of shape (n_samples, m_features), optional (default=None) containing input data ...
['def', 'accuracy', '(', 'self', ',', 'X', '=', 'None', ',', 'y', '=', 'None', ',', 'mu', '=', 'None', ')', ':', 'if', 'not', 'self', '.', '_is_fitted', ':', 'raise', 'AttributeError', '(', "'GAM has not been fitted. Call fit first.'", ')', 'y', '=', 'check_y', '(', 'y', ',', 'self', '.', 'link', ',', 'self', '.', 'dis...
computes the accuracy of the LogisticGAM Parameters ---------- note: X or mu must be defined. defaults to mu X : array-like of shape (n_samples, m_features), optional (default=None) containing input data y : array-like of shape (n,) containing target dat...
['computes', 'the', 'accuracy', 'of', 'the', 'LogisticGAM']
train
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/pygam.py#L2395-L2426
9,919
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/visuals/isocurve.py
IsocurveVisual._compute_iso_line
def _compute_iso_line(self): """ compute LineVisual vertices, connects and color-index """ level_index = [] connects = [] verts = [] # calculate which level are within data range # this works for now and the existing examples, but should be tested # thoro...
python
def _compute_iso_line(self): """ compute LineVisual vertices, connects and color-index """ level_index = [] connects = [] verts = [] # calculate which level are within data range # this works for now and the existing examples, but should be tested # thoro...
['def', '_compute_iso_line', '(', 'self', ')', ':', 'level_index', '=', '[', ']', 'connects', '=', '[', ']', 'verts', '=', '[', ']', '# calculate which level are within data range', '# this works for now and the existing examples, but should be tested', '# thoroughly also with the data-sanity check in set_data-function...
compute LineVisual vertices, connects and color-index
['compute', 'LineVisual', 'vertices', 'connects', 'and', 'color', '-', 'index']
train
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/isocurve.py#L138-L175
9,920
tanghaibao/goatools
goatools/grouper/aart_geneproducts_one.py
AArtGeneProductSetsOne.prt_report_grp1
def prt_report_grp1(self, prt=sys.stdout, **kws_grp): """Print full GO/gene report with grouping.""" summaryline = self.str_summaryline() # Print grouped GO IDs prt.write("{SUMMARY}\n".format(SUMMARY=summaryline)) self.prt_gos_grouped(prt, **kws_grp) # genes genes...
python
def prt_report_grp1(self, prt=sys.stdout, **kws_grp): """Print full GO/gene report with grouping.""" summaryline = self.str_summaryline() # Print grouped GO IDs prt.write("{SUMMARY}\n".format(SUMMARY=summaryline)) self.prt_gos_grouped(prt, **kws_grp) # genes genes...
['def', 'prt_report_grp1', '(', 'self', ',', 'prt', '=', 'sys', '.', 'stdout', ',', '*', '*', 'kws_grp', ')', ':', 'summaryline', '=', 'self', '.', 'str_summaryline', '(', ')', '# Print grouped GO IDs', 'prt', '.', 'write', '(', '"{SUMMARY}\\n"', '.', 'format', '(', 'SUMMARY', '=', 'summaryline', ')', ')', 'self', '.',...
Print full GO/gene report with grouping.
['Print', 'full', 'GO', '/', 'gene', 'report', 'with', 'grouping', '.']
train
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/grouper/aart_geneproducts_one.py#L52-L66
9,921
synw/dataswim
dataswim/data/clean.py
Clean.fill_nan
def fill_nan(self, val: str, *cols): """ Fill NaN values with new values in the main dataframe :param val: new value :type val: str :param \*cols: names of the colums :type \*cols: str, at least one :example: ``ds.fill_nan("new value", "mycol1", "mycol2")`` ...
python
def fill_nan(self, val: str, *cols): """ Fill NaN values with new values in the main dataframe :param val: new value :type val: str :param \*cols: names of the colums :type \*cols: str, at least one :example: ``ds.fill_nan("new value", "mycol1", "mycol2")`` ...
['def', 'fill_nan', '(', 'self', ',', 'val', ':', 'str', ',', '*', 'cols', ')', ':', 'df', '=', 'self', '.', '_fill_nan', '(', 'val', ',', '*', 'cols', ')', 'if', 'df', 'is', 'not', 'None', ':', 'self', '.', 'df', '=', 'df', 'else', ':', 'self', '.', 'err', '(', '"Can not fill nan values"', ')']
Fill NaN values with new values in the main dataframe :param val: new value :type val: str :param \*cols: names of the colums :type \*cols: str, at least one :example: ``ds.fill_nan("new value", "mycol1", "mycol2")``
['Fill', 'NaN', 'values', 'with', 'new', 'values', 'in', 'the', 'main', 'dataframe']
train
https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/clean.py#L88-L103
9,922
nornir-automation/nornir
nornir/core/inventory.py
Host.get_connection_state
def get_connection_state(self, connection: str) -> Dict[str, Any]: """ For an already established connection return its state. """ if connection not in self.connections: raise ConnectionNotOpen(connection) return self.connections[connection].state
python
def get_connection_state(self, connection: str) -> Dict[str, Any]: """ For an already established connection return its state. """ if connection not in self.connections: raise ConnectionNotOpen(connection) return self.connections[connection].state
['def', 'get_connection_state', '(', 'self', ',', 'connection', ':', 'str', ')', '->', 'Dict', '[', 'str', ',', 'Any', ']', ':', 'if', 'connection', 'not', 'in', 'self', '.', 'connections', ':', 'raise', 'ConnectionNotOpen', '(', 'connection', ')', 'return', 'self', '.', 'connections', '[', 'connection', ']', '.', 'sta...
For an already established connection return its state.
['For', 'an', 'already', 'established', 'connection', 'return', 'its', 'state', '.']
train
https://github.com/nornir-automation/nornir/blob/3425c47fd870db896cb80f619bae23bd98d50c74/nornir/core/inventory.py#L306-L313
9,923
geophysics-ubonn/crtomo_tools
lib/crtomo/tdManager.py
tdMan.invert
def invert(self, output_directory=None, catch_output=True, **kwargs): """Invert this instance, and import the result files No directories/files will be overwritten. Raise an IOError if the output directory exists. Parameters ---------- output_directory: string, optional...
python
def invert(self, output_directory=None, catch_output=True, **kwargs): """Invert this instance, and import the result files No directories/files will be overwritten. Raise an IOError if the output directory exists. Parameters ---------- output_directory: string, optional...
['def', 'invert', '(', 'self', ',', 'output_directory', '=', 'None', ',', 'catch_output', '=', 'True', ',', '*', '*', 'kwargs', ')', ':', 'self', '.', '_check_state', '(', ')', 'if', 'self', '.', 'can_invert', ':', 'if', 'output_directory', 'is', 'not', 'None', ':', 'if', 'not', 'os', '.', 'path', '.', 'isdir', '(', 'o...
Invert this instance, and import the result files No directories/files will be overwritten. Raise an IOError if the output directory exists. Parameters ---------- output_directory: string, optional use this directory as output directory for the generated tomodir. ...
['Invert', 'this', 'instance', 'and', 'import', 'the', 'result', 'files']
train
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/tdManager.py#L956-L1001
9,924
google/grr
grr/core/grr_response_core/lib/config_lib.py
ParseConfigCommandLine
def ParseConfigCommandLine(): """Parse all the command line options which control the config system.""" # The user may specify the primary config file on the command line. if flags.FLAGS.config: _CONFIG.Initialize(filename=flags.FLAGS.config, must_exist=True) else: raise RuntimeError("A config file is n...
python
def ParseConfigCommandLine(): """Parse all the command line options which control the config system.""" # The user may specify the primary config file on the command line. if flags.FLAGS.config: _CONFIG.Initialize(filename=flags.FLAGS.config, must_exist=True) else: raise RuntimeError("A config file is n...
['def', 'ParseConfigCommandLine', '(', ')', ':', '# The user may specify the primary config file on the command line.', 'if', 'flags', '.', 'FLAGS', '.', 'config', ':', '_CONFIG', '.', 'Initialize', '(', 'filename', '=', 'flags', '.', 'FLAGS', '.', 'config', ',', 'must_exist', '=', 'True', ')', 'else', ':', 'raise', 'R...
Parse all the command line options which control the config system.
['Parse', 'all', 'the', 'command', 'line', 'options', 'which', 'control', 'the', 'config', 'system', '.']
train
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1704-L1740
9,925
senaite/senaite.core
bika/lims/exportimport/instruments/shimadzu/nexera/LC2040C.py
TSVParser.parse_TSVline
def parse_TSVline(self, line): """ Parses result lines """ split_row = [token.strip() for token in line.split('\t')] _results = {'DefaultResult': 'Conc.'} # ID# 1 if split_row[0] == 'ID#': return 0 # Name CBDV - cannabidivarin elif split_row[...
python
def parse_TSVline(self, line): """ Parses result lines """ split_row = [token.strip() for token in line.split('\t')] _results = {'DefaultResult': 'Conc.'} # ID# 1 if split_row[0] == 'ID#': return 0 # Name CBDV - cannabidivarin elif split_row[...
['def', 'parse_TSVline', '(', 'self', ',', 'line', ')', ':', 'split_row', '=', '[', 'token', '.', 'strip', '(', ')', 'for', 'token', 'in', 'line', '.', 'split', '(', "'\\t'", ')', ']', '_results', '=', '{', "'DefaultResult'", ':', "'Conc.'", '}', '# ID# 1', 'if', 'split_row', '[', '0', ']', '==', "'ID#'", ':', 'return'...
Parses result lines
['Parses', 'result', 'lines']
train
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/exportimport/instruments/shimadzu/nexera/LC2040C.py#L101-L146
9,926
evhub/coconut
coconut/compiler/grammar.py
subscriptgroup_handle
def subscriptgroup_handle(tokens): """Process subscriptgroups.""" internal_assert(0 < len(tokens) <= 3, "invalid slice args", tokens) args = [] for arg in tokens: if not arg: arg = "None" args.append(arg) if len(args) == 1: return args[0] else: return ...
python
def subscriptgroup_handle(tokens): """Process subscriptgroups.""" internal_assert(0 < len(tokens) <= 3, "invalid slice args", tokens) args = [] for arg in tokens: if not arg: arg = "None" args.append(arg) if len(args) == 1: return args[0] else: return ...
['def', 'subscriptgroup_handle', '(', 'tokens', ')', ':', 'internal_assert', '(', '0', '<', 'len', '(', 'tokens', ')', '<=', '3', ',', '"invalid slice args"', ',', 'tokens', ')', 'args', '=', '[', ']', 'for', 'arg', 'in', 'tokens', ':', 'if', 'not', 'arg', ':', 'arg', '=', '"None"', 'args', '.', 'append', '(', 'arg', '...
Process subscriptgroups.
['Process', 'subscriptgroups', '.']
train
https://github.com/evhub/coconut/blob/ff97177344e7604e89a0a98a977a87ed2a56fc6d/coconut/compiler/grammar.py#L563-L574
9,927
ANTsX/ANTsPy
ants/utils/invariant_image_similarity.py
invariant_image_similarity
def invariant_image_similarity(image1, image2, local_search_iterations=0, metric='MI', thetas=np.linspace(0,360,5), thetas2=np.linspace(0,360,5), thetas3=np.linspace(0,360,5), ...
python
def invariant_image_similarity(image1, image2, local_search_iterations=0, metric='MI', thetas=np.linspace(0,360,5), thetas2=np.linspace(0,360,5), thetas3=np.linspace(0,360,5), ...
['def', 'invariant_image_similarity', '(', 'image1', ',', 'image2', ',', 'local_search_iterations', '=', '0', ',', 'metric', '=', "'MI'", ',', 'thetas', '=', 'np', '.', 'linspace', '(', '0', ',', '360', ',', '5', ')', ',', 'thetas2', '=', 'np', '.', 'linspace', '(', '0', ',', '360', ',', '5', ')', ',', 'thetas3', '=', ...
Similarity metrics between two images as a function of geometry Compute similarity metric between two images as image is rotated about its center w/ or w/o optimization ANTsR function: `invariantImageSimilarity` Arguments --------- image1 : ANTsImage reference image image2 : ...
['Similarity', 'metrics', 'between', 'two', 'images', 'as', 'a', 'function', 'of', 'geometry']
train
https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/utils/invariant_image_similarity.py#L15-L197
9,928
bigchaindb/bigchaindb-driver
bigchaindb_driver/driver.py
TransactionsEndpoint.prepare
def prepare(*, operation='CREATE', signers=None, recipients=None, asset=None, metadata=None, inputs=None): """Prepares a transaction payload, ready to be fulfilled. Args: operation (str): The operation to perform. Must be ``'CREATE'`` or ``'TRANSFER'``. Case ...
python
def prepare(*, operation='CREATE', signers=None, recipients=None, asset=None, metadata=None, inputs=None): """Prepares a transaction payload, ready to be fulfilled. Args: operation (str): The operation to perform. Must be ``'CREATE'`` or ``'TRANSFER'``. Case ...
['def', 'prepare', '(', '*', ',', 'operation', '=', "'CREATE'", ',', 'signers', '=', 'None', ',', 'recipients', '=', 'None', ',', 'asset', '=', 'None', ',', 'metadata', '=', 'None', ',', 'inputs', '=', 'None', ')', ':', 'return', 'prepare_transaction', '(', 'operation', '=', 'operation', ',', 'signers', '=', 'signers',...
Prepares a transaction payload, ready to be fulfilled. Args: operation (str): The operation to perform. Must be ``'CREATE'`` or ``'TRANSFER'``. Case insensitive. Defaults to ``'CREATE'``. signers (:obj:`list` | :obj:`tuple` | :obj:`str`, optional): One or...
['Prepares', 'a', 'transaction', 'payload', 'ready', 'to', 'be', 'fulfilled', '.']
train
https://github.com/bigchaindb/bigchaindb-driver/blob/c294a535f0696bd19483ae11a4882b74e6fc061e/bigchaindb_driver/driver.py#L181-L255
9,929
mishbahr/django-usersettings2
usersettings/context_processors.py
usersettings
def usersettings(request): """ Returns the current ``UserSettings`` based on the SITE_ID in the project's settings as context variables If there is no 'usersettings' attribute in the request, fetches the current UserSettings (from usersettings.shortcuts.get_current_usersettings). """ if has...
python
def usersettings(request): """ Returns the current ``UserSettings`` based on the SITE_ID in the project's settings as context variables If there is no 'usersettings' attribute in the request, fetches the current UserSettings (from usersettings.shortcuts.get_current_usersettings). """ if has...
['def', 'usersettings', '(', 'request', ')', ':', 'if', 'hasattr', '(', 'request', ',', "'usersettings'", ')', ':', 'usersettings', '=', 'request', '.', 'usersettings', 'else', ':', 'from', '.', 'shortcuts', 'import', 'get_current_usersettings', 'usersettings', '=', 'get_current_usersettings', '(', ')', 'return', '{', ...
Returns the current ``UserSettings`` based on the SITE_ID in the project's settings as context variables If there is no 'usersettings' attribute in the request, fetches the current UserSettings (from usersettings.shortcuts.get_current_usersettings).
['Returns', 'the', 'current', 'UserSettings', 'based', 'on', 'the', 'SITE_ID', 'in', 'the', 'project', 's', 'settings', 'as', 'context', 'variables']
train
https://github.com/mishbahr/django-usersettings2/blob/cbc2f4b2e01d5401bec8a3fa39151730cd2dcd2a/usersettings/context_processors.py#L2-L18
9,930
shaunduncan/helga-facts
helga_facts.py
term_regex
def term_regex(term): """ Returns a case-insensitive regex for searching terms """ return re.compile(r'^{0}$'.format(re.escape(term)), re.IGNORECASE)
python
def term_regex(term): """ Returns a case-insensitive regex for searching terms """ return re.compile(r'^{0}$'.format(re.escape(term)), re.IGNORECASE)
['def', 'term_regex', '(', 'term', ')', ':', 'return', 're', '.', 'compile', '(', "r'^{0}$'", '.', 'format', '(', 're', '.', 'escape', '(', 'term', ')', ')', ',', 're', '.', 'IGNORECASE', ')']
Returns a case-insensitive regex for searching terms
['Returns', 'a', 'case', '-', 'insensitive', 'regex', 'for', 'searching', 'terms']
train
https://github.com/shaunduncan/helga-facts/blob/956b1d93abccdaaf318d7cac4451edc7e73bf5e9/helga_facts.py#L23-L27
9,931
mbj4668/pyang
pyang/plugins/sample-xml-skeleton.py
SampleXMLSkeletonPlugin.leaf
def leaf(self, node, elem, module, path): """Create a sample leaf element.""" if node.i_default is None: nel, newm, path = self.sample_element(node, elem, module, path) if path is None: return if self.annots: nel.append(etree.Comment( ...
python
def leaf(self, node, elem, module, path): """Create a sample leaf element.""" if node.i_default is None: nel, newm, path = self.sample_element(node, elem, module, path) if path is None: return if self.annots: nel.append(etree.Comment( ...
['def', 'leaf', '(', 'self', ',', 'node', ',', 'elem', ',', 'module', ',', 'path', ')', ':', 'if', 'node', '.', 'i_default', 'is', 'None', ':', 'nel', ',', 'newm', ',', 'path', '=', 'self', '.', 'sample_element', '(', 'node', ',', 'elem', ',', 'module', ',', 'path', ')', 'if', 'path', 'is', 'None', ':', 'return', 'if',...
Create a sample leaf element.
['Create', 'a', 'sample', 'leaf', 'element', '.']
train
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/plugins/sample-xml-skeleton.py#L153-L166
9,932
senaite/senaite.core
bika/lims/browser/samplinground/printform.py
PrintForm.pdfFromPOST
def pdfFromPOST(self): """ It returns the pdf for the sampling rounds printed """ html = self.request.form.get('html') style = self.request.form.get('style') reporthtml = "<html><head>%s</head><body><div id='report'>%s</body></html>" % (style, html) return self.pr...
python
def pdfFromPOST(self): """ It returns the pdf for the sampling rounds printed """ html = self.request.form.get('html') style = self.request.form.get('style') reporthtml = "<html><head>%s</head><body><div id='report'>%s</body></html>" % (style, html) return self.pr...
['def', 'pdfFromPOST', '(', 'self', ')', ':', 'html', '=', 'self', '.', 'request', '.', 'form', '.', 'get', '(', "'html'", ')', 'style', '=', 'self', '.', 'request', '.', 'form', '.', 'get', '(', "'style'", ')', 'reporthtml', '=', '"<html><head>%s</head><body><div id=\'report\'>%s</body></html>"', '%', '(', 'style', ',...
It returns the pdf for the sampling rounds printed
['It', 'returns', 'the', 'pdf', 'for', 'the', 'sampling', 'rounds', 'printed']
train
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/samplinground/printform.py#L241-L248
9,933
restran/mountains
mountains/encoding/converter.py
bin2str
def bin2str(b): """ Binary to string. """ ret = [] for pos in range(0, len(b), 8): ret.append(chr(int(b[pos:pos + 8], 2))) return ''.join(ret)
python
def bin2str(b): """ Binary to string. """ ret = [] for pos in range(0, len(b), 8): ret.append(chr(int(b[pos:pos + 8], 2))) return ''.join(ret)
['def', 'bin2str', '(', 'b', ')', ':', 'ret', '=', '[', ']', 'for', 'pos', 'in', 'range', '(', '0', ',', 'len', '(', 'b', ')', ',', '8', ')', ':', 'ret', '.', 'append', '(', 'chr', '(', 'int', '(', 'b', '[', 'pos', ':', 'pos', '+', '8', ']', ',', '2', ')', ')', ')', 'return', "''", '.', 'join', '(', 'ret', ')']
Binary to string.
['Binary', 'to', 'string', '.']
train
https://github.com/restran/mountains/blob/a97fee568b112f4e10d878f815d0db3dd0a98d74/mountains/encoding/converter.py#L183-L190
9,934
roboogle/gtkmvc3
gtkmvco/examples/converter/src/models/currencies.py
CurrenciesModel.add
def add(self, model): """raises an exception if the model cannot be added""" def foo(m, p, i): if m[i][0].name == model.name: raise ValueError("Model already exists") return # checks if already existing self.foreach(foo) self.appen...
python
def add(self, model): """raises an exception if the model cannot be added""" def foo(m, p, i): if m[i][0].name == model.name: raise ValueError("Model already exists") return # checks if already existing self.foreach(foo) self.appen...
['def', 'add', '(', 'self', ',', 'model', ')', ':', 'def', 'foo', '(', 'm', ',', 'p', ',', 'i', ')', ':', 'if', 'm', '[', 'i', ']', '[', '0', ']', '.', 'name', '==', 'model', '.', 'name', ':', 'raise', 'ValueError', '(', '"Model already exists"', ')', 'return', '# checks if already existing', 'self', '.', 'foreach', '(...
raises an exception if the model cannot be added
['raises', 'an', 'exception', 'if', 'the', 'model', 'cannot', 'be', 'added']
train
https://github.com/roboogle/gtkmvc3/blob/63405fd8d2056be26af49103b13a8d5e57fe4dff/gtkmvco/examples/converter/src/models/currencies.py#L56-L66
9,935
pantsbuild/pants
src/python/pants/base/deprecated.py
validate_deprecation_semver
def validate_deprecation_semver(version_string, version_description): """Validates that version_string is a valid semver. If so, returns that semver. Raises an error otherwise. :param str version_string: A pantsbuild.pants version which affects some deprecated entity. :param str version_description: A string...
python
def validate_deprecation_semver(version_string, version_description): """Validates that version_string is a valid semver. If so, returns that semver. Raises an error otherwise. :param str version_string: A pantsbuild.pants version which affects some deprecated entity. :param str version_description: A string...
['def', 'validate_deprecation_semver', '(', 'version_string', ',', 'version_description', ')', ':', 'if', 'version_string', 'is', 'None', ':', 'raise', 'MissingSemanticVersionError', '(', "'The {} must be provided.'", '.', 'format', '(', 'version_description', ')', ')', 'if', 'not', 'isinstance', '(', 'version_string',...
Validates that version_string is a valid semver. If so, returns that semver. Raises an error otherwise. :param str version_string: A pantsbuild.pants version which affects some deprecated entity. :param str version_description: A string used in exception messages to describe what the ...
['Validates', 'that', 'version_string', 'is', 'a', 'valid', 'semver', '.']
train
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/base/deprecated.py#L61-L90
9,936
crocs-muni/roca
roca/detect.py
RocaFingerprinter.process_ssh
def process_ssh(self, data, name): """ Processes SSH keys :param data: :param name: :return: """ if data is None or len(data) == 0: return ret = [] try: lines = [x.strip() for x in data.split(b'\n')] for idx, li...
python
def process_ssh(self, data, name): """ Processes SSH keys :param data: :param name: :return: """ if data is None or len(data) == 0: return ret = [] try: lines = [x.strip() for x in data.split(b'\n')] for idx, li...
['def', 'process_ssh', '(', 'self', ',', 'data', ',', 'name', ')', ':', 'if', 'data', 'is', 'None', 'or', 'len', '(', 'data', ')', '==', '0', ':', 'return', 'ret', '=', '[', ']', 'try', ':', 'lines', '=', '[', 'x', '.', 'strip', '(', ')', 'for', 'x', 'in', 'data', '.', 'split', '(', "b'\\n'", ')', ']', 'for', 'idx', ',...
Processes SSH keys :param data: :param name: :return:
['Processes', 'SSH', 'keys', ':', 'param', 'data', ':', ':', 'param', 'name', ':', ':', 'return', ':']
train
https://github.com/crocs-muni/roca/blob/74ad6ce63c428d83dcffce9c5e26ef7b9e30faa5/roca/detect.py#L1605-L1624
9,937
openvax/varcode
varcode/common.py
groupby_field
def groupby_field(records, field_name, skip_none=True): """ Given a list of objects, group them into a dictionary by the unique values of a given field name. """ return apply_groupby( records, lambda obj: getattr(obj, field_name), skip_none=skip_none)
python
def groupby_field(records, field_name, skip_none=True): """ Given a list of objects, group them into a dictionary by the unique values of a given field name. """ return apply_groupby( records, lambda obj: getattr(obj, field_name), skip_none=skip_none)
['def', 'groupby_field', '(', 'records', ',', 'field_name', ',', 'skip_none', '=', 'True', ')', ':', 'return', 'apply_groupby', '(', 'records', ',', 'lambda', 'obj', ':', 'getattr', '(', 'obj', ',', 'field_name', ')', ',', 'skip_none', '=', 'skip_none', ')']
Given a list of objects, group them into a dictionary by the unique values of a given field name.
['Given', 'a', 'list', 'of', 'objects', 'group', 'them', 'into', 'a', 'dictionary', 'by', 'the', 'unique', 'values', 'of', 'a', 'given', 'field', 'name', '.']
train
https://github.com/openvax/varcode/blob/981633db45ca2b31f76c06894a7360ea5d70a9b8/varcode/common.py#L49-L57
9,938
Hypex/hyppy
hyppy/hapi.py
HAPIResponse.parse
def parse(response): """Parse a postdata-style response format from the API into usable data""" """Split a a=1b=2c=3 string into a dictionary of pairs""" tokens = {r[0]: r[1] for r in [r.split('=') for r in response.split("&")]} # The odd dummy parameter is of no use to us if '...
python
def parse(response): """Parse a postdata-style response format from the API into usable data""" """Split a a=1b=2c=3 string into a dictionary of pairs""" tokens = {r[0]: r[1] for r in [r.split('=') for r in response.split("&")]} # The odd dummy parameter is of no use to us if '...
['def', 'parse', '(', 'response', ')', ':', '"""Split a a=1b=2c=3 string into a dictionary of pairs"""', 'tokens', '=', '{', 'r', '[', '0', ']', ':', 'r', '[', '1', ']', 'for', 'r', 'in', '[', 'r', '.', 'split', '(', "'='", ')', 'for', 'r', 'in', 'response', '.', 'split', '(', '"&"', ')', ']', '}', '# The odd dummy par...
Parse a postdata-style response format from the API into usable data
['Parse', 'a', 'postdata', '-', 'style', 'response', 'format', 'from', 'the', 'API', 'into', 'usable', 'data']
train
https://github.com/Hypex/hyppy/blob/a425619c2a102b0e598fd6cac8aa0f6b766f542d/hyppy/hapi.py#L204-L234
9,939
ryanvarley/ExoData
exodata/astroclasses.py
_createMagConversionDict
def _createMagConversionDict(): """ loads magnitude_conversion.dat which is table A% 1995ApJS..101..117K """ magnitude_conversion_filepath = resource_stream(__name__, 'data/magnitude_conversion.dat') raw_table = np.loadtxt(magnitude_conversion_filepath, '|S5') magDict = {} for row in raw_table:...
python
def _createMagConversionDict(): """ loads magnitude_conversion.dat which is table A% 1995ApJS..101..117K """ magnitude_conversion_filepath = resource_stream(__name__, 'data/magnitude_conversion.dat') raw_table = np.loadtxt(magnitude_conversion_filepath, '|S5') magDict = {} for row in raw_table:...
['def', '_createMagConversionDict', '(', ')', ':', 'magnitude_conversion_filepath', '=', 'resource_stream', '(', '__name__', ',', "'data/magnitude_conversion.dat'", ')', 'raw_table', '=', 'np', '.', 'loadtxt', '(', 'magnitude_conversion_filepath', ',', "'|S5'", ')', 'magDict', '=', '{', '}', 'for', 'row', 'in', 'raw_ta...
loads magnitude_conversion.dat which is table A% 1995ApJS..101..117K
['loads', 'magnitude_conversion', '.', 'dat', 'which', 'is', 'table', 'A%', '1995ApJS', '..', '101', '..', '117K']
train
https://github.com/ryanvarley/ExoData/blob/e0d3652117214d2377a707d6778f93b7eb201a41/exodata/astroclasses.py#L1253-L1269
9,940
spyder-ide/spyder
spyder/plugins/ipythonconsole/widgets/shell.py
ShellWidget.set_backend_for_mayavi
def set_backend_for_mayavi(self, command): """ Mayavi plots require the Qt backend, so we try to detect if one is generated to change backends """ calling_mayavi = False lines = command.splitlines() for l in lines: if not l.startswith('#'): ...
python
def set_backend_for_mayavi(self, command): """ Mayavi plots require the Qt backend, so we try to detect if one is generated to change backends """ calling_mayavi = False lines = command.splitlines() for l in lines: if not l.startswith('#'): ...
['def', 'set_backend_for_mayavi', '(', 'self', ',', 'command', ')', ':', 'calling_mayavi', '=', 'False', 'lines', '=', 'command', '.', 'splitlines', '(', ')', 'for', 'l', 'in', 'lines', ':', 'if', 'not', 'l', '.', 'startswith', '(', "'#'", ')', ':', 'if', "'import mayavi'", 'in', 'l', 'or', "'from mayavi'", 'in', 'l', ...
Mayavi plots require the Qt backend, so we try to detect if one is generated to change backends
['Mayavi', 'plots', 'require', 'the', 'Qt', 'backend', 'so', 'we', 'try', 'to', 'detect', 'if', 'one', 'is', 'generated', 'to', 'change', 'backends']
train
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/ipythonconsole/widgets/shell.py#L435-L450
9,941
biosustain/optlang
optlang/gurobi_interface.py
_constraint_lb_and_ub_to_gurobi_sense_rhs_and_range_value
def _constraint_lb_and_ub_to_gurobi_sense_rhs_and_range_value(lb, ub): """Helper function used by Constraint and Model""" if lb is None and ub is None: raise Exception("Free constraint ...") elif lb is None: sense = '<' rhs = float(ub) range_value = 0. elif ub is None: ...
python
def _constraint_lb_and_ub_to_gurobi_sense_rhs_and_range_value(lb, ub): """Helper function used by Constraint and Model""" if lb is None and ub is None: raise Exception("Free constraint ...") elif lb is None: sense = '<' rhs = float(ub) range_value = 0. elif ub is None: ...
['def', '_constraint_lb_and_ub_to_gurobi_sense_rhs_and_range_value', '(', 'lb', ',', 'ub', ')', ':', 'if', 'lb', 'is', 'None', 'and', 'ub', 'is', 'None', ':', 'raise', 'Exception', '(', '"Free constraint ..."', ')', 'elif', 'lb', 'is', 'None', ':', 'sense', '=', "'<'", 'rhs', '=', 'float', '(', 'ub', ')', 'range_value'...
Helper function used by Constraint and Model
['Helper', 'function', 'used', 'by', 'Constraint', 'and', 'Model']
train
https://github.com/biosustain/optlang/blob/13673ac26f6b3ba37a2ef392489722c52e3c5ff1/optlang/gurobi_interface.py#L65-L87
9,942
eumis/pyviews
pyviews/rendering/modifiers.py
call
def call(node: Node, key: str, value: Any): """Calls node or node instance method""" value = _to_list(value) if not value or not isinstance(value[-1], dict): value.append({}) args = value[0:-1] kwargs = value[-1] node.__dict__[key](*args, **kwargs)
python
def call(node: Node, key: str, value: Any): """Calls node or node instance method""" value = _to_list(value) if not value or not isinstance(value[-1], dict): value.append({}) args = value[0:-1] kwargs = value[-1] node.__dict__[key](*args, **kwargs)
['def', 'call', '(', 'node', ':', 'Node', ',', 'key', ':', 'str', ',', 'value', ':', 'Any', ')', ':', 'value', '=', '_to_list', '(', 'value', ')', 'if', 'not', 'value', 'or', 'not', 'isinstance', '(', 'value', '[', '-', '1', ']', ',', 'dict', ')', ':', 'value', '.', 'append', '(', '{', '}', ')', 'args', '=', 'value', '...
Calls node or node instance method
['Calls', 'node', 'or', 'node', 'instance', 'method']
train
https://github.com/eumis/pyviews/blob/80a868242ee9cdc6f4ded594b3e0544cc238ed55/pyviews/rendering/modifiers.py#L24-L31
9,943
RJT1990/pyflux
pyflux/families/t.py
t.second_order_score
def second_order_score(y, mean, scale, shape, skewness): """ GAS t Update term potentially using second-order information - native Python function Parameters ---------- y : float datapoint for the time series mean : float location parameter for the t dis...
python
def second_order_score(y, mean, scale, shape, skewness): """ GAS t Update term potentially using second-order information - native Python function Parameters ---------- y : float datapoint for the time series mean : float location parameter for the t dis...
['def', 'second_order_score', '(', 'y', ',', 'mean', ',', 'scale', ',', 'shape', ',', 'skewness', ')', ':', 'return', '(', '(', 'shape', '+', '1', ')', '/', 'shape', ')', '*', '(', 'y', '-', 'mean', ')', '/', '(', 'np', '.', 'power', '(', 'scale', ',', '2', ')', '+', '(', 'np', '.', 'power', '(', 'y', '-', 'mean', ',',...
GAS t Update term potentially using second-order information - native Python function Parameters ---------- y : float datapoint for the time series mean : float location parameter for the t distribution scale : float scale parameter for the ...
['GAS', 't', 'Update', 'term', 'potentially', 'using', 'second', '-', 'order', 'information', '-', 'native', 'Python', 'function']
train
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/t.py#L330-L354
9,944
ecordell/pymacaroons
pymacaroons/serializers/json_serializer.py
JsonSerializer._deserialize_v1
def _deserialize_v1(self, deserialized): '''Deserialize a JSON macaroon in v1 format. @param serialized the macaroon in v1 JSON format. @return the macaroon object. ''' from pymacaroons.macaroon import Macaroon, MACAROON_V1 from pymacaroons.caveat import Caveat ...
python
def _deserialize_v1(self, deserialized): '''Deserialize a JSON macaroon in v1 format. @param serialized the macaroon in v1 JSON format. @return the macaroon object. ''' from pymacaroons.macaroon import Macaroon, MACAROON_V1 from pymacaroons.caveat import Caveat ...
['def', '_deserialize_v1', '(', 'self', ',', 'deserialized', ')', ':', 'from', 'pymacaroons', '.', 'macaroon', 'import', 'Macaroon', ',', 'MACAROON_V1', 'from', 'pymacaroons', '.', 'caveat', 'import', 'Caveat', 'caveats', '=', '[', ']', 'for', 'c', 'in', 'deserialized', '.', 'get', '(', "'caveats'", ',', '[', ']', ')',...
Deserialize a JSON macaroon in v1 format. @param serialized the macaroon in v1 JSON format. @return the macaroon object.
['Deserialize', 'a', 'JSON', 'macaroon', 'in', 'v1', 'format', '.']
train
https://github.com/ecordell/pymacaroons/blob/c941614df15fe732ea432a62788e45410bcb868d/pymacaroons/serializers/json_serializer.py#L69-L99
9,945
ladybug-tools/ladybug
ladybug/euclid.py
Vector2.angle
def angle(self, other): """Return the angle to the vector other""" return math.acos(self.dot(other) / (self.magnitude() * other.magnitude()))
python
def angle(self, other): """Return the angle to the vector other""" return math.acos(self.dot(other) / (self.magnitude() * other.magnitude()))
['def', 'angle', '(', 'self', ',', 'other', ')', ':', 'return', 'math', '.', 'acos', '(', 'self', '.', 'dot', '(', 'other', ')', '/', '(', 'self', '.', 'magnitude', '(', ')', '*', 'other', '.', 'magnitude', '(', ')', ')', ')']
Return the angle to the vector other
['Return', 'the', 'angle', 'to', 'the', 'vector', 'other']
train
https://github.com/ladybug-tools/ladybug/blob/c08b7308077a48d5612f644943f92d5b5dade583/ladybug/euclid.py#L298-L300
9,946
xgfs/NetLSD
netlsd/util.py
mat_to_laplacian
def mat_to_laplacian(mat, normalized): """ Converts a sparse or dence adjacency matrix to Laplacian. Parameters ---------- mat : obj Input adjacency matrix. If it is a Laplacian matrix already, return it. normalized : bool Whether to use normalized Laplacian. Normali...
python
def mat_to_laplacian(mat, normalized): """ Converts a sparse or dence adjacency matrix to Laplacian. Parameters ---------- mat : obj Input adjacency matrix. If it is a Laplacian matrix already, return it. normalized : bool Whether to use normalized Laplacian. Normali...
['def', 'mat_to_laplacian', '(', 'mat', ',', 'normalized', ')', ':', 'if', 'sps', '.', 'issparse', '(', 'mat', ')', ':', 'if', 'np', '.', 'all', '(', 'mat', '.', 'diagonal', '(', ')', '>=', '0', ')', ':', '# Check diagonal', 'if', 'np', '.', 'all', '(', '(', 'mat', '-', 'sps', '.', 'diags', '(', 'mat', '.', 'diagonal',...
Converts a sparse or dence adjacency matrix to Laplacian. Parameters ---------- mat : obj Input adjacency matrix. If it is a Laplacian matrix already, return it. normalized : bool Whether to use normalized Laplacian. Normalized and unnormalized Laplacians capture different p...
['Converts', 'a', 'sparse', 'or', 'dence', 'adjacency', 'matrix', 'to', 'Laplacian', '.', 'Parameters', '----------', 'mat', ':', 'obj', 'Input', 'adjacency', 'matrix', '.', 'If', 'it', 'is', 'a', 'Laplacian', 'matrix', 'already', 'return', 'it', '.', 'normalized', ':', 'bool', 'Whether', 'to', 'use', 'normalized', 'La...
train
https://github.com/xgfs/NetLSD/blob/54820b3669a94852bd9653be23b09e126e901ab3/netlsd/util.py#L129-L174
9,947
scanny/python-pptx
pptx/text/layout.py
TextFitter._break_line
def _break_line(self, line_source, point_size): """ Return a (line, remainder) pair where *line* is the longest line in *line_source* that will fit in this fitter's width and *remainder* is a |_LineSource| object containing the text following the break point. """ lines = ...
python
def _break_line(self, line_source, point_size): """ Return a (line, remainder) pair where *line* is the longest line in *line_source* that will fit in this fitter's width and *remainder* is a |_LineSource| object containing the text following the break point. """ lines = ...
['def', '_break_line', '(', 'self', ',', 'line_source', ',', 'point_size', ')', ':', 'lines', '=', '_BinarySearchTree', '.', 'from_ordered_sequence', '(', 'line_source', ')', 'predicate', '=', 'self', '.', '_fits_in_width_predicate', '(', 'point_size', ')', 'return', 'lines', '.', 'find_max', '(', 'predicate', ')']
Return a (line, remainder) pair where *line* is the longest line in *line_source* that will fit in this fitter's width and *remainder* is a |_LineSource| object containing the text following the break point.
['Return', 'a', '(', 'line', 'remainder', ')', 'pair', 'where', '*', 'line', '*', 'is', 'the', 'longest', 'line', 'in', '*', 'line_source', '*', 'that', 'will', 'fit', 'in', 'this', 'fitter', 's', 'width', 'and', '*', 'remainder', '*', 'is', 'a', '|_LineSource|', 'object', 'containing', 'the', 'text', 'following', 'the...
train
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/text/layout.py#L42-L50
9,948
Stranger6667/postmarker
postmarker/models/stats.py
StatsManager.emailclients
def emailclients(self, tag=None, fromdate=None, todate=None): """ Gets an overview of the email clients used to open your emails. This is only recorded when open tracking is enabled for that email. """ return self.call("GET", "/stats/outbound/opens/emailclients", tag=tag, fromdat...
python
def emailclients(self, tag=None, fromdate=None, todate=None): """ Gets an overview of the email clients used to open your emails. This is only recorded when open tracking is enabled for that email. """ return self.call("GET", "/stats/outbound/opens/emailclients", tag=tag, fromdat...
['def', 'emailclients', '(', 'self', ',', 'tag', '=', 'None', ',', 'fromdate', '=', 'None', ',', 'todate', '=', 'None', ')', ':', 'return', 'self', '.', 'call', '(', '"GET"', ',', '"/stats/outbound/opens/emailclients"', ',', 'tag', '=', 'tag', ',', 'fromdate', '=', 'fromdate', ',', 'todate', '=', 'todate', ')']
Gets an overview of the email clients used to open your emails. This is only recorded when open tracking is enabled for that email.
['Gets', 'an', 'overview', 'of', 'the', 'email', 'clients', 'used', 'to', 'open', 'your', 'emails', '.', 'This', 'is', 'only', 'recorded', 'when', 'open', 'tracking', 'is', 'enabled', 'for', 'that', 'email', '.']
train
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/stats.py#L52-L57
9,949
jciskey/pygraph
pygraph/functions/planarity/kocay_algorithm.py
__insert_frond_LF
def __insert_frond_LF(d_w, d_u, dfs_data): """Encapsulates the process of inserting a frond uw into the left side frond group.""" # --Add the frond to the left side dfs_data['LF'].append( (d_w, d_u) ) dfs_data['FG']['l'] += 1 dfs_data['last_inserted_side'] = 'LF'
python
def __insert_frond_LF(d_w, d_u, dfs_data): """Encapsulates the process of inserting a frond uw into the left side frond group.""" # --Add the frond to the left side dfs_data['LF'].append( (d_w, d_u) ) dfs_data['FG']['l'] += 1 dfs_data['last_inserted_side'] = 'LF'
['def', '__insert_frond_LF', '(', 'd_w', ',', 'd_u', ',', 'dfs_data', ')', ':', '# --Add the frond to the left side', 'dfs_data', '[', "'LF'", ']', '.', 'append', '(', '(', 'd_w', ',', 'd_u', ')', ')', 'dfs_data', '[', "'FG'", ']', '[', "'l'", ']', '+=', '1', 'dfs_data', '[', "'last_inserted_side'", ']', '=', "'LF'"]
Encapsulates the process of inserting a frond uw into the left side frond group.
['Encapsulates', 'the', 'process', 'of', 'inserting', 'a', 'frond', 'uw', 'into', 'the', 'left', 'side', 'frond', 'group', '.']
train
https://github.com/jciskey/pygraph/blob/037bb2f32503fecb60d62921f9766d54109f15e2/pygraph/functions/planarity/kocay_algorithm.py#L481-L487
9,950
quantmind/pulsar
pulsar/apps/http/stream.py
HttpStream.read
async def read(self, n=None): """Read all content """ if self._streamed: return b'' buffer = [] async for body in self: buffer.append(body) return b''.join(buffer)
python
async def read(self, n=None): """Read all content """ if self._streamed: return b'' buffer = [] async for body in self: buffer.append(body) return b''.join(buffer)
['async', 'def', 'read', '(', 'self', ',', 'n', '=', 'None', ')', ':', 'if', 'self', '.', '_streamed', ':', 'return', "b''", 'buffer', '=', '[', ']', 'async', 'for', 'body', 'in', 'self', ':', 'buffer', '.', 'append', '(', 'body', ')', 'return', "b''", '.', 'join', '(', 'buffer', ')']
Read all content
['Read', 'all', 'content']
train
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/http/stream.py#L27-L35
9,951
pkgw/pwkit
pwkit/environments/casa/dftphotom.py
dftphotom
def dftphotom(cfg): """Run the discrete-Fourier-transform photometry algorithm. See the module-level documentation and the output of ``casatask dftphotom --help`` for help. All of the algorithm configuration is specified in the *cfg* argument, which is an instance of :class:`Config`. """ tb = ...
python
def dftphotom(cfg): """Run the discrete-Fourier-transform photometry algorithm. See the module-level documentation and the output of ``casatask dftphotom --help`` for help. All of the algorithm configuration is specified in the *cfg* argument, which is an instance of :class:`Config`. """ tb = ...
['def', 'dftphotom', '(', 'cfg', ')', ':', 'tb', '=', 'util', '.', 'tools', '.', 'table', '(', ')', 'ms', '=', 'util', '.', 'tools', '.', 'ms', '(', ')', 'me', '=', 'util', '.', 'tools', '.', 'measures', '(', ')', "# Read stuff in. Even if the weight values don't have their", '# absolute scale set correctly, we can sti...
Run the discrete-Fourier-transform photometry algorithm. See the module-level documentation and the output of ``casatask dftphotom --help`` for help. All of the algorithm configuration is specified in the *cfg* argument, which is an instance of :class:`Config`.
['Run', 'the', 'discrete', '-', 'Fourier', '-', 'transform', 'photometry', 'algorithm', '.']
train
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/environments/casa/dftphotom.py#L190-L381
9,952
cuihantao/andes
andes/models/base.py
ModelBase.on_bus
def on_bus(self, bus_idx): """ Return the indices of elements on the given buses for shunt-connected elements :param bus_idx: idx of the buses to which the elements are connected :return: idx of elements connected to bus_idx """ assert hasattr(self, 'bus') ...
python
def on_bus(self, bus_idx): """ Return the indices of elements on the given buses for shunt-connected elements :param bus_idx: idx of the buses to which the elements are connected :return: idx of elements connected to bus_idx """ assert hasattr(self, 'bus') ...
['def', 'on_bus', '(', 'self', ',', 'bus_idx', ')', ':', 'assert', 'hasattr', '(', 'self', ',', "'bus'", ')', 'ret', '=', '[', ']', 'if', 'isinstance', '(', 'bus_idx', ',', '(', 'int', ',', 'float', ',', 'str', ')', ')', ':', 'bus_idx', '=', '[', 'bus_idx', ']', 'for', 'item', 'in', 'bus_idx', ':', 'idx', '=', '[', ']'...
Return the indices of elements on the given buses for shunt-connected elements :param bus_idx: idx of the buses to which the elements are connected :return: idx of elements connected to bus_idx
['Return', 'the', 'indices', 'of', 'elements', 'on', 'the', 'given', 'buses', 'for', 'shunt', '-', 'connected', 'elements']
train
https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/base.py#L1366-L1396
9,953
nkavaldj/myhdl_lib
myhdl_lib/fifo.py
fifo
def fifo(rst, clk, full, we, din, empty, re, dout, afull=None, aempty=None, afull_th=None, aempty_th=None, ovf=None, udf=None, count=None, count_max=None, depth=None, width=None): """ Synchronous FIFO Input interface: full, we, din Output interface: empty, re, dout It s possible to se...
python
def fifo(rst, clk, full, we, din, empty, re, dout, afull=None, aempty=None, afull_th=None, aempty_th=None, ovf=None, udf=None, count=None, count_max=None, depth=None, width=None): """ Synchronous FIFO Input interface: full, we, din Output interface: empty, re, dout It s possible to se...
['def', 'fifo', '(', 'rst', ',', 'clk', ',', 'full', ',', 'we', ',', 'din', ',', 'empty', ',', 're', ',', 'dout', ',', 'afull', '=', 'None', ',', 'aempty', '=', 'None', ',', 'afull_th', '=', 'None', ',', 'aempty_th', '=', 'None', ',', 'ovf', '=', 'None', ',', 'udf', '=', 'None', ',', 'count', '=', 'None', ',', 'count_m...
Synchronous FIFO Input interface: full, we, din Output interface: empty, re, dout It s possible to set din and dout to None. Then the fifo width will be 0 and the fifo will contain no storage. Extra interface: afull (o) - almost full flag, asserted when the number of ...
['Synchronous', 'FIFO']
train
https://github.com/nkavaldj/myhdl_lib/blob/9902afd2031e7847373f692821b2135fd0810aa8/myhdl_lib/fifo.py#L6-L210
9,954
chemlab/chemlab
chemlab/mviewer/api/appeareance.py
change_color
def change_color(color): """Change the color of the currently selected objects. *color* is represented as a string. Otherwise color can be passed as an rgba tuple of values between 0, 255 Reset the color by passing *color=None*. You can call this function interactively by using:: chan...
python
def change_color(color): """Change the color of the currently selected objects. *color* is represented as a string. Otherwise color can be passed as an rgba tuple of values between 0, 255 Reset the color by passing *color=None*. You can call this function interactively by using:: chan...
['def', 'change_color', '(', 'color', ')', ':', 'rep', '=', 'current_representation', '(', ')', "# Let's parse the color first", 'if', 'isinstance', '(', 'color', ',', 'str', ')', ':', '# The color should be a string', 'col', '=', 'color_from_string', '(', 'color', ')', 'if', 'isinstance', '(', 'color', ',', 'tuple', '...
Change the color of the currently selected objects. *color* is represented as a string. Otherwise color can be passed as an rgba tuple of values between 0, 255 Reset the color by passing *color=None*. You can call this function interactively by using:: change_color.interactive() ...
['Change', 'the', 'color', 'of', 'the', 'currently', 'selected', 'objects', '.', '*', 'color', '*', 'is', 'represented', 'as', 'a', 'string', '.', 'Otherwise', 'color', 'can', 'be', 'passed', 'as', 'an', 'rgba', 'tuple', 'of', 'values', 'between', '0', '255']
train
https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/mviewer/api/appeareance.py#L85-L113
9,955
thiagopbueno/rddl2tf
rddl2tf/fluent.py
TensorFluent.stop_gradient
def stop_gradient(cls, x: 'TensorFluent') -> 'TensorFluent': '''Returns a copy of the input fluent with stop_gradient at tensor level. Args: x: The input fluent. Returns: A TensorFluent that stops backpropagation of gradient computations. ''' scope = x.s...
python
def stop_gradient(cls, x: 'TensorFluent') -> 'TensorFluent': '''Returns a copy of the input fluent with stop_gradient at tensor level. Args: x: The input fluent. Returns: A TensorFluent that stops backpropagation of gradient computations. ''' scope = x.s...
['def', 'stop_gradient', '(', 'cls', ',', 'x', ':', "'TensorFluent'", ')', '->', "'TensorFluent'", ':', 'scope', '=', 'x', '.', 'scope', '.', 'as_list', '(', ')', 'batch', '=', 'x', '.', 'batch', 'return', 'TensorFluent', '(', 'tf', '.', 'stop_gradient', '(', 'x', '.', 'tensor', ')', ',', 'scope', ',', 'batch', ')']
Returns a copy of the input fluent with stop_gradient at tensor level. Args: x: The input fluent. Returns: A TensorFluent that stops backpropagation of gradient computations.
['Returns', 'a', 'copy', 'of', 'the', 'input', 'fluent', 'with', 'stop_gradient', 'at', 'tensor', 'level', '.']
train
https://github.com/thiagopbueno/rddl2tf/blob/f7c03d3a74d2663807c1e23e04eeed2e85166b71/rddl2tf/fluent.py#L256-L267
9,956
priestc/moneywagon
moneywagon/tx.py
Transaction.select_inputs
def select_inputs(self, amount): '''Maximize transaction priority. Select the oldest inputs, that are sufficient to cover the spent amount. Then, remove any unneeded inputs, starting with the smallest in value. Returns sum of amounts of inputs selected''' sorted_txin = sorted(self.in...
python
def select_inputs(self, amount): '''Maximize transaction priority. Select the oldest inputs, that are sufficient to cover the spent amount. Then, remove any unneeded inputs, starting with the smallest in value. Returns sum of amounts of inputs selected''' sorted_txin = sorted(self.in...
['def', 'select_inputs', '(', 'self', ',', 'amount', ')', ':', 'sorted_txin', '=', 'sorted', '(', 'self', '.', 'ins', ',', 'key', '=', 'lambda', 'x', ':', '-', 'x', '[', "'input'", ']', '[', "'confirmations'", ']', ')', 'total_amount', '=', '0', 'for', '(', 'idx', ',', 'tx_in', ')', 'in', 'enumerate', '(', 'sorted_txin...
Maximize transaction priority. Select the oldest inputs, that are sufficient to cover the spent amount. Then, remove any unneeded inputs, starting with the smallest in value. Returns sum of amounts of inputs selected
['Maximize', 'transaction', 'priority', '.', 'Select', 'the', 'oldest', 'inputs', 'that', 'are', 'sufficient', 'to', 'cover', 'the', 'spent', 'amount', '.', 'Then', 'remove', 'any', 'unneeded', 'inputs', 'starting', 'with', 'the', 'smallest', 'in', 'value', '.', 'Returns', 'sum', 'of', 'amounts', 'of', 'inputs', 'selec...
train
https://github.com/priestc/moneywagon/blob/00518f1f557dcca8b3031f46d3564c2baa0227a3/moneywagon/tx.py#L123-L143
9,957
Bogdanp/dramatiq
dramatiq/rate_limits/rate_limiter.py
RateLimiter.acquire
def acquire(self, *, raise_on_failure=True): """Attempt to acquire a slot under this rate limiter. Parameters: raise_on_failure(bool): Whether or not failures should raise an exception. If this is false, the context manager will instead return a boolean value represen...
python
def acquire(self, *, raise_on_failure=True): """Attempt to acquire a slot under this rate limiter. Parameters: raise_on_failure(bool): Whether or not failures should raise an exception. If this is false, the context manager will instead return a boolean value represen...
['def', 'acquire', '(', 'self', ',', '*', ',', 'raise_on_failure', '=', 'True', ')', ':', 'acquired', '=', 'False', 'try', ':', 'acquired', '=', 'self', '.', '_acquire', '(', ')', 'if', 'raise_on_failure', 'and', 'not', 'acquired', ':', 'raise', 'RateLimitExceeded', '(', '"rate limit exceeded for key %(key)r"', '%', 'v...
Attempt to acquire a slot under this rate limiter. Parameters: raise_on_failure(bool): Whether or not failures should raise an exception. If this is false, the context manager will instead return a boolean value representing whether or not the rate limit slot was ...
['Attempt', 'to', 'acquire', 'a', 'slot', 'under', 'this', 'rate', 'limiter', '.']
train
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/rate_limits/rate_limiter.py#L56-L78
9,958
HDI-Project/ballet
ballet/project.py
Project.pr_num
def pr_num(self): """Return the PR number or None if not on a PR""" result = get_pr_num(repo=self.repo) if result is None: result = get_travis_pr_num() return result
python
def pr_num(self): """Return the PR number or None if not on a PR""" result = get_pr_num(repo=self.repo) if result is None: result = get_travis_pr_num() return result
['def', 'pr_num', '(', 'self', ')', ':', 'result', '=', 'get_pr_num', '(', 'repo', '=', 'self', '.', 'repo', ')', 'if', 'result', 'is', 'None', ':', 'result', '=', 'get_travis_pr_num', '(', ')', 'return', 'result']
Return the PR number or None if not on a PR
['Return', 'the', 'PR', 'number', 'or', 'None', 'if', 'not', 'on', 'a', 'PR']
train
https://github.com/HDI-Project/ballet/blob/6f4d4b87b8234cb6bb38b9e9484a58ef8fe8fdb2/ballet/project.py#L165-L170
9,959
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py
MAVLink.data64_send
def data64_send(self, type, len, data, force_mavlink1=False): ''' Data packet, size 64 type : data type (uint8_t) len : data length (uint8_t) data : raw data (uint8_t) ...
python
def data64_send(self, type, len, data, force_mavlink1=False): ''' Data packet, size 64 type : data type (uint8_t) len : data length (uint8_t) data : raw data (uint8_t) ...
['def', 'data64_send', '(', 'self', ',', 'type', ',', 'len', ',', 'data', ',', 'force_mavlink1', '=', 'False', ')', ':', 'return', 'self', '.', 'send', '(', 'self', '.', 'data64_encode', '(', 'type', ',', 'len', ',', 'data', ')', ',', 'force_mavlink1', '=', 'force_mavlink1', ')']
Data packet, size 64 type : data type (uint8_t) len : data length (uint8_t) data : raw data (uint8_t)
['Data', 'packet', 'size', '64']
train
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/dialects/v20/ardupilotmega.py#L10273-L10282
9,960
titusjan/argos
argos/widgets/argostreeview.py
ArgosTreeView.expandPath
def expandPath(self, path): """ Follows the path and expand all nodes along the way. Returns (item, index) tuple of the last node in the path (the leaf node). This can be reused e.g. to select it. """ iiPath = self.model().findItemAndIndexPath(path) for (item, ind...
python
def expandPath(self, path): """ Follows the path and expand all nodes along the way. Returns (item, index) tuple of the last node in the path (the leaf node). This can be reused e.g. to select it. """ iiPath = self.model().findItemAndIndexPath(path) for (item, ind...
['def', 'expandPath', '(', 'self', ',', 'path', ')', ':', 'iiPath', '=', 'self', '.', 'model', '(', ')', '.', 'findItemAndIndexPath', '(', 'path', ')', 'for', '(', 'item', ',', 'index', ')', 'in', 'iiPath', '[', '1', ':', ']', ':', '# skip invisible root', 'assert', 'index', '.', 'isValid', '(', ')', ',', '"Sanity chec...
Follows the path and expand all nodes along the way. Returns (item, index) tuple of the last node in the path (the leaf node). This can be reused e.g. to select it.
['Follows', 'the', 'path', 'and', 'expand', 'all', 'nodes', 'along', 'the', 'way', '.', 'Returns', '(', 'item', 'index', ')', 'tuple', 'of', 'the', 'last', 'node', 'in', 'the', 'path', '(', 'the', 'leaf', 'node', ')', '.', 'This', 'can', 'be', 'reused', 'e', '.', 'g', '.', 'to', 'select', 'it', '.']
train
https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/widgets/argostreeview.py#L126-L137
9,961
allenai/allennlp
allennlp/models/semantic_parsing/wikitables/wikitables_semantic_parser.py
WikiTablesSemanticParser.decode
def decode(self, output_dict: Dict[str, torch.Tensor]) -> Dict[str, torch.Tensor]: """ This method overrides ``Model.decode``, which gets called after ``Model.forward``, at test time, to finalize predictions. This is (confusingly) a separate notion from the "decoder" in "encoder/decoder...
python
def decode(self, output_dict: Dict[str, torch.Tensor]) -> Dict[str, torch.Tensor]: """ This method overrides ``Model.decode``, which gets called after ``Model.forward``, at test time, to finalize predictions. This is (confusingly) a separate notion from the "decoder" in "encoder/decoder...
['def', 'decode', '(', 'self', ',', 'output_dict', ':', 'Dict', '[', 'str', ',', 'torch', '.', 'Tensor', ']', ')', '->', 'Dict', '[', 'str', ',', 'torch', '.', 'Tensor', ']', ':', 'action_mapping', '=', 'output_dict', '[', "'action_mapping'", ']', 'best_actions', '=', 'output_dict', '[', '"best_action_sequence"', ']', ...
This method overrides ``Model.decode``, which gets called after ``Model.forward``, at test time, to finalize predictions. This is (confusingly) a separate notion from the "decoder" in "encoder/decoder", where that decoder logic lives in the ``TransitionFunction``. This method trims the output ...
['This', 'method', 'overrides', 'Model', '.', 'decode', 'which', 'gets', 'called', 'after', 'Model', '.', 'forward', 'at', 'test', 'time', 'to', 'finalize', 'predictions', '.', 'This', 'is', '(', 'confusingly', ')', 'a', 'separate', 'notion', 'from', 'the', 'decoder', 'in', 'encoder', '/', 'decoder', 'where', 'that', '...
train
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/models/semantic_parsing/wikitables/wikitables_semantic_parser.py#L676-L708
9,962
flowersteam/explauto
explauto/sensorimotor_model/inverse/cma.py
CMADataLogger.register
def register(self, es, append=None, modulo=None): """register a `CMAEvolutionStrategy` instance for logging, ``append=True`` appends to previous data logged under the same name, by default previous data are overwritten. """ if not isinstance(es, CMAEvolutionStrategy): ...
python
def register(self, es, append=None, modulo=None): """register a `CMAEvolutionStrategy` instance for logging, ``append=True`` appends to previous data logged under the same name, by default previous data are overwritten. """ if not isinstance(es, CMAEvolutionStrategy): ...
['def', 'register', '(', 'self', ',', 'es', ',', 'append', '=', 'None', ',', 'modulo', '=', 'None', ')', ':', 'if', 'not', 'isinstance', '(', 'es', ',', 'CMAEvolutionStrategy', ')', ':', 'raise', 'TypeError', '(', '"only class CMAEvolutionStrategy can be "', '+', '"registered for logging"', ')', 'self', '.', 'es', '=',...
register a `CMAEvolutionStrategy` instance for logging, ``append=True`` appends to previous data logged under the same name, by default previous data are overwritten.
['register', 'a', 'CMAEvolutionStrategy', 'instance', 'for', 'logging', 'append', '=', 'True', 'appends', 'to', 'previous', 'data', 'logged', 'under', 'the', 'same', 'name', 'by', 'default', 'previous', 'data', 'are', 'overwritten', '.']
train
https://github.com/flowersteam/explauto/blob/cf0f81ecb9f6412f7276a95bd27359000e1e26b6/explauto/sensorimotor_model/inverse/cma.py#L5722-L5737
9,963
glomex/gcdt
gcdt/ramuda_core.py
cleanup_bundle
def cleanup_bundle(): """Deletes files used for creating bundle. * vendored/* * bundle.zip """ paths = ['./vendored', './bundle.zip'] for path in paths: if os.path.exists(path): log.debug("Deleting %s..." % path) if os.path.isdir(path): shu...
python
def cleanup_bundle(): """Deletes files used for creating bundle. * vendored/* * bundle.zip """ paths = ['./vendored', './bundle.zip'] for path in paths: if os.path.exists(path): log.debug("Deleting %s..." % path) if os.path.isdir(path): shu...
['def', 'cleanup_bundle', '(', ')', ':', 'paths', '=', '[', "'./vendored'", ',', "'./bundle.zip'", ']', 'for', 'path', 'in', 'paths', ':', 'if', 'os', '.', 'path', '.', 'exists', '(', 'path', ')', ':', 'log', '.', 'debug', '(', '"Deleting %s..."', '%', 'path', ')', 'if', 'os', '.', 'path', '.', 'isdir', '(', 'path', ')...
Deletes files used for creating bundle. * vendored/* * bundle.zip
['Deletes', 'files', 'used', 'for', 'creating', 'bundle', '.', '*', 'vendored', '/', '*', '*', 'bundle', '.', 'zip']
train
https://github.com/glomex/gcdt/blob/cd67cf416371337b83cb9ca3f696277125703339/gcdt/ramuda_core.py#L623-L635
9,964
datastax/python-driver
cassandra/metadata.py
NetworkTopologyStrategy.export_for_schema
def export_for_schema(self): """ Returns a string version of these replication options which are suitable for use in a CREATE KEYSPACE statement. """ ret = "{'class': 'NetworkTopologyStrategy'" for dc, repl_factor in sorted(self.dc_replication_factors.items()): ...
python
def export_for_schema(self): """ Returns a string version of these replication options which are suitable for use in a CREATE KEYSPACE statement. """ ret = "{'class': 'NetworkTopologyStrategy'" for dc, repl_factor in sorted(self.dc_replication_factors.items()): ...
['def', 'export_for_schema', '(', 'self', ')', ':', 'ret', '=', '"{\'class\': \'NetworkTopologyStrategy\'"', 'for', 'dc', ',', 'repl_factor', 'in', 'sorted', '(', 'self', '.', 'dc_replication_factors', '.', 'items', '(', ')', ')', ':', 'ret', '+=', '", \'%s\': \'%d\'"', '%', '(', 'dc', ',', 'repl_factor', ')', 'return'...
Returns a string version of these replication options which are suitable for use in a CREATE KEYSPACE statement.
['Returns', 'a', 'string', 'version', 'of', 'these', 'replication', 'options', 'which', 'are', 'suitable', 'for', 'use', 'in', 'a', 'CREATE', 'KEYSPACE', 'statement', '.']
train
https://github.com/datastax/python-driver/blob/30a80d0b798b1f45f8cb77163b1fa791f3e3ca29/cassandra/metadata.py#L565-L573
9,965
Laufire/ec
ec/modules/config.py
task
def task(__decorated__=None, **Config): r"""A decorator to make tasks out of functions. Config: * name (str): The name of the task. Defaults to __decorated__.__name__. * desc (str): The description of the task (optional). * alias (str): The alias for the task (optional). """ if isinstance(__decorat...
python
def task(__decorated__=None, **Config): r"""A decorator to make tasks out of functions. Config: * name (str): The name of the task. Defaults to __decorated__.__name__. * desc (str): The description of the task (optional). * alias (str): The alias for the task (optional). """ if isinstance(__decorat...
['def', 'task', '(', '__decorated__', '=', 'None', ',', '*', '*', 'Config', ')', ':', 'if', 'isinstance', '(', '__decorated__', ',', 'tuple', ')', ':', '# the task has some args', '_Task', '=', 'Task', '(', '__decorated__', '[', '0', ']', ',', '__decorated__', '[', '1', ']', ',', 'Config', '=', 'Config', ')', 'else', '...
r"""A decorator to make tasks out of functions. Config: * name (str): The name of the task. Defaults to __decorated__.__name__. * desc (str): The description of the task (optional). * alias (str): The alias for the task (optional).
['r', 'A', 'decorator', 'to', 'make', 'tasks', 'out', 'of', 'functions', '.']
train
https://github.com/Laufire/ec/blob/63e84a1daef9234487d7de538e5da233a7d13071/ec/modules/config.py#L37-L53
9,966
theonion/django-bulbs
bulbs/content/serializers.py
ContentTypeField.to_internal_value
def to_internal_value(self, value): """Convert to integer id.""" natural_key = value.split("_") content_type = ContentType.objects.get_by_natural_key(*natural_key) return content_type.id
python
def to_internal_value(self, value): """Convert to integer id.""" natural_key = value.split("_") content_type = ContentType.objects.get_by_natural_key(*natural_key) return content_type.id
['def', 'to_internal_value', '(', 'self', ',', 'value', ')', ':', 'natural_key', '=', 'value', '.', 'split', '(', '"_"', ')', 'content_type', '=', 'ContentType', '.', 'objects', '.', 'get_by_natural_key', '(', '*', 'natural_key', ')', 'return', 'content_type', '.', 'id']
Convert to integer id.
['Convert', 'to', 'integer', 'id', '.']
train
https://github.com/theonion/django-bulbs/blob/0c0e6e3127a7dc487b96677fab95cacd2b3806da/bulbs/content/serializers.py#L24-L28
9,967
TriOptima/tri.table
lib/tri/table/__init__.py
prepare_headers
def prepare_headers(table, bound_columns): """ :type bound_columns: list of BoundColumn """ if table.request is None: return for column in bound_columns: if column.sortable: params = table.request.GET.copy() param_path = _with_path_prefix(table, 'order') ...
python
def prepare_headers(table, bound_columns): """ :type bound_columns: list of BoundColumn """ if table.request is None: return for column in bound_columns: if column.sortable: params = table.request.GET.copy() param_path = _with_path_prefix(table, 'order') ...
['def', 'prepare_headers', '(', 'table', ',', 'bound_columns', ')', ':', 'if', 'table', '.', 'request', 'is', 'None', ':', 'return', 'for', 'column', 'in', 'bound_columns', ':', 'if', 'column', '.', 'sortable', ':', 'params', '=', 'table', '.', 'request', '.', 'GET', '.', 'copy', '(', ')', 'param_path', '=', '_with_pat...
:type bound_columns: list of BoundColumn
[':', 'type', 'bound_columns', ':', 'list', 'of', 'BoundColumn']
train
https://github.com/TriOptima/tri.table/blob/fc38c02098a80a3fb336ac4cf502954d74e31484/lib/tri/table/__init__.py#L112-L138
9,968
glenfant/openxmllib
openxmllib/document.py
Document.mimeType
def mimeType(self): """The official MIME type for this document, guessed from the extensions of the :py:attr:`openxmllib.document.Document.filename` attribute, as opposed to the :py:attr:`openxmllib.document.Document.mime_type` attribute. :return: ``application/xxx`` for this fi...
python
def mimeType(self): """The official MIME type for this document, guessed from the extensions of the :py:attr:`openxmllib.document.Document.filename` attribute, as opposed to the :py:attr:`openxmllib.document.Document.mime_type` attribute. :return: ``application/xxx`` for this fi...
['def', 'mimeType', '(', 'self', ')', ':', 'if', 'self', '.', 'mime_type', ':', '# Supposed validated by the factory', 'return', 'self', '.', 'mime_type', 'for', 'pattern', ',', 'mime_type', 'in', 'self', '.', '_extpattern_to_mime', '.', 'items', '(', ')', ':', 'if', 'fnmatch', '.', 'fnmatch', '(', 'self', '.', 'filena...
The official MIME type for this document, guessed from the extensions of the :py:attr:`openxmllib.document.Document.filename` attribute, as opposed to the :py:attr:`openxmllib.document.Document.mime_type` attribute. :return: ``application/xxx`` for this file
['The', 'official', 'MIME', 'type', 'for', 'this', 'document', 'guessed', 'from', 'the', 'extensions', 'of', 'the', ':', 'py', ':', 'attr', ':', 'openxmllib', '.', 'document', '.', 'Document', '.', 'filename', 'attribute', 'as', 'opposed', 'to', 'the', ':', 'py', ':', 'attr', ':', 'openxmllib', '.', 'document', '.', 'D...
train
https://github.com/glenfant/openxmllib/blob/c8208f8ecd9fc3ef1e73c1db68081a65361afb3f/openxmllib/document.py#L89-L102
9,969
Accelize/pycosio
pycosio/storage/azure_file.py
_AzureFileSystem._make_dir
def _make_dir(self, client_kwargs): """ Make a directory. args: client_kwargs (dict): Client arguments. """ with _handle_azure_exception(): # Directory if 'directory_name' in client_kwargs: return self.client.create_directory( ...
python
def _make_dir(self, client_kwargs): """ Make a directory. args: client_kwargs (dict): Client arguments. """ with _handle_azure_exception(): # Directory if 'directory_name' in client_kwargs: return self.client.create_directory( ...
['def', '_make_dir', '(', 'self', ',', 'client_kwargs', ')', ':', 'with', '_handle_azure_exception', '(', ')', ':', '# Directory', 'if', "'directory_name'", 'in', 'client_kwargs', ':', 'return', 'self', '.', 'client', '.', 'create_directory', '(', 'share_name', '=', 'client_kwargs', '[', "'share_name'", ']', ',', 'dire...
Make a directory. args: client_kwargs (dict): Client arguments.
['Make', 'a', 'directory', '.']
train
https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure_file.py#L169-L184
9,970
dmlc/gluon-nlp
scripts/machine_translation/bleu.py
_bpe_to_words
def _bpe_to_words(sentence, delimiter='@@'): """Convert a sequence of bpe words into sentence.""" words = [] word = '' delimiter_len = len(delimiter) for subwords in sentence: if len(subwords) >= delimiter_len and subwords[-delimiter_len:] == delimiter: word += subwords[:-delimit...
python
def _bpe_to_words(sentence, delimiter='@@'): """Convert a sequence of bpe words into sentence.""" words = [] word = '' delimiter_len = len(delimiter) for subwords in sentence: if len(subwords) >= delimiter_len and subwords[-delimiter_len:] == delimiter: word += subwords[:-delimit...
['def', '_bpe_to_words', '(', 'sentence', ',', 'delimiter', '=', "'@@'", ')', ':', 'words', '=', '[', ']', 'word', '=', "''", 'delimiter_len', '=', 'len', '(', 'delimiter', ')', 'for', 'subwords', 'in', 'sentence', ':', 'if', 'len', '(', 'subwords', ')', '>=', 'delimiter_len', 'and', 'subwords', '[', '-', 'delimiter_le...
Convert a sequence of bpe words into sentence.
['Convert', 'a', 'sequence', 'of', 'bpe', 'words', 'into', 'sentence', '.']
train
https://github.com/dmlc/gluon-nlp/blob/4b83eb6bcc8881e5f1081a3675adaa19fac5c0ba/scripts/machine_translation/bleu.py#L61-L73
9,971
StackStorm/pybind
pybind/nos/v6_0_2f/brocade_xstp_ext_rpc/get_stp_brief_info/output/spanning_tree_info/__init__.py
spanning_tree_info._set_stp
def _set_stp(self, v, load=False): """ Setter method for stp, mapped from YANG variable /brocade_xstp_ext_rpc/get_stp_brief_info/output/spanning_tree_info/stp (container) If this variable is read-only (config: false) in the source YANG file, then _set_stp is considered as a private method. Backends ...
python
def _set_stp(self, v, load=False): """ Setter method for stp, mapped from YANG variable /brocade_xstp_ext_rpc/get_stp_brief_info/output/spanning_tree_info/stp (container) If this variable is read-only (config: false) in the source YANG file, then _set_stp is considered as a private method. Backends ...
['def', '_set_stp', '(', 'self', ',', 'v', ',', 'load', '=', 'False', ')', ':', 'if', 'hasattr', '(', 'v', ',', '"_utype"', ')', ':', 'v', '=', 'v', '.', '_utype', '(', 'v', ')', 'try', ':', 't', '=', 'YANGDynClass', '(', 'v', ',', 'base', '=', 'stp', '.', 'stp', ',', 'is_container', '=', "'container'", ',', 'presence'...
Setter method for stp, mapped from YANG variable /brocade_xstp_ext_rpc/get_stp_brief_info/output/spanning_tree_info/stp (container) If this variable is read-only (config: false) in the source YANG file, then _set_stp is considered as a private method. Backends looking to populate this variable should do...
['Setter', 'method', 'for', 'stp', 'mapped', 'from', 'YANG', 'variable', '/', 'brocade_xstp_ext_rpc', '/', 'get_stp_brief_info', '/', 'output', '/', 'spanning_tree_info', '/', 'stp', '(', 'container', ')', 'If', 'this', 'variable', 'is', 'read', '-', 'only', '(', 'config', ':', 'false', ')', 'in', 'the', 'source', 'YAN...
train
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/brocade_xstp_ext_rpc/get_stp_brief_info/output/spanning_tree_info/__init__.py#L140-L161
9,972
Cog-Creators/Red-Lavalink
lavalink/player_manager.py
Player.handle_player_update
async def handle_player_update(self, state: "node.PlayerState"): """ Handles player updates from lavalink. Parameters ---------- state : websocket.PlayerState """ if state.position > self.position: self._is_playing = True self.position = state...
python
async def handle_player_update(self, state: "node.PlayerState"): """ Handles player updates from lavalink. Parameters ---------- state : websocket.PlayerState """ if state.position > self.position: self._is_playing = True self.position = state...
['async', 'def', 'handle_player_update', '(', 'self', ',', 'state', ':', '"node.PlayerState"', ')', ':', 'if', 'state', '.', 'position', '>', 'self', '.', 'position', ':', 'self', '.', '_is_playing', '=', 'True', 'self', '.', 'position', '=', 'state', '.', 'position']
Handles player updates from lavalink. Parameters ---------- state : websocket.PlayerState
['Handles', 'player', 'updates', 'from', 'lavalink', '.']
train
https://github.com/Cog-Creators/Red-Lavalink/blob/5b3fc6eb31ee5db8bd2b633a523cf69749957111/lavalink/player_manager.py#L214-L224
9,973
bruth/django-preserialize
preserialize/utils.py
ModelFieldResolver._get_local_fields
def _get_local_fields(self, model): "Return the names of all locally defined fields on the model class." local = [f for f in model._meta.fields] m2m = [f for f in model._meta.many_to_many] fields = local + m2m names = tuple([x.name for x in fields]) return { ...
python
def _get_local_fields(self, model): "Return the names of all locally defined fields on the model class." local = [f for f in model._meta.fields] m2m = [f for f in model._meta.many_to_many] fields = local + m2m names = tuple([x.name for x in fields]) return { ...
['def', '_get_local_fields', '(', 'self', ',', 'model', ')', ':', 'local', '=', '[', 'f', 'for', 'f', 'in', 'model', '.', '_meta', '.', 'fields', ']', 'm2m', '=', '[', 'f', 'for', 'f', 'in', 'model', '.', '_meta', '.', 'many_to_many', ']', 'fields', '=', 'local', '+', 'm2m', 'names', '=', 'tuple', '(', '[', 'x', '.', '...
Return the names of all locally defined fields on the model class.
['Return', 'the', 'names', 'of', 'all', 'locally', 'defined', 'fields', 'on', 'the', 'model', 'class', '.']
train
https://github.com/bruth/django-preserialize/blob/d772c224bd8c2c9e9ff997d82c54fe6ebb9444b6/preserialize/utils.py#L42-L51
9,974
totalgood/nlpia
src/nlpia/book/examples/ch04_sklearn_pca_source.py
_fit_full
def _fit_full(self=self, X=X, n_components=6): """Fit the model by computing full SVD on X""" n_samples, n_features = X.shape # Center data self.mean_ = np.mean(X, axis=0) print(self.mean_) X -= self.mean_ print(X.round(2)) U, S, V = linalg.svd(X, full_matrices=False) print(V.round...
python
def _fit_full(self=self, X=X, n_components=6): """Fit the model by computing full SVD on X""" n_samples, n_features = X.shape # Center data self.mean_ = np.mean(X, axis=0) print(self.mean_) X -= self.mean_ print(X.round(2)) U, S, V = linalg.svd(X, full_matrices=False) print(V.round...
['def', '_fit_full', '(', 'self', '=', 'self', ',', 'X', '=', 'X', ',', 'n_components', '=', '6', ')', ':', 'n_samples', ',', 'n_features', '=', 'X', '.', 'shape', '# Center data', 'self', '.', 'mean_', '=', 'np', '.', 'mean', '(', 'X', ',', 'axis', '=', '0', ')', 'print', '(', 'self', '.', 'mean_', ')', 'X', '-=', 'se...
Fit the model by computing full SVD on X
['Fit', 'the', 'model', 'by', 'computing', 'full', 'SVD', 'on', 'X']
train
https://github.com/totalgood/nlpia/blob/efa01126275e9cd3c3a5151a644f1c798a9ec53f/src/nlpia/book/examples/ch04_sklearn_pca_source.py#L136-L186
9,975
pypa/setuptools
setuptools/command/easy_install.py
ScriptWriter.best
def best(cls): """ Select the best ScriptWriter for this environment. """ if sys.platform == 'win32' or (os.name == 'java' and os._name == 'nt'): return WindowsScriptWriter.best() else: return cls
python
def best(cls): """ Select the best ScriptWriter for this environment. """ if sys.platform == 'win32' or (os.name == 'java' and os._name == 'nt'): return WindowsScriptWriter.best() else: return cls
['def', 'best', '(', 'cls', ')', ':', 'if', 'sys', '.', 'platform', '==', "'win32'", 'or', '(', 'os', '.', 'name', '==', "'java'", 'and', 'os', '.', '_name', '==', "'nt'", ')', ':', 'return', 'WindowsScriptWriter', '.', 'best', '(', ')', 'else', ':', 'return', 'cls']
Select the best ScriptWriter for this environment.
['Select', 'the', 'best', 'ScriptWriter', 'for', 'this', 'environment', '.']
train
https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/setuptools/command/easy_install.py#L2130-L2137
9,976
saltstack/salt
salt/modules/macdefaults.py
write
def write(domain, key, value, type='string', user=None): ''' Write a default to the system CLI Example: .. code-block:: bash salt '*' macdefaults.write com.apple.CrashReporter DialogType Server salt '*' macdefaults.write NSGlobalDomain ApplePersistence True type=bool domain ...
python
def write(domain, key, value, type='string', user=None): ''' Write a default to the system CLI Example: .. code-block:: bash salt '*' macdefaults.write com.apple.CrashReporter DialogType Server salt '*' macdefaults.write NSGlobalDomain ApplePersistence True type=bool domain ...
['def', 'write', '(', 'domain', ',', 'key', ',', 'value', ',', 'type', '=', "'string'", ',', 'user', '=', 'None', ')', ':', 'if', 'type', '==', "'bool'", 'or', 'type', '==', "'boolean'", ':', 'if', 'value', 'is', 'True', ':', 'value', '=', "'TRUE'", 'elif', 'value', 'is', 'False', ':', 'value', '=', "'FALSE'", 'cmd', '...
Write a default to the system CLI Example: .. code-block:: bash salt '*' macdefaults.write com.apple.CrashReporter DialogType Server salt '*' macdefaults.write NSGlobalDomain ApplePersistence True type=bool domain The name of the domain to write to key The key of th...
['Write', 'a', 'default', 'to', 'the', 'system']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/macdefaults.py#L27-L64
9,977
askedrelic/libgreader
libgreader/auth.py
ClientAuthMethod.post
def post(self, url, postParameters=None, urlParameters=None): """ Convenience method for requesting to google with proper cookies/params. """ if urlParameters: url = url + "?" + self.getParameters(urlParameters) headers = {'Authorization':'GoogleLogin auth=%s' % self....
python
def post(self, url, postParameters=None, urlParameters=None): """ Convenience method for requesting to google with proper cookies/params. """ if urlParameters: url = url + "?" + self.getParameters(urlParameters) headers = {'Authorization':'GoogleLogin auth=%s' % self....
['def', 'post', '(', 'self', ',', 'url', ',', 'postParameters', '=', 'None', ',', 'urlParameters', '=', 'None', ')', ':', 'if', 'urlParameters', ':', 'url', '=', 'url', '+', '"?"', '+', 'self', '.', 'getParameters', '(', 'urlParameters', ')', 'headers', '=', '{', "'Authorization'", ':', "'GoogleLogin auth=%s'", '%', 's...
Convenience method for requesting to google with proper cookies/params.
['Convenience', 'method', 'for', 'requesting', 'to', 'google', 'with', 'proper', 'cookies', '/', 'params', '.']
train
https://github.com/askedrelic/libgreader/blob/7b668ee291c2464ea172ef44393100c369efa970/libgreader/auth.py#L83-L94
9,978
phoebe-project/phoebe2
phoebe/frontend/bundle.py
Bundle._add_history
def _add_history(self, redo_func, redo_kwargs, undo_func, undo_kwargs, **kwargs): """ Add a new log (undo/redoable) to this history context :parameter str redo_func: function to redo the action, must be a method of :class:`Bundle` :parameter dict redo_kw...
python
def _add_history(self, redo_func, redo_kwargs, undo_func, undo_kwargs, **kwargs): """ Add a new log (undo/redoable) to this history context :parameter str redo_func: function to redo the action, must be a method of :class:`Bundle` :parameter dict redo_kw...
['def', '_add_history', '(', 'self', ',', 'redo_func', ',', 'redo_kwargs', ',', 'undo_func', ',', 'undo_kwargs', ',', '*', '*', 'kwargs', ')', ':', 'if', 'not', 'self', '.', 'history_enabled', ':', 'return', 'param', '=', 'HistoryParameter', '(', 'self', ',', 'redo_func', ',', 'redo_kwargs', ',', 'undo_func', ',', 'und...
Add a new log (undo/redoable) to this history context :parameter str redo_func: function to redo the action, must be a method of :class:`Bundle` :parameter dict redo_kwargs: kwargs to pass to the redo_func. Each item must be serializable (float or str, not objects) :par...
['Add', 'a', 'new', 'log', '(', 'undo', '/', 'redoable', ')', 'to', 'this', 'history', 'context']
train
https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/frontend/bundle.py#L811-L839
9,979
openstack/hacking
hacking/checks/docstrings.py
is_docstring
def is_docstring(tokens, previous_logical): """Return found docstring 'A docstring is a string literal that occurs as the first statement in a module, function, class,' http://www.python.org/dev/peps/pep-0257/#what-is-a-docstring """ for token_type, text, start, _, _ in tokens: if token...
python
def is_docstring(tokens, previous_logical): """Return found docstring 'A docstring is a string literal that occurs as the first statement in a module, function, class,' http://www.python.org/dev/peps/pep-0257/#what-is-a-docstring """ for token_type, text, start, _, _ in tokens: if token...
['def', 'is_docstring', '(', 'tokens', ',', 'previous_logical', ')', ':', 'for', 'token_type', ',', 'text', ',', 'start', ',', '_', ',', '_', 'in', 'tokens', ':', 'if', 'token_type', '==', 'tokenize', '.', 'STRING', ':', 'break', 'elif', 'token_type', '!=', 'tokenize', '.', 'INDENT', ':', 'return', 'False', 'else', ':'...
Return found docstring 'A docstring is a string literal that occurs as the first statement in a module, function, class,' http://www.python.org/dev/peps/pep-0257/#what-is-a-docstring
['Return', 'found', 'docstring']
train
https://github.com/openstack/hacking/blob/10e58f907181cac91d3b2af422c2458b04a1ec79/hacking/checks/docstrings.py#L128-L147
9,980
jantman/pypi-download-stats
pypi_download_stats/dataquery.py
DataQuery._query_by_installer
def _query_by_installer(self, table_name): """ Query for download data broken down by installer, for one day. :param table_name: table name to query against :type table_name: str :return: dict of download information by installer; keys are project name, values are a di...
python
def _query_by_installer(self, table_name): """ Query for download data broken down by installer, for one day. :param table_name: table name to query against :type table_name: str :return: dict of download information by installer; keys are project name, values are a di...
['def', '_query_by_installer', '(', 'self', ',', 'table_name', ')', ':', 'logger', '.', 'info', '(', "'Querying for downloads by installer in table %s'", ',', 'table_name', ')', 'q', '=', '"SELECT file.project, details.installer.name, "', '"details.installer.version, COUNT(*) as dl_count "', '"%s "', '"%s "', '"GROUP B...
Query for download data broken down by installer, for one day. :param table_name: table name to query against :type table_name: str :return: dict of download information by installer; keys are project name, values are a dict of installer names to dicts of installer version t...
['Query', 'for', 'download', 'data', 'broken', 'down', 'by', 'installer', 'for', 'one', 'day', '.']
train
https://github.com/jantman/pypi-download-stats/blob/44a7a6bbcd61a9e7f02bd02c52584a98183f80c5/pypi_download_stats/dataquery.py#L320-L356
9,981
axltxl/m2bk
m2bk/config.py
set_entry
def set_entry(key, value): """ Set a configuration entry :param key: key name :param value: value for this key :raises KeyError: if key is not str """ if type(key) != str: raise KeyError('key must be str') _config[key] = value
python
def set_entry(key, value): """ Set a configuration entry :param key: key name :param value: value for this key :raises KeyError: if key is not str """ if type(key) != str: raise KeyError('key must be str') _config[key] = value
['def', 'set_entry', '(', 'key', ',', 'value', ')', ':', 'if', 'type', '(', 'key', ')', '!=', 'str', ':', 'raise', 'KeyError', '(', "'key must be str'", ')', '_config', '[', 'key', ']', '=', 'value']
Set a configuration entry :param key: key name :param value: value for this key :raises KeyError: if key is not str
['Set', 'a', 'configuration', 'entry']
train
https://github.com/axltxl/m2bk/blob/980083dfd17e6e783753a946e9aa809714551141/m2bk/config.py#L62-L72
9,982
dmlc/gluon-nlp
src/gluonnlp/data/transforms.py
BERTBasicTokenizer._is_control
def _is_control(self, char): """Checks whether `chars` is a control character.""" # These are technically control characters but we count them as whitespace # characters. if char in ['\t', '\n', '\r']: return False cat = unicodedata.category(char) if cat.start...
python
def _is_control(self, char): """Checks whether `chars` is a control character.""" # These are technically control characters but we count them as whitespace # characters. if char in ['\t', '\n', '\r']: return False cat = unicodedata.category(char) if cat.start...
['def', '_is_control', '(', 'self', ',', 'char', ')', ':', '# These are technically control characters but we count them as whitespace', '# characters.', 'if', 'char', 'in', '[', "'\\t'", ',', "'\\n'", ',', "'\\r'", ']', ':', 'return', 'False', 'cat', '=', 'unicodedata', '.', 'category', '(', 'char', ')', 'if', 'cat', ...
Checks whether `chars` is a control character.
['Checks', 'whether', 'chars', 'is', 'a', 'control', 'character', '.']
train
https://github.com/dmlc/gluon-nlp/blob/4b83eb6bcc8881e5f1081a3675adaa19fac5c0ba/src/gluonnlp/data/transforms.py#L793-L802
9,983
johnnoone/aioconsul
aioconsul/client/query_endpoint.py
QueryEndpoint.items
async def items(self, *, dc=None, watch=None, consistency=None): """Provides a listing of all prepared queries Parameters: dc (str): Specify datacenter that will be used. Defaults to the agent's local datacenter. watch (Blocking): Do a blocking query ...
python
async def items(self, *, dc=None, watch=None, consistency=None): """Provides a listing of all prepared queries Parameters: dc (str): Specify datacenter that will be used. Defaults to the agent's local datacenter. watch (Blocking): Do a blocking query ...
['async', 'def', 'items', '(', 'self', ',', '*', ',', 'dc', '=', 'None', ',', 'watch', '=', 'None', ',', 'consistency', '=', 'None', ')', ':', 'response', '=', 'await', 'self', '.', '_api', '.', 'get', '(', '"/v1/query"', ',', 'params', '=', '{', '"dc"', ':', 'dc', '}', ')', 'return', 'response', '.', 'body']
Provides a listing of all prepared queries Parameters: dc (str): Specify datacenter that will be used. Defaults to the agent's local datacenter. watch (Blocking): Do a blocking query consistency (Consistency): Force consistency Returns: ...
['Provides', 'a', 'listing', 'of', 'all', 'prepared', 'queries']
train
https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/client/query_endpoint.py#L15-L54
9,984
saltstack/salt
salt/modules/boto_kms.py
decrypt
def decrypt(ciphertext_blob, encryption_context=None, grant_tokens=None, region=None, key=None, keyid=None, profile=None): ''' Decrypt ciphertext. CLI example:: salt myminion boto_kms.decrypt encrypted_ciphertext ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile...
python
def decrypt(ciphertext_blob, encryption_context=None, grant_tokens=None, region=None, key=None, keyid=None, profile=None): ''' Decrypt ciphertext. CLI example:: salt myminion boto_kms.decrypt encrypted_ciphertext ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile...
['def', 'decrypt', '(', 'ciphertext_blob', ',', 'encryption_context', '=', 'None', ',', 'grant_tokens', '=', 'None', ',', 'region', '=', 'None', ',', 'key', '=', 'None', ',', 'keyid', '=', 'None', ',', 'profile', '=', 'None', ')', ':', 'conn', '=', '_get_conn', '(', 'region', '=', 'region', ',', 'key', '=', 'key', ',',...
Decrypt ciphertext. CLI example:: salt myminion boto_kms.decrypt encrypted_ciphertext
['Decrypt', 'ciphertext', '.']
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L156-L177
9,985
kallimachos/chios
chios/remoteinclude/__init__.py
setup
def setup(app): """ Setup for Sphinx extension. :param app: Sphinx application context. """ app.info('adding remote-include directive...', nonl=True) app.add_directive('remote-include', RemoteInclude) app.info(' done') return { 'version': __version__, 'parallel_read_safe...
python
def setup(app): """ Setup for Sphinx extension. :param app: Sphinx application context. """ app.info('adding remote-include directive...', nonl=True) app.add_directive('remote-include', RemoteInclude) app.info(' done') return { 'version': __version__, 'parallel_read_safe...
['def', 'setup', '(', 'app', ')', ':', 'app', '.', 'info', '(', "'adding remote-include directive...'", ',', 'nonl', '=', 'True', ')', 'app', '.', 'add_directive', '(', "'remote-include'", ',', 'RemoteInclude', ')', 'app', '.', 'info', '(', "' done'", ')', 'return', '{', "'version'", ':', '__version__', ',', "'parallel...
Setup for Sphinx extension. :param app: Sphinx application context.
['Setup', 'for', 'Sphinx', 'extension', '.']
train
https://github.com/kallimachos/chios/blob/e14044e4019d57089c625d4ad2f73ccb66b8b7b8/chios/remoteinclude/__init__.py#L60-L73
9,986
HDI-Project/BTB
btb/selection/pure.py
PureBestKVelocity.compute_rewards
def compute_rewards(self, scores): """ Compute the "velocity" of (average distance between) the k+1 best scores. Return a list with those k velocities padded out with zeros so that the count remains the same. """ # get the k + 1 best scores in descending order bes...
python
def compute_rewards(self, scores): """ Compute the "velocity" of (average distance between) the k+1 best scores. Return a list with those k velocities padded out with zeros so that the count remains the same. """ # get the k + 1 best scores in descending order bes...
['def', 'compute_rewards', '(', 'self', ',', 'scores', ')', ':', '# get the k + 1 best scores in descending order', 'best_scores', '=', 'sorted', '(', 'scores', ',', 'reverse', '=', 'True', ')', '[', ':', 'self', '.', 'k', '+', '1', ']', 'velocities', '=', '[', 'best_scores', '[', 'i', ']', '-', 'best_scores', '[', 'i'...
Compute the "velocity" of (average distance between) the k+1 best scores. Return a list with those k velocities padded out with zeros so that the count remains the same.
['Compute', 'the', 'velocity', 'of', '(', 'average', 'distance', 'between', ')', 'the', 'k', '+', '1', 'best', 'scores', '.', 'Return', 'a', 'list', 'with', 'those', 'k', 'velocities', 'padded', 'out', 'with', 'zeros', 'so', 'that', 'the', 'count', 'remains', 'the', 'same', '.']
train
https://github.com/HDI-Project/BTB/blob/7f489ebc5591bd0886652ef743098c022d7f7460/btb/selection/pure.py#L23-L36
9,987
python-gitlab/python-gitlab
gitlab/mixins.py
UpdateMixin.update
def update(self, id=None, new_data={}, **kwargs): """Update an object on the server. Args: id: ID of the object to update (can be None if not required) new_data: the update data for the object **kwargs: Extra options to send to the server (e.g. sudo) Returns...
python
def update(self, id=None, new_data={}, **kwargs): """Update an object on the server. Args: id: ID of the object to update (can be None if not required) new_data: the update data for the object **kwargs: Extra options to send to the server (e.g. sudo) Returns...
['def', 'update', '(', 'self', ',', 'id', '=', 'None', ',', 'new_data', '=', '{', '}', ',', '*', '*', 'kwargs', ')', ':', 'if', 'id', 'is', 'None', ':', 'path', '=', 'self', '.', 'path', 'else', ':', 'path', '=', "'%s/%s'", '%', '(', 'self', '.', 'path', ',', 'id', ')', 'self', '.', '_check_missing_update_attrs', '(', ...
Update an object on the server. Args: id: ID of the object to update (can be None if not required) new_data: the update data for the object **kwargs: Extra options to send to the server (e.g. sudo) Returns: dict: The new object data (*not* a RESTObject) ...
['Update', 'an', 'object', 'on', 'the', 'server', '.']
train
https://github.com/python-gitlab/python-gitlab/blob/16de1b03fde3dbbe8f851614dd1d8c09de102fe5/gitlab/mixins.py#L241-L283
9,988
ml4ai/delphi
delphi/GrFN/networks.py
GroundedFunctionNetwork.to_FIB
def to_FIB(self, other): """ Creates a ForwardInfluenceBlanket object representing the intersection of this model with the other input model. Args: other: The GroundedFunctionNetwork object to compare this model to. Returns: A ForwardInfluenceBlanket object to u...
python
def to_FIB(self, other): """ Creates a ForwardInfluenceBlanket object representing the intersection of this model with the other input model. Args: other: The GroundedFunctionNetwork object to compare this model to. Returns: A ForwardInfluenceBlanket object to u...
['def', 'to_FIB', '(', 'self', ',', 'other', ')', ':', 'if', 'not', 'isinstance', '(', 'other', ',', 'GroundedFunctionNetwork', ')', ':', 'raise', 'TypeError', '(', 'f"Expected GroundedFunctionNetwork, but got {type(other)}"', ')', 'def', 'shortname', '(', 'var', ')', ':', 'return', 'var', '[', 'var', '.', 'find', '(',...
Creates a ForwardInfluenceBlanket object representing the intersection of this model with the other input model. Args: other: The GroundedFunctionNetwork object to compare this model to. Returns: A ForwardInfluenceBlanket object to use for model comparison.
['Creates', 'a', 'ForwardInfluenceBlanket', 'object', 'representing', 'the', 'intersection', 'of', 'this', 'model', 'with', 'the', 'other', 'input', 'model', '.']
train
https://github.com/ml4ai/delphi/blob/6d03d8aafeab99610387c51b89c99738ff2abbe3/delphi/GrFN/networks.py#L550-L590
9,989
TaurusOlson/fntools
fntools/fntools.py
valueof
def valueof(records, key): """Extract the value corresponding to the given key in all the dictionaries >>> bands = [{'name': 'Led Zeppelin', 'singer': 'Robert Plant', 'guitarist': 'Jimmy Page'}, ... {'name': 'Metallica', 'singer': 'James Hetfield', 'guitarist': 'Kirk Hammet'}] >>> valueof(bands, 'singe...
python
def valueof(records, key): """Extract the value corresponding to the given key in all the dictionaries >>> bands = [{'name': 'Led Zeppelin', 'singer': 'Robert Plant', 'guitarist': 'Jimmy Page'}, ... {'name': 'Metallica', 'singer': 'James Hetfield', 'guitarist': 'Kirk Hammet'}] >>> valueof(bands, 'singe...
['def', 'valueof', '(', 'records', ',', 'key', ')', ':', 'if', 'isinstance', '(', 'records', ',', 'dict', ')', ':', 'records', '=', '[', 'records', ']', 'return', 'map', '(', 'operator', '.', 'itemgetter', '(', 'key', ')', ',', 'records', ')']
Extract the value corresponding to the given key in all the dictionaries >>> bands = [{'name': 'Led Zeppelin', 'singer': 'Robert Plant', 'guitarist': 'Jimmy Page'}, ... {'name': 'Metallica', 'singer': 'James Hetfield', 'guitarist': 'Kirk Hammet'}] >>> valueof(bands, 'singer') ['Robert Plant', 'James He...
['Extract', 'the', 'value', 'corresponding', 'to', 'the', 'given', 'key', 'in', 'all', 'the', 'dictionaries']
train
https://github.com/TaurusOlson/fntools/blob/316080c7b5bfdd88c9f3fac4a67deb5be3c319e5/fntools/fntools.py#L553-L564
9,990
log2timeline/plaso
plaso/multi_processing/base_process.py
MultiProcessBaseProcess._StartProfiling
def _StartProfiling(self, configuration): """Starts profiling. Args: configuration (ProfilingConfiguration): profiling configuration. """ if not configuration: return if configuration.HaveProfileMemoryGuppy(): self._guppy_memory_profiler = profilers.GuppyMemoryProfiler( ...
python
def _StartProfiling(self, configuration): """Starts profiling. Args: configuration (ProfilingConfiguration): profiling configuration. """ if not configuration: return if configuration.HaveProfileMemoryGuppy(): self._guppy_memory_profiler = profilers.GuppyMemoryProfiler( ...
['def', '_StartProfiling', '(', 'self', ',', 'configuration', ')', ':', 'if', 'not', 'configuration', ':', 'return', 'if', 'configuration', '.', 'HaveProfileMemoryGuppy', '(', ')', ':', 'self', '.', '_guppy_memory_profiler', '=', 'profilers', '.', 'GuppyMemoryProfiler', '(', 'self', '.', '_name', ',', 'configuration', ...
Starts profiling. Args: configuration (ProfilingConfiguration): profiling configuration.
['Starts', 'profiling', '.']
train
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/multi_processing/base_process.py#L175-L213
9,991
dariusbakunas/rawdisk
rawdisk/plugins/filesystems/ntfs/ntfs.py
Ntfs.detect
def detect(self, filename, offset, standalone=False): """Verifies NTFS filesystem signature. Returns: bool: True if filesystem signature at offset 0x03 \ matches 'NTFS ', False otherwise. """ r = RawStruct( filename=filename, offset=off...
python
def detect(self, filename, offset, standalone=False): """Verifies NTFS filesystem signature. Returns: bool: True if filesystem signature at offset 0x03 \ matches 'NTFS ', False otherwise. """ r = RawStruct( filename=filename, offset=off...
['def', 'detect', '(', 'self', ',', 'filename', ',', 'offset', ',', 'standalone', '=', 'False', ')', ':', 'r', '=', 'RawStruct', '(', 'filename', '=', 'filename', ',', 'offset', '=', 'offset', '+', 'SIG_OFFSET', ',', 'length', '=', 'SIG_SIZE', ')', 'oem_id', '=', 'r', '.', 'data', 'if', 'oem_id', '==', 'b"NTFS "', '...
Verifies NTFS filesystem signature. Returns: bool: True if filesystem signature at offset 0x03 \ matches 'NTFS ', False otherwise.
['Verifies', 'NTFS', 'filesystem', 'signature', '.']
train
https://github.com/dariusbakunas/rawdisk/blob/1dc9d0b377fe5da3c406ccec4abc238c54167403/rawdisk/plugins/filesystems/ntfs/ntfs.py#L27-L44
9,992
Azure/azure-python-devtools
src/azure_devtools/ci_tools/bot_framework.py
build_from_issue_comment
def build_from_issue_comment(gh_token, body): """Create a WebhookMetadata from a comment added to an issue. """ if body["action"] in ["created", "edited"]: github_con = Github(gh_token) repo = github_con.get_repo(body['repository']['full_name']) issue = repo.get_issue(body['issue']['...
python
def build_from_issue_comment(gh_token, body): """Create a WebhookMetadata from a comment added to an issue. """ if body["action"] in ["created", "edited"]: github_con = Github(gh_token) repo = github_con.get_repo(body['repository']['full_name']) issue = repo.get_issue(body['issue']['...
['def', 'build_from_issue_comment', '(', 'gh_token', ',', 'body', ')', ':', 'if', 'body', '[', '"action"', ']', 'in', '[', '"created"', ',', '"edited"', ']', ':', 'github_con', '=', 'Github', '(', 'gh_token', ')', 'repo', '=', 'github_con', '.', 'get_repo', '(', 'body', '[', "'repository'", ']', '[', "'full_name'", ']'...
Create a WebhookMetadata from a comment added to an issue.
['Create', 'a', 'WebhookMetadata', 'from', 'a', 'comment', 'added', 'to', 'an', 'issue', '.']
train
https://github.com/Azure/azure-python-devtools/blob/2bf87b1f3cedd2b26fb2e4fd47a9baf435dcf936/src/azure_devtools/ci_tools/bot_framework.py#L25-L39
9,993
xmunoz/sodapy
sodapy/__init__.py
Socrata.upsert
def upsert(self, dataset_identifier, payload, content_type="json"): ''' Insert, update or delete data to/from an existing dataset. Currently supports json and csv file objects. See here for the upsert documentation: http://dev.socrata.com/publishers/upsert.html ''' ...
python
def upsert(self, dataset_identifier, payload, content_type="json"): ''' Insert, update or delete data to/from an existing dataset. Currently supports json and csv file objects. See here for the upsert documentation: http://dev.socrata.com/publishers/upsert.html ''' ...
['def', 'upsert', '(', 'self', ',', 'dataset_identifier', ',', 'payload', ',', 'content_type', '=', '"json"', ')', ':', 'resource', '=', '_format_new_api_request', '(', 'dataid', '=', 'dataset_identifier', ',', 'content_type', '=', 'content_type', ')', 'return', 'self', '.', '_perform_update', '(', '"post"', ',', 'reso...
Insert, update or delete data to/from an existing dataset. Currently supports json and csv file objects. See here for the upsert documentation: http://dev.socrata.com/publishers/upsert.html
['Insert', 'update', 'or', 'delete', 'data', 'to', '/', 'from', 'an', 'existing', 'dataset', '.', 'Currently', 'supports', 'json', 'and', 'csv', 'file', 'objects', '.', 'See', 'here', 'for', 'the', 'upsert', 'documentation', ':', 'http', ':', '//', 'dev', '.', 'socrata', '.', 'com', '/', 'publishers', '/', 'upsert', '....
train
https://github.com/xmunoz/sodapy/blob/dad2ca9560cde0acb03bdb4423260e891ca40d7b/sodapy/__init__.py#L365-L374
9,994
androguard/androguard
androguard/decompiler/dad/control_flow.py
derived_sequence
def derived_sequence(graph): """ Compute the derived sequence of the graph G The intervals of G are collapsed into nodes, intervals of these nodes are built, and the process is repeated iteratively until we obtain a single node (if the graph is not irreducible) """ deriv_seq = [graph] de...
python
def derived_sequence(graph): """ Compute the derived sequence of the graph G The intervals of G are collapsed into nodes, intervals of these nodes are built, and the process is repeated iteratively until we obtain a single node (if the graph is not irreducible) """ deriv_seq = [graph] de...
['def', 'derived_sequence', '(', 'graph', ')', ':', 'deriv_seq', '=', '[', 'graph', ']', 'deriv_interv', '=', '[', ']', 'single_node', '=', 'False', 'while', 'not', 'single_node', ':', 'interv_graph', ',', 'interv_heads', '=', 'intervals', '(', 'graph', ')', 'deriv_interv', '.', 'append', '(', 'interv_heads', ')', 'sin...
Compute the derived sequence of the graph G The intervals of G are collapsed into nodes, intervals of these nodes are built, and the process is repeated iteratively until we obtain a single node (if the graph is not irreducible)
['Compute', 'the', 'derived', 'sequence', 'of', 'the', 'graph', 'G', 'The', 'intervals', 'of', 'G', 'are', 'collapsed', 'into', 'nodes', 'intervals', 'of', 'these', 'nodes', 'are', 'built', 'and', 'the', 'process', 'is', 'repeated', 'iteratively', 'until', 'we', 'obtain', 'a', 'single', 'node', '(', 'if', 'the', 'graph...
train
https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/decompiler/dad/control_flow.py#L86-L109
9,995
croscon/fleaker
fleaker/config.py
MultiStageConfigurableApp.configure
def configure(self, *args, **kwargs): """Configure the Application through a varied number of sources of different types. This function chains multiple possible configuration methods together in order to just "make it work". You can pass multiple configuration sources in to the ...
python
def configure(self, *args, **kwargs): """Configure the Application through a varied number of sources of different types. This function chains multiple possible configuration methods together in order to just "make it work". You can pass multiple configuration sources in to the ...
['def', 'configure', '(', 'self', ',', '*', 'args', ',', '*', '*', 'kwargs', ')', ':', 'whitelist_keys_from_mappings', '=', 'kwargs', '.', 'get', '(', "'whitelist_keys_from_mappings'", ',', 'False', ')', 'whitelist', '=', 'kwargs', '.', 'get', '(', "'whitelist'", ')', 'for', 'item', 'in', 'args', ':', 'if', 'isinstance...
Configure the Application through a varied number of sources of different types. This function chains multiple possible configuration methods together in order to just "make it work". You can pass multiple configuration sources in to the method and each one will be tried in a sane fashi...
['Configure', 'the', 'Application', 'through', 'a', 'varied', 'number', 'of', 'sources', 'of', 'different', 'types', '.']
train
https://github.com/croscon/fleaker/blob/046b026b79c9912bceebb17114bc0c5d2d02e3c7/fleaker/config.py#L56-L156
9,996
rapidpro/expressions
python/temba_expressions/functions/excel.py
datedif
def datedif(ctx, start_date, end_date, unit): """ Calculates the number of days, months, or years between two dates. """ start_date = conversions.to_date(start_date, ctx) end_date = conversions.to_date(end_date, ctx) unit = conversions.to_string(unit, ctx).lower() if start_date > end_date: ...
python
def datedif(ctx, start_date, end_date, unit): """ Calculates the number of days, months, or years between two dates. """ start_date = conversions.to_date(start_date, ctx) end_date = conversions.to_date(end_date, ctx) unit = conversions.to_string(unit, ctx).lower() if start_date > end_date: ...
['def', 'datedif', '(', 'ctx', ',', 'start_date', ',', 'end_date', ',', 'unit', ')', ':', 'start_date', '=', 'conversions', '.', 'to_date', '(', 'start_date', ',', 'ctx', ')', 'end_date', '=', 'conversions', '.', 'to_date', '(', 'end_date', ',', 'ctx', ')', 'unit', '=', 'conversions', '.', 'to_string', '(', 'unit', ','...
Calculates the number of days, months, or years between two dates.
['Calculates', 'the', 'number', 'of', 'days', 'months', 'or', 'years', 'between', 'two', 'dates', '.']
train
https://github.com/rapidpro/expressions/blob/b03d91ec58fc328960bce90ecb5fa49dcf467627/python/temba_expressions/functions/excel.py#L164-L189
9,997
gagneurlab/concise
concise/utils/plot.py
add_letter_to_axis
def add_letter_to_axis(ax, let, col, x, y, height): """Add 'let' with position x,y and height height to matplotlib axis 'ax'. """ if len(let) == 2: colors = [col, "white"] elif len(let) == 1: colors = [col] else: raise ValueError("3 or more Polygons are not supported") f...
python
def add_letter_to_axis(ax, let, col, x, y, height): """Add 'let' with position x,y and height height to matplotlib axis 'ax'. """ if len(let) == 2: colors = [col, "white"] elif len(let) == 1: colors = [col] else: raise ValueError("3 or more Polygons are not supported") f...
['def', 'add_letter_to_axis', '(', 'ax', ',', 'let', ',', 'col', ',', 'x', ',', 'y', ',', 'height', ')', ':', 'if', 'len', '(', 'let', ')', '==', '2', ':', 'colors', '=', '[', 'col', ',', '"white"', ']', 'elif', 'len', '(', 'let', ')', '==', '1', ':', 'colors', '=', '[', 'col', ']', 'else', ':', 'raise', 'ValueError', ...
Add 'let' with position x,y and height height to matplotlib axis 'ax'.
['Add', 'let', 'with', 'position', 'x', 'y', 'and', 'height', 'height', 'to', 'matplotlib', 'axis', 'ax', '.']
train
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/utils/plot.py#L174-L192
9,998
jtwhite79/pyemu
pyemu/plot/plot_utils.py
res_phi_pie
def res_phi_pie(pst,logger=None, **kwargs): """plot current phi components as a pie chart. Parameters ---------- pst : pyemu.Pst logger : pyemu.Logger kwargs : dict accepts 'include_zero' as a flag to include phi groups with only zero-weight obs (not sure why anyone would do thi...
python
def res_phi_pie(pst,logger=None, **kwargs): """plot current phi components as a pie chart. Parameters ---------- pst : pyemu.Pst logger : pyemu.Logger kwargs : dict accepts 'include_zero' as a flag to include phi groups with only zero-weight obs (not sure why anyone would do thi...
['def', 'res_phi_pie', '(', 'pst', ',', 'logger', '=', 'None', ',', '*', '*', 'kwargs', ')', ':', 'if', 'logger', 'is', 'None', ':', 'logger', '=', 'Logger', '(', "'Default_Loggger.log'", ',', 'echo', '=', 'False', ')', 'logger', '.', 'log', '(', '"plot res_phi_pie"', ')', 'if', '"ensemble"', 'in', 'kwargs', ':', 'try'...
plot current phi components as a pie chart. Parameters ---------- pst : pyemu.Pst logger : pyemu.Logger kwargs : dict accepts 'include_zero' as a flag to include phi groups with only zero-weight obs (not sure why anyone would do this, but whatevs). Returns ------- ...
['plot', 'current', 'phi', 'components', 'as', 'a', 'pie', 'chart', '.']
train
https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/plot/plot_utils.py#L609-L660
9,999
inasafe/inasafe
safe/report/processors/default.py
atlas_renderer
def atlas_renderer(layout, coverage_layer, output_path, file_format): """Extract composition using atlas generation. :param layout: QGIS Print Layout object used for producing the report. :type layout: qgis.core.QgsPrintLayout :param coverage_layer: Coverage Layer used for atlas map. :type coverag...
python
def atlas_renderer(layout, coverage_layer, output_path, file_format): """Extract composition using atlas generation. :param layout: QGIS Print Layout object used for producing the report. :type layout: qgis.core.QgsPrintLayout :param coverage_layer: Coverage Layer used for atlas map. :type coverag...
['def', 'atlas_renderer', '(', 'layout', ',', 'coverage_layer', ',', 'output_path', ',', 'file_format', ')', ':', '# set the composer map to be atlas driven', 'composer_map', '=', 'layout_item', '(', 'layout', ',', "'impact-map'", ',', 'QgsLayoutItemMap', ')', 'composer_map', '.', 'setAtlasDriven', '(', 'True', ')', 'c...
Extract composition using atlas generation. :param layout: QGIS Print Layout object used for producing the report. :type layout: qgis.core.QgsPrintLayout :param coverage_layer: Coverage Layer used for atlas map. :type coverage_layer: QgsMapLayer :param output_path: The output path of the product....
['Extract', 'composition', 'using', 'atlas', 'generation', '.']
train
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/report/processors/default.py#L716-L781