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 |
|---|---|---|---|---|---|---|---|---|
CivicSpleen/ambry | ambry/orm/config.py | https://github.com/CivicSpleen/ambry/blob/d7f2be4bf1f7ffd086f3fadd4fcae60c32473e42/ambry/orm/config.py#L260-L267 | def new_datetime(self):
"""Return the time the bundle was created as a datetime object"""
from datetime import datetime
try:
return datetime.fromtimestamp(self.state.new)
except TypeError:
return None | [
"def",
"new_datetime",
"(",
"self",
")",
":",
"from",
"datetime",
"import",
"datetime",
"try",
":",
"return",
"datetime",
".",
"fromtimestamp",
"(",
"self",
".",
"state",
".",
"new",
")",
"except",
"TypeError",
":",
"return",
"None"
] | Return the time the bundle was created as a datetime object | [
"Return",
"the",
"time",
"the",
"bundle",
"was",
"created",
"as",
"a",
"datetime",
"object"
] | python | train |
pypa/pipenv | pipenv/vendor/passa/internals/_pip_shims.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/internals/_pip_shims.py#L24-L38 | def _build_wheel_modern(ireq, output_dir, finder, wheel_cache, kwargs):
"""Build a wheel.
* ireq: The InstallRequirement object to build
* output_dir: The directory to build the wheel in.
* finder: pip's internal Finder object to find the source out of ireq.
* kwargs: Various keyword arguments from... | [
"def",
"_build_wheel_modern",
"(",
"ireq",
",",
"output_dir",
",",
"finder",
",",
"wheel_cache",
",",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"{",
"\"progress_bar\"",
":",
"\"off\"",
",",
"\"build_isolation\"",
":",
"False",
"}",
")",
"with",
"pip_... | Build a wheel.
* ireq: The InstallRequirement object to build
* output_dir: The directory to build the wheel in.
* finder: pip's internal Finder object to find the source out of ireq.
* kwargs: Various keyword arguments from `_prepare_wheel_building_kwargs`. | [
"Build",
"a",
"wheel",
"."
] | python | train |
fabioz/PyDev.Debugger | pydevd_attach_to_process/winappdbg/process.py | https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/process.py#L490-L514 | def __fixup_labels(self, disasm):
"""
Private method used when disassembling from process memory.
It has no return value because the list is modified in place. On return
all raw memory addresses are replaced by labels when possible.
@type disasm: list of tuple(int, int, str, s... | [
"def",
"__fixup_labels",
"(",
"self",
",",
"disasm",
")",
":",
"for",
"index",
"in",
"compat",
".",
"xrange",
"(",
"len",
"(",
"disasm",
")",
")",
":",
"(",
"address",
",",
"size",
",",
"text",
",",
"dump",
")",
"=",
"disasm",
"[",
"index",
"]",
... | Private method used when disassembling from process memory.
It has no return value because the list is modified in place. On return
all raw memory addresses are replaced by labels when possible.
@type disasm: list of tuple(int, int, str, str)
@param disasm: Output of one of the dissas... | [
"Private",
"method",
"used",
"when",
"disassembling",
"from",
"process",
"memory",
"."
] | python | train |
adrn/gala | gala/dynamics/_genfunc/genfunc_3d.py | https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/_genfunc/genfunc_3d.py#L30-L44 | def check_angle_solution(ang,n_vec,toy_aa,timeseries):
""" Plots the toy angle solution against the toy angles ---
Takes true angles and frequencies ang,
the Fourier vectors n_vec,
the toy action-angles toy_aa
and the timeseries """
f,a=plt.subplots(3,1)
for i in range(3):
... | [
"def",
"check_angle_solution",
"(",
"ang",
",",
"n_vec",
",",
"toy_aa",
",",
"timeseries",
")",
":",
"f",
",",
"a",
"=",
"plt",
".",
"subplots",
"(",
"3",
",",
"1",
")",
"for",
"i",
"in",
"range",
"(",
"3",
")",
":",
"a",
"[",
"i",
"]",
".",
... | Plots the toy angle solution against the toy angles ---
Takes true angles and frequencies ang,
the Fourier vectors n_vec,
the toy action-angles toy_aa
and the timeseries | [
"Plots",
"the",
"toy",
"angle",
"solution",
"against",
"the",
"toy",
"angles",
"---",
"Takes",
"true",
"angles",
"and",
"frequencies",
"ang",
"the",
"Fourier",
"vectors",
"n_vec",
"the",
"toy",
"action",
"-",
"angles",
"toy_aa",
"and",
"the",
"timeseries"
] | python | train |
pandas-dev/pandas | pandas/core/arrays/categorical.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/arrays/categorical.py#L1126-L1206 | def map(self, mapper):
"""
Map categories using input correspondence (dict, Series, or function).
Maps the categories to new categories. If the mapping correspondence is
one-to-one the result is a :class:`~pandas.Categorical` which has the
same order property as the original, ot... | [
"def",
"map",
"(",
"self",
",",
"mapper",
")",
":",
"new_categories",
"=",
"self",
".",
"categories",
".",
"map",
"(",
"mapper",
")",
"try",
":",
"return",
"self",
".",
"from_codes",
"(",
"self",
".",
"_codes",
".",
"copy",
"(",
")",
",",
"categories... | Map categories using input correspondence (dict, Series, or function).
Maps the categories to new categories. If the mapping correspondence is
one-to-one the result is a :class:`~pandas.Categorical` which has the
same order property as the original, otherwise a :class:`~pandas.Index`
is... | [
"Map",
"categories",
"using",
"input",
"correspondence",
"(",
"dict",
"Series",
"or",
"function",
")",
"."
] | python | train |
summa-tx/riemann | riemann/tx/shared.py | https://github.com/summa-tx/riemann/blob/04ae336dfd4007ceaed748daadc91cc32fa278ec/riemann/tx/shared.py#L180-L212 | def from_bytes(VarInt, byte_string):
'''
byte-like -> VarInt
accepts arbitrary length input, gets a VarInt off the front
'''
num = byte_string
if num[0] <= 0xfc:
num = num[0:1]
non_compact = False
elif num[0] == 0xfd:
num = num[... | [
"def",
"from_bytes",
"(",
"VarInt",
",",
"byte_string",
")",
":",
"num",
"=",
"byte_string",
"if",
"num",
"[",
"0",
"]",
"<=",
"0xfc",
":",
"num",
"=",
"num",
"[",
"0",
":",
"1",
"]",
"non_compact",
"=",
"False",
"elif",
"num",
"[",
"0",
"]",
"==... | byte-like -> VarInt
accepts arbitrary length input, gets a VarInt off the front | [
"byte",
"-",
"like",
"-",
">",
"VarInt",
"accepts",
"arbitrary",
"length",
"input",
"gets",
"a",
"VarInt",
"off",
"the",
"front"
] | python | train |
nephila/djangocms-installer | djangocms_installer/django/__init__.py | https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/django/__init__.py#L448-L465 | def create_user(config_data):
"""
Create admin user without user input
:param config_data: configuration data
"""
with chdir(os.path.abspath(config_data.project_directory)):
env = deepcopy(dict(os.environ))
env[str('DJANGO_SETTINGS_MODULE')] = str('{0}.settings'.format(config_data.p... | [
"def",
"create_user",
"(",
"config_data",
")",
":",
"with",
"chdir",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"config_data",
".",
"project_directory",
")",
")",
":",
"env",
"=",
"deepcopy",
"(",
"dict",
"(",
"os",
".",
"environ",
")",
")",
"env",
... | Create admin user without user input
:param config_data: configuration data | [
"Create",
"admin",
"user",
"without",
"user",
"input"
] | python | valid |
sparklingpandas/sparklingpandas | sparklingpandas/custom_functions.py | https://github.com/sparklingpandas/sparklingpandas/blob/7d549df4348c979042b683c355aa778fc6d3a768/sparklingpandas/custom_functions.py#L10-L20 | def _create_function(name, doc=""):
""" Create a function for aggregator by name"""
def _(col):
spark_ctx = SparkContext._active_spark_context
java_ctx = (getattr(spark_ctx._jvm.com.sparklingpandas.functions,
name)
(col._java_ctx if isinstance(col,... | [
"def",
"_create_function",
"(",
"name",
",",
"doc",
"=",
"\"\"",
")",
":",
"def",
"_",
"(",
"col",
")",
":",
"spark_ctx",
"=",
"SparkContext",
".",
"_active_spark_context",
"java_ctx",
"=",
"(",
"getattr",
"(",
"spark_ctx",
".",
"_jvm",
".",
"com",
".",
... | Create a function for aggregator by name | [
"Create",
"a",
"function",
"for",
"aggregator",
"by",
"name"
] | python | train |
maas/python-libmaas | maas/client/bones/__init__.py | https://github.com/maas/python-libmaas/blob/4092c68ef7fb1753efc843569848e2bcc3415002/maas/client/bones/__init__.py#L85-L97 | async def connect(
cls, url, *, apikey=None, insecure=False):
"""Make a `SessionAPI` by connecting with an apikey.
:return: A tuple of ``profile`` and ``session``, where the former is
an unsaved `Profile` instance, and the latter is a `SessionAPI`
instance made using... | [
"async",
"def",
"connect",
"(",
"cls",
",",
"url",
",",
"*",
",",
"apikey",
"=",
"None",
",",
"insecure",
"=",
"False",
")",
":",
"profile",
"=",
"await",
"helpers",
".",
"connect",
"(",
"url",
"=",
"url",
",",
"apikey",
"=",
"apikey",
",",
"insecu... | Make a `SessionAPI` by connecting with an apikey.
:return: A tuple of ``profile`` and ``session``, where the former is
an unsaved `Profile` instance, and the latter is a `SessionAPI`
instance made using the profile. | [
"Make",
"a",
"SessionAPI",
"by",
"connecting",
"with",
"an",
"apikey",
"."
] | python | train |
bapakode/OmMongo | ommongo/query.py | https://github.com/bapakode/OmMongo/blob/52b5a5420516dc709f2d2eb065818c7973991ce3/ommongo/query.py#L594-L598 | def nin(self, qfield, *values):
''' Works the same as the query expression method ``nin_``
'''
self.__query_obj.nin(qfield, *values)
return self | [
"def",
"nin",
"(",
"self",
",",
"qfield",
",",
"*",
"values",
")",
":",
"self",
".",
"__query_obj",
".",
"nin",
"(",
"qfield",
",",
"*",
"values",
")",
"return",
"self"
] | Works the same as the query expression method ``nin_`` | [
"Works",
"the",
"same",
"as",
"the",
"query",
"expression",
"method",
"nin_"
] | python | train |
BlackEarth/bxml | bxml/xml.py | https://github.com/BlackEarth/bxml/blob/8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77/bxml/xml.py#L751-L758 | def wrap_content(cls, container, wrapper):
"wrap the content of container element with wrapper element"
wrapper.text = (container.text or '') + (wrapper.text or '')
container.text = ''
for ch in container:
wrapper.append(ch)
container.insert(0, wrapper)
... | [
"def",
"wrap_content",
"(",
"cls",
",",
"container",
",",
"wrapper",
")",
":",
"wrapper",
".",
"text",
"=",
"(",
"container",
".",
"text",
"or",
"''",
")",
"+",
"(",
"wrapper",
".",
"text",
"or",
"''",
")",
"container",
".",
"text",
"=",
"''",
"for... | wrap the content of container element with wrapper element | [
"wrap",
"the",
"content",
"of",
"container",
"element",
"with",
"wrapper",
"element"
] | python | train |
IBMStreams/pypi.streamsx | streamsx/rest_primitives.py | https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/rest_primitives.py#L1223-L1245 | def retrieve_console_log(self, filename=None, dir=None):
"""Retrieves the application console log (standard out and error)
files for this PE and saves them as a plain text file.
An existing file with the same name will be overwritten.
Args:
filename (str): name of the creat... | [
"def",
"retrieve_console_log",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"dir",
"=",
"None",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"\"consoleLog\"",
")",
"and",
"self",
".",
"consoleLog",
"is",
"not",
"None",
":",
"logger",
".",
"debug",
"... | Retrieves the application console log (standard out and error)
files for this PE and saves them as a plain text file.
An existing file with the same name will be overwritten.
Args:
filename (str): name of the created file. Defaults to `pe_<id>_<timestamp>.stdouterr` where `id` is t... | [
"Retrieves",
"the",
"application",
"console",
"log",
"(",
"standard",
"out",
"and",
"error",
")",
"files",
"for",
"this",
"PE",
"and",
"saves",
"them",
"as",
"a",
"plain",
"text",
"file",
"."
] | python | train |
jaraco/jaraco.functools | jaraco/functools.py | https://github.com/jaraco/jaraco.functools/blob/cc972095e5aa2ae80d1d69d7ca84ee94178e869a/jaraco/functools.py#L386-L423 | def assign_params(func, namespace):
"""
Assign parameters from namespace where func solicits.
>>> def func(x, y=3):
... print(x, y)
>>> assigned = assign_params(func, dict(x=2, z=4))
>>> assigned()
2 3
The usual errors are raised if a function doesn't receive
its required parameters:
>>> assigned = ass... | [
"def",
"assign_params",
"(",
"func",
",",
"namespace",
")",
":",
"try",
":",
"sig",
"=",
"inspect",
".",
"signature",
"(",
"func",
")",
"params",
"=",
"sig",
".",
"parameters",
".",
"keys",
"(",
")",
"except",
"AttributeError",
":",
"spec",
"=",
"inspe... | Assign parameters from namespace where func solicits.
>>> def func(x, y=3):
... print(x, y)
>>> assigned = assign_params(func, dict(x=2, z=4))
>>> assigned()
2 3
The usual errors are raised if a function doesn't receive
its required parameters:
>>> assigned = assign_params(func, dict(y=3, z=4))
>>> assi... | [
"Assign",
"parameters",
"from",
"namespace",
"where",
"func",
"solicits",
"."
] | python | train |
janpipek/physt | physt/plotting/matplotlib.py | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/plotting/matplotlib.py#L415-L450 | def image(h2: Histogram2D, ax: Axes, *, show_colorbar: bool = True, interpolation: str = "nearest", **kwargs):
"""Plot of 2D histograms based on pixmaps.
Similar to map, but it:
- has fewer options
- is much more effective (enables thousands)
- does not support irregular bins
Parameters
--... | [
"def",
"image",
"(",
"h2",
":",
"Histogram2D",
",",
"ax",
":",
"Axes",
",",
"*",
",",
"show_colorbar",
":",
"bool",
"=",
"True",
",",
"interpolation",
":",
"str",
"=",
"\"nearest\"",
",",
"*",
"*",
"kwargs",
")",
":",
"cmap",
"=",
"_get_cmap",
"(",
... | Plot of 2D histograms based on pixmaps.
Similar to map, but it:
- has fewer options
- is much more effective (enables thousands)
- does not support irregular bins
Parameters
----------
interpolation: interpolation parameter passed to imshow, default: "nearest" (creates rectangles) | [
"Plot",
"of",
"2D",
"histograms",
"based",
"on",
"pixmaps",
"."
] | python | train |
tensorflow/tensor2tensor | tensor2tensor/models/lstm.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/lstm.py#L206-L225 | def lstm_seq2seq_internal_attention(inputs, targets, hparams, train,
inputs_length, targets_length):
"""LSTM seq2seq model with attention, main step used for training."""
with tf.variable_scope("lstm_seq2seq_attention"):
# Flatten inputs.
inputs = common_layers.flatten4d3... | [
"def",
"lstm_seq2seq_internal_attention",
"(",
"inputs",
",",
"targets",
",",
"hparams",
",",
"train",
",",
"inputs_length",
",",
"targets_length",
")",
":",
"with",
"tf",
".",
"variable_scope",
"(",
"\"lstm_seq2seq_attention\"",
")",
":",
"# Flatten inputs.",
"inpu... | LSTM seq2seq model with attention, main step used for training. | [
"LSTM",
"seq2seq",
"model",
"with",
"attention",
"main",
"step",
"used",
"for",
"training",
"."
] | python | train |
keras-rl/keras-rl | rl/policy.py | https://github.com/keras-rl/keras-rl/blob/e6efb0d8297ec38d704a3110b5d6ed74d09a05e3/rl/policy.py#L348-L356 | def get_config(self):
"""Return configurations of BoltzmannGumbelQPolicy
# Returns
Dict of config
"""
config = super(BoltzmannGumbelQPolicy, self).get_config()
config['C'] = self.C
return config | [
"def",
"get_config",
"(",
"self",
")",
":",
"config",
"=",
"super",
"(",
"BoltzmannGumbelQPolicy",
",",
"self",
")",
".",
"get_config",
"(",
")",
"config",
"[",
"'C'",
"]",
"=",
"self",
".",
"C",
"return",
"config"
] | Return configurations of BoltzmannGumbelQPolicy
# Returns
Dict of config | [
"Return",
"configurations",
"of",
"BoltzmannGumbelQPolicy"
] | python | train |
jtwhite79/pyemu | pyemu/sc.py | https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/sc.py#L420-L499 | def get_par_contribution(self,parlist_dict=None,include_prior_results=False):
"""get a dataframe the prior and posterior uncertainty
reduction as a result of some parameter becoming perfectly known
Parameters
----------
parlist_dict : dict
a nested dictionary-list of... | [
"def",
"get_par_contribution",
"(",
"self",
",",
"parlist_dict",
"=",
"None",
",",
"include_prior_results",
"=",
"False",
")",
":",
"self",
".",
"log",
"(",
"\"calculating contribution from parameters\"",
")",
"if",
"parlist_dict",
"is",
"None",
":",
"parlist_dict",... | get a dataframe the prior and posterior uncertainty
reduction as a result of some parameter becoming perfectly known
Parameters
----------
parlist_dict : dict
a nested dictionary-list of groups of parameters
that are to be treated as perfectly known. key values ... | [
"get",
"a",
"dataframe",
"the",
"prior",
"and",
"posterior",
"uncertainty",
"reduction",
"as",
"a",
"result",
"of",
"some",
"parameter",
"becoming",
"perfectly",
"known"
] | python | train |
ARMmbed/mbed-cloud-sdk-python | src/mbed_cloud/billing/billing.py | https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/billing/billing.py#L114-L136 | def get_report_overview(self, month, file_path):
"""Downloads a report overview
:param month: month as datetime instance, or string in YYYY-MM format
:type month: str or datetime
:param str file_path: location to store output file
:return: outcome
:rtype: True or None
... | [
"def",
"get_report_overview",
"(",
"self",
",",
"month",
",",
"file_path",
")",
":",
"api",
"=",
"self",
".",
"_get_api",
"(",
"billing",
".",
"DefaultApi",
")",
"month",
"=",
"self",
".",
"_month_converter",
"(",
"month",
")",
"response",
"=",
"api",
".... | Downloads a report overview
:param month: month as datetime instance, or string in YYYY-MM format
:type month: str or datetime
:param str file_path: location to store output file
:return: outcome
:rtype: True or None | [
"Downloads",
"a",
"report",
"overview"
] | python | train |
tamasgal/km3pipe | km3pipe/math.py | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/math.py#L403-L410 | def g_parameter(time_residual):
"""stolen from thomas"""
mean = np.mean(time_residual)
time_residual_prime = (time_residual - np.ones(time_residual.shape) * mean)
time_residual_prime *= time_residual_prime / (-2 * 1.5 * 1.5)
time_residual_prime = np.exp(time_residual_prime)
g = np.sum(time_resid... | [
"def",
"g_parameter",
"(",
"time_residual",
")",
":",
"mean",
"=",
"np",
".",
"mean",
"(",
"time_residual",
")",
"time_residual_prime",
"=",
"(",
"time_residual",
"-",
"np",
".",
"ones",
"(",
"time_residual",
".",
"shape",
")",
"*",
"mean",
")",
"time_resi... | stolen from thomas | [
"stolen",
"from",
"thomas"
] | python | train |
boriel/zxbasic | arch/zx48k/optimizer.py | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/optimizer.py#L1531-L1563 | def is_used(self, regs, i, top=None):
""" Checks whether any of the given regs are required from the given point
to the end or not.
"""
if i < 0:
i = 0
if self.lock:
return True
regs = list(regs) # make a copy
if top is None:
... | [
"def",
"is_used",
"(",
"self",
",",
"regs",
",",
"i",
",",
"top",
"=",
"None",
")",
":",
"if",
"i",
"<",
"0",
":",
"i",
"=",
"0",
"if",
"self",
".",
"lock",
":",
"return",
"True",
"regs",
"=",
"list",
"(",
"regs",
")",
"# make a copy",
"if",
... | Checks whether any of the given regs are required from the given point
to the end or not. | [
"Checks",
"whether",
"any",
"of",
"the",
"given",
"regs",
"are",
"required",
"from",
"the",
"given",
"point",
"to",
"the",
"end",
"or",
"not",
"."
] | python | train |
horazont/aioxmpp | aioxmpp/private_xml/service.py | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/private_xml/service.py#L43-L60 | def get_private_xml(self, query_xso):
"""
Get the private XML data for the element `query_xso` from the
server.
:param query_xso: the object to retrieve.
:returns: the stored private XML data.
`query_xso` *must* serialize to an empty XML node of the
wanted names... | [
"def",
"get_private_xml",
"(",
"self",
",",
"query_xso",
")",
":",
"iq",
"=",
"aioxmpp",
".",
"IQ",
"(",
"type_",
"=",
"aioxmpp",
".",
"IQType",
".",
"GET",
",",
"payload",
"=",
"private_xml_xso",
".",
"Query",
"(",
"query_xso",
")",
")",
"return",
"("... | Get the private XML data for the element `query_xso` from the
server.
:param query_xso: the object to retrieve.
:returns: the stored private XML data.
`query_xso` *must* serialize to an empty XML node of the
wanted namespace and type and *must* be registered as private
... | [
"Get",
"the",
"private",
"XML",
"data",
"for",
"the",
"element",
"query_xso",
"from",
"the",
"server",
"."
] | python | train |
theislab/anndata | anndata/readwrite/read.py | https://github.com/theislab/anndata/blob/34f4eb63710628fbc15e7050e5efcac1d7806062/anndata/readwrite/read.py#L42-L65 | def read_excel(
filename: PathLike,
sheet: Union[str, int],
dtype: str='float32',
) -> AnnData:
"""Read ``.xlsx`` (Excel) file.
Assumes that the first columns stores the row names and the first row the
column names.
Parameters
----------
filename
File name to read from.
... | [
"def",
"read_excel",
"(",
"filename",
":",
"PathLike",
",",
"sheet",
":",
"Union",
"[",
"str",
",",
"int",
"]",
",",
"dtype",
":",
"str",
"=",
"'float32'",
",",
")",
"->",
"AnnData",
":",
"# rely on pandas for reading an excel file",
"from",
"pandas",
"impor... | Read ``.xlsx`` (Excel) file.
Assumes that the first columns stores the row names and the first row the
column names.
Parameters
----------
filename
File name to read from.
sheet
Name of sheet in Excel file. | [
"Read",
".",
"xlsx",
"(",
"Excel",
")",
"file",
"."
] | python | train |
arne-cl/discoursegraphs | src/discoursegraphs/readwrite/exportxml.py | https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/exportxml.py#L355-L394 | def add_edurange(self, edurange):
"""
Parameters
----------
edurange : etree.Element
etree representation of a <edurange> element
(annotation that groups a number of EDUs)
<edu-range> seems to glue together a number of `<edu> elements,
whic... | [
"def",
"add_edurange",
"(",
"self",
",",
"edurange",
")",
":",
"edurange_id",
"=",
"self",
".",
"get_element_id",
"(",
"edurange",
")",
"edurange_attribs",
"=",
"self",
".",
"element_attribs_to_dict",
"(",
"edurange",
")",
"# contains 'span' or nothing",
"self",
"... | Parameters
----------
edurange : etree.Element
etree representation of a <edurange> element
(annotation that groups a number of EDUs)
<edu-range> seems to glue together a number of `<edu> elements,
which may be scattered over a number of sentences
... | [
"Parameters",
"----------",
"edurange",
":",
"etree",
".",
"Element",
"etree",
"representation",
"of",
"a",
"<edurange",
">",
"element",
"(",
"annotation",
"that",
"groups",
"a",
"number",
"of",
"EDUs",
")",
"<edu",
"-",
"range",
">",
"seems",
"to",
"glue",
... | python | train |
twilio/twilio-python | twilio/rest/preview/sync/service/document/__init__.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/preview/sync/service/document/__init__.py#L356-L370 | def _proxy(self):
"""
Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: DocumentContext for this DocumentInstance
:rtype: twilio.rest.preview.sync.service.document.Docum... | [
"def",
"_proxy",
"(",
"self",
")",
":",
"if",
"self",
".",
"_context",
"is",
"None",
":",
"self",
".",
"_context",
"=",
"DocumentContext",
"(",
"self",
".",
"_version",
",",
"service_sid",
"=",
"self",
".",
"_solution",
"[",
"'service_sid'",
"]",
",",
... | Generate an instance context for the instance, the context is capable of
performing various actions. All instance actions are proxied to the context
:returns: DocumentContext for this DocumentInstance
:rtype: twilio.rest.preview.sync.service.document.DocumentContext | [
"Generate",
"an",
"instance",
"context",
"for",
"the",
"instance",
"the",
"context",
"is",
"capable",
"of",
"performing",
"various",
"actions",
".",
"All",
"instance",
"actions",
"are",
"proxied",
"to",
"the",
"context"
] | python | train |
vertexproject/synapse | synapse/lib/types.py | https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/lib/types.py#L1467-L1490 | def _ctorCmprRange(self, vals):
'''
Override default *range= handler to account for relative computation.
'''
if not isinstance(vals, (list, tuple)):
raise s_exc.BadCmprValu(valu=vals, cmpr='*range=')
if len(vals) != 2:
raise s_exc.BadCmprValu(valu=vals,... | [
"def",
"_ctorCmprRange",
"(",
"self",
",",
"vals",
")",
":",
"if",
"not",
"isinstance",
"(",
"vals",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"raise",
"s_exc",
".",
"BadCmprValu",
"(",
"valu",
"=",
"vals",
",",
"cmpr",
"=",
"'*range='",
")",
... | Override default *range= handler to account for relative computation. | [
"Override",
"default",
"*",
"range",
"=",
"handler",
"to",
"account",
"for",
"relative",
"computation",
"."
] | python | train |
ga4gh/ga4gh-server | ga4gh/server/datamodel/variants.py | https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/datamodel/variants.py#L130-L136 | def addVariantAnnotationSet(self, variantAnnotationSet):
"""
Adds the specified variantAnnotationSet to this dataset.
"""
id_ = variantAnnotationSet.getId()
self._variantAnnotationSetIdMap[id_] = variantAnnotationSet
self._variantAnnotationSetIds.append(id_) | [
"def",
"addVariantAnnotationSet",
"(",
"self",
",",
"variantAnnotationSet",
")",
":",
"id_",
"=",
"variantAnnotationSet",
".",
"getId",
"(",
")",
"self",
".",
"_variantAnnotationSetIdMap",
"[",
"id_",
"]",
"=",
"variantAnnotationSet",
"self",
".",
"_variantAnnotatio... | Adds the specified variantAnnotationSet to this dataset. | [
"Adds",
"the",
"specified",
"variantAnnotationSet",
"to",
"this",
"dataset",
"."
] | python | train |
mitsei/dlkit | dlkit/handcar/learning/managers.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/learning/managers.py#L805-L827 | def get_objective_search_session(self):
"""Gets the OsidSession associated with the objective search
service.
return: (osid.learning.ObjectiveSearchSession) - an
ObjectiveSearchSession
raise: OperationFailed - unable to complete request
raise: Unimplemented - s... | [
"def",
"get_objective_search_session",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"supports_objective_search",
"(",
")",
":",
"raise",
"Unimplemented",
"(",
")",
"try",
":",
"from",
".",
"import",
"sessions",
"except",
"ImportError",
":",
"raise",
"Opera... | Gets the OsidSession associated with the objective search
service.
return: (osid.learning.ObjectiveSearchSession) - an
ObjectiveSearchSession
raise: OperationFailed - unable to complete request
raise: Unimplemented - supports_objective_search() is false
complia... | [
"Gets",
"the",
"OsidSession",
"associated",
"with",
"the",
"objective",
"search",
"service",
"."
] | python | train |
opencobra/cobrapy | cobra/io/mat.py | https://github.com/opencobra/cobrapy/blob/9d1987cdb3a395cf4125a3439c3b002ff2be2009/cobra/io/mat.py#L268-L302 | def model_to_pymatbridge(model, variable_name="model", matlab=None):
"""send the model to a MATLAB workspace through pymatbridge
This model can then be manipulated through the COBRA toolbox
Parameters
----------
variable_name : str
The variable name to which the model will be assigned in t... | [
"def",
"model_to_pymatbridge",
"(",
"model",
",",
"variable_name",
"=",
"\"model\"",
",",
"matlab",
"=",
"None",
")",
":",
"if",
"scipy_sparse",
"is",
"None",
":",
"raise",
"ImportError",
"(",
"\"`model_to_pymatbridge` requires scipy!\"",
")",
"if",
"matlab",
"is"... | send the model to a MATLAB workspace through pymatbridge
This model can then be manipulated through the COBRA toolbox
Parameters
----------
variable_name : str
The variable name to which the model will be assigned in the
MATLAB workspace
matlab : None or pymatbridge.Matlab instanc... | [
"send",
"the",
"model",
"to",
"a",
"MATLAB",
"workspace",
"through",
"pymatbridge"
] | python | valid |
welbornprod/colr | examples/walk_dir.py | https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/examples/walk_dir.py#L91-L121 | def walk_dir_animated(path, maxdircnt=1000):
""" Walk a directory, printing status updates along the way. """
p = AnimatedProgress(
'Walking {}...'.format(path),
frames=Frames.dots_orbit.as_rainbow(),
show_time=True,
)
rootcnt = 0
print('\nStarting animated progress.')
wi... | [
"def",
"walk_dir_animated",
"(",
"path",
",",
"maxdircnt",
"=",
"1000",
")",
":",
"p",
"=",
"AnimatedProgress",
"(",
"'Walking {}...'",
".",
"format",
"(",
"path",
")",
",",
"frames",
"=",
"Frames",
".",
"dots_orbit",
".",
"as_rainbow",
"(",
")",
",",
"s... | Walk a directory, printing status updates along the way. | [
"Walk",
"a",
"directory",
"printing",
"status",
"updates",
"along",
"the",
"way",
"."
] | python | train |
vertexproject/synapse | synapse/daemon.py | https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/daemon.py#L175-L192 | def share(self, name, item):
'''
Share an object via the telepath protocol.
Args:
name (str): Name of the shared object
item (object): The object to share over telepath.
'''
try:
if isinstance(item, s_telepath.Aware):
item.on... | [
"def",
"share",
"(",
"self",
",",
"name",
",",
"item",
")",
":",
"try",
":",
"if",
"isinstance",
"(",
"item",
",",
"s_telepath",
".",
"Aware",
")",
":",
"item",
".",
"onTeleShare",
"(",
"self",
",",
"name",
")",
"self",
".",
"shared",
"[",
"name",
... | Share an object via the telepath protocol.
Args:
name (str): Name of the shared object
item (object): The object to share over telepath. | [
"Share",
"an",
"object",
"via",
"the",
"telepath",
"protocol",
"."
] | python | train |
MacHu-GWU/pymongo_mate-project | pymongo_mate/pkg/pandas_mate/pkg/rolex/__init__.py | https://github.com/MacHu-GWU/pymongo_mate-project/blob/be53170c2db54cb705b9e548d32ef26c773ff7f3/pymongo_mate/pkg/pandas_mate/pkg/rolex/__init__.py#L217-L240 | def to_utctimestamp(self, dt):
"""Calculate number of seconds from UTC 1970-01-01 00:00:00.
When:
- dt doesn't have tzinfo: assume it's a utc time
- dt has tzinfo: use tzinfo
WARNING, if your datetime object doens't have ``tzinfo``, make sure
it's a UTC time, but **NOT... | [
"def",
"to_utctimestamp",
"(",
"self",
",",
"dt",
")",
":",
"if",
"dt",
".",
"tzinfo",
"is",
"None",
":",
"dt",
"=",
"dt",
".",
"replace",
"(",
"tzinfo",
"=",
"utc",
")",
"delta",
"=",
"dt",
"-",
"datetime",
"(",
"1970",
",",
"1",
",",
"1",
","... | Calculate number of seconds from UTC 1970-01-01 00:00:00.
When:
- dt doesn't have tzinfo: assume it's a utc time
- dt has tzinfo: use tzinfo
WARNING, if your datetime object doens't have ``tzinfo``, make sure
it's a UTC time, but **NOT a LOCAL TIME**.
**中文文档**
... | [
"Calculate",
"number",
"of",
"seconds",
"from",
"UTC",
"1970",
"-",
"01",
"-",
"01",
"00",
":",
"00",
":",
"00",
"."
] | python | train |
phaethon/kamene | kamene/sendrecv.py | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/sendrecv.py#L629-L692 | def bridge_and_sniff(if1, if2, count=0, store=1, offline=None, prn = None, lfilter=None, L2socket=None, timeout=None,
stop_filter=None, stop_callback=None, *args, **kargs):
"""Forward traffic between two interfaces and sniff packets exchanged
bridge_and_sniff([count=0,] [prn=None,] [store=1,] [... | [
"def",
"bridge_and_sniff",
"(",
"if1",
",",
"if2",
",",
"count",
"=",
"0",
",",
"store",
"=",
"1",
",",
"offline",
"=",
"None",
",",
"prn",
"=",
"None",
",",
"lfilter",
"=",
"None",
",",
"L2socket",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
... | Forward traffic between two interfaces and sniff packets exchanged
bridge_and_sniff([count=0,] [prn=None,] [store=1,] [offline=None,] [lfilter=None,] + L2Socket args) -> list of packets
count: number of packets to capture. 0 means infinity
store: wether to store sniffed packets or discard them
prn: function to... | [
"Forward",
"traffic",
"between",
"two",
"interfaces",
"and",
"sniff",
"packets",
"exchanged",
"bridge_and_sniff",
"(",
"[",
"count",
"=",
"0",
"]",
"[",
"prn",
"=",
"None",
"]",
"[",
"store",
"=",
"1",
"]",
"[",
"offline",
"=",
"None",
"]",
"[",
"lfilt... | python | train |
hydpy-dev/hydpy | hydpy/auxs/armatools.py | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/auxs/armatools.py#L676-L692 | def calc_next_ma_coef(self, ma_order, ma_model):
"""Determine the MA coefficients of the ARMA model based on its
predetermined AR coefficients and the MA ordinates of the given
|MA| model.
The MA coefficients are determined one at a time, beginning with the
first one. Each ARMA... | [
"def",
"calc_next_ma_coef",
"(",
"self",
",",
"ma_order",
",",
"ma_model",
")",
":",
"idx",
"=",
"ma_order",
"-",
"1",
"coef",
"=",
"ma_model",
".",
"coefs",
"[",
"idx",
"]",
"for",
"jdx",
",",
"ar_coef",
"in",
"enumerate",
"(",
"self",
".",
"ar_coefs"... | Determine the MA coefficients of the ARMA model based on its
predetermined AR coefficients and the MA ordinates of the given
|MA| model.
The MA coefficients are determined one at a time, beginning with the
first one. Each ARMA MA coefficient in set in a manner that allows
for t... | [
"Determine",
"the",
"MA",
"coefficients",
"of",
"the",
"ARMA",
"model",
"based",
"on",
"its",
"predetermined",
"AR",
"coefficients",
"and",
"the",
"MA",
"ordinates",
"of",
"the",
"given",
"|MA|",
"model",
"."
] | python | train |
bcbio/bcbio-nextgen | bcbio/pipeline/shared.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/pipeline/shared.py#L161-L173 | def add_highdepth_genome_exclusion(items):
"""Add exclusions to input items to avoid slow runtimes on whole genomes.
"""
out = []
for d in items:
d = utils.deepish_copy(d)
if dd.get_coverage_interval(d) == "genome":
e = dd.get_exclude_regions(d)
if "highdepth" not... | [
"def",
"add_highdepth_genome_exclusion",
"(",
"items",
")",
":",
"out",
"=",
"[",
"]",
"for",
"d",
"in",
"items",
":",
"d",
"=",
"utils",
".",
"deepish_copy",
"(",
"d",
")",
"if",
"dd",
".",
"get_coverage_interval",
"(",
"d",
")",
"==",
"\"genome\"",
"... | Add exclusions to input items to avoid slow runtimes on whole genomes. | [
"Add",
"exclusions",
"to",
"input",
"items",
"to",
"avoid",
"slow",
"runtimes",
"on",
"whole",
"genomes",
"."
] | python | train |
andrewsnowden/dota2py | dota2py/api.py | https://github.com/andrewsnowden/dota2py/blob/67637f4b9c160ea90c11b7e81545baf350affa7a/dota2py/api.py#L152-L158 | def get_steam_id(vanityurl, **kwargs):
"""
Get a players steam id from their steam name/vanity url
"""
params = {"vanityurl": vanityurl}
return make_request("ResolveVanityURL", params, version="v0001",
base="http://api.steampowered.com/ISteamUser/", **kwargs) | [
"def",
"get_steam_id",
"(",
"vanityurl",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"{",
"\"vanityurl\"",
":",
"vanityurl",
"}",
"return",
"make_request",
"(",
"\"ResolveVanityURL\"",
",",
"params",
",",
"version",
"=",
"\"v0001\"",
",",
"base",
"=",
... | Get a players steam id from their steam name/vanity url | [
"Get",
"a",
"players",
"steam",
"id",
"from",
"their",
"steam",
"name",
"/",
"vanity",
"url"
] | python | train |
jasonbot/arcrest | arcrest/server.py | https://github.com/jasonbot/arcrest/blob/b1ba71fd59bb6349415e7879d753d307dbc0da26/arcrest/server.py#L1043-L1053 | def candidates(self):
"""A list of candidate addresses (as dictionaries) from a geocode
operation"""
# convert x['location'] to a point from a json point struct
def cditer():
for candidate in self._json_struct['candidates']:
newcandidate = candidate.copy()
... | [
"def",
"candidates",
"(",
"self",
")",
":",
"# convert x['location'] to a point from a json point struct",
"def",
"cditer",
"(",
")",
":",
"for",
"candidate",
"in",
"self",
".",
"_json_struct",
"[",
"'candidates'",
"]",
":",
"newcandidate",
"=",
"candidate",
".",
... | A list of candidate addresses (as dictionaries) from a geocode
operation | [
"A",
"list",
"of",
"candidate",
"addresses",
"(",
"as",
"dictionaries",
")",
"from",
"a",
"geocode",
"operation"
] | python | train |
Alignak-monitoring/alignak | alignak/external_command.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/external_command.py#L3573-L3589 | def schedule_host_check(self, host, check_time):
"""Schedule a check on a host
Format of the line that triggers function call::
SCHEDULE_HOST_CHECK;<host_name>;<check_time>
:param host: host to check
:type host: alignak.object.host.Host
:param check_time: time to check
... | [
"def",
"schedule_host_check",
"(",
"self",
",",
"host",
",",
"check_time",
")",
":",
"host",
".",
"schedule",
"(",
"self",
".",
"daemon",
".",
"hosts",
",",
"self",
".",
"daemon",
".",
"services",
",",
"self",
".",
"daemon",
".",
"timeperiods",
",",
"s... | Schedule a check on a host
Format of the line that triggers function call::
SCHEDULE_HOST_CHECK;<host_name>;<check_time>
:param host: host to check
:type host: alignak.object.host.Host
:param check_time: time to check
:type check_time:
:return: None | [
"Schedule",
"a",
"check",
"on",
"a",
"host",
"Format",
"of",
"the",
"line",
"that",
"triggers",
"function",
"call",
"::"
] | python | train |
Rapptz/discord.py | discord/webhook.py | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/webhook.py#L645-L733 | def send(self, content=None, *, wait=False, username=None, avatar_url=None, tts=False,
file=None, files=None, embed=None, embeds=None):
"""|maybecoro|
Sends a message using the webhook.
If the webhook is constructed with a :class:`RequestsWebhookAdapter` the... | [
"def",
"send",
"(",
"self",
",",
"content",
"=",
"None",
",",
"*",
",",
"wait",
"=",
"False",
",",
"username",
"=",
"None",
",",
"avatar_url",
"=",
"None",
",",
"tts",
"=",
"False",
",",
"file",
"=",
"None",
",",
"files",
"=",
"None",
",",
"embed... | |maybecoro|
Sends a message using the webhook.
If the webhook is constructed with a :class:`RequestsWebhookAdapter` then this is
not a coroutine.
The content must be a type that can convert to a string through ``str(content)``.
To upload a single file, the ``file`` parameter ... | [
"|maybecoro|"
] | python | train |
Parquery/icontract | icontract/_metaclass.py | https://github.com/Parquery/icontract/blob/846e3187869a9ba790e9b893c98e5055e1cce274/icontract/_metaclass.py#L16-L31 | def _collapse_invariants(bases: List[type], namespace: MutableMapping[str, Any]) -> None:
"""Collect invariants from the bases and merge them with the invariants in the namespace."""
invariants = [] # type: List[Contract]
# Add invariants of the bases
for base in bases:
if hasattr(base, "__inv... | [
"def",
"_collapse_invariants",
"(",
"bases",
":",
"List",
"[",
"type",
"]",
",",
"namespace",
":",
"MutableMapping",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"None",
":",
"invariants",
"=",
"[",
"]",
"# type: List[Contract]",
"# Add invariants of the bases",
"f... | Collect invariants from the bases and merge them with the invariants in the namespace. | [
"Collect",
"invariants",
"from",
"the",
"bases",
"and",
"merge",
"them",
"with",
"the",
"invariants",
"in",
"the",
"namespace",
"."
] | python | train |
luizirber/bioinfo | bioinfo/__init__.py | https://github.com/luizirber/bioinfo/blob/756758f62b4f7136cdb54de2f79033ff0226a6b7/bioinfo/__init__.py#L37-L46 | def main():
'''Main entry point for the bioinfo CLI.'''
args = docopt(__doc__, version=__version__)
if 'bam_coverage' in args:
bam_coverage(args['<reference>'],
args['<alignments>'],
int(args['<minmatch>']),
min_mapq=int(args['--mapq'])... | [
"def",
"main",
"(",
")",
":",
"args",
"=",
"docopt",
"(",
"__doc__",
",",
"version",
"=",
"__version__",
")",
"if",
"'bam_coverage'",
"in",
"args",
":",
"bam_coverage",
"(",
"args",
"[",
"'<reference>'",
"]",
",",
"args",
"[",
"'<alignments>'",
"]",
",",... | Main entry point for the bioinfo CLI. | [
"Main",
"entry",
"point",
"for",
"the",
"bioinfo",
"CLI",
"."
] | python | train |
minhhoit/yacms | yacms/forms/forms.py | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/forms/forms.py#L321-L329 | def columns(self):
"""
Returns the list of selected column names.
"""
fields = [f.label for f in self.form_fields
if self.cleaned_data["field_%s_export" % f.id]]
if self.cleaned_data["field_0_export"]:
fields.append(self.entry_time_name)
retu... | [
"def",
"columns",
"(",
"self",
")",
":",
"fields",
"=",
"[",
"f",
".",
"label",
"for",
"f",
"in",
"self",
".",
"form_fields",
"if",
"self",
".",
"cleaned_data",
"[",
"\"field_%s_export\"",
"%",
"f",
".",
"id",
"]",
"]",
"if",
"self",
".",
"cleaned_da... | Returns the list of selected column names. | [
"Returns",
"the",
"list",
"of",
"selected",
"column",
"names",
"."
] | python | train |
saltstack/salt | salt/utils/network.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1118-L1137 | def _hw_addr_aix(iface):
'''
Return the hardware address (a.k.a. MAC address) for a given interface on AIX
MAC address not available in through interfaces
'''
cmd = subprocess.Popen(
'entstat -d {0} | grep \'Hardware Address\''.format(iface),
shell=True,
stdout=subprocess.PIP... | [
"def",
"_hw_addr_aix",
"(",
"iface",
")",
":",
"cmd",
"=",
"subprocess",
".",
"Popen",
"(",
"'entstat -d {0} | grep \\'Hardware Address\\''",
".",
"format",
"(",
"iface",
")",
",",
"shell",
"=",
"True",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"st... | Return the hardware address (a.k.a. MAC address) for a given interface on AIX
MAC address not available in through interfaces | [
"Return",
"the",
"hardware",
"address",
"(",
"a",
".",
"k",
".",
"a",
".",
"MAC",
"address",
")",
"for",
"a",
"given",
"interface",
"on",
"AIX",
"MAC",
"address",
"not",
"available",
"in",
"through",
"interfaces"
] | python | train |
postlund/pyatv | pyatv/mrp/messages.py | https://github.com/postlund/pyatv/blob/655dfcda4e2f9d1c501540e18da4f480d8bf0e70/pyatv/mrp/messages.py#L73-L82 | def register_hid_device(screen_width, screen_height,
absolute=False, integrated_display=False):
"""Create a new REGISTER_HID_DEVICE_MESSAGE."""
message = create(protobuf.REGISTER_HID_DEVICE_MESSAGE)
descriptor = message.inner().deviceDescriptor
descriptor.absolute = 1 if absolute... | [
"def",
"register_hid_device",
"(",
"screen_width",
",",
"screen_height",
",",
"absolute",
"=",
"False",
",",
"integrated_display",
"=",
"False",
")",
":",
"message",
"=",
"create",
"(",
"protobuf",
".",
"REGISTER_HID_DEVICE_MESSAGE",
")",
"descriptor",
"=",
"messa... | Create a new REGISTER_HID_DEVICE_MESSAGE. | [
"Create",
"a",
"new",
"REGISTER_HID_DEVICE_MESSAGE",
"."
] | python | train |
authomatic/authomatic | authomatic/providers/__init__.py | https://github.com/authomatic/authomatic/blob/90a9ce60cc405ae8a2bf5c3713acd5d78579a04e/authomatic/providers/__init__.py#L336-L353 | def _log(cls, level, msg, **kwargs):
"""
Logs a message with pre-formatted prefix.
:param int level:
Logging level as specified in the
`login module <http://docs.python.org/2/library/logging.html>`_ of
Python standard library.
:param str msg:
... | [
"def",
"_log",
"(",
"cls",
",",
"level",
",",
"msg",
",",
"*",
"*",
"kwargs",
")",
":",
"logger",
"=",
"getattr",
"(",
"cls",
",",
"'_logger'",
",",
"None",
")",
"or",
"authomatic",
".",
"core",
".",
"_logger",
"logger",
".",
"log",
"(",
"level",
... | Logs a message with pre-formatted prefix.
:param int level:
Logging level as specified in the
`login module <http://docs.python.org/2/library/logging.html>`_ of
Python standard library.
:param str msg:
The actual message. | [
"Logs",
"a",
"message",
"with",
"pre",
"-",
"formatted",
"prefix",
"."
] | python | test |
bpannier/simpletr64 | simpletr64/devicetr64.py | https://github.com/bpannier/simpletr64/blob/31081139f4e6c85084a56de1617df73927135466/simpletr64/devicetr64.py#L836-L923 | def _loadSCPD(self, serviceType, timeout):
"""Internal method to load the action definitions.
:param str serviceType: the service type to load
:param int timeout: the timeout for downloading
"""
if serviceType not in self.__deviceServiceDefinitions.keys():
raise Val... | [
"def",
"_loadSCPD",
"(",
"self",
",",
"serviceType",
",",
"timeout",
")",
":",
"if",
"serviceType",
"not",
"in",
"self",
".",
"__deviceServiceDefinitions",
".",
"keys",
"(",
")",
":",
"raise",
"ValueError",
"(",
"\"Can not load SCPD, no service type defined for: \""... | Internal method to load the action definitions.
:param str serviceType: the service type to load
:param int timeout: the timeout for downloading | [
"Internal",
"method",
"to",
"load",
"the",
"action",
"definitions",
"."
] | python | train |
mitsei/dlkit | dlkit/json_/repository/objects.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/repository/objects.py#L1228-L1239 | def set_principal_credit_string(self, credit_string):
"""Sets the principal credit string.
arg: credit_string (string): the new credit string
raise: InvalidArgument - ``credit_string`` is invalid
raise: NoAccess - ``Metadata.isReadOnly()`` is ``true``
raise: NullArgument -... | [
"def",
"set_principal_credit_string",
"(",
"self",
",",
"credit_string",
")",
":",
"# Implemented from template for osid.repository.AssetForm.set_title_template",
"self",
".",
"_my_map",
"[",
"'principalCreditString'",
"]",
"=",
"self",
".",
"_get_display_text",
"(",
"credit_... | Sets the principal credit string.
arg: credit_string (string): the new credit string
raise: InvalidArgument - ``credit_string`` is invalid
raise: NoAccess - ``Metadata.isReadOnly()`` is ``true``
raise: NullArgument - ``credit_string`` is ``null``
*compliance: mandatory -- ... | [
"Sets",
"the",
"principal",
"credit",
"string",
"."
] | python | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/models/neural_network/quantization_utils.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/models/neural_network/quantization_utils.py#L96-L117 | def _get_linear_lookup_table_and_weight(nbits, wp):
"""
Generate a linear lookup table.
:param nbits: int
Number of bits to represent a quantized weight value
:param wp: numpy.array
Weight blob to be quantized
Returns
-------
lookup_table: numpy.array
Lookup table ... | [
"def",
"_get_linear_lookup_table_and_weight",
"(",
"nbits",
",",
"wp",
")",
":",
"w",
"=",
"wp",
".",
"reshape",
"(",
"1",
",",
"-",
"1",
")",
"qw",
",",
"scales",
",",
"biases",
"=",
"_quantize_channelwise_linear",
"(",
"w",
",",
"nbits",
",",
"axis",
... | Generate a linear lookup table.
:param nbits: int
Number of bits to represent a quantized weight value
:param wp: numpy.array
Weight blob to be quantized
Returns
-------
lookup_table: numpy.array
Lookup table of shape (2^nbits, )
qw: numpy.array
Decomposed bit ... | [
"Generate",
"a",
"linear",
"lookup",
"table",
"."
] | python | train |
pallets/werkzeug | src/werkzeug/local.py | https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/local.py#L150-L161 | def pop(self):
"""Removes the topmost item from the stack, will return the
old value or `None` if the stack was already empty.
"""
stack = getattr(self._local, "stack", None)
if stack is None:
return None
elif len(stack) == 1:
release_local(self._l... | [
"def",
"pop",
"(",
"self",
")",
":",
"stack",
"=",
"getattr",
"(",
"self",
".",
"_local",
",",
"\"stack\"",
",",
"None",
")",
"if",
"stack",
"is",
"None",
":",
"return",
"None",
"elif",
"len",
"(",
"stack",
")",
"==",
"1",
":",
"release_local",
"("... | Removes the topmost item from the stack, will return the
old value or `None` if the stack was already empty. | [
"Removes",
"the",
"topmost",
"item",
"from",
"the",
"stack",
"will",
"return",
"the",
"old",
"value",
"or",
"None",
"if",
"the",
"stack",
"was",
"already",
"empty",
"."
] | python | train |
bitlabstudio/django-development-fabfile | development_fabfile/fabfile/remote.py | https://github.com/bitlabstudio/django-development-fabfile/blob/a135c6eb5bdd0b496a7eccfd271aca558dd99243/development_fabfile/fabfile/remote.py#L131-L144 | def run_export_db(filename=None):
"""
Exports the database on the server.
Usage::
fab prod run_export_db
fab prod run_export_db:filename=foobar.dump
"""
if not filename:
filename = settings.DB_DUMP_FILENAME
with cd(settings.FAB_SETTING('SERVER_PROJECT_ROOT')):
... | [
"def",
"run_export_db",
"(",
"filename",
"=",
"None",
")",
":",
"if",
"not",
"filename",
":",
"filename",
"=",
"settings",
".",
"DB_DUMP_FILENAME",
"with",
"cd",
"(",
"settings",
".",
"FAB_SETTING",
"(",
"'SERVER_PROJECT_ROOT'",
")",
")",
":",
"run_workon",
... | Exports the database on the server.
Usage::
fab prod run_export_db
fab prod run_export_db:filename=foobar.dump | [
"Exports",
"the",
"database",
"on",
"the",
"server",
"."
] | python | train |
zacernst/timed_dict | timed_dict/timed_dict.py | https://github.com/zacernst/timed_dict/blob/01a1d145d246832e63c2e92e11d91cac5c3f2d1e/timed_dict/timed_dict.py#L198-L221 | def set_expiration(self, key, ignore_missing=False,
additional_seconds=None, seconds=None):
'''
Alters the expiration time for a key. If the key is not
present, then raise an Exception unless `ignore_missing`
is set to `True`.
Args:
key: The key whose exp... | [
"def",
"set_expiration",
"(",
"self",
",",
"key",
",",
"ignore_missing",
"=",
"False",
",",
"additional_seconds",
"=",
"None",
",",
"seconds",
"=",
"None",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"time_dict",
"and",
"ignore_missing",
":",
"return"... | Alters the expiration time for a key. If the key is not
present, then raise an Exception unless `ignore_missing`
is set to `True`.
Args:
key: The key whose expiration we are changing.
ignore_missing (bool): If set, then return silently
if the key does not... | [
"Alters",
"the",
"expiration",
"time",
"for",
"a",
"key",
".",
"If",
"the",
"key",
"is",
"not",
"present",
"then",
"raise",
"an",
"Exception",
"unless",
"ignore_missing",
"is",
"set",
"to",
"True",
"."
] | python | train |
brechtm/rinohtype | src/rinoh/backend/pdf/xobject/purepng.py | https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L2625-L2662 | def read(self, lenient=False):
"""
Read the PNG file and decode it.
Returns (`width`, `height`, `pixels`, `metadata`).
May use excessive memory.
`pixels` are returned in boxed row flat pixel format.
If the optional `lenient` argument evaluates to True,
checksu... | [
"def",
"read",
"(",
"self",
",",
"lenient",
"=",
"False",
")",
":",
"self",
".",
"preamble",
"(",
"lenient",
"=",
"lenient",
")",
"raw",
"=",
"self",
".",
"idatdecomp",
"(",
"lenient",
")",
"if",
"self",
".",
"interlace",
":",
"raw",
"=",
"bytearray"... | Read the PNG file and decode it.
Returns (`width`, `height`, `pixels`, `metadata`).
May use excessive memory.
`pixels` are returned in boxed row flat pixel format.
If the optional `lenient` argument evaluates to True,
checksum failures will raise warnings rather than exceptio... | [
"Read",
"the",
"PNG",
"file",
"and",
"decode",
"it",
"."
] | python | train |
ejeschke/ginga | ginga/rv/plugins/Colorbar.py | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Colorbar.py#L130-L140 | def rgbmap_cb(self, rgbmap, channel):
"""
This method is called when the RGBMap is changed. We update
the ColorBar to match.
"""
if not self.gui_up:
return
fitsimage = channel.fitsimage
if fitsimage != self.fv.getfocus_fitsimage():
return ... | [
"def",
"rgbmap_cb",
"(",
"self",
",",
"rgbmap",
",",
"channel",
")",
":",
"if",
"not",
"self",
".",
"gui_up",
":",
"return",
"fitsimage",
"=",
"channel",
".",
"fitsimage",
"if",
"fitsimage",
"!=",
"self",
".",
"fv",
".",
"getfocus_fitsimage",
"(",
")",
... | This method is called when the RGBMap is changed. We update
the ColorBar to match. | [
"This",
"method",
"is",
"called",
"when",
"the",
"RGBMap",
"is",
"changed",
".",
"We",
"update",
"the",
"ColorBar",
"to",
"match",
"."
] | python | train |
saltstack/salt | salt/modules/boto_s3_bucket.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_s3_bucket.py#L778-L807 | def put_versioning(Bucket, Status, MFADelete=None, MFA=None,
region=None, key=None, keyid=None, profile=None):
'''
Given a valid config, update the versioning configuration for a bucket.
Returns {updated: true} if versioning configuration was updated and returns
{updated: False} if versionin... | [
"def",
"put_versioning",
"(",
"Bucket",
",",
"Status",
",",
"MFADelete",
"=",
"None",
",",
"MFA",
"=",
"None",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"try",
":",
"conn"... | Given a valid config, update the versioning configuration for a bucket.
Returns {updated: true} if versioning configuration was updated and returns
{updated: False} if versioning configuration was not updated.
CLI Example:
.. code-block:: bash
salt myminion boto_s3_bucket.put_versioning my_b... | [
"Given",
"a",
"valid",
"config",
"update",
"the",
"versioning",
"configuration",
"for",
"a",
"bucket",
"."
] | python | train |
lpantano/seqcluster | seqcluster/libs/thinkbayes.py | https://github.com/lpantano/seqcluster/blob/774e23add8cd4fdc83d626cea3bd1f458e7d060d/seqcluster/libs/thinkbayes.py#L1389-L1399 | def Percentile(pmf, percentage):
"""Computes a percentile of a given Pmf.
percentage: float 0-100
"""
p = percentage / 100.0
total = 0
for val, prob in pmf.Items():
total += prob
if total >= p:
return val | [
"def",
"Percentile",
"(",
"pmf",
",",
"percentage",
")",
":",
"p",
"=",
"percentage",
"/",
"100.0",
"total",
"=",
"0",
"for",
"val",
",",
"prob",
"in",
"pmf",
".",
"Items",
"(",
")",
":",
"total",
"+=",
"prob",
"if",
"total",
">=",
"p",
":",
"ret... | Computes a percentile of a given Pmf.
percentage: float 0-100 | [
"Computes",
"a",
"percentile",
"of",
"a",
"given",
"Pmf",
"."
] | python | train |
openego/ding0 | ding0/grid/mv_grid/util/data_input.py | https://github.com/openego/ding0/blob/e2d6528f96255e4bb22ba15514a4f1883564ed5d/ding0/grid/mv_grid/util/data_input.py#L221-L248 | def _create_node_matrix_from_coord_section(specs):
"""Transformed parsed data from NODE_COORD_SECTION into an upper triangular matrix
Calculates distances between nodes
'MATRIX' key added to `specs`
"""
distances = specs['NODE_COORD_SECTION']
specs['MATRIX'] = {}
for i in distances:
... | [
"def",
"_create_node_matrix_from_coord_section",
"(",
"specs",
")",
":",
"distances",
"=",
"specs",
"[",
"'NODE_COORD_SECTION'",
"]",
"specs",
"[",
"'MATRIX'",
"]",
"=",
"{",
"}",
"for",
"i",
"in",
"distances",
":",
"origin",
"=",
"tuple",
"(",
"distances",
... | Transformed parsed data from NODE_COORD_SECTION into an upper triangular matrix
Calculates distances between nodes
'MATRIX' key added to `specs` | [
"Transformed",
"parsed",
"data",
"from",
"NODE_COORD_SECTION",
"into",
"an",
"upper",
"triangular",
"matrix"
] | python | train |
apache/spark | python/pyspark/cloudpickle.py | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/cloudpickle.py#L799-L816 | def save_attrgetter(self, obj):
"""attrgetter serializer"""
class Dummy(object):
def __init__(self, attrs, index=None):
self.attrs = attrs
self.index = index
def __getattribute__(self, item):
attrs = object.__getattribute__(self, "a... | [
"def",
"save_attrgetter",
"(",
"self",
",",
"obj",
")",
":",
"class",
"Dummy",
"(",
"object",
")",
":",
"def",
"__init__",
"(",
"self",
",",
"attrs",
",",
"index",
"=",
"None",
")",
":",
"self",
".",
"attrs",
"=",
"attrs",
"self",
".",
"index",
"="... | attrgetter serializer | [
"attrgetter",
"serializer"
] | python | train |
hyperledger/indy-sdk | wrappers/python/indy/anoncreds.py | https://github.com/hyperledger/indy-sdk/blob/55240dc170308d7883c48f03f308130a6d077be6/wrappers/python/indy/anoncreds.py#L1247-L1364 | async def verifier_verify_proof(proof_request_json: str,
proof_json: str,
schemas_json: str,
credential_defs_json: str,
rev_reg_defs_json: str,
rev_regs_json: s... | [
"async",
"def",
"verifier_verify_proof",
"(",
"proof_request_json",
":",
"str",
",",
"proof_json",
":",
"str",
",",
"schemas_json",
":",
"str",
",",
"credential_defs_json",
":",
"str",
",",
"rev_reg_defs_json",
":",
"str",
",",
"rev_regs_json",
":",
"str",
")",
... | Verifies a proof (of multiple credential).
All required schemas, public keys and revocation registries must be provided.
:param proof_request_json:
{
"name": string,
"version": string,
"nonce": string,
"requested_attributes": { // set of requested a... | [
"Verifies",
"a",
"proof",
"(",
"of",
"multiple",
"credential",
")",
".",
"All",
"required",
"schemas",
"public",
"keys",
"and",
"revocation",
"registries",
"must",
"be",
"provided",
"."
] | python | train |
pyQode/pyqode.core | pyqode/core/widgets/output_window.py | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/output_window.py#L1246-L1258 | def _linefeed(self):
"""
Performs a line feed.
"""
last_line = self._cursor.blockNumber() == self._text_edit.blockCount() - 1
if self._cursor.atEnd() or last_line:
if last_line:
self._cursor.movePosition(self._cursor.EndOfBlock)
self._curso... | [
"def",
"_linefeed",
"(",
"self",
")",
":",
"last_line",
"=",
"self",
".",
"_cursor",
".",
"blockNumber",
"(",
")",
"==",
"self",
".",
"_text_edit",
".",
"blockCount",
"(",
")",
"-",
"1",
"if",
"self",
".",
"_cursor",
".",
"atEnd",
"(",
")",
"or",
"... | Performs a line feed. | [
"Performs",
"a",
"line",
"feed",
"."
] | python | train |
edx/edx-search | search/elastic.py | https://github.com/edx/edx-search/blob/476cf02b71ceba34ae7d8b798f36d60692317c55/search/elastic.py#L64-L90 | def _get_filter_field(field_name, field_value):
""" Return field to apply into filter, if an array then use a range, otherwise look for a term match """
filter_field = None
if isinstance(field_value, ValueRange):
range_values = {}
if field_value.lower:
range_values.update({"gte":... | [
"def",
"_get_filter_field",
"(",
"field_name",
",",
"field_value",
")",
":",
"filter_field",
"=",
"None",
"if",
"isinstance",
"(",
"field_value",
",",
"ValueRange",
")",
":",
"range_values",
"=",
"{",
"}",
"if",
"field_value",
".",
"lower",
":",
"range_values"... | Return field to apply into filter, if an array then use a range, otherwise look for a term match | [
"Return",
"field",
"to",
"apply",
"into",
"filter",
"if",
"an",
"array",
"then",
"use",
"a",
"range",
"otherwise",
"look",
"for",
"a",
"term",
"match"
] | python | valid |
tcalmant/ipopo | pelix/shell/parser.py | https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/parser.py#L382-L416 | def get_ns_command(self, cmd_name):
"""
Retrieves the name space and the command associated to the given
command name.
:param cmd_name: The given command name
:return: A 2-tuple (name space, command)
:raise ValueError: Unknown command name
"""
namespace, ... | [
"def",
"get_ns_command",
"(",
"self",
",",
"cmd_name",
")",
":",
"namespace",
",",
"command",
"=",
"_split_ns_command",
"(",
"cmd_name",
")",
"if",
"not",
"namespace",
":",
"# Name space not given, look for the command",
"spaces",
"=",
"self",
".",
"__find_command_n... | Retrieves the name space and the command associated to the given
command name.
:param cmd_name: The given command name
:return: A 2-tuple (name space, command)
:raise ValueError: Unknown command name | [
"Retrieves",
"the",
"name",
"space",
"and",
"the",
"command",
"associated",
"to",
"the",
"given",
"command",
"name",
"."
] | python | train |
MediaFire/mediafire-python-open-sdk | mediafire/client.py | https://github.com/MediaFire/mediafire-python-open-sdk/blob/8f1f23db1b16f16e026f5c6777aec32d00baa05f/mediafire/client.py#L255-L280 | def get_folder_contents_iter(self, uri):
"""Return iterator for directory contents.
uri -- mediafire URI
Example:
for item in get_folder_contents_iter('mf:///Documents'):
print(item)
"""
resource = self.get_resource_by_uri(uri)
if not isins... | [
"def",
"get_folder_contents_iter",
"(",
"self",
",",
"uri",
")",
":",
"resource",
"=",
"self",
".",
"get_resource_by_uri",
"(",
"uri",
")",
"if",
"not",
"isinstance",
"(",
"resource",
",",
"Folder",
")",
":",
"raise",
"NotAFolderError",
"(",
"uri",
")",
"f... | Return iterator for directory contents.
uri -- mediafire URI
Example:
for item in get_folder_contents_iter('mf:///Documents'):
print(item) | [
"Return",
"iterator",
"for",
"directory",
"contents",
"."
] | python | train |
daler/gffutils | gffutils/helpers.py | https://github.com/daler/gffutils/blob/6f7f547cad898738a1bd0a999fd68ba68db2c524/gffutils/helpers.py#L307-L333 | def merge_attributes(attr1, attr2):
"""
Merges two attribute dictionaries into a single dictionary.
Parameters
----------
`attr1`, `attr2` : dict
Returns
-------
dict
"""
new_d = copy.deepcopy(attr1)
new_d.update(attr2)
#all of attr2 key : values just overwrote attr1,... | [
"def",
"merge_attributes",
"(",
"attr1",
",",
"attr2",
")",
":",
"new_d",
"=",
"copy",
".",
"deepcopy",
"(",
"attr1",
")",
"new_d",
".",
"update",
"(",
"attr2",
")",
"#all of attr2 key : values just overwrote attr1, fix it",
"for",
"k",
",",
"v",
"in",
"new_d"... | Merges two attribute dictionaries into a single dictionary.
Parameters
----------
`attr1`, `attr2` : dict
Returns
-------
dict | [
"Merges",
"two",
"attribute",
"dictionaries",
"into",
"a",
"single",
"dictionary",
"."
] | python | train |
neuropsychology/NeuroKit.py | neurokit/signal/signal.py | https://github.com/neuropsychology/NeuroKit.py/blob/c9589348fbbde0fa7e986048c48f38e6b488adfe/neurokit/signal/signal.py#L21-L71 | def interpolate(values, value_times, sampling_rate=1000):
"""
3rd order spline interpolation.
Parameters
----------
values : dataframe
Values.
value_times : list
Time indices of values.
sampling_rate : int
Sampling rate (samples/second).
Returns
----------
... | [
"def",
"interpolate",
"(",
"values",
",",
"value_times",
",",
"sampling_rate",
"=",
"1000",
")",
":",
"# values=RRis.copy()",
"# value_times=beats_times.copy()",
"# Preprocessing",
"initial_index",
"=",
"value_times",
"[",
"0",
"]",
"value_times",
"=",
"np",
"."... | 3rd order spline interpolation.
Parameters
----------
values : dataframe
Values.
value_times : list
Time indices of values.
sampling_rate : int
Sampling rate (samples/second).
Returns
----------
signal : pd.Series
An array containing the values indexed b... | [
"3rd",
"order",
"spline",
"interpolation",
"."
] | python | train |
shoebot/shoebot | lib/photobot/__init__.py | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/photobot/__init__.py#L745-L756 | def sharpen(self, value=1.0):
"""Increases or decreases the sharpness in the layer.
The given value is a percentage to increase
or decrease the image sharpness,
for example 0.8 means sharpness at 80%.
"""
s = ImageEnhance.Sharpness(self.img)
self... | [
"def",
"sharpen",
"(",
"self",
",",
"value",
"=",
"1.0",
")",
":",
"s",
"=",
"ImageEnhance",
".",
"Sharpness",
"(",
"self",
".",
"img",
")",
"self",
".",
"img",
"=",
"s",
".",
"enhance",
"(",
"value",
")"
] | Increases or decreases the sharpness in the layer.
The given value is a percentage to increase
or decrease the image sharpness,
for example 0.8 means sharpness at 80%. | [
"Increases",
"or",
"decreases",
"the",
"sharpness",
"in",
"the",
"layer",
".",
"The",
"given",
"value",
"is",
"a",
"percentage",
"to",
"increase",
"or",
"decrease",
"the",
"image",
"sharpness",
"for",
"example",
"0",
".",
"8",
"means",
"sharpness",
"at",
"... | python | valid |
Mxit/python-mxit | mxit/services.py | https://github.com/Mxit/python-mxit/blob/6b18a54ef6fbfe1f9d94755ba3d4ad77743c8b0c/mxit/services.py#L240-L249 | def add_contact(self, contact_id, scope='contact/invite'):
"""
Add a contact
contact_id can either be the mxit ID of a service or a Mxit user
User authentication required with the following scope: 'contact/invite'
"""
return _put(
token=self.oauth.get_user_tok... | [
"def",
"add_contact",
"(",
"self",
",",
"contact_id",
",",
"scope",
"=",
"'contact/invite'",
")",
":",
"return",
"_put",
"(",
"token",
"=",
"self",
".",
"oauth",
".",
"get_user_token",
"(",
"scope",
")",
",",
"uri",
"=",
"'/user/socialgraph/contact/'",
"+",
... | Add a contact
contact_id can either be the mxit ID of a service or a Mxit user
User authentication required with the following scope: 'contact/invite' | [
"Add",
"a",
"contact",
"contact_id",
"can",
"either",
"be",
"the",
"mxit",
"ID",
"of",
"a",
"service",
"or",
"a",
"Mxit",
"user",
"User",
"authentication",
"required",
"with",
"the",
"following",
"scope",
":",
"contact",
"/",
"invite"
] | python | train |
bjoernricks/python-quilt | quilt/db.py | https://github.com/bjoernricks/python-quilt/blob/fae88237f601848cc34d073584d9dcb409f01777/quilt/db.py#L156-L169 | def add_patches(self, patches, after=None):
""" Add a list of patches to the patches list """
if after is None:
self.insert_patches(patches)
else:
self._check_patch(after)
patchlines = self._patchlines_before(after)
patchlines.append(self.patch2lin... | [
"def",
"add_patches",
"(",
"self",
",",
"patches",
",",
"after",
"=",
"None",
")",
":",
"if",
"after",
"is",
"None",
":",
"self",
".",
"insert_patches",
"(",
"patches",
")",
"else",
":",
"self",
".",
"_check_patch",
"(",
"after",
")",
"patchlines",
"="... | Add a list of patches to the patches list | [
"Add",
"a",
"list",
"of",
"patches",
"to",
"the",
"patches",
"list"
] | python | test |
ktdreyer/txbugzilla | txbugzilla/__init__.py | https://github.com/ktdreyer/txbugzilla/blob/ccfc6667ce9d696b08b468b25c813cc2b68d30d6/txbugzilla/__init__.py#L218-L221 | def id(self):
""" Bug ID number that caused this error """
m = re.match(r'Bug #(\d+) does not exist', self.message)
return m.group(1) | [
"def",
"id",
"(",
"self",
")",
":",
"m",
"=",
"re",
".",
"match",
"(",
"r'Bug #(\\d+) does not exist'",
",",
"self",
".",
"message",
")",
"return",
"m",
".",
"group",
"(",
"1",
")"
] | Bug ID number that caused this error | [
"Bug",
"ID",
"number",
"that",
"caused",
"this",
"error"
] | python | train |
markuskiller/textblob-de | textblob_de/ext/_pattern/text/tree.py | https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/tree.py#L1489-L1534 | def _parse_tokens(chunk, format=[WORD, POS, CHUNK, PNP, REL, ANCHOR, LEMMA]):
""" Parses tokens from <word> elements in the given XML <chunk> element.
Returns a flat list of tokens, in which each token is [WORD, POS, CHUNK, PNP, RELATION, ANCHOR, LEMMA].
If a <chunk type="PNP"> is encountered, trave... | [
"def",
"_parse_tokens",
"(",
"chunk",
",",
"format",
"=",
"[",
"WORD",
",",
"POS",
",",
"CHUNK",
",",
"PNP",
",",
"REL",
",",
"ANCHOR",
",",
"LEMMA",
"]",
")",
":",
"tokens",
"=",
"[",
"]",
"# Only process <chunk> and <chink> elements, ",
"# text nodes in be... | Parses tokens from <word> elements in the given XML <chunk> element.
Returns a flat list of tokens, in which each token is [WORD, POS, CHUNK, PNP, RELATION, ANCHOR, LEMMA].
If a <chunk type="PNP"> is encountered, traverses all of the chunks in the PNP. | [
"Parses",
"tokens",
"from",
"<word",
">",
"elements",
"in",
"the",
"given",
"XML",
"<chunk",
">",
"element",
".",
"Returns",
"a",
"flat",
"list",
"of",
"tokens",
"in",
"which",
"each",
"token",
"is",
"[",
"WORD",
"POS",
"CHUNK",
"PNP",
"RELATION",
"ANCHO... | python | train |
zeroSteiner/AdvancedHTTPServer | advancedhttpserver.py | https://github.com/zeroSteiner/AdvancedHTTPServer/blob/8c53cf7e1ddbf7ae9f573c82c5fe5f6992db7b5a/advancedhttpserver.py#L1961-L1975 | def shutdown(self):
"""Shutdown the server and stop responding to requests."""
self.__should_stop.set()
if self.__server_thread == threading.current_thread():
self.__is_shutdown.set()
self.__is_running.clear()
else:
if self.__wakeup_fd is not None:
os.write(self.__wakeup_fd.write_fd, b'\x00')
se... | [
"def",
"shutdown",
"(",
"self",
")",
":",
"self",
".",
"__should_stop",
".",
"set",
"(",
")",
"if",
"self",
".",
"__server_thread",
"==",
"threading",
".",
"current_thread",
"(",
")",
":",
"self",
".",
"__is_shutdown",
".",
"set",
"(",
")",
"self",
"."... | Shutdown the server and stop responding to requests. | [
"Shutdown",
"the",
"server",
"and",
"stop",
"responding",
"to",
"requests",
"."
] | python | train |
apple/turicreate | deps/src/libxml2-2.9.1/python/libxml2.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L5686-L5689 | def resolve(self, pubID, sysID):
"""Do a complete resolution lookup of an External Identifier """
ret = libxml2mod.xmlACatalogResolve(self._o, pubID, sysID)
return ret | [
"def",
"resolve",
"(",
"self",
",",
"pubID",
",",
"sysID",
")",
":",
"ret",
"=",
"libxml2mod",
".",
"xmlACatalogResolve",
"(",
"self",
".",
"_o",
",",
"pubID",
",",
"sysID",
")",
"return",
"ret"
] | Do a complete resolution lookup of an External Identifier | [
"Do",
"a",
"complete",
"resolution",
"lookup",
"of",
"an",
"External",
"Identifier"
] | python | train |
DigitalGlobe/gbdxtools | gbdxtools/catalog.py | https://github.com/DigitalGlobe/gbdxtools/blob/def62f8f2d77b168aa2bd115290aaa0f9a08a4bb/gbdxtools/catalog.py#L100-L115 | def get_address_coords(self, address):
''' Use the google geocoder to get latitude and longitude for an address string
Args:
address: any address string
Returns:
A tuple of (lat,lng)
'''
url = "https://maps.googleapis.com/maps/api/geocode/json?&address="... | [
"def",
"get_address_coords",
"(",
"self",
",",
"address",
")",
":",
"url",
"=",
"\"https://maps.googleapis.com/maps/api/geocode/json?&address=\"",
"+",
"address",
"r",
"=",
"requests",
".",
"get",
"(",
"url",
")",
"r",
".",
"raise_for_status",
"(",
")",
"results",... | Use the google geocoder to get latitude and longitude for an address string
Args:
address: any address string
Returns:
A tuple of (lat,lng) | [
"Use",
"the",
"google",
"geocoder",
"to",
"get",
"latitude",
"and",
"longitude",
"for",
"an",
"address",
"string"
] | python | valid |
gijzelaerr/python-snap7 | snap7/server.py | https://github.com/gijzelaerr/python-snap7/blob/a6db134c7a3a2ef187b9eca04669221d6fc634c3/snap7/server.py#L151-L159 | def start(self, tcpport=102):
"""
start the server.
"""
if tcpport != 102:
logger.info("setting server TCP port to %s" % tcpport)
self.set_param(snap7.snap7types.LocalPort, tcpport)
logger.info("starting server on 0.0.0.0:%s" % tcpport)
return self... | [
"def",
"start",
"(",
"self",
",",
"tcpport",
"=",
"102",
")",
":",
"if",
"tcpport",
"!=",
"102",
":",
"logger",
".",
"info",
"(",
"\"setting server TCP port to %s\"",
"%",
"tcpport",
")",
"self",
".",
"set_param",
"(",
"snap7",
".",
"snap7types",
".",
"L... | start the server. | [
"start",
"the",
"server",
"."
] | python | train |
sprymix/metamagic.json | metamagic/json/encoder.py | https://github.com/sprymix/metamagic.json/blob/c95d3cacd641d433af44f0774f51a085cb4888e6/metamagic/json/encoder.py#L216-L227 | def _encode_list(self, obj):# do
"""Returns a JSON representation of a Python list"""
self._increment_nested_level()
buffer = []
for element in obj:
buffer.append(self._encode(element))
self._decrement_nested_level()
return '['+ ','.join(buffer) + ']' | [
"def",
"_encode_list",
"(",
"self",
",",
"obj",
")",
":",
"# do",
"self",
".",
"_increment_nested_level",
"(",
")",
"buffer",
"=",
"[",
"]",
"for",
"element",
"in",
"obj",
":",
"buffer",
".",
"append",
"(",
"self",
".",
"_encode",
"(",
"element",
")",
... | Returns a JSON representation of a Python list | [
"Returns",
"a",
"JSON",
"representation",
"of",
"a",
"Python",
"list"
] | python | train |
ic-labs/django-icekit | icekit/plugins/base.py | https://github.com/ic-labs/django-icekit/blob/c507ea5b1864303732c53ad7c5800571fca5fa94/icekit/plugins/base.py#L41-L45 | def get_plugins(cls, *args, **kwargs):
"""
Return a list of plugin instances and pass through arguments.
"""
return [plugin(*args, **kwargs) for plugin in cls.plugins] | [
"def",
"get_plugins",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"[",
"plugin",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"for",
"plugin",
"in",
"cls",
".",
"plugins",
"]"
] | Return a list of plugin instances and pass through arguments. | [
"Return",
"a",
"list",
"of",
"plugin",
"instances",
"and",
"pass",
"through",
"arguments",
"."
] | python | train |
roanuz/py-cricket | src/pycricket.py | https://github.com/roanuz/py-cricket/blob/fa47fe2e92915fc58db38898213e974742af55d4/src/pycricket.py#L206-L217 | def get_player_stats(self, player_key, board_key):
"""
Calling the Player Stats API
Args:
player_key: Key of the player
board_key: key of the board
Return:
json data
"""
player_stats_url = self.api_path + 'player/' + player_key + '/leag... | [
"def",
"get_player_stats",
"(",
"self",
",",
"player_key",
",",
"board_key",
")",
":",
"player_stats_url",
"=",
"self",
".",
"api_path",
"+",
"'player/'",
"+",
"player_key",
"+",
"'/league/'",
"+",
"board_key",
"+",
"'/stats/'",
"response",
"=",
"self",
".",
... | Calling the Player Stats API
Args:
player_key: Key of the player
board_key: key of the board
Return:
json data | [
"Calling",
"the",
"Player",
"Stats",
"API",
"Args",
":",
"player_key",
":",
"Key",
"of",
"the",
"player",
"board_key",
":",
"key",
"of",
"the",
"board",
"Return",
":",
"json",
"data"
] | python | train |
jobovy/galpy | galpy/potential/TwoPowerSphericalPotential.py | https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/potential/TwoPowerSphericalPotential.py#L878-L895 | def _evaluate(self,R,z,phi=0.,t=0.):
"""
NAME:
_evaluate
PURPOSE:
evaluate the potential at R,z
INPUT:
R - Galactocentric cylindrical radius
z - vertical height
phi - azimuth
t - time
OUTPUT:
Phi(R,z)
... | [
"def",
"_evaluate",
"(",
"self",
",",
"R",
",",
"z",
",",
"phi",
"=",
"0.",
",",
"t",
"=",
"0.",
")",
":",
"r",
"=",
"numpy",
".",
"sqrt",
"(",
"R",
"**",
"2.",
"+",
"z",
"**",
"2.",
")",
"return",
"-",
"numpy",
".",
"log",
"(",
"1.",
"+"... | NAME:
_evaluate
PURPOSE:
evaluate the potential at R,z
INPUT:
R - Galactocentric cylindrical radius
z - vertical height
phi - azimuth
t - time
OUTPUT:
Phi(R,z)
HISTORY:
2010-07-09 - Started - Bovy (NY... | [
"NAME",
":",
"_evaluate",
"PURPOSE",
":",
"evaluate",
"the",
"potential",
"at",
"R",
"z",
"INPUT",
":",
"R",
"-",
"Galactocentric",
"cylindrical",
"radius",
"z",
"-",
"vertical",
"height",
"phi",
"-",
"azimuth",
"t",
"-",
"time",
"OUTPUT",
":",
"Phi",
"(... | python | train |
larsmans/seqlearn | examples/conll.py | https://github.com/larsmans/seqlearn/blob/32d4bfaebdd877733f180ea6072e8fc1266bc559/examples/conll.py#L18-L39 | def features(sentence, i):
"""Features for i'th token in sentence.
Currently baseline named-entity recognition features, but these can
easily be changed to do POS tagging or chunking.
"""
word = sentence[i]
yield "word:{}" + word.lower()
if word[0].isupper():
yield "CAP"
if ... | [
"def",
"features",
"(",
"sentence",
",",
"i",
")",
":",
"word",
"=",
"sentence",
"[",
"i",
"]",
"yield",
"\"word:{}\"",
"+",
"word",
".",
"lower",
"(",
")",
"if",
"word",
"[",
"0",
"]",
".",
"isupper",
"(",
")",
":",
"yield",
"\"CAP\"",
"if",
"i"... | Features for i'th token in sentence.
Currently baseline named-entity recognition features, but these can
easily be changed to do POS tagging or chunking. | [
"Features",
"for",
"i",
"th",
"token",
"in",
"sentence",
"."
] | python | train |
facetoe/zenpy | zenpy/lib/api.py | https://github.com/facetoe/zenpy/blob/34c54c7e408b9ed01604ddf8b3422204c8bf31ea/zenpy/lib/api.py#L1470-L1478 | def count_many(self, views, include=None):
"""
Return many ViewCounts.
:param include: list of objects to sideload. `Side-loading API Docs
<https://developer.zendesk.com/rest_api/docs/core/side_loading>`__.
:param views: iterable of View or view ids
"""
retu... | [
"def",
"count_many",
"(",
"self",
",",
"views",
",",
"include",
"=",
"None",
")",
":",
"return",
"self",
".",
"_get",
"(",
"self",
".",
"_build_url",
"(",
"self",
".",
"endpoint",
"(",
"count_many",
"=",
"views",
",",
"include",
"=",
"include",
")",
... | Return many ViewCounts.
:param include: list of objects to sideload. `Side-loading API Docs
<https://developer.zendesk.com/rest_api/docs/core/side_loading>`__.
:param views: iterable of View or view ids | [
"Return",
"many",
"ViewCounts",
"."
] | python | train |
pyviz/imagen | imagen/colorspaces.py | https://github.com/pyviz/imagen/blob/53c5685c880f54b42795964d8db50b02e8590e88/imagen/colorspaces.py#L435-L442 | def _swaplch(LCH):
"Reverse the order of an LCH numpy dstack or tuple for analysis."
try: # Numpy array
L,C,H = np.dsplit(LCH,3)
return np.dstack((H,C,L))
except: # Tuple
L,C,H = LCH
return H,C,L | [
"def",
"_swaplch",
"(",
"LCH",
")",
":",
"try",
":",
"# Numpy array",
"L",
",",
"C",
",",
"H",
"=",
"np",
".",
"dsplit",
"(",
"LCH",
",",
"3",
")",
"return",
"np",
".",
"dstack",
"(",
"(",
"H",
",",
"C",
",",
"L",
")",
")",
"except",
":",
"... | Reverse the order of an LCH numpy dstack or tuple for analysis. | [
"Reverse",
"the",
"order",
"of",
"an",
"LCH",
"numpy",
"dstack",
"or",
"tuple",
"for",
"analysis",
"."
] | python | train |
cozy/python_cozy_management | cozy_management/couchdb.py | https://github.com/cozy/python_cozy_management/blob/820cea58458ae3e067fa8cc2da38edbda4681dac/cozy_management/couchdb.py#L50-L59 | def get_admin():
'''
Return the actual admin from token file
'''
if os.path.isfile(LOGIN_FILENAME):
with open(LOGIN_FILENAME, 'r') as token_file:
old_login, old_password = token_file.read().splitlines()[:2]
return old_login, old_password
else:
return None,... | [
"def",
"get_admin",
"(",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"LOGIN_FILENAME",
")",
":",
"with",
"open",
"(",
"LOGIN_FILENAME",
",",
"'r'",
")",
"as",
"token_file",
":",
"old_login",
",",
"old_password",
"=",
"token_file",
".",
"read",... | Return the actual admin from token file | [
"Return",
"the",
"actual",
"admin",
"from",
"token",
"file"
] | python | train |
Azure/blobxfer | blobxfer/retry.py | https://github.com/Azure/blobxfer/blob/3eccbe7530cc6a20ab2d30f9e034b6f021817f34/blobxfer/retry.py#L103-L184 | def _should_retry(self, context):
# type: (ExponentialRetryWithMaxWait,
# azure.storage.common.models.RetryContext) -> bool
"""Determine if retry should happen or not
:param ExponentialRetryWithMaxWait self: this
:param azure.storage.common.models.RetryContext context: ret... | [
"def",
"_should_retry",
"(",
"self",
",",
"context",
")",
":",
"# type: (ExponentialRetryWithMaxWait,",
"# azure.storage.common.models.RetryContext) -> bool",
"# do not retry if max attempts equal or exceeded",
"if",
"context",
".",
"count",
">=",
"self",
".",
"max_attempt... | Determine if retry should happen or not
:param ExponentialRetryWithMaxWait self: this
:param azure.storage.common.models.RetryContext context: retry context
:rtype: bool
:return: True if retry should happen, False otherwise | [
"Determine",
"if",
"retry",
"should",
"happen",
"or",
"not",
":",
"param",
"ExponentialRetryWithMaxWait",
"self",
":",
"this",
":",
"param",
"azure",
".",
"storage",
".",
"common",
".",
"models",
".",
"RetryContext",
"context",
":",
"retry",
"context",
":",
... | python | train |
Huong-nt/flask-rak | flask_rak/core.py | https://github.com/Huong-nt/flask-rak/blob/ffe16b0fc3d49e83c1d220c445ce14632219f69d/flask_rak/core.py#L155-L172 | def intent(self, intent_name):
"""Decorator routes an Rogo IntentRequest.
Functions decorated as an intent are registered as the view function for the Intent's URL,
and provide the backend responses to give your Skill its functionality.
@ask.intent('WeatherIntent')
def weather(ci... | [
"def",
"intent",
"(",
"self",
",",
"intent_name",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"self",
".",
"_intent_view_funcs",
"[",
"intent_name",
"]",
"=",
"f",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*"... | Decorator routes an Rogo IntentRequest.
Functions decorated as an intent are registered as the view function for the Intent's URL,
and provide the backend responses to give your Skill its functionality.
@ask.intent('WeatherIntent')
def weather(city):
return statement('I predi... | [
"Decorator",
"routes",
"an",
"Rogo",
"IntentRequest",
".",
"Functions",
"decorated",
"as",
"an",
"intent",
"are",
"registered",
"as",
"the",
"view",
"function",
"for",
"the",
"Intent",
"s",
"URL",
"and",
"provide",
"the",
"backend",
"responses",
"to",
"give",
... | python | train |
aio-libs/aiohttp-sse | aiohttp_sse/__init__.py | https://github.com/aio-libs/aiohttp-sse/blob/5148d087f9df75ecea61f574d3c768506680e5dc/aiohttp_sse/__init__.py#L113-L121 | async def wait(self):
"""EventSourceResponse object is used for streaming data to the client,
this method returns future, so we can wain until connection will
be closed or other task explicitly call ``stop_streaming`` method.
"""
if self._ping_task is None:
raise Runt... | [
"async",
"def",
"wait",
"(",
"self",
")",
":",
"if",
"self",
".",
"_ping_task",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"'Response is not started'",
")",
"with",
"contextlib",
".",
"suppress",
"(",
"asyncio",
".",
"CancelledError",
")",
":",
"await"... | EventSourceResponse object is used for streaming data to the client,
this method returns future, so we can wain until connection will
be closed or other task explicitly call ``stop_streaming`` method. | [
"EventSourceResponse",
"object",
"is",
"used",
"for",
"streaming",
"data",
"to",
"the",
"client",
"this",
"method",
"returns",
"future",
"so",
"we",
"can",
"wain",
"until",
"connection",
"will",
"be",
"closed",
"or",
"other",
"task",
"explicitly",
"call",
"sto... | python | train |
dmlc/gluon-nlp | scripts/word_embeddings/evaluation.py | https://github.com/dmlc/gluon-nlp/blob/4b83eb6bcc8881e5f1081a3675adaa19fac5c0ba/scripts/word_embeddings/evaluation.py#L262-L280 | def log_similarity_result(logfile, result):
"""Log a similarity evaluation result dictionary as TSV to logfile."""
assert result['task'] == 'similarity'
if not logfile:
return
with open(logfile, 'a') as f:
f.write('\t'.join([
str(result['global_step']),
result['... | [
"def",
"log_similarity_result",
"(",
"logfile",
",",
"result",
")",
":",
"assert",
"result",
"[",
"'task'",
"]",
"==",
"'similarity'",
"if",
"not",
"logfile",
":",
"return",
"with",
"open",
"(",
"logfile",
",",
"'a'",
")",
"as",
"f",
":",
"f",
".",
"wr... | Log a similarity evaluation result dictionary as TSV to logfile. | [
"Log",
"a",
"similarity",
"evaluation",
"result",
"dictionary",
"as",
"TSV",
"to",
"logfile",
"."
] | python | train |
ansible/molecule | molecule/command/lint.py | https://github.com/ansible/molecule/blob/766dc35b0b0ce498cd5e3a62b40f828742d0d08c/molecule/command/lint.py#L63-L80 | def execute(self):
"""
Execute the actions necessary to perform a `molecule lint` and
returns None.
:return: None
"""
self.print_info()
linters = [
l for l in [
self._config.lint,
self._config.verifier.lint,
... | [
"def",
"execute",
"(",
"self",
")",
":",
"self",
".",
"print_info",
"(",
")",
"linters",
"=",
"[",
"l",
"for",
"l",
"in",
"[",
"self",
".",
"_config",
".",
"lint",
",",
"self",
".",
"_config",
".",
"verifier",
".",
"lint",
",",
"self",
".",
"_con... | Execute the actions necessary to perform a `molecule lint` and
returns None.
:return: None | [
"Execute",
"the",
"actions",
"necessary",
"to",
"perform",
"a",
"molecule",
"lint",
"and",
"returns",
"None",
"."
] | python | train |
pennlabs/penn-sdk-python | penn/wharton.py | https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/wharton.py#L186-L189 | def get_wharton_gsrs_formatted(self, sessionid, date=None):
""" Return the wharton GSR listing formatted in studyspaces format. """
gsrs = self.get_wharton_gsrs(sessionid, date)
return self.switch_format(gsrs) | [
"def",
"get_wharton_gsrs_formatted",
"(",
"self",
",",
"sessionid",
",",
"date",
"=",
"None",
")",
":",
"gsrs",
"=",
"self",
".",
"get_wharton_gsrs",
"(",
"sessionid",
",",
"date",
")",
"return",
"self",
".",
"switch_format",
"(",
"gsrs",
")"
] | Return the wharton GSR listing formatted in studyspaces format. | [
"Return",
"the",
"wharton",
"GSR",
"listing",
"formatted",
"in",
"studyspaces",
"format",
"."
] | python | train |
deifyed/vault | libconman/target.py | https://github.com/deifyed/vault/blob/e3c37ade6c3e6b61a76ec6cd2ba98881c7401d97/libconman/target.py#L51-L68 | def delete(self):
'''
Deletes link from vault and removes database information
'''
if not self._id:
verbose('This target does not have an id')
return False
# Removes link from vault directory
verbose('Removing link from vault directory')
... | [
"def",
"delete",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_id",
":",
"verbose",
"(",
"'This target does not have an id'",
")",
"return",
"False",
"# Removes link from vault directory",
"verbose",
"(",
"'Removing link from vault directory'",
")",
"os",
".",
... | Deletes link from vault and removes database information | [
"Deletes",
"link",
"from",
"vault",
"and",
"removes",
"database",
"information"
] | python | train |
eng-tools/sfsimodels | sfsimodels/models/foundations.py | https://github.com/eng-tools/sfsimodels/blob/65a690ca440d61307f5a9b8478e4704f203a5925/sfsimodels/models/foundations.py#L347-L357 | def pad_position_w(self, i):
"""
Determines the position of the ith pad in the width direction.
Assumes equally spaced pads.
:param i: ith number of pad in width direction (0-indexed)
:return:
"""
if i >= self.n_pads_w:
raise ModelError("pad index out... | [
"def",
"pad_position_w",
"(",
"self",
",",
"i",
")",
":",
"if",
"i",
">=",
"self",
".",
"n_pads_w",
":",
"raise",
"ModelError",
"(",
"\"pad index out-of-bounds\"",
")",
"return",
"(",
"self",
".",
"width",
"-",
"self",
".",
"pad_width",
")",
"/",
"(",
... | Determines the position of the ith pad in the width direction.
Assumes equally spaced pads.
:param i: ith number of pad in width direction (0-indexed)
:return: | [
"Determines",
"the",
"position",
"of",
"the",
"ith",
"pad",
"in",
"the",
"width",
"direction",
".",
"Assumes",
"equally",
"spaced",
"pads",
"."
] | python | train |
saltstack/salt | salt/modules/solarispkg.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/solarispkg.py#L201-L385 | def install(name=None, sources=None, saltenv='base', **kwargs):
'''
Install the passed package. Can install packages from the following
sources:
* Locally (package already exists on the minion
* HTTP/HTTPS server
* FTP server
* Salt master
Returns a dict containing the new package name... | [
"def",
"install",
"(",
"name",
"=",
"None",
",",
"sources",
"=",
"None",
",",
"saltenv",
"=",
"'base'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"salt",
".",
"utils",
".",
"data",
".",
"is_true",
"(",
"kwargs",
".",
"get",
"(",
"'refresh'",
")",
... | Install the passed package. Can install packages from the following
sources:
* Locally (package already exists on the minion
* HTTP/HTTPS server
* FTP server
* Salt master
Returns a dict containing the new package names and versions:
.. code-block:: python
{'<package>': {'old': '... | [
"Install",
"the",
"passed",
"package",
".",
"Can",
"install",
"packages",
"from",
"the",
"following",
"sources",
":"
] | python | train |
bwohlberg/sporco | sporco/plot.py | https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/plot.py#L76-L171 | def attach_zoom(ax, scaling=2.0):
"""
Attach an event handler that supports zooming within a plot using
the mouse scroll wheel.
Parameters
----------
ax : :class:`matplotlib.axes.Axes` object
Axes to which event handling is to be attached
scaling : float, optional (default 2.0)
... | [
"def",
"attach_zoom",
"(",
"ax",
",",
"scaling",
"=",
"2.0",
")",
":",
"# See https://stackoverflow.com/questions/11551049",
"def",
"zoom",
"(",
"event",
")",
":",
"# Get the current x and y limits",
"cur_xlim",
"=",
"ax",
".",
"get_xlim",
"(",
")",
"cur_ylim",
"=... | Attach an event handler that supports zooming within a plot using
the mouse scroll wheel.
Parameters
----------
ax : :class:`matplotlib.axes.Axes` object
Axes to which event handling is to be attached
scaling : float, optional (default 2.0)
Scaling factor for zooming in and out
Ret... | [
"Attach",
"an",
"event",
"handler",
"that",
"supports",
"zooming",
"within",
"a",
"plot",
"using",
"the",
"mouse",
"scroll",
"wheel",
"."
] | python | train |
LionelR/pyair | pyair/xair.py | https://github.com/LionelR/pyair/blob/467e8a843ca9f882f8bb2958805b7293591996ad/pyair/xair.py#L519-L570 | def get_manuelles(self, site, code_parametre, debut, fin, court=False):
"""
Recupération des mesures manuelles (labo) pour un site
site: numéro du site (voir fonction liste_sites_prelevement)
code_parametre: code ISO du paramètre à rechercher (C6H6=V4)
debut: date de début du pr... | [
"def",
"get_manuelles",
"(",
"self",
",",
"site",
",",
"code_parametre",
",",
"debut",
",",
"fin",
",",
"court",
"=",
"False",
")",
":",
"condition",
"=",
"\"WHERE MESLA.NOPOL='%s' \"",
"%",
"code_parametre",
"condition",
"+=",
"\"AND SITMETH.NSIT=%s \"",
"%",
"... | Recupération des mesures manuelles (labo) pour un site
site: numéro du site (voir fonction liste_sites_prelevement)
code_parametre: code ISO du paramètre à rechercher (C6H6=V4)
debut: date de début du premier prélèvement
fin: date de fin du dernier prélèvement
court: Renvoie un ... | [
"Recupération",
"des",
"mesures",
"manuelles",
"(",
"labo",
")",
"pour",
"un",
"site"
] | python | valid |
RLBot/RLBot | src/main/python/rlbot/gui/qt_root.py | https://github.com/RLBot/RLBot/blob/3f9b6bec8b9baf4dcfff0f6cf3103c8744ac6234/src/main/python/rlbot/gui/qt_root.py#L321-L341 | def team_settings_edit_event(self, value=None):
"""
Handles the events when editing a value regarding the team settings
:param value: the new value to store in the config
:return:
"""
sender = self.sender()
if value is None:
value = sender.text()
... | [
"def",
"team_settings_edit_event",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"sender",
"=",
"self",
".",
"sender",
"(",
")",
"if",
"value",
"is",
"None",
":",
"value",
"=",
"sender",
".",
"text",
"(",
")",
"if",
"sender",
"is",
"self",
".",
... | Handles the events when editing a value regarding the team settings
:param value: the new value to store in the config
:return: | [
"Handles",
"the",
"events",
"when",
"editing",
"a",
"value",
"regarding",
"the",
"team",
"settings",
":",
"param",
"value",
":",
"the",
"new",
"value",
"to",
"store",
"in",
"the",
"config",
":",
"return",
":"
] | python | train |
thewca/wca-regulations-compiler | wrc/parse/lexer.py | https://github.com/thewca/wca-regulations-compiler/blob/3ebbd8fe8fec7c9167296f59b2677696fe61a954/wrc/parse/lexer.py#L55-L61 | def t_LABELDECL(self, token):
ur'-\s<label>\s*\[(?P<label>.+?)\]\s*(?P<text>.+?)\n'
label = token.lexer.lexmatch.group("label").decode("utf8")
text = token.lexer.lexmatch.group("text").decode("utf8")
token.value = (label, text)
token.lexer.lineno += 1
return token | [
"def",
"t_LABELDECL",
"(",
"self",
",",
"token",
")",
":",
"label",
"=",
"token",
".",
"lexer",
".",
"lexmatch",
".",
"group",
"(",
"\"label\"",
")",
".",
"decode",
"(",
"\"utf8\"",
")",
"text",
"=",
"token",
".",
"lexer",
".",
"lexmatch",
".",
"grou... | ur'-\s<label>\s*\[(?P<label>.+?)\]\s*(?P<text>.+?)\n | [
"ur",
"-",
"\\",
"s<label",
">",
"\\",
"s",
"*",
"\\",
"[",
"(",
"?P<label",
">",
".",
"+",
"?",
")",
"\\",
"]",
"\\",
"s",
"*",
"(",
"?P<text",
">",
".",
"+",
"?",
")",
"\\",
"n"
] | python | train |
napalm-automation/napalm | napalm/junos/junos.py | https://github.com/napalm-automation/napalm/blob/c11ae8bb5ce395698704a0051cdf8d144fbb150d/napalm/junos/junos.py#L249-L252 | def load_merge_candidate(self, filename=None, config=None):
"""Open the candidate config and replace."""
self.config_replace = False
self._load_candidate(filename, config, False) | [
"def",
"load_merge_candidate",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"config",
"=",
"None",
")",
":",
"self",
".",
"config_replace",
"=",
"False",
"self",
".",
"_load_candidate",
"(",
"filename",
",",
"config",
",",
"False",
")"
] | Open the candidate config and replace. | [
"Open",
"the",
"candidate",
"config",
"and",
"replace",
"."
] | python | train |
inasafe/inasafe | safe/gui/tools/metadata_converter_dialog.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/metadata_converter_dialog.py#L297-L325 | def select_output_directory(self):
"""Select output directory"""
# Input layer
input_layer_path = self.layer.source()
input_file_name = os.path.basename(input_layer_path)
input_extension = os.path.splitext(input_file_name)[1]
# Get current path
current_file_path ... | [
"def",
"select_output_directory",
"(",
"self",
")",
":",
"# Input layer",
"input_layer_path",
"=",
"self",
".",
"layer",
".",
"source",
"(",
")",
"input_file_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"input_layer_path",
")",
"input_extension",
"=",
... | Select output directory | [
"Select",
"output",
"directory"
] | python | train |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/nbformat/v3/nbbase.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/nbformat/v3/nbbase.py#L158-L173 | def new_notebook(name=None, metadata=None, worksheets=None):
"""Create a notebook by name, id and a list of worksheets."""
nb = NotebookNode()
nb.nbformat = nbformat
nb.nbformat_minor = nbformat_minor
if worksheets is None:
nb.worksheets = []
else:
nb.worksheets = list(worksheets... | [
"def",
"new_notebook",
"(",
"name",
"=",
"None",
",",
"metadata",
"=",
"None",
",",
"worksheets",
"=",
"None",
")",
":",
"nb",
"=",
"NotebookNode",
"(",
")",
"nb",
".",
"nbformat",
"=",
"nbformat",
"nb",
".",
"nbformat_minor",
"=",
"nbformat_minor",
"if"... | Create a notebook by name, id and a list of worksheets. | [
"Create",
"a",
"notebook",
"by",
"name",
"id",
"and",
"a",
"list",
"of",
"worksheets",
"."
] | python | test |
awslabs/sockeye | sockeye/coverage.py | https://github.com/awslabs/sockeye/blob/5d64a1ee1ef3cbba17c6d1d94bc061020c43f6ab/sockeye/coverage.py#L218-L265 | def on(self, source: mx.sym.Symbol, source_length: mx.sym.Symbol, source_seq_len: int) -> Callable:
"""
Returns callable to be used for updating coverage vectors in a sequence decoder.
:param source: Shape: (batch_size, seq_len, encoder_num_hidden).
:param source_length: Shape: (batch_s... | [
"def",
"on",
"(",
"self",
",",
"source",
":",
"mx",
".",
"sym",
".",
"Symbol",
",",
"source_length",
":",
"mx",
".",
"sym",
".",
"Symbol",
",",
"source_seq_len",
":",
"int",
")",
"->",
"Callable",
":",
"def",
"update_coverage",
"(",
"prev_hidden",
":",... | Returns callable to be used for updating coverage vectors in a sequence decoder.
:param source: Shape: (batch_size, seq_len, encoder_num_hidden).
:param source_length: Shape: (batch_size,).
:param source_seq_len: Maximum length of source sequences.
:return: Coverage callable. | [
"Returns",
"callable",
"to",
"be",
"used",
"for",
"updating",
"coverage",
"vectors",
"in",
"a",
"sequence",
"decoder",
"."
] | python | train |
Kozea/pygal | pygal/graph/bar.py | https://github.com/Kozea/pygal/blob/5e25c98a59a0642eecd9fcc5dbfeeb2190fbb5e7/pygal/graph/bar.py#L106-L136 | def bar(self, serie, rescale=False):
"""Draw a bar graph for a serie"""
serie_node = self.svg.serie(serie)
bars = self.svg.node(serie_node['plot'], class_="bars")
if rescale and self.secondary_series:
points = self._rescale(serie.points)
else:
points = ser... | [
"def",
"bar",
"(",
"self",
",",
"serie",
",",
"rescale",
"=",
"False",
")",
":",
"serie_node",
"=",
"self",
".",
"svg",
".",
"serie",
"(",
"serie",
")",
"bars",
"=",
"self",
".",
"svg",
".",
"node",
"(",
"serie_node",
"[",
"'plot'",
"]",
",",
"cl... | Draw a bar graph for a serie | [
"Draw",
"a",
"bar",
"graph",
"for",
"a",
"serie"
] | python | train |
restran/mountains | mountains/django/model.py | https://github.com/restran/mountains/blob/a97fee568b112f4e10d878f815d0db3dd0a98d74/mountains/django/model.py#L36-L45 | def set_dict_none_default(dict_item, default_value):
"""
对字典中为None的值,重新设置默认值
:param dict_item:
:param default_value:
:return:
"""
for (k, v) in iteritems(dict_item):
if v is None:
dict_item[k] = default_value | [
"def",
"set_dict_none_default",
"(",
"dict_item",
",",
"default_value",
")",
":",
"for",
"(",
"k",
",",
"v",
")",
"in",
"iteritems",
"(",
"dict_item",
")",
":",
"if",
"v",
"is",
"None",
":",
"dict_item",
"[",
"k",
"]",
"=",
"default_value"
] | 对字典中为None的值,重新设置默认值
:param dict_item:
:param default_value:
:return: | [
"对字典中为None的值,重新设置默认值",
":",
"param",
"dict_item",
":",
":",
"param",
"default_value",
":",
":",
"return",
":"
] | python | train |
PMBio/limix-backup | limix/mtSet/core/plink_reader.py | https://github.com/PMBio/limix-backup/blob/1e201fdb5c694d0d5506f207f3de65d8ef66146c/limix/mtSet/core/plink_reader.py#L36-L42 | def readFAM(basefilename,usecols=None):
"""
helper method for speeding up read FAM
"""
fam = basefilename+'.fam'
fam = SP.loadtxt(fam,dtype=bytes,usecols=usecols)
return fam | [
"def",
"readFAM",
"(",
"basefilename",
",",
"usecols",
"=",
"None",
")",
":",
"fam",
"=",
"basefilename",
"+",
"'.fam'",
"fam",
"=",
"SP",
".",
"loadtxt",
"(",
"fam",
",",
"dtype",
"=",
"bytes",
",",
"usecols",
"=",
"usecols",
")",
"return",
"fam"
] | helper method for speeding up read FAM | [
"helper",
"method",
"for",
"speeding",
"up",
"read",
"FAM"
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.