repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
chainer/chainerui | chainerui/tasks/crawl_result.py | https://github.com/chainer/chainerui/blob/87ad25e875bc332bfdad20197fd3d0cb81a078e8/chainerui/tasks/crawl_result.py#L14-L27 | def load_result_json(result_path, json_file_name):
"""load_result_json."""
json_path = os.path.join(result_path, json_file_name)
_list = []
if os.path.isfile(json_path):
with open(json_path) as json_data:
try:
_list = json.load(json_data)
except ValueErro... | [
"def",
"load_result_json",
"(",
"result_path",
",",
"json_file_name",
")",
":",
"json_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"result_path",
",",
"json_file_name",
")",
"_list",
"=",
"[",
"]",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"json_p... | load_result_json. | [
"load_result_json",
"."
] | python | train |
elyase/geotext | geotext/geotext.py | https://github.com/elyase/geotext/blob/21a8a7f5eebea40f270beef9ede4d9a57e3c81c3/geotext/geotext.py#L15-L60 | def read_table(filename, usecols=(0, 1), sep='\t', comment='#', encoding='utf-8', skip=0):
"""Parse data files from the data directory
Parameters
----------
filename: string
Full path to file
usecols: list, default [0, 1]
A list of two elements representing the columns to be parsed... | [
"def",
"read_table",
"(",
"filename",
",",
"usecols",
"=",
"(",
"0",
",",
"1",
")",
",",
"sep",
"=",
"'\\t'",
",",
"comment",
"=",
"'#'",
",",
"encoding",
"=",
"'utf-8'",
",",
"skip",
"=",
"0",
")",
":",
"with",
"io",
".",
"open",
"(",
"filename"... | Parse data files from the data directory
Parameters
----------
filename: string
Full path to file
usecols: list, default [0, 1]
A list of two elements representing the columns to be parsed into a dictionary.
The first element will be used as keys and the second as values. Defau... | [
"Parse",
"data",
"files",
"from",
"the",
"data",
"directory"
] | python | train |
angr/angr | angr/keyed_region.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/keyed_region.py#L325-L338 | def _store(self, start, obj, size, overwrite=False):
"""
Store a variable into the storage.
:param int start: The beginning address of the variable.
:param obj: The object to store.
:param int size: Size of the object to store.
:param bool overwrite: Whether existing obj... | [
"def",
"_store",
"(",
"self",
",",
"start",
",",
"obj",
",",
"size",
",",
"overwrite",
"=",
"False",
")",
":",
"stored_object",
"=",
"StoredObject",
"(",
"start",
",",
"obj",
",",
"size",
")",
"self",
".",
"_object_mapping",
"[",
"stored_object",
".",
... | Store a variable into the storage.
:param int start: The beginning address of the variable.
:param obj: The object to store.
:param int size: Size of the object to store.
:param bool overwrite: Whether existing objects should be overwritten or not.
:return: None | [
"Store",
"a",
"variable",
"into",
"the",
"storage",
"."
] | python | train |
pyBookshelf/bookshelf | bookshelf/api_v1.py | https://github.com/pyBookshelf/bookshelf/blob/a6770678e735de95b194f6e6989223970db5f654/bookshelf/api_v1.py#L1721-L1729 | def ssh_session(key_filename,
username,
ip_address,
*cli):
""" opens a ssh shell to the host """
local('ssh -t -i %s %s@%s %s' % (key_filename,
username,
ip_address,
... | [
"def",
"ssh_session",
"(",
"key_filename",
",",
"username",
",",
"ip_address",
",",
"*",
"cli",
")",
":",
"local",
"(",
"'ssh -t -i %s %s@%s %s'",
"%",
"(",
"key_filename",
",",
"username",
",",
"ip_address",
",",
"\"\"",
".",
"join",
"(",
"chain",
".",
"f... | opens a ssh shell to the host | [
"opens",
"a",
"ssh",
"shell",
"to",
"the",
"host"
] | python | train |
radjkarl/fancyTools | fancytools/math/findPeaks.py | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/findPeaks.py#L6-L12 | def findMax(arr):
"""
in comparison to argrelmax() more simple and reliable peak finder
"""
out = np.zeros(shape=arr.shape, dtype=bool)
_calcMax(arr, out)
return out | [
"def",
"findMax",
"(",
"arr",
")",
":",
"out",
"=",
"np",
".",
"zeros",
"(",
"shape",
"=",
"arr",
".",
"shape",
",",
"dtype",
"=",
"bool",
")",
"_calcMax",
"(",
"arr",
",",
"out",
")",
"return",
"out"
] | in comparison to argrelmax() more simple and reliable peak finder | [
"in",
"comparison",
"to",
"argrelmax",
"()",
"more",
"simple",
"and",
"reliable",
"peak",
"finder"
] | python | train |
projectatomic/osbs-client | osbs/build/plugins_configuration.py | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/plugins_configuration.py#L332-L342 | def render_import_image(self, use_auth=None):
"""
Configure the import_image plugin
"""
# import_image is a multi-phase plugin
if self.user_params.imagestream_name.value is None:
self.pt.remove_plugin('exit_plugins', 'import_image',
'... | [
"def",
"render_import_image",
"(",
"self",
",",
"use_auth",
"=",
"None",
")",
":",
"# import_image is a multi-phase plugin",
"if",
"self",
".",
"user_params",
".",
"imagestream_name",
".",
"value",
"is",
"None",
":",
"self",
".",
"pt",
".",
"remove_plugin",
"(",... | Configure the import_image plugin | [
"Configure",
"the",
"import_image",
"plugin"
] | python | train |
hydpy-dev/hydpy | hydpy/models/hland/hland_model.py | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/hland/hland_model.py#L13-L57 | def calc_tc_v1(self):
"""Adjust the measured air temperature to the altitude of the
individual zones.
Required control parameters:
|NmbZones|
|TCAlt|
|ZoneZ|
|ZRelT|
Required input sequence:
|hland_inputs.T|
Calculated flux sequences:
|TC|
Basic equation:
... | [
"def",
"calc_tc_v1",
"(",
"self",
")",
":",
"con",
"=",
"self",
".",
"parameters",
".",
"control",
".",
"fastaccess",
"inp",
"=",
"self",
".",
"sequences",
".",
"inputs",
".",
"fastaccess",
"flu",
"=",
"self",
".",
"sequences",
".",
"fluxes",
".",
"fas... | Adjust the measured air temperature to the altitude of the
individual zones.
Required control parameters:
|NmbZones|
|TCAlt|
|ZoneZ|
|ZRelT|
Required input sequence:
|hland_inputs.T|
Calculated flux sequences:
|TC|
Basic equation:
:math:`TC = T - TCAlt \... | [
"Adjust",
"the",
"measured",
"air",
"temperature",
"to",
"the",
"altitude",
"of",
"the",
"individual",
"zones",
"."
] | python | train |
bokeh/bokeh | bokeh/client/util.py | https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/client/util.py#L73-L99 | def websocket_url_for_server_url(url):
''' Convert an ``http(s)`` URL for a Bokeh server websocket endpoint into
the appropriate ``ws(s)`` URL
Args:
url (str):
An ``http(s)`` URL
Returns:
str:
The corresponding ``ws(s)`` URL ending in ``/ws``
Raises:
... | [
"def",
"websocket_url_for_server_url",
"(",
"url",
")",
":",
"if",
"url",
".",
"startswith",
"(",
"\"http:\"",
")",
":",
"reprotocoled",
"=",
"\"ws\"",
"+",
"url",
"[",
"4",
":",
"]",
"elif",
"url",
".",
"startswith",
"(",
"\"https:\"",
")",
":",
"reprot... | Convert an ``http(s)`` URL for a Bokeh server websocket endpoint into
the appropriate ``ws(s)`` URL
Args:
url (str):
An ``http(s)`` URL
Returns:
str:
The corresponding ``ws(s)`` URL ending in ``/ws``
Raises:
ValueError:
If the input URL is n... | [
"Convert",
"an",
"http",
"(",
"s",
")",
"URL",
"for",
"a",
"Bokeh",
"server",
"websocket",
"endpoint",
"into",
"the",
"appropriate",
"ws",
"(",
"s",
")",
"URL"
] | python | train |
angr/angr | angr/state_plugins/uc_manager.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/uc_manager.py#L33-L52 | def assign(self, dst_addr_ast):
"""
Assign a new region for under-constrained symbolic execution.
:param dst_addr_ast: the symbolic AST which address of the new allocated region will be assigned to.
:return: as ast of memory address that points to a new region
"""
if ds... | [
"def",
"assign",
"(",
"self",
",",
"dst_addr_ast",
")",
":",
"if",
"dst_addr_ast",
".",
"uc_alloc_depth",
">",
"self",
".",
"_max_alloc_depth",
":",
"raise",
"SimUCManagerAllocationError",
"(",
"'Current allocation depth %d is greater than the cap (%d)'",
"%",
"(",
"dst... | Assign a new region for under-constrained symbolic execution.
:param dst_addr_ast: the symbolic AST which address of the new allocated region will be assigned to.
:return: as ast of memory address that points to a new region | [
"Assign",
"a",
"new",
"region",
"for",
"under",
"-",
"constrained",
"symbolic",
"execution",
"."
] | python | train |
shoebot/shoebot | lib/web/wikipedia.py | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/wikipedia.py#L674-L709 | def parse_links(self, markup):
""" Returns a list of internal Wikipedia links in the markup.
# A Wikipedia link looks like:
# [[List of operating systems#Embedded | List of embedded operating systems]]
# It does not contain a colon, this indicates images, users, languages, etc.... | [
"def",
"parse_links",
"(",
"self",
",",
"markup",
")",
":",
"links",
"=",
"[",
"]",
"m",
"=",
"re",
".",
"findall",
"(",
"self",
".",
"re",
"[",
"\"link\"",
"]",
",",
"markup",
")",
"for",
"link",
"in",
"m",
":",
"# We don't like [[{{{1|Universe (disam... | Returns a list of internal Wikipedia links in the markup.
# A Wikipedia link looks like:
# [[List of operating systems#Embedded | List of embedded operating systems]]
# It does not contain a colon, this indicates images, users, languages, etc.
The return value is a list contain... | [
"Returns",
"a",
"list",
"of",
"internal",
"Wikipedia",
"links",
"in",
"the",
"markup",
"."
] | python | valid |
saltstack/salt | salt/modules/boto_apigateway.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_apigateway.py#L427-L443 | def describe_api_key(apiKey, region=None, key=None, keyid=None, profile=None):
'''
Gets info about the given api key
CLI Example:
.. code-block:: bash
salt myminion boto_apigateway.describe_api_key apigw_api_key
'''
try:
conn = _get_conn(region=region, key=key, keyid=keyid, p... | [
"def",
"describe_api_key",
"(",
"apiKey",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"try",
":",
"conn",
"=",
"_get_conn",
"(",
"region",
"=",
"region",
",",
"key",
"=",
"k... | Gets info about the given api key
CLI Example:
.. code-block:: bash
salt myminion boto_apigateway.describe_api_key apigw_api_key | [
"Gets",
"info",
"about",
"the",
"given",
"api",
"key"
] | python | train |
eerimoq/bincopy | bincopy.py | https://github.com/eerimoq/bincopy/blob/5e02cd001c3e9b54729425db6bffad5f03e1beac/bincopy.py#L1358-L1373 | def crop(self, minimum_address, maximum_address):
"""Keep given range and discard the rest.
`minimum_address` is the first word address to keep
(including).
`maximum_address` is the last word address to keep
(excluding).
"""
minimum_address *= self.word_size_b... | [
"def",
"crop",
"(",
"self",
",",
"minimum_address",
",",
"maximum_address",
")",
":",
"minimum_address",
"*=",
"self",
".",
"word_size_bytes",
"maximum_address",
"*=",
"self",
".",
"word_size_bytes",
"maximum_address_address",
"=",
"self",
".",
"_segments",
".",
"... | Keep given range and discard the rest.
`minimum_address` is the first word address to keep
(including).
`maximum_address` is the last word address to keep
(excluding). | [
"Keep",
"given",
"range",
"and",
"discard",
"the",
"rest",
"."
] | python | train |
Legobot/Legobot | Legobot/Connectors/IRC.py | https://github.com/Legobot/Legobot/blob/d13da172960a149681cb5151ce34b2f3a58ad32b/Legobot/Connectors/IRC.py#L122-L131 | def on_privmsg(self, c, e):
"""
This function runs when the bot receives a private message (query).
"""
text = e.arguments[0]
logger.debug('{0!s}'.format(e.source))
metadata = self.set_metadata(e)
metadata['is_private_message'] = True
message = Message(tex... | [
"def",
"on_privmsg",
"(",
"self",
",",
"c",
",",
"e",
")",
":",
"text",
"=",
"e",
".",
"arguments",
"[",
"0",
"]",
"logger",
".",
"debug",
"(",
"'{0!s}'",
".",
"format",
"(",
"e",
".",
"source",
")",
")",
"metadata",
"=",
"self",
".",
"set_metada... | This function runs when the bot receives a private message (query). | [
"This",
"function",
"runs",
"when",
"the",
"bot",
"receives",
"a",
"private",
"message",
"(",
"query",
")",
"."
] | python | train |
PmagPy/PmagPy | SPD/lib/lib_tail_check_statistics.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/SPD/lib/lib_tail_check_statistics.py#L58-L66 | def get_delta_TR(tail_check_max, y_int):
"""
input: tail_check_max, y_intercept
output: delta_TR
"""
if tail_check_max == 0 or numpy.isnan(tail_check_max):
return float('nan')
delta_TR = (old_div(tail_check_max, abs(y_int))) * 100.
return delta_TR | [
"def",
"get_delta_TR",
"(",
"tail_check_max",
",",
"y_int",
")",
":",
"if",
"tail_check_max",
"==",
"0",
"or",
"numpy",
".",
"isnan",
"(",
"tail_check_max",
")",
":",
"return",
"float",
"(",
"'nan'",
")",
"delta_TR",
"=",
"(",
"old_div",
"(",
"tail_check_m... | input: tail_check_max, y_intercept
output: delta_TR | [
"input",
":",
"tail_check_max",
"y_intercept",
"output",
":",
"delta_TR"
] | python | train |
erdewit/ib_insync | ib_insync/ib.py | https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ib.py#L1563-L1571 | def replaceFA(self, faDataType: int, xml: str):
"""
Replaces Financial Advisor's settings.
Args:
faDataType: See :meth:`.requestFA`.
xml: The XML-formatted configuration string.
"""
self.client.replaceFA(faDataType, xml) | [
"def",
"replaceFA",
"(",
"self",
",",
"faDataType",
":",
"int",
",",
"xml",
":",
"str",
")",
":",
"self",
".",
"client",
".",
"replaceFA",
"(",
"faDataType",
",",
"xml",
")"
] | Replaces Financial Advisor's settings.
Args:
faDataType: See :meth:`.requestFA`.
xml: The XML-formatted configuration string. | [
"Replaces",
"Financial",
"Advisor",
"s",
"settings",
"."
] | python | train |
bpannier/simpletr64 | simpletr64/devicetr64.py | https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/devicetr64.py#L591-L642 | def loadDeviceDefinitions(self, urlOfXMLDefinition, timeout=3):
"""Loads the device definitions from a given URL which points to the root XML in the device.
This loads the device definitions which is needed in case you like to:
* get additional information's about the device like manufacture, ... | [
"def",
"loadDeviceDefinitions",
"(",
"self",
",",
"urlOfXMLDefinition",
",",
"timeout",
"=",
"3",
")",
":",
"# setup proxies",
"proxies",
"=",
"{",
"}",
"if",
"self",
".",
"__httpsProxy",
":",
"proxies",
"=",
"{",
"\"https\"",
":",
"self",
".",
"__httpsProxy... | Loads the device definitions from a given URL which points to the root XML in the device.
This loads the device definitions which is needed in case you like to:
* get additional information's about the device like manufacture, device type, etc
* get all support service types of this device
... | [
"Loads",
"the",
"device",
"definitions",
"from",
"a",
"given",
"URL",
"which",
"points",
"to",
"the",
"root",
"XML",
"in",
"the",
"device",
"."
] | python | train |
twilio/twilio-python | twilio/rest/ip_messaging/v1/service/channel/__init__.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/ip_messaging/v1/service/channel/__init__.py#L157-L166 | def get(self, sid):
"""
Constructs a ChannelContext
:param sid: The sid
:returns: twilio.rest.chat.v1.service.channel.ChannelContext
:rtype: twilio.rest.chat.v1.service.channel.ChannelContext
"""
return ChannelContext(self._version, service_sid=self._solution['s... | [
"def",
"get",
"(",
"self",
",",
"sid",
")",
":",
"return",
"ChannelContext",
"(",
"self",
".",
"_version",
",",
"service_sid",
"=",
"self",
".",
"_solution",
"[",
"'service_sid'",
"]",
",",
"sid",
"=",
"sid",
",",
")"
] | Constructs a ChannelContext
:param sid: The sid
:returns: twilio.rest.chat.v1.service.channel.ChannelContext
:rtype: twilio.rest.chat.v1.service.channel.ChannelContext | [
"Constructs",
"a",
"ChannelContext"
] | python | train |
Cologler/fsoopify-python | fsoopify/paths.py | https://github.com/Cologler/fsoopify-python/blob/83d45f16ae9abdea4fcc829373c32df501487dda/fsoopify/paths.py#L152-L160 | def from_caller_file():
'''return a `Path` from the path of caller file'''
import inspect
curframe = inspect.currentframe()
calframe = inspect.getouterframes(curframe, 2)
filename = calframe[1].filename
if not os.path.isfile(filename):
raise RuntimeError('call... | [
"def",
"from_caller_file",
"(",
")",
":",
"import",
"inspect",
"curframe",
"=",
"inspect",
".",
"currentframe",
"(",
")",
"calframe",
"=",
"inspect",
".",
"getouterframes",
"(",
"curframe",
",",
"2",
")",
"filename",
"=",
"calframe",
"[",
"1",
"]",
".",
... | return a `Path` from the path of caller file | [
"return",
"a",
"Path",
"from",
"the",
"path",
"of",
"caller",
"file"
] | python | train |
mapbox/mapboxgl-jupyter | mapboxgl/utils.py | https://github.com/mapbox/mapboxgl-jupyter/blob/f6e403c13eaa910e70659c7d179e8e32ce95ae34/mapboxgl/utils.py#L188-L228 | def create_color_stops(breaks, colors='RdYlGn', color_ramps=color_ramps):
"""Convert a list of breaks into color stops using colors from colorBrewer
or a custom list of color values in RGB, RGBA, HSL, CSS text, or HEX format.
See www.colorbrewer2.org for a list of color options to pass
"""
num_brea... | [
"def",
"create_color_stops",
"(",
"breaks",
",",
"colors",
"=",
"'RdYlGn'",
",",
"color_ramps",
"=",
"color_ramps",
")",
":",
"num_breaks",
"=",
"len",
"(",
"breaks",
")",
"stops",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"colors",
",",
"list",
")",
":",
... | Convert a list of breaks into color stops using colors from colorBrewer
or a custom list of color values in RGB, RGBA, HSL, CSS text, or HEX format.
See www.colorbrewer2.org for a list of color options to pass | [
"Convert",
"a",
"list",
"of",
"breaks",
"into",
"color",
"stops",
"using",
"colors",
"from",
"colorBrewer",
"or",
"a",
"custom",
"list",
"of",
"color",
"values",
"in",
"RGB",
"RGBA",
"HSL",
"CSS",
"text",
"or",
"HEX",
"format",
".",
"See",
"www",
".",
... | python | train |
agoragames/chai | chai/stub.py | https://github.com/agoragames/chai/blob/8148d7b7754226b0d1cabfc2af10cd912612abdc/chai/stub.py#L263-L269 | def expect(self):
'''
Add an expectation to this stub. Return the expectation.
'''
exp = Expectation(self)
self._expectations.append(exp)
return exp | [
"def",
"expect",
"(",
"self",
")",
":",
"exp",
"=",
"Expectation",
"(",
"self",
")",
"self",
".",
"_expectations",
".",
"append",
"(",
"exp",
")",
"return",
"exp"
] | Add an expectation to this stub. Return the expectation. | [
"Add",
"an",
"expectation",
"to",
"this",
"stub",
".",
"Return",
"the",
"expectation",
"."
] | python | train |
numenta/nupic | src/nupic/regions/tm_region.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/regions/tm_region.py#L65-L114 | def _buildArgs(f, self=None, kwargs={}):
"""
Get the default arguments from the function and assign as instance vars.
Return a list of 3-tuples with (name, description, defaultValue) for each
argument to the function.
Assigns all arguments to the function as instance variables of TMRegion.
If the argume... | [
"def",
"_buildArgs",
"(",
"f",
",",
"self",
"=",
"None",
",",
"kwargs",
"=",
"{",
"}",
")",
":",
"# Get the name, description, and default value for each argument",
"argTuples",
"=",
"getArgumentDescriptions",
"(",
"f",
")",
"argTuples",
"=",
"argTuples",
"[",
"1"... | Get the default arguments from the function and assign as instance vars.
Return a list of 3-tuples with (name, description, defaultValue) for each
argument to the function.
Assigns all arguments to the function as instance variables of TMRegion.
If the argument was not provided, uses the default value.
P... | [
"Get",
"the",
"default",
"arguments",
"from",
"the",
"function",
"and",
"assign",
"as",
"instance",
"vars",
"."
] | python | valid |
lsbardel/python-stdnet | stdnet/utils/jsontools.py | https://github.com/lsbardel/python-stdnet/blob/78db5320bdedc3f28c5e4f38cda13a4469e35db7/stdnet/utils/jsontools.py#L98-L154 | def flat_to_nested(data, instance=None, attname=None,
separator=None, loads=None):
'''Convert a flat representation of a dictionary to
a nested representation. Fields in the flat representation are separated
by the *splitter* parameters.
:parameter data: a flat dictionary of key value pairs.
:pa... | [
"def",
"flat_to_nested",
"(",
"data",
",",
"instance",
"=",
"None",
",",
"attname",
"=",
"None",
",",
"separator",
"=",
"None",
",",
"loads",
"=",
"None",
")",
":",
"separator",
"=",
"separator",
"or",
"JSPLITTER",
"val",
"=",
"{",
"}",
"flat_vals",
"=... | Convert a flat representation of a dictionary to
a nested representation. Fields in the flat representation are separated
by the *splitter* parameters.
:parameter data: a flat dictionary of key value pairs.
:parameter instance: optional instance of a model.
:parameter attribute: optional attribute of a model.
:paramet... | [
"Convert",
"a",
"flat",
"representation",
"of",
"a",
"dictionary",
"to",
"a",
"nested",
"representation",
".",
"Fields",
"in",
"the",
"flat",
"representation",
"are",
"separated",
"by",
"the",
"*",
"splitter",
"*",
"parameters",
"."
] | python | train |
gem/oq-engine | openquake/hmtk/seismicity/catalogue.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/seismicity/catalogue.py#L192-L221 | def write_catalogue(self, output_file, key_list=SORTED_ATTRIBUTE_LIST):
"""
Writes the catalogue to file using HTMK format (CSV).
:param output_file:
Name of the output file
:param key_list:
Optional list of attribute keys to be exported
"""
with... | [
"def",
"write_catalogue",
"(",
"self",
",",
"output_file",
",",
"key_list",
"=",
"SORTED_ATTRIBUTE_LIST",
")",
":",
"with",
"open",
"(",
"output_file",
",",
"'w'",
")",
"as",
"of",
":",
"writer",
"=",
"csv",
".",
"DictWriter",
"(",
"of",
",",
"fieldnames",... | Writes the catalogue to file using HTMK format (CSV).
:param output_file:
Name of the output file
:param key_list:
Optional list of attribute keys to be exported | [
"Writes",
"the",
"catalogue",
"to",
"file",
"using",
"HTMK",
"format",
"(",
"CSV",
")",
"."
] | python | train |
PiotrDabkowski/Js2Py | js2py/legecy_translators/nodevisitor.py | https://github.com/PiotrDabkowski/Js2Py/blob/c0fa43f5679cf91ca8986c5747fcb07a433dc584/js2py/legecy_translators/nodevisitor.py#L75-L261 | def translate(self):
"""Translates outer operation and calls translate on inner operation.
Returns fully translated code."""
if not self.code:
return ''
new = bracket_replace(self.code)
#Check comma operator:
cand = new.split(',') #every comma in new must ... | [
"def",
"translate",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"code",
":",
"return",
"''",
"new",
"=",
"bracket_replace",
"(",
"self",
".",
"code",
")",
"#Check comma operator:",
"cand",
"=",
"new",
".",
"split",
"(",
"','",
")",
"#every comma in ... | Translates outer operation and calls translate on inner operation.
Returns fully translated code. | [
"Translates",
"outer",
"operation",
"and",
"calls",
"translate",
"on",
"inner",
"operation",
".",
"Returns",
"fully",
"translated",
"code",
"."
] | python | valid |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/tailf_confd_monitoring.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/tailf_confd_monitoring.py#L3119-L3131 | def confd_state_internal_cdb_client_lock(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
confd_state = ET.SubElement(config, "confd-state", xmlns="http://tail-f.com/yang/confd-monitoring")
internal = ET.SubElement(confd_state, "internal")
cdb = E... | [
"def",
"confd_state_internal_cdb_client_lock",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"confd_state",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"confd-state\"",
",",
"xmlns",
"=",... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
EventTeam/beliefs | src/beliefs/cells/lazy.py | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/lazy.py#L42-L52 | def size(self):
"""
Size of LazyCell: the size of the intension plus accounting for
excluded and included additions.
The exclusions are assumed to be part of the set
The inclusions are assumed to NOT be part of the intension
"""
return self._size_full_intension ... | [
"def",
"size",
"(",
"self",
")",
":",
"return",
"self",
".",
"_size_full_intension",
"-",
"len",
"(",
"self",
".",
"exclude",
")",
"+",
"len",
"(",
"self",
".",
"include",
")"
] | Size of LazyCell: the size of the intension plus accounting for
excluded and included additions.
The exclusions are assumed to be part of the set
The inclusions are assumed to NOT be part of the intension | [
"Size",
"of",
"LazyCell",
":",
"the",
"size",
"of",
"the",
"intension",
"plus",
"accounting",
"for",
"excluded",
"and",
"included",
"additions",
"."
] | python | train |
goshuirc/irc | girc/client.py | https://github.com/goshuirc/irc/blob/d6a5e3e04d337566c009b087f108cd76f9e122cc/girc/client.py#L548-L559 | def nickserv_identify(self, password, use_nick=None):
"""Identify to NickServ (legacy)."""
if self.ready:
if use_nick:
self.msg(use_nick, 'IDENTIFY {}'.format(password))
else:
self.send('NICKSERV', params=['IDENTIFY', password])
else:
... | [
"def",
"nickserv_identify",
"(",
"self",
",",
"password",
",",
"use_nick",
"=",
"None",
")",
":",
"if",
"self",
".",
"ready",
":",
"if",
"use_nick",
":",
"self",
".",
"msg",
"(",
"use_nick",
",",
"'IDENTIFY {}'",
".",
"format",
"(",
"password",
")",
")... | Identify to NickServ (legacy). | [
"Identify",
"to",
"NickServ",
"(",
"legacy",
")",
"."
] | python | train |
ZEDGR/pychal | challonge/api.py | https://github.com/ZEDGR/pychal/blob/3600fa9e0557a2a14eb1ad0c0711d28dad3693d7/challonge/api.py#L100-L132 | def _parse(data):
"""Recursively convert a json into python data types"""
if not data:
return []
elif isinstance(data, (tuple, list)):
return [_parse(subdata) for subdata in data]
# extract the nested dict. ex. {"tournament": {"url": "7k1safq" ...}}
d = {ik: v for k in data.keys() ... | [
"def",
"_parse",
"(",
"data",
")",
":",
"if",
"not",
"data",
":",
"return",
"[",
"]",
"elif",
"isinstance",
"(",
"data",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"return",
"[",
"_parse",
"(",
"subdata",
")",
"for",
"subdata",
"in",
"data",
... | Recursively convert a json into python data types | [
"Recursively",
"convert",
"a",
"json",
"into",
"python",
"data",
"types"
] | python | train |
GoogleCloudPlatform/compute-image-packages | packages/python-google-compute-engine/google_compute_engine/distro_lib/ip_forwarding_utils.py | https://github.com/GoogleCloudPlatform/compute-image-packages/blob/53ea8cd069fb4d9a1984d1c167e54c133033f8da/packages/python-google-compute-engine/google_compute_engine/distro_lib/ip_forwarding_utils.py#L262-L282 | def GetForwardedIps(self, interface, interface_ip=None):
"""Retrieve the list of configured forwarded IP addresses.
Args:
interface: string, the output device to query.
interface_ip: string, current interface ip address.
Returns:
list, the IP address strings.
"""
try:
ips =... | [
"def",
"GetForwardedIps",
"(",
"self",
",",
"interface",
",",
"interface_ip",
"=",
"None",
")",
":",
"try",
":",
"ips",
"=",
"netifaces",
".",
"ifaddresses",
"(",
"interface",
")",
"ips",
"=",
"ips",
"[",
"netifaces",
".",
"AF_INET",
"]",
"except",
"(",
... | Retrieve the list of configured forwarded IP addresses.
Args:
interface: string, the output device to query.
interface_ip: string, current interface ip address.
Returns:
list, the IP address strings. | [
"Retrieve",
"the",
"list",
"of",
"configured",
"forwarded",
"IP",
"addresses",
"."
] | python | train |
hyperledger/indy-sdk | wrappers/python/indy/ledger.py | https://github.com/hyperledger/indy-sdk/blob/55240dc170308d7883c48f03f308130a6d077be6/wrappers/python/indy/ledger.py#L981-L1018 | async def parse_get_revoc_reg_def_response(get_revoc_ref_def_response: str) -> (str, str):
"""
Parse a GET_REVOC_REG_DEF response to get Revocation Registry Definition in the format compatible with Anoncreds API.
:param get_revoc_ref_def_response: response of GET_REVOC_REG_DEF request.
:return: Revocat... | [
"async",
"def",
"parse_get_revoc_reg_def_response",
"(",
"get_revoc_ref_def_response",
":",
"str",
")",
"->",
"(",
"str",
",",
"str",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"debug",
"(",
"\"parse_get_revoc_reg_... | Parse a GET_REVOC_REG_DEF response to get Revocation Registry Definition in the format compatible with Anoncreds API.
:param get_revoc_ref_def_response: response of GET_REVOC_REG_DEF request.
:return: Revocation Registry Definition Id and Revocation Registry Definition json.
{
"id": string - ID... | [
"Parse",
"a",
"GET_REVOC_REG_DEF",
"response",
"to",
"get",
"Revocation",
"Registry",
"Definition",
"in",
"the",
"format",
"compatible",
"with",
"Anoncreds",
"API",
"."
] | python | train |
pkgw/pwkit | pwkit/lmmin.py | https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/lmmin.py#L2511-L2529 | def _lmder1_rosenbrock():
"""Rosenbrock function (lmder test #4)"""
def func(params, vec):
vec[0] = 10 * (params[1] - params[0]**2)
vec[1] = 1 - params[0]
def jac(params, jac):
jac[0,0] = -20 * params[0]
jac[0,1] = -1
jac[1,0] = 10
jac[1,1] = 0
guess = ... | [
"def",
"_lmder1_rosenbrock",
"(",
")",
":",
"def",
"func",
"(",
"params",
",",
"vec",
")",
":",
"vec",
"[",
"0",
"]",
"=",
"10",
"*",
"(",
"params",
"[",
"1",
"]",
"-",
"params",
"[",
"0",
"]",
"**",
"2",
")",
"vec",
"[",
"1",
"]",
"=",
"1"... | Rosenbrock function (lmder test #4) | [
"Rosenbrock",
"function",
"(",
"lmder",
"test",
"#4",
")"
] | python | train |
kislyuk/aegea | aegea/packages/github3/repos/release.py | https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/repos/release.py#L169-L197 | def download(self, path=''):
"""Download the data for this asset.
:param path: (optional), path where the file should be saved
to, default is the filename provided in the headers and will be
written in the current directory.
it can take a file-like object as well
... | [
"def",
"download",
"(",
"self",
",",
"path",
"=",
"''",
")",
":",
"headers",
"=",
"{",
"'Accept'",
":",
"'application/octet-stream'",
"}",
"resp",
"=",
"self",
".",
"_get",
"(",
"self",
".",
"_api",
",",
"allow_redirects",
"=",
"False",
",",
"stream",
... | Download the data for this asset.
:param path: (optional), path where the file should be saved
to, default is the filename provided in the headers and will be
written in the current directory.
it can take a file-like object as well
:type path: str, file
:retu... | [
"Download",
"the",
"data",
"for",
"this",
"asset",
"."
] | python | train |
programa-stic/barf-project | barf/arch/x86/translator.py | https://github.com/programa-stic/barf-project/blob/18ed9e5eace55f7bf6015ec57f037c364099021c/barf/arch/x86/translator.py#L261-L322 | def resolve_memory_access(self, tb, x86_mem_operand):
"""Return operand memory access translation.
"""
size = self.__get_memory_access_size(x86_mem_operand)
addr = None
if x86_mem_operand.base:
addr = ReilRegisterOperand(x86_mem_operand.base, size)
if x86_m... | [
"def",
"resolve_memory_access",
"(",
"self",
",",
"tb",
",",
"x86_mem_operand",
")",
":",
"size",
"=",
"self",
".",
"__get_memory_access_size",
"(",
"x86_mem_operand",
")",
"addr",
"=",
"None",
"if",
"x86_mem_operand",
".",
"base",
":",
"addr",
"=",
"ReilRegis... | Return operand memory access translation. | [
"Return",
"operand",
"memory",
"access",
"translation",
"."
] | python | train |
avelino/bottle-auth | bottle_auth/core/auth.py | https://github.com/avelino/bottle-auth/blob/db07e526864aeac05ee68444b47e5db29540ce18/bottle_auth/core/auth.py#L142-L146 | def require_setting(self, name, feature="this feature"):
"""Raises an exception if the given app setting is not defined."""
if name not in self.settings:
raise Exception("You must define the '%s' setting in your "
"application to use %s" % (name, feature)) | [
"def",
"require_setting",
"(",
"self",
",",
"name",
",",
"feature",
"=",
"\"this feature\"",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"settings",
":",
"raise",
"Exception",
"(",
"\"You must define the '%s' setting in your \"",
"\"application to use %s\"",
"... | Raises an exception if the given app setting is not defined. | [
"Raises",
"an",
"exception",
"if",
"the",
"given",
"app",
"setting",
"is",
"not",
"defined",
"."
] | python | test |
orbingol/NURBS-Python | geomdl/helpers.py | https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/helpers.py#L71-L91 | def find_span_linear(degree, knot_vector, num_ctrlpts, knot, **kwargs):
""" Finds the span of a single knot over the knot vector using linear search.
Alternative implementation for the Algorithm A2.1 from The NURBS Book by Piegl & Tiller.
:param degree: degree, :math:`p`
:type degree: int
:param k... | [
"def",
"find_span_linear",
"(",
"degree",
",",
"knot_vector",
",",
"num_ctrlpts",
",",
"knot",
",",
"*",
"*",
"kwargs",
")",
":",
"span",
"=",
"0",
"# Knot span index starts from zero",
"while",
"span",
"<",
"num_ctrlpts",
"and",
"knot_vector",
"[",
"span",
"]... | Finds the span of a single knot over the knot vector using linear search.
Alternative implementation for the Algorithm A2.1 from The NURBS Book by Piegl & Tiller.
:param degree: degree, :math:`p`
:type degree: int
:param knot_vector: knot vector, :math:`U`
:type knot_vector: list, tuple
:param... | [
"Finds",
"the",
"span",
"of",
"a",
"single",
"knot",
"over",
"the",
"knot",
"vector",
"using",
"linear",
"search",
"."
] | python | train |
chrislit/abydos | abydos/corpus/_ngram_corpus.py | https://github.com/chrislit/abydos/blob/165466b3ff6afd8024a4c8660421b0c4e7773db9/abydos/corpus/_ngram_corpus.py#L222-L258 | def tf(self, term):
r"""Return term frequency.
Parameters
----------
term : str
The term for which to calculate tf
Returns
-------
float
The term frequency (tf)
Raises
------
ValueError
tf can only cal... | [
"def",
"tf",
"(",
"self",
",",
"term",
")",
":",
"if",
"' '",
"in",
"term",
":",
"raise",
"ValueError",
"(",
"'tf can only calculate the term frequency of individual words'",
")",
"tcount",
"=",
"self",
".",
"get_count",
"(",
"term",
")",
"if",
"tcount",
"==",... | r"""Return term frequency.
Parameters
----------
term : str
The term for which to calculate tf
Returns
-------
float
The term frequency (tf)
Raises
------
ValueError
tf can only calculate the frequency of indi... | [
"r",
"Return",
"term",
"frequency",
"."
] | python | valid |
ibis-project/ibis | ibis/mapd/client.py | https://github.com/ibis-project/ibis/blob/1e39a5fd9ef088b45c155e8a5f541767ee8ef2e7/ibis/mapd/client.py#L473-L483 | def create_database(self, name, owner=None):
"""
Create a new MapD database
Parameters
----------
name : string
Database name
"""
statement = ddl.CreateDatabase(name, owner=owner)
self._execute(statement) | [
"def",
"create_database",
"(",
"self",
",",
"name",
",",
"owner",
"=",
"None",
")",
":",
"statement",
"=",
"ddl",
".",
"CreateDatabase",
"(",
"name",
",",
"owner",
"=",
"owner",
")",
"self",
".",
"_execute",
"(",
"statement",
")"
] | Create a new MapD database
Parameters
----------
name : string
Database name | [
"Create",
"a",
"new",
"MapD",
"database"
] | python | train |
jeffh/describe | describe/spec/containers.py | https://github.com/jeffh/describe/blob/6a33ffecc3340b57e60bc8a7095521882ff9a156/describe/spec/containers.py#L175-L178 | def before(self, context):
"Invokes all before functions with context passed to them."
run.before_each.execute(context)
self._invoke(self._before, context) | [
"def",
"before",
"(",
"self",
",",
"context",
")",
":",
"run",
".",
"before_each",
".",
"execute",
"(",
"context",
")",
"self",
".",
"_invoke",
"(",
"self",
".",
"_before",
",",
"context",
")"
] | Invokes all before functions with context passed to them. | [
"Invokes",
"all",
"before",
"functions",
"with",
"context",
"passed",
"to",
"them",
"."
] | python | train |
lago-project/lago | lago/workdir.py | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/workdir.py#L258-L284 | def add_prefix(self, name, *args, **kwargs):
"""
Adds a new prefix to the workdir.
Args:
name(str): Name of the new prefix to add
*args: args to pass along to the prefix constructor
*kwargs: kwargs to pass along to the prefix constructor
Returns:
... | [
"def",
"add_prefix",
"(",
"self",
",",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"join",
"(",
"name",
")",
")",
":",
"raise",
"LagoPrefixAlreadyExistsError",
"(",
"name",
... | Adds a new prefix to the workdir.
Args:
name(str): Name of the new prefix to add
*args: args to pass along to the prefix constructor
*kwargs: kwargs to pass along to the prefix constructor
Returns:
The newly created prefix
Raises:
La... | [
"Adds",
"a",
"new",
"prefix",
"to",
"the",
"workdir",
"."
] | python | train |
google/prettytensor | prettytensor/recurrent_networks.py | https://github.com/google/prettytensor/blob/75daa0b11252590f548da5647addc0ea610c4c45/prettytensor/recurrent_networks.py#L554-L573 | def create_sequence_pretty_tensor(sequence_input, shape=None, save_state=True):
"""Creates a PrettyTensor object for the given sequence.
The first dimension is treated as a time-dimension * batch and a default is
set for `unroll` and `state_saver`.
TODO(eiderman): Remove shape.
Args:
sequence_input: A ... | [
"def",
"create_sequence_pretty_tensor",
"(",
"sequence_input",
",",
"shape",
"=",
"None",
",",
"save_state",
"=",
"True",
")",
":",
"inputs",
"=",
"prettytensor",
".",
"wrap_sequence",
"(",
"sequence_input",
".",
"inputs",
",",
"tensor_shape",
"=",
"shape",
")",... | Creates a PrettyTensor object for the given sequence.
The first dimension is treated as a time-dimension * batch and a default is
set for `unroll` and `state_saver`.
TODO(eiderman): Remove shape.
Args:
sequence_input: A SequenceInput or StateSavingSequenceInput
shape: The shape of each item in the se... | [
"Creates",
"a",
"PrettyTensor",
"object",
"for",
"the",
"given",
"sequence",
"."
] | python | train |
DLR-RM/RAFCON | source/rafcon/gui/models/abstract_state.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/models/abstract_state.py#L466-L522 | def load_meta_data(self, path=None):
"""Load meta data of state model from the file system
The meta data of the state model is loaded from the file system and stored in the meta property of the model.
Existing meta data is removed. Also the meta data of all state elements (data ports, outcomes,... | [
"def",
"load_meta_data",
"(",
"self",
",",
"path",
"=",
"None",
")",
":",
"# TODO: for an Execution state this method is called for each hierarchy level again and again, still?? check it!",
"# print(\"1AbstractState_load_meta_data: \", path, not path)",
"if",
"not",
"path",
":",
"pat... | Load meta data of state model from the file system
The meta data of the state model is loaded from the file system and stored in the meta property of the model.
Existing meta data is removed. Also the meta data of all state elements (data ports, outcomes,
etc) are loaded, as those stored in the... | [
"Load",
"meta",
"data",
"of",
"state",
"model",
"from",
"the",
"file",
"system"
] | python | train |
sergiocorreia/panflute | panflute/tools.py | https://github.com/sergiocorreia/panflute/blob/65c2d570c26a190deb600cab5e2ad8a828a3302e/panflute/tools.py#L173-L207 | def stringify(element, newlines=True):
"""
Return the raw text version of an elements (and its children element).
Example:
>>> from panflute import *
>>> e1 = Emph(Str('Hello'), Space, Str('world!'))
>>> e2 = Strong(Str('Bye!'))
>>> para = Para(e1, Space, e2)
>>> st... | [
"def",
"stringify",
"(",
"element",
",",
"newlines",
"=",
"True",
")",
":",
"def",
"attach_str",
"(",
"e",
",",
"doc",
",",
"answer",
")",
":",
"if",
"hasattr",
"(",
"e",
",",
"'text'",
")",
":",
"ans",
"=",
"e",
".",
"text",
"elif",
"isinstance",
... | Return the raw text version of an elements (and its children element).
Example:
>>> from panflute import *
>>> e1 = Emph(Str('Hello'), Space, Str('world!'))
>>> e2 = Strong(Str('Bye!'))
>>> para = Para(e1, Space, e2)
>>> stringify(para)
'Hello world! Bye!\n\n'
... | [
"Return",
"the",
"raw",
"text",
"version",
"of",
"an",
"elements",
"(",
"and",
"its",
"children",
"element",
")",
"."
] | python | train |
apache/incubator-heron | heron/tools/ui/src/python/handlers/api/topology.py | https://github.com/apache/incubator-heron/blob/ad10325a0febe89ad337e561ebcbe37ec5d9a5ac/heron/tools/ui/src/python/handlers/api/topology.py#L148-L167 | def get(self, cluster, environ, topology):
'''
:param cluster:
:param environ:
:param topology:
:return:
'''
start_time = time.time()
pplan = yield access.get_physical_plan(cluster, environ, topology)
result_map = dict(
status="success",
message="",
version=... | [
"def",
"get",
"(",
"self",
",",
"cluster",
",",
"environ",
",",
"topology",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"pplan",
"=",
"yield",
"access",
".",
"get_physical_plan",
"(",
"cluster",
",",
"environ",
",",
"topology",
")",
"re... | :param cluster:
:param environ:
:param topology:
:return: | [
":",
"param",
"cluster",
":",
":",
"param",
"environ",
":",
":",
"param",
"topology",
":",
":",
"return",
":"
] | python | valid |
facebook/watchman | python/pywatchman_aio/__init__.py | https://github.com/facebook/watchman/blob/d416c249dd8f463dc69fc2691d0f890598c045a9/python/pywatchman_aio/__init__.py#L291-L297 | def close(self):
"""Close the underlying connection."""
self._closed = True
if self.receive_task:
self.receive_task.cancel()
if self.connection:
self.connection.close() | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"_closed",
"=",
"True",
"if",
"self",
".",
"receive_task",
":",
"self",
".",
"receive_task",
".",
"cancel",
"(",
")",
"if",
"self",
".",
"connection",
":",
"self",
".",
"connection",
".",
"close",
"... | Close the underlying connection. | [
"Close",
"the",
"underlying",
"connection",
"."
] | python | train |
gem/oq-engine | openquake/calculators/base.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/base.py#L65-L79 | def fix_ones(pmap):
"""
Physically, an extremely small intensity measure level can have an
extremely large probability of exceedence, however that probability
cannot be exactly 1 unless the level is exactly 0. Numerically, the
PoE can be 1 and this give issues when calculating the damage (there
... | [
"def",
"fix_ones",
"(",
"pmap",
")",
":",
"for",
"sid",
"in",
"pmap",
":",
"array",
"=",
"pmap",
"[",
"sid",
"]",
".",
"array",
"array",
"[",
"array",
"==",
"1.",
"]",
"=",
".9999999999999999",
"return",
"pmap"
] | Physically, an extremely small intensity measure level can have an
extremely large probability of exceedence, however that probability
cannot be exactly 1 unless the level is exactly 0. Numerically, the
PoE can be 1 and this give issues when calculating the damage (there
is a log(0) in
:class:`openq... | [
"Physically",
"an",
"extremely",
"small",
"intensity",
"measure",
"level",
"can",
"have",
"an",
"extremely",
"large",
"probability",
"of",
"exceedence",
"however",
"that",
"probability",
"cannot",
"be",
"exactly",
"1",
"unless",
"the",
"level",
"is",
"exactly",
... | python | train |
pyrogram/pyrogram | pyrogram/client/types/messages_and_media/message.py | https://github.com/pyrogram/pyrogram/blob/e7258a341ba905cfa86264c22040654db732ec1c/pyrogram/client/types/messages_and_media/message.py#L652-L727 | def reply(
self,
text: str,
quote: bool = None,
parse_mode: str = "",
disable_web_page_preview: bool = None,
disable_notification: bool = None,
reply_to_message_id: int = None,
reply_markup=None
) -> "Message":
"""Bound method *reply* of :obj:`... | [
"def",
"reply",
"(",
"self",
",",
"text",
":",
"str",
",",
"quote",
":",
"bool",
"=",
"None",
",",
"parse_mode",
":",
"str",
"=",
"\"\"",
",",
"disable_web_page_preview",
":",
"bool",
"=",
"None",
",",
"disable_notification",
":",
"bool",
"=",
"None",
... | Bound method *reply* of :obj:`Message <pyrogram.Message>`.
Use as a shortcut for:
.. code-block:: python
client.send_message(
chat_id=message.chat.id,
text="hello",
reply_to_message_id=message.message_id
)
Example:
... | [
"Bound",
"method",
"*",
"reply",
"*",
"of",
":",
"obj",
":",
"Message",
"<pyrogram",
".",
"Message",
">",
"."
] | python | train |
pyapi-gitlab/pyapi-gitlab | gitlab/__init__.py | https://github.com/pyapi-gitlab/pyapi-gitlab/blob/f74b6fb5c13cecae9524997847e928905cc60acf/gitlab/__init__.py#L2175-L2193 | def editlabel(self, project_id, name, new_name=None, color=None):
"""
Updates an existing label with new name or now color.
At least one parameter is required, to update the label.
:param project_id: The ID of a project
:param name: The name of the label
:return: True if... | [
"def",
"editlabel",
"(",
"self",
",",
"project_id",
",",
"name",
",",
"new_name",
"=",
"None",
",",
"color",
"=",
"None",
")",
":",
"data",
"=",
"{",
"'name'",
":",
"name",
",",
"'new_name'",
":",
"new_name",
",",
"'color'",
":",
"color",
"}",
"reque... | Updates an existing label with new name or now color.
At least one parameter is required, to update the label.
:param project_id: The ID of a project
:param name: The name of the label
:return: True if succeed | [
"Updates",
"an",
"existing",
"label",
"with",
"new",
"name",
"or",
"now",
"color",
".",
"At",
"least",
"one",
"parameter",
"is",
"required",
"to",
"update",
"the",
"label",
"."
] | python | train |
cocaine/cocaine-tools | cocaine/tools/actions/mql/__init__.py | https://github.com/cocaine/cocaine-tools/blob/d8834f8e04ca42817d5f4e368d471484d4b3419f/cocaine/tools/actions/mql/__init__.py#L186-L205 | def expr(self):
"""
expr ::= term ((AND | OR) term)*
term ::= factor ((EQ | NE) factor)*
factor ::= func | const | LPAREN expr RPAREN
func ::= lit LPAREN expr (,expr)* RPAREN
lit ::= alphanum
"""
node = self.term()
while True:
... | [
"def",
"expr",
"(",
"self",
")",
":",
"node",
"=",
"self",
".",
"term",
"(",
")",
"while",
"True",
":",
"token",
"=",
"self",
".",
"current_token",
"if",
"token",
".",
"type",
"==",
"AND",
":",
"self",
".",
"eat",
"(",
"AND",
")",
"elif",
"token"... | expr ::= term ((AND | OR) term)*
term ::= factor ((EQ | NE) factor)*
factor ::= func | const | LPAREN expr RPAREN
func ::= lit LPAREN expr (,expr)* RPAREN
lit ::= alphanum | [
"expr",
"::",
"=",
"term",
"((",
"AND",
"|",
"OR",
")",
"term",
")",
"*",
"term",
"::",
"=",
"factor",
"((",
"EQ",
"|",
"NE",
")",
"factor",
")",
"*",
"factor",
"::",
"=",
"func",
"|",
"const",
"|",
"LPAREN",
"expr",
"RPAREN",
"func",
"::",
"="... | python | train |
yychen/twd97 | twd97/converter.py | https://github.com/yychen/twd97/blob/2fe05dbca335be425a1f451e0ef8f210ec864de1/twd97/converter.py#L80-L86 | def tomindecstr(origin):
"""
Convert [+/-]DDD.DDDDD to [+/-]DDD°MMM.MMMM'
"""
degrees, minutes = tomindec(origin)
return u'%d°%f\'' % (degrees, minutes) | [
"def",
"tomindecstr",
"(",
"origin",
")",
":",
"degrees",
",",
"minutes",
"=",
"tomindec",
"(",
"origin",
")",
"return",
"u'%d°%f\\'' ",
" ",
"d",
"egrees,",
" ",
"inutes)",
""
] | Convert [+/-]DDD.DDDDD to [+/-]DDD°MMM.MMMM' | [
"Convert",
"[",
"+",
"/",
"-",
"]",
"DDD",
".",
"DDDDD",
"to",
"[",
"+",
"/",
"-",
"]",
"DDD°MMM",
".",
"MMMM"
] | python | train |
thomasjiangcy/django-rest-mock | rest_mock_server/builder.py | https://github.com/thomasjiangcy/django-rest-mock/blob/09e91de20d1a5efd5c47c6e3d7fe979443012e2c/rest_mock_server/builder.py#L177-L245 | def build(port=8000, fixtures=None):
"""
Builds a server file.
1. Extract mock response details from all valid docstrings in existing views
2. Parse and generate mock values
3. Create a store of all endpoints and data
4. Construct server file
"""
extractor = Extractor()
parser = Par... | [
"def",
"build",
"(",
"port",
"=",
"8000",
",",
"fixtures",
"=",
"None",
")",
":",
"extractor",
"=",
"Extractor",
"(",
")",
"parser",
"=",
"Parser",
"(",
"extractor",
".",
"url_details",
",",
"fixtures",
")",
"parser",
".",
"parse",
"(",
")",
"url_detai... | Builds a server file.
1. Extract mock response details from all valid docstrings in existing views
2. Parse and generate mock values
3. Create a store of all endpoints and data
4. Construct server file | [
"Builds",
"a",
"server",
"file",
"."
] | python | train |
Alignak-monitoring/alignak | alignak/objects/satellitelink.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/satellitelink.py#L689-L699 | def stop_request(self, stop_now=False):
"""Send a stop request to the daemon
:param stop_now: stop now or go to stop wait mode
:type stop_now: bool
:return: the daemon response (True)
"""
logger.debug("Sending stop request to %s, stop now: %s", self.name, stop_now)
... | [
"def",
"stop_request",
"(",
"self",
",",
"stop_now",
"=",
"False",
")",
":",
"logger",
".",
"debug",
"(",
"\"Sending stop request to %s, stop now: %s\"",
",",
"self",
".",
"name",
",",
"stop_now",
")",
"res",
"=",
"self",
".",
"con",
".",
"get",
"(",
"'sto... | Send a stop request to the daemon
:param stop_now: stop now or go to stop wait mode
:type stop_now: bool
:return: the daemon response (True) | [
"Send",
"a",
"stop",
"request",
"to",
"the",
"daemon"
] | python | train |
trentm/cmdln | bin/mkmanpage.py | https://github.com/trentm/cmdln/blob/55e980cf52c9b03e62d2349a7e62c9101d08ae10/bin/mkmanpage.py#L18-L24 | def mkmanpage(name):
"""Return man page content for the given `cmdln.Cmdln` subclass name."""
mod_name, class_name = name.rsplit('.', 1)
mod = __import__(mod_name)
inst = getattr(mod, class_name)()
sections = cmdln.man_sections_from_cmdln(inst)
sys.stdout.write(''.join(sections)) | [
"def",
"mkmanpage",
"(",
"name",
")",
":",
"mod_name",
",",
"class_name",
"=",
"name",
".",
"rsplit",
"(",
"'.'",
",",
"1",
")",
"mod",
"=",
"__import__",
"(",
"mod_name",
")",
"inst",
"=",
"getattr",
"(",
"mod",
",",
"class_name",
")",
"(",
")",
"... | Return man page content for the given `cmdln.Cmdln` subclass name. | [
"Return",
"man",
"page",
"content",
"for",
"the",
"given",
"cmdln",
".",
"Cmdln",
"subclass",
"name",
"."
] | python | train |
nabetama/slacky | slacky/rest/rest.py | https://github.com/nabetama/slacky/blob/dde62ce49af9b8f581729c36d2ac790310b570e4/slacky/rest/rest.py#L377-L385 | def info(self, file, **kwargs):
""" https://slack.com/api/files.info
"""
self.params.update({
'file': file,
})
if kwargs:
self.params.update(kwargs)
return FromUrl('https://slack.com/api/files.info', self._requests)(data=self.params).get() | [
"def",
"info",
"(",
"self",
",",
"file",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"params",
".",
"update",
"(",
"{",
"'file'",
":",
"file",
",",
"}",
")",
"if",
"kwargs",
":",
"self",
".",
"params",
".",
"update",
"(",
"kwargs",
")",
"re... | https://slack.com/api/files.info | [
"https",
":",
"//",
"slack",
".",
"com",
"/",
"api",
"/",
"files",
".",
"info"
] | python | train |
Cornices/cornice.ext.swagger | examples/minimalist.py | https://github.com/Cornices/cornice.ext.swagger/blob/c31a5cc8d5dd112b11dc41ccb6d09b423b537abc/examples/minimalist.py#L46-L51 | def set_value(request):
"""Set the value and returns *True* or *False*."""
key = request.matchdict['key']
_VALUES[key] = request.json_body
return _VALUES.get(key) | [
"def",
"set_value",
"(",
"request",
")",
":",
"key",
"=",
"request",
".",
"matchdict",
"[",
"'key'",
"]",
"_VALUES",
"[",
"key",
"]",
"=",
"request",
".",
"json_body",
"return",
"_VALUES",
".",
"get",
"(",
"key",
")"
] | Set the value and returns *True* or *False*. | [
"Set",
"the",
"value",
"and",
"returns",
"*",
"True",
"*",
"or",
"*",
"False",
"*",
"."
] | python | valid |
aaugustin/websockets | src/websockets/headers.py | https://github.com/aaugustin/websockets/blob/17b3f47549b6f752a1be07fa1ba3037cb59c7d56/src/websockets/headers.py#L207-L221 | def parse_upgrade_protocol(
header: str, pos: int, header_name: str
) -> Tuple[UpgradeProtocol, int]:
"""
Parse an Upgrade protocol from ``header`` at the given position.
Return the protocol value and the new position.
Raise :exc:`~websockets.exceptions.InvalidHeaderFormat` on invalid inputs.
... | [
"def",
"parse_upgrade_protocol",
"(",
"header",
":",
"str",
",",
"pos",
":",
"int",
",",
"header_name",
":",
"str",
")",
"->",
"Tuple",
"[",
"UpgradeProtocol",
",",
"int",
"]",
":",
"match",
"=",
"_protocol_re",
".",
"match",
"(",
"header",
",",
"pos",
... | Parse an Upgrade protocol from ``header`` at the given position.
Return the protocol value and the new position.
Raise :exc:`~websockets.exceptions.InvalidHeaderFormat` on invalid inputs. | [
"Parse",
"an",
"Upgrade",
"protocol",
"from",
"header",
"at",
"the",
"given",
"position",
"."
] | python | train |
luismasuelli/django-trackmodels-ritual | grimoire/django/tracked/admin.py | https://github.com/luismasuelli/django-trackmodels-ritual/blob/ee0a6e07a5851ed477c9c1e3b9f8aafd9da35657/grimoire/django/tracked/admin.py#L106-L114 | def get_reporters(self):
"""
Converts the report_generators list to a dictionary, and caches the result.
:return: A dictionary with such references.
"""
if not hasattr(self, '_report_generators_by_key'):
self._report_generators_by_key = {r.key: r for r in self.report... | [
"def",
"get_reporters",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_report_generators_by_key'",
")",
":",
"self",
".",
"_report_generators_by_key",
"=",
"{",
"r",
".",
"key",
":",
"r",
"for",
"r",
"in",
"self",
".",
"report_generato... | Converts the report_generators list to a dictionary, and caches the result.
:return: A dictionary with such references. | [
"Converts",
"the",
"report_generators",
"list",
"to",
"a",
"dictionary",
"and",
"caches",
"the",
"result",
".",
":",
"return",
":",
"A",
"dictionary",
"with",
"such",
"references",
"."
] | python | train |
Gandi/gandi.cli | gandi/cli/commands/mail.py | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/mail.py#L140-L158 | def purge(gandi, email, background, force, alias):
"""Purge a mailbox."""
login, domain = email
if alias:
if not force:
proceed = click.confirm('Are you sure to purge all aliases for '
'mailbox %s@%s ?' % (login, domain))
if not proceed:
... | [
"def",
"purge",
"(",
"gandi",
",",
"email",
",",
"background",
",",
"force",
",",
"alias",
")",
":",
"login",
",",
"domain",
"=",
"email",
"if",
"alias",
":",
"if",
"not",
"force",
":",
"proceed",
"=",
"click",
".",
"confirm",
"(",
"'Are you sure to pu... | Purge a mailbox. | [
"Purge",
"a",
"mailbox",
"."
] | python | train |
projectatomic/atomic-reactor | atomic_reactor/inner.py | https://github.com/projectatomic/atomic-reactor/blob/fd31c01b964097210bf169960d051e5f04019a80/atomic_reactor/inner.py#L531-L578 | def build_inside(input_method, input_args=None, substitutions=None):
"""
use requested input plugin to load configuration and then initiate build
"""
def process_keyvals(keyvals):
""" ["key=val", "x=y"] -> {"key": "val", "x": "y"} """
keyvals = keyvals or []
processed_keyvals = {... | [
"def",
"build_inside",
"(",
"input_method",
",",
"input_args",
"=",
"None",
",",
"substitutions",
"=",
"None",
")",
":",
"def",
"process_keyvals",
"(",
"keyvals",
")",
":",
"\"\"\" [\"key=val\", \"x=y\"] -> {\"key\": \"val\", \"x\": \"y\"} \"\"\"",
"keyvals",
"=",
"keyv... | use requested input plugin to load configuration and then initiate build | [
"use",
"requested",
"input",
"plugin",
"to",
"load",
"configuration",
"and",
"then",
"initiate",
"build"
] | python | train |
timknip/pyswf | swf/export.py | https://github.com/timknip/pyswf/blob/3740cc80d7650156831e728ea0d408819e5671eb/swf/export.py#L879-L886 | def export(self, swf, frame, **export_opts):
""" Exports a frame of the specified SWF to SVG.
@param swf The SWF.
@param frame Which frame to export, by 0-based index (int)
"""
self.wanted_frame = frame
return super(FrameSVGExporterMixin, self).export(swf, *export_opts... | [
"def",
"export",
"(",
"self",
",",
"swf",
",",
"frame",
",",
"*",
"*",
"export_opts",
")",
":",
"self",
".",
"wanted_frame",
"=",
"frame",
"return",
"super",
"(",
"FrameSVGExporterMixin",
",",
"self",
")",
".",
"export",
"(",
"swf",
",",
"*",
"export_o... | Exports a frame of the specified SWF to SVG.
@param swf The SWF.
@param frame Which frame to export, by 0-based index (int) | [
"Exports",
"a",
"frame",
"of",
"the",
"specified",
"SWF",
"to",
"SVG",
"."
] | python | train |
google/tangent | tangent/optimization.py | https://github.com/google/tangent/blob/6533e83af09de7345d1b438512679992f080dcc9/tangent/optimization.py#L62-L88 | def dead_code_elimination(node):
"""Perform a simple form of dead code elimination on a Python AST.
This method performs reaching definitions analysis on all function
definitions. It then looks for the definition of variables that are not used
elsewhere and removes those definitions.
This function takes int... | [
"def",
"dead_code_elimination",
"(",
"node",
")",
":",
"to_remove",
"=",
"set",
"(",
"def_",
"[",
"1",
"]",
"for",
"def_",
"in",
"annotate",
".",
"unused",
"(",
"node",
")",
"if",
"not",
"isinstance",
"(",
"def_",
"[",
"1",
"]",
",",
"(",
"gast",
"... | Perform a simple form of dead code elimination on a Python AST.
This method performs reaching definitions analysis on all function
definitions. It then looks for the definition of variables that are not used
elsewhere and removes those definitions.
This function takes into consideration push and pop statement... | [
"Perform",
"a",
"simple",
"form",
"of",
"dead",
"code",
"elimination",
"on",
"a",
"Python",
"AST",
"."
] | python | train |
racitup/static-ranges | static_ranges.py | https://github.com/racitup/static-ranges/blob/a15c2e2bd6f643279ae046494b8714634dd380a4/static_ranges.py#L125-L136 | def convert_ranges(cls, ranges, length):
"""Converts to valid byte ranges"""
result = []
for start, end in ranges:
if end is None:
result.append( (start, length-1) )
elif start is None:
s = length - end
result.append( (0 if ... | [
"def",
"convert_ranges",
"(",
"cls",
",",
"ranges",
",",
"length",
")",
":",
"result",
"=",
"[",
"]",
"for",
"start",
",",
"end",
"in",
"ranges",
":",
"if",
"end",
"is",
"None",
":",
"result",
".",
"append",
"(",
"(",
"start",
",",
"length",
"-",
... | Converts to valid byte ranges | [
"Converts",
"to",
"valid",
"byte",
"ranges"
] | python | valid |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/core/alias.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/core/alias.py#L150-L155 | def soft_define_alias(self, name, cmd):
"""Define an alias, but don't raise on an AliasError."""
try:
self.define_alias(name, cmd)
except AliasError, e:
error("Invalid alias: %s" % e) | [
"def",
"soft_define_alias",
"(",
"self",
",",
"name",
",",
"cmd",
")",
":",
"try",
":",
"self",
".",
"define_alias",
"(",
"name",
",",
"cmd",
")",
"except",
"AliasError",
",",
"e",
":",
"error",
"(",
"\"Invalid alias: %s\"",
"%",
"e",
")"
] | Define an alias, but don't raise on an AliasError. | [
"Define",
"an",
"alias",
"but",
"don",
"t",
"raise",
"on",
"an",
"AliasError",
"."
] | python | test |
rgmining/ria | ria/bipartite.py | https://github.com/rgmining/ria/blob/39223c67b7e59e10bd8e3a9062fb13f8bf893a5d/ria/bipartite.py#L412-L429 | def retrieve_reviewers(self, product):
"""Retrieve reviewers who reviewed a given product.
Args:
product: A product specifying reviewers.
Returns:
A list of reviewers who review the product.
Raises:
TypeError: when given product isn't instance of specifie... | [
"def",
"retrieve_reviewers",
"(",
"self",
",",
"product",
")",
":",
"if",
"not",
"isinstance",
"(",
"product",
",",
"self",
".",
"_product_cls",
")",
":",
"raise",
"TypeError",
"(",
"\"Type of given product isn't acceptable:\"",
",",
"product",
",",
"\", expected:... | Retrieve reviewers who reviewed a given product.
Args:
product: A product specifying reviewers.
Returns:
A list of reviewers who review the product.
Raises:
TypeError: when given product isn't instance of specified product
class when this graph is con... | [
"Retrieve",
"reviewers",
"who",
"reviewed",
"a",
"given",
"product",
"."
] | python | train |
gem/oq-engine | openquake/hazardlib/geo/mesh.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/mesh.py#L297-L317 | def _get_proj_convex_hull(self):
"""
Create a projection centered in the center of this mesh and define
a convex polygon in that projection, enveloping all the points
of the mesh.
:returns:
Tuple of two items: projection function and shapely 2d polygon.
N... | [
"def",
"_get_proj_convex_hull",
"(",
"self",
")",
":",
"# create a projection centered in the center of points collection",
"proj",
"=",
"geo_utils",
".",
"OrthographicProjection",
"(",
"*",
"geo_utils",
".",
"get_spherical_bounding_box",
"(",
"self",
".",
"lons",
",",
"s... | Create a projection centered in the center of this mesh and define
a convex polygon in that projection, enveloping all the points
of the mesh.
:returns:
Tuple of two items: projection function and shapely 2d polygon.
Note that the result geometry can be line or point dep... | [
"Create",
"a",
"projection",
"centered",
"in",
"the",
"center",
"of",
"this",
"mesh",
"and",
"define",
"a",
"convex",
"polygon",
"in",
"that",
"projection",
"enveloping",
"all",
"the",
"points",
"of",
"the",
"mesh",
"."
] | python | train |
panzarino/mlbgame | mlbgame/game.py | https://github.com/panzarino/mlbgame/blob/0a2d10540de793fdc3b8476aa18f5cf3b53d0b54/mlbgame/game.py#L332-L364 | def overview(game_id):
"""Gets the overview information for the game with matching id."""
output = {}
# get data
overview = mlbgame.data.get_overview(game_id)
# parse data
overview_root = etree.parse(overview).getroot()
try:
output = add_raw_box_score_attributes(output, game_id)
... | [
"def",
"overview",
"(",
"game_id",
")",
":",
"output",
"=",
"{",
"}",
"# get data",
"overview",
"=",
"mlbgame",
".",
"data",
".",
"get_overview",
"(",
"game_id",
")",
"# parse data",
"overview_root",
"=",
"etree",
".",
"parse",
"(",
"overview",
")",
".",
... | Gets the overview information for the game with matching id. | [
"Gets",
"the",
"overview",
"information",
"for",
"the",
"game",
"with",
"matching",
"id",
"."
] | python | train |
gagneurlab/concise | concise/legacy/concise.py | https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/legacy/concise.py#L1062-L1098 | def from_dict(cls, obj_dict):
"""
Load the object from a dictionary (produced with :py:func:`Concise.to_dict`)
Returns:
Concise: Loaded Concise object.
"""
# convert the output into a proper form
obj_dict['output'] = helper.rec_dict_to_numpy_dict(obj_dict["o... | [
"def",
"from_dict",
"(",
"cls",
",",
"obj_dict",
")",
":",
"# convert the output into a proper form",
"obj_dict",
"[",
"'output'",
"]",
"=",
"helper",
".",
"rec_dict_to_numpy_dict",
"(",
"obj_dict",
"[",
"\"output\"",
"]",
")",
"helper",
".",
"dict_to_numpy_dict",
... | Load the object from a dictionary (produced with :py:func:`Concise.to_dict`)
Returns:
Concise: Loaded Concise object. | [
"Load",
"the",
"object",
"from",
"a",
"dictionary",
"(",
"produced",
"with",
":",
"py",
":",
"func",
":",
"Concise",
".",
"to_dict",
")"
] | python | train |
sdispater/orator | orator/migrations/migration_creator.py | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/migrations/migration_creator.py#L21-L50 | def create(self, name, path, table=None, create=False):
"""
Create a new migration at the given path.
:param name: The name of the migration
:type name: str
:param path: The path of the migrations
:type path: str
:param table: The table name
:type table: ... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"path",
",",
"table",
"=",
"None",
",",
"create",
"=",
"False",
")",
":",
"path",
"=",
"self",
".",
"_get_path",
"(",
"name",
",",
"path",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
... | Create a new migration at the given path.
:param name: The name of the migration
:type name: str
:param path: The path of the migrations
:type path: str
:param table: The table name
:type table: str
:param create: Whether it's a create migration or not
:t... | [
"Create",
"a",
"new",
"migration",
"at",
"the",
"given",
"path",
"."
] | python | train |
devopshq/youtrack | youtrack/connection.py | https://github.com/devopshq/youtrack/blob/c4ec19aca253ae30ac8eee7976a2f330e480a73b/youtrack/connection.py#L312-L315 | def get_user(self, login):
""" http://confluence.jetbrains.net/display/YTD2/GET+user
"""
return youtrack.User(self._get("/admin/user/" + urlquote(login.encode('utf8'))), self) | [
"def",
"get_user",
"(",
"self",
",",
"login",
")",
":",
"return",
"youtrack",
".",
"User",
"(",
"self",
".",
"_get",
"(",
"\"/admin/user/\"",
"+",
"urlquote",
"(",
"login",
".",
"encode",
"(",
"'utf8'",
")",
")",
")",
",",
"self",
")"
] | http://confluence.jetbrains.net/display/YTD2/GET+user | [
"http",
":",
"//",
"confluence",
".",
"jetbrains",
".",
"net",
"/",
"display",
"/",
"YTD2",
"/",
"GET",
"+",
"user"
] | python | train |
fulfilio/python-magento | magento/sales.py | https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/sales.py#L418-L432 | def addcomment(self, invoice_increment_id,
comment=None, email=False, include_comment=False):
"""
Add comment to invoice or change its state
:param invoice_increment_id: Invoice ID
"""
if comment is None:
comment = ""
return bool(
self... | [
"def",
"addcomment",
"(",
"self",
",",
"invoice_increment_id",
",",
"comment",
"=",
"None",
",",
"email",
"=",
"False",
",",
"include_comment",
"=",
"False",
")",
":",
"if",
"comment",
"is",
"None",
":",
"comment",
"=",
"\"\"",
"return",
"bool",
"(",
"se... | Add comment to invoice or change its state
:param invoice_increment_id: Invoice ID | [
"Add",
"comment",
"to",
"invoice",
"or",
"change",
"its",
"state"
] | python | train |
trendels/rhino | rhino/mapper.py | https://github.com/trendels/rhino/blob/f1f0ef21b6080a2bd130b38b5bef163074c94aed/rhino/mapper.py#L405-L413 | def add_property(self, name, fn, cached=True):
"""Adds a property to the Context.
See `Mapper.add_ctx_property`, which uses this method to install
the properties added on the Mapper level.
"""
if name in self.__properties:
raise KeyError("Trying to add a property '%s... | [
"def",
"add_property",
"(",
"self",
",",
"name",
",",
"fn",
",",
"cached",
"=",
"True",
")",
":",
"if",
"name",
"in",
"self",
".",
"__properties",
":",
"raise",
"KeyError",
"(",
"\"Trying to add a property '%s' that already exists on this %s object.\"",
"%",
"(",
... | Adds a property to the Context.
See `Mapper.add_ctx_property`, which uses this method to install
the properties added on the Mapper level. | [
"Adds",
"a",
"property",
"to",
"the",
"Context",
"."
] | python | train |
PSPC-SPAC-buyandsell/von_agent | von_agent/agent/holder_prover.py | https://github.com/PSPC-SPAC-buyandsell/von_agent/blob/0b1c17cca3bd178b6e6974af84dbac1dfce5cf45/von_agent/agent/holder_prover.py#L957-L1089 | async def create_proof(self, proof_req: dict, creds: dict, requested_creds: dict) -> str:
"""
Create proof as HolderProver.
Raise:
* AbsentLinkSecret if link secret not set
* CredentialFocus on attempt to create proof on no creds or multiple creds for a credential defini... | [
"async",
"def",
"create_proof",
"(",
"self",
",",
"proof_req",
":",
"dict",
",",
"creds",
":",
"dict",
",",
"requested_creds",
":",
"dict",
")",
"->",
"str",
":",
"LOGGER",
".",
"debug",
"(",
"'HolderProver.create_proof >>> proof_req: %s, creds: %s, requested_creds:... | Create proof as HolderProver.
Raise:
* AbsentLinkSecret if link secret not set
* CredentialFocus on attempt to create proof on no creds or multiple creds for a credential definition
* AbsentTails if missing required tails file
* BadRevStateTime if a timestamp for... | [
"Create",
"proof",
"as",
"HolderProver",
"."
] | python | train |
mitsei/dlkit | dlkit/services/grading.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/services/grading.py#L1401-L1409 | def use_federated_gradebook_view(self):
"""Pass through to provider GradeSystemLookupSession.use_federated_gradebook_view"""
self._gradebook_view = FEDERATED
# self._get_provider_session('grade_system_lookup_session') # To make sure the session is tracked
for session in self._get_provide... | [
"def",
"use_federated_gradebook_view",
"(",
"self",
")",
":",
"self",
".",
"_gradebook_view",
"=",
"FEDERATED",
"# self._get_provider_session('grade_system_lookup_session') # To make sure the session is tracked",
"for",
"session",
"in",
"self",
".",
"_get_provider_sessions",
"(",... | Pass through to provider GradeSystemLookupSession.use_federated_gradebook_view | [
"Pass",
"through",
"to",
"provider",
"GradeSystemLookupSession",
".",
"use_federated_gradebook_view"
] | python | train |
uw-it-aca/uw-restclients-canvas | uw_canvas/courses.py | https://github.com/uw-it-aca/uw-restclients-canvas/blob/9845faf33d49a8f06908efc22640c001116d6ea2/uw_canvas/courses.py#L98-L106 | def update_sis_id(self, course_id, sis_course_id):
"""
Updates the SIS ID for the course identified by the passed course ID.
https://canvas.instructure.com/doc/api/courses.html#method.courses.update
"""
url = COURSES_API.format(course_id)
body = {"course": {"sis_course_i... | [
"def",
"update_sis_id",
"(",
"self",
",",
"course_id",
",",
"sis_course_id",
")",
":",
"url",
"=",
"COURSES_API",
".",
"format",
"(",
"course_id",
")",
"body",
"=",
"{",
"\"course\"",
":",
"{",
"\"sis_course_id\"",
":",
"sis_course_id",
"}",
"}",
"return",
... | Updates the SIS ID for the course identified by the passed course ID.
https://canvas.instructure.com/doc/api/courses.html#method.courses.update | [
"Updates",
"the",
"SIS",
"ID",
"for",
"the",
"course",
"identified",
"by",
"the",
"passed",
"course",
"ID",
"."
] | python | test |
LonamiWebs/Telethon | telethon/sessions/sqlite.py | https://github.com/LonamiWebs/Telethon/blob/1ead9757d366b58c1e0567cddb0196e20f1a445f/telethon/sessions/sqlite.py#L251-L256 | def list_sessions(cls):
"""Lists all the sessions of the users who have ever connected
using this client and never logged out
"""
return [os.path.splitext(os.path.basename(f))[0]
for f in os.listdir('.') if f.endswith(EXTENSION)] | [
"def",
"list_sessions",
"(",
"cls",
")",
":",
"return",
"[",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"f",
")",
")",
"[",
"0",
"]",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"'.'",
")",
"if",
"f",
"... | Lists all the sessions of the users who have ever connected
using this client and never logged out | [
"Lists",
"all",
"the",
"sessions",
"of",
"the",
"users",
"who",
"have",
"ever",
"connected",
"using",
"this",
"client",
"and",
"never",
"logged",
"out"
] | python | train |
touilleMan/marshmallow-mongoengine | marshmallow_mongoengine/schema.py | https://github.com/touilleMan/marshmallow-mongoengine/blob/21223700ea1f1d0209c967761e5c22635ee721e7/marshmallow_mongoengine/schema.py#L49-L88 | def get_declared_fields(mcs, klass, *args, **kwargs):
"""Updates declared fields with fields converted from the
Mongoengine model passed as the `model` class Meta option.
"""
declared_fields = kwargs.get('dict_class', dict)()
# Generate the fields provided through inheritance
... | [
"def",
"get_declared_fields",
"(",
"mcs",
",",
"klass",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"declared_fields",
"=",
"kwargs",
".",
"get",
"(",
"'dict_class'",
",",
"dict",
")",
"(",
")",
"# Generate the fields provided through inheritance",
"o... | Updates declared fields with fields converted from the
Mongoengine model passed as the `model` class Meta option. | [
"Updates",
"declared",
"fields",
"with",
"fields",
"converted",
"from",
"the",
"Mongoengine",
"model",
"passed",
"as",
"the",
"model",
"class",
"Meta",
"option",
"."
] | python | train |
pgxcentre/geneparse | geneparse/core.py | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/core.py#L139-L150 | def complement_alleles(self):
"""Complement the alleles of this variant.
This will call this module's `complement_alleles` function.
Note that this will not create a new object, but modify the state of
the current instance.
"""
self.alleles = self._encode_alleles(
... | [
"def",
"complement_alleles",
"(",
"self",
")",
":",
"self",
".",
"alleles",
"=",
"self",
".",
"_encode_alleles",
"(",
"[",
"complement_alleles",
"(",
"i",
")",
"for",
"i",
"in",
"self",
".",
"alleles",
"]",
")"
] | Complement the alleles of this variant.
This will call this module's `complement_alleles` function.
Note that this will not create a new object, but modify the state of
the current instance. | [
"Complement",
"the",
"alleles",
"of",
"this",
"variant",
"."
] | python | train |
rgarcia-herrera/pyveplot | pyveplot/__init__.py | https://github.com/rgarcia-herrera/pyveplot/blob/57ceadcca47e79c94ee22efc9ba1e4962f462015/pyveplot/__init__.py#L74-L121 | def connect(self, axis0, n0_index, source_angle, axis1, n1_index, target_angle, **kwargs):
"""Draw edges as Bézier curves.
Start and end points map to the coordinates of the given nodes
which in turn are set when adding nodes to an axis with the
Axis.add_node() method, by using the plac... | [
"def",
"connect",
"(",
"self",
",",
"axis0",
",",
"n0_index",
",",
"source_angle",
",",
"axis1",
",",
"n1_index",
",",
"target_angle",
",",
"*",
"*",
"kwargs",
")",
":",
"n0",
"=",
"axis0",
".",
"nodes",
"[",
"n0_index",
"]",
"n1",
"=",
"axis1",
".",... | Draw edges as Bézier curves.
Start and end points map to the coordinates of the given nodes
which in turn are set when adding nodes to an axis with the
Axis.add_node() method, by using the placement information of
the axis and a specified offset from its start point.
Co... | [
"Draw",
"edges",
"as",
"Bézier",
"curves",
"."
] | python | valid |
jim-easterbrook/pywws | src/pywws/sqlite3data.py | https://github.com/jim-easterbrook/pywws/blob/4e4d74cee5a3ac5bf42286feaa251cd2ffcaf02c/src/pywws/sqlite3data.py#L516-L520 | def items(self):
"""D.items() -> a set-like object providing a view on D's items"""
keycol = self._keycol
for row in self.__iter__():
yield (row[keycol], dict(row)) | [
"def",
"items",
"(",
"self",
")",
":",
"keycol",
"=",
"self",
".",
"_keycol",
"for",
"row",
"in",
"self",
".",
"__iter__",
"(",
")",
":",
"yield",
"(",
"row",
"[",
"keycol",
"]",
",",
"dict",
"(",
"row",
")",
")"
] | D.items() -> a set-like object providing a view on D's items | [
"D",
".",
"items",
"()",
"-",
">",
"a",
"set",
"-",
"like",
"object",
"providing",
"a",
"view",
"on",
"D",
"s",
"items"
] | python | train |
litl/park | park.py | https://github.com/litl/park/blob/85738418b3c1db57046a5b2f217ee3f5d55851df/park.py#L210-L215 | def ibatch(iterable, size):
"""Yield a series of batches from iterable, each size elements long."""
source = iter(iterable)
while True:
batch = itertools.islice(source, size)
yield itertools.chain([next(batch)], batch) | [
"def",
"ibatch",
"(",
"iterable",
",",
"size",
")",
":",
"source",
"=",
"iter",
"(",
"iterable",
")",
"while",
"True",
":",
"batch",
"=",
"itertools",
".",
"islice",
"(",
"source",
",",
"size",
")",
"yield",
"itertools",
".",
"chain",
"(",
"[",
"next... | Yield a series of batches from iterable, each size elements long. | [
"Yield",
"a",
"series",
"of",
"batches",
"from",
"iterable",
"each",
"size",
"elements",
"long",
"."
] | python | train |
ouroboroscoding/format-oc-python | FormatOC/__init__.py | https://github.com/ouroboroscoding/format-oc-python/blob/c160b46fe4ff2c92333c776991c712de23991225/FormatOC/__init__.py#L2276-L2294 | def toDict(self):
"""To Dict
Returns the Parent as a dictionary in the same format as is used in
constructing it
Returns:
dict
"""
# Get the parents dict as the starting point of our return
dRet = super(Parent,self).toDict()
# Go through each field and add it to the return
for k,v in iteritems(... | [
"def",
"toDict",
"(",
"self",
")",
":",
"# Get the parents dict as the starting point of our return",
"dRet",
"=",
"super",
"(",
"Parent",
",",
"self",
")",
".",
"toDict",
"(",
")",
"# Go through each field and add it to the return",
"for",
"k",
",",
"v",
"in",
"ite... | To Dict
Returns the Parent as a dictionary in the same format as is used in
constructing it
Returns:
dict | [
"To",
"Dict"
] | python | train |
ciena/afkak | afkak/consumer.py | https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/consumer.py#L554-L587 | def _handle_offset_error(self, failure):
"""
Retry the offset fetch request if appropriate.
Once the :attr:`.retry_delay` reaches our :attr:`.retry_max_delay`, we
log a warning. This should perhaps be extended to abort sooner on
certain errors.
"""
# outstanding... | [
"def",
"_handle_offset_error",
"(",
"self",
",",
"failure",
")",
":",
"# outstanding request got errback'd, clear it",
"self",
".",
"_request_d",
"=",
"None",
"if",
"self",
".",
"_stopping",
"and",
"failure",
".",
"check",
"(",
"CancelledError",
")",
":",
"# Not r... | Retry the offset fetch request if appropriate.
Once the :attr:`.retry_delay` reaches our :attr:`.retry_max_delay`, we
log a warning. This should perhaps be extended to abort sooner on
certain errors. | [
"Retry",
"the",
"offset",
"fetch",
"request",
"if",
"appropriate",
"."
] | python | train |
NetEaseGame/ATX | atx/adbkit/device.py | https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/adbkit/device.py#L153-L165 | def packages(self):
"""
Show all packages
"""
pattern = re.compile(r'package:(/[^=]+\.apk)=([^\s]+)')
packages = []
for line in self.shell('pm', 'list', 'packages', '-f').splitlines():
m = pattern.match(line)
if not m:
continue
... | [
"def",
"packages",
"(",
"self",
")",
":",
"pattern",
"=",
"re",
".",
"compile",
"(",
"r'package:(/[^=]+\\.apk)=([^\\s]+)'",
")",
"packages",
"=",
"[",
"]",
"for",
"line",
"in",
"self",
".",
"shell",
"(",
"'pm'",
",",
"'list'",
",",
"'packages'",
",",
"'-... | Show all packages | [
"Show",
"all",
"packages"
] | python | train |
neo4j-contrib/neomodel | neomodel/match.py | https://github.com/neo4j-contrib/neomodel/blob/cca5de4c4e90998293558b871b1b529095c91a38/neomodel/match.py#L129-L179 | def process_filter_args(cls, kwargs):
"""
loop through properties in filter parameters check they match class definition
deflate them and convert into something easy to generate cypher from
"""
output = {}
for key, value in kwargs.items():
if '__' in key:
prop, operator = k... | [
"def",
"process_filter_args",
"(",
"cls",
",",
"kwargs",
")",
":",
"output",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"if",
"'__'",
"in",
"key",
":",
"prop",
",",
"operator",
"=",
"key",
".",
"rsplit",... | loop through properties in filter parameters check they match class definition
deflate them and convert into something easy to generate cypher from | [
"loop",
"through",
"properties",
"in",
"filter",
"parameters",
"check",
"they",
"match",
"class",
"definition",
"deflate",
"them",
"and",
"convert",
"into",
"something",
"easy",
"to",
"generate",
"cypher",
"from"
] | python | train |
apple/turicreate | src/unity/python/turicreate/toolkits/regression/linear_regression.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/regression/linear_regression.py#L427-L451 | def export_coreml(self, filename):
"""
Export the model in Core ML format.
Parameters
----------
filename: str
A valid filename where the model can be saved.
Examples
--------
>>> model.export_coreml("MyModel.mlmodel")
"""
from ... | [
"def",
"export_coreml",
"(",
"self",
",",
"filename",
")",
":",
"from",
"turicreate",
".",
"extensions",
"import",
"_linear_regression_export_as_model_asset",
"from",
"turicreate",
".",
"toolkits",
"import",
"_coreml_utils",
"display_name",
"=",
"\"linear regression\"",
... | Export the model in Core ML format.
Parameters
----------
filename: str
A valid filename where the model can be saved.
Examples
--------
>>> model.export_coreml("MyModel.mlmodel") | [
"Export",
"the",
"model",
"in",
"Core",
"ML",
"format",
"."
] | python | train |
Salamek/cron-descriptor | cron_descriptor/ExpressionDescriptor.py | https://github.com/Salamek/cron-descriptor/blob/fafe86b33e190caf205836fa1c719d27c7b408c7/cron_descriptor/ExpressionDescriptor.py#L216-L231 | def get_seconds_description(self):
"""Generates a description for only the SECONDS portion of the expression
Returns:
The SECONDS description
"""
return self.get_segment_description(
self._expression_parts[0],
_("every second"),
lambda s... | [
"def",
"get_seconds_description",
"(",
"self",
")",
":",
"return",
"self",
".",
"get_segment_description",
"(",
"self",
".",
"_expression_parts",
"[",
"0",
"]",
",",
"_",
"(",
"\"every second\"",
")",
",",
"lambda",
"s",
":",
"s",
",",
"lambda",
"s",
":",
... | Generates a description for only the SECONDS portion of the expression
Returns:
The SECONDS description | [
"Generates",
"a",
"description",
"for",
"only",
"the",
"SECONDS",
"portion",
"of",
"the",
"expression"
] | python | train |
DataDog/integrations-core | tokumx/datadog_checks/tokumx/vendor/pymongo/client_options.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/client_options.py#L101-L123 | def _parse_pool_options(options):
"""Parse connection pool options."""
max_pool_size = options.get('maxpoolsize', common.MAX_POOL_SIZE)
min_pool_size = options.get('minpoolsize', common.MIN_POOL_SIZE)
max_idle_time_ms = options.get('maxidletimems', common.MAX_IDLE_TIME_MS)
if max_pool_size is not No... | [
"def",
"_parse_pool_options",
"(",
"options",
")",
":",
"max_pool_size",
"=",
"options",
".",
"get",
"(",
"'maxpoolsize'",
",",
"common",
".",
"MAX_POOL_SIZE",
")",
"min_pool_size",
"=",
"options",
".",
"get",
"(",
"'minpoolsize'",
",",
"common",
".",
"MIN_POO... | Parse connection pool options. | [
"Parse",
"connection",
"pool",
"options",
"."
] | python | train |
sorgerlab/indra | indra/assemblers/sbgn/assembler.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/sbgn/assembler.py#L125-L136 | def save_model(self, file_name='model.sbgn'):
"""Save the assembled SBGN model in a file.
Parameters
----------
file_name : Optional[str]
The name of the file to save the SBGN network to.
Default: model.sbgn
"""
model = self.print_model()
... | [
"def",
"save_model",
"(",
"self",
",",
"file_name",
"=",
"'model.sbgn'",
")",
":",
"model",
"=",
"self",
".",
"print_model",
"(",
")",
"with",
"open",
"(",
"file_name",
",",
"'wb'",
")",
"as",
"fh",
":",
"fh",
".",
"write",
"(",
"model",
")"
] | Save the assembled SBGN model in a file.
Parameters
----------
file_name : Optional[str]
The name of the file to save the SBGN network to.
Default: model.sbgn | [
"Save",
"the",
"assembled",
"SBGN",
"model",
"in",
"a",
"file",
"."
] | python | train |
turicas/rows | rows/operations.py | https://github.com/turicas/rows/blob/c74da41ae9ed091356b803a64f8a30c641c5fc45/rows/operations.py#L26-L53 | def join(keys, tables):
"""Merge a list of `Table` objects using `keys` to group rows"""
# Make new (merged) Table fields
fields = OrderedDict()
for table in tables:
fields.update(table.fields)
# TODO: may raise an error if a same field is different in some tables
# Check if all keys a... | [
"def",
"join",
"(",
"keys",
",",
"tables",
")",
":",
"# Make new (merged) Table fields",
"fields",
"=",
"OrderedDict",
"(",
")",
"for",
"table",
"in",
"tables",
":",
"fields",
".",
"update",
"(",
"table",
".",
"fields",
")",
"# TODO: may raise an error if a same... | Merge a list of `Table` objects using `keys` to group rows | [
"Merge",
"a",
"list",
"of",
"Table",
"objects",
"using",
"keys",
"to",
"group",
"rows"
] | python | train |
UniversalDevicesInc/polyglot-v2-python-interface | polyinterface/polyinterface.py | https://github.com/UniversalDevicesInc/polyglot-v2-python-interface/blob/fe613135b762731a41a081222e43d2a8ae4fc53f/polyinterface/polyinterface.py#L349-L361 | def send(self, message):
"""
Formatted Message to send to Polyglot. Connection messages are sent automatically from this module
so this method is used to send commands to/from Polyglot and formats it for consumption
"""
if not isinstance(message, dict) and self.connected:
... | [
"def",
"send",
"(",
"self",
",",
"message",
")",
":",
"if",
"not",
"isinstance",
"(",
"message",
",",
"dict",
")",
"and",
"self",
".",
"connected",
":",
"warnings",
".",
"warn",
"(",
"'payload not a dictionary'",
")",
"return",
"False",
"try",
":",
"mess... | Formatted Message to send to Polyglot. Connection messages are sent automatically from this module
so this method is used to send commands to/from Polyglot and formats it for consumption | [
"Formatted",
"Message",
"to",
"send",
"to",
"Polyglot",
".",
"Connection",
"messages",
"are",
"sent",
"automatically",
"from",
"this",
"module",
"so",
"this",
"method",
"is",
"used",
"to",
"send",
"commands",
"to",
"/",
"from",
"Polyglot",
"and",
"formats",
... | python | train |
SmartTeleMax/iktomi | iktomi/forms/fields.py | https://github.com/SmartTeleMax/iktomi/blob/80bc0f1408d63efe7f5844367d1f6efba44b35f2/iktomi/forms/fields.py#L202-L209 | def accept(self):
'''Extracts raw value from form's raw data and passes it to converter'''
value = self.raw_value
if not self._check_value_type(value):
# XXX should this be silent or TypeError?
value = [] if self.multiple else self._null_value
self.clean_value = s... | [
"def",
"accept",
"(",
"self",
")",
":",
"value",
"=",
"self",
".",
"raw_value",
"if",
"not",
"self",
".",
"_check_value_type",
"(",
"value",
")",
":",
"# XXX should this be silent or TypeError?",
"value",
"=",
"[",
"]",
"if",
"self",
".",
"multiple",
"else",... | Extracts raw value from form's raw data and passes it to converter | [
"Extracts",
"raw",
"value",
"from",
"form",
"s",
"raw",
"data",
"and",
"passes",
"it",
"to",
"converter"
] | python | train |
kubernetes-client/python | kubernetes/client/apis/networking_v1beta1_api.py | https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/apis/networking_v1beta1_api.py#L997-L1020 | def read_namespaced_ingress(self, name, namespace, **kwargs):
"""
read the specified Ingress
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.read_namespaced_ingress(name, namespace, async_r... | [
"def",
"read_namespaced_ingress",
"(",
"self",
",",
"name",
",",
"namespace",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'",
")",
":",
"return",
"self",
".",
... | read the specified Ingress
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.read_namespaced_ingress(name, namespace, async_req=True)
>>> result = thread.get()
:param async_req bool
... | [
"read",
"the",
"specified",
"Ingress",
"This",
"method",
"makes",
"a",
"synchronous",
"HTTP",
"request",
"by",
"default",
".",
"To",
"make",
"an",
"asynchronous",
"HTTP",
"request",
"please",
"pass",
"async_req",
"=",
"True",
">>>",
"thread",
"=",
"api",
"."... | python | train |
Qiskit/qiskit-terra | qiskit/visualization/text.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/visualization/text.py#L60-L69 | def bot(self):
""" Constructs the bottom line of the element"""
ret = self.bot_format % self.bot_connect.center(
self.width, self.bot_pad)
if self.right_fill:
ret = ret.ljust(self.right_fill, self.bot_pad)
if self.left_fill:
ret = ret.rjust(self.left_f... | [
"def",
"bot",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"bot_format",
"%",
"self",
".",
"bot_connect",
".",
"center",
"(",
"self",
".",
"width",
",",
"self",
".",
"bot_pad",
")",
"if",
"self",
".",
"right_fill",
":",
"ret",
"=",
"ret",
".",
... | Constructs the bottom line of the element | [
"Constructs",
"the",
"bottom",
"line",
"of",
"the",
"element"
] | python | test |
sods/paramz | paramz/core/indexable.py | https://github.com/sods/paramz/blob/ae6fc6274b70fb723d91e48fc5026a9bc5a06508/paramz/core/indexable.py#L164-L184 | def _raveled_index_for_transformed(self, param):
"""
get the raveled index for a param for the transformed parameter array
(optimizer array).
that is an int array, containing the indexes for the flattened
param inside this parameterized logic.
!Warning! be sure to call ... | [
"def",
"_raveled_index_for_transformed",
"(",
"self",
",",
"param",
")",
":",
"ravi",
"=",
"self",
".",
"_raveled_index_for",
"(",
"param",
")",
"if",
"self",
".",
"_has_fixes",
"(",
")",
":",
"fixes",
"=",
"self",
".",
"_fixes_",
"### Transformed indices, han... | get the raveled index for a param for the transformed parameter array
(optimizer array).
that is an int array, containing the indexes for the flattened
param inside this parameterized logic.
!Warning! be sure to call this method on the highest parent of a hierarchy,
as it uses ... | [
"get",
"the",
"raveled",
"index",
"for",
"a",
"param",
"for",
"the",
"transformed",
"parameter",
"array",
"(",
"optimizer",
"array",
")",
"."
] | python | train |
rosshamish/catanlog | catanlog.py | https://github.com/rosshamish/catanlog/blob/6f204920d9b67fd53fc6ff6a1c7b6a756b009bf0/catanlog.py#L151-L156 | def log_player_roll(self, player, roll):
"""
:param player: catan.game.Player
:param roll: integer or string, the sum of the dice
"""
self._logln('{0} rolls {1}{2}'.format(player.color, roll, ' ...DEUCES!' if int(roll) == 2 else '')) | [
"def",
"log_player_roll",
"(",
"self",
",",
"player",
",",
"roll",
")",
":",
"self",
".",
"_logln",
"(",
"'{0} rolls {1}{2}'",
".",
"format",
"(",
"player",
".",
"color",
",",
"roll",
",",
"' ...DEUCES!'",
"if",
"int",
"(",
"roll",
")",
"==",
"2",
"els... | :param player: catan.game.Player
:param roll: integer or string, the sum of the dice | [
":",
"param",
"player",
":",
"catan",
".",
"game",
".",
"Player",
":",
"param",
"roll",
":",
"integer",
"or",
"string",
"the",
"sum",
"of",
"the",
"dice"
] | python | train |
inspirehep/inspire-schemas | inspire_schemas/builders/authors.py | https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/authors.py#L102-L110 | def add_name_variant(self, name):
"""Add name variant.
Args:
:param name: name variant for the current author.
:type name: string
"""
self._ensure_field('name', {})
self.obj['name'].setdefault('name_variants', []).append(name) | [
"def",
"add_name_variant",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"_ensure_field",
"(",
"'name'",
",",
"{",
"}",
")",
"self",
".",
"obj",
"[",
"'name'",
"]",
".",
"setdefault",
"(",
"'name_variants'",
",",
"[",
"]",
")",
".",
"append",
"(",... | Add name variant.
Args:
:param name: name variant for the current author.
:type name: string | [
"Add",
"name",
"variant",
"."
] | python | train |
saltstack/salt | salt/modules/infoblox.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/infoblox.py#L58-L75 | def _get_config(**api_opts):
'''
Return configuration
user passed api_opts override salt config.get vars
'''
config = {
'api_sslverify': True,
'api_url': 'https://INFOBLOX/wapi/v1.2.1',
'api_user': '',
'api_key': '',
}
if '__salt__' in globals():
confi... | [
"def",
"_get_config",
"(",
"*",
"*",
"api_opts",
")",
":",
"config",
"=",
"{",
"'api_sslverify'",
":",
"True",
",",
"'api_url'",
":",
"'https://INFOBLOX/wapi/v1.2.1'",
",",
"'api_user'",
":",
"''",
",",
"'api_key'",
":",
"''",
",",
"}",
"if",
"'__salt__'",
... | Return configuration
user passed api_opts override salt config.get vars | [
"Return",
"configuration",
"user",
"passed",
"api_opts",
"override",
"salt",
"config",
".",
"get",
"vars"
] | python | train |
pypa/pipenv | pipenv/core.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/core.py#L318-L339 | def find_a_system_python(line):
"""Find a Python installation from a given line.
This tries to parse the line in various of ways:
* Looks like an absolute path? Use it directly.
* Looks like a py.exe call? Use py.exe to get the executable.
* Starts with "py" something? Looks like a python command.... | [
"def",
"find_a_system_python",
"(",
"line",
")",
":",
"from",
".",
"vendor",
".",
"pythonfinder",
"import",
"Finder",
"finder",
"=",
"Finder",
"(",
"system",
"=",
"False",
",",
"global_search",
"=",
"True",
")",
"if",
"not",
"line",
":",
"return",
"next",
... | Find a Python installation from a given line.
This tries to parse the line in various of ways:
* Looks like an absolute path? Use it directly.
* Looks like a py.exe call? Use py.exe to get the executable.
* Starts with "py" something? Looks like a python command. Try to find it
in PATH, and use ... | [
"Find",
"a",
"Python",
"installation",
"from",
"a",
"given",
"line",
"."
] | python | train |
klahnakoski/pyLibrary | jx_elasticsearch/meta.py | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_elasticsearch/meta.py#L631-L638 | def query_paths(self):
"""
RETURN A LIST OF ALL NESTED COLUMNS
"""
output = self.namespace.alias_to_query_paths.get(self.name)
if output:
return output
Log.error("Can not find index {{index|quote}}", index=self.name) | [
"def",
"query_paths",
"(",
"self",
")",
":",
"output",
"=",
"self",
".",
"namespace",
".",
"alias_to_query_paths",
".",
"get",
"(",
"self",
".",
"name",
")",
"if",
"output",
":",
"return",
"output",
"Log",
".",
"error",
"(",
"\"Can not find index {{index|quo... | RETURN A LIST OF ALL NESTED COLUMNS | [
"RETURN",
"A",
"LIST",
"OF",
"ALL",
"NESTED",
"COLUMNS"
] | python | train |
spyder-ide/spyder | spyder/widgets/browser.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/browser.py#L185-L198 | def setHtml(self, html, baseUrl=QUrl()):
"""
Reimplement Qt method to prevent WebEngine to steal focus
when setting html on the page
Solution taken from
https://bugreports.qt.io/browse/QTBUG-52999
"""
if WEBENGINE:
self.setEnabled(False)
... | [
"def",
"setHtml",
"(",
"self",
",",
"html",
",",
"baseUrl",
"=",
"QUrl",
"(",
")",
")",
":",
"if",
"WEBENGINE",
":",
"self",
".",
"setEnabled",
"(",
"False",
")",
"super",
"(",
"WebView",
",",
"self",
")",
".",
"setHtml",
"(",
"html",
",",
"baseUrl... | Reimplement Qt method to prevent WebEngine to steal focus
when setting html on the page
Solution taken from
https://bugreports.qt.io/browse/QTBUG-52999 | [
"Reimplement",
"Qt",
"method",
"to",
"prevent",
"WebEngine",
"to",
"steal",
"focus",
"when",
"setting",
"html",
"on",
"the",
"page",
"Solution",
"taken",
"from",
"https",
":",
"//",
"bugreports",
".",
"qt",
".",
"io",
"/",
"browse",
"/",
"QTBUG",
"-",
"5... | python | train |
penguinmenac3/opendatalake | opendatalake/detection/utils.py | https://github.com/penguinmenac3/opendatalake/blob/77c888377095e1812a16982c8efbd2f6b1697a33/opendatalake/detection/utils.py#L771-L784 | def move_detections(label, dy, dx):
"""
Move detections in direction dx, dy.
:param label: The label dict containing all detection lists.
:param dy: The delta in y direction as a number.
:param dx: The delta in x direction as a number.
:return:
"""
for k in label.keys():
if k.st... | [
"def",
"move_detections",
"(",
"label",
",",
"dy",
",",
"dx",
")",
":",
"for",
"k",
"in",
"label",
".",
"keys",
"(",
")",
":",
"if",
"k",
".",
"startswith",
"(",
"\"detection\"",
")",
":",
"detections",
"=",
"label",
"[",
"k",
"]",
"for",
"detectio... | Move detections in direction dx, dy.
:param label: The label dict containing all detection lists.
:param dy: The delta in y direction as a number.
:param dx: The delta in x direction as a number.
:return: | [
"Move",
"detections",
"in",
"direction",
"dx",
"dy",
"."
] | python | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.