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 |
|---|---|---|---|---|---|---|---|---|
ask/carrot | carrot/backends/pyamqplib.py | https://github.com/ask/carrot/blob/5889a25cd2e274642071c9bba39772f4b3e3d9da/carrot/backends/pyamqplib.py#L221-L234 | def queue_exists(self, queue):
"""Check if a queue has been declared.
:rtype bool:
"""
try:
self.channel.queue_declare(queue=queue, passive=True)
except AMQPChannelException, e:
if e.amqp_reply_code == 404:
return False
raise ... | [
"def",
"queue_exists",
"(",
"self",
",",
"queue",
")",
":",
"try",
":",
"self",
".",
"channel",
".",
"queue_declare",
"(",
"queue",
"=",
"queue",
",",
"passive",
"=",
"True",
")",
"except",
"AMQPChannelException",
",",
"e",
":",
"if",
"e",
".",
"amqp_r... | Check if a queue has been declared.
:rtype bool: | [
"Check",
"if",
"a",
"queue",
"has",
"been",
"declared",
"."
] | python | train |
ploneintranet/ploneintranet.workspace | src/ploneintranet/workspace/adapters.py | https://github.com/ploneintranet/ploneintranet.workspace/blob/a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba/src/ploneintranet/workspace/adapters.py#L46-L57 | def group_for_policy(self, policy=None):
"""
Lookup the collective.workspace usergroup corresponding to the
given policy
:param policy: The value of the policy to lookup, defaults to the
current policy
:type policy: str
"""
if policy is Non... | [
"def",
"group_for_policy",
"(",
"self",
",",
"policy",
"=",
"None",
")",
":",
"if",
"policy",
"is",
"None",
":",
"policy",
"=",
"self",
".",
"context",
".",
"participant_policy",
"return",
"\"%s:%s\"",
"%",
"(",
"policy",
".",
"title",
"(",
")",
",",
"... | Lookup the collective.workspace usergroup corresponding to the
given policy
:param policy: The value of the policy to lookup, defaults to the
current policy
:type policy: str | [
"Lookup",
"the",
"collective",
".",
"workspace",
"usergroup",
"corresponding",
"to",
"the",
"given",
"policy"
] | python | train |
scot-dev/scot | doc/make.py | https://github.com/scot-dev/scot/blob/48598b79d4400dad893b134cd2194715511facda/doc/make.py#L41-L105 | def copytree(src, dst, symlinks=False, ignore=None):
"""Recursively copy a directory tree using copy2().
The destination directory must not already exist.
If exception(s) occur, an Error is raised with a list of reasons.
If the optional symlinks flag is true, symbolic links in the
source tree resu... | [
"def",
"copytree",
"(",
"src",
",",
"dst",
",",
"symlinks",
"=",
"False",
",",
"ignore",
"=",
"None",
")",
":",
"from",
"shutil",
"import",
"copy2",
",",
"Error",
",",
"copystat",
"names",
"=",
"os",
".",
"listdir",
"(",
"src",
")",
"if",
"ignore",
... | Recursively copy a directory tree using copy2().
The destination directory must not already exist.
If exception(s) occur, an Error is raised with a list of reasons.
If the optional symlinks flag is true, symbolic links in the
source tree result in symbolic links in the destination tree; if
it is f... | [
"Recursively",
"copy",
"a",
"directory",
"tree",
"using",
"copy2",
"()",
"."
] | python | train |
tanghaibao/jcvi | jcvi/annotation/evm.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/annotation/evm.py#L168-L193 | def pasa(args):
"""
%prog pasa pasa_db fastafile
Run EVM in TIGR-only mode.
"""
p = OptionParser(pasa.__doc__)
opts, args = p.parse_args(args)
if len(args) != 2:
sys.exit(not p.print_help())
pasa_db, fastafile = args
termexons = "pasa.terminal_exons.gff3"
if need_upda... | [
"def",
"pasa",
"(",
"args",
")",
":",
"p",
"=",
"OptionParser",
"(",
"pasa",
".",
"__doc__",
")",
"opts",
",",
"args",
"=",
"p",
".",
"parse_args",
"(",
"args",
")",
"if",
"len",
"(",
"args",
")",
"!=",
"2",
":",
"sys",
".",
"exit",
"(",
"not",... | %prog pasa pasa_db fastafile
Run EVM in TIGR-only mode. | [
"%prog",
"pasa",
"pasa_db",
"fastafile"
] | python | train |
flashashen/flange | flange/data.py | https://github.com/flashashen/flange/blob/67ebaf70e39887f65ce1163168d182a8e4c2774a/flange/data.py#L37-L52 | def search(self, path_expression, mode=UXP, values=None, ifunc=lambda x: x):
"""
find matches for the given path expression in the data
:param path_expression: path tuple or string
:return:
"""
# keys = path_expression if isinstance(path_expression, six.string_types) els... | [
"def",
"search",
"(",
"self",
",",
"path_expression",
",",
"mode",
"=",
"UXP",
",",
"values",
"=",
"None",
",",
"ifunc",
"=",
"lambda",
"x",
":",
"x",
")",
":",
"# keys = path_expression if isinstance(path_expression, six.string_types) else path_expression[-1]",
"path... | find matches for the given path expression in the data
:param path_expression: path tuple or string
:return: | [
"find",
"matches",
"for",
"the",
"given",
"path",
"expression",
"in",
"the",
"data"
] | python | train |
LordGaav/python-chaos | chaos/amqp/rpc.py | https://github.com/LordGaav/python-chaos/blob/52cd29a6fd15693ee1e53786b93bcb23fbf84ddd/chaos/amqp/rpc.py#L323-L345 | def rpc_reply(channel, original_headers, message, properties=None):
"""
Reply to a RPC request. This function will use the default exchange, to directly contact the reply_to queue.
Parameters
----------
channel: object
Properly initialized AMQP channel to use.
original_headers: dict
The headers of the origin... | [
"def",
"rpc_reply",
"(",
"channel",
",",
"original_headers",
",",
"message",
",",
"properties",
"=",
"None",
")",
":",
"if",
"not",
"properties",
":",
"properties",
"=",
"{",
"}",
"properties",
"[",
"'correlation_id'",
"]",
"=",
"original_headers",
".",
"cor... | Reply to a RPC request. This function will use the default exchange, to directly contact the reply_to queue.
Parameters
----------
channel: object
Properly initialized AMQP channel to use.
original_headers: dict
The headers of the originating message that caused this reply.
message: string
Message to reply ... | [
"Reply",
"to",
"a",
"RPC",
"request",
".",
"This",
"function",
"will",
"use",
"the",
"default",
"exchange",
"to",
"directly",
"contact",
"the",
"reply_to",
"queue",
"."
] | python | train |
CZ-NIC/python-rt | rt.py | https://github.com/CZ-NIC/python-rt/blob/e7a9f555e136708aec3317f857045145a2271e16/rt.py#L570-L640 | def get_ticket(self, ticket_id):
""" Fetch ticket by its ID.
:param ticket_id: ID of demanded ticket
:returns: Dictionary with key, value pairs for ticket with
*ticket_id* or None if ticket does not exist. List of keys:
* id
* nume... | [
"def",
"get_ticket",
"(",
"self",
",",
"ticket_id",
")",
":",
"msg",
"=",
"self",
".",
"__request",
"(",
"'ticket/{}/show'",
".",
"format",
"(",
"str",
"(",
"ticket_id",
")",
",",
")",
")",
"status_code",
"=",
"self",
".",
"__get_status_code",
"(",
"msg"... | Fetch ticket by its ID.
:param ticket_id: ID of demanded ticket
:returns: Dictionary with key, value pairs for ticket with
*ticket_id* or None if ticket does not exist. List of keys:
* id
* numerical_id
* Queue
... | [
"Fetch",
"ticket",
"by",
"its",
"ID",
"."
] | python | train |
mailgun/talon | talon/signature/learning/dataset.py | https://github.com/mailgun/talon/blob/cdd84563dd329c4f887591807870d10015e0c7a7/talon/signature/learning/dataset.py#L48-L85 | def parse_msg_sender(filename, sender_known=True):
"""Given a filename returns the sender and the message.
Here the message is assumed to be a whole MIME message or just
message body.
>>> sender, msg = parse_msg_sender('msg.eml')
>>> sender, msg = parse_msg_sender('msg_body')
If you don't wan... | [
"def",
"parse_msg_sender",
"(",
"filename",
",",
"sender_known",
"=",
"True",
")",
":",
"import",
"sys",
"kwargs",
"=",
"{",
"}",
"if",
"sys",
".",
"version_info",
">",
"(",
"3",
",",
"0",
")",
":",
"kwargs",
"[",
"\"encoding\"",
"]",
"=",
"\"utf8\"",
... | Given a filename returns the sender and the message.
Here the message is assumed to be a whole MIME message or just
message body.
>>> sender, msg = parse_msg_sender('msg.eml')
>>> sender, msg = parse_msg_sender('msg_body')
If you don't want to consider the sender's name in your classification
... | [
"Given",
"a",
"filename",
"returns",
"the",
"sender",
"and",
"the",
"message",
"."
] | python | train |
ksbg/sparklanes | sparklanes/_framework/validation.py | https://github.com/ksbg/sparklanes/blob/62e70892e6ae025be2f4c419f4afc34714d6884c/sparklanes/_framework/validation.py#L55-L105 | def validate_params(cls, mtd_name, *args, **kwargs):
"""Validates if the given args/kwargs match the method signature. Checks if:
- at least all required args/kwargs are given
- no redundant args/kwargs are given
Parameters
----------
cls : Class
mtd_name : str
Name of the method wh... | [
"def",
"validate_params",
"(",
"cls",
",",
"mtd_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"mtd",
"=",
"getattr",
"(",
"cls",
",",
"mtd_name",
")",
"py3_mtd_condition",
"=",
"(",
"not",
"(",
"inspect",
".",
"isfunction",
"(",
"mtd",
... | Validates if the given args/kwargs match the method signature. Checks if:
- at least all required args/kwargs are given
- no redundant args/kwargs are given
Parameters
----------
cls : Class
mtd_name : str
Name of the method whose parameters shall be validated
args: list
Pos... | [
"Validates",
"if",
"the",
"given",
"args",
"/",
"kwargs",
"match",
"the",
"method",
"signature",
".",
"Checks",
"if",
":",
"-",
"at",
"least",
"all",
"required",
"args",
"/",
"kwargs",
"are",
"given",
"-",
"no",
"redundant",
"args",
"/",
"kwargs",
"are",... | python | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers2.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers2.py#L621-L638 | def convert_merge(builder, layer, input_names, output_names, keras_layer):
"""
Convert concat layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
# Get input and ou... | [
"def",
"convert_merge",
"(",
"builder",
",",
"layer",
",",
"input_names",
",",
"output_names",
",",
"keras_layer",
")",
":",
"# Get input and output names",
"output_name",
"=",
"output_names",
"[",
"0",
"]",
"mode",
"=",
"_get_elementwise_name_from_keras_layer",
"(",
... | Convert concat layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"concat",
"layer",
"from",
"keras",
"to",
"coreml",
"."
] | python | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/navigation/__init__.py | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/navigation/__init__.py#L63-L88 | def process(self, article):
"""
Ingests an Article to create navigation structures and parse global
metadata.
"""
if self.article is not None and not self.collection:
log.warning('Could not process additional article. Navigation only \
handles one article unless colle... | [
"def",
"process",
"(",
"self",
",",
"article",
")",
":",
"if",
"self",
".",
"article",
"is",
"not",
"None",
"and",
"not",
"self",
".",
"collection",
":",
"log",
".",
"warning",
"(",
"'Could not process additional article. Navigation only \\\nhandles one article unle... | Ingests an Article to create navigation structures and parse global
metadata. | [
"Ingests",
"an",
"Article",
"to",
"create",
"navigation",
"structures",
"and",
"parse",
"global",
"metadata",
"."
] | python | train |
kensho-technologies/graphql-compiler | graphql_compiler/query_formatting/graphql_formatting.py | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/graphql_formatting.py#L10-L20 | def pretty_print_graphql(query, use_four_spaces=True):
"""Take a GraphQL query, pretty print it, and return it."""
# Use our custom visitor, which fixes directive argument order
# to get the canonical representation
output = visit(parse(query), CustomPrintingVisitor())
# Using four spaces for inden... | [
"def",
"pretty_print_graphql",
"(",
"query",
",",
"use_four_spaces",
"=",
"True",
")",
":",
"# Use our custom visitor, which fixes directive argument order",
"# to get the canonical representation",
"output",
"=",
"visit",
"(",
"parse",
"(",
"query",
")",
",",
"CustomPrinti... | Take a GraphQL query, pretty print it, and return it. | [
"Take",
"a",
"GraphQL",
"query",
"pretty",
"print",
"it",
"and",
"return",
"it",
"."
] | python | train |
aloetesting/aloe_webdriver | aloe_webdriver/__init__.py | https://github.com/aloetesting/aloe_webdriver/blob/65d847da4bdc63f9c015cb19d4efdee87df8ffad/aloe_webdriver/__init__.py#L208-L216 | def element_not_contains(self, element_id, value):
"""
Assert provided content is not contained within an element found by ``id``.
"""
elem = world.browser.find_elements_by_xpath(str(
'id("{id}")[contains(., "{value}")]'.format(
id=element_id, value=value)))
assert not elem, \
... | [
"def",
"element_not_contains",
"(",
"self",
",",
"element_id",
",",
"value",
")",
":",
"elem",
"=",
"world",
".",
"browser",
".",
"find_elements_by_xpath",
"(",
"str",
"(",
"'id(\"{id}\")[contains(., \"{value}\")]'",
".",
"format",
"(",
"id",
"=",
"element_id",
... | Assert provided content is not contained within an element found by ``id``. | [
"Assert",
"provided",
"content",
"is",
"not",
"contained",
"within",
"an",
"element",
"found",
"by",
"id",
"."
] | python | train |
quantopian/zipline | zipline/pipeline/loaders/blaze/utils.py | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/blaze/utils.py#L5-L48 | def load_raw_data(assets,
data_query_cutoff_times,
expr,
odo_kwargs,
checkpoints=None):
"""
Given an expression representing data to load, perform normalization and
forward-filling and return the data, materialized. Only accepts data wi... | [
"def",
"load_raw_data",
"(",
"assets",
",",
"data_query_cutoff_times",
",",
"expr",
",",
"odo_kwargs",
",",
"checkpoints",
"=",
"None",
")",
":",
"lower_dt",
",",
"upper_dt",
"=",
"data_query_cutoff_times",
"[",
"[",
"0",
",",
"-",
"1",
"]",
"]",
"raw",
"=... | Given an expression representing data to load, perform normalization and
forward-filling and return the data, materialized. Only accepts data with a
`sid` field.
Parameters
----------
assets : pd.int64index
the assets to load data for.
data_query_cutoff_times : pd.DatetimeIndex
... | [
"Given",
"an",
"expression",
"representing",
"data",
"to",
"load",
"perform",
"normalization",
"and",
"forward",
"-",
"filling",
"and",
"return",
"the",
"data",
"materialized",
".",
"Only",
"accepts",
"data",
"with",
"a",
"sid",
"field",
"."
] | python | train |
INM-6/hybridLFPy | hybridLFPy/helpers.py | https://github.com/INM-6/hybridLFPy/blob/c38bdf38982c4624c2f70caeb50c40f1d5980abd/hybridLFPy/helpers.py#L378-L398 | def normalize(data):
"""
Function to normalize data to have mean 0 and unity standard deviation
(also called z-transform)
Parameters
----------
data : numpy.ndarray
Returns
-------
numpy.ndarray
z-transform of input array
"""
data = data.astyp... | [
"def",
"normalize",
"(",
"data",
")",
":",
"data",
"=",
"data",
".",
"astype",
"(",
"float",
")",
"data",
"-=",
"data",
".",
"mean",
"(",
")",
"return",
"data",
"/",
"data",
".",
"std",
"(",
")"
] | Function to normalize data to have mean 0 and unity standard deviation
(also called z-transform)
Parameters
----------
data : numpy.ndarray
Returns
-------
numpy.ndarray
z-transform of input array | [
"Function",
"to",
"normalize",
"data",
"to",
"have",
"mean",
"0",
"and",
"unity",
"standard",
"deviation",
"(",
"also",
"called",
"z",
"-",
"transform",
")",
"Parameters",
"----------",
"data",
":",
"numpy",
".",
"ndarray",
"Returns",
"-------",
"numpy",
"."... | python | train |
senaite/senaite.core | bika/lims/browser/analysisrequest/add2.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/analysisrequest/add2.py#L1205-L1218 | def ajax_get_service(self):
"""Returns the services information
"""
uid = self.request.form.get("uid", None)
if uid is None:
return self.error("Invalid UID", status=400)
service = self.get_object_by_uid(uid)
if not service:
return self.error("Ser... | [
"def",
"ajax_get_service",
"(",
"self",
")",
":",
"uid",
"=",
"self",
".",
"request",
".",
"form",
".",
"get",
"(",
"\"uid\"",
",",
"None",
")",
"if",
"uid",
"is",
"None",
":",
"return",
"self",
".",
"error",
"(",
"\"Invalid UID\"",
",",
"status",
"=... | Returns the services information | [
"Returns",
"the",
"services",
"information"
] | python | train |
kadrlica/pymodeler | pymodeler/parameter.py | https://github.com/kadrlica/pymodeler/blob/f426c01416fd4b8fc3afeeb6d3b5d1cb0cb8f8e3/pymodeler/parameter.py#L147-L166 | def _load(self, **kwargs):
"""Load kwargs key,value pairs into __dict__
"""
defaults = dict([(d[0], d[1]) for d in self.defaults])
# Require kwargs are in defaults
for k in kwargs:
if k not in defaults:
msg = "Unrecognized attribute of %s: %s" % (
... | [
"def",
"_load",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"defaults",
"=",
"dict",
"(",
"[",
"(",
"d",
"[",
"0",
"]",
",",
"d",
"[",
"1",
"]",
")",
"for",
"d",
"in",
"self",
".",
"defaults",
"]",
")",
"# Require kwargs are in defaults",
"fo... | Load kwargs key,value pairs into __dict__ | [
"Load",
"kwargs",
"key",
"value",
"pairs",
"into",
"__dict__"
] | python | test |
SeanOC/sharpy | sharpy/product.py | https://github.com/SeanOC/sharpy/blob/935943ca86034255f0a93c1a84734814be176ed4/sharpy/product.py#L214-L241 | def get_customers(self, filter_data=None):
'''
Returns all customers. Sometimes they are too much and cause internal
server errors on CG. API call permits post parameters for filtering
which tends to fix this
https://cheddargetter.com/developers#all-customers
filter_da... | [
"def",
"get_customers",
"(",
"self",
",",
"filter_data",
"=",
"None",
")",
":",
"customers",
"=",
"[",
"]",
"try",
":",
"response",
"=",
"self",
".",
"client",
".",
"make_request",
"(",
"path",
"=",
"'customers/get'",
",",
"data",
"=",
"filter_data",
")"... | Returns all customers. Sometimes they are too much and cause internal
server errors on CG. API call permits post parameters for filtering
which tends to fix this
https://cheddargetter.com/developers#all-customers
filter_data
Will be processed by urlencode and can be used f... | [
"Returns",
"all",
"customers",
".",
"Sometimes",
"they",
"are",
"too",
"much",
"and",
"cause",
"internal",
"server",
"errors",
"on",
"CG",
".",
"API",
"call",
"permits",
"post",
"parameters",
"for",
"filtering",
"which",
"tends",
"to",
"fix",
"this",
"https"... | python | train |
gmr/tinman | tinman/handlers/base.py | https://github.com/gmr/tinman/blob/98f0acd15a228d752caa1864cdf02aaa3d492a9f/tinman/handlers/base.py#L222-L229 | def prepare(self):
"""Prepare the session, setting up the session object and loading in
the values, assigning the IP address to the session if it's an new one.
"""
super(SessionRequestHandler, self).prepare()
result = yield gen.Task(self.start_session)
LOGGER.debug('Exit... | [
"def",
"prepare",
"(",
"self",
")",
":",
"super",
"(",
"SessionRequestHandler",
",",
"self",
")",
".",
"prepare",
"(",
")",
"result",
"=",
"yield",
"gen",
".",
"Task",
"(",
"self",
".",
"start_session",
")",
"LOGGER",
".",
"debug",
"(",
"'Exiting Session... | Prepare the session, setting up the session object and loading in
the values, assigning the IP address to the session if it's an new one. | [
"Prepare",
"the",
"session",
"setting",
"up",
"the",
"session",
"object",
"and",
"loading",
"in",
"the",
"values",
"assigning",
"the",
"IP",
"address",
"to",
"the",
"session",
"if",
"it",
"s",
"an",
"new",
"one",
"."
] | python | train |
hydraplatform/hydra-base | hydra_base/lib/attributes.py | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/attributes.py#L425-L453 | def get_resource_attributes(ref_key, ref_id, type_id=None, **kwargs):
"""
Get all the resource attributes for a given resource.
If type_id is specified, only
return the resource attributes within the type.
"""
user_id = kwargs.get('user_id')
resource_attr_qry = db.DBSession.que... | [
"def",
"get_resource_attributes",
"(",
"ref_key",
",",
"ref_id",
",",
"type_id",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"user_id",
"=",
"kwargs",
".",
"get",
"(",
"'user_id'",
")",
"resource_attr_qry",
"=",
"db",
".",
"DBSession",
".",
"query",
... | Get all the resource attributes for a given resource.
If type_id is specified, only
return the resource attributes within the type. | [
"Get",
"all",
"the",
"resource",
"attributes",
"for",
"a",
"given",
"resource",
".",
"If",
"type_id",
"is",
"specified",
"only",
"return",
"the",
"resource",
"attributes",
"within",
"the",
"type",
"."
] | python | train |
waqasbhatti/astrobase | astrobase/checkplot/pkl_png.py | https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/checkplot/pkl_png.py#L75-L1129 | def checkplot_pickle_to_png(
checkplotin,
outfile,
extrarows=None
):
'''This reads the checkplot pickle or dict provided, and writes out a PNG.
The output PNG contains most of the information in the input checkplot
pickle/dict, and can be used to quickly glance through the highlight... | [
"def",
"checkplot_pickle_to_png",
"(",
"checkplotin",
",",
"outfile",
",",
"extrarows",
"=",
"None",
")",
":",
"# figure out if the checkplotpickle is a filename",
"# python 3",
"if",
"sys",
".",
"version_info",
"[",
":",
"2",
"]",
">",
"(",
"3",
",",
"2",
")",
... | This reads the checkplot pickle or dict provided, and writes out a PNG.
The output PNG contains most of the information in the input checkplot
pickle/dict, and can be used to quickly glance through the highlights
instead of having to review the checkplot with the `checkplotserver`
webapp. This is usefu... | [
"This",
"reads",
"the",
"checkplot",
"pickle",
"or",
"dict",
"provided",
"and",
"writes",
"out",
"a",
"PNG",
"."
] | python | valid |
cons3rt/pycons3rt | pycons3rt/awsapi/metadata.py | https://github.com/cons3rt/pycons3rt/blob/f004ab3a35c5bff2f698131fef3b2a8ed5a7596d/pycons3rt/awsapi/metadata.py#L44-L79 | def is_aws():
"""Determines if this system is on AWS
:return: bool True if this system is running on AWS
"""
log = logging.getLogger(mod_logger + '.is_aws')
log.info('Querying AWS meta data URL: {u}'.format(u=metadata_url))
# Re-try logic for checking the AWS meta data URL
retry_time_sec =... | [
"def",
"is_aws",
"(",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"mod_logger",
"+",
"'.is_aws'",
")",
"log",
".",
"info",
"(",
"'Querying AWS meta data URL: {u}'",
".",
"format",
"(",
"u",
"=",
"metadata_url",
")",
")",
"# Re-try logic for checkin... | Determines if this system is on AWS
:return: bool True if this system is running on AWS | [
"Determines",
"if",
"this",
"system",
"is",
"on",
"AWS"
] | python | train |
proycon/pynlpl | pynlpl/formats/folia.py | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1877-L2047 | def xml(self, attribs = None,elements = None, skipchildren = False):
"""Serialises the FoLiA element and all its contents to XML.
Arguments are mostly for internal use.
Returns:
an lxml.etree.Element
See also:
:meth:`AbstractElement.xmlstring` - for direct stri... | [
"def",
"xml",
"(",
"self",
",",
"attribs",
"=",
"None",
",",
"elements",
"=",
"None",
",",
"skipchildren",
"=",
"False",
")",
":",
"E",
"=",
"ElementMaker",
"(",
"namespace",
"=",
"NSFOLIA",
",",
"nsmap",
"=",
"{",
"None",
":",
"NSFOLIA",
",",
"'xml'... | Serialises the FoLiA element and all its contents to XML.
Arguments are mostly for internal use.
Returns:
an lxml.etree.Element
See also:
:meth:`AbstractElement.xmlstring` - for direct string output | [
"Serialises",
"the",
"FoLiA",
"element",
"and",
"all",
"its",
"contents",
"to",
"XML",
"."
] | python | train |
gamechanger/dusty | dusty/compiler/compose/__init__.py | https://github.com/gamechanger/dusty/blob/dc12de90bb6945023d6f43a8071e984313a1d984/dusty/compiler/compose/__init__.py#L70-L75 | def _get_build_path(app_spec):
""" Given a spec for an app, returns the value of the `build` field for docker-compose.
If the path is relative, it is expanded and added to the path of the app's repo. """
if os.path.isabs(app_spec['build']):
return app_spec['build']
return os.path.join(Repo(app_s... | [
"def",
"_get_build_path",
"(",
"app_spec",
")",
":",
"if",
"os",
".",
"path",
".",
"isabs",
"(",
"app_spec",
"[",
"'build'",
"]",
")",
":",
"return",
"app_spec",
"[",
"'build'",
"]",
"return",
"os",
".",
"path",
".",
"join",
"(",
"Repo",
"(",
"app_sp... | Given a spec for an app, returns the value of the `build` field for docker-compose.
If the path is relative, it is expanded and added to the path of the app's repo. | [
"Given",
"a",
"spec",
"for",
"an",
"app",
"returns",
"the",
"value",
"of",
"the",
"build",
"field",
"for",
"docker",
"-",
"compose",
".",
"If",
"the",
"path",
"is",
"relative",
"it",
"is",
"expanded",
"and",
"added",
"to",
"the",
"path",
"of",
"the",
... | python | valid |
dask/dask-ml | dask_ml/utils.py | https://github.com/dask/dask-ml/blob/cc4837c2c2101f9302cac38354b55754263cd1f3/dask_ml/utils.py#L224-L261 | def check_chunks(n_samples, n_features, chunks=None):
"""Validate and normalize the chunks argument for a dask.array
Parameters
----------
n_samples, n_features : int
Give the shape of the array
chunks : int, sequence, optional, default None
* For 'chunks=None', this picks a "good" ... | [
"def",
"check_chunks",
"(",
"n_samples",
",",
"n_features",
",",
"chunks",
"=",
"None",
")",
":",
"if",
"chunks",
"is",
"None",
":",
"chunks",
"=",
"(",
"max",
"(",
"100",
",",
"n_samples",
"//",
"cpu_count",
"(",
")",
")",
",",
"n_features",
")",
"e... | Validate and normalize the chunks argument for a dask.array
Parameters
----------
n_samples, n_features : int
Give the shape of the array
chunks : int, sequence, optional, default None
* For 'chunks=None', this picks a "good" default number of chunks based
on the number of CPU... | [
"Validate",
"and",
"normalize",
"the",
"chunks",
"argument",
"for",
"a",
"dask",
".",
"array"
] | python | train |
amicks/Speculator | speculator/utils/date.py | https://github.com/amicks/Speculator/blob/f7d6590aded20b1e1b5df16a4b27228ee821c4ab/speculator/utils/date.py#L71-L103 | def get_end_start_epochs(year, month, day, direction, unit, count):
""" Gets epoch from a start date and epoch from a shifted date
Args:
year: Int between 1 and 9999.
month: Int between 1 and 12.
day: Int between 1 and 31.
direction: String to shift time forwards or backwards.
... | [
"def",
"get_end_start_epochs",
"(",
"year",
",",
"month",
",",
"day",
",",
"direction",
",",
"unit",
",",
"count",
")",
":",
"if",
"year",
"or",
"month",
"or",
"day",
":",
"# Date is specified",
"if",
"not",
"year",
":",
"year",
"=",
"2017",
"if",
"not... | Gets epoch from a start date and epoch from a shifted date
Args:
year: Int between 1 and 9999.
month: Int between 1 and 12.
day: Int between 1 and 31.
direction: String to shift time forwards or backwards.
Valid values: 'last', 'next'.
unit: String of time period... | [
"Gets",
"epoch",
"from",
"a",
"start",
"date",
"and",
"epoch",
"from",
"a",
"shifted",
"date"
] | python | train |
gaqzi/py-gocd | gocd/api/pipeline.py | https://github.com/gaqzi/py-gocd/blob/6fe5b62dea51e665c11a343aba5fc98e130c5c63/gocd/api/pipeline.py#L192-L204 | def artifact(self, counter, stage, job, stage_counter=1):
"""Helper to instantiate an :class:`gocd.api.artifact.Artifact` object
Args:
counter (int): The pipeline counter to get the artifact for
stage: Stage name
job: Job name
stage_counter: Defaults to 1
... | [
"def",
"artifact",
"(",
"self",
",",
"counter",
",",
"stage",
",",
"job",
",",
"stage_counter",
"=",
"1",
")",
":",
"return",
"Artifact",
"(",
"self",
".",
"server",
",",
"self",
".",
"name",
",",
"counter",
",",
"stage",
",",
"job",
",",
"stage_coun... | Helper to instantiate an :class:`gocd.api.artifact.Artifact` object
Args:
counter (int): The pipeline counter to get the artifact for
stage: Stage name
job: Job name
stage_counter: Defaults to 1
Returns:
Artifact: :class:`gocd.api.artifact.Artifact` ob... | [
"Helper",
"to",
"instantiate",
"an",
":",
"class",
":",
"gocd",
".",
"api",
".",
"artifact",
".",
"Artifact",
"object"
] | python | valid |
pallets/werkzeug | src/werkzeug/datastructures.py | https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/datastructures.py#L2091-L2100 | def find(self, header):
"""Return the index of the header in the set or return -1 if not found.
:param header: the header to be looked up.
"""
header = header.lower()
for idx, item in enumerate(self._headers):
if item.lower() == header:
return idx
... | [
"def",
"find",
"(",
"self",
",",
"header",
")",
":",
"header",
"=",
"header",
".",
"lower",
"(",
")",
"for",
"idx",
",",
"item",
"in",
"enumerate",
"(",
"self",
".",
"_headers",
")",
":",
"if",
"item",
".",
"lower",
"(",
")",
"==",
"header",
":",... | Return the index of the header in the set or return -1 if not found.
:param header: the header to be looked up. | [
"Return",
"the",
"index",
"of",
"the",
"header",
"in",
"the",
"set",
"or",
"return",
"-",
"1",
"if",
"not",
"found",
"."
] | python | train |
b3j0f/utils | b3j0f/utils/proxy.py | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/proxy.py#L174-L259 | def proxify_routine(routine, impl=None):
"""Proxify a routine with input impl.
:param routine: routine to proxify.
:param impl: new impl to use. If None, use routine.
"""
# init impl
impl = routine if impl is None else impl
is_method = ismethod(routine)
if is_method:
function ... | [
"def",
"proxify_routine",
"(",
"routine",
",",
"impl",
"=",
"None",
")",
":",
"# init impl",
"impl",
"=",
"routine",
"if",
"impl",
"is",
"None",
"else",
"impl",
"is_method",
"=",
"ismethod",
"(",
"routine",
")",
"if",
"is_method",
":",
"function",
"=",
"... | Proxify a routine with input impl.
:param routine: routine to proxify.
:param impl: new impl to use. If None, use routine. | [
"Proxify",
"a",
"routine",
"with",
"input",
"impl",
"."
] | python | train |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_nameserver.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_nameserver.py#L199-L213 | def get_nameserver_detail_output_show_nameserver_nameserver_porttype(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_nameserver_detail = ET.Element("get_nameserver_detail")
config = get_nameserver_detail
output = ET.SubElement(get_nameserver_... | [
"def",
"get_nameserver_detail_output_show_nameserver_nameserver_porttype",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"get_nameserver_detail",
"=",
"ET",
".",
"Element",
"(",
"\"get_nameserver_detail\""... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
open-homeautomation/miflora | miflora/miflora_scanner.py | https://github.com/open-homeautomation/miflora/blob/916606e7edc70bdc017dfbe681bc81771e0df7f3/miflora/miflora_scanner.py#L10-L20 | def scan(backend, timeout=10):
"""Scan for miflora devices.
Note: this must be run as root!
"""
result = []
for (mac, name) in backend.scan_for_devices(timeout):
if (name is not None and name.lower() in VALID_DEVICE_NAMES) or \
mac is not None and mac.upper().startswith(DEVI... | [
"def",
"scan",
"(",
"backend",
",",
"timeout",
"=",
"10",
")",
":",
"result",
"=",
"[",
"]",
"for",
"(",
"mac",
",",
"name",
")",
"in",
"backend",
".",
"scan_for_devices",
"(",
"timeout",
")",
":",
"if",
"(",
"name",
"is",
"not",
"None",
"and",
"... | Scan for miflora devices.
Note: this must be run as root! | [
"Scan",
"for",
"miflora",
"devices",
"."
] | python | train |
tensorflow/tensor2tensor | tensor2tensor/models/research/transformer_revnet.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/research/transformer_revnet.py#L136-L213 | def transformer_revnet_decoder(decoder_input,
encoder_output,
decoder_self_attention_bias,
encoder_decoder_attention_bias,
hparams,
name="decoder"):
"""A stack of ... | [
"def",
"transformer_revnet_decoder",
"(",
"decoder_input",
",",
"encoder_output",
",",
"decoder_self_attention_bias",
",",
"encoder_decoder_attention_bias",
",",
"hparams",
",",
"name",
"=",
"\"decoder\"",
")",
":",
"def",
"f",
"(",
"x",
",",
"side_input",
")",
":",... | A stack of transformer layers.
Args:
decoder_input: a Tensor
encoder_output: a Tensor
decoder_self_attention_bias: bias Tensor for self-attention
(see common_attention.attention_bias())
encoder_decoder_attention_bias: bias Tensor for encoder-decoder attention
(see common_attention.attenti... | [
"A",
"stack",
"of",
"transformer",
"layers",
"."
] | python | train |
saltstack/salt | salt/returners/redis_return.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/redis_return.py#L219-L224 | def save_load(jid, load, minions=None):
'''
Save the load to the specified jid
'''
serv = _get_serv(ret=None)
serv.setex('load:{0}'.format(jid), _get_ttl(), salt.utils.json.dumps(load)) | [
"def",
"save_load",
"(",
"jid",
",",
"load",
",",
"minions",
"=",
"None",
")",
":",
"serv",
"=",
"_get_serv",
"(",
"ret",
"=",
"None",
")",
"serv",
".",
"setex",
"(",
"'load:{0}'",
".",
"format",
"(",
"jid",
")",
",",
"_get_ttl",
"(",
")",
",",
"... | Save the load to the specified jid | [
"Save",
"the",
"load",
"to",
"the",
"specified",
"jid"
] | python | train |
ismms-himc/clustergrammer2 | setupbase.py | https://github.com/ismms-himc/clustergrammer2/blob/5acea9bff7eda546cf0647b9e3647f631eb6f5f5/setupbase.py#L321-L377 | def install_npm(path=None, build_dir=None, source_dir=None, build_cmd='build', force=False, npm=None):
"""Return a Command for managing an npm installation.
Note: The command is skipped if the `--skip-npm` flag is used.
Parameters
----------
path: str, optional
The base path of the node pa... | [
"def",
"install_npm",
"(",
"path",
"=",
"None",
",",
"build_dir",
"=",
"None",
",",
"source_dir",
"=",
"None",
",",
"build_cmd",
"=",
"'build'",
",",
"force",
"=",
"False",
",",
"npm",
"=",
"None",
")",
":",
"class",
"NPM",
"(",
"BaseCommand",
")",
"... | Return a Command for managing an npm installation.
Note: The command is skipped if the `--skip-npm` flag is used.
Parameters
----------
path: str, optional
The base path of the node package. Defaults to the repo root.
build_dir: str, optional
The target build directory. If this a... | [
"Return",
"a",
"Command",
"for",
"managing",
"an",
"npm",
"installation",
"."
] | python | train |
JarryShaw/PyPCAPKit | src/toolkit/scapy.py | https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/toolkit/scapy.py#L48-L63 | def packet2dict(packet, *, count=NotImplemented):
"""Convert Scapy packet into dict."""
if scapy_all is None:
raise ModuleNotFound("No module named 'scapy'", name='scapy')
def wrapper(packet):
dict_ = packet.fields
payload = packet.payload
if not isinstance(payload, scapy_al... | [
"def",
"packet2dict",
"(",
"packet",
",",
"*",
",",
"count",
"=",
"NotImplemented",
")",
":",
"if",
"scapy_all",
"is",
"None",
":",
"raise",
"ModuleNotFound",
"(",
"\"No module named 'scapy'\"",
",",
"name",
"=",
"'scapy'",
")",
"def",
"wrapper",
"(",
"packe... | Convert Scapy packet into dict. | [
"Convert",
"Scapy",
"packet",
"into",
"dict",
"."
] | python | train |
gmr/helper | helper/unix.py | https://github.com/gmr/helper/blob/fe8e45fc8eabf619429b2940c682c252ee33c082/helper/unix.py#L131-L142 | def uid(self):
"""Return the user id that the process will run as
:rtype: int
"""
if not self._uid:
if self.config.daemon.user:
self._uid = pwd.getpwnam(self.config.daemon.user).pw_uid
else:
self._uid = os.getuid()
return ... | [
"def",
"uid",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_uid",
":",
"if",
"self",
".",
"config",
".",
"daemon",
".",
"user",
":",
"self",
".",
"_uid",
"=",
"pwd",
".",
"getpwnam",
"(",
"self",
".",
"config",
".",
"daemon",
".",
"user",
... | Return the user id that the process will run as
:rtype: int | [
"Return",
"the",
"user",
"id",
"that",
"the",
"process",
"will",
"run",
"as"
] | python | train |
pantsbuild/pants | pants-plugins/src/python/internal_backend/sitegen/tasks/sitegen.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/pants-plugins/src/python/internal_backend/sitegen/tasks/sitegen.py#L249-L256 | def transform_soups(config, soups, precomputed):
"""Mutate our soups to be better when we write them out later."""
fixup_internal_links(config, soups)
ensure_headings_linkable(soups)
# Do this after ensure_headings_linkable so that there will be links.
generate_page_tocs(soups, precomputed)
link_pantsrefs(... | [
"def",
"transform_soups",
"(",
"config",
",",
"soups",
",",
"precomputed",
")",
":",
"fixup_internal_links",
"(",
"config",
",",
"soups",
")",
"ensure_headings_linkable",
"(",
"soups",
")",
"# Do this after ensure_headings_linkable so that there will be links.",
"generate_p... | Mutate our soups to be better when we write them out later. | [
"Mutate",
"our",
"soups",
"to",
"be",
"better",
"when",
"we",
"write",
"them",
"out",
"later",
"."
] | python | train |
Qiskit/qiskit-terra | qiskit/qasm/node/id.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/qasm/node/id.py#L56-L63 | def sym(self, nested_scope=None):
"""Return the correspond symbolic number."""
if not nested_scope or self.name not in nested_scope[-1]:
raise NodeException("Expected local parameter name: ",
"name=%s, line=%s, file=%s" % (
... | [
"def",
"sym",
"(",
"self",
",",
"nested_scope",
"=",
"None",
")",
":",
"if",
"not",
"nested_scope",
"or",
"self",
".",
"name",
"not",
"in",
"nested_scope",
"[",
"-",
"1",
"]",
":",
"raise",
"NodeException",
"(",
"\"Expected local parameter name: \"",
",",
... | Return the correspond symbolic number. | [
"Return",
"the",
"correspond",
"symbolic",
"number",
"."
] | python | test |
EventRegistry/event-registry-python | eventregistry/QueryEvents.py | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/QueryEvents.py#L172-L179 | def initWithEventUriWgtList(uriWgtList):
"""
Set a custom list of event uris. The results will be then computed on this list - no query will be done (all conditions will be ignored).
"""
q = QueryEvents()
assert isinstance(uriWgtList, list), "uriWgtList has to be a list of string... | [
"def",
"initWithEventUriWgtList",
"(",
"uriWgtList",
")",
":",
"q",
"=",
"QueryEvents",
"(",
")",
"assert",
"isinstance",
"(",
"uriWgtList",
",",
"list",
")",
",",
"\"uriWgtList has to be a list of strings that represent event uris with their weights\"",
"q",
".",
"queryP... | Set a custom list of event uris. The results will be then computed on this list - no query will be done (all conditions will be ignored). | [
"Set",
"a",
"custom",
"list",
"of",
"event",
"uris",
".",
"The",
"results",
"will",
"be",
"then",
"computed",
"on",
"this",
"list",
"-",
"no",
"query",
"will",
"be",
"done",
"(",
"all",
"conditions",
"will",
"be",
"ignored",
")",
"."
] | python | train |
ome/omego | omego/fileutils.py | https://github.com/ome/omego/blob/2dadbf3c6342b6c995f9e0dceaf3c0b7fab030fb/omego/fileutils.py#L194-L228 | def check_extracted_paths(namelist, subdir=None):
"""
Check whether zip file paths are all relative, and optionally in a
specified subdirectory, raises an exception if not
namelist: A list of paths from the zip file
subdir: If specified then check whether all paths in the zip file are
under t... | [
"def",
"check_extracted_paths",
"(",
"namelist",
",",
"subdir",
"=",
"None",
")",
":",
"def",
"relpath",
"(",
"p",
")",
":",
"# relpath strips a trailing sep",
"# Windows paths may also use unix sep",
"q",
"=",
"os",
".",
"path",
".",
"relpath",
"(",
"p",
")",
... | Check whether zip file paths are all relative, and optionally in a
specified subdirectory, raises an exception if not
namelist: A list of paths from the zip file
subdir: If specified then check whether all paths in the zip file are
under this subdirectory
Python docs are unclear about the securi... | [
"Check",
"whether",
"zip",
"file",
"paths",
"are",
"all",
"relative",
"and",
"optionally",
"in",
"a",
"specified",
"subdirectory",
"raises",
"an",
"exception",
"if",
"not"
] | python | train |
ThomasChiroux/attowiki | src/attowiki/views.py | https://github.com/ThomasChiroux/attowiki/blob/6c93c420305490d324fdc95a7b40b2283a222183/src/attowiki/views.py#L314-L378 | def view_page(name=None):
"""Serve a page name.
.. note:: this is a bottle view
* if the view is called with the POST method, write the new page
content to the file, commit the modification and then display the
html rendering of the restructured text file
* if the view is called with the ... | [
"def",
"view_page",
"(",
"name",
"=",
"None",
")",
":",
"if",
"request",
".",
"method",
"==",
"'POST'",
":",
"if",
"name",
"is",
"None",
":",
"# new file",
"if",
"len",
"(",
"request",
".",
"forms",
".",
"filename",
")",
">",
"0",
":",
"name",
"=",... | Serve a page name.
.. note:: this is a bottle view
* if the view is called with the POST method, write the new page
content to the file, commit the modification and then display the
html rendering of the restructured text file
* if the view is called with the GET method, directly display the ... | [
"Serve",
"a",
"page",
"name",
"."
] | python | train |
hamelsmu/ktext | ktext/preprocess.py | https://github.com/hamelsmu/ktext/blob/221f09f5b1762705075fd1bd914881c0724d5e02/ktext/preprocess.py#L307-L311 | def token_count_pandas(self):
""" See token counts as pandas dataframe"""
freq_df = pd.DataFrame.from_dict(self.indexer.word_counts, orient='index')
freq_df.columns = ['count']
return freq_df.sort_values('count', ascending=False) | [
"def",
"token_count_pandas",
"(",
"self",
")",
":",
"freq_df",
"=",
"pd",
".",
"DataFrame",
".",
"from_dict",
"(",
"self",
".",
"indexer",
".",
"word_counts",
",",
"orient",
"=",
"'index'",
")",
"freq_df",
".",
"columns",
"=",
"[",
"'count'",
"]",
"retur... | See token counts as pandas dataframe | [
"See",
"token",
"counts",
"as",
"pandas",
"dataframe"
] | python | test |
ARMmbed/icetea | icetea_lib/ResourceProvider/ResourceConfig.py | https://github.com/ARMmbed/icetea/blob/b2b97ac607429830cf7d62dae2e3903692c7c778/icetea_lib/ResourceProvider/ResourceConfig.py#L79-L107 | def resolve_configuration(self, configuration):
"""
Resolve requirements from given JSON encoded data.
The JSON should follow the testcase meta-data requirements field format. This function
will resolve requirements for each individual DUT and create a DUT requirements list
that ... | [
"def",
"resolve_configuration",
"(",
"self",
",",
"configuration",
")",
":",
"configuration",
"=",
"configuration",
"if",
"configuration",
"else",
"self",
".",
"json_config",
"self",
".",
"_resolve_requirements",
"(",
"configuration",
"[",
"\"requirements\"",
"]",
"... | Resolve requirements from given JSON encoded data.
The JSON should follow the testcase meta-data requirements field format. This function
will resolve requirements for each individual DUT and create a DUT requirements list
that contains the configuration for each DUT, eg:
{
"... | [
"Resolve",
"requirements",
"from",
"given",
"JSON",
"encoded",
"data",
".",
"The",
"JSON",
"should",
"follow",
"the",
"testcase",
"meta",
"-",
"data",
"requirements",
"field",
"format",
".",
"This",
"function",
"will",
"resolve",
"requirements",
"for",
"each",
... | python | train |
h2oai/h2o-3 | h2o-py/h2o/model/model_base.py | https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/model/model_base.py#L823-L838 | def save_mojo(self, path="", force=False):
"""
Save an H2O Model as MOJO (Model Object, Optimized) to disk.
:param model: The model object to save.
:param path: a path to save the model at (hdfs, s3, local)
:param force: if True overwrite destination directory in case it exists,... | [
"def",
"save_mojo",
"(",
"self",
",",
"path",
"=",
"\"\"",
",",
"force",
"=",
"False",
")",
":",
"assert_is_type",
"(",
"path",
",",
"str",
")",
"assert_is_type",
"(",
"force",
",",
"bool",
")",
"if",
"not",
"self",
".",
"have_mojo",
":",
"raise",
"H... | Save an H2O Model as MOJO (Model Object, Optimized) to disk.
:param model: The model object to save.
:param path: a path to save the model at (hdfs, s3, local)
:param force: if True overwrite destination directory in case it exists, or throw exception if set to False.
:returns str: the... | [
"Save",
"an",
"H2O",
"Model",
"as",
"MOJO",
"(",
"Model",
"Object",
"Optimized",
")",
"to",
"disk",
"."
] | python | test |
rstoneback/pysat | pysat/instruments/dmsp_ivm.py | https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/instruments/dmsp_ivm.py#L135-L175 | def download(date_array, tag, sat_id, data_path=None, user=None, password=None):
"""Downloads data from Madrigal.
The user's names should be provided in field user. John Malkovich should be
entered as John+Malkovich
The password field should be the user's email address. These parameters
... | [
"def",
"download",
"(",
"date_array",
",",
"tag",
",",
"sat_id",
",",
"data_path",
"=",
"None",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"import",
"subprocess",
"# currently passes things along if no user and password supplied",
"# need to d... | Downloads data from Madrigal.
The user's names should be provided in field user. John Malkovich should be
entered as John+Malkovich
The password field should be the user's email address. These parameters
are passed to Madrigal when downloading.
The affiliation field is set to pysat ... | [
"Downloads",
"data",
"from",
"Madrigal",
".",
"The",
"user",
"s",
"names",
"should",
"be",
"provided",
"in",
"field",
"user",
".",
"John",
"Malkovich",
"should",
"be",
"entered",
"as",
"John",
"+",
"Malkovich",
"The",
"password",
"field",
"should",
"be",
"... | python | train |
nuagenetworks/bambou | bambou/nurest_object.py | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/nurest_object.py#L432-L464 | def expose_attribute(self, local_name, attribute_type, remote_name=None, display_name=None, is_required=False, is_readonly=False, max_length=None, min_length=None, is_identifier=False, choices=None, is_unique=False, is_email=False, is_login=False, is_editable=True, is_password=False, can_order=False, can_search=False, ... | [
"def",
"expose_attribute",
"(",
"self",
",",
"local_name",
",",
"attribute_type",
",",
"remote_name",
"=",
"None",
",",
"display_name",
"=",
"None",
",",
"is_required",
"=",
"False",
",",
"is_readonly",
"=",
"False",
",",
"max_length",
"=",
"None",
",",
"min... | Expose local_name as remote_name
An exposed attribute `local_name` will be sent within the HTTP request as
a `remote_name` | [
"Expose",
"local_name",
"as",
"remote_name"
] | python | train |
esterhui/pypu | pypu/service_facebook.py | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L103-L111 | def Remove(self,directory,filename):
"""Deletes files from fb"""
if self._isMediaFile(filename):
return self._remove_media(directory,filename)
elif self._isConfigFile(filename):
return True
print "Not handled!"
return False | [
"def",
"Remove",
"(",
"self",
",",
"directory",
",",
"filename",
")",
":",
"if",
"self",
".",
"_isMediaFile",
"(",
"filename",
")",
":",
"return",
"self",
".",
"_remove_media",
"(",
"directory",
",",
"filename",
")",
"elif",
"self",
".",
"_isConfigFile",
... | Deletes files from fb | [
"Deletes",
"files",
"from",
"fb"
] | python | train |
pywbem/pywbem | attic/cim_provider.py | https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/attic/cim_provider.py#L604-L632 | def MI_createInstance(self,
env,
instance):
# pylint: disable=invalid-name
"""Create a CIM instance, and return its instance name
Implements the WBEM operation CreateInstance in terms
of the set_instance method. A derived class will n... | [
"def",
"MI_createInstance",
"(",
"self",
",",
"env",
",",
"instance",
")",
":",
"# pylint: disable=invalid-name",
"logger",
"=",
"env",
".",
"get_logger",
"(",
")",
"logger",
".",
"log_debug",
"(",
"'CIMProvider MI_createInstance called...'",
")",
"rval",
"=",
"No... | Create a CIM instance, and return its instance name
Implements the WBEM operation CreateInstance in terms
of the set_instance method. A derived class will not normally
override this method. | [
"Create",
"a",
"CIM",
"instance",
"and",
"return",
"its",
"instance",
"name"
] | python | train |
saltstack/salt | salt/modules/redismod.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/redismod.py#L346-L359 | def hlen(key, host=None, port=None, db=None, password=None):
'''
Returns number of fields of a hash.
.. versionadded:: 2017.7.0
CLI Example:
.. code-block:: bash
salt '*' redis.hlen foo_hash
'''
server = _connect(host, port, db, password)
return server.hlen(key) | [
"def",
"hlen",
"(",
"key",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"db",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"server",
"=",
"_connect",
"(",
"host",
",",
"port",
",",
"db",
",",
"password",
")",
"return",
"server... | Returns number of fields of a hash.
.. versionadded:: 2017.7.0
CLI Example:
.. code-block:: bash
salt '*' redis.hlen foo_hash | [
"Returns",
"number",
"of",
"fields",
"of",
"a",
"hash",
"."
] | python | train |
JukeboxPipeline/jukebox-core | src/jukeboxcore/gui/widgetdelegate.py | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/widgetdelegate.py#L534-L547 | def get_total_indentation(self, index):
"""Get the indentation for the given index
:param index: the index to query
:type index: :class:`QtCore.ModelIndex`
:returns: the number of parents
:rtype: int
:raises: None
"""
n = 0
while index.isValid():
... | [
"def",
"get_total_indentation",
"(",
"self",
",",
"index",
")",
":",
"n",
"=",
"0",
"while",
"index",
".",
"isValid",
"(",
")",
":",
"n",
"+=",
"1",
"index",
"=",
"index",
".",
"parent",
"(",
")",
"return",
"n",
"*",
"self",
".",
"indentation",
"("... | Get the indentation for the given index
:param index: the index to query
:type index: :class:`QtCore.ModelIndex`
:returns: the number of parents
:rtype: int
:raises: None | [
"Get",
"the",
"indentation",
"for",
"the",
"given",
"index"
] | python | train |
vmonaco/pohmm | pohmm/classification.py | https://github.com/vmonaco/pohmm/blob/c00f8a62d3005a171d424549a55d46c421859ae9/pohmm/classification.py#L32-L45 | def fit_df(self, labels, dfs, pstate_col=PSTATE_COL):
"""
Fit the classifier with labels y and DataFrames dfs
"""
assert len(labels) == len(dfs)
for label in set(labels):
label_dfs = [s for l,s in zip(labels, dfs) if l == label]
pohmm = self.pohmm_factor... | [
"def",
"fit_df",
"(",
"self",
",",
"labels",
",",
"dfs",
",",
"pstate_col",
"=",
"PSTATE_COL",
")",
":",
"assert",
"len",
"(",
"labels",
")",
"==",
"len",
"(",
"dfs",
")",
"for",
"label",
"in",
"set",
"(",
"labels",
")",
":",
"label_dfs",
"=",
"[",... | Fit the classifier with labels y and DataFrames dfs | [
"Fit",
"the",
"classifier",
"with",
"labels",
"y",
"and",
"DataFrames",
"dfs"
] | python | train |
wbond/vat_moss-python | vat_moss/billing_address.py | https://github.com/wbond/vat_moss-python/blob/5089dcf036eb2e9abc58e78186fd46b522a50620/vat_moss/billing_address.py#L17-L104 | def calculate_rate(country_code, postal_code, city):
"""
Calculates the VAT rate that should be collected based on address
information provided
:param country_code:
The two-character country code
:param postal_code:
The postal code for the user
:param city:
The city na... | [
"def",
"calculate_rate",
"(",
"country_code",
",",
"postal_code",
",",
"city",
")",
":",
"if",
"not",
"country_code",
"or",
"not",
"isinstance",
"(",
"country_code",
",",
"str_cls",
")",
":",
"raise",
"ValueError",
"(",
"'Invalidly formatted country code'",
")",
... | Calculates the VAT rate that should be collected based on address
information provided
:param country_code:
The two-character country code
:param postal_code:
The postal code for the user
:param city:
The city name for the user
:raises:
ValueError - If country cod... | [
"Calculates",
"the",
"VAT",
"rate",
"that",
"should",
"be",
"collected",
"based",
"on",
"address",
"information",
"provided"
] | python | train |
gem/oq-engine | openquake/baselib/datastore.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/baselib/datastore.py#L256-L268 | def get_attrs(self, key):
"""
:param key: dataset path
:returns: dictionary of attributes for that path
"""
try:
dset = h5py.File.__getitem__(self.hdf5, key)
except KeyError:
if self.parent != ():
dset = h5py.File.__getitem__(self.p... | [
"def",
"get_attrs",
"(",
"self",
",",
"key",
")",
":",
"try",
":",
"dset",
"=",
"h5py",
".",
"File",
".",
"__getitem__",
"(",
"self",
".",
"hdf5",
",",
"key",
")",
"except",
"KeyError",
":",
"if",
"self",
".",
"parent",
"!=",
"(",
")",
":",
"dset... | :param key: dataset path
:returns: dictionary of attributes for that path | [
":",
"param",
"key",
":",
"dataset",
"path",
":",
"returns",
":",
"dictionary",
"of",
"attributes",
"for",
"that",
"path"
] | python | train |
cltk/cltk | cltk/stem/latin/declension.py | https://github.com/cltk/cltk/blob/ed9c025b7ec43c949481173251b70e05e4dffd27/cltk/stem/latin/declension.py#L113-L189 | def decline(self, lemma, flatten=False, collatinus_dict=False):
""" Decline a lemma
.. warning:: POS are incomplete as we do not detect the type outside of verbs, participle and adjective.
:raise UnknownLemma: When the lemma is unknown to our data
:param lemma: Lemma (Canonical form) ... | [
"def",
"decline",
"(",
"self",
",",
"lemma",
",",
"flatten",
"=",
"False",
",",
"collatinus_dict",
"=",
"False",
")",
":",
"if",
"lemma",
"not",
"in",
"self",
".",
"__lemmas__",
":",
"raise",
"UnknownLemma",
"(",
"\"%s is unknown\"",
"%",
"lemma",
")",
"... | Decline a lemma
.. warning:: POS are incomplete as we do not detect the type outside of verbs, participle and adjective.
:raise UnknownLemma: When the lemma is unknown to our data
:param lemma: Lemma (Canonical form) to decline
:type lemma: str
:param flatten: If set to True, ... | [
"Decline",
"a",
"lemma"
] | python | train |
Dallinger/Dallinger | dallinger/deployment.py | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/deployment.py#L548-L568 | def check_status(self):
"""Check the output of the summary route until
the experiment is complete, then we can stop monitoring Heroku
subprocess output.
"""
self.out.log("Recruitment is complete. Waiting for experiment completion...")
base_url = get_base_url()
sta... | [
"def",
"check_status",
"(",
"self",
")",
":",
"self",
".",
"out",
".",
"log",
"(",
"\"Recruitment is complete. Waiting for experiment completion...\"",
")",
"base_url",
"=",
"get_base_url",
"(",
")",
"status_url",
"=",
"base_url",
"+",
"\"/summary\"",
"while",
"not"... | Check the output of the summary route until
the experiment is complete, then we can stop monitoring Heroku
subprocess output. | [
"Check",
"the",
"output",
"of",
"the",
"summary",
"route",
"until",
"the",
"experiment",
"is",
"complete",
"then",
"we",
"can",
"stop",
"monitoring",
"Heroku",
"subprocess",
"output",
"."
] | python | train |
sammchardy/python-binance | binance/client.py | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L1286-L1310 | def order_market_buy(self, **params):
"""Send in a new market buy order
:param symbol: required
:type symbol: str
:param quantity: required
:type quantity: decimal
:param newClientOrderId: A unique id for the order. Automatically generated if not sent.
:type newC... | [
"def",
"order_market_buy",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"params",
".",
"update",
"(",
"{",
"'side'",
":",
"self",
".",
"SIDE_BUY",
"}",
")",
"return",
"self",
".",
"order_market",
"(",
"*",
"*",
"params",
")"
] | Send in a new market buy order
:param symbol: required
:type symbol: str
:param quantity: required
:type quantity: decimal
:param newClientOrderId: A unique id for the order. Automatically generated if not sent.
:type newClientOrderId: str
:param newOrderRespType... | [
"Send",
"in",
"a",
"new",
"market",
"buy",
"order"
] | python | train |
eqcorrscan/EQcorrscan | eqcorrscan/core/match_filter.py | https://github.com/eqcorrscan/EQcorrscan/blob/3121b4aca801ee5d38f56ca297ce1c0f9515d9ff/eqcorrscan/core/match_filter.py#L3808-L3825 | def read_party(fname=None, read_detection_catalog=True):
"""
Read detections and metadata from a tar archive.
:type fname: str
:param fname:
Filename to read from, if this contains a single Family, then will
return a party of length = 1
:type read_detection_catalog: bool
:param ... | [
"def",
"read_party",
"(",
"fname",
"=",
"None",
",",
"read_detection_catalog",
"=",
"True",
")",
":",
"party",
"=",
"Party",
"(",
")",
"party",
".",
"read",
"(",
"filename",
"=",
"fname",
",",
"read_detection_catalog",
"=",
"read_detection_catalog",
")",
"re... | Read detections and metadata from a tar archive.
:type fname: str
:param fname:
Filename to read from, if this contains a single Family, then will
return a party of length = 1
:type read_detection_catalog: bool
:param read_detection_catalog:
Whether to read the detection catalog... | [
"Read",
"detections",
"and",
"metadata",
"from",
"a",
"tar",
"archive",
"."
] | python | train |
aleju/imgaug | imgaug/augmentables/lines.py | https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/lines.py#L1286-L1324 | def to_segmentation_map(self, image_shape, size_lines=1, size_points=0,
raise_if_out_of_image=False):
"""
Generate a segmentation map object from the line string.
This is similar to
:func:`imgaug.augmentables.lines.LineString.draw_mask`.
The result is... | [
"def",
"to_segmentation_map",
"(",
"self",
",",
"image_shape",
",",
"size_lines",
"=",
"1",
",",
"size_points",
"=",
"0",
",",
"raise_if_out_of_image",
"=",
"False",
")",
":",
"from",
".",
"segmaps",
"import",
"SegmentationMapOnImage",
"return",
"SegmentationMapOn... | Generate a segmentation map object from the line string.
This is similar to
:func:`imgaug.augmentables.lines.LineString.draw_mask`.
The result is wrapped in a ``SegmentationMapOnImage`` object
instead of just an array.
Parameters
----------
image_shape : tuple o... | [
"Generate",
"a",
"segmentation",
"map",
"object",
"from",
"the",
"line",
"string",
"."
] | python | valid |
dead-beef/markovchain | markovchain/cli/image.py | https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/cli/image.py#L286-L325 | def cmd_generate(args):
"""Generate images.
Parameters
----------
args : `argparse.Namespace`
Command arguments.
"""
check_output_format(args.output, args.count)
markov = load(MarkovImage, args.state, args)
if args.size is None:
if markov.scanner.resize is None:
... | [
"def",
"cmd_generate",
"(",
"args",
")",
":",
"check_output_format",
"(",
"args",
".",
"output",
",",
"args",
".",
"count",
")",
"markov",
"=",
"load",
"(",
"MarkovImage",
",",
"args",
".",
"state",
",",
"args",
")",
"if",
"args",
".",
"size",
"is",
... | Generate images.
Parameters
----------
args : `argparse.Namespace`
Command arguments. | [
"Generate",
"images",
"."
] | python | train |
mardix/Mocha | mocha/contrib/auth/__init__.py | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/contrib/auth/__init__.py#L636-L645 | def add_federation(self, provider, federated_id):
"""
Add federated login to the current user
:param provider:
:param federated_id:
:return:
"""
models.AuthUserFederation.new(user=self,
provider=provider,
... | [
"def",
"add_federation",
"(",
"self",
",",
"provider",
",",
"federated_id",
")",
":",
"models",
".",
"AuthUserFederation",
".",
"new",
"(",
"user",
"=",
"self",
",",
"provider",
"=",
"provider",
",",
"federated_id",
"=",
"federated_id",
")"
] | Add federated login to the current user
:param provider:
:param federated_id:
:return: | [
"Add",
"federated",
"login",
"to",
"the",
"current",
"user",
":",
"param",
"provider",
":",
":",
"param",
"federated_id",
":",
":",
"return",
":"
] | python | train |
Zsailer/pandas_flavor | pandas_flavor/register.py | https://github.com/Zsailer/pandas_flavor/blob/1953aeee09424300d69a11dd2ffd3460a806fb65/pandas_flavor/register.py#L6-L35 | def register_dataframe_method(method):
"""Register a function as a method attached to the Pandas DataFrame.
Example
-------
.. code-block:: python
@register_dataframe_method
def print_column(df, col):
'''Print the dataframe column given'''
print(df[col])
""... | [
"def",
"register_dataframe_method",
"(",
"method",
")",
":",
"def",
"inner",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"class",
"AccessorMethod",
"(",
"object",
")",
":",
"def",
"__init__",
"(",
"self",
",",
"pandas_obj",
")",
":",
"self",
"... | Register a function as a method attached to the Pandas DataFrame.
Example
-------
.. code-block:: python
@register_dataframe_method
def print_column(df, col):
'''Print the dataframe column given'''
print(df[col]) | [
"Register",
"a",
"function",
"as",
"a",
"method",
"attached",
"to",
"the",
"Pandas",
"DataFrame",
"."
] | python | train |
onecodex/onecodex | onecodex/utils.py | https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/utils.py#L100-L109 | def valid_api_key(ctx, param, value):
"""
Ensures an API has valid length (this is a click callback)
"""
if value is not None and len(value) != 32:
raise click.BadParameter(
"API Key must be 32 characters long, not {}".format(str(len(value)))
)
else:
return value | [
"def",
"valid_api_key",
"(",
"ctx",
",",
"param",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
"and",
"len",
"(",
"value",
")",
"!=",
"32",
":",
"raise",
"click",
".",
"BadParameter",
"(",
"\"API Key must be 32 characters long, not {}\"",
".",... | Ensures an API has valid length (this is a click callback) | [
"Ensures",
"an",
"API",
"has",
"valid",
"length",
"(",
"this",
"is",
"a",
"click",
"callback",
")"
] | python | train |
TrafficSenseMSD/SumoTools | sumolib/miscutils.py | https://github.com/TrafficSenseMSD/SumoTools/blob/8607b4f885f1d1798e43240be643efe6dccccdaa/sumolib/miscutils.py#L124-L130 | def avg(self):
"""return the mean value"""
# XXX rename this method
if len(self.values) > 0:
return sum(self.values) / float(len(self.values))
else:
return None | [
"def",
"avg",
"(",
"self",
")",
":",
"# XXX rename this method",
"if",
"len",
"(",
"self",
".",
"values",
")",
">",
"0",
":",
"return",
"sum",
"(",
"self",
".",
"values",
")",
"/",
"float",
"(",
"len",
"(",
"self",
".",
"values",
")",
")",
"else",
... | return the mean value | [
"return",
"the",
"mean",
"value"
] | python | train |
Robpol86/libnl | libnl/nl80211/iw_scan.py | https://github.com/Robpol86/libnl/blob/274e9fdaa39822d06ef70b799ed4a95937a4d923/libnl/nl80211/iw_scan.py#L306-L328 | def get_11u_advert(_, data):
"""http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n676.
Positional arguments:
data -- bytearray data to read.
Returns:
Dict.
"""
answers = dict()
idx = 0
while idx < len(data) - 1:
qri = data[idx]
proto_id ... | [
"def",
"get_11u_advert",
"(",
"_",
",",
"data",
")",
":",
"answers",
"=",
"dict",
"(",
")",
"idx",
"=",
"0",
"while",
"idx",
"<",
"len",
"(",
"data",
")",
"-",
"1",
":",
"qri",
"=",
"data",
"[",
"idx",
"]",
"proto_id",
"=",
"data",
"[",
"idx",
... | http://git.kernel.org/cgit/linux/kernel/git/jberg/iw.git/tree/scan.c?id=v3.17#n676.
Positional arguments:
data -- bytearray data to read.
Returns:
Dict. | [
"http",
":",
"//",
"git",
".",
"kernel",
".",
"org",
"/",
"cgit",
"/",
"linux",
"/",
"kernel",
"/",
"git",
"/",
"jberg",
"/",
"iw",
".",
"git",
"/",
"tree",
"/",
"scan",
".",
"c?id",
"=",
"v3",
".",
"17#n676",
"."
] | python | train |
StackStorm/pybind | pybind/nos/v6_0_2f/rbridge_id/router/ospf/timers/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/rbridge_id/router/ospf/timers/__init__.py#L126-L147 | def _set_throttle(self, v, load=False):
"""
Setter method for throttle, mapped from YANG variable /rbridge_id/router/ospf/timers/throttle (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_throttle is considered as a private
method. Backends looking to popul... | [
"def",
"_set_throttle",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"base"... | Setter method for throttle, mapped from YANG variable /rbridge_id/router/ospf/timers/throttle (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_throttle is considered as a private
method. Backends looking to populate this variable should
do so via calling thisO... | [
"Setter",
"method",
"for",
"throttle",
"mapped",
"from",
"YANG",
"variable",
"/",
"rbridge_id",
"/",
"router",
"/",
"ospf",
"/",
"timers",
"/",
"throttle",
"(",
"container",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"f... | python | train |
toumorokoshi/sprinter | sprinter/formula/base.py | https://github.com/toumorokoshi/sprinter/blob/846697a7a087e69c61d075232e754d6975a64152/sprinter/formula/base.py#L192-L212 | def _prompt_value(self, key, prompt_string, default=None, only_if_empty=True):
"""prompts the user for a value, and saves it to either the target or
source manifest (whichever is appropriate for the phase)
this method takes will default to the original value passed by
the user in the ca... | [
"def",
"_prompt_value",
"(",
"self",
",",
"key",
",",
"prompt_string",
",",
"default",
"=",
"None",
",",
"only_if_empty",
"=",
"True",
")",
":",
"main_manifest",
"=",
"self",
".",
"target",
"or",
"self",
".",
"source",
"if",
"only_if_empty",
"and",
"main_m... | prompts the user for a value, and saves it to either the target or
source manifest (whichever is appropriate for the phase)
this method takes will default to the original value passed by
the user in the case one exists. e.g. if a user already
answered 'yes' to a question, it will use 'y... | [
"prompts",
"the",
"user",
"for",
"a",
"value",
"and",
"saves",
"it",
"to",
"either",
"the",
"target",
"or",
"source",
"manifest",
"(",
"whichever",
"is",
"appropriate",
"for",
"the",
"phase",
")"
] | python | train |
samghelms/mathviz | mathviz_hopper/src/bottle.py | https://github.com/samghelms/mathviz/blob/30fe89537379faea4de8c8b568ac6e52e4d15353/mathviz_hopper/src/bottle.py#L581-L597 | def get_undecorated_callback(self):
""" Return the callback. If the callback is a decorated function, try to
recover the original function. """
func = self.callback
func = getattr(func, '__func__' if py3k else 'im_func', func)
closure_attr = '__closure__' if py3k else 'func_c... | [
"def",
"get_undecorated_callback",
"(",
"self",
")",
":",
"func",
"=",
"self",
".",
"callback",
"func",
"=",
"getattr",
"(",
"func",
",",
"'__func__'",
"if",
"py3k",
"else",
"'im_func'",
",",
"func",
")",
"closure_attr",
"=",
"'__closure__'",
"if",
"py3k",
... | Return the callback. If the callback is a decorated function, try to
recover the original function. | [
"Return",
"the",
"callback",
".",
"If",
"the",
"callback",
"is",
"a",
"decorated",
"function",
"try",
"to",
"recover",
"the",
"original",
"function",
"."
] | python | train |
orb-framework/orb | orb/core/column_types/string.py | https://github.com/orb-framework/orb/blob/575be2689cb269e65a0a2678232ff940acc19e5a/orb/core/column_types/string.py#L250-L263 | def clean(self, py_value):
"""
Cleans the value before storing it.
:param: py_value : <str>
:return: <str>
"""
try:
import bleach
return bleach.clean(py_value, **self.__bleachOptions)
except ImportError:
warnings.warn('... | [
"def",
"clean",
"(",
"self",
",",
"py_value",
")",
":",
"try",
":",
"import",
"bleach",
"return",
"bleach",
".",
"clean",
"(",
"py_value",
",",
"*",
"*",
"self",
".",
"__bleachOptions",
")",
"except",
"ImportError",
":",
"warnings",
".",
"warn",
"(",
"... | Cleans the value before storing it.
:param: py_value : <str>
:return: <str> | [
"Cleans",
"the",
"value",
"before",
"storing",
"it",
"."
] | python | train |
cloudtools/troposphere | troposphere/template_generator.py | https://github.com/cloudtools/troposphere/blob/f7ea5591a7c287a843adc9c184d2f56064cfc632/troposphere/template_generator.py#L301-L332 | def _normalize_properties(self, definition):
"""
Inspects the definition and returns a copy of it that is updated
with any special property such as Condition, UpdatePolicy and the
like.
"""
args = definition.get('Properties', {}).copy()
if 'Condition' in definitio... | [
"def",
"_normalize_properties",
"(",
"self",
",",
"definition",
")",
":",
"args",
"=",
"definition",
".",
"get",
"(",
"'Properties'",
",",
"{",
"}",
")",
".",
"copy",
"(",
")",
"if",
"'Condition'",
"in",
"definition",
":",
"args",
".",
"update",
"(",
"... | Inspects the definition and returns a copy of it that is updated
with any special property such as Condition, UpdatePolicy and the
like. | [
"Inspects",
"the",
"definition",
"and",
"returns",
"a",
"copy",
"of",
"it",
"that",
"is",
"updated",
"with",
"any",
"special",
"property",
"such",
"as",
"Condition",
"UpdatePolicy",
"and",
"the",
"like",
"."
] | python | train |
tensorflow/tensorboard | tensorboard/plugins/interactive_inference/interactive_inference_plugin.py | https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/plugins/interactive_inference/interactive_inference_plugin.py#L84-L100 | def get_plugin_apps(self):
"""Obtains a mapping between routes and handlers. Stores the logdir.
Returns:
A mapping between routes and handlers (functions that respond to
requests).
"""
return {
'/infer': self._infer,
'/update_example': self._update_example,
'/example... | [
"def",
"get_plugin_apps",
"(",
"self",
")",
":",
"return",
"{",
"'/infer'",
":",
"self",
".",
"_infer",
",",
"'/update_example'",
":",
"self",
".",
"_update_example",
",",
"'/examples_from_path'",
":",
"self",
".",
"_examples_from_path_handler",
",",
"'/sprite'",
... | Obtains a mapping between routes and handlers. Stores the logdir.
Returns:
A mapping between routes and handlers (functions that respond to
requests). | [
"Obtains",
"a",
"mapping",
"between",
"routes",
"and",
"handlers",
".",
"Stores",
"the",
"logdir",
"."
] | python | train |
wandb/client | wandb/vendor/prompt_toolkit/key_binding/bindings/named_commands.py | https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/vendor/prompt_toolkit/key_binding/bindings/named_commands.py#L186-L190 | def delete_char(event):
" Delete character before the cursor. "
deleted = event.current_buffer.delete(count=event.arg)
if not deleted:
event.cli.output.bell() | [
"def",
"delete_char",
"(",
"event",
")",
":",
"deleted",
"=",
"event",
".",
"current_buffer",
".",
"delete",
"(",
"count",
"=",
"event",
".",
"arg",
")",
"if",
"not",
"deleted",
":",
"event",
".",
"cli",
".",
"output",
".",
"bell",
"(",
")"
] | Delete character before the cursor. | [
"Delete",
"character",
"before",
"the",
"cursor",
"."
] | python | train |
skorch-dev/skorch | skorch/classifier.py | https://github.com/skorch-dev/skorch/blob/5b9b8b7b7712cb6e5aaa759d9608ea6269d5bcd3/skorch/classifier.py#L158-L193 | def predict(self, X):
"""Where applicable, return class labels for samples in X.
If the module's forward method returns multiple outputs as a
tuple, it is assumed that the first output contains the
relevant information and the other values are ignored. If all
values are relevant... | [
"def",
"predict",
"(",
"self",
",",
"X",
")",
":",
"y_preds",
"=",
"[",
"]",
"for",
"yp",
"in",
"self",
".",
"forward_iter",
"(",
"X",
",",
"training",
"=",
"False",
")",
":",
"yp",
"=",
"yp",
"[",
"0",
"]",
"if",
"isinstance",
"(",
"yp",
",",
... | Where applicable, return class labels for samples in X.
If the module's forward method returns multiple outputs as a
tuple, it is assumed that the first output contains the
relevant information and the other values are ignored. If all
values are relevant, consider using
:func:`~... | [
"Where",
"applicable",
"return",
"class",
"labels",
"for",
"samples",
"in",
"X",
"."
] | python | train |
locationlabs/mockredis | mockredis/client.py | https://github.com/locationlabs/mockredis/blob/fd4e3117066ff0c24e86ebca007853a8092e3254/mockredis/client.py#L394-L400 | def psetex(self, key, time, value):
"""
Set the value of ``key`` to ``value`` that expires in ``time``
milliseconds. ``time`` can be represented by an integer or a Python
timedelta object.
"""
return self.set(key, value, px=time) | [
"def",
"psetex",
"(",
"self",
",",
"key",
",",
"time",
",",
"value",
")",
":",
"return",
"self",
".",
"set",
"(",
"key",
",",
"value",
",",
"px",
"=",
"time",
")"
] | Set the value of ``key`` to ``value`` that expires in ``time``
milliseconds. ``time`` can be represented by an integer or a Python
timedelta object. | [
"Set",
"the",
"value",
"of",
"key",
"to",
"value",
"that",
"expires",
"in",
"time",
"milliseconds",
".",
"time",
"can",
"be",
"represented",
"by",
"an",
"integer",
"or",
"a",
"Python",
"timedelta",
"object",
"."
] | python | train |
DataBiosphere/toil | src/toil/wdl/wdl_synthesis.py | https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/src/toil/wdl/wdl_synthesis.py#L424-L443 | def write_scatterfunction(self, job, scattername):
'''
Writes out a python function for each WDL "scatter" object.
'''
scatter_outputs = self.fetch_scatter_outputs(job)
# write the function header
fn_section = self.write_scatterfunction_header(scattername)
# wr... | [
"def",
"write_scatterfunction",
"(",
"self",
",",
"job",
",",
"scattername",
")",
":",
"scatter_outputs",
"=",
"self",
".",
"fetch_scatter_outputs",
"(",
"job",
")",
"# write the function header",
"fn_section",
"=",
"self",
".",
"write_scatterfunction_header",
"(",
... | Writes out a python function for each WDL "scatter" object. | [
"Writes",
"out",
"a",
"python",
"function",
"for",
"each",
"WDL",
"scatter",
"object",
"."
] | python | train |
apple/turicreate | src/unity/python/turicreate/toolkits/nearest_neighbors/_nearest_neighbors.py | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/nearest_neighbors/_nearest_neighbors.py#L777-L935 | def query(self, dataset, label=None, k=5, radius=None, verbose=True):
"""
For each row of the input 'dataset', retrieve the nearest neighbors
from the model's stored data. In general, the query dataset does not
need to be the same as the reference data stored in the model, but if
... | [
"def",
"query",
"(",
"self",
",",
"dataset",
",",
"label",
"=",
"None",
",",
"k",
"=",
"5",
",",
"radius",
"=",
"None",
",",
"verbose",
"=",
"True",
")",
":",
"## Validate the 'dataset' input",
"_tkutl",
".",
"_raise_error_if_not_sframe",
"(",
"dataset",
"... | For each row of the input 'dataset', retrieve the nearest neighbors
from the model's stored data. In general, the query dataset does not
need to be the same as the reference data stored in the model, but if
it is, the 'include_self_edges' parameter can be set to False to
exclude results ... | [
"For",
"each",
"row",
"of",
"the",
"input",
"dataset",
"retrieve",
"the",
"nearest",
"neighbors",
"from",
"the",
"model",
"s",
"stored",
"data",
".",
"In",
"general",
"the",
"query",
"dataset",
"does",
"not",
"need",
"to",
"be",
"the",
"same",
"as",
"the... | python | train |
palantir/python-jsonrpc-server | pyls_jsonrpc/endpoint.py | https://github.com/palantir/python-jsonrpc-server/blob/7021d849901705ab53c141e483a71d0779aff3d2/pyls_jsonrpc/endpoint.py#L153-L161 | def _notification_callback(method, params):
"""Construct a notification callback for the given request ID."""
def callback(future):
try:
future.result()
log.debug("Successfully handled async notification %s %s", method, params)
except Exception: #... | [
"def",
"_notification_callback",
"(",
"method",
",",
"params",
")",
":",
"def",
"callback",
"(",
"future",
")",
":",
"try",
":",
"future",
".",
"result",
"(",
")",
"log",
".",
"debug",
"(",
"\"Successfully handled async notification %s %s\"",
",",
"method",
",... | Construct a notification callback for the given request ID. | [
"Construct",
"a",
"notification",
"callback",
"for",
"the",
"given",
"request",
"ID",
"."
] | python | train |
pandas-dev/pandas | pandas/io/sas/sas_xport.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/io/sas/sas_xport.py#L170-L224 | def _parse_float_vec(vec):
"""
Parse a vector of float values representing IBM 8 byte floats into
native 8 byte floats.
"""
dtype = np.dtype('>u4,>u4')
vec1 = vec.view(dtype=dtype)
xport1 = vec1['f0']
xport2 = vec1['f1']
# Start by setting first half of ieee number to first half of... | [
"def",
"_parse_float_vec",
"(",
"vec",
")",
":",
"dtype",
"=",
"np",
".",
"dtype",
"(",
"'>u4,>u4'",
")",
"vec1",
"=",
"vec",
".",
"view",
"(",
"dtype",
"=",
"dtype",
")",
"xport1",
"=",
"vec1",
"[",
"'f0'",
"]",
"xport2",
"=",
"vec1",
"[",
"'f1'",... | Parse a vector of float values representing IBM 8 byte floats into
native 8 byte floats. | [
"Parse",
"a",
"vector",
"of",
"float",
"values",
"representing",
"IBM",
"8",
"byte",
"floats",
"into",
"native",
"8",
"byte",
"floats",
"."
] | python | train |
titusjan/argos | argos/inspector/dialog.py | https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/inspector/dialog.py#L85-L89 | def setCurrentInspectorRegItem(self, regItem):
""" Sets the current inspector given an InspectorRegItem
"""
check_class(regItem, InspectorRegItem, allow_none=True)
self.inspectorTab.setCurrentRegItem(regItem) | [
"def",
"setCurrentInspectorRegItem",
"(",
"self",
",",
"regItem",
")",
":",
"check_class",
"(",
"regItem",
",",
"InspectorRegItem",
",",
"allow_none",
"=",
"True",
")",
"self",
".",
"inspectorTab",
".",
"setCurrentRegItem",
"(",
"regItem",
")"
] | Sets the current inspector given an InspectorRegItem | [
"Sets",
"the",
"current",
"inspector",
"given",
"an",
"InspectorRegItem"
] | python | train |
kennethreitz/legit | legit/cli.py | https://github.com/kennethreitz/legit/blob/699802c5be665bd358456a940953b5c1d8672754/legit/cli.py#L135-L173 | def sync(ctx, scm, to_branch, verbose, fake):
"""Stashes unstaged changes, Fetches remote data, Performs smart
pull+merge, Pushes local commits up, and Unstashes changes.
Defaults to current branch.
"""
scm.fake = fake
scm.verbose = fake or verbose
scm.repo_check(require_remote=True)
... | [
"def",
"sync",
"(",
"ctx",
",",
"scm",
",",
"to_branch",
",",
"verbose",
",",
"fake",
")",
":",
"scm",
".",
"fake",
"=",
"fake",
"scm",
".",
"verbose",
"=",
"fake",
"or",
"verbose",
"scm",
".",
"repo_check",
"(",
"require_remote",
"=",
"True",
")",
... | Stashes unstaged changes, Fetches remote data, Performs smart
pull+merge, Pushes local commits up, and Unstashes changes.
Defaults to current branch. | [
"Stashes",
"unstaged",
"changes",
"Fetches",
"remote",
"data",
"Performs",
"smart",
"pull",
"+",
"merge",
"Pushes",
"local",
"commits",
"up",
"and",
"Unstashes",
"changes",
"."
] | python | train |
Opentrons/opentrons | api/src/opentrons/protocol_api/labware.py | https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/protocol_api/labware.py#L114-L122 | def center(self) -> Location:
"""
:return: a Point corresponding to the absolute position of the center
of the well relative to the deck (with the front-left corner of slot 1
as (0,0,0))
"""
top = self.top()
center_z = top.point.z - (self._depth / 2.0)
ret... | [
"def",
"center",
"(",
"self",
")",
"->",
"Location",
":",
"top",
"=",
"self",
".",
"top",
"(",
")",
"center_z",
"=",
"top",
".",
"point",
".",
"z",
"-",
"(",
"self",
".",
"_depth",
"/",
"2.0",
")",
"return",
"Location",
"(",
"Point",
"(",
"x",
... | :return: a Point corresponding to the absolute position of the center
of the well relative to the deck (with the front-left corner of slot 1
as (0,0,0)) | [
":",
"return",
":",
"a",
"Point",
"corresponding",
"to",
"the",
"absolute",
"position",
"of",
"the",
"center",
"of",
"the",
"well",
"relative",
"to",
"the",
"deck",
"(",
"with",
"the",
"front",
"-",
"left",
"corner",
"of",
"slot",
"1",
"as",
"(",
"0",
... | python | train |
petl-developers/petl | petl/transform/setops.py | https://github.com/petl-developers/petl/blob/1d33ca055f7e04e0d28a772041c9fd30c8d415d6/petl/transform/setops.py#L227-L287 | def diff(a, b, presorted=False, buffersize=None, tempdir=None, cache=True,
strict=False):
"""
Find the difference between rows in two tables. Returns a pair of tables.
E.g.::
>>> import petl as etl
>>> a = [['foo', 'bar', 'baz'],
... ['A', 1, True],
... ['... | [
"def",
"diff",
"(",
"a",
",",
"b",
",",
"presorted",
"=",
"False",
",",
"buffersize",
"=",
"None",
",",
"tempdir",
"=",
"None",
",",
"cache",
"=",
"True",
",",
"strict",
"=",
"False",
")",
":",
"if",
"not",
"presorted",
":",
"a",
"=",
"sort",
"("... | Find the difference between rows in two tables. Returns a pair of tables.
E.g.::
>>> import petl as etl
>>> a = [['foo', 'bar', 'baz'],
... ['A', 1, True],
... ['C', 7, False],
... ['B', 2, False],
... ['C', 9, True]]
>>> b = [['x', 'y', '... | [
"Find",
"the",
"difference",
"between",
"rows",
"in",
"two",
"tables",
".",
"Returns",
"a",
"pair",
"of",
"tables",
".",
"E",
".",
"g",
".",
"::"
] | python | train |
qiniu/python-sdk | qiniu/auth.py | https://github.com/qiniu/python-sdk/blob/a69fbef4e3e6ea1ebe09f4610a5b18bb2c17de59/qiniu/auth.py#L166-L185 | def verify_callback(
self,
origin_authorization,
url,
body,
content_type='application/x-www-form-urlencoded'):
"""回调验证
Args:
origin_authorization: 回调时请求Header中的Authorization字段
url: 回调请求的url
... | [
"def",
"verify_callback",
"(",
"self",
",",
"origin_authorization",
",",
"url",
",",
"body",
",",
"content_type",
"=",
"'application/x-www-form-urlencoded'",
")",
":",
"token",
"=",
"self",
".",
"token_of_request",
"(",
"url",
",",
"body",
",",
"content_type",
"... | 回调验证
Args:
origin_authorization: 回调时请求Header中的Authorization字段
url: 回调请求的url
body: 回调请求的body
content_type: 回调请求body的Content-Type
Returns:
返回true表示验证成功,返回false表示验证失败 | [
"回调验证"
] | python | train |
adamrehn/ue4cli | ue4cli/ThirdPartyLibraryDetails.py | https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/ThirdPartyLibraryDetails.py#L83-L92 | def getLinkerFlags(self, engineRoot, fmt, includeLibs=True):
"""
Constructs the linker flags string for building against this library
"""
components = self.resolveRoot(self.ldFlags, engineRoot)
if includeLibs == True:
components.extend(self.prefixedStrings(self.linkerDirPrefix, self.linkDirs, engineRoot))
... | [
"def",
"getLinkerFlags",
"(",
"self",
",",
"engineRoot",
",",
"fmt",
",",
"includeLibs",
"=",
"True",
")",
":",
"components",
"=",
"self",
".",
"resolveRoot",
"(",
"self",
".",
"ldFlags",
",",
"engineRoot",
")",
"if",
"includeLibs",
"==",
"True",
":",
"c... | Constructs the linker flags string for building against this library | [
"Constructs",
"the",
"linker",
"flags",
"string",
"for",
"building",
"against",
"this",
"library"
] | python | train |
PyCQA/astroid | astroid/node_classes.py | https://github.com/PyCQA/astroid/blob/e0a298df55b15abcb77c2a93253f5ab7be52d0fb/astroid/node_classes.py#L4116-L4134 | def block_range(self, lineno):
"""Get a range from the given line number to where this node ends.
:param lineno: The line number to start the range at.
:type lineno: int
:returns: The range of line numbers that this node belongs to,
starting at the given line number.
... | [
"def",
"block_range",
"(",
"self",
",",
"lineno",
")",
":",
"last",
"=",
"None",
"for",
"exhandler",
"in",
"self",
".",
"handlers",
":",
"if",
"exhandler",
".",
"type",
"and",
"lineno",
"==",
"exhandler",
".",
"type",
".",
"fromlineno",
":",
"return",
... | Get a range from the given line number to where this node ends.
:param lineno: The line number to start the range at.
:type lineno: int
:returns: The range of line numbers that this node belongs to,
starting at the given line number.
:rtype: tuple(int, int) | [
"Get",
"a",
"range",
"from",
"the",
"given",
"line",
"number",
"to",
"where",
"this",
"node",
"ends",
"."
] | python | train |
asweigart/pysimplevalidate | src/pysimplevalidate/__init__.py | https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L1373-L1411 | def validateDayOfMonth(value, year, month, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None):
"""Raises ValidationException if value is not a day of the month, from
1 to 28, 29, 30, or 31 depending on the month and year.
Returns value.
* value (str): The value being va... | [
"def",
"validateDayOfMonth",
"(",
"value",
",",
"year",
",",
"month",
",",
"blank",
"=",
"False",
",",
"strip",
"=",
"None",
",",
"allowlistRegexes",
"=",
"None",
",",
"blocklistRegexes",
"=",
"None",
",",
"excMsg",
"=",
"None",
")",
":",
"try",
":",
"... | Raises ValidationException if value is not a day of the month, from
1 to 28, 29, 30, or 31 depending on the month and year.
Returns value.
* value (str): The value being validated as existing as a numbered day in the given year and month.
* year (int): The given year.
* month (int): The given month... | [
"Raises",
"ValidationException",
"if",
"value",
"is",
"not",
"a",
"day",
"of",
"the",
"month",
"from",
"1",
"to",
"28",
"29",
"30",
"or",
"31",
"depending",
"on",
"the",
"month",
"and",
"year",
".",
"Returns",
"value",
"."
] | python | train |
jobovy/galpy | galpy/potential/TwoPowerSphericalPotential.py | https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/potential/TwoPowerSphericalPotential.py#L283-L308 | 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.",
")",
":",
"if",
"not",
"self",
".",
"HernquistSelf",
"==",
"None",
":",
"return",
"self",
".",
"HernquistSelf",
".",
"_evaluate",
"(",
"R",
",",
"z",... | 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 |
DiscordBotList/DBL-Python-Library | dbl/http.py | https://github.com/DiscordBotList/DBL-Python-Library/blob/c1461ae0acc644cdeedef8fd6b5e36f76d81c1aa/dbl/http.py#L190-L194 | async def get_bots(self, limit, offset):
'''Gets an object of bots on DBL'''
if limit > 500:
limit = 50
return await self.request('GET', '{}/bots?limit={}&offset={}'.format(self.BASE, limit, offset)) | [
"async",
"def",
"get_bots",
"(",
"self",
",",
"limit",
",",
"offset",
")",
":",
"if",
"limit",
">",
"500",
":",
"limit",
"=",
"50",
"return",
"await",
"self",
".",
"request",
"(",
"'GET'",
",",
"'{}/bots?limit={}&offset={}'",
".",
"format",
"(",
"self",
... | Gets an object of bots on DBL | [
"Gets",
"an",
"object",
"of",
"bots",
"on",
"DBL"
] | python | test |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/scene/cameras/arcball.py | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/scene/cameras/arcball.py#L71-L77 | def _dist_to_trans(self, dist):
"""Convert mouse x, y movement into x, y, z translations"""
rot, x, y, z = self._quaternion.get_axis_angle()
tr = MatrixTransform()
tr.rotate(180 * rot / np.pi, (x, y, z))
dx, dz, dy = np.dot(tr.matrix[:3, :3], (dist[0], dist[1], 0.))
retur... | [
"def",
"_dist_to_trans",
"(",
"self",
",",
"dist",
")",
":",
"rot",
",",
"x",
",",
"y",
",",
"z",
"=",
"self",
".",
"_quaternion",
".",
"get_axis_angle",
"(",
")",
"tr",
"=",
"MatrixTransform",
"(",
")",
"tr",
".",
"rotate",
"(",
"180",
"*",
"rot",... | Convert mouse x, y movement into x, y, z translations | [
"Convert",
"mouse",
"x",
"y",
"movement",
"into",
"x",
"y",
"z",
"translations"
] | python | train |
CodeReclaimers/neat-python | neat/population.py | https://github.com/CodeReclaimers/neat-python/blob/e3dbe77c0d776eae41d598e6439e6ac02ab90b18/neat/population.py#L59-L136 | def run(self, fitness_function, n=None):
"""
Runs NEAT's genetic algorithm for at most n generations. If n
is None, run until solution is found or extinction occurs.
The user-provided fitness_function must take only two arguments:
1. The population as a list of (genome id, ... | [
"def",
"run",
"(",
"self",
",",
"fitness_function",
",",
"n",
"=",
"None",
")",
":",
"if",
"self",
".",
"config",
".",
"no_fitness_termination",
"and",
"(",
"n",
"is",
"None",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Cannot have no generational limit with no... | Runs NEAT's genetic algorithm for at most n generations. If n
is None, run until solution is found or extinction occurs.
The user-provided fitness_function must take only two arguments:
1. The population as a list of (genome id, genome) tuples.
2. The current configuration obje... | [
"Runs",
"NEAT",
"s",
"genetic",
"algorithm",
"for",
"at",
"most",
"n",
"generations",
".",
"If",
"n",
"is",
"None",
"run",
"until",
"solution",
"is",
"found",
"or",
"extinction",
"occurs",
"."
] | python | train |
GoogleCloudPlatform/cloud-debug-python | src/googleclouddebugger/capture_collector.py | https://github.com/GoogleCloudPlatform/cloud-debug-python/blob/89ce3782c98b814838a3ecb5479ed3882368cbee/src/googleclouddebugger/capture_collector.py#L593-L609 | def _CaptureExpression(self, frame, expression):
"""Evalutes the expression and captures it into a Variable object.
Args:
frame: evaluation context.
expression: watched expression to compile and evaluate.
Returns:
Variable object (which will have error status if the expression fails
... | [
"def",
"_CaptureExpression",
"(",
"self",
",",
"frame",
",",
"expression",
")",
":",
"rc",
",",
"value",
"=",
"_EvaluateExpression",
"(",
"frame",
",",
"expression",
")",
"if",
"not",
"rc",
":",
"return",
"{",
"'name'",
":",
"expression",
",",
"'status'",
... | Evalutes the expression and captures it into a Variable object.
Args:
frame: evaluation context.
expression: watched expression to compile and evaluate.
Returns:
Variable object (which will have error status if the expression fails
to evaluate). | [
"Evalutes",
"the",
"expression",
"and",
"captures",
"it",
"into",
"a",
"Variable",
"object",
"."
] | python | train |
fracpete/python-weka-wrapper3 | python/weka/flow/transformer.py | https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1774-L1797 | def fix_config(self, options):
"""
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary.
:param options: the options to fix
:type options: dict
:return: the (potentially) fixed options
:rtype: dict
"""
options = super(Pre... | [
"def",
"fix_config",
"(",
"self",
",",
"options",
")",
":",
"options",
"=",
"super",
"(",
"Predict",
",",
"self",
")",
".",
"fix_config",
"(",
"options",
")",
"opt",
"=",
"\"model\"",
"if",
"opt",
"not",
"in",
"options",
":",
"options",
"[",
"opt",
"... | Fixes the options, if necessary. I.e., it adds all required elements to the dictionary.
:param options: the options to fix
:type options: dict
:return: the (potentially) fixed options
:rtype: dict | [
"Fixes",
"the",
"options",
"if",
"necessary",
".",
"I",
".",
"e",
".",
"it",
"adds",
"all",
"required",
"elements",
"to",
"the",
"dictionary",
"."
] | python | train |
BlueBrain/nat | nat/gitManager.py | https://github.com/BlueBrain/nat/blob/0934f06e48e6efedf55a9617b15becae0d7b277c/nat/gitManager.py#L141-L167 | def push(self):
"""
Adding the no_thin argument to the GIT push because we had some issues pushing previously.
According to http://stackoverflow.com/questions/16586642/git-unpack-error-on-push-to-gerrit#comment42953435_23610917,
"a new optimization which causes git to send as little d... | [
"def",
"push",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"canRunRemoteCmd",
"(",
")",
":",
"return",
"None",
"try",
":",
"fetchInfo",
"=",
"self",
".",
"repo",
".",
"remotes",
".",
"origin",
".",
"push",
"(",
"no_thin",
"=",
"True",
")",
"["... | Adding the no_thin argument to the GIT push because we had some issues pushing previously.
According to http://stackoverflow.com/questions/16586642/git-unpack-error-on-push-to-gerrit#comment42953435_23610917,
"a new optimization which causes git to send as little data as possible over the network caus... | [
"Adding",
"the",
"no_thin",
"argument",
"to",
"the",
"GIT",
"push",
"because",
"we",
"had",
"some",
"issues",
"pushing",
"previously",
".",
"According",
"to",
"http",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"16586642",
"/",
"git",
"-... | python | train |
Skyscanner/pycfmodel | pycfmodel/model/parameter.py | https://github.com/Skyscanner/pycfmodel/blob/e3da4db96f59c0a5dba06ae66ad25645775e5500/pycfmodel/model/parameter.py#L31-L41 | def set_generic_keys(self, properties, exclude_list):
"""
Sets all the key value pairs that were not set manually in __init__.
"""
generic_keys = set(properties.keys()) - set(exclude_list)
for generic_key in generic_keys:
self.__setattr__(
self._conve... | [
"def",
"set_generic_keys",
"(",
"self",
",",
"properties",
",",
"exclude_list",
")",
":",
"generic_keys",
"=",
"set",
"(",
"properties",
".",
"keys",
"(",
")",
")",
"-",
"set",
"(",
"exclude_list",
")",
"for",
"generic_key",
"in",
"generic_keys",
":",
"sel... | Sets all the key value pairs that were not set manually in __init__. | [
"Sets",
"all",
"the",
"key",
"value",
"pairs",
"that",
"were",
"not",
"set",
"manually",
"in",
"__init__",
"."
] | python | train |
spry-group/python-vultr | vultr/v1_server.py | https://github.com/spry-group/python-vultr/blob/bad1448f1df7b5dba70fd3d11434f32580f0b850/vultr/v1_server.py#L118-L130 | def os_change(self, subid, osid, params=None):
''' /v1/server/os_change
POST - account
Changes the operating system of a virtual machine. All data will be
permanently lost.
Link: https://www.vultr.com/api/#server_os_change
'''
params = update_params(params, {
... | [
"def",
"os_change",
"(",
"self",
",",
"subid",
",",
"osid",
",",
"params",
"=",
"None",
")",
":",
"params",
"=",
"update_params",
"(",
"params",
",",
"{",
"'SUBID'",
":",
"subid",
",",
"'OSID'",
":",
"osid",
"}",
")",
"return",
"self",
".",
"request"... | /v1/server/os_change
POST - account
Changes the operating system of a virtual machine. All data will be
permanently lost.
Link: https://www.vultr.com/api/#server_os_change | [
"/",
"v1",
"/",
"server",
"/",
"os_change",
"POST",
"-",
"account",
"Changes",
"the",
"operating",
"system",
"of",
"a",
"virtual",
"machine",
".",
"All",
"data",
"will",
"be",
"permanently",
"lost",
"."
] | python | train |
hyperledger/sawtooth-core | cli/sawtooth_cli/state.py | https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/cli/sawtooth_cli/state.py#L82-L135 | def do_state(args):
"""Runs the batch list or batch show command, printing output to the
console
Args:
args: The parsed arguments sent to the command at runtime
"""
rest_client = RestClient(args.url, args.user)
if args.subcommand == 'list':
response = rest_client.list_s... | [
"def",
"do_state",
"(",
"args",
")",
":",
"rest_client",
"=",
"RestClient",
"(",
"args",
".",
"url",
",",
"args",
".",
"user",
")",
"if",
"args",
".",
"subcommand",
"==",
"'list'",
":",
"response",
"=",
"rest_client",
".",
"list_state",
"(",
"args",
".... | Runs the batch list or batch show command, printing output to the
console
Args:
args: The parsed arguments sent to the command at runtime | [
"Runs",
"the",
"batch",
"list",
"or",
"batch",
"show",
"command",
"printing",
"output",
"to",
"the",
"console"
] | python | train |
PyCQA/pylint | pylint/lint.py | https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/lint.py#L787-L805 | def error_mode(self):
"""error mode: enable only errors; no reports, no persistent"""
self._error_mode = True
self.disable_noerror_messages()
self.disable("miscellaneous")
if self._python3_porting_mode:
self.disable("all")
for msg_id in self._checker_messa... | [
"def",
"error_mode",
"(",
"self",
")",
":",
"self",
".",
"_error_mode",
"=",
"True",
"self",
".",
"disable_noerror_messages",
"(",
")",
"self",
".",
"disable",
"(",
"\"miscellaneous\"",
")",
"if",
"self",
".",
"_python3_porting_mode",
":",
"self",
".",
"disa... | error mode: enable only errors; no reports, no persistent | [
"error",
"mode",
":",
"enable",
"only",
"errors",
";",
"no",
"reports",
"no",
"persistent"
] | python | test |
quantumlib/Cirq | cirq/google/line/placement/greedy.py | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/google/line/placement/greedy.py#L105-L130 | def _sequence_search(self, start: GridQubit,
current: List[GridQubit]) -> List[GridQubit]:
"""Search for the continuous linear sequence from the given qubit.
This method is called twice for the same starting qubit, so that
sequences that begin and end on this qubit are ... | [
"def",
"_sequence_search",
"(",
"self",
",",
"start",
":",
"GridQubit",
",",
"current",
":",
"List",
"[",
"GridQubit",
"]",
")",
"->",
"List",
"[",
"GridQubit",
"]",
":",
"used",
"=",
"set",
"(",
"current",
")",
"seq",
"=",
"[",
"]",
"n",
"=",
"sta... | Search for the continuous linear sequence from the given qubit.
This method is called twice for the same starting qubit, so that
sequences that begin and end on this qubit are searched for.
Args:
start: The first qubit, where search should be trigerred from.
current: Pr... | [
"Search",
"for",
"the",
"continuous",
"linear",
"sequence",
"from",
"the",
"given",
"qubit",
"."
] | python | train |
loganasherjones/yapconf | yapconf/items.py | https://github.com/loganasherjones/yapconf/blob/d2970e6e7e3334615d4d978d8b0ca33006d79d16/yapconf/items.py#L243-L254 | def update_default(self, new_default, respect_none=False):
"""Update our current default with the new_default.
Args:
new_default: New default to set.
respect_none: Flag to determine if ``None`` is a valid value.
"""
if new_default is not None:
self.d... | [
"def",
"update_default",
"(",
"self",
",",
"new_default",
",",
"respect_none",
"=",
"False",
")",
":",
"if",
"new_default",
"is",
"not",
"None",
":",
"self",
".",
"default",
"=",
"new_default",
"elif",
"new_default",
"is",
"None",
"and",
"respect_none",
":",... | Update our current default with the new_default.
Args:
new_default: New default to set.
respect_none: Flag to determine if ``None`` is a valid value. | [
"Update",
"our",
"current",
"default",
"with",
"the",
"new_default",
"."
] | python | train |
satellogic/telluric | telluric/collections.py | https://github.com/satellogic/telluric/blob/e752cd3ee71e339f79717e526fde362e80055d9e/telluric/collections.py#L209-L219 | def dissolve(self, by=None, aggfunc=None):
# type: (Optional[str], Optional[Callable]) -> FeatureCollection
"""Dissolve geometries and rasters within `groupby`.
"""
if by:
agg = partial(dissolve, aggfunc=aggfunc) # type: Callable[[BaseCollection], GeoFeature]
re... | [
"def",
"dissolve",
"(",
"self",
",",
"by",
"=",
"None",
",",
"aggfunc",
"=",
"None",
")",
":",
"# type: (Optional[str], Optional[Callable]) -> FeatureCollection",
"if",
"by",
":",
"agg",
"=",
"partial",
"(",
"dissolve",
",",
"aggfunc",
"=",
"aggfunc",
")",
"# ... | Dissolve geometries and rasters within `groupby`. | [
"Dissolve",
"geometries",
"and",
"rasters",
"within",
"groupby",
"."
] | python | train |
lrq3000/pyFileFixity | pyFileFixity/lib/profilers/visual/pympler/classtracker.py | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker.py#L217-L228 | def total(self):
"""
Return the total (virtual) size of the process in bytes. If process
information is not available, get the best number available, even if it
is a poor approximation of reality.
"""
if self.system_total.available:
return self.system_total.vs... | [
"def",
"total",
"(",
"self",
")",
":",
"if",
"self",
".",
"system_total",
".",
"available",
":",
"return",
"self",
".",
"system_total",
".",
"vsz",
"elif",
"self",
".",
"asizeof_total",
":",
"# pragma: no cover",
"return",
"self",
".",
"asizeof_total",
"else... | Return the total (virtual) size of the process in bytes. If process
information is not available, get the best number available, even if it
is a poor approximation of reality. | [
"Return",
"the",
"total",
"(",
"virtual",
")",
"size",
"of",
"the",
"process",
"in",
"bytes",
".",
"If",
"process",
"information",
"is",
"not",
"available",
"get",
"the",
"best",
"number",
"available",
"even",
"if",
"it",
"is",
"a",
"poor",
"approximation"... | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.