repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
globocom/GloboNetworkAPI-client-python | networkapiclient/ApiIPv4.py | https://github.com/globocom/GloboNetworkAPI-client-python/blob/cf34f913da48d9abbf750114f5d2ac4b2dde137d/networkapiclient/ApiIPv4.py#L77-L89 | def update(self, ipv4s):
"""
Method to update ipv4's
:param ipv4s: List containing ipv4's desired to updated
:return: None
"""
data = {'ips': ipv4s}
ipv4s_ids = [str(ipv4.get('id')) for ipv4 in ipv4s]
return super(ApiIPv4, self).put('api/v3/ipv4/%s/' %
... | [
"def",
"update",
"(",
"self",
",",
"ipv4s",
")",
":",
"data",
"=",
"{",
"'ips'",
":",
"ipv4s",
"}",
"ipv4s_ids",
"=",
"[",
"str",
"(",
"ipv4",
".",
"get",
"(",
"'id'",
")",
")",
"for",
"ipv4",
"in",
"ipv4s",
"]",
"return",
"super",
"(",
"ApiIPv4"... | Method to update ipv4's
:param ipv4s: List containing ipv4's desired to updated
:return: None | [
"Method",
"to",
"update",
"ipv4",
"s"
] | python | train | 28.769231 |
mattja/nsim | nsim/analysesN/misc.py | https://github.com/mattja/nsim/blob/ed62c41cd56b918fd97e09f7ad73c12c76a8c3e0/nsim/analysesN/misc.py#L16-L40 | def first_return_times(dts, c=None, d=0.0):
"""For an ensemble of time series, return the set of all time intervals
between successive returns to value c for all instances in the ensemble.
If c is not given, the default is the mean across all times and across all
time series in the ensemble.
Args:
... | [
"def",
"first_return_times",
"(",
"dts",
",",
"c",
"=",
"None",
",",
"d",
"=",
"0.0",
")",
":",
"if",
"c",
"is",
"None",
":",
"c",
"=",
"dts",
".",
"mean",
"(",
")",
"vmrt",
"=",
"distob",
".",
"vectorize",
"(",
"analyses1",
".",
"first_return_time... | For an ensemble of time series, return the set of all time intervals
between successive returns to value c for all instances in the ensemble.
If c is not given, the default is the mean across all times and across all
time series in the ensemble.
Args:
dts (DistTimeseries)
c (float): Option... | [
"For",
"an",
"ensemble",
"of",
"time",
"series",
"return",
"the",
"set",
"of",
"all",
"time",
"intervals",
"between",
"successive",
"returns",
"to",
"value",
"c",
"for",
"all",
"instances",
"in",
"the",
"ensemble",
".",
"If",
"c",
"is",
"not",
"given",
"... | python | train | 38 |
Contraz/demosys-py | demosys/context/base.py | https://github.com/Contraz/demosys-py/blob/6466128a3029c4d09631420ccce73024025bd5b6/demosys/context/base.py#L272-L284 | def cursor_event(self, x, y, dx, dy):
"""
The standard mouse movement event method.
Can be overriden to add new functionality.
By default this feeds the system camera with new values.
Args:
x: The current mouse x position
y: The current mouse y position
... | [
"def",
"cursor_event",
"(",
"self",
",",
"x",
",",
"y",
",",
"dx",
",",
"dy",
")",
":",
"self",
".",
"sys_camera",
".",
"rot_state",
"(",
"x",
",",
"y",
")"
] | The standard mouse movement event method.
Can be overriden to add new functionality.
By default this feeds the system camera with new values.
Args:
x: The current mouse x position
y: The current mouse y position
dx: Delta x postion (x position difference from... | [
"The",
"standard",
"mouse",
"movement",
"event",
"method",
".",
"Can",
"be",
"overriden",
"to",
"add",
"new",
"functionality",
".",
"By",
"default",
"this",
"feeds",
"the",
"system",
"camera",
"with",
"new",
"values",
"."
] | python | valid | 39.846154 |
ramrod-project/database-brain | schema/brain/queries/reads.py | https://github.com/ramrod-project/database-brain/blob/b024cb44f34cabb9d80af38271ddb65c25767083/schema/brain/queries/reads.py#L161-L179 | def get_output_content(job_id, max_size=1024, conn=None):
"""
returns the content buffer for a job_id if that job output exists
:param job_id: <str> id for the job
:param max_size: <int> truncate after [max_size] bytes
:param conn: (optional)<connection> to run on
:return: <str> or <bytes>
... | [
"def",
"get_output_content",
"(",
"job_id",
",",
"max_size",
"=",
"1024",
",",
"conn",
"=",
"None",
")",
":",
"content",
"=",
"None",
"if",
"RBO",
".",
"index_list",
"(",
")",
".",
"contains",
"(",
"IDX_OUTPUT_JOB_ID",
")",
".",
"run",
"(",
"conn",
")"... | returns the content buffer for a job_id if that job output exists
:param job_id: <str> id for the job
:param max_size: <int> truncate after [max_size] bytes
:param conn: (optional)<connection> to run on
:return: <str> or <bytes> | [
"returns",
"the",
"content",
"buffer",
"for",
"a",
"job_id",
"if",
"that",
"job",
"output",
"exists"
] | python | train | 37.894737 |
yangl1996/libpagure | libpagure/libpagure.py | https://github.com/yangl1996/libpagure/blob/dd96ed29142407463790c66ed321984a6ea7465a/libpagure/libpagure.py#L523-L545 | def user_activity_stats(self, username, format=None):
"""
Retrieve the activity stats about a specific user over the last year.
Params:
username (string): filters the username of the user whose activity you are interested in.
format (string): Allows changing the of the d... | [
"def",
"user_activity_stats",
"(",
"self",
",",
"username",
",",
"format",
"=",
"None",
")",
":",
"request_url",
"=",
"\"{}/api/0/user/{}/activity/stats\"",
".",
"format",
"(",
"self",
".",
"instance",
",",
"username",
")",
"payload",
"=",
"{",
"}",
"if",
"u... | Retrieve the activity stats about a specific user over the last year.
Params:
username (string): filters the username of the user whose activity you are interested in.
format (string): Allows changing the of the date/time returned from iso format
to unix tim... | [
"Retrieve",
"the",
"activity",
"stats",
"about",
"a",
"specific",
"user",
"over",
"the",
"last",
"year",
"."
] | python | train | 40.217391 |
moonso/loqusdb | loqusdb/commands/identity.py | https://github.com/moonso/loqusdb/blob/792dcd0d461aff5adc703c49eebf58964913a513/loqusdb/commands/identity.py#L13-L32 | def identity(ctx, variant_id):
"""Check how well SVs are working in the database
"""
if not variant_id:
LOG.warning("Please provide a variant id")
ctx.abort()
adapter = ctx.obj['adapter']
version = ctx.obj['version']
LOG.info("Search variants {0}".format(adapter))
... | [
"def",
"identity",
"(",
"ctx",
",",
"variant_id",
")",
":",
"if",
"not",
"variant_id",
":",
"LOG",
".",
"warning",
"(",
"\"Please provide a variant id\"",
")",
"ctx",
".",
"abort",
"(",
")",
"adapter",
"=",
"ctx",
".",
"obj",
"[",
"'adapter'",
"]",
"vers... | Check how well SVs are working in the database | [
"Check",
"how",
"well",
"SVs",
"are",
"working",
"in",
"the",
"database"
] | python | train | 25.05 |
sdispater/orator | orator/commands/migrations/install_command.py | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/commands/migrations/install_command.py#L15-L25 | def handle(self):
"""
Executes the command
"""
database = self.option("database")
repository = DatabaseMigrationRepository(self.resolver, "migrations")
repository.set_source(database)
repository.create_repository()
self.info("Migration table created succ... | [
"def",
"handle",
"(",
"self",
")",
":",
"database",
"=",
"self",
".",
"option",
"(",
"\"database\"",
")",
"repository",
"=",
"DatabaseMigrationRepository",
"(",
"self",
".",
"resolver",
",",
"\"migrations\"",
")",
"repository",
".",
"set_source",
"(",
"databas... | Executes the command | [
"Executes",
"the",
"command"
] | python | train | 29.090909 |
iotile/coretools | iotilegateway/iotilegateway/supervisor/service_manager.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/supervisor/service_manager.py#L187-L212 | def service_status(self, short_name):
"""Get the current status of a service.
Returns information about the service such as the length since the last
heartbeat, any status messages that have been posted about the service
and whether the heartbeat should be considered out of the ordinary... | [
"def",
"service_status",
"(",
"self",
",",
"short_name",
")",
":",
"if",
"short_name",
"not",
"in",
"self",
".",
"services",
":",
"raise",
"ArgumentError",
"(",
"\"Unknown service name\"",
",",
"short_name",
"=",
"short_name",
")",
"info",
"=",
"{",
"}",
"se... | Get the current status of a service.
Returns information about the service such as the length since the last
heartbeat, any status messages that have been posted about the service
and whether the heartbeat should be considered out of the ordinary.
Args:
short_name (string):... | [
"Get",
"the",
"current",
"status",
"of",
"a",
"service",
"."
] | python | train | 33.192308 |
FelixSchwarz/pymta | pymta/session.py | https://github.com/FelixSchwarz/pymta/blob/1884accc3311e6c2e89259784f9592314f6d34fc/pymta/session.py#L68-L81 | def get_all_allowed_internal_commands(self):
"""Returns an iterable which includes all allowed commands. This does
not mean that a specific command from the result is executable right now
in this session state (or that it can be executed at all in this
connection).
Please note t... | [
"def",
"get_all_allowed_internal_commands",
"(",
"self",
")",
":",
"states",
"=",
"set",
"(",
")",
"for",
"command_name",
"in",
"self",
".",
"_get_all_commands",
"(",
"including_quit",
"=",
"True",
")",
":",
"if",
"command_name",
"not",
"in",
"[",
"'GREET'",
... | Returns an iterable which includes all allowed commands. This does
not mean that a specific command from the result is executable right now
in this session state (or that it can be executed at all in this
connection).
Please note that the returned values are /internal/ commands, not SMT... | [
"Returns",
"an",
"iterable",
"which",
"includes",
"all",
"allowed",
"commands",
".",
"This",
"does",
"not",
"mean",
"that",
"a",
"specific",
"command",
"from",
"the",
"result",
"is",
"executable",
"right",
"now",
"in",
"this",
"session",
"state",
"(",
"or",
... | python | train | 50.071429 |
tsnaomi/finnsyll | finnsyll/prev/v09.py | https://github.com/tsnaomi/finnsyll/blob/6a42740311688c946a636a3e2304866c7aa041b3/finnsyll/prev/v09.py#L66-L95 | def _syllabify_simplex(word):
'''Syllabify the given word.'''
word, rules = apply_T1(word)
if re.search(r'[^ieAyOauo]*([ieAyOauo]{2})[^ieAyOauo]*', word):
word, T2 = apply_T2(word)
word, T8 = apply_T8(word)
word, T9 = apply_T9(word)
rules += T2 + T8 + T9
# T4 produc... | [
"def",
"_syllabify_simplex",
"(",
"word",
")",
":",
"word",
",",
"rules",
"=",
"apply_T1",
"(",
"word",
")",
"if",
"re",
".",
"search",
"(",
"r'[^ieAyOauo]*([ieAyOauo]{2})[^ieAyOauo]*'",
",",
"word",
")",
":",
"word",
",",
"T2",
"=",
"apply_T2",
"(",
"word... | Syllabify the given word. | [
"Syllabify",
"the",
"given",
"word",
"."
] | python | train | 28.366667 |
solocompt/plugs-filter | plugs_filter/utils.py | https://github.com/solocompt/plugs-filter/blob/cb34c7d662d3f96c07c10b3ed0a34bafef78b52c/plugs_filter/utils.py#L21-L30 | def match_field(field_class):
"""
Iterates the field_classes and
returns the first match
"""
for cls in field_class.mro():
if cls in list(LOOKUP_TABLE.keys()):
return cls
# could not match the field class
raise Exception('{0} None Found '.format(field_class)) | [
"def",
"match_field",
"(",
"field_class",
")",
":",
"for",
"cls",
"in",
"field_class",
".",
"mro",
"(",
")",
":",
"if",
"cls",
"in",
"list",
"(",
"LOOKUP_TABLE",
".",
"keys",
"(",
")",
")",
":",
"return",
"cls",
"# could not match the field class",
"raise"... | Iterates the field_classes and
returns the first match | [
"Iterates",
"the",
"field_classes",
"and",
"returns",
"the",
"first",
"match"
] | python | train | 29.8 |
gbiggs/rtctree | rtctree/node.py | https://github.com/gbiggs/rtctree/blob/bd725a47ac87c259c8bce06156ccc9ab71111c26/rtctree/node.py#L97-L126 | def get_node(self, path):
'''Get a child node of this node, or this node, based on a path.
@param path A list of path elements pointing to a node in the tree.
For example, ['/', 'localhost', 'dir.host']. The first
element in this path should be this node's name.
... | [
"def",
"get_node",
"(",
"self",
",",
"path",
")",
":",
"with",
"self",
".",
"_mutex",
":",
"if",
"path",
"[",
"0",
"]",
"==",
"self",
".",
"_name",
":",
"if",
"len",
"(",
"path",
")",
"==",
"1",
":",
"return",
"self",
"elif",
"path",
"[",
"1",
... | Get a child node of this node, or this node, based on a path.
@param path A list of path elements pointing to a node in the tree.
For example, ['/', 'localhost', 'dir.host']. The first
element in this path should be this node's name.
@return The node pointed to b... | [
"Get",
"a",
"child",
"node",
"of",
"this",
"node",
"or",
"this",
"node",
"based",
"on",
"a",
"path",
"."
] | python | train | 37.033333 |
mar10/wsgidav | wsgidav/dav_provider.py | https://github.com/mar10/wsgidav/blob/cec0d84222fc24bea01be1cea91729001963f172/wsgidav/dav_provider.py#L380-L397 | def get_href(self):
"""Convert path to a URL that can be passed to XML responses.
Byte string, UTF-8 encoded, quoted.
See http://www.webdav.org/specs/rfc4918.html#rfc.section.8.3
We are using the path-absolute option. i.e. starting with '/'.
URI ; See section 3.2.1 of [RFC2068]... | [
"def",
"get_href",
"(",
"self",
")",
":",
"# Nautilus chokes, if href encodes '(' as '%28'",
"# So we don't encode 'extra' and 'safe' characters (see rfc2068 3.2.1)",
"safe",
"=",
"\"/\"",
"+",
"\"!*'(),\"",
"+",
"\"$-_|.\"",
"return",
"compat",
".",
"quote",
"(",
"self",
"... | Convert path to a URL that can be passed to XML responses.
Byte string, UTF-8 encoded, quoted.
See http://www.webdav.org/specs/rfc4918.html#rfc.section.8.3
We are using the path-absolute option. i.e. starting with '/'.
URI ; See section 3.2.1 of [RFC2068] | [
"Convert",
"path",
"to",
"a",
"URL",
"that",
"can",
"be",
"passed",
"to",
"XML",
"responses",
"."
] | python | valid | 37.166667 |
DEIB-GECO/PyGMQL | gmql/ml/genometric_space.py | https://github.com/DEIB-GECO/PyGMQL/blob/e58b2f9402a86056dcda484a32e3de0bb06ed991/gmql/ml/genometric_space.py#L148-L188 | def to_bag_of_genomes(self, clustering_object):
"""
Creates a bag of genomes representation for data mining purposes
Each document (genome) in the representation is a set of metadata key and value pairs belonging to the same cluster.
The bag of genomes are saved under ./bag_of_genomes/ d... | [
"def",
"to_bag_of_genomes",
"(",
"self",
",",
"clustering_object",
")",
":",
"meta_files",
"=",
"Parser",
".",
"_get_files",
"(",
"'meta'",
",",
"self",
".",
"_path",
")",
"meta_dict",
"=",
"{",
"}",
"for",
"f",
"in",
"meta_files",
":",
"meta_dict",
"[",
... | Creates a bag of genomes representation for data mining purposes
Each document (genome) in the representation is a set of metadata key and value pairs belonging to the same cluster.
The bag of genomes are saved under ./bag_of_genomes/ directory
:param clustering_object: The clustering.rst objec... | [
"Creates",
"a",
"bag",
"of",
"genomes",
"representation",
"for",
"data",
"mining",
"purposes",
"Each",
"document",
"(",
"genome",
")",
"in",
"the",
"representation",
"is",
"a",
"set",
"of",
"metadata",
"key",
"and",
"value",
"pairs",
"belonging",
"to",
"the"... | python | train | 48.585366 |
Opentrons/opentrons | api/src/opentrons/protocol_api/contexts.py | https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/protocol_api/contexts.py#L878-L965 | def pick_up_tip(self, location: Union[types.Location, Well] = None,
presses: int = 3,
increment: float = 1.0) -> 'InstrumentContext':
"""
Pick up a tip for the pipette to run liquid-handling commands with
If no location is passed, the Pipette will pick up... | [
"def",
"pick_up_tip",
"(",
"self",
",",
"location",
":",
"Union",
"[",
"types",
".",
"Location",
",",
"Well",
"]",
"=",
"None",
",",
"presses",
":",
"int",
"=",
"3",
",",
"increment",
":",
"float",
"=",
"1.0",
")",
"->",
"'InstrumentContext'",
":",
"... | Pick up a tip for the pipette to run liquid-handling commands with
If no location is passed, the Pipette will pick up the next available
tip in its :py:attr:`InstrumentContext.tip_racks` list.
The tip to pick up can be manually specified with the `location`
argument. The `location` arg... | [
"Pick",
"up",
"a",
"tip",
"for",
"the",
"pipette",
"to",
"run",
"liquid",
"-",
"handling",
"commands",
"with"
] | python | train | 46.670455 |
saltstack/salt | salt/utils/gitfs.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/gitfs.py#L1889-L1898 | def get_tree_from_branch(self, ref):
'''
Return a pygit2.Tree object matching a head ref fetched into
refs/remotes/origin/
'''
try:
return self.peel(self.repo.lookup_reference(
'refs/remotes/origin/{0}'.format(ref))).tree
except KeyError:
... | [
"def",
"get_tree_from_branch",
"(",
"self",
",",
"ref",
")",
":",
"try",
":",
"return",
"self",
".",
"peel",
"(",
"self",
".",
"repo",
".",
"lookup_reference",
"(",
"'refs/remotes/origin/{0}'",
".",
"format",
"(",
"ref",
")",
")",
")",
".",
"tree",
"exce... | Return a pygit2.Tree object matching a head ref fetched into
refs/remotes/origin/ | [
"Return",
"a",
"pygit2",
".",
"Tree",
"object",
"matching",
"a",
"head",
"ref",
"fetched",
"into",
"refs",
"/",
"remotes",
"/",
"origin",
"/"
] | python | train | 32.9 |
ludeeus/pyruter | pyruter/cli.py | https://github.com/ludeeus/pyruter/blob/415d8b9c8bfd48caa82c1a1201bfd3beb670a117/pyruter/cli.py#L34-L45 | def destinations(stop):
"""Get destination information."""
from pyruter.api import Departures
async def get_destinations():
"""Get departure information."""
async with aiohttp.ClientSession() as session:
data = Departures(LOOP, stop, session=session)
result = await d... | [
"def",
"destinations",
"(",
"stop",
")",
":",
"from",
"pyruter",
".",
"api",
"import",
"Departures",
"async",
"def",
"get_destinations",
"(",
")",
":",
"\"\"\"Get departure information.\"\"\"",
"async",
"with",
"aiohttp",
".",
"ClientSession",
"(",
")",
"as",
"s... | Get destination information. | [
"Get",
"destination",
"information",
"."
] | python | train | 41.416667 |
mrstephenneal/mysql-toolkit | mysql/toolkit/components/structure/schema.py | https://github.com/mrstephenneal/mysql-toolkit/blob/6964f718f4b72eb30f2259adfcfaf3090526c53d/mysql/toolkit/components/structure/schema.py#L46-L56 | def add_column(self, table, name='ID', data_type='int(11)', after_col=None, null=False, primary_key=False):
"""Add a column to an existing table."""
location = 'AFTER {0}'.format(after_col) if after_col else 'FIRST'
null_ = 'NULL' if null else 'NOT NULL'
comment = "COMMENT 'Column auto c... | [
"def",
"add_column",
"(",
"self",
",",
"table",
",",
"name",
"=",
"'ID'",
",",
"data_type",
"=",
"'int(11)'",
",",
"after_col",
"=",
"None",
",",
"null",
"=",
"False",
",",
"primary_key",
"=",
"False",
")",
":",
"location",
"=",
"'AFTER {0}'",
".",
"fo... | Add a column to an existing table. | [
"Add",
"a",
"column",
"to",
"an",
"existing",
"table",
"."
] | python | train | 71.090909 |
ambv/flake8-pyi | pyi.py | https://github.com/ambv/flake8-pyi/blob/19e8028b44b6305dff1bfb9a51a23a029c546993/pyi.py#L29-L43 | def ASSIGN(self, node):
"""This is a custom implementation of ASSIGN derived from
handleChildren() in pyflakes 1.3.0.
The point here is that on module level, there's type aliases that we
want to bind eagerly, but defer computation of the values of the
assignments (the type alias... | [
"def",
"ASSIGN",
"(",
"self",
",",
"node",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"scope",
",",
"ModuleScope",
")",
":",
"return",
"super",
"(",
")",
".",
"ASSIGN",
"(",
"node",
")",
"for",
"target",
"in",
"node",
".",
"targets",
":... | This is a custom implementation of ASSIGN derived from
handleChildren() in pyflakes 1.3.0.
The point here is that on module level, there's type aliases that we
want to bind eagerly, but defer computation of the values of the
assignments (the type aliases might have forward references). | [
"This",
"is",
"a",
"custom",
"implementation",
"of",
"ASSIGN",
"derived",
"from",
"handleChildren",
"()",
"in",
"pyflakes",
"1",
".",
"3",
".",
"0",
"."
] | python | train | 38.066667 |
tensorforce/tensorforce | docs/m2r.py | https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/docs/m2r.py#L248-L261 | def table(self, header, body):
"""Rendering table element. Wrap header and body in it.
:param header: header part of the table.
:param body: body part of the table.
"""
table = '\n.. list-table::\n'
if header and not header.isspace():
table = (table + self.in... | [
"def",
"table",
"(",
"self",
",",
"header",
",",
"body",
")",
":",
"table",
"=",
"'\\n.. list-table::\\n'",
"if",
"header",
"and",
"not",
"header",
".",
"isspace",
"(",
")",
":",
"table",
"=",
"(",
"table",
"+",
"self",
".",
"indent",
"+",
"':header-ro... | Rendering table element. Wrap header and body in it.
:param header: header part of the table.
:param body: body part of the table. | [
"Rendering",
"table",
"element",
".",
"Wrap",
"header",
"and",
"body",
"in",
"it",
"."
] | python | valid | 37.071429 |
fprimex/zdesk | zdesk/zdesk_api.py | https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L1780-L1784 | def help_center_category_translations_missing(self, category_id, **kwargs):
"https://developer.zendesk.com/rest_api/docs/help_center/translations#list-missing-translations"
api_path = "/api/v2/help_center/categories/{category_id}/translations/missing.json"
api_path = api_path.format(category_id=... | [
"def",
"help_center_category_translations_missing",
"(",
"self",
",",
"category_id",
",",
"*",
"*",
"kwargs",
")",
":",
"api_path",
"=",
"\"/api/v2/help_center/categories/{category_id}/translations/missing.json\"",
"api_path",
"=",
"api_path",
".",
"format",
"(",
"category_... | https://developer.zendesk.com/rest_api/docs/help_center/translations#list-missing-translations | [
"https",
":",
"//",
"developer",
".",
"zendesk",
".",
"com",
"/",
"rest_api",
"/",
"docs",
"/",
"help_center",
"/",
"translations#list",
"-",
"missing",
"-",
"translations"
] | python | train | 74.6 |
PythonCharmers/python-future | src/libpasteurize/fixes/fix_unpacking.py | https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/libpasteurize/fixes/fix_unpacking.py#L83-L120 | def transform(self, node, results):
u"""
a,b,c,d,e,f,*g,h,i = range(100) changes to
_3to2list = list(range(100))
a,b,c,d,e,f,g,h,i, = _3to2list[:6] + [_3to2list[6:-2]] + _3to2list[-2:]
and
for a,b,*c,d,e in iter_of_iters: do_stuff changes to
for _3to2iter in ite... | [
"def",
"transform",
"(",
"self",
",",
"node",
",",
"results",
")",
":",
"self",
".",
"LISTNAME",
"=",
"self",
".",
"new_name",
"(",
"u\"_3to2list\"",
")",
"self",
".",
"ITERNAME",
"=",
"self",
".",
"new_name",
"(",
"u\"_3to2iter\"",
")",
"expl",
",",
"... | u"""
a,b,c,d,e,f,*g,h,i = range(100) changes to
_3to2list = list(range(100))
a,b,c,d,e,f,g,h,i, = _3to2list[:6] + [_3to2list[6:-2]] + _3to2list[-2:]
and
for a,b,*c,d,e in iter_of_iters: do_stuff changes to
for _3to2iter in iter_of_iters:
_3to2list = list(_3t... | [
"u",
"a",
"b",
"c",
"d",
"e",
"f",
"*",
"g",
"h",
"i",
"=",
"range",
"(",
"100",
")",
"changes",
"to",
"_3to2list",
"=",
"list",
"(",
"range",
"(",
"100",
"))",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"=",
"_3to2list",
"[",
":",
"6",... | python | train | 43.421053 |
geometalab/pyGeoTile | pygeotile/tile.py | https://github.com/geometalab/pyGeoTile/blob/b1f44271698f5fc4d18c2add935797ed43254aa6/pygeotile/tile.py#L35-L40 | def from_google(cls, google_x, google_y, zoom):
"""Creates a tile from Google format X Y and zoom"""
max_tile = (2 ** zoom) - 1
assert 0 <= google_x <= max_tile, 'Google X needs to be a value between 0 and (2^zoom) -1.'
assert 0 <= google_y <= max_tile, 'Google Y needs to be a value betw... | [
"def",
"from_google",
"(",
"cls",
",",
"google_x",
",",
"google_y",
",",
"zoom",
")",
":",
"max_tile",
"=",
"(",
"2",
"**",
"zoom",
")",
"-",
"1",
"assert",
"0",
"<=",
"google_x",
"<=",
"max_tile",
",",
"'Google X needs to be a value between 0 and (2^zoom) -1.... | Creates a tile from Google format X Y and zoom | [
"Creates",
"a",
"tile",
"from",
"Google",
"format",
"X",
"Y",
"and",
"zoom"
] | python | train | 69.666667 |
senaite/senaite.core | bika/lims/workflow/referenceanalysis/events.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/workflow/referenceanalysis/events.py#L43-L48 | def after_unassign(reference_analysis):
"""Removes the reference analysis from the system
"""
analysis_events.after_unassign(reference_analysis)
ref_sample = reference_analysis.aq_parent
ref_sample.manage_delObjects([reference_analysis.getId()]) | [
"def",
"after_unassign",
"(",
"reference_analysis",
")",
":",
"analysis_events",
".",
"after_unassign",
"(",
"reference_analysis",
")",
"ref_sample",
"=",
"reference_analysis",
".",
"aq_parent",
"ref_sample",
".",
"manage_delObjects",
"(",
"[",
"reference_analysis",
"."... | Removes the reference analysis from the system | [
"Removes",
"the",
"reference",
"analysis",
"from",
"the",
"system"
] | python | train | 43.333333 |
soravux/scoop | scoop/_control.py | https://github.com/soravux/scoop/blob/d391dfa62f47e49d48328ee9cf08aa114256fd33/scoop/_control.py#L91-L95 | def advertiseBrokerWorkerDown(exctype, value, traceback):
"""Hook advertizing the broker if an impromptu shutdown is occuring."""
if not scoop.SHUTDOWN_REQUESTED:
execQueue.shutdown()
sys.__excepthook__(exctype, value, traceback) | [
"def",
"advertiseBrokerWorkerDown",
"(",
"exctype",
",",
"value",
",",
"traceback",
")",
":",
"if",
"not",
"scoop",
".",
"SHUTDOWN_REQUESTED",
":",
"execQueue",
".",
"shutdown",
"(",
")",
"sys",
".",
"__excepthook__",
"(",
"exctype",
",",
"value",
",",
"trac... | Hook advertizing the broker if an impromptu shutdown is occuring. | [
"Hook",
"advertizing",
"the",
"broker",
"if",
"an",
"impromptu",
"shutdown",
"is",
"occuring",
"."
] | python | train | 49 |
Chilipp/psyplot | psyplot/data.py | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/data.py#L4377-L4397 | def extend(self, iterable, new_name=False):
"""
Add further arrays from an iterable to this list
Parameters
----------
iterable
Any iterable that contains :class:`InteractiveBase` instances
%(ArrayList.rename.parameters.new_name)s
Raises
----... | [
"def",
"extend",
"(",
"self",
",",
"iterable",
",",
"new_name",
"=",
"False",
")",
":",
"# extend those arrays that aren't alredy in the list",
"super",
"(",
"ArrayList",
",",
"self",
")",
".",
"extend",
"(",
"t",
"[",
"0",
"]",
"for",
"t",
"in",
"filter",
... | Add further arrays from an iterable to this list
Parameters
----------
iterable
Any iterable that contains :class:`InteractiveBase` instances
%(ArrayList.rename.parameters.new_name)s
Raises
------
%(ArrayList.rename.raises)s
See Also
... | [
"Add",
"further",
"arrays",
"from",
"an",
"iterable",
"to",
"this",
"list"
] | python | train | 30.52381 |
openai/universe | universe/envs/vnc_core_env/translator.py | https://github.com/openai/universe/blob/cc9ce6ec241821bfb0f3b85dd455bd36e4ee7a8c/universe/envs/vnc_core_env/translator.py#L19-L34 | def apply_vnc_actions(self, vnc_actions):
"""
Play a list of vnc_actions forward over the current keysyms state
NOTE: Since we are squashing a set of diffs into a single keyboard state, some information may be lost.
For example if the Z key is down, then we receive [(Z-up), (Z-down)], t... | [
"def",
"apply_vnc_actions",
"(",
"self",
",",
"vnc_actions",
")",
":",
"for",
"event",
"in",
"vnc_actions",
":",
"if",
"isinstance",
"(",
"event",
",",
"spaces",
".",
"KeyEvent",
")",
":",
"if",
"event",
".",
"down",
":",
"self",
".",
"_down_keysyms",
".... | Play a list of vnc_actions forward over the current keysyms state
NOTE: Since we are squashing a set of diffs into a single keyboard state, some information may be lost.
For example if the Z key is down, then we receive [(Z-up), (Z-down)], the output will not reflect any change in Z
You can mak... | [
"Play",
"a",
"list",
"of",
"vnc_actions",
"forward",
"over",
"the",
"current",
"keysyms",
"state"
] | python | train | 47.25 |
vinci1it2000/schedula | schedula/utils/io.py | https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/io.py#L91-L123 | def save_default_values(dsp, path):
"""
Write Dispatcher default values in Python pickle format.
Pickles are a serialized byte stream of a Python object.
This format will preserve Python objects used as nodes or edges.
:param dsp:
A dispatcher that identifies the model adopted.
:type d... | [
"def",
"save_default_values",
"(",
"dsp",
",",
"path",
")",
":",
"import",
"dill",
"with",
"open",
"(",
"path",
",",
"'wb'",
")",
"as",
"f",
":",
"dill",
".",
"dump",
"(",
"dsp",
".",
"default_values",
",",
"f",
")"
] | Write Dispatcher default values in Python pickle format.
Pickles are a serialized byte stream of a Python object.
This format will preserve Python objects used as nodes or edges.
:param dsp:
A dispatcher that identifies the model adopted.
:type dsp: schedula.Dispatcher
:param path:
... | [
"Write",
"Dispatcher",
"default",
"values",
"in",
"Python",
"pickle",
"format",
"."
] | python | train | 28.333333 |
basho/riak-python-client | riak/multidict.py | https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/multidict.py#L85-L106 | def mixed(self):
"""
Returns a dictionary where the values are either single
values, or a list of values when a key/value appears more than
once in this dictionary. This is similar to the kind of
dictionary often used to represent the variables in a web
request.
... | [
"def",
"mixed",
"(",
"self",
")",
":",
"result",
"=",
"{",
"}",
"multi",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"self",
".",
"_items",
":",
"if",
"key",
"in",
"result",
":",
"# We do this to not clobber any lists that are",
"# *actual* values in th... | Returns a dictionary where the values are either single
values, or a list of values when a key/value appears more than
once in this dictionary. This is similar to the kind of
dictionary often used to represent the variables in a web
request. | [
"Returns",
"a",
"dictionary",
"where",
"the",
"values",
"are",
"either",
"single",
"values",
"or",
"a",
"list",
"of",
"values",
"when",
"a",
"key",
"/",
"value",
"appears",
"more",
"than",
"once",
"in",
"this",
"dictionary",
".",
"This",
"is",
"similar",
... | python | train | 36.227273 |
dpmcmlxxvi/pixelscan | pixelscan/pixelscan.py | https://github.com/dpmcmlxxvi/pixelscan/blob/d641207b13a8fc5bf7ac9964b982971652bb0a7e/pixelscan/pixelscan.py#L241-L250 | def next(self):
"""Next point in iteration
"""
if self.probability == 1:
x, y = next(self.scan)
else:
while True:
x, y = next(self.scan)
if random.random() <= self.probability: break
return x, y | [
"def",
"next",
"(",
"self",
")",
":",
"if",
"self",
".",
"probability",
"==",
"1",
":",
"x",
",",
"y",
"=",
"next",
"(",
"self",
".",
"scan",
")",
"else",
":",
"while",
"True",
":",
"x",
",",
"y",
"=",
"next",
"(",
"self",
".",
"scan",
")",
... | Next point in iteration | [
"Next",
"point",
"in",
"iteration"
] | python | train | 28.1 |
majerteam/sqla_inspect | sqla_inspect/csv.py | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/csv.py#L108-L123 | def set_headers(self, headers):
"""
Set the headers of our csv writer
:param list headers: list of dict with label and name key (label is
mandatory : used for the export)
"""
self.headers = []
if 'order' in self.options:
for element in self.options['o... | [
"def",
"set_headers",
"(",
"self",
",",
"headers",
")",
":",
"self",
".",
"headers",
"=",
"[",
"]",
"if",
"'order'",
"in",
"self",
".",
"options",
":",
"for",
"element",
"in",
"self",
".",
"options",
"[",
"'order'",
"]",
":",
"for",
"header",
"in",
... | Set the headers of our csv writer
:param list headers: list of dict with label and name key (label is
mandatory : used for the export) | [
"Set",
"the",
"headers",
"of",
"our",
"csv",
"writer"
] | python | train | 33.1875 |
applegrew/django-select2 | django_select2/forms.py | https://github.com/applegrew/django-select2/blob/2bb6f3a9740a368e486e1ea01ff553d2d1954241/django_select2/forms.py#L95-L115 | def _get_media(self):
"""
Construct Media as a dynamic property.
.. Note:: For more information visit
https://docs.djangoproject.com/en/stable/topics/forms/media/#media-as-a-dynamic-property
"""
lang = get_language()
select2_js = (settings.SELECT2_JS,) if set... | [
"def",
"_get_media",
"(",
"self",
")",
":",
"lang",
"=",
"get_language",
"(",
")",
"select2_js",
"=",
"(",
"settings",
".",
"SELECT2_JS",
",",
")",
"if",
"settings",
".",
"SELECT2_JS",
"else",
"(",
")",
"select2_css",
"=",
"(",
"settings",
".",
"SELECT2_... | Construct Media as a dynamic property.
.. Note:: For more information visit
https://docs.djangoproject.com/en/stable/topics/forms/media/#media-as-a-dynamic-property | [
"Construct",
"Media",
"as",
"a",
"dynamic",
"property",
"."
] | python | train | 38.571429 |
chaoss/grimoirelab-elk | grimoire_elk/enriched/phabricator.py | https://github.com/chaoss/grimoirelab-elk/blob/64e08b324b36d9f6909bf705145d6451c8d34e65/grimoire_elk/enriched/phabricator.py#L130-L227 | def get_rich_events(self, item):
"""
In the events there are some common fields with the task. The name
of the field must be the same in the task and in the event
so we can filer using it in task and event at the same time.
* Fields that don't change: the field does not change w... | [
"def",
"get_rich_events",
"(",
"self",
",",
"item",
")",
":",
"# To get values from the task",
"eitem",
"=",
"self",
".",
"get_rich_item",
"(",
"item",
")",
"# Fields that don't change never",
"task_fields_nochange",
"=",
"[",
"'author_userName'",
",",
"'creation_date'"... | In the events there are some common fields with the task. The name
of the field must be the same in the task and in the event
so we can filer using it in task and event at the same time.
* Fields that don't change: the field does not change with the events
in a task so the value is alwa... | [
"In",
"the",
"events",
"there",
"are",
"some",
"common",
"fields",
"with",
"the",
"task",
".",
"The",
"name",
"of",
"the",
"field",
"must",
"be",
"the",
"same",
"in",
"the",
"task",
"and",
"in",
"the",
"event",
"so",
"we",
"can",
"filer",
"using",
"i... | python | train | 47.704082 |
Blazemeter/apiritif | apiritif/loadgen.py | https://github.com/Blazemeter/apiritif/blob/27b48a68425949998c2254e5e1e0226882d9eee8/apiritif/loadgen.py#L48-L59 | def spawn_worker(params):
"""
This method has to be module level function
:type params: Params
"""
setup_logging(params)
log.info("Adding worker: idx=%s\tconcurrency=%s\tresults=%s", params.worker_index, params.concurrency,
params.report)
worker = Worker(params)
worker.star... | [
"def",
"spawn_worker",
"(",
"params",
")",
":",
"setup_logging",
"(",
"params",
")",
"log",
".",
"info",
"(",
"\"Adding worker: idx=%s\\tconcurrency=%s\\tresults=%s\"",
",",
"params",
".",
"worker_index",
",",
"params",
".",
"concurrency",
",",
"params",
".",
"rep... | This method has to be module level function
:type params: Params | [
"This",
"method",
"has",
"to",
"be",
"module",
"level",
"function"
] | python | train | 27.5 |
JonathonReinhart/scuba | scuba/__main__.py | https://github.com/JonathonReinhart/scuba/blob/0244c81ec482d3c60202028bc075621447bc3ad1/scuba/__main__.py#L208-L235 | def __load_config(self):
'''Find and load .scuba.yml
'''
# top_path is where .scuba.yml is found, and becomes the top of our bind mount.
# top_rel is the relative path from top_path to the current working directory,
# and is where we'll set the working directory in the container... | [
"def",
"__load_config",
"(",
"self",
")",
":",
"# top_path is where .scuba.yml is found, and becomes the top of our bind mount.",
"# top_rel is the relative path from top_path to the current working directory,",
"# and is where we'll set the working directory in the container (relative to",
"# the... | Find and load .scuba.yml | [
"Find",
"and",
"load",
".",
"scuba",
".",
"yml"
] | python | train | 41.892857 |
codenerix/django-codenerix-pos | codenerix_pos/consumers.py | https://github.com/codenerix/django-codenerix-pos/blob/d59f233dd421a6bfe0e9e2674468de2b632643b8/codenerix_pos/consumers.py#L128-L209 | def recv(self, message, ref, pos):
"""
Called when a message is received with decoded JSON content
"""
# Get action
action = message.get('action', None)
# Show the message we got
if action != 'pingdog':
self.debug("{} - Receive: {} (ref:{}) - {}".for... | [
"def",
"recv",
"(",
"self",
",",
"message",
",",
"ref",
",",
"pos",
")",
":",
"# Get action",
"action",
"=",
"message",
".",
"get",
"(",
"'action'",
",",
"None",
")",
"# Show the message we got",
"if",
"action",
"!=",
"'pingdog'",
":",
"self",
".",
"debu... | Called when a message is received with decoded JSON content | [
"Called",
"when",
"a",
"message",
"is",
"received",
"with",
"decoded",
"JSON",
"content"
] | python | train | 52.97561 |
katerina7479/pypdflite | pypdflite/pdfobjects/pdftransforms.py | https://github.com/katerina7479/pypdflite/blob/ac2501f30d6619eae9dea5644717575ca9263d0a/pypdflite/pdfobjects/pdftransforms.py#L56-L61 | def absolute_position(self, x, y):
"""return the absolute position of x,y in user space w.r.t. default user space"""
(a, b, c, d, e, f) = self._currentMatrix
xp = a * x + c * y + e
yp = b * x + d * y + f
return xp, yp | [
"def",
"absolute_position",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"(",
"a",
",",
"b",
",",
"c",
",",
"d",
",",
"e",
",",
"f",
")",
"=",
"self",
".",
"_currentMatrix",
"xp",
"=",
"a",
"*",
"x",
"+",
"c",
"*",
"y",
"+",
"e",
"yp",
"=",... | return the absolute position of x,y in user space w.r.t. default user space | [
"return",
"the",
"absolute",
"position",
"of",
"x",
"y",
"in",
"user",
"space",
"w",
".",
"r",
".",
"t",
".",
"default",
"user",
"space"
] | python | test | 42 |
bspaans/python-mingus | mingus/midi/pyfluidsynth.py | https://github.com/bspaans/python-mingus/blob/aa5a5d992d45ada61be0f9f86261380731bd7749/mingus/midi/pyfluidsynth.py#L214-L222 | def noteon(self, chan, key, vel):
"""Play a note."""
if key < 0 or key > 128:
return False
if chan < 0:
return False
if vel < 0 or vel > 128:
return False
return fluid_synth_noteon(self.synth, chan, key, vel) | [
"def",
"noteon",
"(",
"self",
",",
"chan",
",",
"key",
",",
"vel",
")",
":",
"if",
"key",
"<",
"0",
"or",
"key",
">",
"128",
":",
"return",
"False",
"if",
"chan",
"<",
"0",
":",
"return",
"False",
"if",
"vel",
"<",
"0",
"or",
"vel",
">",
"128... | Play a note. | [
"Play",
"a",
"note",
"."
] | python | train | 30.666667 |
coldfix/udiskie | udiskie/mount.py | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L656-L668 | def is_addable(self, device, automount=True):
"""Check if device can be added with ``auto_add``."""
if not self.is_automount(device, automount):
return False
if device.is_filesystem:
return not device.is_mounted
if device.is_crypto:
return self._prompt... | [
"def",
"is_addable",
"(",
"self",
",",
"device",
",",
"automount",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"is_automount",
"(",
"device",
",",
"automount",
")",
":",
"return",
"False",
"if",
"device",
".",
"is_filesystem",
":",
"return",
"not",
... | Check if device can be added with ``auto_add``. | [
"Check",
"if",
"device",
"can",
"be",
"added",
"with",
"auto_add",
"."
] | python | train | 42.692308 |
brocade/pynos | pynos/versions/ver_7/ver_7_1_0/yang/brocade_notification_stream.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_notification_stream.py#L211-L221 | def RIBNextHopLimitExceeded_originator_switch_info_switchIdentifier(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
RIBNextHopLimitExceeded = ET.SubElement(config, "RIBNextHopLimitExceeded", xmlns="http://brocade.com/ns/brocade-notification-stream")
orig... | [
"def",
"RIBNextHopLimitExceeded_originator_switch_info_switchIdentifier",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"RIBNextHopLimitExceeded",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"R... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 57.636364 |
KelSolaar/Umbra | umbra/ui/widgets/notification_QLabel.py | https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/ui/widgets/notification_QLabel.py#L462-L473 | def fade_speed(self, value):
"""
Setter for **self.__fade_speed** attribute.
:param value: Attribute value.
:type value: float
"""
if value is not None:
assert type(value) is float, "'{0}' attribute: '{1}' type is not 'float'!".format("fade_speed", value)
... | [
"def",
"fade_speed",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"assert",
"type",
"(",
"value",
")",
"is",
"float",
",",
"\"'{0}' attribute: '{1}' type is not 'float'!\"",
".",
"format",
"(",
"\"fade_speed\"",
",",
"value",
... | Setter for **self.__fade_speed** attribute.
:param value: Attribute value.
:type value: float | [
"Setter",
"for",
"**",
"self",
".",
"__fade_speed",
"**",
"attribute",
"."
] | python | train | 37.75 |
h2oai/h2o-3 | scripts/jira.py | https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/scripts/jira.py#L313-L337 | def main(argv):
"""
Main program.
@return: none
"""
global g_script_name
g_script_name = os.path.basename(argv[0])
parse_config_file()
parse_args(argv)
url = 'https://0xdata.atlassian.net/rest/api/2/search?jql=sprint="' + urllib.quote(g_sprint) + '"&maxResults=1000'
r = reques... | [
"def",
"main",
"(",
"argv",
")",
":",
"global",
"g_script_name",
"g_script_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"argv",
"[",
"0",
"]",
")",
"parse_config_file",
"(",
")",
"parse_args",
"(",
"argv",
")",
"url",
"=",
"'https://0xdata.atlassia... | Main program.
@return: none | [
"Main",
"program",
"."
] | python | test | 23.44 |
danpoland/pyramid-restful-framework | pyramid_restful/routers.py | https://github.com/danpoland/pyramid-restful-framework/blob/4d8c9db44b1869c3d1fdd59ca304c3166473fcbb/pyramid_restful/routers.py#L87-L122 | def register(self, prefix, viewset, basename, factory=None, permission=None):
"""
Factory and permission are likely only going to exist until I have enough time
to write a permissions module for PRF.
:param prefix: the uri route prefix.
:param viewset: The ViewSet class to route... | [
"def",
"register",
"(",
"self",
",",
"prefix",
",",
"viewset",
",",
"basename",
",",
"factory",
"=",
"None",
",",
"permission",
"=",
"None",
")",
":",
"lookup",
"=",
"self",
".",
"get_lookup",
"(",
"viewset",
")",
"routes",
"=",
"self",
".",
"get_route... | Factory and permission are likely only going to exist until I have enough time
to write a permissions module for PRF.
:param prefix: the uri route prefix.
:param viewset: The ViewSet class to route.
:param basename: Used to name the route in pyramid.
:param factory: Optional, ro... | [
"Factory",
"and",
"permission",
"are",
"likely",
"only",
"going",
"to",
"exist",
"until",
"I",
"have",
"enough",
"time",
"to",
"write",
"a",
"permissions",
"module",
"for",
"PRF",
"."
] | python | train | 38.416667 |
xeroc/python-graphenelib | graphenestorage/masterpassword.py | https://github.com/xeroc/python-graphenelib/blob/8bb5396bc79998ee424cf3813af478304173f3a6/graphenestorage/masterpassword.py#L55-L70 | def unlocked(self):
""" Is the store unlocked so that I can decrypt the content?
"""
if self.password is not None:
return bool(self.password)
else:
if (
"UNLOCK" in os.environ
and os.environ["UNLOCK"]
and self.config... | [
"def",
"unlocked",
"(",
"self",
")",
":",
"if",
"self",
".",
"password",
"is",
"not",
"None",
":",
"return",
"bool",
"(",
"self",
".",
"password",
")",
"else",
":",
"if",
"(",
"\"UNLOCK\"",
"in",
"os",
".",
"environ",
"and",
"os",
".",
"environ",
"... | Is the store unlocked so that I can decrypt the content? | [
"Is",
"the",
"store",
"unlocked",
"so",
"that",
"I",
"can",
"decrypt",
"the",
"content?"
] | python | valid | 37 |
sci-bots/mpm | mpm/api.py | https://github.com/sci-bots/mpm/blob/a69651cda4b37ee6b17df4fe0809249e7f4dc536/mpm/api.py#L240-L299 | def rollback(*args, **kwargs):
'''
Restore previous revision of Conda environment according to most recent
action in :attr:`MICRODROP_CONDA_ACTIONS`.
.. versionchanged:: 0.18
Add support for action revision files compressed using ``bz2``.
.. versionchanged:: 0.24
Remove channels ar... | [
"def",
"rollback",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"action_files",
"=",
"MICRODROP_CONDA_ACTIONS",
".",
"files",
"(",
")",
"if",
"not",
"action_files",
":",
"# No action files, return current revision.",
"logger",
".",
"debug",
"(",
"'No rol... | Restore previous revision of Conda environment according to most recent
action in :attr:`MICRODROP_CONDA_ACTIONS`.
.. versionchanged:: 0.18
Add support for action revision files compressed using ``bz2``.
.. versionchanged:: 0.24
Remove channels argument. Use Conda channels as configured i... | [
"Restore",
"previous",
"revision",
"of",
"Conda",
"environment",
"according",
"to",
"most",
"recent",
"action",
"in",
":",
"attr",
":",
"MICRODROP_CONDA_ACTIONS",
"."
] | python | train | 38.666667 |
data-8/datascience | datascience/tables.py | https://github.com/data-8/datascience/blob/4cee38266903ca169cea4a53b8cc39502d85c464/datascience/tables.py#L1177-L1274 | def join(self, column_label, other, other_label=None):
"""Creates a new table with the columns of self and other, containing
rows for all values of a column that appear in both tables.
Args:
``column_label`` (``str``): label of column in self that is used to
join r... | [
"def",
"join",
"(",
"self",
",",
"column_label",
",",
"other",
",",
"other_label",
"=",
"None",
")",
":",
"if",
"self",
".",
"num_rows",
"==",
"0",
"or",
"other",
".",
"num_rows",
"==",
"0",
":",
"return",
"None",
"if",
"not",
"other_label",
":",
"ot... | Creates a new table with the columns of self and other, containing
rows for all values of a column that appear in both tables.
Args:
``column_label`` (``str``): label of column in self that is used to
join rows of ``other``.
``other``: Table object to join with... | [
"Creates",
"a",
"new",
"table",
"with",
"the",
"columns",
"of",
"self",
"and",
"other",
"containing",
"rows",
"for",
"all",
"values",
"of",
"a",
"column",
"that",
"appear",
"in",
"both",
"tables",
"."
] | python | train | 37.438776 |
firstprayer/monsql | monsql/db.py | https://github.com/firstprayer/monsql/blob/6285c15b574c8664046eae2edfeb548c7b173efd/monsql/db.py#L109-L136 | def create_table(self, tablename, columns, primary_key=None, force_recreate=False):
"""
:Parameters:
- tablename: string
- columns: list or tuples, with each element be a string like 'id INT NOT NULL UNIQUE'
- primary_key: list or tuples, with elements be the column names
... | [
"def",
"create_table",
"(",
"self",
",",
"tablename",
",",
"columns",
",",
"primary_key",
"=",
"None",
",",
"force_recreate",
"=",
"False",
")",
":",
"if",
"self",
".",
"is_table_existed",
"(",
"tablename",
")",
":",
"if",
"force_recreate",
":",
"self",
".... | :Parameters:
- tablename: string
- columns: list or tuples, with each element be a string like 'id INT NOT NULL UNIQUE'
- primary_key: list or tuples, with elements be the column names
- force_recreate: When table of the same name already exists, if this is True, drop that table; if Fal... | [
":",
"Parameters",
":"
] | python | train | 38.107143 |
SheffieldML/GPy | GPy/util/datasets.py | https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/util/datasets.py#L360-L400 | def football_data(season='1314', data_set='football_data'):
"""Football data from English games since 1993. This downloads data from football-data.co.uk for the given season. """
def league2num(string):
league_dict = {'E0':0, 'E1':1, 'E2': 2, 'E3': 3, 'EC':4}
return league_dict[string]
def ... | [
"def",
"football_data",
"(",
"season",
"=",
"'1314'",
",",
"data_set",
"=",
"'football_data'",
")",
":",
"def",
"league2num",
"(",
"string",
")",
":",
"league_dict",
"=",
"{",
"'E0'",
":",
"0",
",",
"'E1'",
":",
"1",
",",
"'E2'",
":",
"2",
",",
"'E3'... | Football data from English games since 1993. This downloads data from football-data.co.uk for the given season. | [
"Football",
"data",
"from",
"English",
"games",
"since",
"1993",
".",
"This",
"downloads",
"data",
"from",
"football",
"-",
"data",
".",
"co",
".",
"uk",
"for",
"the",
"given",
"season",
"."
] | python | train | 44.487805 |
jazzband/django-pipeline | pipeline/templatetags/pipeline.py | https://github.com/jazzband/django-pipeline/blob/3cd2f93bb47bf8d34447e13ff691f7027e7b07a2/pipeline/templatetags/pipeline.py#L56-L72 | def render_compressed(self, package, package_name, package_type):
"""Render HTML for the package.
If ``PIPELINE_ENABLED`` is ``True``, this will render the package's
output file (using :py:meth:`render_compressed_output`). Otherwise,
this will render the package's source files (using
... | [
"def",
"render_compressed",
"(",
"self",
",",
"package",
",",
"package_name",
",",
"package_type",
")",
":",
"if",
"settings",
".",
"PIPELINE_ENABLED",
":",
"return",
"self",
".",
"render_compressed_output",
"(",
"package",
",",
"package_name",
",",
"package_type"... | Render HTML for the package.
If ``PIPELINE_ENABLED`` is ``True``, this will render the package's
output file (using :py:meth:`render_compressed_output`). Otherwise,
this will render the package's source files (using
:py:meth:`render_compressed_sources`).
Subclasses can override... | [
"Render",
"HTML",
"for",
"the",
"package",
"."
] | python | train | 46.823529 |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/nose/plugins/failuredetail.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/nose/plugins/failuredetail.py#L29-L35 | def configure(self, options, conf):
"""Configure plugin.
"""
if not self.can_configure:
return
self.enabled = options.detailedErrors
self.conf = conf | [
"def",
"configure",
"(",
"self",
",",
"options",
",",
"conf",
")",
":",
"if",
"not",
"self",
".",
"can_configure",
":",
"return",
"self",
".",
"enabled",
"=",
"options",
".",
"detailedErrors",
"self",
".",
"conf",
"=",
"conf"
] | Configure plugin. | [
"Configure",
"plugin",
"."
] | python | test | 27.857143 |
jldantas/libmft | libmft/attribute.py | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L1427-L1437 | def _allocated_entries_bitmap(self):
'''Creates a generator that returns all allocated entries in the
bitmap.
Yields:
int: The bit index of the allocated entries.
'''
for entry_number in range(len(self._bitmap) * 8):
if self.entry_allocated(entry_number):
yield entry_nu... | [
"def",
"_allocated_entries_bitmap",
"(",
"self",
")",
":",
"for",
"entry_number",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"_bitmap",
")",
"*",
"8",
")",
":",
"if",
"self",
".",
"entry_allocated",
"(",
"entry_number",
")",
":",
"yield",
"entry_number"
... | Creates a generator that returns all allocated entries in the
bitmap.
Yields:
int: The bit index of the allocated entries. | [
"Creates",
"a",
"generator",
"that",
"returns",
"all",
"allocated",
"entries",
"in",
"the",
"bitmap",
"."
] | python | train | 28.545455 |
wonambi-python/wonambi | wonambi/detect/spindle.py | https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/detect/spindle.py#L1054-L1125 | def detect_Concordia(dat_orig, s_freq, time, opts):
"""Spindle detection, experimental Concordia method. Similar to Moelle 2011
and Nir2011.
Parameters
----------
dat_orig : ndarray (dtype='float')
vector with the data for one channel
s_freq : float
sampling frequency
opts :... | [
"def",
"detect_Concordia",
"(",
"dat_orig",
",",
"s_freq",
",",
"time",
",",
"opts",
")",
":",
"dat_det",
"=",
"transform_signal",
"(",
"dat_orig",
",",
"s_freq",
",",
"'butter'",
",",
"opts",
".",
"det_butter",
")",
"dat_det",
"=",
"transform_signal",
"(",
... | Spindle detection, experimental Concordia method. Similar to Moelle 2011
and Nir2011.
Parameters
----------
dat_orig : ndarray (dtype='float')
vector with the data for one channel
s_freq : float
sampling frequency
opts : instance of 'DetectSpindle'
'det_butter' : dict
... | [
"Spindle",
"detection",
"experimental",
"Concordia",
"method",
".",
"Similar",
"to",
"Moelle",
"2011",
"and",
"Nir2011",
"."
] | python | train | 35.375 |
manns/pyspread | pyspread/src/gui/_main_window.py | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_main_window.py#L726-L734 | def OnTableListToggle(self, event):
"""Table list toggle event handler"""
table_list_panel_info = \
self.main_window._mgr.GetPane("table_list_panel")
self._toggle_pane(table_list_panel_info)
event.Skip() | [
"def",
"OnTableListToggle",
"(",
"self",
",",
"event",
")",
":",
"table_list_panel_info",
"=",
"self",
".",
"main_window",
".",
"_mgr",
".",
"GetPane",
"(",
"\"table_list_panel\"",
")",
"self",
".",
"_toggle_pane",
"(",
"table_list_panel_info",
")",
"event",
"."... | Table list toggle event handler | [
"Table",
"list",
"toggle",
"event",
"handler"
] | python | train | 26.888889 |
quantopian/pgcontents | pgcontents/query.py | https://github.com/quantopian/pgcontents/blob/ed36268b7917332d16868208e1e565742a8753e1/pgcontents/query.py#L867-L876 | def select_file_ids(db, user_id):
"""
Get all file ids for a user.
"""
return list(
db.execute(
select([files.c.id])
.where(files.c.user_id == user_id)
)
) | [
"def",
"select_file_ids",
"(",
"db",
",",
"user_id",
")",
":",
"return",
"list",
"(",
"db",
".",
"execute",
"(",
"select",
"(",
"[",
"files",
".",
"c",
".",
"id",
"]",
")",
".",
"where",
"(",
"files",
".",
"c",
".",
"user_id",
"==",
"user_id",
")... | Get all file ids for a user. | [
"Get",
"all",
"file",
"ids",
"for",
"a",
"user",
"."
] | python | test | 20.6 |
potash/drain | drain/step.py | https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/step.py#L26-L56 | def load(steps, reload=False):
"""
safely load steps in place, excluding those that fail
Args:
steps: the steps to load
"""
# work on collections by default for fewer isinstance() calls per call to load()
if reload:
_STEP_CACHE.clear()
if callable(steps):
steps = ste... | [
"def",
"load",
"(",
"steps",
",",
"reload",
"=",
"False",
")",
":",
"# work on collections by default for fewer isinstance() calls per call to load()",
"if",
"reload",
":",
"_STEP_CACHE",
".",
"clear",
"(",
")",
"if",
"callable",
"(",
"steps",
")",
":",
"steps",
"... | safely load steps in place, excluding those that fail
Args:
steps: the steps to load | [
"safely",
"load",
"steps",
"in",
"place",
"excluding",
"those",
"that",
"fail",
"Args",
":",
"steps",
":",
"the",
"steps",
"to",
"load"
] | python | train | 26.774194 |
tanghaibao/jcvi | jcvi/formats/agp.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/formats/agp.py#L277-L282 | def transfer_header(self, fw=sys.stdout):
"""
transfer_header() copies header to a new file.
print_header() creates a new header.
"""
print("\n".join(self.header), file=fw) | [
"def",
"transfer_header",
"(",
"self",
",",
"fw",
"=",
"sys",
".",
"stdout",
")",
":",
"print",
"(",
"\"\\n\"",
".",
"join",
"(",
"self",
".",
"header",
")",
",",
"file",
"=",
"fw",
")"
] | transfer_header() copies header to a new file.
print_header() creates a new header. | [
"transfer_header",
"()",
"copies",
"header",
"to",
"a",
"new",
"file",
".",
"print_header",
"()",
"creates",
"a",
"new",
"header",
"."
] | python | train | 34.5 |
codelv/enaml-native | src/enamlnative/core/app.py | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/core/app.py#L34-L41 | def load(self):
""" Load the object defined by the plugin entry point """
print("[DEBUG] Loading plugin {} from {}".format(self.name,
self.source))
import pydoc
path, attr = self.source.split(":")
module = pydoc.locate(path... | [
"def",
"load",
"(",
"self",
")",
":",
"print",
"(",
"\"[DEBUG] Loading plugin {} from {}\"",
".",
"format",
"(",
"self",
".",
"name",
",",
"self",
".",
"source",
")",
")",
"import",
"pydoc",
"path",
",",
"attr",
"=",
"self",
".",
"source",
".",
"split",
... | Load the object defined by the plugin entry point | [
"Load",
"the",
"object",
"defined",
"by",
"the",
"plugin",
"entry",
"point"
] | python | train | 43.875 |
Robpol86/sphinxcontrib-versioning | sphinxcontrib/versioning/lib.py | https://github.com/Robpol86/sphinxcontrib-versioning/blob/920edec0ac764081b583a2ecf4e6952762b9dbf2/sphinxcontrib/versioning/lib.py#L102-L125 | def update(self, params, ignore_set=False, overwrite=False):
"""Set instance values from dictionary.
:param dict params: Click context params.
:param bool ignore_set: Skip already-set values instead of raising AttributeError.
:param bool overwrite: Allow overwriting already-set values.
... | [
"def",
"update",
"(",
"self",
",",
"params",
",",
"ignore_set",
"=",
"False",
",",
"overwrite",
"=",
"False",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"valid",
"=",
"{",
"i",
"[",
"0",
"]",
"for",
"i",
"in",
"self",
... | Set instance values from dictionary.
:param dict params: Click context params.
:param bool ignore_set: Skip already-set values instead of raising AttributeError.
:param bool overwrite: Allow overwriting already-set values. | [
"Set",
"instance",
"values",
"from",
"dictionary",
"."
] | python | train | 51.541667 |
orlandodiaz/log3 | log3/log.py | https://github.com/orlandodiaz/log3/blob/aeedf83159be8dd3d4757e0d9240f9cdbc9c3ea2/log3/log.py#L34-L53 | def log_to_file(log_path, log_urllib=False, limit=None):
""" Add file_handler to logger"""
log_path = log_path
file_handler = logging.FileHandler(log_path)
if limit:
file_handler = RotatingFileHandler(
log_path,
mode='a',
maxBytes=limit * 1024 * 1024,
... | [
"def",
"log_to_file",
"(",
"log_path",
",",
"log_urllib",
"=",
"False",
",",
"limit",
"=",
"None",
")",
":",
"log_path",
"=",
"log_path",
"file_handler",
"=",
"logging",
".",
"FileHandler",
"(",
"log_path",
")",
"if",
"limit",
":",
"file_handler",
"=",
"Ro... | Add file_handler to logger | [
"Add",
"file_handler",
"to",
"logger"
] | python | train | 36 |
JoeVirtual/KonFoo | konfoo/core.py | https://github.com/JoeVirtual/KonFoo/blob/0c62ef5c2bed4deaf908b34082e4de2544532fdc/konfoo/core.py#L5200-L5234 | def deserialize(self, buffer=bytes(), index=Index(), **options):
""" De-serializes the `Pointer` field from the byte *buffer* starting
at the begin of the *buffer* or with the given *index* by mapping the
bytes to the :attr:`value` of the `Pointer` field in accordance with
the decoding *... | [
"def",
"deserialize",
"(",
"self",
",",
"buffer",
"=",
"bytes",
"(",
")",
",",
"index",
"=",
"Index",
"(",
")",
",",
"*",
"*",
"options",
")",
":",
"# Field",
"index",
"=",
"super",
"(",
")",
".",
"deserialize",
"(",
"buffer",
",",
"index",
",",
... | De-serializes the `Pointer` field from the byte *buffer* starting
at the begin of the *buffer* or with the given *index* by mapping the
bytes to the :attr:`value` of the `Pointer` field in accordance with
the decoding *byte order* for the de-serialization and the decoding
:attr:`byte_ord... | [
"De",
"-",
"serializes",
"the",
"Pointer",
"field",
"from",
"the",
"byte",
"*",
"buffer",
"*",
"starting",
"at",
"the",
"begin",
"of",
"the",
"*",
"buffer",
"*",
"or",
"with",
"the",
"given",
"*",
"index",
"*",
"by",
"mapping",
"the",
"bytes",
"to",
... | python | train | 51.628571 |
GetmeUK/MongoFrames | mongoframes/frames.py | https://github.com/GetmeUK/MongoFrames/blob/7d2bd792235dfa77a9deecab5366f5f73480823d/mongoframes/frames.py#L56-L63 | def to_json_type(self):
"""
Return a dictionary for the document with values converted to JSON safe
types.
"""
document_dict = self._json_safe(self._document)
self._remove_keys(document_dict, self._private_fields)
return document_dict | [
"def",
"to_json_type",
"(",
"self",
")",
":",
"document_dict",
"=",
"self",
".",
"_json_safe",
"(",
"self",
".",
"_document",
")",
"self",
".",
"_remove_keys",
"(",
"document_dict",
",",
"self",
".",
"_private_fields",
")",
"return",
"document_dict"
] | Return a dictionary for the document with values converted to JSON safe
types. | [
"Return",
"a",
"dictionary",
"for",
"the",
"document",
"with",
"values",
"converted",
"to",
"JSON",
"safe",
"types",
"."
] | python | train | 35.375 |
jrspruitt/ubi_reader | ubireader/utils.py | https://github.com/jrspruitt/ubi_reader/blob/7079dd380c1c9896bced30d6d34e8780b9181597/ubireader/utils.py#L131-L186 | def guess_peb_size(path):
"""Determine the most likely block size
Arguments:
Str:path -- Path to file.
Returns:
Int -- PEB size.
Searches file for Magic Number, picks most
common length between them.
"""
file_offset = 0
offsets = []
f = open(path, '... | [
"def",
"guess_peb_size",
"(",
"path",
")",
":",
"file_offset",
"=",
"0",
"offsets",
"=",
"[",
"]",
"f",
"=",
"open",
"(",
"path",
",",
"'rb'",
")",
"f",
".",
"seek",
"(",
"0",
",",
"2",
")",
"file_size",
"=",
"f",
".",
"tell",
"(",
")",
"+",
... | Determine the most likely block size
Arguments:
Str:path -- Path to file.
Returns:
Int -- PEB size.
Searches file for Magic Number, picks most
common length between them. | [
"Determine",
"the",
"most",
"likely",
"block",
"size"
] | python | train | 21.821429 |
MycroftAI/mycroft-precise | precise/scripts/train_generated.py | https://github.com/MycroftAI/mycroft-precise/blob/e17cebdd171906dbd8a16e282d8a7966fba2eeba/precise/scripts/train_generated.py#L226-L237 | def run(self):
"""Train the model on randomly generated batches"""
_, test_data = self.data.load(train=False, test=True)
try:
self.model.fit_generator(
self.samples_to_batches(self.generate_samples(), self.args.batch_size), steps_per_epoch=self.args.steps_per_epoch,
... | [
"def",
"run",
"(",
"self",
")",
":",
"_",
",",
"test_data",
"=",
"self",
".",
"data",
".",
"load",
"(",
"train",
"=",
"False",
",",
"test",
"=",
"True",
")",
"try",
":",
"self",
".",
"model",
".",
"fit_generator",
"(",
"self",
".",
"samples_to_batc... | Train the model on randomly generated batches | [
"Train",
"the",
"model",
"on",
"randomly",
"generated",
"batches"
] | python | train | 47.666667 |
rdireen/spherepy | spherepy/file.py | https://github.com/rdireen/spherepy/blob/241521401d4d76851d4a1a564a365cfab8e98496/spherepy/file.py#L208-L248 | def load_vcoef(filename):
"""Loads a set of vector coefficients that were saved in MATLAB. The third
number on the first line is the directivity calculated within the MATLAB
code."""
with open(filename) as f:
lines = f.readlines()
lst = lines[0].split(',')
nmax = int(lst[0])
... | [
"def",
"load_vcoef",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"f",
":",
"lines",
"=",
"f",
".",
"readlines",
"(",
")",
"lst",
"=",
"lines",
"[",
"0",
"]",
".",
"split",
"(",
"','",
")",
"nmax",
"=",
"int",
"(",
"ls... | Loads a set of vector coefficients that were saved in MATLAB. The third
number on the first line is the directivity calculated within the MATLAB
code. | [
"Loads",
"a",
"set",
"of",
"vector",
"coefficients",
"that",
"were",
"saved",
"in",
"MATLAB",
".",
"The",
"third",
"number",
"on",
"the",
"first",
"line",
"is",
"the",
"directivity",
"calculated",
"within",
"the",
"MATLAB",
"code",
"."
] | python | train | 25.219512 |
dshean/pygeotools | pygeotools/lib/timelib.py | https://github.com/dshean/pygeotools/blob/5ac745717c0098d01eb293ff1fe32fd7358c76ab/pygeotools/lib/timelib.py#L226-L236 | def get_closest_dt_padded_idx(dt, dt_list, pad=timedelta(days=30)):
"""Get indices of dt_list that is closest to input dt +/- pad days
"""
#If pad is in decimal days
if not isinstance(pad, timedelta):
pad = timedelta(days=pad)
from pygeotools.lib import malib
dt_list = malib.checkma(dt_l... | [
"def",
"get_closest_dt_padded_idx",
"(",
"dt",
",",
"dt_list",
",",
"pad",
"=",
"timedelta",
"(",
"days",
"=",
"30",
")",
")",
":",
"#If pad is in decimal days",
"if",
"not",
"isinstance",
"(",
"pad",
",",
"timedelta",
")",
":",
"pad",
"=",
"timedelta",
"(... | Get indices of dt_list that is closest to input dt +/- pad days | [
"Get",
"indices",
"of",
"dt_list",
"that",
"is",
"closest",
"to",
"input",
"dt",
"+",
"/",
"-",
"pad",
"days"
] | python | train | 39.181818 |
AndrewAnnex/SpiceyPy | spiceypy/spiceypy.py | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L14430-L14445 | def utc2et(utcstr):
"""
Convert an input time from Calendar or Julian Date format, UTC,
to ephemeris seconds past J2000.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/utc2et_c.html
:param utcstr: Input time string, UTC.
:type utcstr: str
:return: Output epoch, ephemeris seconds ... | [
"def",
"utc2et",
"(",
"utcstr",
")",
":",
"utcstr",
"=",
"stypes",
".",
"stringToCharP",
"(",
"utcstr",
")",
"et",
"=",
"ctypes",
".",
"c_double",
"(",
")",
"libspice",
".",
"utc2et_c",
"(",
"utcstr",
",",
"ctypes",
".",
"byref",
"(",
"et",
")",
")",... | Convert an input time from Calendar or Julian Date format, UTC,
to ephemeris seconds past J2000.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/utc2et_c.html
:param utcstr: Input time string, UTC.
:type utcstr: str
:return: Output epoch, ephemeris seconds past J2000.
:rtype: float | [
"Convert",
"an",
"input",
"time",
"from",
"Calendar",
"or",
"Julian",
"Date",
"format",
"UTC",
"to",
"ephemeris",
"seconds",
"past",
"J2000",
"."
] | python | train | 29.9375 |
StackStorm/pybind | pybind/nos/v6_0_2f/rmon/alarm_entry/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/rmon/alarm_entry/__init__.py#L368-L389 | def _set_alarm_owner(self, v, load=False):
"""
Setter method for alarm_owner, mapped from YANG variable /rmon/alarm_entry/alarm_owner (owner-string)
If this variable is read-only (config: false) in the
source YANG file, then _set_alarm_owner is considered as a private
method. Backends looking to pop... | [
"def",
"_set_alarm_owner",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"ba... | Setter method for alarm_owner, mapped from YANG variable /rmon/alarm_entry/alarm_owner (owner-string)
If this variable is read-only (config: false) in the
source YANG file, then _set_alarm_owner is considered as a private
method. Backends looking to populate this variable should
do so via calling thisOb... | [
"Setter",
"method",
"for",
"alarm_owner",
"mapped",
"from",
"YANG",
"variable",
"/",
"rmon",
"/",
"alarm_entry",
"/",
"alarm_owner",
"(",
"owner",
"-",
"string",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
... | python | train | 86.272727 |
StagPython/StagPy | stagpy/time_series.py | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/time_series.py#L153-L178 | def cmd():
"""Implementation of time subcommand.
Other Parameters:
conf.time
conf.core
"""
sdat = StagyyData(conf.core.path)
if sdat.tseries is None:
return
if conf.time.fraction is not None:
if not 0 < conf.time.fraction <= 1:
raise InvalidTimeFract... | [
"def",
"cmd",
"(",
")",
":",
"sdat",
"=",
"StagyyData",
"(",
"conf",
".",
"core",
".",
"path",
")",
"if",
"sdat",
".",
"tseries",
"is",
"None",
":",
"return",
"if",
"conf",
".",
"time",
".",
"fraction",
"is",
"not",
"None",
":",
"if",
"not",
"0",... | Implementation of time subcommand.
Other Parameters:
conf.time
conf.core | [
"Implementation",
"of",
"time",
"subcommand",
"."
] | python | train | 28.384615 |
uw-it-aca/uw-restclients-canvas | uw_canvas/analytics.py | https://github.com/uw-it-aca/uw-restclients-canvas/blob/9845faf33d49a8f06908efc22640c001116d6ea2/uw_canvas/analytics.py#L27-L35 | def get_statistics_by_account(self, account_id, term_id):
"""
Returns statistics for the given account_id and term_id.
https://canvas.instructure.com/doc/api/analytics.html#method.analytics_api.department_statistics
"""
url = ("/api/v1/accounts/sis_account_id:%s/analytics/"
... | [
"def",
"get_statistics_by_account",
"(",
"self",
",",
"account_id",
",",
"term_id",
")",
":",
"url",
"=",
"(",
"\"/api/v1/accounts/sis_account_id:%s/analytics/\"",
"\"terms/sis_term_id:%s/statistics.json\"",
")",
"%",
"(",
"account_id",
",",
"term_id",
")",
"return",
"s... | Returns statistics for the given account_id and term_id.
https://canvas.instructure.com/doc/api/analytics.html#method.analytics_api.department_statistics | [
"Returns",
"statistics",
"for",
"the",
"given",
"account_id",
"and",
"term_id",
"."
] | python | test | 47.222222 |
neo4j/neo4j-python-driver | neo4j/blocking.py | https://github.com/neo4j/neo4j-python-driver/blob/0c641e826765e86ff5454dae57c99521db8ca45c/neo4j/blocking.py#L653-L662 | def detach(self, sync=True):
""" Detach this result from its parent session by fetching the
remainder of this result from the network into the buffer.
:returns: number of records fetched
"""
if self.attached():
return self._session.detach(self, sync=sync)
els... | [
"def",
"detach",
"(",
"self",
",",
"sync",
"=",
"True",
")",
":",
"if",
"self",
".",
"attached",
"(",
")",
":",
"return",
"self",
".",
"_session",
".",
"detach",
"(",
"self",
",",
"sync",
"=",
"sync",
")",
"else",
":",
"return",
"0"
] | Detach this result from its parent session by fetching the
remainder of this result from the network into the buffer.
:returns: number of records fetched | [
"Detach",
"this",
"result",
"from",
"its",
"parent",
"session",
"by",
"fetching",
"the",
"remainder",
"of",
"this",
"result",
"from",
"the",
"network",
"into",
"the",
"buffer",
"."
] | python | train | 33.4 |
ryan-roemer/django-cloud-browser | cloud_browser/cloud/google.py | https://github.com/ryan-roemer/django-cloud-browser/blob/b06cdd24885a6309e843ed924dbf1705b67e7f48/cloud_browser/cloud/google.py#L67-L75 | def from_prefix(cls, container, prefix):
"""Create from prefix object."""
if cls._is_gs_folder(prefix):
name, suffix, extra = prefix.name.partition(cls._gs_folder_suffix)
if (suffix, extra) == (cls._gs_folder_suffix, ''):
# Patch GS specific folder to remove suffi... | [
"def",
"from_prefix",
"(",
"cls",
",",
"container",
",",
"prefix",
")",
":",
"if",
"cls",
".",
"_is_gs_folder",
"(",
"prefix",
")",
":",
"name",
",",
"suffix",
",",
"extra",
"=",
"prefix",
".",
"name",
".",
"partition",
"(",
"cls",
".",
"_gs_folder_suf... | Create from prefix object. | [
"Create",
"from",
"prefix",
"object",
"."
] | python | train | 46.333333 |
wandb/client | wandb/apis/internal.py | https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/apis/internal.py#L766-L803 | def download_url(self, project, file_name, run=None, entity=None):
"""Generate download urls
Args:
project (str): The project to download
file_name (str): The name of the file to download
run (str, optional): The run to upload to
entity (str, optional): T... | [
"def",
"download_url",
"(",
"self",
",",
"project",
",",
"file_name",
",",
"run",
"=",
"None",
",",
"entity",
"=",
"None",
")",
":",
"query",
"=",
"gql",
"(",
"'''\n query Model($name: String!, $fileName: String!, $entity: String!, $run: String!) {\n mo... | Generate download urls
Args:
project (str): The project to download
file_name (str): The name of the file to download
run (str, optional): The run to upload to
entity (str, optional): The entity to scope this project to. Defaults to wandb models
Returns... | [
"Generate",
"download",
"urls"
] | python | train | 39.789474 |
saltstack/salt | salt/modules/swift.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/swift.py#L179-L202 | def put(cont, path=None, local_file=None, profile=None):
'''
Create a new container, or upload an object to a container.
CLI Example to create a container:
.. code-block:: bash
salt myminion swift.put mycontainer
CLI Example to upload an object to a container:
.. code-block:: bash
... | [
"def",
"put",
"(",
"cont",
",",
"path",
"=",
"None",
",",
"local_file",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"swift_conn",
"=",
"_auth",
"(",
"profile",
")",
"if",
"path",
"is",
"None",
":",
"return",
"swift_conn",
".",
"put_container",
... | Create a new container, or upload an object to a container.
CLI Example to create a container:
.. code-block:: bash
salt myminion swift.put mycontainer
CLI Example to upload an object to a container:
.. code-block:: bash
salt myminion swift.put mycontainer remotepath local_file=/pa... | [
"Create",
"a",
"new",
"container",
"or",
"upload",
"an",
"object",
"to",
"a",
"container",
"."
] | python | train | 25.375 |
dotzero/tilda-api-python | tilda/client.py | https://github.com/dotzero/tilda-api-python/blob/0ab984e0236cbfb676b0fbddc1ab37202d92e0a8/tilda/client.py#L92-L99 | def get_project_export(self, project_id):
""" Get project info for export """
try:
result = self._request('/getprojectexport/',
{'projectid': project_id})
return TildaProject(**result)
except NetworkError:
return [] | [
"def",
"get_project_export",
"(",
"self",
",",
"project_id",
")",
":",
"try",
":",
"result",
"=",
"self",
".",
"_request",
"(",
"'/getprojectexport/'",
",",
"{",
"'projectid'",
":",
"project_id",
"}",
")",
"return",
"TildaProject",
"(",
"*",
"*",
"result",
... | Get project info for export | [
"Get",
"project",
"info",
"for",
"export"
] | python | train | 37.875 |
inasafe/inasafe | safe/gis/vector/tools.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gis/vector/tools.py#L265-L283 | def remove_fields(layer, fields_to_remove):
"""Remove fields from a vector layer.
:param layer: The vector layer.
:type layer: QgsVectorLayer
:param fields_to_remove: List of fields to remove.
:type fields_to_remove: list
"""
index_to_remove = []
data_provider = layer.dataProvider()
... | [
"def",
"remove_fields",
"(",
"layer",
",",
"fields_to_remove",
")",
":",
"index_to_remove",
"=",
"[",
"]",
"data_provider",
"=",
"layer",
".",
"dataProvider",
"(",
")",
"for",
"field",
"in",
"fields_to_remove",
":",
"index",
"=",
"layer",
".",
"fields",
"(",... | Remove fields from a vector layer.
:param layer: The vector layer.
:type layer: QgsVectorLayer
:param fields_to_remove: List of fields to remove.
:type fields_to_remove: list | [
"Remove",
"fields",
"from",
"a",
"vector",
"layer",
"."
] | python | train | 27.842105 |
bwohlberg/sporco | sporco/util.py | https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/util.py#L433-L449 | def rgb2gray(rgb):
"""Convert an RGB image (or images) to grayscale.
Parameters
----------
rgb : ndarray
RGB image as Nr x Nc x 3 or Nr x Nc x 3 x K array
Returns
-------
gry : ndarray
Grayscale image as Nr x Nc or Nr x Nc x K array
"""
w = sla.atleast_nd(rgb.ndim, np.... | [
"def",
"rgb2gray",
"(",
"rgb",
")",
":",
"w",
"=",
"sla",
".",
"atleast_nd",
"(",
"rgb",
".",
"ndim",
",",
"np",
".",
"array",
"(",
"[",
"0.299",
",",
"0.587",
",",
"0.144",
"]",
",",
"dtype",
"=",
"rgb",
".",
"dtype",
",",
"ndmin",
"=",
"3",
... | Convert an RGB image (or images) to grayscale.
Parameters
----------
rgb : ndarray
RGB image as Nr x Nc x 3 or Nr x Nc x 3 x K array
Returns
-------
gry : ndarray
Grayscale image as Nr x Nc or Nr x Nc x K array | [
"Convert",
"an",
"RGB",
"image",
"(",
"or",
"images",
")",
"to",
"grayscale",
"."
] | python | train | 25.647059 |
sorgerlab/indra | indra/tools/reading/submit_reading_pipeline.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/tools/reading/submit_reading_pipeline.py#L22-L208 | def wait_for_complete(queue_name, job_list=None, job_name_prefix=None,
poll_interval=10, idle_log_timeout=None,
kill_on_log_timeout=False, stash_log_method=None,
tag_instances=False, result_record=None):
"""Return when all jobs in the given list fini... | [
"def",
"wait_for_complete",
"(",
"queue_name",
",",
"job_list",
"=",
"None",
",",
"job_name_prefix",
"=",
"None",
",",
"poll_interval",
"=",
"10",
",",
"idle_log_timeout",
"=",
"None",
",",
"kill_on_log_timeout",
"=",
"False",
",",
"stash_log_method",
"=",
"None... | Return when all jobs in the given list finished.
If not job list is given, return when all jobs in queue finished.
Parameters
----------
queue_name : str
The name of the queue to wait for completion.
job_list : Optional[list(dict)]
A list of jobID-s in a dict, as returned by the su... | [
"Return",
"when",
"all",
"jobs",
"in",
"the",
"given",
"list",
"finished",
"."
] | python | train | 44.122995 |
openstack/networking-cisco | networking_cisco/apps/saf/server/services/firewall/native/fw_mgr.py | https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fw_mgr.py#L473-L481 | def _check_update_fw(self, tenant_id, drvr_name):
"""Update the Firewall config by calling the driver.
This function calls the device manager routine to update the device
with modified FW cfg.
"""
if self.fwid_attr[tenant_id].is_fw_complete():
fw_dict = self.fwid_att... | [
"def",
"_check_update_fw",
"(",
"self",
",",
"tenant_id",
",",
"drvr_name",
")",
":",
"if",
"self",
".",
"fwid_attr",
"[",
"tenant_id",
"]",
".",
"is_fw_complete",
"(",
")",
":",
"fw_dict",
"=",
"self",
".",
"fwid_attr",
"[",
"tenant_id",
"]",
".",
"get_... | Update the Firewall config by calling the driver.
This function calls the device manager routine to update the device
with modified FW cfg. | [
"Update",
"the",
"Firewall",
"config",
"by",
"calling",
"the",
"driver",
"."
] | python | train | 46 |
itamarst/eliot | eliot/filter.py | https://github.com/itamarst/eliot/blob/c03c96520c5492fadfc438b4b0f6336e2785ba2d/eliot/filter.py#L52-L62 | def run(self):
"""
For each incoming message, decode the JSON, evaluate expression, encode
as JSON and write that to the output file.
"""
for line in self.incoming:
message = loads(line)
result = self._evaluate(message)
if result is self._SKIP:... | [
"def",
"run",
"(",
"self",
")",
":",
"for",
"line",
"in",
"self",
".",
"incoming",
":",
"message",
"=",
"loads",
"(",
"line",
")",
"result",
"=",
"self",
".",
"_evaluate",
"(",
"message",
")",
"if",
"result",
"is",
"self",
".",
"_SKIP",
":",
"conti... | For each incoming message, decode the JSON, evaluate expression, encode
as JSON and write that to the output file. | [
"For",
"each",
"incoming",
"message",
"decode",
"the",
"JSON",
"evaluate",
"expression",
"encode",
"as",
"JSON",
"and",
"write",
"that",
"to",
"the",
"output",
"file",
"."
] | python | train | 37.636364 |
veripress/veripress | veripress/model/storages.py | https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/model/storages.py#L420-L432 | def get_tags(self):
"""
Get all tags and post count of each tag.
:return: dict_item(tag_name, Pair(count_all, count_published))
"""
posts = self.get_posts(include_draft=True)
result = {}
for post in posts:
for tag_name in set(post.tags):
... | [
"def",
"get_tags",
"(",
"self",
")",
":",
"posts",
"=",
"self",
".",
"get_posts",
"(",
"include_draft",
"=",
"True",
")",
"result",
"=",
"{",
"}",
"for",
"post",
"in",
"posts",
":",
"for",
"tag_name",
"in",
"set",
"(",
"post",
".",
"tags",
")",
":"... | Get all tags and post count of each tag.
:return: dict_item(tag_name, Pair(count_all, count_published)) | [
"Get",
"all",
"tags",
"and",
"post",
"count",
"of",
"each",
"tag",
"."
] | python | train | 35.615385 |
biocommons/hgvs | hgvs/projector.py | https://github.com/biocommons/hgvs/blob/4d16efb475e1802b2531a2f1c373e8819d8e533b/hgvs/projector.py#L44-L52 | def project_interval_forward(self, c_interval):
"""
project c_interval on the source transcript to the
destination transcript
:param c_interval: an :class:`hgvs.interval.Interval` object on the source transcript
:returns: c_interval: an :class:`hgvs.interval.Interval` object on ... | [
"def",
"project_interval_forward",
"(",
"self",
",",
"c_interval",
")",
":",
"return",
"self",
".",
"dst_tm",
".",
"g_to_c",
"(",
"self",
".",
"src_tm",
".",
"c_to_g",
"(",
"c_interval",
")",
")"
] | project c_interval on the source transcript to the
destination transcript
:param c_interval: an :class:`hgvs.interval.Interval` object on the source transcript
:returns: c_interval: an :class:`hgvs.interval.Interval` object on the destination transcript | [
"project",
"c_interval",
"on",
"the",
"source",
"transcript",
"to",
"the",
"destination",
"transcript"
] | python | train | 46.222222 |
inasafe/inasafe | safe/gui/tools/help/peta_bencana_help.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/help/peta_bencana_help.py#L44-L100 | def content():
"""Helper method that returns just the content.
This method was added so that the text could be reused in the
dock_help module.
.. versionadded:: 3.2.3
:returns: A message object without brand element.
:rtype: safe.messaging.message.Message
"""
message = m.Message()
... | [
"def",
"content",
"(",
")",
":",
"message",
"=",
"m",
".",
"Message",
"(",
")",
"paragraph",
"=",
"m",
".",
"Paragraph",
"(",
"m",
".",
"Image",
"(",
"'file:///%s/img/screenshots/'",
"'petabencana-screenshot.png'",
"%",
"resources_path",
"(",
")",
")",
",",
... | Helper method that returns just the content.
This method was added so that the text could be reused in the
dock_help module.
.. versionadded:: 3.2.3
:returns: A message object without brand element.
:rtype: safe.messaging.message.Message | [
"Helper",
"method",
"that",
"returns",
"just",
"the",
"content",
"."
] | python | train | 37.140351 |
Duke-GCB/DukeDSClient | ddsc/ddsclient.py | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/ddsclient.py#L267-L288 | def run(self, args):
"""
Gives user permission based on auth_role arg and sends email to that user.
:param args Namespace arguments parsed from the command line
"""
email = args.email # email of person to send email to
username = args.username ... | [
"def",
"run",
"(",
"self",
",",
"args",
")",
":",
"email",
"=",
"args",
".",
"email",
"# email of person to send email to",
"username",
"=",
"args",
".",
"username",
"# username of person to send email to, will be None if email is specified",
"force_send",
"=",
"args",
... | Gives user permission based on auth_role arg and sends email to that user.
:param args Namespace arguments parsed from the command line | [
"Gives",
"user",
"permission",
"based",
"on",
"auth_role",
"arg",
"and",
"sends",
"email",
"to",
"that",
"user",
".",
":",
"param",
"args",
"Namespace",
"arguments",
"parsed",
"from",
"the",
"command",
"line"
] | python | train | 56.772727 |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_ntp.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_ntp.py#L12-L23 | def show_ntp_input_rbridge_id(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
show_ntp = ET.Element("show_ntp")
config = show_ntp
input = ET.SubElement(show_ntp, "input")
rbridge_id = ET.SubElement(input, "rbridge-id")
rbridge_id.... | [
"def",
"show_ntp_input_rbridge_id",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"show_ntp",
"=",
"ET",
".",
"Element",
"(",
"\"show_ntp\"",
")",
"config",
"=",
"show_ntp",
"input",
"=",
"ET... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 35.916667 |
ratt-ru/PyMORESANE | pymoresane/iuwt.py | https://github.com/ratt-ru/PyMORESANE/blob/b024591ad0bbb69320d08841f28a2c27f62ae1af/pymoresane/iuwt.py#L113-L149 | def ser_iuwt_recomposition(in1, scale_adjust, smoothed_array):
"""
This function calls the a trous algorithm code to recompose the input into a single array. This is the
implementation of the isotropic undecimated wavelet transform recomposition for a single CPU core.
INPUTS:
in1 (no de... | [
"def",
"ser_iuwt_recomposition",
"(",
"in1",
",",
"scale_adjust",
",",
"smoothed_array",
")",
":",
"wavelet_filter",
"=",
"(",
"1.",
"/",
"16",
")",
"*",
"np",
".",
"array",
"(",
"[",
"1",
",",
"4",
",",
"6",
",",
"4",
",",
"1",
"]",
")",
"# Filter... | This function calls the a trous algorithm code to recompose the input into a single array. This is the
implementation of the isotropic undecimated wavelet transform recomposition for a single CPU core.
INPUTS:
in1 (no default): Array containing wavelet coefficients.
scale_adjust (no de... | [
"This",
"function",
"calls",
"the",
"a",
"trous",
"algorithm",
"code",
"to",
"recompose",
"the",
"input",
"into",
"a",
"single",
"array",
".",
"This",
"is",
"the",
"implementation",
"of",
"the",
"isotropic",
"undecimated",
"wavelet",
"transform",
"recomposition"... | python | train | 44.378378 |
wdbm/shijian | shijian.py | https://github.com/wdbm/shijian/blob/ad6aea877e1eb99fe148127ea185f39f1413ed4f/shijian.py#L1231-L1242 | def ustr(text):
"""
Convert a string to Python 2 unicode or Python 3 string as appropriate to
the version of Python in use.
"""
if text is not None:
if sys.version_info >= (3, 0):
return str(text)
else:
return unicode(text)
else:
return text | [
"def",
"ustr",
"(",
"text",
")",
":",
"if",
"text",
"is",
"not",
"None",
":",
"if",
"sys",
".",
"version_info",
">=",
"(",
"3",
",",
"0",
")",
":",
"return",
"str",
"(",
"text",
")",
"else",
":",
"return",
"unicode",
"(",
"text",
")",
"else",
"... | Convert a string to Python 2 unicode or Python 3 string as appropriate to
the version of Python in use. | [
"Convert",
"a",
"string",
"to",
"Python",
"2",
"unicode",
"or",
"Python",
"3",
"string",
"as",
"appropriate",
"to",
"the",
"version",
"of",
"Python",
"in",
"use",
"."
] | python | train | 25.166667 |
pandas-dev/pandas | pandas/core/dtypes/common.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L375-L405 | def is_period(arr):
"""
Check whether an array-like is a periodical index.
.. deprecated:: 0.24.0
Parameters
----------
arr : array-like
The array-like to check.
Returns
-------
boolean
Whether or not the array-like is a periodical index.
Examples
--------... | [
"def",
"is_period",
"(",
"arr",
")",
":",
"warnings",
".",
"warn",
"(",
"\"'is_period' is deprecated and will be removed in a future \"",
"\"version. Use 'is_period_dtype' or is_period_arraylike' \"",
"\"instead.\"",
",",
"FutureWarning",
",",
"stacklevel",
"=",
"2",
")",
"r... | Check whether an array-like is a periodical index.
.. deprecated:: 0.24.0
Parameters
----------
arr : array-like
The array-like to check.
Returns
-------
boolean
Whether or not the array-like is a periodical index.
Examples
--------
>>> is_period([1, 2, 3])
... | [
"Check",
"whether",
"an",
"array",
"-",
"like",
"is",
"a",
"periodical",
"index",
"."
] | python | train | 23.967742 |
riga/tfdeploy | tfdeploy.py | https://github.com/riga/tfdeploy/blob/8481f657d6e3a51d76185a195b993e45f448828a/tfdeploy.py#L1804-L1809 | def Sum(a, axis, keep_dims):
"""
Sum reduction op.
"""
return np.sum(a, axis=axis if not isinstance(axis, np.ndarray) else tuple(axis),
keepdims=keep_dims), | [
"def",
"Sum",
"(",
"a",
",",
"axis",
",",
"keep_dims",
")",
":",
"return",
"np",
".",
"sum",
"(",
"a",
",",
"axis",
"=",
"axis",
"if",
"not",
"isinstance",
"(",
"axis",
",",
"np",
".",
"ndarray",
")",
"else",
"tuple",
"(",
"axis",
")",
",",
"ke... | Sum reduction op. | [
"Sum",
"reduction",
"op",
"."
] | python | train | 30.833333 |
ttroy50/pyephember | pyephember/pyephember.py | https://github.com/ttroy50/pyephember/blob/3ee159ee82b926b957dae8dcbc7a4bfb6807a9b4/pyephember/pyephember.py#L210-L219 | def get_zone_temperature(self, zone_name):
"""
Get the temperature for a zone
"""
zone = self.get_zone(zone_name)
if zone is None:
raise RuntimeError("Unknown zone")
return zone['currentTemperature'] | [
"def",
"get_zone_temperature",
"(",
"self",
",",
"zone_name",
")",
":",
"zone",
"=",
"self",
".",
"get_zone",
"(",
"zone_name",
")",
"if",
"zone",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"Unknown zone\"",
")",
"return",
"zone",
"[",
"'currentTempe... | Get the temperature for a zone | [
"Get",
"the",
"temperature",
"for",
"a",
"zone"
] | python | train | 25.2 |
wummel/linkchecker | linkcheck/checker/httpurl.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/checker/httpurl.py#L254-L280 | def follow_redirections(self, request):
"""Follow all redirections of http response."""
log.debug(LOG_CHECK, "follow all redirections")
if self.is_redirect():
# run connection plugins for old connection
self.aggregate.plugin_manager.run_connection_plugins(self)
re... | [
"def",
"follow_redirections",
"(",
"self",
",",
"request",
")",
":",
"log",
".",
"debug",
"(",
"LOG_CHECK",
",",
"\"follow all redirections\"",
")",
"if",
"self",
".",
"is_redirect",
"(",
")",
":",
"# run connection plugins for old connection",
"self",
".",
"aggre... | Follow all redirections of http response. | [
"Follow",
"all",
"redirections",
"of",
"http",
"response",
"."
] | python | train | 47.111111 |
Diviyan-Kalainathan/CausalDiscoveryToolbox | cdt/utils/Settings.py | https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/utils/Settings.py#L163-L208 | def check_cuda_devices():
"""Output some information on CUDA-enabled devices on your computer,
including current memory usage. Modified to only get number of devices.
It's a port of https://gist.github.com/f0k/0d6431e3faa60bffc788f8b4daa029b1
from C to Python with ctypes, so it can run without compilin... | [
"def",
"check_cuda_devices",
"(",
")",
":",
"import",
"ctypes",
"# Some constants taken from cuda.h",
"CUDA_SUCCESS",
"=",
"0",
"libnames",
"=",
"(",
"'libcuda.so'",
",",
"'libcuda.dylib'",
",",
"'cuda.dll'",
")",
"for",
"libname",
"in",
"libnames",
":",
"try",
":... | Output some information on CUDA-enabled devices on your computer,
including current memory usage. Modified to only get number of devices.
It's a port of https://gist.github.com/f0k/0d6431e3faa60bffc788f8b4daa029b1
from C to Python with ctypes, so it can run without compiling
anything. Note that this is... | [
"Output",
"some",
"information",
"on",
"CUDA",
"-",
"enabled",
"devices",
"on",
"your",
"computer",
"including",
"current",
"memory",
"usage",
".",
"Modified",
"to",
"only",
"get",
"number",
"of",
"devices",
"."
] | python | valid | 36.521739 |
python/core-workflow | cherry_picker/cherry_picker/cherry_picker.py | https://github.com/python/core-workflow/blob/b93c76195f6db382cfcefee334380fb4c68d4e21/cherry_picker/cherry_picker/cherry_picker.py#L671-L687 | def version_from_branch(branch):
"""
return version information from a git branch name
"""
try:
return tuple(
map(
int,
re.match(r"^.*(?P<version>\d+(\.\d+)+).*$", branch)
.groupdict()["version"]
.split("."),
... | [
"def",
"version_from_branch",
"(",
"branch",
")",
":",
"try",
":",
"return",
"tuple",
"(",
"map",
"(",
"int",
",",
"re",
".",
"match",
"(",
"r\"^.*(?P<version>\\d+(\\.\\d+)+).*$\"",
",",
"branch",
")",
".",
"groupdict",
"(",
")",
"[",
"\"version\"",
"]",
"... | return version information from a git branch name | [
"return",
"version",
"information",
"from",
"a",
"git",
"branch",
"name"
] | python | train | 28.058824 |
arista-eosplus/pyeapi | pyeapi/api/system.py | https://github.com/arista-eosplus/pyeapi/blob/96a74faef1fe3bd79c4e900aed29c9956a0587d6/pyeapi/api/system.py#L118-L134 | def set_hostname(self, value=None, default=False, disable=False):
"""Configures the global system hostname setting
EosVersion:
4.13.7M
Args:
value (str): The hostname value
default (bool): Controls use of the default keyword
disable (bool): Contr... | [
"def",
"set_hostname",
"(",
"self",
",",
"value",
"=",
"None",
",",
"default",
"=",
"False",
",",
"disable",
"=",
"False",
")",
":",
"cmd",
"=",
"self",
".",
"command_builder",
"(",
"'hostname'",
",",
"value",
"=",
"value",
",",
"default",
"=",
"defaul... | Configures the global system hostname setting
EosVersion:
4.13.7M
Args:
value (str): The hostname value
default (bool): Controls use of the default keyword
disable (bool): Controls the use of the no keyword
Returns:
bool: True if the... | [
"Configures",
"the",
"global",
"system",
"hostname",
"setting"
] | python | train | 34.882353 |
summanlp/textrank | summa/preprocessing/porter.py | https://github.com/summanlp/textrank/blob/6844bbe8c4b2b468020ae0dfd6574a743f9ad442/summa/preprocessing/porter.py#L552-L563 | def _step5(self, word):
"""step5() removes a final -e if m() > 1, and changes -ll to -l if
m() > 1.
"""
if word[-1] == 'e':
a = self._m(word, len(word)-1)
if a > 1 or (a == 1 and not self._cvc(word, len(word)-2)):
word = word[:-1]
if word.e... | [
"def",
"_step5",
"(",
"self",
",",
"word",
")",
":",
"if",
"word",
"[",
"-",
"1",
"]",
"==",
"'e'",
":",
"a",
"=",
"self",
".",
"_m",
"(",
"word",
",",
"len",
"(",
"word",
")",
"-",
"1",
")",
"if",
"a",
">",
"1",
"or",
"(",
"a",
"==",
"... | step5() removes a final -e if m() > 1, and changes -ll to -l if
m() > 1. | [
"step5",
"()",
"removes",
"a",
"final",
"-",
"e",
"if",
"m",
"()",
">",
"1",
"and",
"changes",
"-",
"ll",
"to",
"-",
"l",
"if",
"m",
"()",
">",
"1",
"."
] | python | train | 34 |
jahuth/litus | spikes.py | https://github.com/jahuth/litus/blob/712b016ea2dbb1cf0a30bfdbb0a136945a7b7c5e/spikes.py#L606-L645 | def _get_constrained_labels(self,remove_dimensions=False,**kwargs):
"""
returns labels which have updated minima and maxima,
depending on the kwargs supplied to this
"""
new_labels = []
for label_no,label in enumerate(self.labels):
new_label = LabelDim... | [
"def",
"_get_constrained_labels",
"(",
"self",
",",
"remove_dimensions",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"new_labels",
"=",
"[",
"]",
"for",
"label_no",
",",
"label",
"in",
"enumerate",
"(",
"self",
".",
"labels",
")",
":",
"new_label",
... | returns labels which have updated minima and maxima,
depending on the kwargs supplied to this | [
"returns",
"labels",
"which",
"have",
"updated",
"minima",
"and",
"maxima",
"depending",
"on",
"the",
"kwargs",
"supplied",
"to",
"this"
] | python | train | 42.8 |
pytroll/satpy | satpy/readers/seviri_base.py | https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/readers/seviri_base.py#L195-L200 | def get_cds_time(days, msecs):
"""Get the datetime object of the time since epoch given in days and
milliseconds of day
"""
return datetime(1958, 1, 1) + timedelta(days=float(days),
milliseconds=float(msecs)) | [
"def",
"get_cds_time",
"(",
"days",
",",
"msecs",
")",
":",
"return",
"datetime",
"(",
"1958",
",",
"1",
",",
"1",
")",
"+",
"timedelta",
"(",
"days",
"=",
"float",
"(",
"days",
")",
",",
"milliseconds",
"=",
"float",
"(",
"msecs",
")",
")"
] | Get the datetime object of the time since epoch given in days and
milliseconds of day | [
"Get",
"the",
"datetime",
"object",
"of",
"the",
"time",
"since",
"epoch",
"given",
"in",
"days",
"and",
"milliseconds",
"of",
"day"
] | python | train | 43.833333 |
joequant/cryptoexchange | cryptoexchange/bitmex.py | https://github.com/joequant/cryptoexchange/blob/6690fbd9a2ba00e40d7484425808c84d44233f0c/cryptoexchange/bitmex.py#L125-L133 | def authentication_required(function):
"""Annotation for methods that require auth."""
def wrapped(self, *args, **kwargs):
if not (self.token or self.apiKey):
msg = "You must be authenticated to use this method"
raise AuthenticationError(msg)
else:... | [
"def",
"authentication_required",
"(",
"function",
")",
":",
"def",
"wrapped",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"(",
"self",
".",
"token",
"or",
"self",
".",
"apiKey",
")",
":",
"msg",
"=",
"\"You must be... | Annotation for methods that require auth. | [
"Annotation",
"for",
"methods",
"that",
"require",
"auth",
"."
] | python | train | 43.333333 |
wzpan/MusicBoxApi | MusicBoxApi/utils.py | https://github.com/wzpan/MusicBoxApi/blob/d539d4b06c59bdf79b8d44756c325e39fde81f13/MusicBoxApi/utils.py#L38-L44 | def notify(msg, msg_type=0, t=None):
"Show system notification with duration t (ms)"
if platform.system() == 'Darwin':
command = notify_command_osx(msg, msg_type, t)
else:
command = notify_command_linux(msg, t)
os.system(command.encode('utf-8')) | [
"def",
"notify",
"(",
"msg",
",",
"msg_type",
"=",
"0",
",",
"t",
"=",
"None",
")",
":",
"if",
"platform",
".",
"system",
"(",
")",
"==",
"'Darwin'",
":",
"command",
"=",
"notify_command_osx",
"(",
"msg",
",",
"msg_type",
",",
"t",
")",
"else",
":"... | Show system notification with duration t (ms) | [
"Show",
"system",
"notification",
"with",
"duration",
"t",
"(",
"ms",
")"
] | python | test | 38.714286 |
ryanvarley/ExoData | exodata/database.py | https://github.com/ryanvarley/ExoData/blob/e0d3652117214d2377a707d6778f93b7eb201a41/exodata/database.py#L68-L81 | def transitingPlanets(self):
""" Returns a list of transiting planet objects
"""
transitingPlanets = []
for planet in self.planets:
try:
if planet.isTransiting:
transitingPlanets.append(planet)
except KeyError: # No 'discover... | [
"def",
"transitingPlanets",
"(",
"self",
")",
":",
"transitingPlanets",
"=",
"[",
"]",
"for",
"planet",
"in",
"self",
".",
"planets",
":",
"try",
":",
"if",
"planet",
".",
"isTransiting",
":",
"transitingPlanets",
".",
"append",
"(",
"planet",
")",
"except... | Returns a list of transiting planet objects | [
"Returns",
"a",
"list",
"of",
"transiting",
"planet",
"objects"
] | python | train | 29.642857 |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/util/quaternion.py | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L61-L71 | def conjugate(self):
""" Obtain the conjugate of the quaternion.
This is simply the same quaternion but with the sign of the
imaginary (vector) parts reversed.
"""
new = self.copy()
new.x *= -1
new.y *= -1
new.z *= -1
return new | [
"def",
"conjugate",
"(",
"self",
")",
":",
"new",
"=",
"self",
".",
"copy",
"(",
")",
"new",
".",
"x",
"*=",
"-",
"1",
"new",
".",
"y",
"*=",
"-",
"1",
"new",
".",
"z",
"*=",
"-",
"1",
"return",
"new"
] | Obtain the conjugate of the quaternion.
This is simply the same quaternion but with the sign of the
imaginary (vector) parts reversed. | [
"Obtain",
"the",
"conjugate",
"of",
"the",
"quaternion",
".",
"This",
"is",
"simply",
"the",
"same",
"quaternion",
"but",
"with",
"the",
"sign",
"of",
"the",
"imaginary",
"(",
"vector",
")",
"parts",
"reversed",
"."
] | python | train | 27.181818 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.