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 |
|---|---|---|---|---|---|---|---|---|
PmagPy/PmagPy | pmagpy/pmag.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/pmag.py#L4364-L4374 | def vclose(L, V):
"""
gets the closest vector
"""
lam, X = 0, []
for k in range(3):
lam = lam + V[k] * L[k]
beta = np.sqrt(1. - lam**2)
for k in range(3):
X.append((old_div((V[k] - lam * L[k]), beta)))
return X | [
"def",
"vclose",
"(",
"L",
",",
"V",
")",
":",
"lam",
",",
"X",
"=",
"0",
",",
"[",
"]",
"for",
"k",
"in",
"range",
"(",
"3",
")",
":",
"lam",
"=",
"lam",
"+",
"V",
"[",
"k",
"]",
"*",
"L",
"[",
"k",
"]",
"beta",
"=",
"np",
".",
"sqrt... | gets the closest vector | [
"gets",
"the",
"closest",
"vector"
] | python | train |
bokeh/bokeh | bokeh/server/util.py | https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/bokeh/server/util.py#L46-L73 | def bind_sockets(address, port):
''' Bind a socket to a port on an address.
Args:
address (str) :
An address to bind a port on, e.g. ``"localhost"``
port (int) :
A port number to bind.
Pass 0 to have the OS automatically choose a free port.
This functi... | [
"def",
"bind_sockets",
"(",
"address",
",",
"port",
")",
":",
"ss",
"=",
"netutil",
".",
"bind_sockets",
"(",
"port",
"=",
"port",
"or",
"0",
",",
"address",
"=",
"address",
")",
"assert",
"len",
"(",
"ss",
")",
"ports",
"=",
"{",
"s",
".",
"getsoc... | Bind a socket to a port on an address.
Args:
address (str) :
An address to bind a port on, e.g. ``"localhost"``
port (int) :
A port number to bind.
Pass 0 to have the OS automatically choose a free port.
This function returns a 2-tuple with the new socket ... | [
"Bind",
"a",
"socket",
"to",
"a",
"port",
"on",
"an",
"address",
"."
] | python | train |
deepmipt/DeepPavlov | deeppavlov/utils/alexa/ssl_tools.py | https://github.com/deepmipt/DeepPavlov/blob/f3e4a69a3764d25d2f5bad4f1f1aebc872b00f9c/deeppavlov/utils/alexa/ssl_tools.py#L61-L73 | def extract_certs(certs_txt: str) -> List[crypto.X509]:
"""Extracts pycrypto X509 objects from SSL certificates chain string.
Args:
certs_txt: SSL certificates chain string.
Returns:
result: List of pycrypto X509 objects.
"""
pattern = r'-----BEGIN CERTIFICATE-----.+?-----END CERTI... | [
"def",
"extract_certs",
"(",
"certs_txt",
":",
"str",
")",
"->",
"List",
"[",
"crypto",
".",
"X509",
"]",
":",
"pattern",
"=",
"r'-----BEGIN CERTIFICATE-----.+?-----END CERTIFICATE-----'",
"certs_txt",
"=",
"re",
".",
"findall",
"(",
"pattern",
",",
"certs_txt",
... | Extracts pycrypto X509 objects from SSL certificates chain string.
Args:
certs_txt: SSL certificates chain string.
Returns:
result: List of pycrypto X509 objects. | [
"Extracts",
"pycrypto",
"X509",
"objects",
"from",
"SSL",
"certificates",
"chain",
"string",
"."
] | python | test |
openxc/openxc-python | openxc/controllers/base.py | https://github.com/openxc/openxc-python/blob/4becb4a6310bd658c125195ef6ffea4deaf7d7e7/openxc/controllers/base.py#L56-L65 | def wait_for_responses(self):
"""Block the thread and wait for the response to the given request to
arrive from the VI. If no matching response is received in
COMMAND_RESPONSE_TIMEOUT_S seconds, returns anyway.
"""
self.thread.join(self.COMMAND_RESPONSE_TIMEOUT_S)
self.r... | [
"def",
"wait_for_responses",
"(",
"self",
")",
":",
"self",
".",
"thread",
".",
"join",
"(",
"self",
".",
"COMMAND_RESPONSE_TIMEOUT_S",
")",
"self",
".",
"running",
"=",
"False",
"return",
"self",
".",
"responses"
] | Block the thread and wait for the response to the given request to
arrive from the VI. If no matching response is received in
COMMAND_RESPONSE_TIMEOUT_S seconds, returns anyway. | [
"Block",
"the",
"thread",
"and",
"wait",
"for",
"the",
"response",
"to",
"the",
"given",
"request",
"to",
"arrive",
"from",
"the",
"VI",
".",
"If",
"no",
"matching",
"response",
"is",
"received",
"in",
"COMMAND_RESPONSE_TIMEOUT_S",
"seconds",
"returns",
"anywa... | python | train |
thiagopbueno/pyrddl | pyrddl/parser.py | https://github.com/thiagopbueno/pyrddl/blob/3bcfa850b1a7532c7744358f3c6b9e0f8ab978c9/pyrddl/parser.py#L516-L522 | def p_pvar_expr(self, p):
'''pvar_expr : IDENT LPAREN term_list RPAREN
| IDENT'''
if len(p) == 2:
p[0] = ('pvar_expr', (p[1], None))
elif len(p) == 5:
p[0] = ('pvar_expr', (p[1], p[3])) | [
"def",
"p_pvar_expr",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"2",
":",
"p",
"[",
"0",
"]",
"=",
"(",
"'pvar_expr'",
",",
"(",
"p",
"[",
"1",
"]",
",",
"None",
")",
")",
"elif",
"len",
"(",
"p",
")",
"==",
"5",
... | pvar_expr : IDENT LPAREN term_list RPAREN
| IDENT | [
"pvar_expr",
":",
"IDENT",
"LPAREN",
"term_list",
"RPAREN",
"|",
"IDENT"
] | python | train |
wandb/client | wandb/vendor/prompt_toolkit/layout/containers.py | https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/vendor/prompt_toolkit/layout/containers.py#L1597-L1605 | def _scroll_down(self, cli):
" Scroll window down. "
info = self.render_info
if self.vertical_scroll < info.content_height - info.window_height:
if info.cursor_position.y <= info.configured_scroll_offsets.top:
self.content.move_cursor_down(cli)
self.vert... | [
"def",
"_scroll_down",
"(",
"self",
",",
"cli",
")",
":",
"info",
"=",
"self",
".",
"render_info",
"if",
"self",
".",
"vertical_scroll",
"<",
"info",
".",
"content_height",
"-",
"info",
".",
"window_height",
":",
"if",
"info",
".",
"cursor_position",
".",
... | Scroll window down. | [
"Scroll",
"window",
"down",
"."
] | python | train |
aerogear/digger-build-cli | digger/base/build.py | https://github.com/aerogear/digger-build-cli/blob/8b88a31063526ec7222dbea6a87309686ad21320/digger/base/build.py#L63-L81 | def from_zip(cls, src='/tmp/app.zip', dest='/app'):
"""
Unzips a zipped app project file and instantiates it.
:param src: zipfile path
:param dest: destination folder to extract the zipfile content
Returns
A project instance.
"""
try:
zf = zipfile.ZipFile(src, 'r')
except F... | [
"def",
"from_zip",
"(",
"cls",
",",
"src",
"=",
"'/tmp/app.zip'",
",",
"dest",
"=",
"'/app'",
")",
":",
"try",
":",
"zf",
"=",
"zipfile",
".",
"ZipFile",
"(",
"src",
",",
"'r'",
")",
"except",
"FileNotFoundError",
":",
"raise",
"errors",
".",
"InvalidP... | Unzips a zipped app project file and instantiates it.
:param src: zipfile path
:param dest: destination folder to extract the zipfile content
Returns
A project instance. | [
"Unzips",
"a",
"zipped",
"app",
"project",
"file",
"and",
"instantiates",
"it",
"."
] | python | train |
saltstack/salt | salt/cloud/clouds/gce.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/gce.py#L728-L807 | def create_subnetwork(kwargs=None, call=None):
'''
... versionadded:: 2017.7.0
Create a GCE Subnetwork. Must specify name, cidr, network, and region.
CLI Example:
.. code-block:: bash
salt-cloud -f create_subnetwork gce name=mysubnet network=mynet1 region=us-west1 cidr=10.0.0.0/24 descrip... | [
"def",
"create_subnetwork",
"(",
"kwargs",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"'function'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The create_subnetwork function must be called with -f or --function.'",
")",
"if",
"not",
"kwargs"... | ... versionadded:: 2017.7.0
Create a GCE Subnetwork. Must specify name, cidr, network, and region.
CLI Example:
.. code-block:: bash
salt-cloud -f create_subnetwork gce name=mysubnet network=mynet1 region=us-west1 cidr=10.0.0.0/24 description=optional | [
"...",
"versionadded",
"::",
"2017",
".",
"7",
".",
"0",
"Create",
"a",
"GCE",
"Subnetwork",
".",
"Must",
"specify",
"name",
"cidr",
"network",
"and",
"region",
"."
] | python | train |
quantumlib/Cirq | cirq/protocols/pow.py | https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/protocols/pow.py#L66-L103 | def pow(val: Any,
exponent: Any,
default: Any = RaiseTypeErrorIfNotProvided) -> Any:
"""Returns `val**factor` of the given value, if defined.
Values define an extrapolation by defining a __pow__(self, exponent) method.
Note that the method may return NotImplemented to indicate a particular
... | [
"def",
"pow",
"(",
"val",
":",
"Any",
",",
"exponent",
":",
"Any",
",",
"default",
":",
"Any",
"=",
"RaiseTypeErrorIfNotProvided",
")",
"->",
"Any",
":",
"raiser",
"=",
"getattr",
"(",
"val",
",",
"'__pow__'",
",",
"None",
")",
"result",
"=",
"NotImple... | Returns `val**factor` of the given value, if defined.
Values define an extrapolation by defining a __pow__(self, exponent) method.
Note that the method may return NotImplemented to indicate a particular
extrapolation can't be done.
Args:
val: The value or iterable of values to invert.
... | [
"Returns",
"val",
"**",
"factor",
"of",
"the",
"given",
"value",
"if",
"defined",
"."
] | python | train |
gem/oq-engine | openquake/hazardlib/gsim/chiou_youngs_2014.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/chiou_youngs_2014.py#L238-L252 | def _get_centered_ztor(self, rup, Frv):
"""
Get ztor centered on the M- dependent avarage ztor(km)
by different fault types.
"""
if Frv == 1:
mean_ztor = max(2.704 - 1.226 * max(rup.mag - 5.849, 0.0), 0.) ** 2
centered_ztor = rup.ztor - mean_ztor
... | [
"def",
"_get_centered_ztor",
"(",
"self",
",",
"rup",
",",
"Frv",
")",
":",
"if",
"Frv",
"==",
"1",
":",
"mean_ztor",
"=",
"max",
"(",
"2.704",
"-",
"1.226",
"*",
"max",
"(",
"rup",
".",
"mag",
"-",
"5.849",
",",
"0.0",
")",
",",
"0.",
")",
"**... | Get ztor centered on the M- dependent avarage ztor(km)
by different fault types. | [
"Get",
"ztor",
"centered",
"on",
"the",
"M",
"-",
"dependent",
"avarage",
"ztor",
"(",
"km",
")",
"by",
"different",
"fault",
"types",
"."
] | python | train |
mattjj/pyhsmm | pyhsmm/models.py | https://github.com/mattjj/pyhsmm/blob/a9a39c2bfd539048e35877cb13283552eadc24e2/pyhsmm/models.py#L664-L678 | def BIC(self,data=None):
'''
BIC on the passed data. If passed data is None (default), calculates BIC
on the model's assigned data
'''
# NOTE: in principle this method computes the BIC only after finding the
# maximum likelihood parameters (or, of course, an EM fixed-poin... | [
"def",
"BIC",
"(",
"self",
",",
"data",
"=",
"None",
")",
":",
"# NOTE: in principle this method computes the BIC only after finding the",
"# maximum likelihood parameters (or, of course, an EM fixed-point as an",
"# approximation!)",
"assert",
"data",
"is",
"None",
"and",
"len",... | BIC on the passed data. If passed data is None (default), calculates BIC
on the model's assigned data | [
"BIC",
"on",
"the",
"passed",
"data",
".",
"If",
"passed",
"data",
"is",
"None",
"(",
"default",
")",
"calculates",
"BIC",
"on",
"the",
"model",
"s",
"assigned",
"data"
] | python | train |
seleniumbase/SeleniumBase | seleniumbase/fixtures/base_case.py | https://github.com/seleniumbase/SeleniumBase/blob/62e5b43ee1f90a9ed923841bdd53b1b38358f43a/seleniumbase/fixtures/base_case.py#L1028-L1088 | def add_tour_step(self, message, selector=None, name=None,
title=None, theme=None, alignment=None, duration=None):
""" Allows the user to add tour steps for a website.
@Params
message - The message to display.
selector - The CSS Selector of the Element t... | [
"def",
"add_tour_step",
"(",
"self",
",",
"message",
",",
"selector",
"=",
"None",
",",
"name",
"=",
"None",
",",
"title",
"=",
"None",
",",
"theme",
"=",
"None",
",",
"alignment",
"=",
"None",
",",
"duration",
"=",
"None",
")",
":",
"if",
"not",
"... | Allows the user to add tour steps for a website.
@Params
message - The message to display.
selector - The CSS Selector of the Element to attach to.
name - If creating multiple tours at the same time,
use this to select the tour you wish to add steps to.... | [
"Allows",
"the",
"user",
"to",
"add",
"tour",
"steps",
"for",
"a",
"website",
"."
] | python | train |
mbr/simplekv | simplekv/__init__.py | https://github.com/mbr/simplekv/blob/fc46ee0b8ca9b071d6699f3f0f18a8e599a5a2d6/simplekv/__init__.py#L400-L416 | def put_file(self, key, file, ttl_secs=None):
"""Like :meth:`~simplekv.KeyValueStore.put_file`, but with an
additional parameter:
:param ttl_secs: Number of seconds until the key expires. See above
for valid values.
:raises exceptions.ValueError: If ... | [
"def",
"put_file",
"(",
"self",
",",
"key",
",",
"file",
",",
"ttl_secs",
"=",
"None",
")",
":",
"if",
"ttl_secs",
"is",
"None",
":",
"ttl_secs",
"=",
"self",
".",
"default_ttl_secs",
"self",
".",
"_check_valid_key",
"(",
"key",
")",
"if",
"isinstance",
... | Like :meth:`~simplekv.KeyValueStore.put_file`, but with an
additional parameter:
:param ttl_secs: Number of seconds until the key expires. See above
for valid values.
:raises exceptions.ValueError: If ``ttl_secs`` is invalid. | [
"Like",
":",
"meth",
":",
"~simplekv",
".",
"KeyValueStore",
".",
"put_file",
"but",
"with",
"an",
"additional",
"parameter",
":"
] | python | train |
Clinical-Genomics/trailblazer | trailblazer/mip/files.py | https://github.com/Clinical-Genomics/trailblazer/blob/27f3cd21043a1077bd7029e85783459a50a7b798/trailblazer/mip/files.py#L184-L192 | def parse_chanjo_sexcheck(handle: TextIO):
"""Parse Chanjo sex-check output."""
samples = csv.DictReader(handle, delimiter='\t')
for sample in samples:
return {
'predicted_sex': sample['sex'],
'x_coverage': float(sample['#X_coverage']),
'y_coverage': float(sample[... | [
"def",
"parse_chanjo_sexcheck",
"(",
"handle",
":",
"TextIO",
")",
":",
"samples",
"=",
"csv",
".",
"DictReader",
"(",
"handle",
",",
"delimiter",
"=",
"'\\t'",
")",
"for",
"sample",
"in",
"samples",
":",
"return",
"{",
"'predicted_sex'",
":",
"sample",
"[... | Parse Chanjo sex-check output. | [
"Parse",
"Chanjo",
"sex",
"-",
"check",
"output",
"."
] | python | train |
jtmoulia/switchboard-python | aplus/__init__.py | https://github.com/jtmoulia/switchboard-python/blob/c9b0cb74cb12a64385465091be633e78d39f08b1/aplus/__init__.py#L121-L248 | def then(self, success=None, failure=None):
"""
This method takes two optional arguments. The first argument
is used if the "self promise" is fulfilled and the other is
used if the "self promise" is rejected. In either case, this
method returns another promise that effectively ... | [
"def",
"then",
"(",
"self",
",",
"success",
"=",
"None",
",",
"failure",
"=",
"None",
")",
":",
"ret",
"=",
"Promise",
"(",
")",
"def",
"callAndFulfill",
"(",
"v",
")",
":",
"\"\"\"\n A callback to be invoked if the \"self promise\"\n is fulfil... | This method takes two optional arguments. The first argument
is used if the "self promise" is fulfilled and the other is
used if the "self promise" is rejected. In either case, this
method returns another promise that effectively represents
the result of either the first of the second ... | [
"This",
"method",
"takes",
"two",
"optional",
"arguments",
".",
"The",
"first",
"argument",
"is",
"used",
"if",
"the",
"self",
"promise",
"is",
"fulfilled",
"and",
"the",
"other",
"is",
"used",
"if",
"the",
"self",
"promise",
"is",
"rejected",
".",
"In",
... | python | train |
google/tangent | tangent/create.py | https://github.com/google/tangent/blob/6533e83af09de7345d1b438512679992f080dcc9/tangent/create.py#L100-L119 | def create_temp(node, namer):
"""Create a temporary variable.
Args:
node: Create a temporary variable to store this variable in.
namer: A naming object that guarantees the names are unique.
Returns:
node: See `create_grad`. Returns a temporary variable, which is always a
simple variable anno... | [
"def",
"create_temp",
"(",
"node",
",",
"namer",
")",
":",
"if",
"isinstance",
"(",
"node",
",",
"gast",
".",
"Name",
")",
":",
"name",
"=",
"node",
".",
"id",
"elif",
"isinstance",
"(",
"node",
",",
"(",
"gast",
".",
"Attribute",
",",
"gast",
".",... | Create a temporary variable.
Args:
node: Create a temporary variable to store this variable in.
namer: A naming object that guarantees the names are unique.
Returns:
node: See `create_grad`. Returns a temporary variable, which is always a
simple variable annotated with `temp_var`. | [
"Create",
"a",
"temporary",
"variable",
"."
] | python | train |
Nic30/hwt | hwt/hdl/types/bitsCast.py | https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/types/bitsCast.py#L96-L113 | def reinterpretBits(self, sigOrVal, toType):
"""
Cast object of same bit size between to other type
(f.e. bits to struct, union or array)
"""
if isinstance(sigOrVal, Value):
return reinterpretBits__val(self, sigOrVal, toType)
elif isinstance(toType, Bits):
return fitTo_t(sigOrVal... | [
"def",
"reinterpretBits",
"(",
"self",
",",
"sigOrVal",
",",
"toType",
")",
":",
"if",
"isinstance",
"(",
"sigOrVal",
",",
"Value",
")",
":",
"return",
"reinterpretBits__val",
"(",
"self",
",",
"sigOrVal",
",",
"toType",
")",
"elif",
"isinstance",
"(",
"to... | Cast object of same bit size between to other type
(f.e. bits to struct, union or array) | [
"Cast",
"object",
"of",
"same",
"bit",
"size",
"between",
"to",
"other",
"type",
"(",
"f",
".",
"e",
".",
"bits",
"to",
"struct",
"union",
"or",
"array",
")"
] | python | test |
DLR-RM/RAFCON | source/rafcon/gui/mygaphas/tools.py | https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/mygaphas/tools.py#L579-L587 | def _set_motion_handle(self, event):
"""Sets motion handle to currently grabbed handle
"""
item = self.grabbed_item
handle = self.grabbed_handle
pos = event.x, event.y
self.motion_handle = HandleInMotion(item, handle, self.view)
self.motion_handle.GLUE_DISTANCE = ... | [
"def",
"_set_motion_handle",
"(",
"self",
",",
"event",
")",
":",
"item",
"=",
"self",
".",
"grabbed_item",
"handle",
"=",
"self",
".",
"grabbed_handle",
"pos",
"=",
"event",
".",
"x",
",",
"event",
".",
"y",
"self",
".",
"motion_handle",
"=",
"HandleInM... | Sets motion handle to currently grabbed handle | [
"Sets",
"motion",
"handle",
"to",
"currently",
"grabbed",
"handle"
] | python | train |
Azure/azure-cli-extensions | src/storage-preview/azext_storage_preview/_format.py | https://github.com/Azure/azure-cli-extensions/blob/3d4854205b0f0d882f688cfa12383d14506c2e35/src/storage-preview/azext_storage_preview/_format.py#L72-L90 | def transform_file_output(result):
""" Transform to convert SDK file/dir list output to something that
more clearly distinguishes between files and directories. """
from collections import OrderedDict
new_result = []
iterable = result if isinstance(result, list) else result.get('items', result)
... | [
"def",
"transform_file_output",
"(",
"result",
")",
":",
"from",
"collections",
"import",
"OrderedDict",
"new_result",
"=",
"[",
"]",
"iterable",
"=",
"result",
"if",
"isinstance",
"(",
"result",
",",
"list",
")",
"else",
"result",
".",
"get",
"(",
"'items'"... | Transform to convert SDK file/dir list output to something that
more clearly distinguishes between files and directories. | [
"Transform",
"to",
"convert",
"SDK",
"file",
"/",
"dir",
"list",
"output",
"to",
"something",
"that",
"more",
"clearly",
"distinguishes",
"between",
"files",
"and",
"directories",
"."
] | python | train |
danielperna84/pyhomematic | pyhomematic/_hm.py | https://github.com/danielperna84/pyhomematic/blob/8b91f3e84c83f05d289c740d507293a0d6759d8e/pyhomematic/_hm.py#L147-L196 | def createDeviceObjects(self, interface_id):
"""Transform the raw device descriptions into instances of devicetypes.generic.HMDevice or availabe subclass."""
global WORKING
WORKING = True
remote = interface_id.split('-')[-1]
LOG.debug(
"RPCFunctions.createDeviceObject... | [
"def",
"createDeviceObjects",
"(",
"self",
",",
"interface_id",
")",
":",
"global",
"WORKING",
"WORKING",
"=",
"True",
"remote",
"=",
"interface_id",
".",
"split",
"(",
"'-'",
")",
"[",
"-",
"1",
"]",
"LOG",
".",
"debug",
"(",
"\"RPCFunctions.createDeviceObj... | Transform the raw device descriptions into instances of devicetypes.generic.HMDevice or availabe subclass. | [
"Transform",
"the",
"raw",
"device",
"descriptions",
"into",
"instances",
"of",
"devicetypes",
".",
"generic",
".",
"HMDevice",
"or",
"availabe",
"subclass",
"."
] | python | train |
bcbio/bcbio-nextgen | bcbio/variation/mutect2.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/mutect2.py#L48-L60 | def _add_region_params(region, out_file, items, gatk_type):
"""Add parameters for selecting by region to command line.
"""
params = []
variant_regions = bedutils.population_variant_regions(items)
region = subset_variant_regions(variant_regions, region, out_file, items)
if region:
if gatk... | [
"def",
"_add_region_params",
"(",
"region",
",",
"out_file",
",",
"items",
",",
"gatk_type",
")",
":",
"params",
"=",
"[",
"]",
"variant_regions",
"=",
"bedutils",
".",
"population_variant_regions",
"(",
"items",
")",
"region",
"=",
"subset_variant_regions",
"("... | Add parameters for selecting by region to command line. | [
"Add",
"parameters",
"for",
"selecting",
"by",
"region",
"to",
"command",
"line",
"."
] | python | train |
mrstephenneal/pdfconduit | sandbox/pdfrw_rotate.py | https://github.com/mrstephenneal/pdfconduit/blob/993421cc087eefefe01ff09afabd893bcc2718ec/sandbox/pdfrw_rotate.py#L12-L35 | def rotate(file_name, rotate, suffix='rotated', tempdir=None):
"""Rotate PDF by increments of 90 degrees."""
# Set output file name
if tempdir:
outfn = NamedTemporaryFile(suffix='.pdf', dir=tempdir, delete=False).name
elif suffix:
outfn = os.path.join(os.path.dirname(file_name), add_suff... | [
"def",
"rotate",
"(",
"file_name",
",",
"rotate",
",",
"suffix",
"=",
"'rotated'",
",",
"tempdir",
"=",
"None",
")",
":",
"# Set output file name",
"if",
"tempdir",
":",
"outfn",
"=",
"NamedTemporaryFile",
"(",
"suffix",
"=",
"'.pdf'",
",",
"dir",
"=",
"te... | Rotate PDF by increments of 90 degrees. | [
"Rotate",
"PDF",
"by",
"increments",
"of",
"90",
"degrees",
"."
] | python | train |
TrafficSenseMSD/SumoTools | traci/_vehicle.py | https://github.com/TrafficSenseMSD/SumoTools/blob/8607b4f885f1d1798e43240be643efe6dccccdaa/traci/_vehicle.py#L803-L813 | def slowDown(self, vehID, speed, duration):
"""slowDown(string, double, int) -> None
Changes the speed smoothly to the given value over the given amount
of time in ms (can also be used to increase speed).
"""
self._connection._beginMessage(
tc.CMD_SET_VEHICLE_VARIABL... | [
"def",
"slowDown",
"(",
"self",
",",
"vehID",
",",
"speed",
",",
"duration",
")",
":",
"self",
".",
"_connection",
".",
"_beginMessage",
"(",
"tc",
".",
"CMD_SET_VEHICLE_VARIABLE",
",",
"tc",
".",
"CMD_SLOWDOWN",
",",
"vehID",
",",
"1",
"+",
"4",
"+",
... | slowDown(string, double, int) -> None
Changes the speed smoothly to the given value over the given amount
of time in ms (can also be used to increase speed). | [
"slowDown",
"(",
"string",
"double",
"int",
")",
"-",
">",
"None"
] | python | train |
synw/dataswim | dataswim/data/__init__.py | https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/data/__init__.py#L107-L122 | def load_h5(self, filepath):
"""Load a Hdf5 file to the main dataframe
:param filepath: url of the csv file to load,
can be absolute if it starts with ``/``
or relative if it starts with ``./``
:type filepath: str... | [
"def",
"load_h5",
"(",
"self",
",",
"filepath",
")",
":",
"try",
":",
"self",
".",
"start",
"(",
"\"Loading Hdf5 data...\"",
")",
"self",
".",
"df",
"=",
"dd",
".",
"io",
".",
"load",
"(",
"filepath",
")",
"self",
".",
"end",
"(",
"\"Finished loading H... | Load a Hdf5 file to the main dataframe
:param filepath: url of the csv file to load,
can be absolute if it starts with ``/``
or relative if it starts with ``./``
:type filepath: str
:example: ``ds.load_h5("./myfi... | [
"Load",
"a",
"Hdf5",
"file",
"to",
"the",
"main",
"dataframe"
] | python | train |
apache/incubator-mxnet | example/cnn_text_classification/data_helpers.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/cnn_text_classification/data_helpers.py#L33-L50 | def clean_str(string):
"""Tokenization/string cleaning for all datasets except for SST.
Original taken from https://github.com/yoonkim/CNN_sentence/blob/master/process_data.py
"""
string = re.sub(r"[^A-Za-z0-9(),!?\'\`]", " ", string)
string = re.sub(r"\'s", " \'s", string)
string = re.sub(r"\'v... | [
"def",
"clean_str",
"(",
"string",
")",
":",
"string",
"=",
"re",
".",
"sub",
"(",
"r\"[^A-Za-z0-9(),!?\\'\\`]\"",
",",
"\" \"",
",",
"string",
")",
"string",
"=",
"re",
".",
"sub",
"(",
"r\"\\'s\"",
",",
"\" \\'s\"",
",",
"string",
")",
"string",
"=",
... | Tokenization/string cleaning for all datasets except for SST.
Original taken from https://github.com/yoonkim/CNN_sentence/blob/master/process_data.py | [
"Tokenization",
"/",
"string",
"cleaning",
"for",
"all",
"datasets",
"except",
"for",
"SST",
".",
"Original",
"taken",
"from",
"https",
":",
"//",
"github",
".",
"com",
"/",
"yoonkim",
"/",
"CNN_sentence",
"/",
"blob",
"/",
"master",
"/",
"process_data",
"... | python | train |
sampottinger/pycotracer | pycotracer/report_interpreters.py | https://github.com/sampottinger/pycotracer/blob/c66c3230949b7bee8c9fec5fc00ab392865a0c8b/pycotracer/report_interpreters.py#L156-L209 | def interpret_expenditure_entry(entry):
"""Interpret data fields within a CO-TRACER expediture report.
Interpret the expenditure amount, expenditure date, filed date, amended,
and amendment fields of the provided entry. All dates (expenditure and
filed) are interpreted together and, if any fails, all w... | [
"def",
"interpret_expenditure_entry",
"(",
"entry",
")",
":",
"try",
":",
"expenditure_amount",
"=",
"float",
"(",
"entry",
"[",
"'ExpenditureAmount'",
"]",
")",
"entry",
"[",
"'AmountsInterpreted'",
"]",
"=",
"True",
"entry",
"[",
"'ExpenditureAmount'",
"]",
"=... | Interpret data fields within a CO-TRACER expediture report.
Interpret the expenditure amount, expenditure date, filed date, amended,
and amendment fields of the provided entry. All dates (expenditure and
filed) are interpreted together and, if any fails, all will retain their
original value. Likewise, ... | [
"Interpret",
"data",
"fields",
"within",
"a",
"CO",
"-",
"TRACER",
"expediture",
"report",
"."
] | python | train |
TomAugspurger/engarde | engarde/checks.py | https://github.com/TomAugspurger/engarde/blob/e7ea040cf0d20aee7ca4375b8c27caa2d9e43945/engarde/checks.py#L244-L272 | def one_to_many(df, unitcol, manycol):
"""
Assert that a many-to-one relationship is preserved between two
columns. For example, a retail store will have have distinct
departments, each with several employees. If each employee may
only work in a single department, then the relationship of the
de... | [
"def",
"one_to_many",
"(",
"df",
",",
"unitcol",
",",
"manycol",
")",
":",
"subset",
"=",
"df",
"[",
"[",
"manycol",
",",
"unitcol",
"]",
"]",
".",
"drop_duplicates",
"(",
")",
"for",
"many",
"in",
"subset",
"[",
"manycol",
"]",
".",
"unique",
"(",
... | Assert that a many-to-one relationship is preserved between two
columns. For example, a retail store will have have distinct
departments, each with several employees. If each employee may
only work in a single department, then the relationship of the
department to the employees is one to many.
Para... | [
"Assert",
"that",
"a",
"many",
"-",
"to",
"-",
"one",
"relationship",
"is",
"preserved",
"between",
"two",
"columns",
".",
"For",
"example",
"a",
"retail",
"store",
"will",
"have",
"have",
"distinct",
"departments",
"each",
"with",
"several",
"employees",
".... | python | train |
thoughtworksarts/EmoPy | EmoPy/src/data_loader.py | https://github.com/thoughtworksarts/EmoPy/blob/a0ab97b3719ebe0a9de9bfc5adae5e46c9b77fd7/EmoPy/src/data_loader.py#L27-L39 | def _load_dataset(self, images, labels, emotion_index_map):
"""
Loads Dataset object with images, labels, and other data.
:param images: numpy array of image data
:param labels: numpy array of one-hot vector labels
:param emotion_index_map: map linking string/integer emotion cla... | [
"def",
"_load_dataset",
"(",
"self",
",",
"images",
",",
"labels",
",",
"emotion_index_map",
")",
":",
"train_images",
",",
"test_images",
",",
"train_labels",
",",
"test_labels",
"=",
"train_test_split",
"(",
"images",
",",
"labels",
",",
"test_size",
"=",
"s... | Loads Dataset object with images, labels, and other data.
:param images: numpy array of image data
:param labels: numpy array of one-hot vector labels
:param emotion_index_map: map linking string/integer emotion class to integer index used in labels vectors
:return: Dataset object cont... | [
"Loads",
"Dataset",
"object",
"with",
"images",
"labels",
"and",
"other",
"data",
"."
] | python | train |
openego/ding0 | ding0/core/__init__.py | https://github.com/openego/ding0/blob/e2d6528f96255e4bb22ba15514a4f1883564ed5d/ding0/core/__init__.py#L364-L469 | def build_lv_grid_district(self,
lv_load_area,
lv_grid_districts,
lv_stations):
"""Instantiates and associates lv_grid_district incl grid and station.
The instantiation creates more or less empty object... | [
"def",
"build_lv_grid_district",
"(",
"self",
",",
"lv_load_area",
",",
"lv_grid_districts",
",",
"lv_stations",
")",
":",
"# There's no LVGD for current LA",
"# -> TEMP WORKAROUND: Create single LVGD from LA, replace unknown valuess by zero",
"# TODO: Fix #155 (see also: data_processing... | Instantiates and associates lv_grid_district incl grid and station.
The instantiation creates more or less empty objects including relevant
data for transformer choice and grid creation
Parameters
----------
lv_load_area: :shapely:`Shapely Polygon object<polygons>`
... | [
"Instantiates",
"and",
"associates",
"lv_grid_district",
"incl",
"grid",
"and",
"station",
".",
"The",
"instantiation",
"creates",
"more",
"or",
"less",
"empty",
"objects",
"including",
"relevant",
"data",
"for",
"transformer",
"choice",
"and",
"grid",
"creation"
] | python | train |
noxdafox/vminspect | vminspect/comparator.py | https://github.com/noxdafox/vminspect/blob/e685282564877e2d1950f1e09b292f4f4db1dbcd/vminspect/comparator.py#L67-L103 | def compare(self, concurrent=False, identify=False, size=False):
"""Compares the two disks according to flags.
Generates the following report:
::
{'created_files': [{'path': '/file/in/disk1/not/in/disk0',
'sha1': 'sha1_of_the_file'}],
'... | [
"def",
"compare",
"(",
"self",
",",
"concurrent",
"=",
"False",
",",
"identify",
"=",
"False",
",",
"size",
"=",
"False",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"\"Comparing FS contents.\"",
")",
"results",
"=",
"compare_filesystems",
"(",
"se... | Compares the two disks according to flags.
Generates the following report:
::
{'created_files': [{'path': '/file/in/disk1/not/in/disk0',
'sha1': 'sha1_of_the_file'}],
'deleted_files': [{'path': '/file/in/disk0/not/in/disk1',
... | [
"Compares",
"the",
"two",
"disks",
"according",
"to",
"flags",
"."
] | python | train |
python-bonobo/bonobo | bonobo/execution/contexts/node.py | https://github.com/python-bonobo/bonobo/blob/70c8e62c4a88576976e5b52e58d380d6e3227ab4/bonobo/execution/contexts/node.py#L254-L265 | def write(self, *messages):
"""
Push a message list to this context's input queue.
:param mixed value: message
"""
for message in messages:
if not isinstance(message, Token):
message = ensure_tuple(message, cls=self._input_type, length=self._input_len... | [
"def",
"write",
"(",
"self",
",",
"*",
"messages",
")",
":",
"for",
"message",
"in",
"messages",
":",
"if",
"not",
"isinstance",
"(",
"message",
",",
"Token",
")",
":",
"message",
"=",
"ensure_tuple",
"(",
"message",
",",
"cls",
"=",
"self",
".",
"_i... | Push a message list to this context's input queue.
:param mixed value: message | [
"Push",
"a",
"message",
"list",
"to",
"this",
"context",
"s",
"input",
"queue",
"."
] | python | train |
42cc/bets-api | bets/__init__.py | https://github.com/42cc/bets-api/blob/63a8227c7d8c65eef9974374607bc34effff5c7c/bets/__init__.py#L141-L148 | def get_project_slug(self, bet):
'''Return slug of a project that given bet is associated with
or None if bet is not associated with any project.
'''
if bet.get('form_params'):
params = json.loads(bet['form_params'])
return params.get('project')
return Non... | [
"def",
"get_project_slug",
"(",
"self",
",",
"bet",
")",
":",
"if",
"bet",
".",
"get",
"(",
"'form_params'",
")",
":",
"params",
"=",
"json",
".",
"loads",
"(",
"bet",
"[",
"'form_params'",
"]",
")",
"return",
"params",
".",
"get",
"(",
"'project'",
... | Return slug of a project that given bet is associated with
or None if bet is not associated with any project. | [
"Return",
"slug",
"of",
"a",
"project",
"that",
"given",
"bet",
"is",
"associated",
"with",
"or",
"None",
"if",
"bet",
"is",
"not",
"associated",
"with",
"any",
"project",
"."
] | python | valid |
rigetti/pyquil | examples/pointer.py | https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/examples/pointer.py#L67-L74 | def fixup(p, data_bits, ptr_bits, bits_set):
"""
Flip back the pointer qubits that were previously flipped indicated by
the flags `bits_set`.
"""
for i in range(ptr_bits):
if 0 != bits_set & (1 << i):
p.inst(X(data_bits + i)) | [
"def",
"fixup",
"(",
"p",
",",
"data_bits",
",",
"ptr_bits",
",",
"bits_set",
")",
":",
"for",
"i",
"in",
"range",
"(",
"ptr_bits",
")",
":",
"if",
"0",
"!=",
"bits_set",
"&",
"(",
"1",
"<<",
"i",
")",
":",
"p",
".",
"inst",
"(",
"X",
"(",
"d... | Flip back the pointer qubits that were previously flipped indicated by
the flags `bits_set`. | [
"Flip",
"back",
"the",
"pointer",
"qubits",
"that",
"were",
"previously",
"flipped",
"indicated",
"by",
"the",
"flags",
"bits_set",
"."
] | python | train |
oursky/norecaptcha | norecaptcha/captcha.py | https://github.com/oursky/norecaptcha/blob/6323054bf42c1bf35c5d7a7def4729cb32518860/norecaptcha/captcha.py#L98-L151 | def submit(recaptcha_response_field,
secret_key,
remoteip,
verify_server=VERIFY_SERVER):
"""
Submits a reCAPTCHA request for verification. Returns RecaptchaResponse
for the request
recaptcha_response_field -- The value from the form
secret_key -- your reCAPTCHA secr... | [
"def",
"submit",
"(",
"recaptcha_response_field",
",",
"secret_key",
",",
"remoteip",
",",
"verify_server",
"=",
"VERIFY_SERVER",
")",
":",
"if",
"not",
"(",
"recaptcha_response_field",
"and",
"len",
"(",
"recaptcha_response_field",
")",
")",
":",
"return",
"Recap... | Submits a reCAPTCHA request for verification. Returns RecaptchaResponse
for the request
recaptcha_response_field -- The value from the form
secret_key -- your reCAPTCHA secret key
remoteip -- the user's ip address | [
"Submits",
"a",
"reCAPTCHA",
"request",
"for",
"verification",
".",
"Returns",
"RecaptchaResponse",
"for",
"the",
"request"
] | python | train |
pytroll/satpy | satpy/readers/goes_imager_nc.py | https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/readers/goes_imager_nc.py#L682-L689 | def _is_yaw_flip(lat, delta=10):
"""Determine whether the satellite is yaw-flipped ('upside down')"""
logger.debug('Computing yaw flip flag')
# In case of yaw-flip the data and coordinates in the netCDF files are
# also flipped. Just check whether the latitude increases or decrases
... | [
"def",
"_is_yaw_flip",
"(",
"lat",
",",
"delta",
"=",
"10",
")",
":",
"logger",
".",
"debug",
"(",
"'Computing yaw flip flag'",
")",
"# In case of yaw-flip the data and coordinates in the netCDF files are",
"# also flipped. Just check whether the latitude increases or decrases",
... | Determine whether the satellite is yaw-flipped ('upside down') | [
"Determine",
"whether",
"the",
"satellite",
"is",
"yaw",
"-",
"flipped",
"(",
"upside",
"down",
")"
] | python | train |
lambdalisue/maidenhair | src/maidenhair/functions.py | https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/functions.py#L24-L145 | def load(pathname, using=None, unite=False, basecolumn=0,
relative=False, baseline=None,
parser=None, loader=None,
with_filename=False, recursive=False, natsort=True, **kwargs):
"""
Load data from file matched with given glob pattern.
Return value will be a list of data unless :a... | [
"def",
"load",
"(",
"pathname",
",",
"using",
"=",
"None",
",",
"unite",
"=",
"False",
",",
"basecolumn",
"=",
"0",
",",
"relative",
"=",
"False",
",",
"baseline",
"=",
"None",
",",
"parser",
"=",
"None",
",",
"loader",
"=",
"None",
",",
"with_filena... | Load data from file matched with given glob pattern.
Return value will be a list of data unless :attr:`unite` is `True`.
If :attr:`unite` is `True` then all data will be united into a single data.
Parameters
----------
pathname : string or list
A glob pattern or a list of glob pattern whic... | [
"Load",
"data",
"from",
"file",
"matched",
"with",
"given",
"glob",
"pattern",
"."
] | python | train |
PredixDev/predixpy | predix/data/eventhub/publisher.py | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/data/eventhub/publisher.py#L234-L242 | def _auto_send(self):
"""
auto send blocking function, when the interval or the message size has been reached, publish
:return:
"""
while True:
if time.time() - self.last_send_time > self.config.async_auto_send_interval_millis or \
len(self... | [
"def",
"_auto_send",
"(",
"self",
")",
":",
"while",
"True",
":",
"if",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"last_send_time",
">",
"self",
".",
"config",
".",
"async_auto_send_interval_millis",
"or",
"len",
"(",
"self",
".",
"_tx_queue",
")"... | auto send blocking function, when the interval or the message size has been reached, publish
:return: | [
"auto",
"send",
"blocking",
"function",
"when",
"the",
"interval",
"or",
"the",
"message",
"size",
"has",
"been",
"reached",
"publish",
":",
"return",
":"
] | python | train |
miguelgrinberg/flask-paranoid | flask_paranoid/paranoid.py | https://github.com/miguelgrinberg/flask-paranoid/blob/ec6205756d55edd1b135249b9bb345871fef0977/flask_paranoid/paranoid.py#L99-L113 | def clear_session(self, response):
"""Clear the session.
This method is invoked when the session is found to be invalid.
Subclasses can override this method to implement a custom session
reset.
"""
session.clear()
# if flask-login is installed, we try to clear t... | [
"def",
"clear_session",
"(",
"self",
",",
"response",
")",
":",
"session",
".",
"clear",
"(",
")",
"# if flask-login is installed, we try to clear the",
"# \"remember me\" cookie, just in case it is set",
"if",
"'flask_login'",
"in",
"sys",
".",
"modules",
":",
"remember_... | Clear the session.
This method is invoked when the session is found to be invalid.
Subclasses can override this method to implement a custom session
reset. | [
"Clear",
"the",
"session",
"."
] | python | train |
apache/incubator-mxnet | python/mxnet/visualization.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/visualization.py#L47-L209 | def print_summary(symbol, shape=None, line_length=120, positions=[.44, .64, .74, 1.]):
"""Convert symbol for detail information.
Parameters
----------
symbol: Symbol
Symbol to be visualized.
shape: dict
A dict of shapes, str->shape (tuple), given input shapes.
line_length: int
... | [
"def",
"print_summary",
"(",
"symbol",
",",
"shape",
"=",
"None",
",",
"line_length",
"=",
"120",
",",
"positions",
"=",
"[",
".44",
",",
".64",
",",
".74",
",",
"1.",
"]",
")",
":",
"if",
"not",
"isinstance",
"(",
"symbol",
",",
"Symbol",
")",
":"... | Convert symbol for detail information.
Parameters
----------
symbol: Symbol
Symbol to be visualized.
shape: dict
A dict of shapes, str->shape (tuple), given input shapes.
line_length: int
Rotal length of printed lines
positions: list
Relative or absolute position... | [
"Convert",
"symbol",
"for",
"detail",
"information",
"."
] | python | train |
allelos/vectors | vectors/vectors.py | https://github.com/allelos/vectors/blob/55db2a7e489ae5f4380e70b3c5b7a6ce39de5cee/vectors/vectors.py#L227-L232 | def from_points(cls, point1, point2):
"""Return a Vector instance from two given points."""
if isinstance(point1, Point) and isinstance(point2, Point):
displacement = point1.substract(point2)
return cls(displacement.x, displacement.y, displacement.z)
raise TypeError | [
"def",
"from_points",
"(",
"cls",
",",
"point1",
",",
"point2",
")",
":",
"if",
"isinstance",
"(",
"point1",
",",
"Point",
")",
"and",
"isinstance",
"(",
"point2",
",",
"Point",
")",
":",
"displacement",
"=",
"point1",
".",
"substract",
"(",
"point2",
... | Return a Vector instance from two given points. | [
"Return",
"a",
"Vector",
"instance",
"from",
"two",
"given",
"points",
"."
] | python | train |
square/pylink | pylink/jlink.py | https://github.com/square/pylink/blob/81dda0a191d923a8b2627c52cb778aba24d279d7/pylink/jlink.py#L4805-L4830 | def rtt_read(self, buffer_index, num_bytes):
"""Reads data from the RTT buffer.
This method will read at most num_bytes bytes from the specified
RTT buffer. The data is automatically removed from the RTT buffer.
If there are not num_bytes bytes waiting in the RTT buffer, the
ent... | [
"def",
"rtt_read",
"(",
"self",
",",
"buffer_index",
",",
"num_bytes",
")",
":",
"buf",
"=",
"(",
"ctypes",
".",
"c_ubyte",
"*",
"num_bytes",
")",
"(",
")",
"bytes_read",
"=",
"self",
".",
"_dll",
".",
"JLINK_RTTERMINAL_Read",
"(",
"buffer_index",
",",
"... | Reads data from the RTT buffer.
This method will read at most num_bytes bytes from the specified
RTT buffer. The data is automatically removed from the RTT buffer.
If there are not num_bytes bytes waiting in the RTT buffer, the
entire contents of the RTT buffer will be read.
Ar... | [
"Reads",
"data",
"from",
"the",
"RTT",
"buffer",
"."
] | python | train |
icometrix/dicom2nifti | dicom2nifti/common.py | https://github.com/icometrix/dicom2nifti/blob/1462ae5dd979fa3f276fe7a78ceb9b028121536f/dicom2nifti/common.py#L167-L195 | def is_valid_imaging_dicom(dicom_header):
"""
Function will do some basic checks to see if this is a valid imaging dicom
"""
# if it is philips and multiframe dicom then we assume it is ok
try:
if is_philips([dicom_header]):
if is_multiframe_dicom([dicom_header]):
... | [
"def",
"is_valid_imaging_dicom",
"(",
"dicom_header",
")",
":",
"# if it is philips and multiframe dicom then we assume it is ok",
"try",
":",
"if",
"is_philips",
"(",
"[",
"dicom_header",
"]",
")",
":",
"if",
"is_multiframe_dicom",
"(",
"[",
"dicom_header",
"]",
")",
... | Function will do some basic checks to see if this is a valid imaging dicom | [
"Function",
"will",
"do",
"some",
"basic",
"checks",
"to",
"see",
"if",
"this",
"is",
"a",
"valid",
"imaging",
"dicom"
] | python | train |
dddomodossola/remi | remi/server.py | https://github.com/dddomodossola/remi/blob/85206f62220662bb7ecd471042268def71ccad28/remi/server.py#L98-L111 | def parse_session_cookie(cookie_to_cook):
""" cookie_to_cook = http_header['cookie']
"""
#print("cookie_to_cook: %s"%str(cookie_to_cook))
session_value = None
tokens = cookie_to_cook.split(";")
for tok in tokens:
if 'remi_session=' in tok:
#print("found session id: %s"%str(to... | [
"def",
"parse_session_cookie",
"(",
"cookie_to_cook",
")",
":",
"#print(\"cookie_to_cook: %s\"%str(cookie_to_cook))",
"session_value",
"=",
"None",
"tokens",
"=",
"cookie_to_cook",
".",
"split",
"(",
"\";\"",
")",
"for",
"tok",
"in",
"tokens",
":",
"if",
"'remi_sessio... | cookie_to_cook = http_header['cookie'] | [
"cookie_to_cook",
"=",
"http_header",
"[",
"cookie",
"]"
] | python | train |
bslatkin/dpxdt | dpxdt/server/work_queue.py | https://github.com/bslatkin/dpxdt/blob/9f860de1731021d99253670429e5f2157e1f6297/dpxdt/server/work_queue.py#L380-L407 | def query(**kwargs):
"""Queries for work items based on their criteria.
Args:
queue_name: Optional queue name to restrict to.
build_id: Optional build ID to restrict to.
release_id: Optional release ID to restrict to.
run_id: Optional run ID to restrict to.
count: How ma... | [
"def",
"query",
"(",
"*",
"*",
"kwargs",
")",
":",
"count",
"=",
"kwargs",
".",
"get",
"(",
"'count'",
",",
"None",
")",
"task_list",
"=",
"_query",
"(",
"*",
"*",
"kwargs",
")",
"task_dict_list",
"=",
"[",
"_task_to_dict",
"(",
"task",
")",
"for",
... | Queries for work items based on their criteria.
Args:
queue_name: Optional queue name to restrict to.
build_id: Optional build ID to restrict to.
release_id: Optional release ID to restrict to.
run_id: Optional run ID to restrict to.
count: How many tasks to fetch. Defaults ... | [
"Queries",
"for",
"work",
"items",
"based",
"on",
"their",
"criteria",
"."
] | python | train |
aiortc/aiortc | aiortc/rtcsctptransport.py | https://github.com/aiortc/aiortc/blob/60ed036abf4575bd63985724b4493d569e6da29b/aiortc/rtcsctptransport.py#L1451-L1471 | def _update_advanced_peer_ack_point(self):
"""
Try to advance "Advanced.Peer.Ack.Point" according to RFC 3758.
"""
if uint32_gt(self._last_sacked_tsn, self._advanced_peer_ack_tsn):
self._advanced_peer_ack_tsn = self._last_sacked_tsn
done = 0
streams = {}
... | [
"def",
"_update_advanced_peer_ack_point",
"(",
"self",
")",
":",
"if",
"uint32_gt",
"(",
"self",
".",
"_last_sacked_tsn",
",",
"self",
".",
"_advanced_peer_ack_tsn",
")",
":",
"self",
".",
"_advanced_peer_ack_tsn",
"=",
"self",
".",
"_last_sacked_tsn",
"done",
"="... | Try to advance "Advanced.Peer.Ack.Point" according to RFC 3758. | [
"Try",
"to",
"advance",
"Advanced",
".",
"Peer",
".",
"Ack",
".",
"Point",
"according",
"to",
"RFC",
"3758",
"."
] | python | train |
snare/scruffy | scruffy/file.py | https://github.com/snare/scruffy/blob/0fedc08cfdb6db927ff93c09f25f24ce5a04c541/scruffy/file.py#L323-L334 | def remove(self, recursive=True, ignore_error=True):
"""
Remove the directory.
"""
try:
if recursive or self._cleanup == 'recursive':
shutil.rmtree(self.path)
else:
os.rmdir(self.path)
except Exception as e:
if n... | [
"def",
"remove",
"(",
"self",
",",
"recursive",
"=",
"True",
",",
"ignore_error",
"=",
"True",
")",
":",
"try",
":",
"if",
"recursive",
"or",
"self",
".",
"_cleanup",
"==",
"'recursive'",
":",
"shutil",
".",
"rmtree",
"(",
"self",
".",
"path",
")",
"... | Remove the directory. | [
"Remove",
"the",
"directory",
"."
] | python | test |
seequent/properties | properties/math.py | https://github.com/seequent/properties/blob/096b07012fff86b0a880c8c018320c3b512751b9/properties/math.py#L278-L292 | def validate(self, instance, value):
"""Check shape and dtype of vector and scales it to given length"""
value = super(BaseVector, self).validate(instance, value)
if self.length is not None:
try:
value.length = self._length_array(value)
except ZeroDivisi... | [
"def",
"validate",
"(",
"self",
",",
"instance",
",",
"value",
")",
":",
"value",
"=",
"super",
"(",
"BaseVector",
",",
"self",
")",
".",
"validate",
"(",
"instance",
",",
"value",
")",
"if",
"self",
".",
"length",
"is",
"not",
"None",
":",
"try",
... | Check shape and dtype of vector and scales it to given length | [
"Check",
"shape",
"and",
"dtype",
"of",
"vector",
"and",
"scales",
"it",
"to",
"given",
"length"
] | python | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Defaults.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Defaults.py#L397-L447 | def _stripixes(prefix, itms, suffix, stripprefixes, stripsuffixes, env, c=None):
"""
This is a wrapper around _concat()/_concat_ixes() that checks for
the existence of prefixes or suffixes on list items and strips them
where it finds them. This is used by tools (like the GNU linker)
that need to tu... | [
"def",
"_stripixes",
"(",
"prefix",
",",
"itms",
",",
"suffix",
",",
"stripprefixes",
",",
"stripsuffixes",
",",
"env",
",",
"c",
"=",
"None",
")",
":",
"if",
"not",
"itms",
":",
"return",
"itms",
"if",
"not",
"callable",
"(",
"c",
")",
":",
"env_c",... | This is a wrapper around _concat()/_concat_ixes() that checks for
the existence of prefixes or suffixes on list items and strips them
where it finds them. This is used by tools (like the GNU linker)
that need to turn something like 'libfoo.a' into '-lfoo'. | [
"This",
"is",
"a",
"wrapper",
"around",
"_concat",
"()",
"/",
"_concat_ixes",
"()",
"that",
"checks",
"for",
"the",
"existence",
"of",
"prefixes",
"or",
"suffixes",
"on",
"list",
"items",
"and",
"strips",
"them",
"where",
"it",
"finds",
"them",
".",
"This"... | python | train |
elifesciences/elife-tools | elifetools/utils.py | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L523-L533 | def escape_ampersand(string):
"""
Quick convert unicode ampersand characters not associated with
a numbered entity or not starting with allowed characters to a plain &
"""
if not string:
return string
start_with_match = r"(\#x(....);|lt;|gt;|amp;)"
# The pattern below is match & ... | [
"def",
"escape_ampersand",
"(",
"string",
")",
":",
"if",
"not",
"string",
":",
"return",
"string",
"start_with_match",
"=",
"r\"(\\#x(....);|lt;|gt;|amp;)\"",
"# The pattern below is match & that is not immediately followed by #",
"string",
"=",
"re",
".",
"sub",
"(",
"r... | Quick convert unicode ampersand characters not associated with
a numbered entity or not starting with allowed characters to a plain & | [
"Quick",
"convert",
"unicode",
"ampersand",
"characters",
"not",
"associated",
"with",
"a",
"numbered",
"entity",
"or",
"not",
"starting",
"with",
"allowed",
"characters",
"to",
"a",
"plain",
"&",
";"
] | python | train |
pneff/wsgiservice | wsgiservice/resource.py | https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/resource.py#L193-L217 | def get_method(self, method=None):
"""Returns the method to call on this instance as a string. Raises a
HTTP exception if no method can be found. Aborts with a 405 status
code for known methods (based on the :attr:`KNOWN_METHODS` list) and a
501 status code for all other methods.
... | [
"def",
"get_method",
"(",
"self",
",",
"method",
"=",
"None",
")",
":",
"if",
"method",
"is",
"None",
":",
"method",
"=",
"self",
".",
"request",
".",
"method",
"if",
"hasattr",
"(",
"self",
",",
"method",
")",
"and",
"callable",
"(",
"getattr",
"(",... | Returns the method to call on this instance as a string. Raises a
HTTP exception if no method can be found. Aborts with a 405 status
code for known methods (based on the :attr:`KNOWN_METHODS` list) and a
501 status code for all other methods.
:param method: Name of the method to return.... | [
"Returns",
"the",
"method",
"to",
"call",
"on",
"this",
"instance",
"as",
"a",
"string",
".",
"Raises",
"a",
"HTTP",
"exception",
"if",
"no",
"method",
"can",
"be",
"found",
".",
"Aborts",
"with",
"a",
"405",
"status",
"code",
"for",
"known",
"methods",
... | python | train |
joferkington/mplstereonet | mplstereonet/stereonet_axes.py | https://github.com/joferkington/mplstereonet/blob/f6d78ca49807915d4223e864e12bb24d497cc2d6/mplstereonet/stereonet_axes.py#L282-L294 | def _polar(self):
"""The "hidden" polar axis used for azimuth labels."""
# This will be called inside LambertAxes.__init__ as well as every
# time the axis is cleared, so we need the try/except to avoid having
# multiple hidden axes when `cla` is _manually_ called.
try:
... | [
"def",
"_polar",
"(",
"self",
")",
":",
"# This will be called inside LambertAxes.__init__ as well as every",
"# time the axis is cleared, so we need the try/except to avoid having",
"# multiple hidden axes when `cla` is _manually_ called.",
"try",
":",
"return",
"self",
".",
"_hidden_po... | The "hidden" polar axis used for azimuth labels. | [
"The",
"hidden",
"polar",
"axis",
"used",
"for",
"azimuth",
"labels",
"."
] | python | train |
StellarCN/py-stellar-base | stellar_base/horizon.py | https://github.com/StellarCN/py-stellar-base/blob/cce2e782064fb3955c85e1696e630d67b1010848/stellar_base/horizon.py#L352-L376 | def assets(self, asset_code=None, asset_issuer=None, cursor=None, order='asc', limit=10):
"""This endpoint represents all assets. It will give you all the assets
in the system along with various statistics about each.
See the documentation below for details on query parameters that are
... | [
"def",
"assets",
"(",
"self",
",",
"asset_code",
"=",
"None",
",",
"asset_issuer",
"=",
"None",
",",
"cursor",
"=",
"None",
",",
"order",
"=",
"'asc'",
",",
"limit",
"=",
"10",
")",
":",
"endpoint",
"=",
"'/assets'",
"params",
"=",
"self",
".",
"__qu... | This endpoint represents all assets. It will give you all the assets
in the system along with various statistics about each.
See the documentation below for details on query parameters that are
available.
`GET /assets{?asset_code,asset_issuer,cursor,limit,order}
<https://www.st... | [
"This",
"endpoint",
"represents",
"all",
"assets",
".",
"It",
"will",
"give",
"you",
"all",
"the",
"assets",
"in",
"the",
"system",
"along",
"with",
"various",
"statistics",
"about",
"each",
"."
] | python | train |
darothen/xbpch | xbpch/uff.py | https://github.com/darothen/xbpch/blob/31972dd6fd5f3f7cecc3a46080ce4f43ca23fbe5/xbpch/uff.py#L67-L77 | def _fix(self, fmt='i'):
"""
Read pre- or suffix of line at current position with given
format `fmt` (default 'i').
"""
fmt = self.endian + fmt
fix = self.read(struct.calcsize(fmt))
if fix:
return struct.unpack(fmt, fix)[0]
else:
ra... | [
"def",
"_fix",
"(",
"self",
",",
"fmt",
"=",
"'i'",
")",
":",
"fmt",
"=",
"self",
".",
"endian",
"+",
"fmt",
"fix",
"=",
"self",
".",
"read",
"(",
"struct",
".",
"calcsize",
"(",
"fmt",
")",
")",
"if",
"fix",
":",
"return",
"struct",
".",
"unpa... | Read pre- or suffix of line at current position with given
format `fmt` (default 'i'). | [
"Read",
"pre",
"-",
"or",
"suffix",
"of",
"line",
"at",
"current",
"position",
"with",
"given",
"format",
"fmt",
"(",
"default",
"i",
")",
"."
] | python | train |
kislyuk/ensure | ensure/main.py | https://github.com/kislyuk/ensure/blob/0a562a4b469ffbaf71c75dc4d394e94334c831f0/ensure/main.py#L221-L226 | def is_not(self, other):
"""
Ensures :attr:`subject` is not *other* (object identity check).
"""
self._run(unittest_case.assertIsNot, (self._subject, other))
return ChainInspector(self._subject) | [
"def",
"is_not",
"(",
"self",
",",
"other",
")",
":",
"self",
".",
"_run",
"(",
"unittest_case",
".",
"assertIsNot",
",",
"(",
"self",
".",
"_subject",
",",
"other",
")",
")",
"return",
"ChainInspector",
"(",
"self",
".",
"_subject",
")"
] | Ensures :attr:`subject` is not *other* (object identity check). | [
"Ensures",
":",
"attr",
":",
"subject",
"is",
"not",
"*",
"other",
"*",
"(",
"object",
"identity",
"check",
")",
"."
] | python | train |
jilljenn/tryalgo | tryalgo/primes.py | https://github.com/jilljenn/tryalgo/blob/89a4dd9655e7b6b0a176f72b4c60d0196420dfe1/tryalgo/primes.py#L29-L48 | def gries_misra(n):
"""Prime numbers by the sieve of Gries-Misra
Computes both the list of all prime numbers less than n,
and a table mapping every integer 2 ≤ x < n to its smallest prime factor
:param n: positive integer
:returns: list of prime numbers, and list of prime factors
:complexity: O... | [
"def",
"gries_misra",
"(",
"n",
")",
":",
"primes",
"=",
"[",
"]",
"factor",
"=",
"[",
"0",
"]",
"*",
"n",
"for",
"x",
"in",
"range",
"(",
"2",
",",
"n",
")",
":",
"if",
"not",
"factor",
"[",
"x",
"]",
":",
"# no factor found",
"factor",
"[",
... | Prime numbers by the sieve of Gries-Misra
Computes both the list of all prime numbers less than n,
and a table mapping every integer 2 ≤ x < n to its smallest prime factor
:param n: positive integer
:returns: list of prime numbers, and list of prime factors
:complexity: O(n) | [
"Prime",
"numbers",
"by",
"the",
"sieve",
"of",
"Gries",
"-",
"Misra",
"Computes",
"both",
"the",
"list",
"of",
"all",
"prime",
"numbers",
"less",
"than",
"n",
"and",
"a",
"table",
"mapping",
"every",
"integer",
"2",
"≤",
"x",
"<",
"n",
"to",
"its",
... | python | train |
pjuren/pyokit | src/pyokit/datastruct/multipleAlignment.py | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/multipleAlignment.py#L201-L257 | def alignment_to_sequence_coords(self, seq_name, start, end, trim=False):
"""
convert an interval in the alignmnet into co-ordinates in one of the
sequences. Alignment intervals are inclusive of start, but not end. They
are one-based. Hence the full alignment has coords [1, N+1), where N is the
leng... | [
"def",
"alignment_to_sequence_coords",
"(",
"self",
",",
"seq_name",
",",
"start",
",",
"end",
",",
"trim",
"=",
"False",
")",
":",
"start",
"=",
"1",
"if",
"start",
"<",
"1",
"and",
"trim",
"else",
"start",
"end",
"=",
"self",
".",
"size",
"(",
")",... | convert an interval in the alignmnet into co-ordinates in one of the
sequences. Alignment intervals are inclusive of start, but not end. They
are one-based. Hence the full alignment has coords [1, N+1), where N is the
length of the alignment (number of columns). Sequence coords follow the
same conventio... | [
"convert",
"an",
"interval",
"in",
"the",
"alignmnet",
"into",
"co",
"-",
"ordinates",
"in",
"one",
"of",
"the",
"sequences",
".",
"Alignment",
"intervals",
"are",
"inclusive",
"of",
"start",
"but",
"not",
"end",
".",
"They",
"are",
"one",
"-",
"based",
... | python | train |
googleapis/google-cloud-python | talent/google/cloud/talent_v4beta1/gapic/tenant_service_client.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/talent/google/cloud/talent_v4beta1/gapic/tenant_service_client.py#L337-L410 | def update_tenant(
self,
tenant,
update_mask=None,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
"""
Updates specified tenant.
Example:
>>> from google.cloud impor... | [
"def",
"update_tenant",
"(",
"self",
",",
"tenant",
",",
"update_mask",
"=",
"None",
",",
"retry",
"=",
"google",
".",
"api_core",
".",
"gapic_v1",
".",
"method",
".",
"DEFAULT",
",",
"timeout",
"=",
"google",
".",
"api_core",
".",
"gapic_v1",
".",
"meth... | Updates specified tenant.
Example:
>>> from google.cloud import talent_v4beta1
>>>
>>> client = talent_v4beta1.TenantServiceClient()
>>>
>>> # TODO: Initialize `tenant`:
>>> tenant = {}
>>>
>>> response = client.upd... | [
"Updates",
"specified",
"tenant",
"."
] | python | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/framebuffer.py | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/framebuffer.py#L52-L90 | def resize(self, shape, format=None):
""" Set the render-buffer size and format
Parameters
----------
shape : tuple of integers
New shape in yx order. A render buffer is always 2D. For
symmetry with the texture class, a 3-element tuple can also
be giv... | [
"def",
"resize",
"(",
"self",
",",
"shape",
",",
"format",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_resizeable",
":",
"raise",
"RuntimeError",
"(",
"\"RenderBuffer is not resizeable\"",
")",
"# Check shape",
"if",
"not",
"(",
"isinstance",
"(",
"sh... | Set the render-buffer size and format
Parameters
----------
shape : tuple of integers
New shape in yx order. A render buffer is always 2D. For
symmetry with the texture class, a 3-element tuple can also
be given, in which case the last dimension is ignored.
... | [
"Set",
"the",
"render",
"-",
"buffer",
"size",
"and",
"format"
] | python | train |
danilobellini/audiolazy | audiolazy/lazy_filters.py | https://github.com/danilobellini/audiolazy/blob/dba0a278937909980ed40b976d866b8e97c35dee/audiolazy/lazy_filters.py#L1176-L1205 | def resonator(freq, bandwidth):
"""
Resonator filter with 2-poles (conjugated pair) and no zeros (constant
numerator), with exponential approximation for bandwidth calculation.
Parameters
----------
freq :
Resonant frequency in rad/sample (max gain).
bandwidth :
Bandwidth frequency range in rad/s... | [
"def",
"resonator",
"(",
"freq",
",",
"bandwidth",
")",
":",
"bandwidth",
"=",
"thub",
"(",
"bandwidth",
",",
"1",
")",
"R",
"=",
"exp",
"(",
"-",
"bandwidth",
"*",
".5",
")",
"R",
"=",
"thub",
"(",
"R",
",",
"5",
")",
"cost",
"=",
"cos",
"(",
... | Resonator filter with 2-poles (conjugated pair) and no zeros (constant
numerator), with exponential approximation for bandwidth calculation.
Parameters
----------
freq :
Resonant frequency in rad/sample (max gain).
bandwidth :
Bandwidth frequency range in rad/sample following the equation:
``R... | [
"Resonator",
"filter",
"with",
"2",
"-",
"poles",
"(",
"conjugated",
"pair",
")",
"and",
"no",
"zeros",
"(",
"constant",
"numerator",
")",
"with",
"exponential",
"approximation",
"for",
"bandwidth",
"calculation",
"."
] | python | train |
senaite/senaite.core | bika/lims/upgrade/v01_02_007.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/upgrade/v01_02_007.py#L54-L82 | def update_permissions_rejected_analysis_requests():
"""
Maps and updates the permissions for rejected analysis requests so lab clerks, clients, owners and
RegulatoryInspector can see rejected analysis requests on lists.
:return: None
"""
workflow_tool = api.get_tool("portal_workflow")
work... | [
"def",
"update_permissions_rejected_analysis_requests",
"(",
")",
":",
"workflow_tool",
"=",
"api",
".",
"get_tool",
"(",
"\"portal_workflow\"",
")",
"workflow",
"=",
"workflow_tool",
".",
"getWorkflowById",
"(",
"'bika_ar_workflow'",
")",
"catalog",
"=",
"api",
".",
... | Maps and updates the permissions for rejected analysis requests so lab clerks, clients, owners and
RegulatoryInspector can see rejected analysis requests on lists.
:return: None | [
"Maps",
"and",
"updates",
"the",
"permissions",
"for",
"rejected",
"analysis",
"requests",
"so",
"lab",
"clerks",
"clients",
"owners",
"and",
"RegulatoryInspector",
"can",
"see",
"rejected",
"analysis",
"requests",
"on",
"lists",
"."
] | python | train |
ArduPilot/MAVProxy | MAVProxy/modules/lib/mp_image.py | https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/mp_image.py#L348-L390 | def on_redraw_timer(self, event):
'''the redraw timer ensures we show new map tiles as they
are downloaded'''
state = self.state
while state.in_queue.qsize():
try:
obj = state.in_queue.get()
except Exception:
time.sleep(0.05)
... | [
"def",
"on_redraw_timer",
"(",
"self",
",",
"event",
")",
":",
"state",
"=",
"self",
".",
"state",
"while",
"state",
".",
"in_queue",
".",
"qsize",
"(",
")",
":",
"try",
":",
"obj",
"=",
"state",
".",
"in_queue",
".",
"get",
"(",
")",
"except",
"Ex... | the redraw timer ensures we show new map tiles as they
are downloaded | [
"the",
"redraw",
"timer",
"ensures",
"we",
"show",
"new",
"map",
"tiles",
"as",
"they",
"are",
"downloaded"
] | python | train |
sunt05/SuPy | docs/source/proc_var_info/nml_rst_proc.py | https://github.com/sunt05/SuPy/blob/47178bd5aee50a059414e3e504940662fbfae0dc/docs/source/proc_var_info/nml_rst_proc.py#L83-L97 | def form_option(str_opt):
'''generate option name based suffix for URL
:param str_opt: opt name
:type str_opt: str
:return: URL suffix for the specified option
:rtype: str
'''
str_base = '#cmdoption-arg-'
str_opt_x = str_base+str_opt.lower()\
.replace('_', '-')\
.replac... | [
"def",
"form_option",
"(",
"str_opt",
")",
":",
"str_base",
"=",
"'#cmdoption-arg-'",
"str_opt_x",
"=",
"str_base",
"+",
"str_opt",
".",
"lower",
"(",
")",
".",
"replace",
"(",
"'_'",
",",
"'-'",
")",
".",
"replace",
"(",
"'('",
",",
"'-'",
")",
".",
... | generate option name based suffix for URL
:param str_opt: opt name
:type str_opt: str
:return: URL suffix for the specified option
:rtype: str | [
"generate",
"option",
"name",
"based",
"suffix",
"for",
"URL"
] | python | train |
evhub/coconut | coconut/compiler/compiler.py | https://github.com/evhub/coconut/blob/ff97177344e7604e89a0a98a977a87ed2a56fc6d/coconut/compiler/compiler.py#L1880-L1886 | def check_strict(self, name, original, loc, tokens):
"""Check that syntax meets --strict requirements."""
internal_assert(len(tokens) == 1, "invalid " + name + " tokens", tokens)
if self.strict:
raise self.make_err(CoconutStyleError, "found " + name, original, loc)
else:
... | [
"def",
"check_strict",
"(",
"self",
",",
"name",
",",
"original",
",",
"loc",
",",
"tokens",
")",
":",
"internal_assert",
"(",
"len",
"(",
"tokens",
")",
"==",
"1",
",",
"\"invalid \"",
"+",
"name",
"+",
"\" tokens\"",
",",
"tokens",
")",
"if",
"self",... | Check that syntax meets --strict requirements. | [
"Check",
"that",
"syntax",
"meets",
"--",
"strict",
"requirements",
"."
] | python | train |
flatangle/flatlib | flatlib/dignities/essential.py | https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/dignities/essential.py#L119-L134 | def getInfo(sign, lon):
""" Returns the complete essential dignities
for a sign and longitude.
"""
return {
'ruler': ruler(sign),
'exalt': exalt(sign),
'dayTrip': dayTrip(sign),
'nightTrip': nightTrip(sign),
'partTrip': partTrip(sign),
'term': term(sign, ... | [
"def",
"getInfo",
"(",
"sign",
",",
"lon",
")",
":",
"return",
"{",
"'ruler'",
":",
"ruler",
"(",
"sign",
")",
",",
"'exalt'",
":",
"exalt",
"(",
"sign",
")",
",",
"'dayTrip'",
":",
"dayTrip",
"(",
"sign",
")",
",",
"'nightTrip'",
":",
"nightTrip",
... | Returns the complete essential dignities
for a sign and longitude. | [
"Returns",
"the",
"complete",
"essential",
"dignities",
"for",
"a",
"sign",
"and",
"longitude",
"."
] | python | train |
tomplus/kubernetes_asyncio | kubernetes_asyncio/client/api/core_v1_api.py | https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/api/core_v1_api.py#L17375-L17398 | def patch_persistent_volume(self, name, body, **kwargs): # noqa: E501
"""patch_persistent_volume # noqa: E501
partially update the specified PersistentVolume # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_... | [
"def",
"patch_persistent_volume",
"(",
"self",
",",
"name",
",",
"body",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'",
")",
":",
"return",
"se... | patch_persistent_volume # noqa: E501
partially update the specified PersistentVolume # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.patch_persistent_volume(name, body, async_req=Tr... | [
"patch_persistent_volume",
"#",
"noqa",
":",
"E501"
] | python | train |
blockstack/blockstack-core | blockstack/lib/subdomains.py | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/subdomains.py#L485-L497 | def check_initial_subdomain(cls, subdomain_rec):
"""
Verify that a first-ever subdomain record is well-formed.
* n must be 0
* the subdomain must not be independent of its domain
"""
if subdomain_rec.n != 0:
return False
if subdomain_rec.indepe... | [
"def",
"check_initial_subdomain",
"(",
"cls",
",",
"subdomain_rec",
")",
":",
"if",
"subdomain_rec",
".",
"n",
"!=",
"0",
":",
"return",
"False",
"if",
"subdomain_rec",
".",
"independent",
":",
"return",
"False",
"return",
"True"
] | Verify that a first-ever subdomain record is well-formed.
* n must be 0
* the subdomain must not be independent of its domain | [
"Verify",
"that",
"a",
"first",
"-",
"ever",
"subdomain",
"record",
"is",
"well",
"-",
"formed",
".",
"*",
"n",
"must",
"be",
"0",
"*",
"the",
"subdomain",
"must",
"not",
"be",
"independent",
"of",
"its",
"domain"
] | python | train |
elifesciences/elife-tools | elifetools/json_rewrite.py | https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/json_rewrite.py#L626-L925 | def rewrite_elife_datasets_json(json_content, doi):
""" this does the work of rewriting elife datasets json """
# Add dates in bulk
elife_dataset_dates = []
elife_dataset_dates.append(("10.7554/eLife.00348", "used", "dataro17", u"2010"))
elife_dataset_dates.append(("10.7554/eLife.01179", "used", "d... | [
"def",
"rewrite_elife_datasets_json",
"(",
"json_content",
",",
"doi",
")",
":",
"# Add dates in bulk",
"elife_dataset_dates",
"=",
"[",
"]",
"elife_dataset_dates",
".",
"append",
"(",
"(",
"\"10.7554/eLife.00348\"",
",",
"\"used\"",
",",
"\"dataro17\"",
",",
"u\"2010... | this does the work of rewriting elife datasets json | [
"this",
"does",
"the",
"work",
"of",
"rewriting",
"elife",
"datasets",
"json"
] | python | train |
saltstack/salt | salt/modules/junos.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/junos.py#L279-L353 | def set_hostname(hostname=None, **kwargs):
'''
Set the device's hostname
hostname
The name to be set
comment
Provide a comment to the commit
dev_timeout : 30
The NETCONF RPC timeout (in seconds)
confirm
Provide time in minutes for commit confirmation. If this op... | [
"def",
"set_hostname",
"(",
"hostname",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"conn",
"=",
"__proxy__",
"[",
"'junos.conn'",
"]",
"(",
")",
"ret",
"=",
"{",
"}",
"if",
"hostname",
"is",
"None",
":",
"ret",
"[",
"'message'",
"]",
"=",
"'Pl... | Set the device's hostname
hostname
The name to be set
comment
Provide a comment to the commit
dev_timeout : 30
The NETCONF RPC timeout (in seconds)
confirm
Provide time in minutes for commit confirmation. If this option is
specified, the commit will be rolled back... | [
"Set",
"the",
"device",
"s",
"hostname"
] | python | train |
DeepHorizons/iarm | iarm/arm_instructions/_meta.py | https://github.com/DeepHorizons/iarm/blob/b913c9fd577b793a6bbced78b78a5d8d7cd88de4/iarm/arm_instructions/_meta.py#L20-L40 | def parse_lines(self, code):
"""
Return a list of the parsed code
For each line, return a three-tuple containing:
1. The label
2. The instruction
3. Any arguments or parameters
An element in the tuple may be None or '' if it did not find anything
:param ... | [
"def",
"parse_lines",
"(",
"self",
",",
"code",
")",
":",
"remove_comments",
"=",
"re",
".",
"compile",
"(",
"r'^([^;@\\n]*);?.*$'",
",",
"re",
".",
"MULTILINE",
")",
"code",
"=",
"'\\n'",
".",
"join",
"(",
"remove_comments",
".",
"findall",
"(",
"code",
... | Return a list of the parsed code
For each line, return a three-tuple containing:
1. The label
2. The instruction
3. Any arguments or parameters
An element in the tuple may be None or '' if it did not find anything
:param code: The code to parse
:return: A list o... | [
"Return",
"a",
"list",
"of",
"the",
"parsed",
"code"
] | python | train |
daknuett/py_register_machine2 | app/web/model.py | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/app/web/model.py#L174-L179 | def get_ram(self, format_ = "nl"):
"""
return a string representations of the ram
"""
ram = [self.ram.read(i) for i in range(self.ram.size)]
return self._format_mem(ram, format_) | [
"def",
"get_ram",
"(",
"self",
",",
"format_",
"=",
"\"nl\"",
")",
":",
"ram",
"=",
"[",
"self",
".",
"ram",
".",
"read",
"(",
"i",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"ram",
".",
"size",
")",
"]",
"return",
"self",
".",
"_format_... | return a string representations of the ram | [
"return",
"a",
"string",
"representations",
"of",
"the",
"ram"
] | python | train |
pypa/pipenv | pipenv/vendor/pexpect/spawnbase.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/pexpect/spawnbase.py#L157-L180 | def read_nonblocking(self, size=1, timeout=None):
"""This reads data from the file descriptor.
This is a simple implementation suitable for a regular file. Subclasses using ptys or pipes should override it.
The timeout parameter is ignored.
"""
try:
s = os.read(sel... | [
"def",
"read_nonblocking",
"(",
"self",
",",
"size",
"=",
"1",
",",
"timeout",
"=",
"None",
")",
":",
"try",
":",
"s",
"=",
"os",
".",
"read",
"(",
"self",
".",
"child_fd",
",",
"size",
")",
"except",
"OSError",
"as",
"err",
":",
"if",
"err",
"."... | This reads data from the file descriptor.
This is a simple implementation suitable for a regular file. Subclasses using ptys or pipes should override it.
The timeout parameter is ignored. | [
"This",
"reads",
"data",
"from",
"the",
"file",
"descriptor",
"."
] | python | train |
openwisp/netjsonconfig | netjsonconfig/backends/openwrt/converters/interfaces.py | https://github.com/openwisp/netjsonconfig/blob/c23ce9732720856e2f6dc54060db71a8182c7d4b/netjsonconfig/backends/openwrt/converters/interfaces.py#L83-L112 | def __intermediate_interface(self, interface, uci_name):
"""
converts NetJSON interface to
UCI intermediate data structure
"""
interface.update({
'.type': 'interface',
'.name': uci_name,
'ifname': interface.pop('name')
})
if 'ne... | [
"def",
"__intermediate_interface",
"(",
"self",
",",
"interface",
",",
"uci_name",
")",
":",
"interface",
".",
"update",
"(",
"{",
"'.type'",
":",
"'interface'",
",",
"'.name'",
":",
"uci_name",
",",
"'ifname'",
":",
"interface",
".",
"pop",
"(",
"'name'",
... | converts NetJSON interface to
UCI intermediate data structure | [
"converts",
"NetJSON",
"interface",
"to",
"UCI",
"intermediate",
"data",
"structure"
] | python | valid |
SergeySatskiy/cdm-pythonparser | cdmpyparser.py | https://github.com/SergeySatskiy/cdm-pythonparser/blob/7e933aca899b1853d744082313ffc3a8b1154505/cdmpyparser.py#L124-L128 | def getDisplayName(self):
"""Provides a name for display purpose respecting the alias"""
if self.alias == "":
return self.name
return self.name + " as " + self.alias | [
"def",
"getDisplayName",
"(",
"self",
")",
":",
"if",
"self",
".",
"alias",
"==",
"\"\"",
":",
"return",
"self",
".",
"name",
"return",
"self",
".",
"name",
"+",
"\" as \"",
"+",
"self",
".",
"alias"
] | Provides a name for display purpose respecting the alias | [
"Provides",
"a",
"name",
"for",
"display",
"purpose",
"respecting",
"the",
"alias"
] | python | train |
Jajcus/pyxmpp2 | pyxmpp2/stanzaprocessor.py | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/stanzaprocessor.py#L145-L193 | def _process_iq_response(self, stanza):
"""Process IQ stanza of type 'response' or 'error'.
:Parameters:
- `stanza`: the stanza received
:Types:
- `stanza`: `Iq`
If a matching handler is available pass the stanza to it. Otherwise
ignore it if it is "err... | [
"def",
"_process_iq_response",
"(",
"self",
",",
"stanza",
")",
":",
"stanza_id",
"=",
"stanza",
".",
"stanza_id",
"from_jid",
"=",
"stanza",
".",
"from_jid",
"if",
"from_jid",
":",
"ufrom",
"=",
"from_jid",
".",
"as_unicode",
"(",
")",
"else",
":",
"ufrom... | Process IQ stanza of type 'response' or 'error'.
:Parameters:
- `stanza`: the stanza received
:Types:
- `stanza`: `Iq`
If a matching handler is available pass the stanza to it. Otherwise
ignore it if it is "error" or "result" stanza or return
"feature-n... | [
"Process",
"IQ",
"stanza",
"of",
"type",
"response",
"or",
"error",
"."
] | python | valid |
mitsei/dlkit | dlkit/json_/learning/managers.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/learning/managers.py#L2005-L2022 | def get_activity_admin_session(self, proxy):
"""Gets the ``OsidSession`` associated with the activity administration service.
arg: proxy (osid.proxy.Proxy): a proxy
return: (osid.learning.ActivityAdminSession) - an
``ActivityAdminSession``
raise: NullArgument - ``pro... | [
"def",
"get_activity_admin_session",
"(",
"self",
",",
"proxy",
")",
":",
"if",
"not",
"self",
".",
"supports_activity_admin",
"(",
")",
":",
"raise",
"errors",
".",
"Unimplemented",
"(",
")",
"# pylint: disable=no-member",
"return",
"sessions",
".",
"ActivityAdmi... | Gets the ``OsidSession`` associated with the activity administration service.
arg: proxy (osid.proxy.Proxy): a proxy
return: (osid.learning.ActivityAdminSession) - an
``ActivityAdminSession``
raise: NullArgument - ``proxy`` is ``null``
raise: OperationFailed - unabl... | [
"Gets",
"the",
"OsidSession",
"associated",
"with",
"the",
"activity",
"administration",
"service",
"."
] | python | train |
pypa/pipenv | pipenv/vendor/requests/sessions.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/sessions.py#L617-L688 | def send(self, request, **kwargs):
"""Send a given PreparedRequest.
:rtype: requests.Response
"""
# Set defaults that the hooks can utilize to ensure they always have
# the correct parameters to reproduce the previous request.
kwargs.setdefault('stream', self.stream)
... | [
"def",
"send",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"# Set defaults that the hooks can utilize to ensure they always have",
"# the correct parameters to reproduce the previous request.",
"kwargs",
".",
"setdefault",
"(",
"'stream'",
",",
"self",
"... | Send a given PreparedRequest.
:rtype: requests.Response | [
"Send",
"a",
"given",
"PreparedRequest",
"."
] | python | train |
zeth/inputs | inputs.py | https://github.com/zeth/inputs/blob/a46681dbf77d6ab07834f550e5855c1f50701f99/inputs.py#L1641-L1647 | def get_fptr(self):
"""Get the function pointer."""
cmpfunc = ctypes.CFUNCTYPE(ctypes.c_int,
WPARAM,
LPARAM,
ctypes.POINTER(KBDLLHookStruct))
return cmpfunc(self.handle_input) | [
"def",
"get_fptr",
"(",
"self",
")",
":",
"cmpfunc",
"=",
"ctypes",
".",
"CFUNCTYPE",
"(",
"ctypes",
".",
"c_int",
",",
"WPARAM",
",",
"LPARAM",
",",
"ctypes",
".",
"POINTER",
"(",
"KBDLLHookStruct",
")",
")",
"return",
"cmpfunc",
"(",
"self",
".",
"ha... | Get the function pointer. | [
"Get",
"the",
"function",
"pointer",
"."
] | python | train |
ktdreyer/txbugzilla | examples/find-external.py | https://github.com/ktdreyer/txbugzilla/blob/ccfc6667ce9d696b08b468b25c813cc2b68d30d6/examples/find-external.py#L12-L23 | def find_tracker_url(ticket_url):
"""
Given http://tracker.ceph.com/issues/16673 or
tracker.ceph.com/issues/16673, return "http://tracker.ceph.com".
"""
if ticket_url.startswith('http://') or ticket_url.startswith('https://'):
o = urlparse(ticket_url)
scheme, netloc = o.scheme, o.net... | [
"def",
"find_tracker_url",
"(",
"ticket_url",
")",
":",
"if",
"ticket_url",
".",
"startswith",
"(",
"'http://'",
")",
"or",
"ticket_url",
".",
"startswith",
"(",
"'https://'",
")",
":",
"o",
"=",
"urlparse",
"(",
"ticket_url",
")",
"scheme",
",",
"netloc",
... | Given http://tracker.ceph.com/issues/16673 or
tracker.ceph.com/issues/16673, return "http://tracker.ceph.com". | [
"Given",
"http",
":",
"//",
"tracker",
".",
"ceph",
".",
"com",
"/",
"issues",
"/",
"16673",
"or",
"tracker",
".",
"ceph",
".",
"com",
"/",
"issues",
"/",
"16673",
"return",
"http",
":",
"//",
"tracker",
".",
"ceph",
".",
"com",
"."
] | python | train |
ajk8/microcache | microcache/__init__.py | https://github.com/ajk8/microcache/blob/24876c2c5f8959a806e2701adb7efbf70a87a1ae/microcache/__init__.py#L208-L214 | def enable(self):
"""
(Re)enable the cache
"""
logger.debug('enable()')
self.options.enabled = True
logger.info('cache enabled') | [
"def",
"enable",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"'enable()'",
")",
"self",
".",
"options",
".",
"enabled",
"=",
"True",
"logger",
".",
"info",
"(",
"'cache enabled'",
")"
] | (Re)enable the cache | [
"(",
"Re",
")",
"enable",
"the",
"cache"
] | python | train |
kontron/python-aardvark | pyaardvark/aardvark.py | https://github.com/kontron/python-aardvark/blob/9827f669fbdc5bceb98e7d08a294b4e4e455d0d5/pyaardvark/aardvark.py#L559-L575 | def i2c_monitor_read(self):
"""Retrieved any data fetched by the monitor.
This function has an integrated timeout mechanism. You should use
:func:`poll` to determine if there is any data available.
Returns a list of data bytes and special symbols. There are three
special symbol... | [
"def",
"i2c_monitor_read",
"(",
"self",
")",
":",
"data",
"=",
"array",
".",
"array",
"(",
"'H'",
",",
"(",
"0",
",",
")",
"*",
"self",
".",
"BUFFER_SIZE",
")",
"ret",
"=",
"api",
".",
"py_aa_i2c_monitor_read",
"(",
"self",
".",
"handle",
",",
"self"... | Retrieved any data fetched by the monitor.
This function has an integrated timeout mechanism. You should use
:func:`poll` to determine if there is any data available.
Returns a list of data bytes and special symbols. There are three
special symbols: `I2C_MONITOR_NACK`, I2C_MONITOR_STAR... | [
"Retrieved",
"any",
"data",
"fetched",
"by",
"the",
"monitor",
"."
] | python | train |
DataDog/integrations-core | datadog_checks_base/datadog_checks/base/utils/platform.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/datadog_checks_base/datadog_checks/base/utils/platform.py#L65-L68 | def is_unix(name=None):
""" Return true if the platform is a unix, False otherwise. """
name = name or sys.platform
return Platform.is_darwin(name) or Platform.is_linux(name) or Platform.is_freebsd(name) | [
"def",
"is_unix",
"(",
"name",
"=",
"None",
")",
":",
"name",
"=",
"name",
"or",
"sys",
".",
"platform",
"return",
"Platform",
".",
"is_darwin",
"(",
"name",
")",
"or",
"Platform",
".",
"is_linux",
"(",
"name",
")",
"or",
"Platform",
".",
"is_freebsd",... | Return true if the platform is a unix, False otherwise. | [
"Return",
"true",
"if",
"the",
"platform",
"is",
"a",
"unix",
"False",
"otherwise",
"."
] | python | train |
FNNDSC/pfurl | pfurl/pfurl.py | https://github.com/FNNDSC/pfurl/blob/572f634ab582b7b7b7a3fbfd5bf12aadc1ba7958/pfurl/pfurl.py#L190-L221 | def storage_resolveBasedOnKey(self, *args, **kwargs):
"""
Call the remote service and ask for the storage location based on the key.
:param args:
:param kwargs:
:return:
"""
global Gd_internalvar
d_msg = {
'action': 'internalctl',
... | [
"def",
"storage_resolveBasedOnKey",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"global",
"Gd_internalvar",
"d_msg",
"=",
"{",
"'action'",
":",
"'internalctl'",
",",
"'meta'",
":",
"{",
"'var'",
":",
"'key2address'",
",",
"'compute'",
... | Call the remote service and ask for the storage location based on the key.
:param args:
:param kwargs:
:return: | [
"Call",
"the",
"remote",
"service",
"and",
"ask",
"for",
"the",
"storage",
"location",
"based",
"on",
"the",
"key",
"."
] | python | train |
lablup/backend.ai-client-py | src/ai/backend/client/cli/files.py | https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/cli/files.py#L17-L35 | def upload(sess_id_or_alias, files):
"""
Upload files to user's home folder.
\b
SESSID: Session ID or its alias given when creating the session.
FILES: Path to upload.
"""
if len(files) < 1:
return
with Session() as session:
try:
print_wait('Uploading files..... | [
"def",
"upload",
"(",
"sess_id_or_alias",
",",
"files",
")",
":",
"if",
"len",
"(",
"files",
")",
"<",
"1",
":",
"return",
"with",
"Session",
"(",
")",
"as",
"session",
":",
"try",
":",
"print_wait",
"(",
"'Uploading files...'",
")",
"kernel",
"=",
"se... | Upload files to user's home folder.
\b
SESSID: Session ID or its alias given when creating the session.
FILES: Path to upload. | [
"Upload",
"files",
"to",
"user",
"s",
"home",
"folder",
"."
] | python | train |
iDigBio/idigbio-python-client | idigbio/pandas_client.py | https://github.com/iDigBio/idigbio-python-client/blob/e896075b9fed297fc420caf303b3bb5a2298d969/idigbio/pandas_client.py#L51-L63 | def search_records(self, **kwargs):
"""
rq Search Query in iDigBio Query Format, using Record Query Fields
sort field to sort on, pick from Record Query Fields
fields a list of fields to return, specified using the fieldName parameter from Fields with type records
... | [
"def",
"search_records",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"__search_base",
"(",
"apifn",
"=",
"self",
".",
"__api",
".",
"search_records",
",",
"*",
"*",
"kwargs",
")"
] | rq Search Query in iDigBio Query Format, using Record Query Fields
sort field to sort on, pick from Record Query Fields
fields a list of fields to return, specified using the fieldName parameter from Fields with type records
fields_exclude a list of fields to exclude, specified... | [
"rq",
"Search",
"Query",
"in",
"iDigBio",
"Query",
"Format",
"using",
"Record",
"Query",
"Fields",
"sort",
"field",
"to",
"sort",
"on",
"pick",
"from",
"Record",
"Query",
"Fields",
"fields",
"a",
"list",
"of",
"fields",
"to",
"return",
"specified",
"using",
... | python | train |
antonybholmes/libdna | libdna/decode.py | https://github.com/antonybholmes/libdna/blob/96badfd33c8896c799b1c633bb9fb75cec65a83a/libdna/decode.py#L495-L539 | def _read_mask(self, l, ret, mask='upper'):
"""
Reads mask from 1 bit file to convert bases to identify poor quality
bases that will either be converted to lowercase or 'N'. In the
2 bit file, 'N' or any other invalid base is written as 'A'.
Therefore the 'N' mask file is require... | [
"def",
"_read_mask",
"(",
"self",
",",
"l",
",",
"ret",
",",
"mask",
"=",
"'upper'",
")",
":",
"if",
"mask",
".",
"startswith",
"(",
"'u'",
")",
":",
"return",
"file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"dir",
",",
"l",
".",... | Reads mask from 1 bit file to convert bases to identify poor quality
bases that will either be converted to lowercase or 'N'. In the
2 bit file, 'N' or any other invalid base is written as 'A'.
Therefore the 'N' mask file is required to correctly identify where
invalid bases are.
... | [
"Reads",
"mask",
"from",
"1",
"bit",
"file",
"to",
"convert",
"bases",
"to",
"identify",
"poor",
"quality",
"bases",
"that",
"will",
"either",
"be",
"converted",
"to",
"lowercase",
"or",
"N",
".",
"In",
"the",
"2",
"bit",
"file",
"N",
"or",
"any",
"oth... | python | train |
grahambell/pymoc | lib/pymoc/moc.py | https://github.com/grahambell/pymoc/blob/0e2e57ce07ff3de6ac024627c1fb6ad30c2fde48/lib/pymoc/moc.py#L578-L657 | def normalize(self, max_order=MAX_ORDER):
"""Ensure that the MOC is "well-formed".
This structures the MOC as is required for the FITS and JSON
representation. This method is invoked automatically when writing
to these formats.
The number of cells in the MOC will be minimized,... | [
"def",
"normalize",
"(",
"self",
",",
"max_order",
"=",
"MAX_ORDER",
")",
":",
"max_order",
"=",
"self",
".",
"_validate_order",
"(",
"max_order",
")",
"# If the MOC is already normalized and we are not being asked",
"# to reduce the order, then do nothing.",
"if",
"self",
... | Ensure that the MOC is "well-formed".
This structures the MOC as is required for the FITS and JSON
representation. This method is invoked automatically when writing
to these formats.
The number of cells in the MOC will be minimized, so that
no area of the sky is covered multip... | [
"Ensure",
"that",
"the",
"MOC",
"is",
"well",
"-",
"formed",
"."
] | python | train |
dmlc/gluon-nlp | src/gluonnlp/data/transforms.py | https://github.com/dmlc/gluon-nlp/blob/4b83eb6bcc8881e5f1081a3675adaa19fac5c0ba/src/gluonnlp/data/transforms.py#L793-L802 | def _is_control(self, char):
"""Checks whether `chars` is a control character."""
# These are technically control characters but we count them as whitespace
# characters.
if char in ['\t', '\n', '\r']:
return False
cat = unicodedata.category(char)
if cat.start... | [
"def",
"_is_control",
"(",
"self",
",",
"char",
")",
":",
"# These are technically control characters but we count them as whitespace",
"# characters.",
"if",
"char",
"in",
"[",
"'\\t'",
",",
"'\\n'",
",",
"'\\r'",
"]",
":",
"return",
"False",
"cat",
"=",
"unicodeda... | Checks whether `chars` is a control character. | [
"Checks",
"whether",
"chars",
"is",
"a",
"control",
"character",
"."
] | python | train |
SheffieldML/GPyOpt | GPyOpt/models/gpmodel.py | https://github.com/SheffieldML/GPyOpt/blob/255539dc5927819ca701e44fe3d76cd4864222fa/GPyOpt/models/gpmodel.py#L129-L140 | def predict_withGradients(self, X):
"""
Returns the mean, standard deviation, mean gradient and standard deviation gradient at X.
"""
if X.ndim==1: X = X[None,:]
m, v = self.model.predict(X)
v = np.clip(v, 1e-10, np.inf)
dmdx, dvdx = self.model.predictive_gradient... | [
"def",
"predict_withGradients",
"(",
"self",
",",
"X",
")",
":",
"if",
"X",
".",
"ndim",
"==",
"1",
":",
"X",
"=",
"X",
"[",
"None",
",",
":",
"]",
"m",
",",
"v",
"=",
"self",
".",
"model",
".",
"predict",
"(",
"X",
")",
"v",
"=",
"np",
"."... | Returns the mean, standard deviation, mean gradient and standard deviation gradient at X. | [
"Returns",
"the",
"mean",
"standard",
"deviation",
"mean",
"gradient",
"and",
"standard",
"deviation",
"gradient",
"at",
"X",
"."
] | python | train |
mardix/Mocha | mocha/contrib/auth/__init__.py | https://github.com/mardix/Mocha/blob/bce481cb31a0972061dd99bc548701411dcb9de3/mocha/contrib/auth/__init__.py#L495-L509 | def unsign_data(self, data, url_safe=True):
"""
Retrieve the signed data. If it is expired, it will throw an exception
:param data: token/signed data
:param url_safe: bool. If true it will allow it to be passed in URL
:return: mixed, the data in its original form
"""
... | [
"def",
"unsign_data",
"(",
"self",
",",
"data",
",",
"url_safe",
"=",
"True",
")",
":",
"if",
"url_safe",
":",
"return",
"utils",
".",
"unsign_url_safe",
"(",
"data",
",",
"secret_key",
"=",
"self",
".",
"secret_key",
",",
"salt",
"=",
"self",
".",
"us... | Retrieve the signed data. If it is expired, it will throw an exception
:param data: token/signed data
:param url_safe: bool. If true it will allow it to be passed in URL
:return: mixed, the data in its original form | [
"Retrieve",
"the",
"signed",
"data",
".",
"If",
"it",
"is",
"expired",
"it",
"will",
"throw",
"an",
"exception",
":",
"param",
"data",
":",
"token",
"/",
"signed",
"data",
":",
"param",
"url_safe",
":",
"bool",
".",
"If",
"true",
"it",
"will",
"allow",... | python | train |
LedgerHQ/btchip-python | btchip/msqr.py | https://github.com/LedgerHQ/btchip-python/blob/fe82d7f5638169f583a445b8e200fd1c9f3ea218/btchip/msqr.py#L84-L94 | def legendre_symbol(a, p):
""" Compute the Legendre symbol a|p using
Euler's criterion. p is a prime, a is
relatively prime to p (if p divides
a, then a|p = 0)
Returns 1 if a has a square root modulo
p, -1 otherwise.
"""
ls = pow(a, (p - 1) / 2, p)
return -1 if ls == p - 1 else ls | [
"def",
"legendre_symbol",
"(",
"a",
",",
"p",
")",
":",
"ls",
"=",
"pow",
"(",
"a",
",",
"(",
"p",
"-",
"1",
")",
"/",
"2",
",",
"p",
")",
"return",
"-",
"1",
"if",
"ls",
"==",
"p",
"-",
"1",
"else",
"ls"
] | Compute the Legendre symbol a|p using
Euler's criterion. p is a prime, a is
relatively prime to p (if p divides
a, then a|p = 0)
Returns 1 if a has a square root modulo
p, -1 otherwise. | [
"Compute",
"the",
"Legendre",
"symbol",
"a|p",
"using",
"Euler",
"s",
"criterion",
".",
"p",
"is",
"a",
"prime",
"a",
"is",
"relatively",
"prime",
"to",
"p",
"(",
"if",
"p",
"divides",
"a",
"then",
"a|p",
"=",
"0",
")"
] | python | train |
materialsproject/pymatgen | pymatgen/core/structure.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/core/structure.py#L2959-L3000 | def rotate_sites(self, indices=None, theta=0, axis=None, anchor=None,
to_unit_cell=True):
"""
Rotate specific sites by some angle around vector at anchor.
Args:
indices (list): List of site indices on which to perform the
translation.
... | [
"def",
"rotate_sites",
"(",
"self",
",",
"indices",
"=",
"None",
",",
"theta",
"=",
"0",
",",
"axis",
"=",
"None",
",",
"anchor",
"=",
"None",
",",
"to_unit_cell",
"=",
"True",
")",
":",
"from",
"numpy",
".",
"linalg",
"import",
"norm",
"from",
"nump... | Rotate specific sites by some angle around vector at anchor.
Args:
indices (list): List of site indices on which to perform the
translation.
theta (float): Angle in radians
axis (3x1 array): Rotation axis vector.
anchor (3x1 array): Point of rotat... | [
"Rotate",
"specific",
"sites",
"by",
"some",
"angle",
"around",
"vector",
"at",
"anchor",
"."
] | python | train |
saltstack/salt | salt/runners/fileserver.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/runners/fileserver.py#L150-L193 | def file_list(saltenv='base', backend=None):
'''
Return a list of files from the salt fileserver
saltenv : base
The salt fileserver environment to be listed
backend
Narrow fileserver backends to a subset of the enabled ones. If all
passed backends start with a minus sign (``-``... | [
"def",
"file_list",
"(",
"saltenv",
"=",
"'base'",
",",
"backend",
"=",
"None",
")",
":",
"fileserver",
"=",
"salt",
".",
"fileserver",
".",
"Fileserver",
"(",
"__opts__",
")",
"load",
"=",
"{",
"'saltenv'",
":",
"saltenv",
",",
"'fsbackend'",
":",
"back... | Return a list of files from the salt fileserver
saltenv : base
The salt fileserver environment to be listed
backend
Narrow fileserver backends to a subset of the enabled ones. If all
passed backends start with a minus sign (``-``), then these backends
will be excluded from the ... | [
"Return",
"a",
"list",
"of",
"files",
"from",
"the",
"salt",
"fileserver"
] | python | train |
zmathew/django-backbone | backbone/views.py | https://github.com/zmathew/django-backbone/blob/53505a247fb058e64a103c4f11da66993037bd6b/backbone/views.py#L297-L307 | def json_dumps(self, data, **options):
"""
Wrapper around `json.dumps` that uses a special JSON encoder.
"""
params = {'sort_keys': True, 'indent': 2}
params.update(options)
# This code is based off django's built in JSON serializer
if json.__version__.split('.') ... | [
"def",
"json_dumps",
"(",
"self",
",",
"data",
",",
"*",
"*",
"options",
")",
":",
"params",
"=",
"{",
"'sort_keys'",
":",
"True",
",",
"'indent'",
":",
"2",
"}",
"params",
".",
"update",
"(",
"options",
")",
"# This code is based off django's built in JSON ... | Wrapper around `json.dumps` that uses a special JSON encoder. | [
"Wrapper",
"around",
"json",
".",
"dumps",
"that",
"uses",
"a",
"special",
"JSON",
"encoder",
"."
] | python | train |
ZEDGR/pychal | challonge/api.py | https://github.com/ZEDGR/pychal/blob/3600fa9e0557a2a14eb1ad0c0711d28dad3693d7/challonge/api.py#L64-L91 | def fetch(method, uri, params_prefix=None, **params):
"""Fetch the given uri and return the contents of the response."""
params = _prepare_params(params, params_prefix)
if method == "POST" or method == "PUT":
r_data = {"data": params}
else:
r_data = {"params": params}
# build the H... | [
"def",
"fetch",
"(",
"method",
",",
"uri",
",",
"params_prefix",
"=",
"None",
",",
"*",
"*",
"params",
")",
":",
"params",
"=",
"_prepare_params",
"(",
"params",
",",
"params_prefix",
")",
"if",
"method",
"==",
"\"POST\"",
"or",
"method",
"==",
"\"PUT\""... | Fetch the given uri and return the contents of the response. | [
"Fetch",
"the",
"given",
"uri",
"and",
"return",
"the",
"contents",
"of",
"the",
"response",
"."
] | python | train |
materialsproject/pymatgen | pymatgen/io/abinit/tasks.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/tasks.py#L1818-L1888 | def set_status(self, status, msg):
"""
Set and return the status of the task.
Args:
status: Status object or string representation of the status
msg: string with human-readable message used in the case of errors.
"""
# truncate string if it's long. msg wi... | [
"def",
"set_status",
"(",
"self",
",",
"status",
",",
"msg",
")",
":",
"# truncate string if it's long. msg will be logged in the object and we don't want to waste memory.",
"if",
"len",
"(",
"msg",
")",
">",
"2000",
":",
"msg",
"=",
"msg",
"[",
":",
"2000",
"]",
... | Set and return the status of the task.
Args:
status: Status object or string representation of the status
msg: string with human-readable message used in the case of errors. | [
"Set",
"and",
"return",
"the",
"status",
"of",
"the",
"task",
"."
] | python | train |
hydpy-dev/hydpy | hydpy/models/lland/lland_derived.py | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/lland/lland_derived.py#L21-L35 | def update(self):
"""Update |AbsFHRU| based on |FT| and |FHRU|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> nhru(2)
>>> lnk(ACKER)
>>> ft(100.0)
>>> fhru(0.2, 0.8)
>>> derived.absfhru.update()
>>> derived.absfhru
absfh... | [
"def",
"update",
"(",
"self",
")",
":",
"control",
"=",
"self",
".",
"subpars",
".",
"pars",
".",
"control",
"self",
"(",
"control",
".",
"ft",
"*",
"control",
".",
"fhru",
")"
] | Update |AbsFHRU| based on |FT| and |FHRU|.
>>> from hydpy.models.lland import *
>>> parameterstep('1d')
>>> nhru(2)
>>> lnk(ACKER)
>>> ft(100.0)
>>> fhru(0.2, 0.8)
>>> derived.absfhru.update()
>>> derived.absfhru
absfhru(20.0, 80.0) | [
"Update",
"|AbsFHRU|",
"based",
"on",
"|FT|",
"and",
"|FHRU|",
"."
] | python | train |
jazzband/django-model-utils | model_utils/models.py | https://github.com/jazzband/django-model-utils/blob/d557c4253312774a7c2f14bcd02675e9ac2ea05f/model_utils/models.py#L86-L102 | def add_timeframed_query_manager(sender, **kwargs):
"""
Add a QueryManager for a specific timeframe.
"""
if not issubclass(sender, TimeFramedModel):
return
if _field_exists(sender, 'timeframed'):
raise ImproperlyConfigured(
"Model '%s' has a field named 'timeframed' "
... | [
"def",
"add_timeframed_query_manager",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"issubclass",
"(",
"sender",
",",
"TimeFramedModel",
")",
":",
"return",
"if",
"_field_exists",
"(",
"sender",
",",
"'timeframed'",
")",
":",
"raise",
"Impr... | Add a QueryManager for a specific timeframe. | [
"Add",
"a",
"QueryManager",
"for",
"a",
"specific",
"timeframe",
"."
] | python | train |
moonlitesolutions/SolrClient | SolrClient/solrresp.py | https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/solrresp.py#L270-L279 | def get_first_field_values_as_list(self, field):
'''
:param str field: The name of the field for lookup.
Goes through all documents returned looking for specified field. At first encounter will return the field's value.
'''
for doc in self.docs:
if field in doc.keys(... | [
"def",
"get_first_field_values_as_list",
"(",
"self",
",",
"field",
")",
":",
"for",
"doc",
"in",
"self",
".",
"docs",
":",
"if",
"field",
"in",
"doc",
".",
"keys",
"(",
")",
":",
"return",
"doc",
"[",
"field",
"]",
"raise",
"SolrResponseError",
"(",
"... | :param str field: The name of the field for lookup.
Goes through all documents returned looking for specified field. At first encounter will return the field's value. | [
":",
"param",
"str",
"field",
":",
"The",
"name",
"of",
"the",
"field",
"for",
"lookup",
"."
] | python | train |
log2timeline/plaso | plaso/cli/tools.py | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/cli/tools.py#L298-L330 | def ListTimeZones(self):
"""Lists the timezones."""
max_length = 0
for timezone_name in pytz.all_timezones:
if len(timezone_name) > max_length:
max_length = len(timezone_name)
utc_date_time = datetime.datetime.utcnow()
table_view = views.ViewsFactory.GetTableView(
self._views... | [
"def",
"ListTimeZones",
"(",
"self",
")",
":",
"max_length",
"=",
"0",
"for",
"timezone_name",
"in",
"pytz",
".",
"all_timezones",
":",
"if",
"len",
"(",
"timezone_name",
")",
">",
"max_length",
":",
"max_length",
"=",
"len",
"(",
"timezone_name",
")",
"ut... | Lists the timezones. | [
"Lists",
"the",
"timezones",
"."
] | python | train |
lehins/django-smartfields | smartfields/managers.py | https://github.com/lehins/django-smartfields/blob/23d4b0b18352f4f40ce8c429735e673ba5191502/smartfields/managers.py#L203-L206 | def set_status(self, instance, status):
"""Sets the field status for up to 5 minutes."""
status_key = self.get_status_key(instance)
cache.set(status_key, status, timeout=300) | [
"def",
"set_status",
"(",
"self",
",",
"instance",
",",
"status",
")",
":",
"status_key",
"=",
"self",
".",
"get_status_key",
"(",
"instance",
")",
"cache",
".",
"set",
"(",
"status_key",
",",
"status",
",",
"timeout",
"=",
"300",
")"
] | Sets the field status for up to 5 minutes. | [
"Sets",
"the",
"field",
"status",
"for",
"up",
"to",
"5",
"minutes",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.