repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
xeroc/python-graphenelib
graphenecommon/blockchain.py
https://github.com/xeroc/python-graphenelib/blob/8bb5396bc79998ee424cf3813af478304173f3a6/graphenecommon/blockchain.py#L224-L248
def stream(self, opNames=[], *args, **kwargs): """ Yield specific operations (e.g. comments) only :param array opNames: List of operations to filter for :param int start: Start at this block :param int stop: Stop at this block :param str mode: We here have the ch...
[ "def", "stream", "(", "self", ",", "opNames", "=", "[", "]", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "op", "in", "self", ".", "ops", "(", "*", "*", "kwargs", ")", ":", "if", "not", "opNames", "or", "op", "[", "\"op\"", "]"...
Yield specific operations (e.g. comments) only :param array opNames: List of operations to filter for :param int start: Start at this block :param int stop: Stop at this block :param str mode: We here have the choice between * "head": the last block ...
[ "Yield", "specific", "operations", "(", "e", ".", "g", ".", "comments", ")", "only" ]
python
valid
43.8
davenquinn/Attitude
attitude/display/hyperbola.py
https://github.com/davenquinn/Attitude/blob/2ce97b9aba0aa5deedc6617c2315e07e6396d240/attitude/display/hyperbola.py#L9-L31
def apparent_dip_correction(axes): """ Produces a two-dimensional rotation matrix that rotates a projected dataset to correct for apparent dip """ a1 = axes[0].copy() a1[-1] = 0 cosa = angle(axes[0],a1,cos=True) _ = 1-cosa**2 if _ > 1e-12: sina = N.sqrt(_) if cosa < 0...
[ "def", "apparent_dip_correction", "(", "axes", ")", ":", "a1", "=", "axes", "[", "0", "]", ".", "copy", "(", ")", "a1", "[", "-", "1", "]", "=", "0", "cosa", "=", "angle", "(", "axes", "[", "0", "]", ",", "a1", ",", "cos", "=", "True", ")", ...
Produces a two-dimensional rotation matrix that rotates a projected dataset to correct for apparent dip
[ "Produces", "a", "two", "-", "dimensional", "rotation", "matrix", "that", "rotates", "a", "projected", "dataset", "to", "correct", "for", "apparent", "dip" ]
python
train
26
yinkaisheng/Python-UIAutomation-for-Windows
uiautomation/uiautomation.py
https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/2cc91060982cc8b777152e698d677cc2989bf263/uiautomation/uiautomation.py#L1815-L1817
def keybd_event(bVk: int, bScan: int, dwFlags: int, dwExtraInfo: int) -> None: """keybd_event from Win32.""" ctypes.windll.user32.keybd_event(bVk, bScan, dwFlags, dwExtraInfo)
[ "def", "keybd_event", "(", "bVk", ":", "int", ",", "bScan", ":", "int", ",", "dwFlags", ":", "int", ",", "dwExtraInfo", ":", "int", ")", "->", "None", ":", "ctypes", ".", "windll", ".", "user32", ".", "keybd_event", "(", "bVk", ",", "bScan", ",", "...
keybd_event from Win32.
[ "keybd_event", "from", "Win32", "." ]
python
valid
60.333333
rueckstiess/mtools
mtools/util/logevent.py
https://github.com/rueckstiess/mtools/blob/a6a22910c3569c0c8a3908660ca218a4557e4249/mtools/util/logevent.py#L844-L940
def _parse_document(self): """Parse system.profile doc, copy all values to member variables.""" self._reset() doc = self._profile_doc self._split_tokens_calculated = True self._split_tokens = None self._duration_calculated = True self._duration = doc[u'millis']...
[ "def", "_parse_document", "(", "self", ")", ":", "self", ".", "_reset", "(", ")", "doc", "=", "self", ".", "_profile_doc", "self", ".", "_split_tokens_calculated", "=", "True", "self", ".", "_split_tokens", "=", "None", "self", ".", "_duration_calculated", "...
Parse system.profile doc, copy all values to member variables.
[ "Parse", "system", ".", "profile", "doc", "copy", "all", "values", "to", "member", "variables", "." ]
python
train
44.804124
kyper-data/python-highcharts
highcharts/highmaps/highmaps.py
https://github.com/kyper-data/python-highcharts/blob/a4c488ae5c2e125616efad5a722f3dfd8a9bc450/highcharts/highmaps/highmaps.py#L378-L397
def buildhtmlheader(self): """generate HTML header content""" #Highcharts lib/ needs to make sure it's up to date if self.drilldown_flag: self.add_JSsource('https://code.highcharts.com/maps/modules/drilldown.js') self.header_css = [ '<link href="%s" rel=...
[ "def", "buildhtmlheader", "(", "self", ")", ":", "#Highcharts lib/ needs to make sure it's up to date", "if", "self", ".", "drilldown_flag", ":", "self", ".", "add_JSsource", "(", "'https://code.highcharts.com/maps/modules/drilldown.js'", ")", "self", ".", "header_css", "="...
generate HTML header content
[ "generate", "HTML", "header", "content" ]
python
train
32.65
pgjones/quart
quart/app.py
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/app.py#L1228-L1230
async def open_session(self, request: BaseRequestWebsocket) -> Session: """Open and return a Session using the request.""" return await ensure_coroutine(self.session_interface.open_session)(self, request)
[ "async", "def", "open_session", "(", "self", ",", "request", ":", "BaseRequestWebsocket", ")", "->", "Session", ":", "return", "await", "ensure_coroutine", "(", "self", ".", "session_interface", ".", "open_session", ")", "(", "self", ",", "request", ")" ]
Open and return a Session using the request.
[ "Open", "and", "return", "a", "Session", "using", "the", "request", "." ]
python
train
72.666667
ofa/django-bouncy
django_bouncy/utils.py
https://github.com/ofa/django-bouncy/blob/a386dfa8c4ce59bd18978a3537c03cd6ad07bf06/django_bouncy/utils.py#L153-L161
def clean_time(time_string): """Return a datetime from the Amazon-provided datetime string""" # Get a timezone-aware datetime object from the string time = dateutil.parser.parse(time_string) if not settings.USE_TZ: # If timezone support is not active, convert the time to UTC and # remove...
[ "def", "clean_time", "(", "time_string", ")", ":", "# Get a timezone-aware datetime object from the string", "time", "=", "dateutil", ".", "parser", ".", "parse", "(", "time_string", ")", "if", "not", "settings", ".", "USE_TZ", ":", "# If timezone support is not active,...
Return a datetime from the Amazon-provided datetime string
[ "Return", "a", "datetime", "from", "the", "Amazon", "-", "provided", "datetime", "string" ]
python
train
45.888889
jaraco/jaraco.windows
jaraco/windows/filesystem/__init__.py
https://github.com/jaraco/jaraco.windows/blob/51811efed50b46ad08daa25408a1cc806bc8d519/jaraco/windows/filesystem/__init__.py#L485-L502
def SetFileAttributes(filepath, *attrs): """ Set file attributes. e.g.: SetFileAttributes('C:\\foo', 'hidden') Each attr must be either a numeric value, a constant defined in jaraco.windows.filesystem.api, or one of the nice names defined in this function. """ nice_names = collections.defaultdict( lambda k...
[ "def", "SetFileAttributes", "(", "filepath", ",", "*", "attrs", ")", ":", "nice_names", "=", "collections", ".", "defaultdict", "(", "lambda", "key", ":", "key", ",", "hidden", "=", "'FILE_ATTRIBUTE_HIDDEN'", ",", "read_only", "=", "'FILE_ATTRIBUTE_READONLY'", "...
Set file attributes. e.g.: SetFileAttributes('C:\\foo', 'hidden') Each attr must be either a numeric value, a constant defined in jaraco.windows.filesystem.api, or one of the nice names defined in this function.
[ "Set", "file", "attributes", ".", "e", ".", "g", ".", ":" ]
python
train
31.333333
datacats/datacats
datacats/environment.py
https://github.com/datacats/datacats/blob/e4bae503efa997660fb3f34fe166699569653157/datacats/environment.py#L611-L624
def _current_web_port(self): """ return just the port number for the web container, or None if not running """ info = inspect_container(self._get_container_name('web')) if info is None: return None try: if not info['State']['Running']: ...
[ "def", "_current_web_port", "(", "self", ")", ":", "info", "=", "inspect_container", "(", "self", ".", "_get_container_name", "(", "'web'", ")", ")", "if", "info", "is", "None", ":", "return", "None", "try", ":", "if", "not", "info", "[", "'State'", "]",...
return just the port number for the web container, or None if not running
[ "return", "just", "the", "port", "number", "for", "the", "web", "container", "or", "None", "if", "not", "running" ]
python
train
32.785714
pandas-dev/pandas
pandas/io/pytables.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/pytables.py#L1151-L1159
def get_storer(self, key): """ return the storer object for a key, raise if not in the file """ group = self.get_node(key) if group is None: raise KeyError('No object named {key} in the file'.format(key=key)) s = self._create_storer(group) s.infer_axes() retu...
[ "def", "get_storer", "(", "self", ",", "key", ")", ":", "group", "=", "self", ".", "get_node", "(", "key", ")", "if", "group", "is", "None", ":", "raise", "KeyError", "(", "'No object named {key} in the file'", ".", "format", "(", "key", "=", "key", ")",...
return the storer object for a key, raise if not in the file
[ "return", "the", "storer", "object", "for", "a", "key", "raise", "if", "not", "in", "the", "file" ]
python
train
35.111111
pywbem/pywbem
try/compat_args.py
https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/try/compat_args.py#L93-L108
def main(): """Main function calls the test functs""" print("Python version %s" % sys.version) print("Testing compatibility for function defined with *args") test_func_args(func_old_args) test_func_args(func_new) print("Testing compatibility for function defined with **kwargs") test_func_...
[ "def", "main", "(", ")", ":", "print", "(", "\"Python version %s\"", "%", "sys", ".", "version", ")", "print", "(", "\"Testing compatibility for function defined with *args\"", ")", "test_func_args", "(", "func_old_args", ")", "test_func_args", "(", "func_new", ")", ...
Main function calls the test functs
[ "Main", "function", "calls", "the", "test", "functs" ]
python
train
29.5
reingart/pyafipws
wslpg.py
https://github.com/reingart/pyafipws/blob/ee87cfe4ac12285ab431df5fec257f103042d1ab/wslpg.py#L2727-L2739
def CrearPlantillaPDF(self, papel="A4", orientacion="portrait"): "Iniciar la creación del archivo PDF" # genero el renderizador con propiedades del PDF t = Template( format=papel, orientation=orientacion, title="F 1116 B/C %s" % (self.NroOrden), ...
[ "def", "CrearPlantillaPDF", "(", "self", ",", "papel", "=", "\"A4\"", ",", "orientacion", "=", "\"portrait\"", ")", ":", "# genero el renderizador con propiedades del PDF", "t", "=", "Template", "(", "format", "=", "papel", ",", "orientation", "=", "orientacion", ...
Iniciar la creación del archivo PDF
[ "Iniciar", "la", "creación", "del", "archivo", "PDF" ]
python
train
47.615385
opendatateam/udata
udata/frontend/csv.py
https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/frontend/csv.py#L30-L37
def safestr(value): '''Ensure type to string serialization''' if not value or isinstance(value, (int, float, bool, long)): return value elif isinstance(value, (date, datetime)): return value.isoformat() else: return unicode(value)
[ "def", "safestr", "(", "value", ")", ":", "if", "not", "value", "or", "isinstance", "(", "value", ",", "(", "int", ",", "float", ",", "bool", ",", "long", ")", ")", ":", "return", "value", "elif", "isinstance", "(", "value", ",", "(", "date", ",", ...
Ensure type to string serialization
[ "Ensure", "type", "to", "string", "serialization" ]
python
train
32.875
mitsei/dlkit
dlkit/json_/commenting/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/commenting/sessions.py#L951-L999
def get_comment_form_for_create(self, reference_id, comment_record_types): """Gets the comment form for creating new comments. A new form should be requested for each create transaction. arg: reference_id (osid.id.Id): the ``Id`` for the reference object arg: comm...
[ "def", "get_comment_form_for_create", "(", "self", ",", "reference_id", ",", "comment_record_types", ")", ":", "# Implemented from template for", "# osid.relationship.CommentAdminSession.get_comment_form_for_create_template", "# These really need to be in module imports:", "if", "not", ...
Gets the comment form for creating new comments. A new form should be requested for each create transaction. arg: reference_id (osid.id.Id): the ``Id`` for the reference object arg: comment_record_types (osid.type.Type[]): array of comment record types ...
[ "Gets", "the", "comment", "form", "for", "creating", "new", "comments", "." ]
python
train
48.183673
sunt05/SuPy
docs/source/proc_var_info/gen_df_forcing_output_csv.py
https://github.com/sunt05/SuPy/blob/47178bd5aee50a059414e3e504940662fbfae0dc/docs/source/proc_var_info/gen_df_forcing_output_csv.py#L38-L76
def gen_df_forcing( path_csv_in='SSss_YYYY_data_tt.csv', url_base=url_repo_input,)->pd.DataFrame: '''Generate description info of supy forcing data into a dataframe Parameters ---------- path_csv_in : str, optional path to the input csv file relative to url_base (the default is ...
[ "def", "gen_df_forcing", "(", "path_csv_in", "=", "'SSss_YYYY_data_tt.csv'", ",", "url_base", "=", "url_repo_input", ",", ")", "->", "pd", ".", "DataFrame", ":", "try", ":", "# load info from SUEWS docs repo", "# this is regarded as the official source", "urlpath_table", ...
Generate description info of supy forcing data into a dataframe Parameters ---------- path_csv_in : str, optional path to the input csv file relative to url_base (the default is '/input_files/SSss_YYYY_data_tt.csv']) url_base : urlpath.URL, optional URL to the input files of repo base (...
[ "Generate", "description", "info", "of", "supy", "forcing", "data", "into", "a", "dataframe" ]
python
train
32.846154
openatx/facebook-wda
wda/__init__.py
https://github.com/openatx/facebook-wda/blob/aa644204620c6d5c7705a9c7452d8c0cc39330d5/wda/__init__.py#L519-L528
def window_size(self): """ Returns: namedtuple: eg Size(width=320, height=568) """ value = self.http.get('/window/size').value w = roundint(value['width']) h = roundint(value['height']) return namedtuple('Size', ['width', 'height'])(w, ...
[ "def", "window_size", "(", "self", ")", ":", "value", "=", "self", ".", "http", ".", "get", "(", "'/window/size'", ")", ".", "value", "w", "=", "roundint", "(", "value", "[", "'width'", "]", ")", "h", "=", "roundint", "(", "value", "[", "'height'", ...
Returns: namedtuple: eg Size(width=320, height=568)
[ "Returns", ":", "namedtuple", ":", "eg", "Size", "(", "width", "=", "320", "height", "=", "568", ")" ]
python
train
31.3
boriel/zxbasic
zxbparser.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/zxbparser.py#L800-L816
def p_const_vector_elem_list(p): """ const_number_list : expr """ if p[1] is None: return if not is_static(p[1]): if isinstance(p[1], symbols.UNARY): tmp = make_constexpr(p.lineno(1), p[1]) else: api.errmsg.syntax_error_not_constant(p.lexer.lineno) ...
[ "def", "p_const_vector_elem_list", "(", "p", ")", ":", "if", "p", "[", "1", "]", "is", "None", ":", "return", "if", "not", "is_static", "(", "p", "[", "1", "]", ")", ":", "if", "isinstance", "(", "p", "[", "1", "]", ",", "symbols", ".", "UNARY", ...
const_number_list : expr
[ "const_number_list", ":", "expr" ]
python
train
22.764706
lanpa/tensorboardX
examples/chainer/plain_logger/net.py
https://github.com/lanpa/tensorboardX/blob/0bf6c07d97b0745654fd9fab8ee3261ec707f253/examples/chainer/plain_logger/net.py#L41-L65
def get_loss_func(self, C=1.0, k=1): """Get loss function of VAE. The loss value is equal to ELBO (Evidence Lower Bound) multiplied by -1. Args: C (int): Usually this is 1.0. Can be changed to control the second term of ELBO bound, which works as regularizat...
[ "def", "get_loss_func", "(", "self", ",", "C", "=", "1.0", ",", "k", "=", "1", ")", ":", "def", "lf", "(", "x", ")", ":", "mu", ",", "ln_var", "=", "self", ".", "encode", "(", "x", ")", "batchsize", "=", "len", "(", "mu", ".", "data", ")", ...
Get loss function of VAE. The loss value is equal to ELBO (Evidence Lower Bound) multiplied by -1. Args: C (int): Usually this is 1.0. Can be changed to control the second term of ELBO bound, which works as regularization. k (int): Number of Monte Carlo ...
[ "Get", "loss", "function", "of", "VAE", "." ]
python
train
37.48
changhiskhan/poseidon
poseidon/api.py
https://github.com/changhiskhan/poseidon/blob/6d1cecbe02f1e510dd185fe23f88f7af35eb737f/poseidon/api.py#L156-L165
def send_request(self, kind, url_components, **kwargs): """ Send a request for this resource to the API Parameters ---------- kind: str, {'get', 'delete', 'put', 'post', 'head'} """ return self.api.send_request(kind, self.resource_path, url_components, ...
[ "def", "send_request", "(", "self", ",", "kind", ",", "url_components", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "api", ".", "send_request", "(", "kind", ",", "self", ".", "resource_path", ",", "url_components", ",", "*", "*", "kwargs", ...
Send a request for this resource to the API Parameters ---------- kind: str, {'get', 'delete', 'put', 'post', 'head'}
[ "Send", "a", "request", "for", "this", "resource", "to", "the", "API" ]
python
valid
34.7
arve0/leicascanningtemplate
leicascanningtemplate/template.py
https://github.com/arve0/leicascanningtemplate/blob/053e075d3bed11e335b61ce048c47067b8e9e921/leicascanningtemplate/template.py#L78-L94
def well(self, well_x=1, well_y=1): """ScanWellData of specific well. Parameters ---------- well_x : int well_y : int Returns ------- lxml.objectify.ObjectifiedElement """ xpath = './ScanWellData' xpath += _xpath_attrib('WellX', w...
[ "def", "well", "(", "self", ",", "well_x", "=", "1", ",", "well_y", "=", "1", ")", ":", "xpath", "=", "'./ScanWellData'", "xpath", "+=", "_xpath_attrib", "(", "'WellX'", ",", "well_x", ")", "xpath", "+=", "_xpath_attrib", "(", "'WellY'", ",", "well_y", ...
ScanWellData of specific well. Parameters ---------- well_x : int well_y : int Returns ------- lxml.objectify.ObjectifiedElement
[ "ScanWellData", "of", "specific", "well", "." ]
python
train
25.588235
jsommers/switchyard
switchyard/llnetreal.py
https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/llnetreal.py#L176-L194
def _low_level_dispatch(pcapdev, devname, pktqueue): ''' Thread entrypoint for doing low-level receive and dispatch for a single pcap device. ''' while LLNetReal.running: # a non-zero timeout value is ok here; this is an # independent thread that handles i...
[ "def", "_low_level_dispatch", "(", "pcapdev", ",", "devname", ",", "pktqueue", ")", ":", "while", "LLNetReal", ".", "running", ":", "# a non-zero timeout value is ok here; this is an", "# independent thread that handles input for this", "# one pcap device. it throws any packets re...
Thread entrypoint for doing low-level receive and dispatch for a single pcap device.
[ "Thread", "entrypoint", "for", "doing", "low", "-", "level", "receive", "and", "dispatch", "for", "a", "single", "pcap", "device", "." ]
python
train
46.842105
LuminosoInsight/python-ftfy
ftfy/fixes.py
https://github.com/LuminosoInsight/python-ftfy/blob/476acc6ad270bffe07f97d4f7cf2139acdc69633/ftfy/fixes.py#L133-L158
def fix_encoding_and_explain(text): """ Re-decodes text that has been decoded incorrectly, and also return a "plan" indicating all the steps required to fix it. The resulting plan could be used with :func:`ftfy.fixes.apply_plan` to fix additional strings that are broken in the same way. """ ...
[ "def", "fix_encoding_and_explain", "(", "text", ")", ":", "best_version", "=", "text", "best_cost", "=", "text_cost", "(", "text", ")", "best_plan", "=", "[", "]", "plan_so_far", "=", "[", "]", "while", "True", ":", "prevtext", "=", "text", "text", ",", ...
Re-decodes text that has been decoded incorrectly, and also return a "plan" indicating all the steps required to fix it. The resulting plan could be used with :func:`ftfy.fixes.apply_plan` to fix additional strings that are broken in the same way.
[ "Re", "-", "decodes", "text", "that", "has", "been", "decoded", "incorrectly", "and", "also", "return", "a", "plan", "indicating", "all", "the", "steps", "required", "to", "fix", "it", "." ]
python
train
31.615385
PMEAL/OpenPNM
openpnm/models/physics/capillary_pressure.py
https://github.com/PMEAL/OpenPNM/blob/0547b5724ffedc0a593aae48639d36fe10e0baed/openpnm/models/physics/capillary_pressure.py#L44-L93
def washburn(target, surface_tension='pore.surface_tension', contact_angle='pore.contact_angle', diameter='throat.diameter'): r""" Computes the capillary entry pressure assuming the throat in a cylindrical tube. Parameters ---------- target : OpenPNM Object The...
[ "def", "washburn", "(", "target", ",", "surface_tension", "=", "'pore.surface_tension'", ",", "contact_angle", "=", "'pore.contact_angle'", ",", "diameter", "=", "'throat.diameter'", ")", ":", "network", "=", "target", ".", "project", ".", "network", "phase", "=",...
r""" Computes the capillary entry pressure assuming the throat in a cylindrical tube. Parameters ---------- target : OpenPNM Object The object for which these values are being calculated. This controls the length of the calculated array, and also provides access to other ne...
[ "r", "Computes", "the", "capillary", "entry", "pressure", "assuming", "the", "throat", "in", "a", "cylindrical", "tube", "." ]
python
train
36.48
fboender/ansible-cmdb
src/ansiblecmdb/parser.py
https://github.com/fboender/ansible-cmdb/blob/ebd960ac10684e8c9ec2b12751bba2c4c9504ab7/src/ansiblecmdb/parser.py#L282-L299
def _group_get_hostnames(self, group_name): """ Recursively fetch a list of each unique hostname that belongs in or under the group. This includes hosts in children groups. """ hostnames = [] hosts_section = self._get_section(group_name, 'hosts') if hosts_section...
[ "def", "_group_get_hostnames", "(", "self", ",", "group_name", ")", ":", "hostnames", "=", "[", "]", "hosts_section", "=", "self", ".", "_get_section", "(", "group_name", ",", "'hosts'", ")", "if", "hosts_section", ":", "for", "entry", "in", "hosts_section", ...
Recursively fetch a list of each unique hostname that belongs in or under the group. This includes hosts in children groups.
[ "Recursively", "fetch", "a", "list", "of", "each", "unique", "hostname", "that", "belongs", "in", "or", "under", "the", "group", ".", "This", "includes", "hosts", "in", "children", "groups", "." ]
python
train
37.666667
belbio/bel
bel/nanopub/belscripts.py
https://github.com/belbio/bel/blob/60333e8815625b942b4836903f3b618cf44b3771/bel/nanopub/belscripts.py#L266-L288
def preprocess_belscript(lines): """ Convert any multi-line SET statements into single line SET statements""" set_flag = False for line in lines: if set_flag is False and re.match("SET", line): set_flag = True set_line = [line.rstrip()] # SET following SET el...
[ "def", "preprocess_belscript", "(", "lines", ")", ":", "set_flag", "=", "False", "for", "line", "in", "lines", ":", "if", "set_flag", "is", "False", "and", "re", ".", "match", "(", "\"SET\"", ",", "line", ")", ":", "set_flag", "=", "True", "set_line", ...
Convert any multi-line SET statements into single line SET statements
[ "Convert", "any", "multi", "-", "line", "SET", "statements", "into", "single", "line", "SET", "statements" ]
python
train
33.73913
JDongian/python-jamo
jamo/jamo.py
https://github.com/JDongian/python-jamo/blob/d087a9f5f52f066fb933ad1da8e9915703374c9a/jamo/jamo.py#L168-L188
def get_jamo_class(jamo): """Determine if a jamo character is a lead, vowel, or tail. Integers and U+11xx characters are valid arguments. HCJ consonants are not valid here. get_jamo_class should return the class ["lead" | "vowel" | "tail"] of a given character or integer. Note: jamo class dire...
[ "def", "get_jamo_class", "(", "jamo", ")", ":", "# TODO: Perhaps raise a separate error for U+3xxx jamo.", "if", "jamo", "in", "JAMO_LEADS", "or", "jamo", "==", "chr", "(", "0x115F", ")", ":", "return", "\"lead\"", "if", "jamo", "in", "JAMO_VOWELS", "or", "jamo", ...
Determine if a jamo character is a lead, vowel, or tail. Integers and U+11xx characters are valid arguments. HCJ consonants are not valid here. get_jamo_class should return the class ["lead" | "vowel" | "tail"] of a given character or integer. Note: jamo class directly corresponds to the Unicode 7...
[ "Determine", "if", "a", "jamo", "character", "is", "a", "lead", "vowel", "or", "tail", ".", "Integers", "and", "U", "+", "11xx", "characters", "are", "valid", "arguments", ".", "HCJ", "consonants", "are", "not", "valid", "here", "." ]
python
train
38.095238
amigocloud/python-amigocloud
amigocloud/amigocloud.py
https://github.com/amigocloud/python-amigocloud/blob/d31403e7299cc46e3a3e1392090ee033f3a02b6d/amigocloud/amigocloud.py#L223-L284
def upload_file(self, simple_upload_url, chunked_upload_url, file_obj, chunk_size=CHUNK_SIZE, force_chunked=False, extra_data=None): """ Generic method to upload files to AmigoCloud. Can be used for different API endpoints. `file_obj` could be a fi...
[ "def", "upload_file", "(", "self", ",", "simple_upload_url", ",", "chunked_upload_url", ",", "file_obj", ",", "chunk_size", "=", "CHUNK_SIZE", ",", "force_chunked", "=", "False", ",", "extra_data", "=", "None", ")", ":", "if", "isinstance", "(", "file_obj", ",...
Generic method to upload files to AmigoCloud. Can be used for different API endpoints. `file_obj` could be a file-like object or a filepath. If the size of the file is greater than MAX_SIZE_SIMPLE_UPLOAD (8MB) `chunked_upload_url` will be used, otherwise `simple_upload_url` will ...
[ "Generic", "method", "to", "upload", "files", "to", "AmigoCloud", ".", "Can", "be", "used", "for", "different", "API", "endpoints", ".", "file_obj", "could", "be", "a", "file", "-", "like", "object", "or", "a", "filepath", ".", "If", "the", "size", "of",...
python
train
42.145161
csparpa/pyowm
pyowm/weatherapi25/owm25.py
https://github.com/csparpa/pyowm/blob/cdd59eb72f32f7238624ceef9b2e2329a5ebd472/pyowm/weatherapi25/owm25.py#L682-L724
def daily_forecast_at_coords(self, lat, lon, limit=None): """ Queries the OWM Weather API for daily weather forecast for the specified geographic coordinate (eg: latitude: 51.5073509, longitude: -0.1277583). A *Forecaster* object is returned, containing a *Forecast* instance cove...
[ "def", "daily_forecast_at_coords", "(", "self", ",", "lat", ",", "lon", ",", "limit", "=", "None", ")", ":", "geo", ".", "assert_is_lon", "(", "lon", ")", "geo", ".", "assert_is_lat", "(", "lat", ")", "if", "limit", "is", "not", "None", ":", "assert", ...
Queries the OWM Weather API for daily weather forecast for the specified geographic coordinate (eg: latitude: 51.5073509, longitude: -0.1277583). A *Forecaster* object is returned, containing a *Forecast* instance covering a global streak of fourteen days by default: this instance encaps...
[ "Queries", "the", "OWM", "Weather", "API", "for", "daily", "weather", "forecast", "for", "the", "specified", "geographic", "coordinate", "(", "eg", ":", "latitude", ":", "51", ".", "5073509", "longitude", ":", "-", "0", ".", "1277583", ")", ".", "A", "*"...
python
train
50.767442
pyQode/pyqode.core
pyqode/core/modes/extended_selection.py
https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/modes/extended_selection.py#L131-L139
def perform_extended_selection(self, event=None): """ Performs extended word selection. :param event: QMouseEvent """ TextHelper(self.editor).select_extended_word( continuation_chars=self.continuation_characters) if event: event.accept()
[ "def", "perform_extended_selection", "(", "self", ",", "event", "=", "None", ")", ":", "TextHelper", "(", "self", ".", "editor", ")", ".", "select_extended_word", "(", "continuation_chars", "=", "self", ".", "continuation_characters", ")", "if", "event", ":", ...
Performs extended word selection. :param event: QMouseEvent
[ "Performs", "extended", "word", "selection", ".", ":", "param", "event", ":", "QMouseEvent" ]
python
train
33.444444
PyHDI/Pyverilog
pyverilog/vparser/parser.py
https://github.com/PyHDI/Pyverilog/blob/b852cc5ed6a7a2712e33639f9d9782d0d1587a53/pyverilog/vparser/parser.py#L1438-L1442
def p_delays_floatnumber(self, p): 'delays : DELAY floatnumber' p[0] = DelayStatement(FloatConst( p[2], lineno=p.lineno(1)), lineno=p.lineno(1)) p.set_lineno(0, p.lineno(1))
[ "def", "p_delays_floatnumber", "(", "self", ",", "p", ")", ":", "p", "[", "0", "]", "=", "DelayStatement", "(", "FloatConst", "(", "p", "[", "2", "]", ",", "lineno", "=", "p", ".", "lineno", "(", "1", ")", ")", ",", "lineno", "=", "p", ".", "li...
delays : DELAY floatnumber
[ "delays", ":", "DELAY", "floatnumber" ]
python
train
41
IBMStreams/pypi.streamsx
streamsx/topology/dependency.py
https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/dependency.py#L252-L267
def _is_builtin_module(module): """Is builtin or part of standard library """ if (not hasattr(module, '__file__')) or module.__name__ in sys.builtin_module_names: return True if module.__name__ in _stdlib._STD_LIB_MODULES: return True amp = os.path.abspath(module.__file__) if 's...
[ "def", "_is_builtin_module", "(", "module", ")", ":", "if", "(", "not", "hasattr", "(", "module", ",", "'__file__'", ")", ")", "or", "module", ".", "__name__", "in", "sys", ".", "builtin_module_names", ":", "return", "True", "if", "module", ".", "__name__"...
Is builtin or part of standard library
[ "Is", "builtin", "or", "part", "of", "standard", "library" ]
python
train
34.5
openpermissions/perch
perch/views.py
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/views.py#L294-L306
def services(doc): """View for getting services""" for service_id, service in doc.get('services', {}).items(): service_type = service.get('service_type') org = doc['_id'] service['id'] = service_id service['organisation_id'] = org yield service_id, service yield ...
[ "def", "services", "(", "doc", ")", ":", "for", "service_id", ",", "service", "in", "doc", ".", "get", "(", "'services'", ",", "{", "}", ")", ".", "items", "(", ")", ":", "service_type", "=", "service", ".", "get", "(", "'service_type'", ")", "org", ...
View for getting services
[ "View", "for", "getting", "services" ]
python
train
34.692308
gem/oq-engine
openquake/commonlib/readinput.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L1388-L1415
def get_checksum32(oqparam, hazard=False): """ Build an unsigned 32 bit integer from the input files of a calculation. :param oqparam: an OqParam instance :param hazard: if True, consider only the hazard files :returns: the checkume """ # NB: using adler32 & 0xffffffff is the documented way...
[ "def", "get_checksum32", "(", "oqparam", ",", "hazard", "=", "False", ")", ":", "# NB: using adler32 & 0xffffffff is the documented way to get a checksum", "# which is the same between Python 2 and Python 3", "checksum", "=", "0", "for", "fname", "in", "get_input_files", "(", ...
Build an unsigned 32 bit integer from the input files of a calculation. :param oqparam: an OqParam instance :param hazard: if True, consider only the hazard files :returns: the checkume
[ "Build", "an", "unsigned", "32", "bit", "integer", "from", "the", "input", "files", "of", "a", "calculation", "." ]
python
train
46.607143
rtfd/recommonmark
recommonmark/transform.py
https://github.com/rtfd/recommonmark/blob/815d75ea503f30af26ab67c6820078f84875b1fc/recommonmark/transform.py#L285-L309
def traverse(self, node): """Traverse the document tree rooted at node. node : docutil node current root node to traverse """ old_level = self.current_level if isinstance(node, nodes.section): if 'level' in node: self.current_level = node[...
[ "def", "traverse", "(", "self", ",", "node", ")", ":", "old_level", "=", "self", ".", "current_level", "if", "isinstance", "(", "node", ",", "nodes", ".", "section", ")", ":", "if", "'level'", "in", "node", ":", "self", ".", "current_level", "=", "node...
Traverse the document tree rooted at node. node : docutil node current root node to traverse
[ "Traverse", "the", "document", "tree", "rooted", "at", "node", "." ]
python
train
30.36
tornadoweb/tornado
tornado/locale.py
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/locale.py#L236-L251
def get_closest(cls, *locale_codes: str) -> "Locale": """Returns the closest match for the given locale code.""" for code in locale_codes: if not code: continue code = code.replace("-", "_") parts = code.split("_") if len(parts) > 2: ...
[ "def", "get_closest", "(", "cls", ",", "*", "locale_codes", ":", "str", ")", "->", "\"Locale\"", ":", "for", "code", "in", "locale_codes", ":", "if", "not", "code", ":", "continue", "code", "=", "code", ".", "replace", "(", "\"-\"", ",", "\"_\"", ")", ...
Returns the closest match for the given locale code.
[ "Returns", "the", "closest", "match", "for", "the", "given", "locale", "code", "." ]
python
train
40.375
google/grr
grr/client/grr_response_client/client_utils_osx.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/client_utils_osx.py#L174-L186
def ParseFileSystemsStruct(struct_class, fs_count, data): """Take the struct type and parse it into a list of structs.""" results = [] cstr = lambda x: x.split(b"\x00", 1)[0] for count in range(0, fs_count): struct_size = struct_class.GetSize() s_data = data[count * struct_size:(count + 1) * struct_size...
[ "def", "ParseFileSystemsStruct", "(", "struct_class", ",", "fs_count", ",", "data", ")", ":", "results", "=", "[", "]", "cstr", "=", "lambda", "x", ":", "x", ".", "split", "(", "b\"\\x00\"", ",", "1", ")", "[", "0", "]", "for", "count", "in", "range"...
Take the struct type and parse it into a list of structs.
[ "Take", "the", "struct", "type", "and", "parse", "it", "into", "a", "list", "of", "structs", "." ]
python
train
38.692308
JelteF/PyLaTeX
pylatex/math.py
https://github.com/JelteF/PyLaTeX/blob/62d9d9912ce8445e6629cdbcb80ad86143a1ed23/pylatex/math.py#L133-L156
def dumps_content(self): """Return a string representing the matrix in LaTeX syntax. Returns ------- str """ import numpy as np string = '' shape = self.matrix.shape for (y, x), value in np.ndenumerate(self.matrix): if x: ...
[ "def", "dumps_content", "(", "self", ")", ":", "import", "numpy", "as", "np", "string", "=", "''", "shape", "=", "self", ".", "matrix", ".", "shape", "for", "(", "y", ",", "x", ")", ",", "value", "in", "np", ".", "ndenumerate", "(", "self", ".", ...
Return a string representing the matrix in LaTeX syntax. Returns ------- str
[ "Return", "a", "string", "representing", "the", "matrix", "in", "LaTeX", "syntax", "." ]
python
train
20.916667
eventable/vobject
docs/build/lib/vobject/ics_diff.py
https://github.com/eventable/vobject/blob/498555a553155ea9b26aace93332ae79365ecb31/docs/build/lib/vobject/ics_diff.py#L47-L171
def diff(left, right): """ Take two VCALENDAR components, compare VEVENTs and VTODOs in them, return a list of object pairs containing just UID and the bits that didn't match, using None for objects that weren't present in one version or the other. When there are multiple ContentLines in one VE...
[ "def", "diff", "(", "left", ",", "right", ")", ":", "def", "processComponentLists", "(", "leftList", ",", "rightList", ")", ":", "output", "=", "[", "]", "rightIndex", "=", "0", "rightListSize", "=", "len", "(", "rightList", ")", "for", "comp", "in", "...
Take two VCALENDAR components, compare VEVENTs and VTODOs in them, return a list of object pairs containing just UID and the bits that didn't match, using None for objects that weren't present in one version or the other. When there are multiple ContentLines in one VEVENT, for instance many DESCRIP...
[ "Take", "two", "VCALENDAR", "components", "compare", "VEVENTs", "and", "VTODOs", "in", "them", "return", "a", "list", "of", "object", "pairs", "containing", "just", "UID", "and", "the", "bits", "that", "didn", "t", "match", "using", "None", "for", "objects",...
python
train
38.488
sirfoga/pyhal
hal/help.py
https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/help.py#L20-L36
def get_platform_info(): """Gets platform info :return: platform info """ try: system_name = platform.system() release_name = platform.release() except: system_name = "Unknown" release_name = "Unknown" return { ...
[ "def", "get_platform_info", "(", ")", ":", "try", ":", "system_name", "=", "platform", ".", "system", "(", ")", "release_name", "=", "platform", ".", "release", "(", ")", "except", ":", "system_name", "=", "\"Unknown\"", "release_name", "=", "\"Unknown\"", "...
Gets platform info :return: platform info
[ "Gets", "platform", "info" ]
python
train
22.058824
djgagne/hagelslag
hagelslag/evaluation/ProbabilityMetrics.py
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/evaluation/ProbabilityMetrics.py#L340-L350
def merge(self, other_rel): """ Ingest another DistributedReliability and add its contents to the current object. Args: other_rel: a Distributed reliability object. """ if other_rel.thresholds.size == self.thresholds.size and np.all(other_rel.thresholds == self.thres...
[ "def", "merge", "(", "self", ",", "other_rel", ")", ":", "if", "other_rel", ".", "thresholds", ".", "size", "==", "self", ".", "thresholds", ".", "size", "and", "np", ".", "all", "(", "other_rel", ".", "thresholds", "==", "self", ".", "thresholds", ")"...
Ingest another DistributedReliability and add its contents to the current object. Args: other_rel: a Distributed reliability object.
[ "Ingest", "another", "DistributedReliability", "and", "add", "its", "contents", "to", "the", "current", "object", "." ]
python
train
40.272727
theiviaxx/Frog
frog/views/comment.py
https://github.com/theiviaxx/Frog/blob/a9475463a8eed1323fe3ef5d51f9751fb1dc9edd/frog/views/comment.py#L146-L169
def emailComment(comment, obj, request): """Send an email to the author about a new comment""" if not obj.author.frog_prefs.get().json()['emailComments']: return if obj.author == request.user: return html = render_to_string('frog/comment_email.html', { 'user': comment.user, ...
[ "def", "emailComment", "(", "comment", ",", "obj", ",", "request", ")", ":", "if", "not", "obj", ".", "author", ".", "frog_prefs", ".", "get", "(", ")", ".", "json", "(", ")", "[", "'emailComments'", "]", ":", "return", "if", "obj", ".", "author", ...
Send an email to the author about a new comment
[ "Send", "an", "email", "to", "the", "author", "about", "a", "new", "comment" ]
python
train
32.5
Toilal/rebulk
rebulk/match.py
https://github.com/Toilal/rebulk/blob/7511a4671f2fd9493e3df1e5177b7656789069e8/rebulk/match.py#L363-L377
def _hole_end(self, position, ignore=None): """ Retrieves the end of hole index from position. :param position: :type position: :param ignore: :type ignore: :return: :rtype: """ for rindex in range(position, self.max_end): for s...
[ "def", "_hole_end", "(", "self", ",", "position", ",", "ignore", "=", "None", ")", ":", "for", "rindex", "in", "range", "(", "position", ",", "self", ".", "max_end", ")", ":", "for", "starting", "in", "self", ".", "starting", "(", "rindex", ")", ":",...
Retrieves the end of hole index from position. :param position: :type position: :param ignore: :type ignore: :return: :rtype:
[ "Retrieves", "the", "end", "of", "hole", "index", "from", "position", ".", ":", "param", "position", ":", ":", "type", "position", ":", ":", "param", "ignore", ":", ":", "type", "ignore", ":", ":", "return", ":", ":", "rtype", ":" ]
python
train
30.4
gears/gears
gears/asset_handler.py
https://github.com/gears/gears/blob/5729c2525a8c04c185e998bd9a86233708972921/gears/asset_handler.py#L55-L64
def run(self, input): """Runs :attr:`executable` with ``input`` as stdin. :class:`AssetHandlerError` exception is raised, if execution is failed, otherwise stdout is returned. """ p = self.get_process() output, errors = p.communicate(input=input.encode('utf-8')) i...
[ "def", "run", "(", "self", ",", "input", ")", ":", "p", "=", "self", ".", "get_process", "(", ")", "output", ",", "errors", "=", "p", ".", "communicate", "(", "input", "=", "input", ".", "encode", "(", "'utf-8'", ")", ")", "if", "p", ".", "return...
Runs :attr:`executable` with ``input`` as stdin. :class:`AssetHandlerError` exception is raised, if execution is failed, otherwise stdout is returned.
[ "Runs", ":", "attr", ":", "executable", "with", "input", "as", "stdin", ".", ":", "class", ":", "AssetHandlerError", "exception", "is", "raised", "if", "execution", "is", "failed", "otherwise", "stdout", "is", "returned", "." ]
python
test
41.3
blockstack/blockstack-core
blockstack/lib/operations/namespacepreorder.py
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/operations/namespacepreorder.py#L53-L134
def check( state_engine, nameop, block_id, checked_ops ): """ Given a NAMESPACE_PREORDER nameop, see if we can preorder it. It must be unqiue. Return True if accepted. Return False if not. """ namespace_id_hash = nameop['preorder_hash'] consensus_hash = nameop['consensus_hash'] tok...
[ "def", "check", "(", "state_engine", ",", "nameop", ",", "block_id", ",", "checked_ops", ")", ":", "namespace_id_hash", "=", "nameop", "[", "'preorder_hash'", "]", "consensus_hash", "=", "nameop", "[", "'consensus_hash'", "]", "token_fee", "=", "nameop", "[", ...
Given a NAMESPACE_PREORDER nameop, see if we can preorder it. It must be unqiue. Return True if accepted. Return False if not.
[ "Given", "a", "NAMESPACE_PREORDER", "nameop", "see", "if", "we", "can", "preorder", "it", ".", "It", "must", "be", "unqiue", "." ]
python
train
39.426829
stevearc/dql
dql/cli.py
https://github.com/stevearc/dql/blob/e9d3aa22873076dae5ebd02e35318aa996b1e56a/dql/cli.py#L336-L340
def opt_pagesize(self, pagesize): """ Get or set the page size of the query output """ if pagesize != "auto": pagesize = int(pagesize) self.conf["pagesize"] = pagesize
[ "def", "opt_pagesize", "(", "self", ",", "pagesize", ")", ":", "if", "pagesize", "!=", "\"auto\"", ":", "pagesize", "=", "int", "(", "pagesize", ")", "self", ".", "conf", "[", "\"pagesize\"", "]", "=", "pagesize" ]
Get or set the page size of the query output
[ "Get", "or", "set", "the", "page", "size", "of", "the", "query", "output" ]
python
train
39.8
htm-community/menorah
menorah/menorah.py
https://github.com/htm-community/menorah/blob/1991b01eda3f6361b22ed165b4a688ae3fb2deaf/menorah/menorah.py#L195-L210
def swarm(self, predictedField=None, swarmParams=None): """ Runs a swarm on data and swarm description found within the given working directory. If no predictedField is provided, it is assumed that the first stream listed in the streamIds provided to the Menorah constructor is the predicted fi...
[ "def", "swarm", "(", "self", ",", "predictedField", "=", "None", ",", "swarmParams", "=", "None", ")", ":", "self", ".", "prepareSwarm", "(", "predictedField", "=", "predictedField", ",", "swarmParams", "=", "swarmParams", ")", "self", ".", "runSwarm", "(", ...
Runs a swarm on data and swarm description found within the given working directory. If no predictedField is provided, it is assumed that the first stream listed in the streamIds provided to the Menorah constructor is the predicted field. :param predictedField: (string) :param swarmParams...
[ "Runs", "a", "swarm", "on", "data", "and", "swarm", "description", "found", "within", "the", "given", "working", "directory", ".", "If", "no", "predictedField", "is", "provided", "it", "is", "assumed", "that", "the", "first", "stream", "listed", "in", "the",...
python
train
34.6875
DLR-RM/RAFCON
source/rafcon/gui/helpers/label.py
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/helpers/label.py#L157-L167
def create_button_label(icon, font_size=constants.FONT_SIZE_NORMAL): """Create a button label with a chosen icon. :param icon: The icon :param font_size: The size of the icon :return: The created label """ label = Gtk.Label() set_label_markup(label, '&#x' + icon + ';', constants.ICON_FONT, ...
[ "def", "create_button_label", "(", "icon", ",", "font_size", "=", "constants", ".", "FONT_SIZE_NORMAL", ")", ":", "label", "=", "Gtk", ".", "Label", "(", ")", "set_label_markup", "(", "label", ",", "'&#x'", "+", "icon", "+", "';'", ",", "constants", ".", ...
Create a button label with a chosen icon. :param icon: The icon :param font_size: The size of the icon :return: The created label
[ "Create", "a", "button", "label", "with", "a", "chosen", "icon", "." ]
python
train
32.181818
nens/turn
turn/core.py
https://github.com/nens/turn/blob/98e806a0749ada0ddfd04b3c29fb04c15bf5ac18/turn/core.py#L98-L126
def draw(self, label, expire): """ Return a Serial number for this resource queue, after bootstrapping. """ # get next number with self.client.pipeline() as pipe: pipe.msetnx({self.keys.dispenser: 0, self.keys.indicator: 1}) pipe.incr(self.keys.dispenser) ...
[ "def", "draw", "(", "self", ",", "label", ",", "expire", ")", ":", "# get next number", "with", "self", ".", "client", ".", "pipeline", "(", ")", "as", "pipe", ":", "pipe", ".", "msetnx", "(", "{", "self", ".", "keys", ".", "dispenser", ":", "0", "...
Return a Serial number for this resource queue, after bootstrapping.
[ "Return", "a", "Serial", "number", "for", "this", "resource", "queue", "after", "bootstrapping", "." ]
python
train
32
glitchassassin/lackey
lackey/PlatformManagerWindows.py
https://github.com/glitchassassin/lackey/blob/7adadfacd7f45d81186710be992f5668b15399fe/lackey/PlatformManagerWindows.py#L580-L604
def highlight(self, rect, color="red", seconds=None): """ Simulates a transparent rectangle over the specified ``rect`` on the screen. Actually takes a screenshot of the region and displays with a rectangle border in a borderless window (due to Tkinter limitations) If a Tkinter root wi...
[ "def", "highlight", "(", "self", ",", "rect", ",", "color", "=", "\"red\"", ",", "seconds", "=", "None", ")", ":", "if", "tk", ".", "_default_root", "is", "None", ":", "Debug", ".", "log", "(", "3", ",", "\"Creating new temporary Tkinter root\"", ")", "t...
Simulates a transparent rectangle over the specified ``rect`` on the screen. Actually takes a screenshot of the region and displays with a rectangle border in a borderless window (due to Tkinter limitations) If a Tkinter root window has already been created somewhere else, uses that in...
[ "Simulates", "a", "transparent", "rectangle", "over", "the", "specified", "rect", "on", "the", "screen", "." ]
python
train
41
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_map/mp_slipmap_util.py
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_map/mp_slipmap_util.py#L461-L471
def img(self): '''return a cv image for the icon''' SlipThumbnail.img(self) if self.rotation: # rotate the image mat = cv2.getRotationMatrix2D((self.height//2, self.width//2), -self.rotation, 1.0) self._rotated = cv2.warpAffine(self._img, mat, (self.height, s...
[ "def", "img", "(", "self", ")", ":", "SlipThumbnail", ".", "img", "(", "self", ")", "if", "self", ".", "rotation", ":", "# rotate the image", "mat", "=", "cv2", ".", "getRotationMatrix2D", "(", "(", "self", ".", "height", "//", "2", ",", "self", ".", ...
return a cv image for the icon
[ "return", "a", "cv", "image", "for", "the", "icon" ]
python
train
36.545455
twilio/twilio-python
twilio/rest/trunking/v1/trunk/terminating_sip_domain.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/trunking/v1/trunk/terminating_sip_domain.py#L309-L323
def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: TerminatingSipDomainContext for this TerminatingSipDomainInstance :rtype: twilio.rest.trunking.v1...
[ "def", "_proxy", "(", "self", ")", ":", "if", "self", ".", "_context", "is", "None", ":", "self", ".", "_context", "=", "TerminatingSipDomainContext", "(", "self", ".", "_version", ",", "trunk_sid", "=", "self", ".", "_solution", "[", "'trunk_sid'", "]", ...
Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: TerminatingSipDomainContext for this TerminatingSipDomainInstance :rtype: twilio.rest.trunking.v1.trunk.terminating_sip_domain.Terminat...
[ "Generate", "an", "instance", "context", "for", "the", "instance", "the", "context", "is", "capable", "of", "performing", "various", "actions", ".", "All", "instance", "actions", "are", "proxied", "to", "the", "context" ]
python
train
42.533333
IntelPython/mkl_fft
mkl_fft/_numpy_fft.py
https://github.com/IntelPython/mkl_fft/blob/54b3271d64666f9af9f11418b4ca43d69054eb94/mkl_fft/_numpy_fft.py#L73-L161
def fft(a, n=None, axis=-1, norm=None): """ Compute the one-dimensional discrete Fourier Transform. This function computes the one-dimensional *n*-point discrete Fourier Transform (DFT) with the efficient Fast Fourier Transform (FFT) algorithm [CT]. Parameters ---------- a : array_like...
[ "def", "fft", "(", "a", ",", "n", "=", "None", ",", "axis", "=", "-", "1", ",", "norm", "=", "None", ")", ":", "output", "=", "mkl_fft", ".", "fft", "(", "a", ",", "n", ",", "axis", ")", "if", "_unitary", "(", "norm", ")", ":", "output", "*...
Compute the one-dimensional discrete Fourier Transform. This function computes the one-dimensional *n*-point discrete Fourier Transform (DFT) with the efficient Fast Fourier Transform (FFT) algorithm [CT]. Parameters ---------- a : array_like Input array, can be complex. n : int, o...
[ "Compute", "the", "one", "-", "dimensional", "discrete", "Fourier", "Transform", "." ]
python
train
35.370787
saltstack/salt
salt/utils/templates.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/templates.py#L516-L521
def render_cheetah_tmpl(tmplstr, context, tmplpath=None): ''' Render a Cheetah template. ''' from Cheetah.Template import Template return salt.utils.data.decode(Template(tmplstr, searchList=[context]))
[ "def", "render_cheetah_tmpl", "(", "tmplstr", ",", "context", ",", "tmplpath", "=", "None", ")", ":", "from", "Cheetah", ".", "Template", "import", "Template", "return", "salt", ".", "utils", ".", "data", ".", "decode", "(", "Template", "(", "tmplstr", ","...
Render a Cheetah template.
[ "Render", "a", "Cheetah", "template", "." ]
python
train
36
gwastro/pycbc-glue
pycbc_glue/ligolw/ligolw.py
https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/ligolw/ligolw.py#L290-L297
def appendData(self, content): """ Add characters to the element's pcdata. """ if self.pcdata is not None: self.pcdata += content else: self.pcdata = content
[ "def", "appendData", "(", "self", ",", "content", ")", ":", "if", "self", ".", "pcdata", "is", "not", "None", ":", "self", ".", "pcdata", "+=", "content", "else", ":", "self", ".", "pcdata", "=", "content" ]
Add characters to the element's pcdata.
[ "Add", "characters", "to", "the", "element", "s", "pcdata", "." ]
python
train
20.75
jobovy/galpy
galpy/potential/MovingObjectPotential.py
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/potential/MovingObjectPotential.py#L112-L135
def _zforce(self,R,z,phi=0.,t=0.): """ NAME: _zforce PURPOSE: evaluate the vertical force for this potential INPUT: R - Galactocentric cylindrical radius z - vertical height phi - azimuth t - time OUTPUT: ...
[ "def", "_zforce", "(", "self", ",", "R", ",", "z", ",", "phi", "=", "0.", ",", "t", "=", "0.", ")", ":", "#Cylindrical distance", "Rdist", "=", "_cylR", "(", "R", ",", "phi", ",", "self", ".", "_orb", ".", "R", "(", "t", ")", ",", "self", "."...
NAME: _zforce PURPOSE: evaluate the vertical force for this potential INPUT: R - Galactocentric cylindrical radius z - vertical height phi - azimuth t - time OUTPUT: the vertical force HISTORY: 2011-0...
[ "NAME", ":", "_zforce", "PURPOSE", ":", "evaluate", "the", "vertical", "force", "for", "this", "potential", "INPUT", ":", "R", "-", "Galactocentric", "cylindrical", "radius", "z", "-", "vertical", "height", "phi", "-", "azimuth", "t", "-", "time", "OUTPUT", ...
python
train
33.458333
heuer/cablemap
cablemap.core/cablemap/core/reader.py
https://github.com/heuer/cablemap/blob/42066c8fc2972d237a2c35578e14525aaf705f38/cablemap.core/cablemap/core/reader.py#L226-L262
def header_body_from_content(content): """\ Tries to extract the header and the message from the cable content. The header is something like UNCLASSIFIED ... SUBJECT ... REF ... while the message begins usually with a summary 1. SUMMARY ... ... 10. ......
[ "def", "header_body_from_content", "(", "content", ")", ":", "m", "=", "_CLASSIFIED_BY_PATTERN", ".", "search", "(", "content", ")", "idx", "=", "m", "and", "m", ".", "end", "(", ")", "or", "0", "m", "=", "_SUMMARY_PATTERN", ".", "search", "(", "content"...
\ Tries to extract the header and the message from the cable content. The header is something like UNCLASSIFIED ... SUBJECT ... REF ... while the message begins usually with a summary 1. SUMMARY ... ... 10. ... Returns (header, msg) or (None, None...
[ "\\", "Tries", "to", "extract", "the", "header", "and", "the", "message", "from", "the", "cable", "content", "." ]
python
train
26.135135
ejhigson/nestcheck
nestcheck/parallel_utils.py
https://github.com/ejhigson/nestcheck/blob/29151c314deb89746fd674f27f6ce54b77603189/nestcheck/parallel_utils.py#L70-L142
def parallel_apply(func, arg_iterable, **kwargs): """Apply function to iterable with parallelisation and a tqdm progress bar. Roughly equivalent to >>> [func(*func_pre_args, x, *func_args, **func_kwargs) for x in arg_iterable] but will **not** necessarily return results in input order. ...
[ "def", "parallel_apply", "(", "func", ",", "arg_iterable", ",", "*", "*", "kwargs", ")", ":", "max_workers", "=", "kwargs", ".", "pop", "(", "'max_workers'", ",", "None", ")", "parallel", "=", "kwargs", ".", "pop", "(", "'parallel'", ",", "True", ")", ...
Apply function to iterable with parallelisation and a tqdm progress bar. Roughly equivalent to >>> [func(*func_pre_args, x, *func_args, **func_kwargs) for x in arg_iterable] but will **not** necessarily return results in input order. Parameters ---------- func: function Func...
[ "Apply", "function", "to", "iterable", "with", "parallelisation", "and", "a", "tqdm", "progress", "bar", "." ]
python
train
40.39726
saltstack/salt
salt/modules/firewalld.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/firewalld.py#L590-L617
def remove_masquerade(zone=None, permanent=True): ''' Remove masquerade on a zone. If zone is omitted, default zone will be used. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' firewalld.remove_masquerade To remove masquerade on a specific zone .. cod...
[ "def", "remove_masquerade", "(", "zone", "=", "None", ",", "permanent", "=", "True", ")", ":", "if", "zone", ":", "cmd", "=", "'--zone={0} --remove-masquerade'", ".", "format", "(", "zone", ")", "else", ":", "cmd", "=", "'--remove-masquerade'", "if", "perman...
Remove masquerade on a zone. If zone is omitted, default zone will be used. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt '*' firewalld.remove_masquerade To remove masquerade on a specific zone .. code-block:: bash salt '*' firewalld.remove_masquerade d...
[ "Remove", "masquerade", "on", "a", "zone", ".", "If", "zone", "is", "omitted", "default", "zone", "will", "be", "used", "." ]
python
train
20.178571
dotzero/tilda-api-python
tilda/client.py
https://github.com/dotzero/tilda-api-python/blob/0ab984e0236cbfb676b0fbddc1ab37202d92e0a8/tilda/client.py#L137-L144
def get_page_full_export(self, page_id): """ Get full page info for export and body html code """ try: result = self._request('/getpagefullexport/', {'pageid': page_id}) return TildaPage(**result) except NetworkError: return ...
[ "def", "get_page_full_export", "(", "self", ",", "page_id", ")", ":", "try", ":", "result", "=", "self", ".", "_request", "(", "'/getpagefullexport/'", ",", "{", "'pageid'", ":", "page_id", "}", ")", "return", "TildaPage", "(", "*", "*", "result", ")", "...
Get full page info for export and body html code
[ "Get", "full", "page", "info", "for", "export", "and", "body", "html", "code" ]
python
train
39.375
AndrewAnnex/SpiceyPy
spiceypy/spiceypy.py
https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L4728-L4743
def elemc(item, inset): """ Determine whether an item is an element of a character set. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/elemc_c.html :param item: Item to be tested. :type item: str :param inset: Set to be tested. :type inset: spiceypy.utils.support_types.SpiceCell ...
[ "def", "elemc", "(", "item", ",", "inset", ")", ":", "assert", "isinstance", "(", "inset", ",", "stypes", ".", "SpiceCell", ")", "item", "=", "stypes", ".", "stringToCharP", "(", "item", ")", "return", "bool", "(", "libspice", ".", "elemc_c", "(", "ite...
Determine whether an item is an element of a character set. http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/elemc_c.html :param item: Item to be tested. :type item: str :param inset: Set to be tested. :type inset: spiceypy.utils.support_types.SpiceCell :return: True if item is an eleme...
[ "Determine", "whether", "an", "item", "is", "an", "element", "of", "a", "character", "set", "." ]
python
train
32.625
Robpol86/sphinxcontrib-versioning
sphinxcontrib/versioning/__main__.py
https://github.com/Robpol86/sphinxcontrib-versioning/blob/920edec0ac764081b583a2ecf4e6952762b9dbf2/sphinxcontrib/versioning/__main__.py#L210-L234
def override_root_main_ref(config, remotes, banner): """Override root_ref or banner_main_ref with tags in config if user requested. :param sphinxcontrib.versioning.lib.Config config: Runtime configuration. :param iter remotes: List of dicts from Versions.remotes. :param bool banner: Evaluate banner mai...
[ "def", "override_root_main_ref", "(", "config", ",", "remotes", ",", "banner", ")", ":", "log", "=", "logging", ".", "getLogger", "(", "__name__", ")", "greatest_tag", "=", "config", ".", "banner_greatest_tag", "if", "banner", "else", "config", ".", "greatest_...
Override root_ref or banner_main_ref with tags in config if user requested. :param sphinxcontrib.versioning.lib.Config config: Runtime configuration. :param iter remotes: List of dicts from Versions.remotes. :param bool banner: Evaluate banner main ref instead of root ref. :return: If root/main ref ex...
[ "Override", "root_ref", "or", "banner_main_ref", "with", "tags", "in", "config", "if", "user", "requested", "." ]
python
train
47.28
jazzband/django-ddp
dddp/models.py
https://github.com/jazzband/django-ddp/blob/1e1954b06fe140346acea43582515991685e4e01/dddp/models.py#L188-L208
def get_object(model, meteor_id, *args, **kwargs): """Return an object for the given meteor_id.""" # Django model._meta is now public API -> pylint: disable=W0212 meta = model._meta if isinstance(meta.pk, AleaIdField): # meteor_id is the primary key return model.objects.filter(*args, **k...
[ "def", "get_object", "(", "model", ",", "meteor_id", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Django model._meta is now public API -> pylint: disable=W0212", "meta", "=", "model", ".", "_meta", "if", "isinstance", "(", "meta", ".", "pk", ",", "A...
Return an object for the given meteor_id.
[ "Return", "an", "object", "for", "the", "given", "meteor_id", "." ]
python
test
35.904762
CityOfZion/neo-python
neo/Core/TX/Transaction.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Core/TX/Transaction.py#L736-L763
def GetTransactionResults(self): """ Get the execution results of the transaction. Returns: None: if the transaction has no references. list: of TransactionResult objects. """ if self.References is None: return None results = [] ...
[ "def", "GetTransactionResults", "(", "self", ")", ":", "if", "self", ".", "References", "is", "None", ":", "return", "None", "results", "=", "[", "]", "realresults", "=", "[", "]", "for", "ref_output", "in", "self", ".", "References", ".", "values", "(",...
Get the execution results of the transaction. Returns: None: if the transaction has no references. list: of TransactionResult objects.
[ "Get", "the", "execution", "results", "of", "the", "transaction", "." ]
python
train
31.035714
denisenkom/pytds
src/pytds/tds_types.py
https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds_types.py#L1583-L1588
def to_pydatetime(self): """ Converts datetime2 object into Python's datetime.datetime object @return: naive datetime.datetime """ return datetime.datetime.combine(self._date.to_pydate(), self._time.to_pytime())
[ "def", "to_pydatetime", "(", "self", ")", ":", "return", "datetime", ".", "datetime", ".", "combine", "(", "self", ".", "_date", ".", "to_pydate", "(", ")", ",", "self", ".", "_time", ".", "to_pytime", "(", ")", ")" ]
Converts datetime2 object into Python's datetime.datetime object @return: naive datetime.datetime
[ "Converts", "datetime2", "object", "into", "Python", "s", "datetime", ".", "datetime", "object" ]
python
train
41
apple/turicreate
deps/src/libxml2-2.9.1/python/libxml2.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L4858-L4863
def schemaValidateDoc(self, ctxt): """Validate a document tree in memory. """ if ctxt is None: ctxt__o = None else: ctxt__o = ctxt._o ret = libxml2mod.xmlSchemaValidateDoc(ctxt__o, self._o) return ret
[ "def", "schemaValidateDoc", "(", "self", ",", "ctxt", ")", ":", "if", "ctxt", "is", "None", ":", "ctxt__o", "=", "None", "else", ":", "ctxt__o", "=", "ctxt", ".", "_o", "ret", "=", "libxml2mod", ".", "xmlSchemaValidateDoc", "(", "ctxt__o", ",", "self", ...
Validate a document tree in memory.
[ "Validate", "a", "document", "tree", "in", "memory", "." ]
python
train
39.166667
pandas-dev/pandas
pandas/plotting/_core.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L489-L503
def _apply_axis_properties(self, axis, rot=None, fontsize=None): """ Tick creation within matplotlib is reasonably expensive and is internally deferred until accessed as Ticks are created/destroyed multiple times per draw. It's therefore beneficial for us to avoid accessing u...
[ "def", "_apply_axis_properties", "(", "self", ",", "axis", ",", "rot", "=", "None", ",", "fontsize", "=", "None", ")", ":", "if", "rot", "is", "not", "None", "or", "fontsize", "is", "not", "None", ":", "# rot=0 is a valid setting, hence the explicit None check",...
Tick creation within matplotlib is reasonably expensive and is internally deferred until accessed as Ticks are created/destroyed multiple times per draw. It's therefore beneficial for us to avoid accessing unless we will act on the Tick.
[ "Tick", "creation", "within", "matplotlib", "is", "reasonably", "expensive", "and", "is", "internally", "deferred", "until", "accessed", "as", "Ticks", "are", "created", "/", "destroyed", "multiple", "times", "per", "draw", ".", "It", "s", "therefore", "benefici...
python
train
50.066667
MillionIntegrals/vel
vel/util/network.py
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/util/network.py#L34-L41
def convolutional_layer_series(initial_size, layer_sequence): """ Execute a series of convolutional layer transformations to the size number """ size = initial_size for filter_size, padding, stride in layer_sequence: size = convolution_size_equation(size, filter_size, padding, stride) return s...
[ "def", "convolutional_layer_series", "(", "initial_size", ",", "layer_sequence", ")", ":", "size", "=", "initial_size", "for", "filter_size", ",", "padding", ",", "stride", "in", "layer_sequence", ":", "size", "=", "convolution_size_equation", "(", "size", ",", "f...
Execute a series of convolutional layer transformations to the size number
[ "Execute", "a", "series", "of", "convolutional", "layer", "transformations", "to", "the", "size", "number" ]
python
train
39.5
jbloomlab/phydms
phydmslib/parsearguments.py
https://github.com/jbloomlab/phydms/blob/9cdebc10bafbe543c552d79486c7f950780ed3c0/phydmslib/parsearguments.py#L19-L23
def error(self, message): """Prints error message, then help.""" sys.stderr.write('error: %s\n\n' % message) self.print_help() sys.exit(2)
[ "def", "error", "(", "self", ",", "message", ")", ":", "sys", ".", "stderr", ".", "write", "(", "'error: %s\\n\\n'", "%", "message", ")", "self", ".", "print_help", "(", ")", "sys", ".", "exit", "(", "2", ")" ]
Prints error message, then help.
[ "Prints", "error", "message", "then", "help", "." ]
python
train
33.2
bloomreach/s4cmd
s4cmd.py
https://github.com/bloomreach/s4cmd/blob/bb51075bf43703e7cd95aa39288cf7732ec13a6d/s4cmd.py#L1635-L1641
def mb_handler(self, args): '''Handler for mb command''' if len(args) == 1: raise InvalidArgument('No s3 bucketname provided') self.validate('cmd|s3', args) self.s3handler().create_bucket(args[1])
[ "def", "mb_handler", "(", "self", ",", "args", ")", ":", "if", "len", "(", "args", ")", "==", "1", ":", "raise", "InvalidArgument", "(", "'No s3 bucketname provided'", ")", "self", ".", "validate", "(", "'cmd|s3'", ",", "args", ")", "self", ".", "s3handl...
Handler for mb command
[ "Handler", "for", "mb", "command" ]
python
test
30.428571
waqasbhatti/astrobase
astrobase/lcproc/lcpfeatures.py
https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/lcproc/lcpfeatures.py#L551-L569
def _periodicfeatures_worker(task): ''' This is a parallel worker for the drivers below. ''' pfpickle, lcbasedir, outdir, starfeatures, kwargs = task try: return get_periodicfeatures(pfpickle, lcbasedir, outdir, ...
[ "def", "_periodicfeatures_worker", "(", "task", ")", ":", "pfpickle", ",", "lcbasedir", ",", "outdir", ",", "starfeatures", ",", "kwargs", "=", "task", "try", ":", "return", "get_periodicfeatures", "(", "pfpickle", ",", "lcbasedir", ",", "outdir", ",", "starfe...
This is a parallel worker for the drivers below.
[ "This", "is", "a", "parallel", "worker", "for", "the", "drivers", "below", "." ]
python
valid
26.736842
pgjones/quart
quart/config.py
https://github.com/pgjones/quart/blob/7cb2d3bd98e8746025764f2b933abc12041fa175/quart/config.py#L147-L179
def from_object(self, instance: Union[object, str]) -> None: """Load the configuration from a Python object. This can be used to reference modules or objects within modules for example, .. code-block:: python app.config.from_object('module') app.config.from_obj...
[ "def", "from_object", "(", "self", ",", "instance", ":", "Union", "[", "object", ",", "str", "]", ")", "->", "None", ":", "if", "isinstance", "(", "instance", ",", "str", ")", ":", "try", ":", "path", ",", "config", "=", "instance", ".", "rsplit", ...
Load the configuration from a Python object. This can be used to reference modules or objects within modules for example, .. code-block:: python app.config.from_object('module') app.config.from_object('module.instance') from module import instance ...
[ "Load", "the", "configuration", "from", "a", "Python", "object", "." ]
python
train
30.878788
OnroerendErfgoed/pyramid_urireferencer
pyramid_urireferencer/renderers.py
https://github.com/OnroerendErfgoed/pyramid_urireferencer/blob/c6ee4ba863e32ced304b9cf00f3f5b450757a29a/pyramid_urireferencer/renderers.py#L14-L38
def registry_adapter(obj, request): """ Adapter for rendering a :class:`pyramid_urireferencer.models.RegistryResponse` to json. :param pyramid_urireferencer.models.RegistryResponse obj: The response to be rendered. :rtype: :class:`dict` """ return { 'query_uri': obj.query_uri, '...
[ "def", "registry_adapter", "(", "obj", ",", "request", ")", ":", "return", "{", "'query_uri'", ":", "obj", ".", "query_uri", ",", "'success'", ":", "obj", ".", "success", ",", "'has_references'", ":", "obj", ".", "has_references", ",", "'count'", ":", "obj...
Adapter for rendering a :class:`pyramid_urireferencer.models.RegistryResponse` to json. :param pyramid_urireferencer.models.RegistryResponse obj: The response to be rendered. :rtype: :class:`dict`
[ "Adapter", "for", "rendering", "a", ":", "class", ":", "pyramid_urireferencer", ".", "models", ".", "RegistryResponse", "to", "json", "." ]
python
train
43.32
secdev/scapy
scapy/layers/inet.py
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/inet.py#L1834-L1848
def IPID_count(lst, funcID=lambda x: x[1].id, funcpres=lambda x: x[1].summary()): # noqa: E501 """Identify IP id values classes in a list of packets lst: a list of packets funcID: a function that returns IP id values funcpres: a function used to summarize packets""" idlst = [funcID(e) for e in lst] ...
[ "def", "IPID_count", "(", "lst", ",", "funcID", "=", "lambda", "x", ":", "x", "[", "1", "]", ".", "id", ",", "funcpres", "=", "lambda", "x", ":", "x", "[", "1", "]", ".", "summary", "(", ")", ")", ":", "# noqa: E501", "idlst", "=", "[", "funcID...
Identify IP id values classes in a list of packets lst: a list of packets funcID: a function that returns IP id values funcpres: a function used to summarize packets
[ "Identify", "IP", "id", "values", "classes", "in", "a", "list", "of", "packets" ]
python
train
41.133333
usc-isi-i2/etk
etk/black_list_filter.py
https://github.com/usc-isi-i2/etk/blob/aab077c984ea20f5e8ae33af622fe11d3c4df866/etk/black_list_filter.py#L9-L27
def filter(self, extractions, case_sensitive=False) -> List[Extraction]: """filters out the extraction if extracted value is in the blacklist""" filtered_extractions = [] if not isinstance(extractions, list): extractions = [extractions] for extraction in extractions: ...
[ "def", "filter", "(", "self", ",", "extractions", ",", "case_sensitive", "=", "False", ")", "->", "List", "[", "Extraction", "]", ":", "filtered_extractions", "=", "[", "]", "if", "not", "isinstance", "(", "extractions", ",", "list", ")", ":", "extractions...
filters out the extraction if extracted value is in the blacklist
[ "filters", "out", "the", "extraction", "if", "extracted", "value", "is", "in", "the", "blacklist" ]
python
train
51.210526
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/textio.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/textio.py#L427-L452
def mixed_list_file(cls, filename, values, bits): """ Write a list of mixed values to a file. If a file of the same name exists, it's contents are replaced. See L{HexInput.mixed_list_file} for a description of the file format. @type filename: str @param filename: Name ...
[ "def", "mixed_list_file", "(", "cls", ",", "filename", ",", "values", ",", "bits", ")", ":", "fd", "=", "open", "(", "filename", ",", "'w'", ")", "for", "original", "in", "values", ":", "try", ":", "parsed", "=", "cls", ".", "integer", "(", "original...
Write a list of mixed values to a file. If a file of the same name exists, it's contents are replaced. See L{HexInput.mixed_list_file} for a description of the file format. @type filename: str @param filename: Name of the file to write. @type values: list( int ) @par...
[ "Write", "a", "list", "of", "mixed", "values", "to", "a", "file", ".", "If", "a", "file", "of", "the", "same", "name", "exists", "it", "s", "contents", "are", "replaced", "." ]
python
train
33.730769
inveniosoftware/invenio-assets
invenio_assets/filters.py
https://github.com/inveniosoftware/invenio-assets/blob/836cc75ebe0c179f0d72456bd8b784cdc18394a6/invenio_assets/filters.py#L71-L74
def setup(self): """Initialize filter just before it will be used.""" super(CleanCSSFilter, self).setup() self.root = current_app.config.get('COLLECT_STATIC_ROOT')
[ "def", "setup", "(", "self", ")", ":", "super", "(", "CleanCSSFilter", ",", "self", ")", ".", "setup", "(", ")", "self", ".", "root", "=", "current_app", ".", "config", ".", "get", "(", "'COLLECT_STATIC_ROOT'", ")" ]
Initialize filter just before it will be used.
[ "Initialize", "filter", "just", "before", "it", "will", "be", "used", "." ]
python
train
46
openego/ding0
ding0/tools/logger.py
https://github.com/openego/ding0/blob/e2d6528f96255e4bb22ba15514a4f1883564ed5d/ding0/tools/logger.py#L55-L66
def get_default_home_dir(): """ Return default home directory of Ding0 Returns ------- :any:`str` Default home directory including its path """ ding0_dir = str(cfg_ding0.get('config', 'config_dir')) return os.path.join(os.path.expanduser('~'), d...
[ "def", "get_default_home_dir", "(", ")", ":", "ding0_dir", "=", "str", "(", "cfg_ding0", ".", "get", "(", "'config'", ",", "'config_dir'", ")", ")", "return", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "expanduser", "(", "'~'", ")", ...
Return default home directory of Ding0 Returns ------- :any:`str` Default home directory including its path
[ "Return", "default", "home", "directory", "of", "Ding0" ]
python
train
26.5
kata198/indexedredis
IndexedRedis/fields/chain.py
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/fields/chain.py#L131-L147
def _checkCanIndex(self): ''' _checkCanIndex - Check if we CAN index (if all fields are indexable). Also checks the right-most field for "hashIndex" - if it needs to hash we will hash. ''' # NOTE: We can't just check the right-most field. For types like pickle that don't support indexing, they don't # ...
[ "def", "_checkCanIndex", "(", "self", ")", ":", "# NOTE: We can't just check the right-most field. For types like pickle that don't support indexing, they don't", "# support it because python2 and python3 have different results for pickle.dumps on the same object.", "# So if we have a field chai...
_checkCanIndex - Check if we CAN index (if all fields are indexable). Also checks the right-most field for "hashIndex" - if it needs to hash we will hash.
[ "_checkCanIndex", "-", "Check", "if", "we", "CAN", "index", "(", "if", "all", "fields", "are", "indexable", ")", ".", "Also", "checks", "the", "right", "-", "most", "field", "for", "hashIndex", "-", "if", "it", "needs", "to", "hash", "we", "will", "has...
python
valid
42.176471
tisimst/mcerp
mcerp/__init__.py
https://github.com/tisimst/mcerp/blob/2bb8260c9ad2d58a806847f1b627b6451e407de1/mcerp/__init__.py#L721-L743
def Beta(alpha, beta, low=0, high=1, tag=None): """ A Beta random variate Parameters ---------- alpha : scalar The first shape parameter beta : scalar The second shape parameter Optional -------- low : scalar Lower bound of the distribution support (...
[ "def", "Beta", "(", "alpha", ",", "beta", ",", "low", "=", "0", ",", "high", "=", "1", ",", "tag", "=", "None", ")", ":", "assert", "(", "alpha", ">", "0", "and", "beta", ">", "0", ")", ",", "'Beta \"alpha\" and \"beta\" parameters must be greater than z...
A Beta random variate Parameters ---------- alpha : scalar The first shape parameter beta : scalar The second shape parameter Optional -------- low : scalar Lower bound of the distribution support (default=0) high : scalar Upper bound of the dist...
[ "A", "Beta", "random", "variate", "Parameters", "----------", "alpha", ":", "scalar", "The", "first", "shape", "parameter", "beta", ":", "scalar", "The", "second", "shape", "parameter", "Optional", "--------", "low", ":", "scalar", "Lower", "bound", "of", "the...
python
train
27.869565
lehins/python-wepay
wepay/calls/account.py
https://github.com/lehins/python-wepay/blob/414d25a1a8d0ecb22a3ddd1f16c60b805bb52a1f/wepay/calls/account.py#L205-L231
def __balance(self, account_id, **kwargs): """Call documentation: `/account/balance <https://www.wepay.com/developer/reference/account-2011-01-15#balance>`_, plus extra keyword parameters: :keyword str access_token: will be used instead of instance's ``access_token``,...
[ "def", "__balance", "(", "self", ",", "account_id", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'account_id'", ":", "account_id", "}", "return", "self", ".", "make_call", "(", "self", ".", "__balance", ",", "params", ",", "kwargs", ")" ]
Call documentation: `/account/balance <https://www.wepay.com/developer/reference/account-2011-01-15#balance>`_, plus extra keyword parameters: :keyword str access_token: will be used instead of instance's ``access_token``, with ``batch_mode=True`` will set `authorization` ...
[ "Call", "documentation", ":", "/", "account", "/", "balance", "<https", ":", "//", "www", ".", "wepay", ".", "com", "/", "developer", "/", "reference", "/", "account", "-", "2011", "-", "01", "-", "15#balance", ">", "_", "plus", "extra", "keyword", "pa...
python
train
34.296296
its-rigs/Trolly
trolly/board.py
https://github.com/its-rigs/Trolly/blob/483dc94c352df40dc05ead31820b059b2545cf82/trolly/board.py#L86-L96
def get_checklists( self ): """ Get the checklists for this board. Returns a list of Checklist objects. """ checklists = self.getChecklistsJson( self.base_uri ) checklists_list = [] for checklist_json in checklists: checklists_list.append( self.createChecklis...
[ "def", "get_checklists", "(", "self", ")", ":", "checklists", "=", "self", ".", "getChecklistsJson", "(", "self", ".", "base_uri", ")", "checklists_list", "=", "[", "]", "for", "checklist_json", "in", "checklists", ":", "checklists_list", ".", "append", "(", ...
Get the checklists for this board. Returns a list of Checklist objects.
[ "Get", "the", "checklists", "for", "this", "board", ".", "Returns", "a", "list", "of", "Checklist", "objects", "." ]
python
test
33
pytroll/pyspectral
pyspectral/utils.py
https://github.com/pytroll/pyspectral/blob/fd296c0e0bdf5364fa180134a1292665d6bc50a3/pyspectral/utils.py#L285-L303
def sort_data(x_vals, y_vals): """Sort the data so that x is monotonically increasing and contains no duplicates. """ # Sort data idxs = np.argsort(x_vals) x_vals = x_vals[idxs] y_vals = y_vals[idxs] # De-duplicate data mask = np.r_[True, (np.diff(x_vals) > 0)] if not mask.all()...
[ "def", "sort_data", "(", "x_vals", ",", "y_vals", ")", ":", "# Sort data", "idxs", "=", "np", ".", "argsort", "(", "x_vals", ")", "x_vals", "=", "x_vals", "[", "idxs", "]", "y_vals", "=", "y_vals", "[", "idxs", "]", "# De-duplicate data", "mask", "=", ...
Sort the data so that x is monotonically increasing and contains no duplicates.
[ "Sort", "the", "data", "so", "that", "x", "is", "monotonically", "increasing", "and", "contains", "no", "duplicates", "." ]
python
train
27.052632
SectorLabs/django-localized-fields
localized_fields/util.py
https://github.com/SectorLabs/django-localized-fields/blob/f0ac0f7f2503317fde5d75ba8481e34db83512bd/localized_fields/util.py#L24-L44
def resolve_object_property(obj, path: str): """Resolves the value of a property on an object. Is able to resolve nested properties. For example, a path can be specified: 'other.beer.name' Raises: AttributeError: In case the property could not be resolved. Returns: ...
[ "def", "resolve_object_property", "(", "obj", ",", "path", ":", "str", ")", ":", "value", "=", "obj", "for", "path_part", "in", "path", ".", "split", "(", "'.'", ")", ":", "value", "=", "getattr", "(", "value", ",", "path_part", ")", "return", "value" ...
Resolves the value of a property on an object. Is able to resolve nested properties. For example, a path can be specified: 'other.beer.name' Raises: AttributeError: In case the property could not be resolved. Returns: The value of the specified property.
[ "Resolves", "the", "value", "of", "a", "property", "on", "an", "object", "." ]
python
train
22.142857
choderalab/pymbar
pymbar/old_mbar.py
https://github.com/choderalab/pymbar/blob/69d1f0ff680e9ac1c6a51a5a207ea28f3ed86740/pymbar/old_mbar.py#L1214-L1372
def computeEntropyAndEnthalpy(self, uncertainty_method=None, verbose=False, warning_cutoff=1.0e-10): """Decompose free energy differences into enthalpy and entropy differences. Compute the decomposition of the free energy difference between states 1 and N into reduced free energy differences, r...
[ "def", "computeEntropyAndEnthalpy", "(", "self", ",", "uncertainty_method", "=", "None", ",", "verbose", "=", "False", ",", "warning_cutoff", "=", "1.0e-10", ")", ":", "if", "verbose", ":", "print", "(", "\"Computing average energy and entropy by MBAR.\"", ")", "# R...
Decompose free energy differences into enthalpy and entropy differences. Compute the decomposition of the free energy difference between states 1 and N into reduced free energy differences, reduced potential (enthalpy) differences, and reduced entropy (S/k) differences. Parameters ...
[ "Decompose", "free", "energy", "differences", "into", "enthalpy", "and", "entropy", "differences", "." ]
python
train
47.031447
deshima-dev/decode
decode/io/functions.py
https://github.com/deshima-dev/decode/blob/e789e174cd316e7ec8bc55be7009ad35baced3c0/decode/io/functions.py#L268-L321
def savefits(cube, fitsname, **kwargs): """Save a cube to a 3D-cube FITS file. Args: cube (xarray.DataArray): Cube to be saved. fitsname (str): Name of output FITS file. kwargs (optional): Other arguments common with astropy.io.fits.writeto(). """ ### pick up kwargs dropdeg ...
[ "def", "savefits", "(", "cube", ",", "fitsname", ",", "*", "*", "kwargs", ")", ":", "### pick up kwargs", "dropdeg", "=", "kwargs", ".", "pop", "(", "'dropdeg'", ",", "False", ")", "ndim", "=", "len", "(", "cube", ".", "dims", ")", "### load yaml", "FI...
Save a cube to a 3D-cube FITS file. Args: cube (xarray.DataArray): Cube to be saved. fitsname (str): Name of output FITS file. kwargs (optional): Other arguments common with astropy.io.fits.writeto().
[ "Save", "a", "cube", "to", "a", "3D", "-", "cube", "FITS", "file", "." ]
python
train
35.481481
zhexiao/ezhost
ezhost/ServerCommon.py
https://github.com/zhexiao/ezhost/blob/4146bc0be14bb1bfe98ec19283d19fab420871b3/ezhost/ServerCommon.py#L286-L298
def kibana_install(self): """ kibana install :return: """ with cd('/tmp'): if not exists('kibana.deb'): sudo('wget {0} -O kibana.deb'.format( bigdata_conf.kibana_download_url )) sudo('dpkg -i kibana.deb'...
[ "def", "kibana_install", "(", "self", ")", ":", "with", "cd", "(", "'/tmp'", ")", ":", "if", "not", "exists", "(", "'kibana.deb'", ")", ":", "sudo", "(", "'wget {0} -O kibana.deb'", ".", "format", "(", "bigdata_conf", ".", "kibana_download_url", ")", ")", ...
kibana install :return:
[ "kibana", "install", ":", "return", ":" ]
python
train
26.769231
zeromake/aiko
aiko/request.py
https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/request.py#L191-L196
def feed_data(self, data: bytes) -> None: """ 代理 feed_data """ if self._parser is not None: self._parser.feed_data(data)
[ "def", "feed_data", "(", "self", ",", "data", ":", "bytes", ")", "->", "None", ":", "if", "self", ".", "_parser", "is", "not", "None", ":", "self", ".", "_parser", ".", "feed_data", "(", "data", ")" ]
代理 feed_data
[ "代理", "feed_data" ]
python
train
26.5
StanfordVL/robosuite
robosuite/utils/transform_utils.py
https://github.com/StanfordVL/robosuite/blob/65cd16810e2ed647e3ec88746af3412065b7f278/robosuite/utils/transform_utils.py#L531-L546
def make_pose(translation, rotation): """ Makes a homogenous pose matrix from a translation vector and a rotation matrix. Args: translation: a 3-dim iterable rotation: a 3x3 matrix Returns: pose: a 4x4 homogenous matrix """ pose = np.zeros((4, 4)) pose[:3, :3] = rot...
[ "def", "make_pose", "(", "translation", ",", "rotation", ")", ":", "pose", "=", "np", ".", "zeros", "(", "(", "4", ",", "4", ")", ")", "pose", "[", ":", "3", ",", ":", "3", "]", "=", "rotation", "pose", "[", ":", "3", ",", "3", "]", "=", "t...
Makes a homogenous pose matrix from a translation vector and a rotation matrix. Args: translation: a 3-dim iterable rotation: a 3x3 matrix Returns: pose: a 4x4 homogenous matrix
[ "Makes", "a", "homogenous", "pose", "matrix", "from", "a", "translation", "vector", "and", "a", "rotation", "matrix", "." ]
python
train
23.5625
PMEAL/OpenPNM
openpnm/algorithms/GenericTransport.py
https://github.com/PMEAL/OpenPNM/blob/0547b5724ffedc0a593aae48639d36fe10e0baed/openpnm/algorithms/GenericTransport.py#L439-L529
def _solve(self, A=None, b=None): r""" Sends the A and b matrices to the specified solver, and solves for *x* given the boundary conditions, and source terms based on the present value of *x*. This method does NOT iterate to solve for non-linear source terms or march time steps....
[ "def", "_solve", "(", "self", ",", "A", "=", "None", ",", "b", "=", "None", ")", ":", "# Fetch A and b from self if not given, and throw error if they've not", "# been calculated", "if", "A", "is", "None", ":", "A", "=", "self", ".", "A", "if", "A", "is", "N...
r""" Sends the A and b matrices to the specified solver, and solves for *x* given the boundary conditions, and source terms based on the present value of *x*. This method does NOT iterate to solve for non-linear source terms or march time steps. Parameters ---------- ...
[ "r", "Sends", "the", "A", "and", "b", "matrices", "to", "the", "specified", "solver", "and", "solves", "for", "*", "x", "*", "given", "the", "boundary", "conditions", "and", "source", "terms", "based", "on", "the", "present", "value", "of", "*", "x", "...
python
train
39.076923
biocore/burrito-fillings
bfillings/rdp_classifier.py
https://github.com/biocore/burrito-fillings/blob/02ab71a46119b40793bd56a4ae00ca15f6dc3329/bfillings/rdp_classifier.py#L224-L238
def _get_base_command(self): """Returns the base command plus command-line options. Handles everything up to and including the classpath. The positional training parameters are added by the _input_handler_decorator method. """ cd_command = ''.join(['cd ', str(self.Worki...
[ "def", "_get_base_command", "(", "self", ")", ":", "cd_command", "=", "''", ".", "join", "(", "[", "'cd '", ",", "str", "(", "self", ".", "WorkingDir", ")", ",", "';'", "]", ")", "jvm_command", "=", "\"java\"", "jvm_args", "=", "self", ".", "_commandli...
Returns the base command plus command-line options. Handles everything up to and including the classpath. The positional training parameters are added by the _input_handler_decorator method.
[ "Returns", "the", "base", "command", "plus", "command", "-", "line", "options", "." ]
python
train
44.066667
rosenbrockc/fortpy
fortpy/base.py
https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/base.py#L15-L32
def exhandler(function, parser): """If -examples was specified in 'args', the specified function is called and the application exits. :arg function: the function that prints the examples. :arg parser: the initialized instance of the parser that has the additional, script-specific parameters. ...
[ "def", "exhandler", "(", "function", ",", "parser", ")", ":", "args", "=", "vars", "(", "bparser", ".", "parse_known_args", "(", ")", "[", "0", "]", ")", "if", "args", "[", "\"examples\"", "]", ":", "function", "(", ")", "exit", "(", "0", ")", "if"...
If -examples was specified in 'args', the specified function is called and the application exits. :arg function: the function that prints the examples. :arg parser: the initialized instance of the parser that has the additional, script-specific parameters.
[ "If", "-", "examples", "was", "specified", "in", "args", "the", "specified", "function", "is", "called", "and", "the", "application", "exits", "." ]
python
train
32.388889
ponty/EasyProcess
easyprocess/__init__.py
https://github.com/ponty/EasyProcess/blob/81c2923339e09a86b6a2b8c12dc960f1bc67db9c/easyprocess/__init__.py#L152-L166
def check(self, return_code=0): """Run command with arguments. Wait for command to complete. If the exit code was as expected and there is no exception then return, otherwise raise EasyProcessError. :param return_code: int, expected return code :rtype: self """ ...
[ "def", "check", "(", "self", ",", "return_code", "=", "0", ")", ":", "ret", "=", "self", ".", "call", "(", ")", ".", "return_code", "ok", "=", "ret", "==", "return_code", "if", "not", "ok", ":", "raise", "EasyProcessError", "(", "self", ",", "'check ...
Run command with arguments. Wait for command to complete. If the exit code was as expected and there is no exception then return, otherwise raise EasyProcessError. :param return_code: int, expected return code :rtype: self
[ "Run", "command", "with", "arguments", ".", "Wait", "for", "command", "to", "complete", ".", "If", "the", "exit", "code", "was", "as", "expected", "and", "there", "is", "no", "exception", "then", "return", "otherwise", "raise", "EasyProcessError", "." ]
python
train
34.933333
radujica/baloo
baloo/weld/weld_str.py
https://github.com/radujica/baloo/blob/f6e05e35b73a75e8a300754c6bdc575e5f2d53b9/baloo/weld/weld_str.py#L6-L38
def weld_str_lower(array): """Convert values to lowercase. Parameters ---------- array : numpy.ndarray or WeldObject Input data. Returns ------- WeldObject Representation of this computation. """ obj_id, weld_obj = create_weld_object(array) weld_template = """...
[ "def", "weld_str_lower", "(", "array", ")", ":", "obj_id", ",", "weld_obj", "=", "create_weld_object", "(", "array", ")", "weld_template", "=", "\"\"\"map(\n {array},\n |e: vec[i8]|\n result(\n for(e,\n appender[i8],\n |c: appende...
Convert values to lowercase. Parameters ---------- array : numpy.ndarray or WeldObject Input data. Returns ------- WeldObject Representation of this computation.
[ "Convert", "values", "to", "lowercase", "." ]
python
train
20.30303
openvax/isovar
isovar/common.py
https://github.com/openvax/isovar/blob/b39b684920e3f6b344851d6598a1a1c67bce913b/isovar/common.py#L27-L37
def groupby(xs, key_fn): """ Group elements of the list `xs` by keys generated from calling `key_fn`. Returns a dictionary which maps keys to sub-lists of `xs`. """ result = defaultdict(list) for x in xs: key = key_fn(x) result[key].append(x) return result
[ "def", "groupby", "(", "xs", ",", "key_fn", ")", ":", "result", "=", "defaultdict", "(", "list", ")", "for", "x", "in", "xs", ":", "key", "=", "key_fn", "(", "x", ")", "result", "[", "key", "]", ".", "append", "(", "x", ")", "return", "result" ]
Group elements of the list `xs` by keys generated from calling `key_fn`. Returns a dictionary which maps keys to sub-lists of `xs`.
[ "Group", "elements", "of", "the", "list", "xs", "by", "keys", "generated", "from", "calling", "key_fn", "." ]
python
train
26.454545
pylast/pylast
src/pylast/__init__.py
https://github.com/pylast/pylast/blob/a52f66d316797fc819b5f1d186d77f18ba97b4ff/src/pylast/__init__.py#L505-L512
def get_artist_by_mbid(self, mbid): """Looks up an artist by its MusicBrainz ID""" params = {"mbid": mbid} doc = _Request(self, "artist.getInfo", params).execute(True) return Artist(_extract(doc, "name"), self)
[ "def", "get_artist_by_mbid", "(", "self", ",", "mbid", ")", ":", "params", "=", "{", "\"mbid\"", ":", "mbid", "}", "doc", "=", "_Request", "(", "self", ",", "\"artist.getInfo\"", ",", "params", ")", ".", "execute", "(", "True", ")", "return", "Artist", ...
Looks up an artist by its MusicBrainz ID
[ "Looks", "up", "an", "artist", "by", "its", "MusicBrainz", "ID" ]
python
train
29.75
SAP/PyHDB
pyhdb/cursor.py
https://github.com/SAP/PyHDB/blob/826539d06b8bcef74fe755e7489b8a8255628f12/pyhdb/cursor.py#L288-L310
def _handle_upsert(self, parts, unwritten_lobs=()): """Handle reply messages from INSERT or UPDATE statements""" self.description = None self._received_last_resultset_part = True # set to 'True' so that cursor.fetch*() returns just empty list for part in parts: if part.kind...
[ "def", "_handle_upsert", "(", "self", ",", "parts", ",", "unwritten_lobs", "=", "(", ")", ")", ":", "self", ".", "description", "=", "None", "self", ".", "_received_last_resultset_part", "=", "True", "# set to 'True' so that cursor.fetch*() returns just empty list", "...
Handle reply messages from INSERT or UPDATE statements
[ "Handle", "reply", "messages", "from", "INSERT", "or", "UPDATE", "statements" ]
python
train
66.130435
pandas-dev/pandas
pandas/io/pytables.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/pytables.py#L1784-L1792
def validate_metadata(self, handler): """ validate that kind=category does not change the categories """ if self.meta == 'category': new_metadata = self.metadata cur_metadata = handler.read_metadata(self.cname) if (new_metadata is not None and cur_metadata is not None...
[ "def", "validate_metadata", "(", "self", ",", "handler", ")", ":", "if", "self", ".", "meta", "==", "'category'", ":", "new_metadata", "=", "self", ".", "metadata", "cur_metadata", "=", "handler", ".", "read_metadata", "(", "self", ".", "cname", ")", "if",...
validate that kind=category does not change the categories
[ "validate", "that", "kind", "=", "category", "does", "not", "change", "the", "categories" ]
python
train
58.777778
hearsaycorp/normalize
normalize/empty.py
https://github.com/hearsaycorp/normalize/blob/8b36522ddca6d41b434580bd848f3bdaa7a999c8/normalize/empty.py#L8-L15
def placeholder(type_): """Returns the EmptyVal instance for the given type""" typetuple = type_ if isinstance(type_, tuple) else (type_,) if any in typetuple: typetuple = any if typetuple not in EMPTY_VALS: EMPTY_VALS[typetuple] = EmptyVal(typetuple) return EMPTY_VALS[typetuple]
[ "def", "placeholder", "(", "type_", ")", ":", "typetuple", "=", "type_", "if", "isinstance", "(", "type_", ",", "tuple", ")", "else", "(", "type_", ",", ")", "if", "any", "in", "typetuple", ":", "typetuple", "=", "any", "if", "typetuple", "not", "in", ...
Returns the EmptyVal instance for the given type
[ "Returns", "the", "EmptyVal", "instance", "for", "the", "given", "type" ]
python
train
38.625
Tygs/ww
src/ww/wrappers/lists.py
https://github.com/Tygs/ww/blob/6a4b85141c9b74026abe8f3fa9bc7021f3c99fd4/src/ww/wrappers/lists.py#L33-L51
def join(self, joiner, formatter=lambda s, t: t.format(s), template="{}"): """Join values and convert to string Example: >>> from ww import l >>> lst = l('012') >>> lst.join(',') u'0,1,2' >>> lst.join(',', template="{}#") ...
[ "def", "join", "(", "self", ",", "joiner", ",", "formatter", "=", "lambda", "s", ",", "t", ":", "t", ".", "format", "(", "s", ")", ",", "template", "=", "\"{}\"", ")", ":", "return", "ww", ".", "s", "(", "joiner", ")", ".", "join", "(", "self",...
Join values and convert to string Example: >>> from ww import l >>> lst = l('012') >>> lst.join(',') u'0,1,2' >>> lst.join(',', template="{}#") u'0#,1#,2#' >>> string = lst.join(',',\ formatte...
[ "Join", "values", "and", "convert", "to", "string" ]
python
train
29.052632
projectshift/shift-schema
shiftschema/schema.py
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/schema.py#L180-L197
def filter(self, model=None, context=None): """ Perform filtering on the model. Will change model in place. :param model: object or dict :param context: object, dict or None :return: None """ if model is None: return # properties self....
[ "def", "filter", "(", "self", ",", "model", "=", "None", ",", "context", "=", "None", ")", ":", "if", "model", "is", "None", ":", "return", "# properties", "self", ".", "filter_properties", "(", "model", ",", "context", "=", "context", ")", "# entities",...
Perform filtering on the model. Will change model in place. :param model: object or dict :param context: object, dict or None :return: None
[ "Perform", "filtering", "on", "the", "model", ".", "Will", "change", "model", "in", "place", ".", ":", "param", "model", ":", "object", "or", "dict", ":", "param", "context", ":", "object", "dict", "or", "None", ":", "return", ":", "None" ]
python
train
27.555556