repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
chemlab/chemlab | chemlab/core/spacegroup/cell.py | https://github.com/chemlab/chemlab/blob/c8730966316d101e24f39ac3b96b51282aba0abe/chemlab/core/spacegroup/cell.py#L101-L105 | def metric_from_cell(cell):
"""Calculates the metric matrix from cell, which is given in the
Cartesian system."""
cell = np.asarray(cell, dtype=float)
return np.dot(cell, cell.T) | [
"def",
"metric_from_cell",
"(",
"cell",
")",
":",
"cell",
"=",
"np",
".",
"asarray",
"(",
"cell",
",",
"dtype",
"=",
"float",
")",
"return",
"np",
".",
"dot",
"(",
"cell",
",",
"cell",
".",
"T",
")"
] | Calculates the metric matrix from cell, which is given in the
Cartesian system. | [
"Calculates",
"the",
"metric",
"matrix",
"from",
"cell",
"which",
"is",
"given",
"in",
"the",
"Cartesian",
"system",
"."
] | python | train |
totokaka/pySpaceGDN | pyspacegdn/requests/find_request.py | https://github.com/totokaka/pySpaceGDN/blob/55c8be8d751e24873e0a7f7e99d2b715442ec878/pyspacegdn/requests/find_request.py#L73-L91 | def sort(self, *sort):
""" Sort the results.
Define how the results should be sorted. The arguments should be tuples
of string defining the key and direction to sort by. For example
`('name', 'asc')` and `('version', 'desc')`. The first sorte rule is
considered first by the API.... | [
"def",
"sort",
"(",
"self",
",",
"*",
"sort",
")",
":",
"self",
".",
"add_get_param",
"(",
"'sort'",
",",
"FILTER_DELIMITER",
".",
"join",
"(",
"[",
"ELEMENT_DELIMITER",
".",
"join",
"(",
"elements",
")",
"for",
"elements",
"in",
"sort",
"]",
")",
")",... | Sort the results.
Define how the results should be sorted. The arguments should be tuples
of string defining the key and direction to sort by. For example
`('name', 'asc')` and `('version', 'desc')`. The first sorte rule is
considered first by the API. See also the API documentation on
... | [
"Sort",
"the",
"results",
"."
] | python | train |
brettcannon/caniusepython3 | caniusepython3/pypi.py | https://github.com/brettcannon/caniusepython3/blob/195775d8f1891f73eb90734f3edda0c57e08dbf3/caniusepython3/pypi.py#L78-L90 | def supports_py3(project_name):
"""Check with PyPI if a project supports Python 3."""
log = logging.getLogger("ciu")
log.info("Checking {} ...".format(project_name))
request = requests.get("https://pypi.org/pypi/{}/json".format(project_name))
if request.status_code >= 400:
log = logging.getL... | [
"def",
"supports_py3",
"(",
"project_name",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"\"ciu\"",
")",
"log",
".",
"info",
"(",
"\"Checking {} ...\"",
".",
"format",
"(",
"project_name",
")",
")",
"request",
"=",
"requests",
".",
"get",
"(",
... | Check with PyPI if a project supports Python 3. | [
"Check",
"with",
"PyPI",
"if",
"a",
"project",
"supports",
"Python",
"3",
"."
] | python | train |
oemof/oemof.db | oemof/db/tools.py | https://github.com/oemof/oemof.db/blob/d51ac50187f03a875bd7ce5991ed4772e8b77b93/oemof/db/tools.py#L234-L272 | def tz_from_geom(connection, geometry):
r"""Finding the timezone of a given point or polygon geometry, assuming
that the polygon is not crossing a border of a timezone. For a given point
or polygon geometry not located within the timezone dataset (e.g. sea) the
nearest timezone based on the bounding box... | [
"def",
"tz_from_geom",
"(",
"connection",
",",
"geometry",
")",
":",
"# TODO@Günni",
"if",
"geometry",
".",
"geom_type",
"in",
"[",
"'Polygon'",
",",
"'MultiPolygon'",
"]",
":",
"coords",
"=",
"geometry",
".",
"centroid",
"else",
":",
"coords",
"=",
"geometr... | r"""Finding the timezone of a given point or polygon geometry, assuming
that the polygon is not crossing a border of a timezone. For a given point
or polygon geometry not located within the timezone dataset (e.g. sea) the
nearest timezone based on the bounding boxes of the geometries is returned.
Param... | [
"r",
"Finding",
"the",
"timezone",
"of",
"a",
"given",
"point",
"or",
"polygon",
"geometry",
"assuming",
"that",
"the",
"polygon",
"is",
"not",
"crossing",
"a",
"border",
"of",
"a",
"timezone",
".",
"For",
"a",
"given",
"point",
"or",
"polygon",
"geometry"... | python | train |
aiogram/aiogram | aiogram/types/message.py | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/types/message.py#L331-L374 | async def answer_audio(self, audio: typing.Union[base.InputFile, base.String],
caption: typing.Union[base.String, None] = None,
duration: typing.Union[base.Integer, None] = None,
performer: typing.Union[base.String, None] = None,
... | [
"async",
"def",
"answer_audio",
"(",
"self",
",",
"audio",
":",
"typing",
".",
"Union",
"[",
"base",
".",
"InputFile",
",",
"base",
".",
"String",
"]",
",",
"caption",
":",
"typing",
".",
"Union",
"[",
"base",
".",
"String",
",",
"None",
"]",
"=",
... | Use this method to send audio files, if you want Telegram clients to display them in the music player.
Your audio must be in the .mp3 format.
For sending voice messages, use the sendVoice method instead.
Source: https://core.telegram.org/bots/api#sendaudio
:param audio: Audio file to ... | [
"Use",
"this",
"method",
"to",
"send",
"audio",
"files",
"if",
"you",
"want",
"Telegram",
"clients",
"to",
"display",
"them",
"in",
"the",
"music",
"player",
".",
"Your",
"audio",
"must",
"be",
"in",
"the",
".",
"mp3",
"format",
"."
] | python | train |
cmbruns/pyopenvr | src/openvr/__init__.py | https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L3484-L3492 | def launchDashboardOverlay(self, pchAppKey):
"""
Launches the dashboard overlay application if it is not already running. This call is only valid for
dashboard overlay applications.
"""
fn = self.function_table.launchDashboardOverlay
result = fn(pchAppKey)
retur... | [
"def",
"launchDashboardOverlay",
"(",
"self",
",",
"pchAppKey",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"launchDashboardOverlay",
"result",
"=",
"fn",
"(",
"pchAppKey",
")",
"return",
"result"
] | Launches the dashboard overlay application if it is not already running. This call is only valid for
dashboard overlay applications. | [
"Launches",
"the",
"dashboard",
"overlay",
"application",
"if",
"it",
"is",
"not",
"already",
"running",
".",
"This",
"call",
"is",
"only",
"valid",
"for",
"dashboard",
"overlay",
"applications",
"."
] | python | train |
phaethon/kamene | kamene/pton_ntop.py | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/pton_ntop.py#L15-L61 | def inet_pton(af, addr):
"""Convert an IP address from text representation into binary form"""
print('hello')
if af == socket.AF_INET:
return inet_aton(addr)
elif af == socket.AF_INET6:
# IPv6: The use of "::" indicates one or more groups of 16 bits of zeros.
# We deal with this ... | [
"def",
"inet_pton",
"(",
"af",
",",
"addr",
")",
":",
"print",
"(",
"'hello'",
")",
"if",
"af",
"==",
"socket",
".",
"AF_INET",
":",
"return",
"inet_aton",
"(",
"addr",
")",
"elif",
"af",
"==",
"socket",
".",
"AF_INET6",
":",
"# IPv6: The use of \"::\" i... | Convert an IP address from text representation into binary form | [
"Convert",
"an",
"IP",
"address",
"from",
"text",
"representation",
"into",
"binary",
"form"
] | python | train |
archman/beamline | beamline/mathutils.py | https://github.com/archman/beamline/blob/417bc5dc13e754bc89d246427984590fced64d07/beamline/mathutils.py#L264-L278 | def transFringe(beta=None, rho=None):
""" Transport matrix of fringe field
:param beta: angle of rotation of pole-face in [RAD]
:param rho: bending radius in [m]
:return: 6x6 numpy array
"""
m = np.eye(6, 6, dtype=np.float64)
if None in (beta, rho):
print("warning: 'theta', 'rho' sh... | [
"def",
"transFringe",
"(",
"beta",
"=",
"None",
",",
"rho",
"=",
"None",
")",
":",
"m",
"=",
"np",
".",
"eye",
"(",
"6",
",",
"6",
",",
"dtype",
"=",
"np",
".",
"float64",
")",
"if",
"None",
"in",
"(",
"beta",
",",
"rho",
")",
":",
"print",
... | Transport matrix of fringe field
:param beta: angle of rotation of pole-face in [RAD]
:param rho: bending radius in [m]
:return: 6x6 numpy array | [
"Transport",
"matrix",
"of",
"fringe",
"field"
] | python | train |
aws/aws-encryption-sdk-python | src/aws_encryption_sdk/internal/formatting/encryption_context.py | https://github.com/aws/aws-encryption-sdk-python/blob/d182155d5fb1ef176d9e7d0647679737d5146495/src/aws_encryption_sdk/internal/formatting/encryption_context.py#L132-L170 | def deserialize_encryption_context(serialized_encryption_context):
"""Deserializes the contents of a byte string into a dictionary.
:param bytes serialized_encryption_context: Source byte string containing serialized dictionary
:returns: Deserialized encryption context
:rtype: dict
:raises Serializ... | [
"def",
"deserialize_encryption_context",
"(",
"serialized_encryption_context",
")",
":",
"if",
"len",
"(",
"serialized_encryption_context",
")",
">",
"aws_encryption_sdk",
".",
"internal",
".",
"defaults",
".",
"MAX_BYTE_ARRAY_SIZE",
":",
"raise",
"SerializationError",
"(... | Deserializes the contents of a byte string into a dictionary.
:param bytes serialized_encryption_context: Source byte string containing serialized dictionary
:returns: Deserialized encryption context
:rtype: dict
:raises SerializationError: if serialized encryption context is too large
:raises Seri... | [
"Deserializes",
"the",
"contents",
"of",
"a",
"byte",
"string",
"into",
"a",
"dictionary",
"."
] | python | train |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/frontend/terminal/interactiveshell.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/frontend/terminal/interactiveshell.py#L637-L663 | def edit_syntax_error(self):
"""The bottom half of the syntax error handler called in the main loop.
Loop until syntax error is fixed or user cancels.
"""
while self.SyntaxTB.last_syntax_error:
# copy and clear last_syntax_error
err = self.SyntaxTB.clear_err_sta... | [
"def",
"edit_syntax_error",
"(",
"self",
")",
":",
"while",
"self",
".",
"SyntaxTB",
".",
"last_syntax_error",
":",
"# copy and clear last_syntax_error",
"err",
"=",
"self",
".",
"SyntaxTB",
".",
"clear_err_state",
"(",
")",
"if",
"not",
"self",
".",
"_should_re... | The bottom half of the syntax error handler called in the main loop.
Loop until syntax error is fixed or user cancels. | [
"The",
"bottom",
"half",
"of",
"the",
"syntax",
"error",
"handler",
"called",
"in",
"the",
"main",
"loop",
"."
] | python | test |
fronzbot/blinkpy | blinkpy/api.py | https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L177-L185 | def request_cameras(blink, network):
"""
Request all camera information.
:param Blink: Blink instance.
:param network: Sync module network id.
"""
url = "{}/network/{}/cameras".format(blink.urls.base_url, network)
return http_get(blink, url) | [
"def",
"request_cameras",
"(",
"blink",
",",
"network",
")",
":",
"url",
"=",
"\"{}/network/{}/cameras\"",
".",
"format",
"(",
"blink",
".",
"urls",
".",
"base_url",
",",
"network",
")",
"return",
"http_get",
"(",
"blink",
",",
"url",
")"
] | Request all camera information.
:param Blink: Blink instance.
:param network: Sync module network id. | [
"Request",
"all",
"camera",
"information",
"."
] | python | train |
SHDShim/pytheos | pytheos/eqn_therm_Speziale.py | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_therm_Speziale.py#L33-L54 | def speziale_debyetemp(v, v0, gamma0, q0, q1, theta0):
"""
calculate Debye temperature for the Speziale equation
:param v: unit-cell volume in A^3
:param v0: unit-cell volume in A^3 at 1 bar
:param gamma0: Gruneisen parameter at 1 bar
:param q0: logarithmic derivative of Gruneisen parameter
... | [
"def",
"speziale_debyetemp",
"(",
"v",
",",
"v0",
",",
"gamma0",
",",
"q0",
",",
"q1",
",",
"theta0",
")",
":",
"if",
"isuncertainties",
"(",
"[",
"v",
",",
"v0",
",",
"gamma0",
",",
"q0",
",",
"q1",
",",
"theta0",
"]",
")",
":",
"f_vu",
"=",
"... | calculate Debye temperature for the Speziale equation
:param v: unit-cell volume in A^3
:param v0: unit-cell volume in A^3 at 1 bar
:param gamma0: Gruneisen parameter at 1 bar
:param q0: logarithmic derivative of Gruneisen parameter
:param q1: logarithmic derivative of Gruneisen parameter
:para... | [
"calculate",
"Debye",
"temperature",
"for",
"the",
"Speziale",
"equation"
] | python | train |
pybel/pybel-tools | src/pybel_tools/mutation/collapse.py | https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/mutation/collapse.py#L86-L107 | def _collapse_edge_by_namespace(graph: BELGraph,
victim_namespaces: Strings,
survivor_namespaces: str,
relations: Strings) -> None:
"""Collapse pairs of nodes with the given namespaces that have the given relationship.
... | [
"def",
"_collapse_edge_by_namespace",
"(",
"graph",
":",
"BELGraph",
",",
"victim_namespaces",
":",
"Strings",
",",
"survivor_namespaces",
":",
"str",
",",
"relations",
":",
"Strings",
")",
"->",
"None",
":",
"relation_filter",
"=",
"build_relation_predicate",
"(",
... | Collapse pairs of nodes with the given namespaces that have the given relationship.
:param graph: A BEL Graph
:param victim_namespaces: The namespace(s) of the node to collapse
:param survivor_namespaces: The namespace of the node to keep
:param relations: The relation(s) to search | [
"Collapse",
"pairs",
"of",
"nodes",
"with",
"the",
"given",
"namespaces",
"that",
"have",
"the",
"given",
"relationship",
"."
] | python | valid |
RLBot/RLBot | src/main/python/rlbot/utils/class_importer.py | https://github.com/RLBot/RLBot/blob/3f9b6bec8b9baf4dcfff0f6cf3103c8744ac6234/src/main/python/rlbot/utils/class_importer.py#L55-L63 | def load_external_class(python_file, base_class):
"""
Returns a tuple: (subclass of base_class, module)
"""
loaded_module = load_external_module(python_file)
# Find a class that extends base_class
loaded_class = extract_class(loaded_module, base_class)
return loaded_class, loaded_module | [
"def",
"load_external_class",
"(",
"python_file",
",",
"base_class",
")",
":",
"loaded_module",
"=",
"load_external_module",
"(",
"python_file",
")",
"# Find a class that extends base_class",
"loaded_class",
"=",
"extract_class",
"(",
"loaded_module",
",",
"base_class",
"... | Returns a tuple: (subclass of base_class, module) | [
"Returns",
"a",
"tuple",
":",
"(",
"subclass",
"of",
"base_class",
"module",
")"
] | python | train |
creare-com/pydem | pydem/dem_processing.py | https://github.com/creare-com/pydem/blob/c2fc8d84cfb411df84f71a6dec9edc4b544f710a/pydem/dem_processing.py#L1020-L1027 | def _slopes_directions(self, data, dX, dY, method='tarboton'):
""" Wrapper to pick between various algorithms
"""
# %%
if method == 'tarboton':
return self._tarboton_slopes_directions(data, dX, dY)
elif method == 'central':
return self._central_slopes_dire... | [
"def",
"_slopes_directions",
"(",
"self",
",",
"data",
",",
"dX",
",",
"dY",
",",
"method",
"=",
"'tarboton'",
")",
":",
"# %%",
"if",
"method",
"==",
"'tarboton'",
":",
"return",
"self",
".",
"_tarboton_slopes_directions",
"(",
"data",
",",
"dX",
",",
"... | Wrapper to pick between various algorithms | [
"Wrapper",
"to",
"pick",
"between",
"various",
"algorithms"
] | python | train |
macpaul/usonic | usonic/usonic.py | https://github.com/macpaul/usonic/blob/92ed69c785aebd54ecdf3e2553a6edc26d5e5878/usonic/usonic.py#L18-L100 | def read(sensor):
"""
distance of object in front of sensor in CM.
"""
import time
import RPi.GPIO as GPIO
# Disable any warning message such as GPIO pins in use
GPIO.setwarnings(False)
# use the values of the GPIO pins, and not the actual pin number
# so if you connect to ... | [
"def",
"read",
"(",
"sensor",
")",
":",
"import",
"time",
"import",
"RPi",
".",
"GPIO",
"as",
"GPIO",
"# Disable any warning message such as GPIO pins in use",
"GPIO",
".",
"setwarnings",
"(",
"False",
")",
"# use the values of the GPIO pins, and not the actual pin number",... | distance of object in front of sensor in CM. | [
"distance",
"of",
"object",
"in",
"front",
"of",
"sensor",
"in",
"CM",
"."
] | python | train |
cmorisse/ikp3db | ikp3db.py | https://github.com/cmorisse/ikp3db/blob/a0f318d4e8494b2e6f2f07ec0f1202ca023c920f/ikp3db.py#L484-L488 | def update_active_breakpoint_flag(cls):
""" Checks all breakpoints to find wether at least one is active and
update `any_active_breakpoint` accordingly.
"""
cls.any_active_breakpoint=any([bp.enabled for bp in cls.breakpoints_by_number if bp]) | [
"def",
"update_active_breakpoint_flag",
"(",
"cls",
")",
":",
"cls",
".",
"any_active_breakpoint",
"=",
"any",
"(",
"[",
"bp",
".",
"enabled",
"for",
"bp",
"in",
"cls",
".",
"breakpoints_by_number",
"if",
"bp",
"]",
")"
] | Checks all breakpoints to find wether at least one is active and
update `any_active_breakpoint` accordingly. | [
"Checks",
"all",
"breakpoints",
"to",
"find",
"wether",
"at",
"least",
"one",
"is",
"active",
"and",
"update",
"any_active_breakpoint",
"accordingly",
"."
] | python | train |
globality-corp/microcosm-postgres | microcosm_postgres/migrate.py | https://github.com/globality-corp/microcosm-postgres/blob/43dd793b1fc9b84e4056700f350e79e0df5ff501/microcosm_postgres/migrate.py#L156-L187 | def patch_script_directory(graph):
"""
Monkey patch the `ScriptDirectory` class, working around configuration assumptions.
Changes include:
- Using a generated, temporary directory (with a generated, temporary `script.py.mako`)
instead of the assumed script directory.
- Using our `make_... | [
"def",
"patch_script_directory",
"(",
"graph",
")",
":",
"temporary_dir",
"=",
"mkdtemp",
"(",
")",
"from_config_original",
"=",
"getattr",
"(",
"ScriptDirectory",
",",
"\"from_config\"",
")",
"run_env_original",
"=",
"getattr",
"(",
"ScriptDirectory",
",",
"\"run_e... | Monkey patch the `ScriptDirectory` class, working around configuration assumptions.
Changes include:
- Using a generated, temporary directory (with a generated, temporary `script.py.mako`)
instead of the assumed script directory.
- Using our `make_script_directory` function instead of the defau... | [
"Monkey",
"patch",
"the",
"ScriptDirectory",
"class",
"working",
"around",
"configuration",
"assumptions",
"."
] | python | train |
DLR-RM/RAFCON | source/rafcon/gui/mygaphas/utils/gap_helper.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/mygaphas/utils/gap_helper.py#L138-L197 | def add_data_flow_to_state(from_port, to_port):
"""Interface method between Gaphas and RAFCON core for adding data flows
The method checks the types of the given ports and their relation. From this the necessary parameters for the
add_dat_flow method of the RAFCON core are determined. Also the parent state... | [
"def",
"add_data_flow_to_state",
"(",
"from_port",
",",
"to_port",
")",
":",
"from",
"rafcon",
".",
"gui",
".",
"mygaphas",
".",
"items",
".",
"ports",
"import",
"InputPortView",
",",
"OutputPortView",
",",
"ScopedVariablePortView",
"from",
"rafcon",
".",
"gui",... | Interface method between Gaphas and RAFCON core for adding data flows
The method checks the types of the given ports and their relation. From this the necessary parameters for the
add_dat_flow method of the RAFCON core are determined. Also the parent state is derived from the ports.
:param from_port: Port... | [
"Interface",
"method",
"between",
"Gaphas",
"and",
"RAFCON",
"core",
"for",
"adding",
"data",
"flows"
] | python | train |
pantsbuild/pants | src/python/pants/backend/jvm/subsystems/zinc.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/backend/jvm/subsystems/zinc.py#L329-L369 | def compile_compiler_bridge(self, context):
"""Compile the compiler bridge to be used by zinc, using our scala bootstrapper.
It will compile and cache the jar, and materialize it if not already there.
:param context: The context of the task trying to compile the bridge.
This is mostly n... | [
"def",
"compile_compiler_bridge",
"(",
"self",
",",
"context",
")",
":",
"bridge_jar_name",
"=",
"'scala-compiler-bridge.jar'",
"bridge_jar",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_compiler_bridge_cache_dir",
",",
"bridge_jar_name",
")",
"global_br... | Compile the compiler bridge to be used by zinc, using our scala bootstrapper.
It will compile and cache the jar, and materialize it if not already there.
:param context: The context of the task trying to compile the bridge.
This is mostly needed to use its scheduler to create digests of the... | [
"Compile",
"the",
"compiler",
"bridge",
"to",
"be",
"used",
"by",
"zinc",
"using",
"our",
"scala",
"bootstrapper",
".",
"It",
"will",
"compile",
"and",
"cache",
"the",
"jar",
"and",
"materialize",
"it",
"if",
"not",
"already",
"there",
"."
] | python | train |
cloudant/python-cloudant | src/cloudant/database.py | https://github.com/cloudant/python-cloudant/blob/e0ba190f6ba07fe3522a668747128214ad573c7e/src/cloudant/database.py#L996-L1046 | def update_handler_result(self, ddoc_id, handler_name, doc_id=None, data=None, **params):
"""
Creates or updates a document from the specified database based on the
update handler function provided. Update handlers are used, for
example, to provide server-side modification timestamps, a... | [
"def",
"update_handler_result",
"(",
"self",
",",
"ddoc_id",
",",
"handler_name",
",",
"doc_id",
"=",
"None",
",",
"data",
"=",
"None",
",",
"*",
"*",
"params",
")",
":",
"ddoc",
"=",
"DesignDocument",
"(",
"self",
",",
"ddoc_id",
")",
"if",
"doc_id",
... | Creates or updates a document from the specified database based on the
update handler function provided. Update handlers are used, for
example, to provide server-side modification timestamps, and document
updates to individual fields without the latest revision. You can
provide query pa... | [
"Creates",
"or",
"updates",
"a",
"document",
"from",
"the",
"specified",
"database",
"based",
"on",
"the",
"update",
"handler",
"function",
"provided",
".",
"Update",
"handlers",
"are",
"used",
"for",
"example",
"to",
"provide",
"server",
"-",
"side",
"modific... | python | train |
Riminder/python-riminder-api | riminder/profile.py | https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/profile.py#L426-L440 | def add(self, source_id, profile_data, training_metadata=[], profile_reference=None, timestamp_reception=None):
"""Use the api to add a new profile using profile_data."""
data = {
"source_id": _validate_source_id(source_id),
"profile_json": _validate_dict(profile_data, "profile_d... | [
"def",
"add",
"(",
"self",
",",
"source_id",
",",
"profile_data",
",",
"training_metadata",
"=",
"[",
"]",
",",
"profile_reference",
"=",
"None",
",",
"timestamp_reception",
"=",
"None",
")",
":",
"data",
"=",
"{",
"\"source_id\"",
":",
"_validate_source_id",
... | Use the api to add a new profile using profile_data. | [
"Use",
"the",
"api",
"to",
"add",
"a",
"new",
"profile",
"using",
"profile_data",
"."
] | python | train |
nprapps/mapturner | mapturner/__init__.py | https://github.com/nprapps/mapturner/blob/fc9747c9d1584af2053bff3df229a460ef2a5f62/mapturner/__init__.py#L193-L228 | def process_ogr2ogr(self, name, layer, input_path):
"""
Process a layer using ogr2ogr.
"""
output_path = os.path.join(TEMP_DIRECTORY, '%s.json' % name)
if os.path.exists(output_path):
os.remove(output_path)
ogr2ogr_cmd = [
'ogr2ogr',
... | [
"def",
"process_ogr2ogr",
"(",
"self",
",",
"name",
",",
"layer",
",",
"input_path",
")",
":",
"output_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"TEMP_DIRECTORY",
",",
"'%s.json'",
"%",
"name",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
... | Process a layer using ogr2ogr. | [
"Process",
"a",
"layer",
"using",
"ogr2ogr",
"."
] | python | train |
Azure/azure-event-hubs-python | azure/eventprocessorhost/lease.py | https://github.com/Azure/azure-event-hubs-python/blob/737c5f966557ada2cf10fa0d8f3c19671ae96348/azure/eventprocessorhost/lease.py#L20-L31 | def with_partition_id(self, partition_id):
"""
Init with partition Id.
:param partition_id: ID of a given partition.
:type partition_id: str
"""
self.partition_id = partition_id
self.owner = None
self.token = None
self.epoch = 0
self.event... | [
"def",
"with_partition_id",
"(",
"self",
",",
"partition_id",
")",
":",
"self",
".",
"partition_id",
"=",
"partition_id",
"self",
".",
"owner",
"=",
"None",
"self",
".",
"token",
"=",
"None",
"self",
".",
"epoch",
"=",
"0",
"self",
".",
"event_processor_co... | Init with partition Id.
:param partition_id: ID of a given partition.
:type partition_id: str | [
"Init",
"with",
"partition",
"Id",
"."
] | python | train |
jwkvam/bowtie | bowtie/_app.py | https://github.com/jwkvam/bowtie/blob/c494850671ac805bf186fbf2bdb07d2a34ae876d/bowtie/_app.py#L1084-L1087 | def node_version():
"""Get node version."""
version = check_output(('node', '--version'))
return tuple(int(x) for x in version.strip()[1:].split(b'.')) | [
"def",
"node_version",
"(",
")",
":",
"version",
"=",
"check_output",
"(",
"(",
"'node'",
",",
"'--version'",
")",
")",
"return",
"tuple",
"(",
"int",
"(",
"x",
")",
"for",
"x",
"in",
"version",
".",
"strip",
"(",
")",
"[",
"1",
":",
"]",
".",
"s... | Get node version. | [
"Get",
"node",
"version",
"."
] | python | train |
aleontiev/dj | dj/commands/lint.py | https://github.com/aleontiev/dj/blob/0612d442fdd8d472aea56466568b9857556ecb51/dj/commands/lint.py#L13-L19 | def lint(args):
"""Run lint checks using flake8."""
application = get_current_application()
if not args:
args = [application.name, 'tests']
args = ['flake8'] + list(args)
run.main(args, standalone_mode=False) | [
"def",
"lint",
"(",
"args",
")",
":",
"application",
"=",
"get_current_application",
"(",
")",
"if",
"not",
"args",
":",
"args",
"=",
"[",
"application",
".",
"name",
",",
"'tests'",
"]",
"args",
"=",
"[",
"'flake8'",
"]",
"+",
"list",
"(",
"args",
"... | Run lint checks using flake8. | [
"Run",
"lint",
"checks",
"using",
"flake8",
"."
] | python | train |
cloud-custodian/cloud-custodian | tools/ops/mugc.py | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/ops/mugc.py#L113-L129 | def resources_gc_prefix(options, policy_config, policy_collection):
"""Garbage collect old custodian policies based on prefix.
We attempt to introspect to find the event sources for a policy
but without the old configuration this is implicit.
"""
# Classify policies by region
policy_regions = ... | [
"def",
"resources_gc_prefix",
"(",
"options",
",",
"policy_config",
",",
"policy_collection",
")",
":",
"# Classify policies by region",
"policy_regions",
"=",
"{",
"}",
"for",
"p",
"in",
"policy_collection",
":",
"if",
"p",
".",
"execution_mode",
"==",
"'poll'",
... | Garbage collect old custodian policies based on prefix.
We attempt to introspect to find the event sources for a policy
but without the old configuration this is implicit. | [
"Garbage",
"collect",
"old",
"custodian",
"policies",
"based",
"on",
"prefix",
"."
] | python | train |
srittau/python-asserts | asserts/__init__.py | https://github.com/srittau/python-asserts/blob/1d5c797031c68ee27552d1c94e7f918c3d3d0453/asserts/__init__.py#L80-L96 | def assert_boolean_true(expr, msg_fmt="{msg}"):
"""Fail the test unless the expression is the constant True.
>>> assert_boolean_true(True)
>>> assert_boolean_true("Hello World!")
Traceback (most recent call last):
...
AssertionError: 'Hello World!' is not True
The following msg_fmt arg... | [
"def",
"assert_boolean_true",
"(",
"expr",
",",
"msg_fmt",
"=",
"\"{msg}\"",
")",
":",
"if",
"expr",
"is",
"not",
"True",
":",
"msg",
"=",
"\"{!r} is not True\"",
".",
"format",
"(",
"expr",
")",
"fail",
"(",
"msg_fmt",
".",
"format",
"(",
"msg",
"=",
... | Fail the test unless the expression is the constant True.
>>> assert_boolean_true(True)
>>> assert_boolean_true("Hello World!")
Traceback (most recent call last):
...
AssertionError: 'Hello World!' is not True
The following msg_fmt arguments are supported:
* msg - the default error mes... | [
"Fail",
"the",
"test",
"unless",
"the",
"expression",
"is",
"the",
"constant",
"True",
"."
] | python | train |
ArduPilot/MAVProxy | MAVProxy/modules/lib/MacOS/backend_wx.py | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/MacOS/backend_wx.py#L1140-L1146 | def _onLeftButtonDClick(self, evt):
"""Start measuring on an axis."""
x = evt.GetX()
y = self.figure.bbox.height - evt.GetY()
evt.Skip()
self.CaptureMouse()
FigureCanvasBase.button_press_event(self, x, y, 1, dblclick=True, guiEvent=evt) | [
"def",
"_onLeftButtonDClick",
"(",
"self",
",",
"evt",
")",
":",
"x",
"=",
"evt",
".",
"GetX",
"(",
")",
"y",
"=",
"self",
".",
"figure",
".",
"bbox",
".",
"height",
"-",
"evt",
".",
"GetY",
"(",
")",
"evt",
".",
"Skip",
"(",
")",
"self",
".",
... | Start measuring on an axis. | [
"Start",
"measuring",
"on",
"an",
"axis",
"."
] | python | train |
mikedh/trimesh | trimesh/collision.py | https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/collision.py#L225-L243 | def set_transform(self, name, transform):
"""
Set the transform for one of the manager's objects.
This replaces the prior transform.
Parameters
----------
name : str
An identifier for the object already in the manager
transform : (4,4) float
A... | [
"def",
"set_transform",
"(",
"self",
",",
"name",
",",
"transform",
")",
":",
"if",
"name",
"in",
"self",
".",
"_objs",
":",
"o",
"=",
"self",
".",
"_objs",
"[",
"name",
"]",
"[",
"'obj'",
"]",
"o",
".",
"setRotation",
"(",
"transform",
"[",
":",
... | Set the transform for one of the manager's objects.
This replaces the prior transform.
Parameters
----------
name : str
An identifier for the object already in the manager
transform : (4,4) float
A new homogenous transform matrix for the object | [
"Set",
"the",
"transform",
"for",
"one",
"of",
"the",
"manager",
"s",
"objects",
".",
"This",
"replaces",
"the",
"prior",
"transform",
"."
] | python | train |
kgori/treeCl | treeCl/distance_matrix.py | https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/distance_matrix.py#L324-L336 | def _embedding_spectral(matrix, dimensions=3, unit_length=True,
affinity_matrix=None, sigma=1):
"""
Private method to calculate Spectral embedding
:param dimensions: (int)
:return: coordinate matrix (np.array)
"""
if affinity_matrix is None:
aff = rbf(matrix, sigm... | [
"def",
"_embedding_spectral",
"(",
"matrix",
",",
"dimensions",
"=",
"3",
",",
"unit_length",
"=",
"True",
",",
"affinity_matrix",
"=",
"None",
",",
"sigma",
"=",
"1",
")",
":",
"if",
"affinity_matrix",
"is",
"None",
":",
"aff",
"=",
"rbf",
"(",
"matrix"... | Private method to calculate Spectral embedding
:param dimensions: (int)
:return: coordinate matrix (np.array) | [
"Private",
"method",
"to",
"calculate",
"Spectral",
"embedding",
":",
"param",
"dimensions",
":",
"(",
"int",
")",
":",
"return",
":",
"coordinate",
"matrix",
"(",
"np",
".",
"array",
")"
] | python | train |
MisterWil/skybellpy | skybellpy/__init__.py | https://github.com/MisterWil/skybellpy/blob/ac966d9f590cda7654f6de7eecc94e2103459eef/skybellpy/__init__.py#L123-L146 | def get_devices(self, refresh=False):
"""Get all devices from Abode."""
if refresh or self._devices is None:
if self._devices is None:
self._devices = {}
_LOGGER.info("Updating all devices...")
response = self.send_request("get", CONST.DEVICES_URL)
... | [
"def",
"get_devices",
"(",
"self",
",",
"refresh",
"=",
"False",
")",
":",
"if",
"refresh",
"or",
"self",
".",
"_devices",
"is",
"None",
":",
"if",
"self",
".",
"_devices",
"is",
"None",
":",
"self",
".",
"_devices",
"=",
"{",
"}",
"_LOGGER",
".",
... | Get all devices from Abode. | [
"Get",
"all",
"devices",
"from",
"Abode",
"."
] | python | train |
zinic/pynsive | pynsive/reflection.py | https://github.com/zinic/pynsive/blob/15bc8b35a91be5817979eb327427b6235b1b411e/pynsive/reflection.py#L168-L194 | def rlist_modules(mname):
"""
Attempts to the submodules under a module recursively. This function
works for modules located in the default path as well as extended paths
via the sys.meta_path hooks.
This function carries the expectation that the hidden module variable
'__path__' has been set c... | [
"def",
"rlist_modules",
"(",
"mname",
")",
":",
"module",
"=",
"import_module",
"(",
"mname",
")",
"if",
"not",
"module",
":",
"raise",
"ImportError",
"(",
"'Unable to load module {}'",
".",
"format",
"(",
"mname",
")",
")",
"found",
"=",
"list",
"(",
")",... | Attempts to the submodules under a module recursively. This function
works for modules located in the default path as well as extended paths
via the sys.meta_path hooks.
This function carries the expectation that the hidden module variable
'__path__' has been set correctly.
:param mname: the modul... | [
"Attempts",
"to",
"the",
"submodules",
"under",
"a",
"module",
"recursively",
".",
"This",
"function",
"works",
"for",
"modules",
"located",
"in",
"the",
"default",
"path",
"as",
"well",
"as",
"extended",
"paths",
"via",
"the",
"sys",
".",
"meta_path",
"hook... | python | test |
Chilipp/psyplot | psyplot/__main__.py | https://github.com/Chilipp/psyplot/blob/75a0a15a9a1dd018e79d2df270d56c4bf5f311d5/psyplot/__main__.py#L24-L46 | def main(args=None):
"""Main function for usage of psyplot from the command line
This function creates a parser that parses command lines to the
:func:`make_plot` functions or (if the ``psyplot_gui`` module is
present, to the :func:`psyplot_gui.start_app` function)
Returns
-------
psyplot.... | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"try",
":",
"from",
"psyplot_gui",
"import",
"get_parser",
"as",
"_get_parser",
"except",
"ImportError",
":",
"logger",
".",
"debug",
"(",
"'Failed to import gui'",
",",
"exc_info",
"=",
"True",
")",
"parser... | Main function for usage of psyplot from the command line
This function creates a parser that parses command lines to the
:func:`make_plot` functions or (if the ``psyplot_gui`` module is
present, to the :func:`psyplot_gui.start_app` function)
Returns
-------
psyplot.parser.FuncArgParser
... | [
"Main",
"function",
"for",
"usage",
"of",
"psyplot",
"from",
"the",
"command",
"line"
] | python | train |
KujiraProject/Flask-PAM | flask_pam/auth.py | https://github.com/KujiraProject/Flask-PAM/blob/d84f90ffd706c0f491af3539cd438e13771ada7e/flask_pam/auth.py#L142-L152 | def get_groups(self, username):
"""Returns list of groups in which user is.
:param username: name of Linux user
"""
groups = []
for group in grp.getgrall():
if username in group.gr_mem:
groups.append(group.gr_name)
return groups | [
"def",
"get_groups",
"(",
"self",
",",
"username",
")",
":",
"groups",
"=",
"[",
"]",
"for",
"group",
"in",
"grp",
".",
"getgrall",
"(",
")",
":",
"if",
"username",
"in",
"group",
".",
"gr_mem",
":",
"groups",
".",
"append",
"(",
"group",
".",
"gr_... | Returns list of groups in which user is.
:param username: name of Linux user | [
"Returns",
"list",
"of",
"groups",
"in",
"which",
"user",
"is",
"."
] | python | train |
slhck/ffmpeg-normalize | ffmpeg_normalize/_ffmpeg_normalize.py | https://github.com/slhck/ffmpeg-normalize/blob/18477a7f2d092777ee238340be40c04ecb45c132/ffmpeg_normalize/_ffmpeg_normalize.py#L141-L161 | def add_media_file(self, input_file, output_file):
"""
Add a media file to normalize
Arguments:
input_file {str} -- Path to input file
output_file {str} -- Path to output file
"""
if not os.path.exists(input_file):
raise FFmpegNormalizeError("... | [
"def",
"add_media_file",
"(",
"self",
",",
"input_file",
",",
"output_file",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"input_file",
")",
":",
"raise",
"FFmpegNormalizeError",
"(",
"\"file \"",
"+",
"input_file",
"+",
"\" does not exist\"",... | Add a media file to normalize
Arguments:
input_file {str} -- Path to input file
output_file {str} -- Path to output file | [
"Add",
"a",
"media",
"file",
"to",
"normalize"
] | python | train |
python273/telegraph | telegraph/api.py | https://github.com/python273/telegraph/blob/6d45cd6bbae4fdbd85b48ce32626f3c66e9e5ddc/telegraph/api.py#L122-L139 | def get_page(self, path, return_content=True, return_html=True):
""" Get a Telegraph page
:param path: Path to the Telegraph page (in the format Title-12-31,
i.e. everything that comes after https://telegra.ph/)
:param return_content: If true, content field will be returne... | [
"def",
"get_page",
"(",
"self",
",",
"path",
",",
"return_content",
"=",
"True",
",",
"return_html",
"=",
"True",
")",
":",
"response",
"=",
"self",
".",
"_telegraph",
".",
"method",
"(",
"'getPage'",
",",
"path",
"=",
"path",
",",
"values",
"=",
"{",
... | Get a Telegraph page
:param path: Path to the Telegraph page (in the format Title-12-31,
i.e. everything that comes after https://telegra.ph/)
:param return_content: If true, content field will be returned
:param return_html: If true, returns HTML instead of Nodes list | [
"Get",
"a",
"Telegraph",
"page"
] | python | train |
pyroscope/pyrocore | src/pyrocore/util/load_config.py | https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/util/load_config.py#L213-L246 | def load(self, optional_cfg_files=None):
""" Actually load the configuation from either the default location or the given directory.
"""
optional_cfg_files = optional_cfg_files or []
# Guard against coding errors
if self._loaded:
raise RuntimeError("INTERNAL ERROR: A... | [
"def",
"load",
"(",
"self",
",",
"optional_cfg_files",
"=",
"None",
")",
":",
"optional_cfg_files",
"=",
"optional_cfg_files",
"or",
"[",
"]",
"# Guard against coding errors",
"if",
"self",
".",
"_loaded",
":",
"raise",
"RuntimeError",
"(",
"\"INTERNAL ERROR: Attemp... | Actually load the configuation from either the default location or the given directory. | [
"Actually",
"load",
"the",
"configuation",
"from",
"either",
"the",
"default",
"location",
"or",
"the",
"given",
"directory",
"."
] | python | train |
mdiener/grace | grace/py27/slimit/parser.py | https://github.com/mdiener/grace/blob/2dab13a2cf636da5da989904c5885166fc94d36d/grace/py27/slimit/parser.py#L1003-L1008 | def p_iteration_statement_4(self, p):
"""
iteration_statement \
: FOR LPAREN left_hand_side_expr IN expr RPAREN statement
"""
p[0] = ast.ForIn(item=p[3], iterable=p[5], statement=p[7]) | [
"def",
"p_iteration_statement_4",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"ForIn",
"(",
"item",
"=",
"p",
"[",
"3",
"]",
",",
"iterable",
"=",
"p",
"[",
"5",
"]",
",",
"statement",
"=",
"p",
"[",
"7",
"]",
")"
] | iteration_statement \
: FOR LPAREN left_hand_side_expr IN expr RPAREN statement | [
"iteration_statement",
"\\",
":",
"FOR",
"LPAREN",
"left_hand_side_expr",
"IN",
"expr",
"RPAREN",
"statement"
] | python | train |
petebachant/PXL | pxl/timeseries.py | https://github.com/petebachant/PXL/blob/d7d06cb74422e1ac0154741351fbecea080cfcc0/pxl/timeseries.py#L175-L196 | def calc_multi_exp_unc(sys_unc, n, mean, std, dof, confidence=0.95):
"""Calculate expanded uncertainty using values from multiple runs.
Note that this function assumes the statistic is a mean value, therefore
the combined standard deviation is divided by `sqrt(N)`.
Parameters
----------
... | [
"def",
"calc_multi_exp_unc",
"(",
"sys_unc",
",",
"n",
",",
"mean",
",",
"std",
",",
"dof",
",",
"confidence",
"=",
"0.95",
")",
":",
"sys_unc",
"=",
"sys_unc",
".",
"mean",
"(",
")",
"std_combined",
"=",
"combine_std",
"(",
"n",
",",
"mean",
",",
"s... | Calculate expanded uncertainty using values from multiple runs.
Note that this function assumes the statistic is a mean value, therefore
the combined standard deviation is divided by `sqrt(N)`.
Parameters
----------
sys_unc : numpy array of systematic uncertainties
n : numpy array of n... | [
"Calculate",
"expanded",
"uncertainty",
"using",
"values",
"from",
"multiple",
"runs",
".",
"Note",
"that",
"this",
"function",
"assumes",
"the",
"statistic",
"is",
"a",
"mean",
"value",
"therefore",
"the",
"combined",
"standard",
"deviation",
"is",
"divided",
"... | python | train |
minhhoit/yacms | yacms/blog/admin.py | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/blog/admin.py#L54-L61 | def has_module_permission(self, request):
"""
Hide from the admin menu unless explicitly set in ``ADMIN_MENU_ORDER``.
"""
for (name, items) in settings.ADMIN_MENU_ORDER:
if "blog.BlogCategory" in items:
return True
return False | [
"def",
"has_module_permission",
"(",
"self",
",",
"request",
")",
":",
"for",
"(",
"name",
",",
"items",
")",
"in",
"settings",
".",
"ADMIN_MENU_ORDER",
":",
"if",
"\"blog.BlogCategory\"",
"in",
"items",
":",
"return",
"True",
"return",
"False"
] | Hide from the admin menu unless explicitly set in ``ADMIN_MENU_ORDER``. | [
"Hide",
"from",
"the",
"admin",
"menu",
"unless",
"explicitly",
"set",
"in",
"ADMIN_MENU_ORDER",
"."
] | python | train |
limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L376-L443 | def _main_loop(self):
"""
Run jobs until must_stop returns True
"""
fetch_priorities_delay = timedelta(seconds=self.fetch_priorities_delay)
fetch_delayed_delay = timedelta(seconds=self.fetch_delayed_delay)
while not self.must_stop():
self.set_status('waiting'... | [
"def",
"_main_loop",
"(",
"self",
")",
":",
"fetch_priorities_delay",
"=",
"timedelta",
"(",
"seconds",
"=",
"self",
".",
"fetch_priorities_delay",
")",
"fetch_delayed_delay",
"=",
"timedelta",
"(",
"seconds",
"=",
"self",
".",
"fetch_delayed_delay",
")",
"while",... | Run jobs until must_stop returns True | [
"Run",
"jobs",
"until",
"must_stop",
"returns",
"True"
] | python | train |
quantopian/alphalens | alphalens/performance.py | https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/performance.py#L128-L204 | def factor_weights(factor_data,
demeaned=True,
group_adjust=False,
equal_weight=False):
"""
Computes asset weights by factor values and dividing by the sum of their
absolute value (achieving gross leverage of 1). Positive factor values will
result... | [
"def",
"factor_weights",
"(",
"factor_data",
",",
"demeaned",
"=",
"True",
",",
"group_adjust",
"=",
"False",
",",
"equal_weight",
"=",
"False",
")",
":",
"def",
"to_weights",
"(",
"group",
",",
"_demeaned",
",",
"_equal_weight",
")",
":",
"if",
"_equal_weig... | Computes asset weights by factor values and dividing by the sum of their
absolute value (achieving gross leverage of 1). Positive factor values will
results in positive weights and negative values in negative weights.
Parameters
----------
factor_data : pd.DataFrame - MultiIndex
A MultiInde... | [
"Computes",
"asset",
"weights",
"by",
"factor",
"values",
"and",
"dividing",
"by",
"the",
"sum",
"of",
"their",
"absolute",
"value",
"(",
"achieving",
"gross",
"leverage",
"of",
"1",
")",
".",
"Positive",
"factor",
"values",
"will",
"results",
"in",
"positiv... | python | train |
pypa/pipenv | pipenv/vendor/passa/internals/utils.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/passa/internals/utils.py#L20-L59 | def get_pinned_version(ireq):
"""Get the pinned version of an InstallRequirement.
An InstallRequirement is considered pinned if:
- Is not editable
- It has exactly one specifier
- That specifier is "=="
- The version does not contain a wildcard
Examples:
django==1.8 # pinned
... | [
"def",
"get_pinned_version",
"(",
"ireq",
")",
":",
"try",
":",
"specifier",
"=",
"ireq",
".",
"specifier",
"except",
"AttributeError",
":",
"raise",
"TypeError",
"(",
"\"Expected InstallRequirement, not {}\"",
".",
"format",
"(",
"type",
"(",
"ireq",
")",
".",
... | Get the pinned version of an InstallRequirement.
An InstallRequirement is considered pinned if:
- Is not editable
- It has exactly one specifier
- That specifier is "=="
- The version does not contain a wildcard
Examples:
django==1.8 # pinned
django>1.8 # NOT pinned
... | [
"Get",
"the",
"pinned",
"version",
"of",
"an",
"InstallRequirement",
"."
] | python | train |
anntzer/mplcursors | lib/mplcursors/_pick_info.py | https://github.com/anntzer/mplcursors/blob/a4bce17a978162b5a1837cc419114c910e7992f9/lib/mplcursors/_pick_info.py#L255-L270 | def _untransform(orig_xy, screen_xy, ax):
"""
Return data coordinates to place an annotation at screen coordinates
*screen_xy* in axes *ax*.
*orig_xy* are the "original" coordinates as stored by the artist; they are
transformed to *screen_xy* by whatever transform the artist uses. If the
artis... | [
"def",
"_untransform",
"(",
"orig_xy",
",",
"screen_xy",
",",
"ax",
")",
":",
"tr_xy",
"=",
"ax",
".",
"transData",
".",
"transform",
"(",
"orig_xy",
")",
"return",
"(",
"orig_xy",
"if",
"(",
"(",
"tr_xy",
"==",
"screen_xy",
")",
"|",
"np",
".",
"isn... | Return data coordinates to place an annotation at screen coordinates
*screen_xy* in axes *ax*.
*orig_xy* are the "original" coordinates as stored by the artist; they are
transformed to *screen_xy* by whatever transform the artist uses. If the
artist uses ``ax.transData``, just return *orig_xy*; else, ... | [
"Return",
"data",
"coordinates",
"to",
"place",
"an",
"annotation",
"at",
"screen",
"coordinates",
"*",
"screen_xy",
"*",
"in",
"axes",
"*",
"ax",
"*",
"."
] | python | train |
alvinwan/TexSoup | TexSoup/reader.py | https://github.com/alvinwan/TexSoup/blob/63323ed71510fd2351102b8c36660a3b7703cead/TexSoup/reader.py#L158-L165 | def tokenize_argument(text):
"""Process both optional and required arguments.
:param Buffer text: iterator over line, with current position
"""
for delim in ARG_TOKENS:
if text.startswith(delim):
return text.forward(len(delim)) | [
"def",
"tokenize_argument",
"(",
"text",
")",
":",
"for",
"delim",
"in",
"ARG_TOKENS",
":",
"if",
"text",
".",
"startswith",
"(",
"delim",
")",
":",
"return",
"text",
".",
"forward",
"(",
"len",
"(",
"delim",
")",
")"
] | Process both optional and required arguments.
:param Buffer text: iterator over line, with current position | [
"Process",
"both",
"optional",
"and",
"required",
"arguments",
"."
] | python | train |
bear/parsedatetime | parsedatetime/__init__.py | https://github.com/bear/parsedatetime/blob/830775dc5e36395622b41f12317f5e10c303d3a2/parsedatetime/__init__.py#L1155-L1179 | def _evalWeekday(self, datetimeString, sourceTime):
"""
Evaluate text passed by L{_partialParseWeekday()}
"""
s = datetimeString.strip()
sourceTime = self._evalDT(datetimeString, sourceTime)
# Given string is a weekday
yr, mth, dy, hr, mn, sec, wd, yd, isdst = so... | [
"def",
"_evalWeekday",
"(",
"self",
",",
"datetimeString",
",",
"sourceTime",
")",
":",
"s",
"=",
"datetimeString",
".",
"strip",
"(",
")",
"sourceTime",
"=",
"self",
".",
"_evalDT",
"(",
"datetimeString",
",",
"sourceTime",
")",
"# Given string is a weekday",
... | Evaluate text passed by L{_partialParseWeekday()} | [
"Evaluate",
"text",
"passed",
"by",
"L",
"{",
"_partialParseWeekday",
"()",
"}"
] | python | train |
AtteqCom/zsl | src/zsl/utils/string_helper.py | https://github.com/AtteqCom/zsl/blob/ab51a96da1780ff642912396d4b85bdcb72560c1/src/zsl/utils/string_helper.py#L85-L104 | def addslashes(s, escaped_chars=None):
"""Add slashes for given characters. Default is for ``\`` and ``'``.
:param s: string
:param escaped_chars: list of characters to prefix with a slash ``\``
:return: string with slashed characters
:rtype: str
:Example:
>>> addslashes("'")
"... | [
"def",
"addslashes",
"(",
"s",
",",
"escaped_chars",
"=",
"None",
")",
":",
"if",
"escaped_chars",
"is",
"None",
":",
"escaped_chars",
"=",
"[",
"\"\\\\\"",
",",
"\"'\"",
",",
"]",
"# l = [\"\\\\\", '\"', \"'\", \"\\0\", ]",
"for",
"i",
"in",
"escaped_chars",
... | Add slashes for given characters. Default is for ``\`` and ``'``.
:param s: string
:param escaped_chars: list of characters to prefix with a slash ``\``
:return: string with slashed characters
:rtype: str
:Example:
>>> addslashes("'")
"\\'" | [
"Add",
"slashes",
"for",
"given",
"characters",
".",
"Default",
"is",
"for",
"\\",
"and",
"."
] | python | train |
wummel/linkchecker | linkcheck/plugins/parseword.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/plugins/parseword.py#L93-L96 | def open_wordfile (app, filename):
"""Open given Word file with application object."""
return app.Documents.Open(filename, ReadOnly=True,
AddToRecentFiles=False, Visible=False, NoEncodingDialog=True) | [
"def",
"open_wordfile",
"(",
"app",
",",
"filename",
")",
":",
"return",
"app",
".",
"Documents",
".",
"Open",
"(",
"filename",
",",
"ReadOnly",
"=",
"True",
",",
"AddToRecentFiles",
"=",
"False",
",",
"Visible",
"=",
"False",
",",
"NoEncodingDialog",
"=",... | Open given Word file with application object. | [
"Open",
"given",
"Word",
"file",
"with",
"application",
"object",
"."
] | python | train |
prechelt/typecheck-decorator | typecheck/framework.py | https://github.com/prechelt/typecheck-decorator/blob/4aa5a7f17235c70b5b787c9e80bb1f24d3f15933/typecheck/framework.py#L96-L121 | def is_compatible(self, typevar, its_type):
"""
Checks whether its_type conforms to typevar.
If the typevar is not yet bound, it will be bound to its_type.
The covariance/contravariance checking described in the respective section
of PEP484 applies to declared types, but here we ... | [
"def",
"is_compatible",
"(",
"self",
",",
"typevar",
",",
"its_type",
")",
":",
"result",
"=",
"True",
"binding",
"=",
"self",
".",
"binding_of",
"(",
"typevar",
")",
"# may or may not exist",
"if",
"binding",
"is",
"None",
":",
"self",
".",
"bind",
"(",
... | Checks whether its_type conforms to typevar.
If the typevar is not yet bound, it will be bound to its_type.
The covariance/contravariance checking described in the respective section
of PEP484 applies to declared types, but here we have actual types;
therefore, (1) subtypes are always co... | [
"Checks",
"whether",
"its_type",
"conforms",
"to",
"typevar",
".",
"If",
"the",
"typevar",
"is",
"not",
"yet",
"bound",
"it",
"will",
"be",
"bound",
"to",
"its_type",
".",
"The",
"covariance",
"/",
"contravariance",
"checking",
"described",
"in",
"the",
"res... | python | train |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/rotmat.py#L313-L323 | def from_two_vectors(self, vec1, vec2):
'''get a rotation matrix from two vectors.
This returns a rotation matrix which when applied to vec1
will produce a vector pointing in the same direction as vec2'''
angle = vec1.angle(vec2)
cross = vec1 % vec2
if cross.length(... | [
"def",
"from_two_vectors",
"(",
"self",
",",
"vec1",
",",
"vec2",
")",
":",
"angle",
"=",
"vec1",
".",
"angle",
"(",
"vec2",
")",
"cross",
"=",
"vec1",
"%",
"vec2",
"if",
"cross",
".",
"length",
"(",
")",
"==",
"0",
":",
"# the two vectors are colinear... | get a rotation matrix from two vectors.
This returns a rotation matrix which when applied to vec1
will produce a vector pointing in the same direction as vec2 | [
"get",
"a",
"rotation",
"matrix",
"from",
"two",
"vectors",
".",
"This",
"returns",
"a",
"rotation",
"matrix",
"which",
"when",
"applied",
"to",
"vec1",
"will",
"produce",
"a",
"vector",
"pointing",
"in",
"the",
"same",
"direction",
"as",
"vec2"
] | python | train |
theislab/anndata | anndata/readwrite/write.py | https://github.com/theislab/anndata/blob/34f4eb63710628fbc15e7050e5efcac1d7806062/anndata/readwrite/write.py#L20-L67 | def write_csvs(dirname: PathLike, adata: AnnData, skip_data: bool = True, sep: str = ','):
"""See :meth:`~anndata.AnnData.write_csvs`.
"""
dirname = Path(dirname)
if dirname.suffix == '.csv':
dirname = dirname.with_suffix('')
logger.info("writing '.csv' files to %s", dirname)
if not dirn... | [
"def",
"write_csvs",
"(",
"dirname",
":",
"PathLike",
",",
"adata",
":",
"AnnData",
",",
"skip_data",
":",
"bool",
"=",
"True",
",",
"sep",
":",
"str",
"=",
"','",
")",
":",
"dirname",
"=",
"Path",
"(",
"dirname",
")",
"if",
"dirname",
".",
"suffix",... | See :meth:`~anndata.AnnData.write_csvs`. | [
"See",
":",
"meth",
":",
"~anndata",
".",
"AnnData",
".",
"write_csvs",
"."
] | python | train |
Esri/ArcREST | src/arcrest/enrichment/_geoenrichment.py | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/enrichment/_geoenrichment.py#L445-L546 | def getVariables(self,
sourceCountry,
optionalCountryDataset=None,
searchText=None):
r"""
The GeoEnrichment GetVariables helper method allows you to search
the data collections for variables that contain specific keywords.
T... | [
"def",
"getVariables",
"(",
"self",
",",
"sourceCountry",
",",
"optionalCountryDataset",
"=",
"None",
",",
"searchText",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"_base_url",
"+",
"self",
".",
"_url_getVariables",
"params",
"=",
"{",
"\"f\"",
":",
"... | r"""
The GeoEnrichment GetVariables helper method allows you to search
the data collections for variables that contain specific keywords.
To see the comprehensive set of global Esri Demographics data that
are available, use the interactive data browser:
http://resources.arcgis.c... | [
"r",
"The",
"GeoEnrichment",
"GetVariables",
"helper",
"method",
"allows",
"you",
"to",
"search",
"the",
"data",
"collections",
"for",
"variables",
"that",
"contain",
"specific",
"keywords",
"."
] | python | train |
jobovy/galpy | galpy/potential/SoftenedNeedleBarPotential.py | https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/potential/SoftenedNeedleBarPotential.py#L112-L129 | def _Rforce(self,R,z,phi=0.,t=0.):
"""
NAME:
_Rforce
PURPOSE:
evaluate the radial force for this potential
INPUT:
R - Galactocentric cylindrical radius
z - vertical height
phi - azimuth
t - time
OUTPUT:
... | [
"def",
"_Rforce",
"(",
"self",
",",
"R",
",",
"z",
",",
"phi",
"=",
"0.",
",",
"t",
"=",
"0.",
")",
":",
"self",
".",
"_compute_xyzforces",
"(",
"R",
",",
"z",
",",
"phi",
",",
"t",
")",
"return",
"numpy",
".",
"cos",
"(",
"phi",
")",
"*",
... | NAME:
_Rforce
PURPOSE:
evaluate the radial force for this potential
INPUT:
R - Galactocentric cylindrical radius
z - vertical height
phi - azimuth
t - time
OUTPUT:
the radial force
HISTORY:
2016-11-02... | [
"NAME",
":",
"_Rforce",
"PURPOSE",
":",
"evaluate",
"the",
"radial",
"force",
"for",
"this",
"potential",
"INPUT",
":",
"R",
"-",
"Galactocentric",
"cylindrical",
"radius",
"z",
"-",
"vertical",
"height",
"phi",
"-",
"azimuth",
"t",
"-",
"time",
"OUTPUT",
... | python | train |
GoogleCloudPlatform/appengine-mapreduce | python/src/mapreduce/context.py | https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/context.py#L323-L326 | def _flush_ndb_puts(self, items, options):
"""Flush all NDB puts to datastore."""
assert ndb is not None
ndb.put_multi(items, config=self._create_config(options)) | [
"def",
"_flush_ndb_puts",
"(",
"self",
",",
"items",
",",
"options",
")",
":",
"assert",
"ndb",
"is",
"not",
"None",
"ndb",
".",
"put_multi",
"(",
"items",
",",
"config",
"=",
"self",
".",
"_create_config",
"(",
"options",
")",
")"
] | Flush all NDB puts to datastore. | [
"Flush",
"all",
"NDB",
"puts",
"to",
"datastore",
"."
] | python | train |
seequent/properties | properties/basic.py | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/basic.py#L376-L383 | def sphinx_class(self):
"""Property class name formatted for Sphinx doc linking"""
classdoc = ':class:`{cls} <{pref}.{cls}>`'
if self.__module__.split('.')[0] == 'properties':
pref = 'properties'
else:
pref = text_type(self.__module__)
return classdoc.form... | [
"def",
"sphinx_class",
"(",
"self",
")",
":",
"classdoc",
"=",
"':class:`{cls} <{pref}.{cls}>`'",
"if",
"self",
".",
"__module__",
".",
"split",
"(",
"'.'",
")",
"[",
"0",
"]",
"==",
"'properties'",
":",
"pref",
"=",
"'properties'",
"else",
":",
"pref",
"=... | Property class name formatted for Sphinx doc linking | [
"Property",
"class",
"name",
"formatted",
"for",
"Sphinx",
"doc",
"linking"
] | python | train |
rq/Flask-RQ2 | src/flask_rq2/functions.py | https://github.com/rq/Flask-RQ2/blob/58eedf6f0cd7bcde4ccd787074762ea08f531337/src/flask_rq2/functions.py#L65-L139 | def queue(self, *args, **kwargs):
"""
A function to queue a RQ job, e.g.::
@rq.job(timeout=60)
def add(x, y):
return x + y
add.queue(1, 2, timeout=30)
:param \\*args: The positional arguments to pass to the queued job.
:param \\*\\*... | [
"def",
"queue",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"queue_name",
"=",
"kwargs",
".",
"pop",
"(",
"'queue'",
",",
"self",
".",
"queue_name",
")",
"timeout",
"=",
"kwargs",
".",
"pop",
"(",
"'timeout'",
",",
"self",
"."... | A function to queue a RQ job, e.g.::
@rq.job(timeout=60)
def add(x, y):
return x + y
add.queue(1, 2, timeout=30)
:param \\*args: The positional arguments to pass to the queued job.
:param \\*\\*kwargs: The keyword arguments to pass to the queued jo... | [
"A",
"function",
"to",
"queue",
"a",
"RQ",
"job",
"e",
".",
"g",
".",
"::"
] | python | train |
jkitzes/macroeco | macroeco/empirical/_empirical.py | https://github.com/jkitzes/macroeco/blob/ee5fac5560a2d64de3a64738b5bc6833e2d7ff2e/macroeco/empirical/_empirical.py#L310-L373 | def _subset_meta(full_meta, subset, incremented=False):
"""
Return metadata reflecting all conditions in subset
Parameters
----------
full_meta : ConfigParser obj
Metadata object
subset : str
String describing subset of data to use for analysis
incremented : bool
If ... | [
"def",
"_subset_meta",
"(",
"full_meta",
",",
"subset",
",",
"incremented",
"=",
"False",
")",
":",
"if",
"not",
"subset",
":",
"return",
"full_meta",
",",
"False",
"meta",
"=",
"{",
"}",
"# Make deepcopy of entire meta (all section dicts in meta dict)",
"for",
"k... | Return metadata reflecting all conditions in subset
Parameters
----------
full_meta : ConfigParser obj
Metadata object
subset : str
String describing subset of data to use for analysis
incremented : bool
If True, the metadata has already been incremented
Returns
---... | [
"Return",
"metadata",
"reflecting",
"all",
"conditions",
"in",
"subset"
] | python | train |
bitprophet/botox | botox/aws.py | https://github.com/bitprophet/botox/blob/02c887a28bd2638273548cc7d1e6d6f1d4d38bf9/botox/aws.py#L217-L231 | def get_subnet_id(self, name):
"""
Return subnet ID for given ``name``, if it exists.
E.g. with a subnet mapping of ``{'abc123': 'ops', '67fd56': 'prod'}``,
``get_subnet_id('ops')`` would return ``'abc123'``. If the map has
non-unique values, the first matching key will be retur... | [
"def",
"get_subnet_id",
"(",
"self",
",",
"name",
")",
":",
"for",
"subnet_id",
",",
"subnet_name",
"in",
"self",
".",
"config",
"[",
"'subnets'",
"]",
".",
"iteritems",
"(",
")",
":",
"if",
"subnet_name",
"==",
"name",
":",
"return",
"subnet_id",
"retur... | Return subnet ID for given ``name``, if it exists.
E.g. with a subnet mapping of ``{'abc123': 'ops', '67fd56': 'prod'}``,
``get_subnet_id('ops')`` would return ``'abc123'``. If the map has
non-unique values, the first matching key will be returned.
If no match is found, the given ``nam... | [
"Return",
"subnet",
"ID",
"for",
"given",
"name",
"if",
"it",
"exists",
"."
] | python | train |
aequitas/python-rflink | rflink/protocol.py | https://github.com/aequitas/python-rflink/blob/46759ce8daf95cfc7cdb608ae17bc5501be9f6d8/rflink/protocol.py#L282-L291 | def handle_event(self, event):
"""Handle incoming packet from rflink gateway."""
if event.get('command'):
if event['command'] == 'on':
cmd = 'off'
else:
cmd = 'on'
task = self.send_command_ack(event['id'], cmd)
self.loop.cr... | [
"def",
"handle_event",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"get",
"(",
"'command'",
")",
":",
"if",
"event",
"[",
"'command'",
"]",
"==",
"'on'",
":",
"cmd",
"=",
"'off'",
"else",
":",
"cmd",
"=",
"'on'",
"task",
"=",
"self",
... | Handle incoming packet from rflink gateway. | [
"Handle",
"incoming",
"packet",
"from",
"rflink",
"gateway",
"."
] | python | train |
seleniumbase/SeleniumBase | seleniumbase/fixtures/base_case.py | https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/fixtures/base_case.py#L3079-L3200 | def setUp(self, masterqa_mode=False):
"""
Be careful if a subclass of BaseCase overrides setUp()
You'll need to add the following line to the subclass setUp() method:
super(SubClassOfBaseCase, self).setUp()
"""
self.masterqa_mode = masterqa_mode
self.is_pytest = N... | [
"def",
"setUp",
"(",
"self",
",",
"masterqa_mode",
"=",
"False",
")",
":",
"self",
".",
"masterqa_mode",
"=",
"masterqa_mode",
"self",
".",
"is_pytest",
"=",
"None",
"try",
":",
"# This raises an exception if the test is not coming from pytest",
"self",
".",
"is_pyt... | Be careful if a subclass of BaseCase overrides setUp()
You'll need to add the following line to the subclass setUp() method:
super(SubClassOfBaseCase, self).setUp() | [
"Be",
"careful",
"if",
"a",
"subclass",
"of",
"BaseCase",
"overrides",
"setUp",
"()",
"You",
"ll",
"need",
"to",
"add",
"the",
"following",
"line",
"to",
"the",
"subclass",
"setUp",
"()",
"method",
":",
"super",
"(",
"SubClassOfBaseCase",
"self",
")",
".",... | python | train |
DLR-RM/RAFCON | source/rafcon/core/global_variable_manager.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/core/global_variable_manager.py#L310-L319 | def global_variable_dictionary(self):
"""Property for the _global_variable_dictionary field"""
dict_copy = {}
for key, value in self.__global_variable_dictionary.items():
if key in self.__variable_references and self.__variable_references[key]:
dict_copy[key] = value
... | [
"def",
"global_variable_dictionary",
"(",
"self",
")",
":",
"dict_copy",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"self",
".",
"__global_variable_dictionary",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"self",
".",
"__variable_references",
"and"... | Property for the _global_variable_dictionary field | [
"Property",
"for",
"the",
"_global_variable_dictionary",
"field"
] | python | train |
saltstack/salt | salt/modules/vsphere.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/vsphere.py#L8127-L8194 | def _apply_serial_port(serial_device_spec, key, operation='add'):
'''
Returns a vim.vm.device.VirtualSerialPort representing a serial port
component
serial_device_spec
Serial device properties
key
Unique key of the device
operation
Add or edit the given device
.. ... | [
"def",
"_apply_serial_port",
"(",
"serial_device_spec",
",",
"key",
",",
"operation",
"=",
"'add'",
")",
":",
"log",
".",
"trace",
"(",
"'Creating serial port adapter=%s type=%s connectable=%s yield=%s'",
",",
"serial_device_spec",
"[",
"'adapter'",
"]",
",",
"serial_de... | Returns a vim.vm.device.VirtualSerialPort representing a serial port
component
serial_device_spec
Serial device properties
key
Unique key of the device
operation
Add or edit the given device
.. code-block:: bash
serial_ports:
adapter: 'Serial port 1'
... | [
"Returns",
"a",
"vim",
".",
"vm",
".",
"device",
".",
"VirtualSerialPort",
"representing",
"a",
"serial",
"port",
"component"
] | python | train |
yola/yoconfigurator | yoconfigurator/smush.py | https://github.com/yola/yoconfigurator/blob/dfb60fa1e30ae7cfec2526bb101fc205f5952639/yoconfigurator/smush.py#L72-L84 | def smush_config(sources, initial=None):
"""Merge the configuration sources and return the resulting DotDict."""
if initial is None:
initial = {}
config = DotDict(initial)
for fn in sources:
log.debug('Merging %s', fn)
mod = get_config_module(fn)
config = mod.update(conf... | [
"def",
"smush_config",
"(",
"sources",
",",
"initial",
"=",
"None",
")",
":",
"if",
"initial",
"is",
"None",
":",
"initial",
"=",
"{",
"}",
"config",
"=",
"DotDict",
"(",
"initial",
")",
"for",
"fn",
"in",
"sources",
":",
"log",
".",
"debug",
"(",
... | Merge the configuration sources and return the resulting DotDict. | [
"Merge",
"the",
"configuration",
"sources",
"and",
"return",
"the",
"resulting",
"DotDict",
"."
] | python | valid |
EventTeam/beliefs | src/beliefs/cells/numeric.py | https://github.com/EventTeam/beliefs/blob/c07d22b61bebeede74a72800030dde770bf64208/src/beliefs/cells/numeric.py#L63-L72 | def is_contradictory(self, other):
"""
Whether other and self can coexist
"""
other = IntervalCell.coerce(other)
assert other.low <= other.high, "Low must be <= high"
if max(other.low, self.low) <= min(other.high, self.high):
return False
else:
... | [
"def",
"is_contradictory",
"(",
"self",
",",
"other",
")",
":",
"other",
"=",
"IntervalCell",
".",
"coerce",
"(",
"other",
")",
"assert",
"other",
".",
"low",
"<=",
"other",
".",
"high",
",",
"\"Low must be <= high\"",
"if",
"max",
"(",
"other",
".",
"lo... | Whether other and self can coexist | [
"Whether",
"other",
"and",
"self",
"can",
"coexist"
] | python | train |
Cue/scales | src/greplin/scales/graphite.py | https://github.com/Cue/scales/blob/0aced26eb050ceb98ee9d5d6cdca8db448666986/src/greplin/scales/graphite.py#L55-L67 | def _forbidden(self, path, value):
"""Is a stat forbidden? Goes through the rules to find one that
applies. Chronologically newer rules are higher-precedence than
older ones. If no rule applies, the stat is forbidden by default."""
if path[0] == '/':
path = path[1:]
for rule in reversed(self.r... | [
"def",
"_forbidden",
"(",
"self",
",",
"path",
",",
"value",
")",
":",
"if",
"path",
"[",
"0",
"]",
"==",
"'/'",
":",
"path",
"=",
"path",
"[",
"1",
":",
"]",
"for",
"rule",
"in",
"reversed",
"(",
"self",
".",
"rules",
")",
":",
"if",
"isinstan... | Is a stat forbidden? Goes through the rules to find one that
applies. Chronologically newer rules are higher-precedence than
older ones. If no rule applies, the stat is forbidden by default. | [
"Is",
"a",
"stat",
"forbidden?",
"Goes",
"through",
"the",
"rules",
"to",
"find",
"one",
"that",
"applies",
".",
"Chronologically",
"newer",
"rules",
"are",
"higher",
"-",
"precedence",
"than",
"older",
"ones",
".",
"If",
"no",
"rule",
"applies",
"the",
"s... | python | train |
shapiromatron/bmds | bmds/models/base.py | https://github.com/shapiromatron/bmds/blob/395c6ce84ad82876fd9fa4a89a3497fb61616de0/bmds/models/base.py#L316-L323 | def write_dfile(self):
"""
Write the generated d_file to a temporary file.
"""
f_in = self.tempfiles.get_tempfile(prefix="bmds-", suffix=".(d)")
with open(f_in, "w") as f:
f.write(self.as_dfile())
return f_in | [
"def",
"write_dfile",
"(",
"self",
")",
":",
"f_in",
"=",
"self",
".",
"tempfiles",
".",
"get_tempfile",
"(",
"prefix",
"=",
"\"bmds-\"",
",",
"suffix",
"=",
"\".(d)\"",
")",
"with",
"open",
"(",
"f_in",
",",
"\"w\"",
")",
"as",
"f",
":",
"f",
".",
... | Write the generated d_file to a temporary file. | [
"Write",
"the",
"generated",
"d_file",
"to",
"a",
"temporary",
"file",
"."
] | python | train |
osrg/ryu | ryu/lib/ovs/vsctl.py | https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/lib/ovs/vsctl.py#L2271-L2279 | def _add(self, ctx, table_name, record_id, column_values):
"""
:type column_values: list of (column, value_json)
"""
vsctl_table = self._get_table(table_name)
ovsrec_row = ctx.must_get_row(vsctl_table, record_id)
for column, value in column_values:
ctx.add_col... | [
"def",
"_add",
"(",
"self",
",",
"ctx",
",",
"table_name",
",",
"record_id",
",",
"column_values",
")",
":",
"vsctl_table",
"=",
"self",
".",
"_get_table",
"(",
"table_name",
")",
"ovsrec_row",
"=",
"ctx",
".",
"must_get_row",
"(",
"vsctl_table",
",",
"rec... | :type column_values: list of (column, value_json) | [
":",
"type",
"column_values",
":",
"list",
"of",
"(",
"column",
"value_json",
")"
] | python | train |
peopledoc/populous | populous/cli.py | https://github.com/peopledoc/populous/blob/50ea445ee973c82a36e0853ae7e2817961143b05/populous/cli.py#L79-L97 | def generators():
"""
List all the available generators.
"""
from populous import generators
base = generators.Generator
for name in dir(generators):
generator = getattr(generators, name)
if isinstance(generator, type) and issubclass(generator, base):
name = genera... | [
"def",
"generators",
"(",
")",
":",
"from",
"populous",
"import",
"generators",
"base",
"=",
"generators",
".",
"Generator",
"for",
"name",
"in",
"dir",
"(",
"generators",
")",
":",
"generator",
"=",
"getattr",
"(",
"generators",
",",
"name",
")",
"if",
... | List all the available generators. | [
"List",
"all",
"the",
"available",
"generators",
"."
] | python | train |
pypa/pipenv | pipenv/vendor/requests/_internal_utils.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/_internal_utils.py#L30-L42 | def unicode_is_ascii(u_string):
"""Determine if unicode string only contains ASCII characters.
:param str u_string: unicode string to check. Must be unicode
and not Python 2 `str`.
:rtype: bool
"""
assert isinstance(u_string, str)
try:
u_string.encode('ascii')
return Tru... | [
"def",
"unicode_is_ascii",
"(",
"u_string",
")",
":",
"assert",
"isinstance",
"(",
"u_string",
",",
"str",
")",
"try",
":",
"u_string",
".",
"encode",
"(",
"'ascii'",
")",
"return",
"True",
"except",
"UnicodeEncodeError",
":",
"return",
"False"
] | Determine if unicode string only contains ASCII characters.
:param str u_string: unicode string to check. Must be unicode
and not Python 2 `str`.
:rtype: bool | [
"Determine",
"if",
"unicode",
"string",
"only",
"contains",
"ASCII",
"characters",
"."
] | python | train |
intake/intake | intake/catalog/base.py | https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/catalog/base.py#L674-L715 | def _load(self):
"""Fetch metadata from remote. Entries are fetched lazily."""
# This will not immediately fetch any sources (entries). It will lazily
# fetch sources from the server in paginated blocks when this Catalog
# is iterated over. It will fetch specific sources when they are
... | [
"def",
"_load",
"(",
"self",
")",
":",
"# This will not immediately fetch any sources (entries). It will lazily",
"# fetch sources from the server in paginated blocks when this Catalog",
"# is iterated over. It will fetch specific sources when they are",
"# accessed in this Catalog via __getitem__... | Fetch metadata from remote. Entries are fetched lazily. | [
"Fetch",
"metadata",
"from",
"remote",
".",
"Entries",
"are",
"fetched",
"lazily",
"."
] | python | train |
getsentry/raven-python | raven/base.py | https://github.com/getsentry/raven-python/blob/d891c20f0f930153f508e9d698d9de42e910face/raven/base.py#L752-L781 | def send_encoded(self, message, auth_header=None, **kwargs):
"""
Given an already serialized message, signs the message and passes the
payload off to ``send_remote``.
"""
client_string = 'raven-python/%s' % (raven.VERSION,)
if not auth_header:
timestamp = tim... | [
"def",
"send_encoded",
"(",
"self",
",",
"message",
",",
"auth_header",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"client_string",
"=",
"'raven-python/%s'",
"%",
"(",
"raven",
".",
"VERSION",
",",
")",
"if",
"not",
"auth_header",
":",
"timestamp",
... | Given an already serialized message, signs the message and passes the
payload off to ``send_remote``. | [
"Given",
"an",
"already",
"serialized",
"message",
"signs",
"the",
"message",
"and",
"passes",
"the",
"payload",
"off",
"to",
"send_remote",
"."
] | python | train |
sethmlarson/virtualbox-python | virtualbox/library.py | https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L24723-L24745 | def put_event_multi_touch_string(self, count, contacts, scan_time):
""":py:func:`put_event_multi_touch`
in count of type int
:py:func:`put_event_multi_touch`
in contacts of type str
Contains information about all contacts:
"id1,x1,y1,inContact1,inRange1;..... | [
"def",
"put_event_multi_touch_string",
"(",
"self",
",",
"count",
",",
"contacts",
",",
"scan_time",
")",
":",
"if",
"not",
"isinstance",
"(",
"count",
",",
"baseinteger",
")",
":",
"raise",
"TypeError",
"(",
"\"count can only be an instance of type baseinteger\"",
... | :py:func:`put_event_multi_touch`
in count of type int
:py:func:`put_event_multi_touch`
in contacts of type str
Contains information about all contacts:
"id1,x1,y1,inContact1,inRange1;...;idN,xN,yN,inContactN,inRangeN".
For example for two contacts: "0,... | [
":",
"py",
":",
"func",
":",
"put_event_multi_touch"
] | python | train |
bokeh/bokeh | bokeh/model.py | https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/model.py#L838-L861 | def _visit_value_and_its_immediate_references(obj, visitor):
''' Recurse down Models, HasProps, and Python containers
The ordering in this function is to optimize performance. We check the
most comomn types (int, float, str) first so that we can quickly return in
the common case. We avoid isinstance ... | [
"def",
"_visit_value_and_its_immediate_references",
"(",
"obj",
",",
"visitor",
")",
":",
"typ",
"=",
"type",
"(",
"obj",
")",
"if",
"typ",
"in",
"_common_types",
":",
"# short circuit on common base types",
"return",
"if",
"typ",
"is",
"list",
"or",
"issubclass",... | Recurse down Models, HasProps, and Python containers
The ordering in this function is to optimize performance. We check the
most comomn types (int, float, str) first so that we can quickly return in
the common case. We avoid isinstance and issubclass checks in a couple
places with `type` checks becau... | [
"Recurse",
"down",
"Models",
"HasProps",
"and",
"Python",
"containers"
] | python | train |
titusjan/argos | argos/inspector/pgplugins/pgctis.py | https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/inspector/pgplugins/pgctis.py#L298-L312 | def setAutoRangeOff(self):
""" Turns off the auto range checkbox.
Calls _refreshNodeFromTarget, not _updateTargetFromNode, because setting auto range off
does not require a redraw of the target.
"""
# TODO: catch exceptions. How?
# /argos/hdf-eos/DeepBlue-SeaWiFS-... | [
"def",
"setAutoRangeOff",
"(",
"self",
")",
":",
"# TODO: catch exceptions. How?",
"# /argos/hdf-eos/DeepBlue-SeaWiFS-1.0_L3_20100101_v002-20110527T191319Z.h5/aerosol_optical_thickness_stddev_ocean",
"if",
"self",
".",
"getRefreshBlocked",
"(",
")",
":",
"logger",
".",
"debug",
"... | Turns off the auto range checkbox.
Calls _refreshNodeFromTarget, not _updateTargetFromNode, because setting auto range off
does not require a redraw of the target. | [
"Turns",
"off",
"the",
"auto",
"range",
"checkbox",
".",
"Calls",
"_refreshNodeFromTarget",
"not",
"_updateTargetFromNode",
"because",
"setting",
"auto",
"range",
"off",
"does",
"not",
"require",
"a",
"redraw",
"of",
"the",
"target",
"."
] | python | train |
seleniumbase/SeleniumBase | seleniumbase/plugins/db_reporting_plugin.py | https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/plugins/db_reporting_plugin.py#L49-L57 | def begin(self):
""" At the start of the run, we want to record the test
execution information in the database. """
exec_payload = ExecutionQueryPayload()
exec_payload.execution_start_time = int(time.time() * 1000)
self.execution_start_time = exec_payload.execution_start_time... | [
"def",
"begin",
"(",
"self",
")",
":",
"exec_payload",
"=",
"ExecutionQueryPayload",
"(",
")",
"exec_payload",
".",
"execution_start_time",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
"*",
"1000",
")",
"self",
".",
"execution_start_time",
"=",
"exec_payl... | At the start of the run, we want to record the test
execution information in the database. | [
"At",
"the",
"start",
"of",
"the",
"run",
"we",
"want",
"to",
"record",
"the",
"test",
"execution",
"information",
"in",
"the",
"database",
"."
] | python | train |
rwl/pylon | pylon/io/dot.py | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/dot.py#L125-L133 | def write_branch_data(self, file, padding=" "):
""" Writes branch data in Graphviz DOT language.
"""
attrs = ['%s="%s"' % (k,v) for k,v in self.branch_attr.iteritems()]
attr_str = ", ".join(attrs)
for br in self.case.branches:
file.write("%s%s -> %s [%s];\n" % \
... | [
"def",
"write_branch_data",
"(",
"self",
",",
"file",
",",
"padding",
"=",
"\" \"",
")",
":",
"attrs",
"=",
"[",
"'%s=\"%s\"'",
"%",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"branch_attr",
".",
"iteritems",
"(",
")",
"]"... | Writes branch data in Graphviz DOT language. | [
"Writes",
"branch",
"data",
"in",
"Graphviz",
"DOT",
"language",
"."
] | python | train |
pazz/alot | alot/account.py | https://github.com/pazz/alot/blob/d0297605c0ec1c6b65f541d0fd5b69ac5a0f4ded/alot/account.py#L316-L322 | def store_sent_mail(self, mail):
"""
stores mail (:class:`email.message.Message` or str) in send-store if
:attr:`sent_box` is set.
"""
if self.sent_box is not None:
return self.store_mail(self.sent_box, mail) | [
"def",
"store_sent_mail",
"(",
"self",
",",
"mail",
")",
":",
"if",
"self",
".",
"sent_box",
"is",
"not",
"None",
":",
"return",
"self",
".",
"store_mail",
"(",
"self",
".",
"sent_box",
",",
"mail",
")"
] | stores mail (:class:`email.message.Message` or str) in send-store if
:attr:`sent_box` is set. | [
"stores",
"mail",
"(",
":",
"class",
":",
"email",
".",
"message",
".",
"Message",
"or",
"str",
")",
"in",
"send",
"-",
"store",
"if",
":",
"attr",
":",
"sent_box",
"is",
"set",
"."
] | python | train |
psss/fmf | fmf/utils.py | https://github.com/psss/fmf/blob/419f2f195d92339b8f9e5d11c0bea0f303e5fd75/fmf/utils.py#L338-L355 | def _create_logger(name='fmf', level=None):
""" Create fmf logger """
# Create logger, handler and formatter
logger = logging.getLogger(name)
handler = logging.StreamHandler()
handler.setFormatter(Logging.ColoredFormatter())
logger.addHandler(handler)
# Save log l... | [
"def",
"_create_logger",
"(",
"name",
"=",
"'fmf'",
",",
"level",
"=",
"None",
")",
":",
"# Create logger, handler and formatter",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"name",
")",
"handler",
"=",
"logging",
".",
"StreamHandler",
"(",
")",
"handler... | Create fmf logger | [
"Create",
"fmf",
"logger"
] | python | train |
SheffieldML/GPy | GPy/util/netpbmfile.py | https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/util/netpbmfile.py#L265-L272 | def _tofile(self, fh, pam=False):
"""Write Netbm file."""
fh.seek(0)
fh.write(self._header(pam))
data = self.asarray(copy=False)
if self.maxval == 1:
data = numpy.packbits(data, axis=-1)
data.tofile(fh) | [
"def",
"_tofile",
"(",
"self",
",",
"fh",
",",
"pam",
"=",
"False",
")",
":",
"fh",
".",
"seek",
"(",
"0",
")",
"fh",
".",
"write",
"(",
"self",
".",
"_header",
"(",
"pam",
")",
")",
"data",
"=",
"self",
".",
"asarray",
"(",
"copy",
"=",
"Fal... | Write Netbm file. | [
"Write",
"Netbm",
"file",
"."
] | python | train |
CalebBell/ht | ht/hx.py | https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/hx.py#L3254-L3362 | def NTU_from_P_E(P1, R1, Ntp, optimal=True):
r'''Returns the number of transfer units of a TEMA E type heat exchanger
with a specified (for side 1) thermal effectiveness `P1`, heat capacity
ratio `R1`, the number of tube passes `Ntp`, and for the two-pass case
whether or not the inlets are arranged opt... | [
"def",
"NTU_from_P_E",
"(",
"P1",
",",
"R1",
",",
"Ntp",
",",
"optimal",
"=",
"True",
")",
":",
"NTU_min",
"=",
"1E-11",
"function",
"=",
"temperature_effectiveness_TEMA_E",
"if",
"Ntp",
"==",
"1",
":",
"return",
"NTU_from_P_basic",
"(",
"P1",
",",
"R1",
... | r'''Returns the number of transfer units of a TEMA E type heat exchanger
with a specified (for side 1) thermal effectiveness `P1`, heat capacity
ratio `R1`, the number of tube passes `Ntp`, and for the two-pass case
whether or not the inlets are arranged optimally. The supported cases are
as follows:
... | [
"r",
"Returns",
"the",
"number",
"of",
"transfer",
"units",
"of",
"a",
"TEMA",
"E",
"type",
"heat",
"exchanger",
"with",
"a",
"specified",
"(",
"for",
"side",
"1",
")",
"thermal",
"effectiveness",
"P1",
"heat",
"capacity",
"ratio",
"R1",
"the",
"number",
... | python | train |
nerdvegas/rez | src/rez/utils/backcompat.py | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/utils/backcompat.py#L20-L37 | def convert_old_variant_handle(handle_dict):
"""Convert a variant handle from serialize_version < 4.0."""
old_variables = handle_dict.get("variables", {})
variables = dict(repository_type="filesystem")
for old_key, key in variant_key_conversions.iteritems():
value = old_variables.get(old_key)
... | [
"def",
"convert_old_variant_handle",
"(",
"handle_dict",
")",
":",
"old_variables",
"=",
"handle_dict",
".",
"get",
"(",
"\"variables\"",
",",
"{",
"}",
")",
"variables",
"=",
"dict",
"(",
"repository_type",
"=",
"\"filesystem\"",
")",
"for",
"old_key",
",",
"... | Convert a variant handle from serialize_version < 4.0. | [
"Convert",
"a",
"variant",
"handle",
"from",
"serialize_version",
"<",
"4",
".",
"0",
"."
] | python | train |
spyder-ide/spyder | spyder/plugins/explorer/widgets.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/explorer/widgets.py#L197-L200 | def set_name_filters(self, name_filters):
"""Set name filters"""
self.name_filters = name_filters
self.fsmodel.setNameFilters(name_filters) | [
"def",
"set_name_filters",
"(",
"self",
",",
"name_filters",
")",
":",
"self",
".",
"name_filters",
"=",
"name_filters",
"self",
".",
"fsmodel",
".",
"setNameFilters",
"(",
"name_filters",
")"
] | Set name filters | [
"Set",
"name",
"filters"
] | python | train |
xenadevel/PyXenaManager | xenamanager/api/xena_cli.py | https://github.com/xenadevel/PyXenaManager/blob/384ca265f73044b8a8b471f5dd7a6103fc54f4df/xenamanager/api/xena_cli.py#L34-L43 | def add_chassis(self, chassis):
"""
:param ip: chassis object
"""
self.chassis_list[chassis] = XenaSocket(self.logger, chassis.ip, chassis.port)
self.chassis_list[chassis].connect()
KeepAliveThread(self.chassis_list[chassis]).start()
self.send_command(chassis, 'c... | [
"def",
"add_chassis",
"(",
"self",
",",
"chassis",
")",
":",
"self",
".",
"chassis_list",
"[",
"chassis",
"]",
"=",
"XenaSocket",
"(",
"self",
".",
"logger",
",",
"chassis",
".",
"ip",
",",
"chassis",
".",
"port",
")",
"self",
".",
"chassis_list",
"[",... | :param ip: chassis object | [
":",
"param",
"ip",
":",
"chassis",
"object"
] | python | train |
usc-isi-i2/etk | etk/extractors/readability/readability.py | https://github.com/usc-isi-i2/etk/blob/aab077c984ea20f5e8ae33af622fe11d3c4df866/etk/extractors/readability/readability.py#L146-L217 | def summary(self, html_partial=False):
"""Generate the summary of the html docuemnt
:param html_partial: return only the div of the document, don't wrap
in html and body tags.
"""
try:
ruthless = True
#Added recall priority flag
... | [
"def",
"summary",
"(",
"self",
",",
"html_partial",
"=",
"False",
")",
":",
"try",
":",
"ruthless",
"=",
"True",
"#Added recall priority flag",
"recallPriority",
"=",
"self",
".",
"recallPriority",
"if",
"recallPriority",
":",
"ruthless",
"=",
"False",
"self",
... | Generate the summary of the html docuemnt
:param html_partial: return only the div of the document, don't wrap
in html and body tags. | [
"Generate",
"the",
"summary",
"of",
"the",
"html",
"docuemnt"
] | python | train |
swisscom/cleanerversion | versions/models.py | https://github.com/swisscom/cleanerversion/blob/becadbab5d7b474a0e9a596b99e97682402d2f2c/versions/models.py#L500-L516 | def _fetch_all(self):
"""
Completely overrides the QuerySet._fetch_all method by adding the
timestamp to all objects
:return: See django.db.models.query.QuerySet._fetch_all for return
values
"""
if self._result_cache is None:
self._result_cache = ... | [
"def",
"_fetch_all",
"(",
"self",
")",
":",
"if",
"self",
".",
"_result_cache",
"is",
"None",
":",
"self",
".",
"_result_cache",
"=",
"list",
"(",
"self",
".",
"iterator",
"(",
")",
")",
"# TODO: Do we have to test for ValuesListIterable, ValuesIterable,",
"# and ... | Completely overrides the QuerySet._fetch_all method by adding the
timestamp to all objects
:return: See django.db.models.query.QuerySet._fetch_all for return
values | [
"Completely",
"overrides",
"the",
"QuerySet",
".",
"_fetch_all",
"method",
"by",
"adding",
"the",
"timestamp",
"to",
"all",
"objects"
] | python | train |
Alignak-monitoring/alignak | alignak/objects/realm.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/realm.py#L474-L519 | def get_links_for_a_scheduler(self, pollers, reactionners, brokers):
"""Get a configuration dictionary with pollers, reactionners and brokers links
for a scheduler
:return: dict containing pollers, reactionners and brokers links (key is satellite id)
:rtype: dict
"""
# ... | [
"def",
"get_links_for_a_scheduler",
"(",
"self",
",",
"pollers",
",",
"reactionners",
",",
"brokers",
")",
":",
"# Create void satellite links",
"cfg",
"=",
"{",
"'pollers'",
":",
"{",
"}",
",",
"'reactionners'",
":",
"{",
"}",
",",
"'brokers'",
":",
"{",
"}... | Get a configuration dictionary with pollers, reactionners and brokers links
for a scheduler
:return: dict containing pollers, reactionners and brokers links (key is satellite id)
:rtype: dict | [
"Get",
"a",
"configuration",
"dictionary",
"with",
"pollers",
"reactionners",
"and",
"brokers",
"links",
"for",
"a",
"scheduler"
] | python | train |
nvbn/thefuck | thefuck/corrector.py | https://github.com/nvbn/thefuck/blob/40ab4eb62db57627bff10cf029d29c94704086a2/thefuck/corrector.py#L81-L92 | def get_corrected_commands(command):
"""Returns generator with sorted and unique corrected commands.
:type command: thefuck.types.Command
:rtype: Iterable[thefuck.types.CorrectedCommand]
"""
corrected_commands = (
corrected for rule in get_rules()
if rule.is_match(command)
... | [
"def",
"get_corrected_commands",
"(",
"command",
")",
":",
"corrected_commands",
"=",
"(",
"corrected",
"for",
"rule",
"in",
"get_rules",
"(",
")",
"if",
"rule",
".",
"is_match",
"(",
"command",
")",
"for",
"corrected",
"in",
"rule",
".",
"get_corrected_comman... | Returns generator with sorted and unique corrected commands.
:type command: thefuck.types.Command
:rtype: Iterable[thefuck.types.CorrectedCommand] | [
"Returns",
"generator",
"with",
"sorted",
"and",
"unique",
"corrected",
"commands",
"."
] | python | train |
twilio/twilio-python | twilio/rest/preview/wireless/sim/usage.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/preview/wireless/sim/usage.py#L127-L145 | def fetch(self, end=values.unset, start=values.unset):
"""
Fetch a UsageInstance
:param unicode end: The end
:param unicode start: The start
:returns: Fetched UsageInstance
:rtype: twilio.rest.preview.wireless.sim.usage.UsageInstance
"""
params = values.... | [
"def",
"fetch",
"(",
"self",
",",
"end",
"=",
"values",
".",
"unset",
",",
"start",
"=",
"values",
".",
"unset",
")",
":",
"params",
"=",
"values",
".",
"of",
"(",
"{",
"'End'",
":",
"end",
",",
"'Start'",
":",
"start",
",",
"}",
")",
"payload",
... | Fetch a UsageInstance
:param unicode end: The end
:param unicode start: The start
:returns: Fetched UsageInstance
:rtype: twilio.rest.preview.wireless.sim.usage.UsageInstance | [
"Fetch",
"a",
"UsageInstance"
] | python | train |
androguard/androguard | androguard/core/bytecodes/axml/__init__.py | https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/core/bytecodes/axml/__init__.py#L1034-L1085 | def _fix_name(self, prefix, name):
"""
Apply some fixes to element named and attribute names.
Try to get conform to:
> Like element names, attribute names are case-sensitive and must start with a letter or underscore.
> The rest of the name can contain letters, digits, hyphens, u... | [
"def",
"_fix_name",
"(",
"self",
",",
"prefix",
",",
"name",
")",
":",
"if",
"not",
"name",
"[",
"0",
"]",
".",
"isalpha",
"(",
")",
"and",
"name",
"[",
"0",
"]",
"!=",
"\"_\"",
":",
"log",
".",
"warning",
"(",
"\"Invalid start for name '{}'. \"",
"\... | Apply some fixes to element named and attribute names.
Try to get conform to:
> Like element names, attribute names are case-sensitive and must start with a letter or underscore.
> The rest of the name can contain letters, digits, hyphens, underscores, and periods.
See: https://msdn.micr... | [
"Apply",
"some",
"fixes",
"to",
"element",
"named",
"and",
"attribute",
"names",
".",
"Try",
"to",
"get",
"conform",
"to",
":",
">",
"Like",
"element",
"names",
"attribute",
"names",
"are",
"case",
"-",
"sensitive",
"and",
"must",
"start",
"with",
"a",
"... | python | train |
calmjs/calmjs.parse | src/calmjs/parse/walkers.py | https://github.com/calmjs/calmjs.parse/blob/369f0ee346c5a84c4d5c35a7733a0e63b02eac59/src/calmjs/parse/walkers.py#L78-L92 | def filter(self, node, condition):
"""
This method accepts a node and the condition function; a
generator will be returned to yield the nodes that got matched
by the condition.
"""
if not isinstance(node, Node):
raise TypeError('not a node')
for chil... | [
"def",
"filter",
"(",
"self",
",",
"node",
",",
"condition",
")",
":",
"if",
"not",
"isinstance",
"(",
"node",
",",
"Node",
")",
":",
"raise",
"TypeError",
"(",
"'not a node'",
")",
"for",
"child",
"in",
"node",
":",
"if",
"condition",
"(",
"child",
... | This method accepts a node and the condition function; a
generator will be returned to yield the nodes that got matched
by the condition. | [
"This",
"method",
"accepts",
"a",
"node",
"and",
"the",
"condition",
"function",
";",
"a",
"generator",
"will",
"be",
"returned",
"to",
"yield",
"the",
"nodes",
"that",
"got",
"matched",
"by",
"the",
"condition",
"."
] | python | train |
fermiPy/fermipy | fermipy/skymap.py | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/skymap.py#L687-L696 | def expanded_counts_map(self):
""" return the full counts map """
if self.hpx._ipix is None:
return self.counts
output = np.zeros(
(self.counts.shape[0], self.hpx._maxpix), self.counts.dtype)
for i in range(self.counts.shape[0]):
output[i][self.hpx._i... | [
"def",
"expanded_counts_map",
"(",
"self",
")",
":",
"if",
"self",
".",
"hpx",
".",
"_ipix",
"is",
"None",
":",
"return",
"self",
".",
"counts",
"output",
"=",
"np",
".",
"zeros",
"(",
"(",
"self",
".",
"counts",
".",
"shape",
"[",
"0",
"]",
",",
... | return the full counts map | [
"return",
"the",
"full",
"counts",
"map"
] | python | train |
fugue/credstash | credstash.py | https://github.com/fugue/credstash/blob/56df8e051fc4c8d15d5e7e373e88bf5bc13f3346/credstash.py#L732-L905 | def get_parser():
"""get the parsers dict"""
parsers = {}
parsers['super'] = argparse.ArgumentParser(
description="A credential/secret storage system")
parsers['super'].add_argument("-r", "--region",
help="the AWS region in which to operate. "
... | [
"def",
"get_parser",
"(",
")",
":",
"parsers",
"=",
"{",
"}",
"parsers",
"[",
"'super'",
"]",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"A credential/secret storage system\"",
")",
"parsers",
"[",
"'super'",
"]",
".",
"add_argument",
"... | get the parsers dict | [
"get",
"the",
"parsers",
"dict"
] | python | train |
nccgroup/Scout2 | AWSScout2/services/vpc.py | https://github.com/nccgroup/Scout2/blob/5d86d46d7ed91a92000496189e9cfa6b98243937/AWSScout2/services/vpc.py#L188-L208 | def get_cidr_name(cidr, ip_ranges_files, ip_ranges_name_key):
"""
Read display name for CIDRs from ip-ranges files
:param cidr:
:param ip_ranges_files:
:param ip_ranges_name_key:
:return:
"""
for filename in ip_ranges_files:
ip_ranges = read_ip_ranges(filename, local_file=True)
... | [
"def",
"get_cidr_name",
"(",
"cidr",
",",
"ip_ranges_files",
",",
"ip_ranges_name_key",
")",
":",
"for",
"filename",
"in",
"ip_ranges_files",
":",
"ip_ranges",
"=",
"read_ip_ranges",
"(",
"filename",
",",
"local_file",
"=",
"True",
")",
"for",
"ip_range",
"in",
... | Read display name for CIDRs from ip-ranges files
:param cidr:
:param ip_ranges_files:
:param ip_ranges_name_key:
:return: | [
"Read",
"display",
"name",
"for",
"CIDRs",
"from",
"ip",
"-",
"ranges",
"files",
":",
"param",
"cidr",
":",
":",
"param",
"ip_ranges_files",
":",
":",
"param",
"ip_ranges_name_key",
":",
":",
"return",
":"
] | python | train |
Gandi/gandi.cli | gandi/cli/modules/webacc.py | https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/webacc.py#L220-L244 | def probe(cls, resource, enable, disable, test, host, interval,
http_method, http_response, threshold, timeout, url, window):
""" Set a probe for a webaccelerator """
params = {
'host': host,
'interval': interval,
'method': http_method,
'resp... | [
"def",
"probe",
"(",
"cls",
",",
"resource",
",",
"enable",
",",
"disable",
",",
"test",
",",
"host",
",",
"interval",
",",
"http_method",
",",
"http_response",
",",
"threshold",
",",
"timeout",
",",
"url",
",",
"window",
")",
":",
"params",
"=",
"{",
... | Set a probe for a webaccelerator | [
"Set",
"a",
"probe",
"for",
"a",
"webaccelerator"
] | python | train |
pypa/pipenv | pipenv/vendor/requirementslib/models/utils.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requirementslib/models/utils.py#L156-L165 | def parse_extras(extras_str):
# type: (AnyStr) -> List[AnyStr]
"""
Turn a string of extras into a parsed extras list
"""
from pkg_resources import Requirement
extras = Requirement.parse("fakepkg{0}".format(extras_to_string(extras_str))).extras
return sorted(dedup([extra.lower() for extra i... | [
"def",
"parse_extras",
"(",
"extras_str",
")",
":",
"# type: (AnyStr) -> List[AnyStr]",
"from",
"pkg_resources",
"import",
"Requirement",
"extras",
"=",
"Requirement",
".",
"parse",
"(",
"\"fakepkg{0}\"",
".",
"format",
"(",
"extras_to_string",
"(",
"extras_str",
")",... | Turn a string of extras into a parsed extras list | [
"Turn",
"a",
"string",
"of",
"extras",
"into",
"a",
"parsed",
"extras",
"list"
] | python | train |
fastavro/fastavro | fastavro/_write_py.py | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_write_py.py#L543-L633 | def writer(fo,
schema,
records,
codec='null',
sync_interval=1000 * SYNC_SIZE,
metadata=None,
validator=None,
sync_marker=None):
"""Write records to fo (stream) according to schema
Parameters
----------
fo: file-like
Ou... | [
"def",
"writer",
"(",
"fo",
",",
"schema",
",",
"records",
",",
"codec",
"=",
"'null'",
",",
"sync_interval",
"=",
"1000",
"*",
"SYNC_SIZE",
",",
"metadata",
"=",
"None",
",",
"validator",
"=",
"None",
",",
"sync_marker",
"=",
"None",
")",
":",
"# Sani... | Write records to fo (stream) according to schema
Parameters
----------
fo: file-like
Output stream
records: iterable
Records to write. This is commonly a list of the dictionary
representation of the records, but it can be any iterable
codec: string, optional
Compress... | [
"Write",
"records",
"to",
"fo",
"(",
"stream",
")",
"according",
"to",
"schema"
] | python | train |
openstack/proliantutils | proliantutils/hpssa/objects.py | https://github.com/openstack/proliantutils/blob/86ef3b47b4eca97c221577e3570b0240d6a25f22/proliantutils/hpssa/objects.py#L517-L562 | def can_accomodate(self, logical_disk):
"""Check if this RAID array can accomodate the logical disk.
This method uses hpssacli/ssacli command's option to check if the
logical disk with desired size and RAID level can be created
on this RAID array.
:param logical_disk: Dictionar... | [
"def",
"can_accomodate",
"(",
"self",
",",
"logical_disk",
")",
":",
"raid_level",
"=",
"constants",
".",
"RAID_LEVEL_INPUT_TO_HPSSA_MAPPING",
".",
"get",
"(",
"logical_disk",
"[",
"'raid_level'",
"]",
",",
"logical_disk",
"[",
"'raid_level'",
"]",
")",
"args",
... | Check if this RAID array can accomodate the logical disk.
This method uses hpssacli/ssacli command's option to check if the
logical disk with desired size and RAID level can be created
on this RAID array.
:param logical_disk: Dictionary of logical disk to be created.
:returns: ... | [
"Check",
"if",
"this",
"RAID",
"array",
"can",
"accomodate",
"the",
"logical",
"disk",
"."
] | python | train |
petebachant/PXL | pxl/timeseries.py | https://github.com/petebachant/PXL/blob/d7d06cb74422e1ac0154741351fbecea080cfcc0/pxl/timeseries.py#L141-L143 | def autocorr_coeff(x, t, tau1, tau2):
"""Calculate the autocorrelation coefficient."""
return corr_coeff(x, x, t, tau1, tau2) | [
"def",
"autocorr_coeff",
"(",
"x",
",",
"t",
",",
"tau1",
",",
"tau2",
")",
":",
"return",
"corr_coeff",
"(",
"x",
",",
"x",
",",
"t",
",",
"tau1",
",",
"tau2",
")"
] | Calculate the autocorrelation coefficient. | [
"Calculate",
"the",
"autocorrelation",
"coefficient",
"."
] | python | train |
Skype4Py/Skype4Py | Skype4Py/api/posix_x11.py | https://github.com/Skype4Py/Skype4Py/blob/c48d83f7034109fe46315d45a066126002c6e0d4/Skype4Py/api/posix_x11.py#L323-L337 | def get_skype(self):
"""Returns Skype window ID or None if Skype not running."""
skype_inst = x11.XInternAtom(self.disp, '_SKYPE_INSTANCE', True)
if not skype_inst:
return
type_ret = Atom()
format_ret = c_int()
nitems_ret = c_ulong()
bytes_after_ret = ... | [
"def",
"get_skype",
"(",
"self",
")",
":",
"skype_inst",
"=",
"x11",
".",
"XInternAtom",
"(",
"self",
".",
"disp",
",",
"'_SKYPE_INSTANCE'",
",",
"True",
")",
"if",
"not",
"skype_inst",
":",
"return",
"type_ret",
"=",
"Atom",
"(",
")",
"format_ret",
"=",... | Returns Skype window ID or None if Skype not running. | [
"Returns",
"Skype",
"window",
"ID",
"or",
"None",
"if",
"Skype",
"not",
"running",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.