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 |
|---|---|---|---|---|---|---|---|---|
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/lib/altgraph/Graph.py | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/lib/altgraph/Graph.py#L279-L284 | def describe_edge(self, edge):
"""
return edge, edge data, head, tail for edge
"""
head, tail, data = self.edges[edge]
return edge, data, head, tail | [
"def",
"describe_edge",
"(",
"self",
",",
"edge",
")",
":",
"head",
",",
"tail",
",",
"data",
"=",
"self",
".",
"edges",
"[",
"edge",
"]",
"return",
"edge",
",",
"data",
",",
"head",
",",
"tail"
] | return edge, edge data, head, tail for edge | [
"return",
"edge",
"edge",
"data",
"head",
"tail",
"for",
"edge"
] | python | train |
mgedmin/findimports | findimports.py | https://github.com/mgedmin/findimports/blob/c20a50b497390fed15aa3835476f4fad57313e8a/findimports.py#L513-L560 | def isModule(self, dotted_name, extrapath=None):
"""Is ``dotted_name`` the name of a module?"""
try:
return self._module_cache[(dotted_name, extrapath)]
except KeyError:
pass
if dotted_name in sys.modules or dotted_name in self.builtin_modules:
return ... | [
"def",
"isModule",
"(",
"self",
",",
"dotted_name",
",",
"extrapath",
"=",
"None",
")",
":",
"try",
":",
"return",
"self",
".",
"_module_cache",
"[",
"(",
"dotted_name",
",",
"extrapath",
")",
"]",
"except",
"KeyError",
":",
"pass",
"if",
"dotted_name",
... | Is ``dotted_name`` the name of a module? | [
"Is",
"dotted_name",
"the",
"name",
"of",
"a",
"module?"
] | python | train |
tanghaibao/jcvi | jcvi/formats/blast.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/formats/blast.py#L884-L915 | def condense(args):
"""
%prog condense blastfile > blastfile.condensed
Condense HSPs that belong to the same query-subject pair into one.
"""
p = OptionParser(condense.__doc__)
opts, args = p.parse_args(args)
if len(args) != 1:
sys.exit(not p.print_help())
blastfile, = args
... | [
"def",
"condense",
"(",
"args",
")",
":",
"p",
"=",
"OptionParser",
"(",
"condense",
".",
"__doc__",
")",
"opts",
",",
"args",
"=",
"p",
".",
"parse_args",
"(",
"args",
")",
"if",
"len",
"(",
"args",
")",
"!=",
"1",
":",
"sys",
".",
"exit",
"(",
... | %prog condense blastfile > blastfile.condensed
Condense HSPs that belong to the same query-subject pair into one. | [
"%prog",
"condense",
"blastfile",
">",
"blastfile",
".",
"condensed"
] | python | train |
StackStorm/pybind | pybind/slxos/v17r_1_01a/isis_state/router_isis_config/is_address_family_v4/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17r_1_01a/isis_state/router_isis_config/is_address_family_v4/__init__.py#L563-L586 | def _set_redist_isis(self, v, load=False):
"""
Setter method for redist_isis, mapped from YANG variable /isis_state/router_isis_config/is_address_family_v4/redist_isis (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_redist_isis is considered as a private
... | [
"def",
"_set_redist_isis",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"ba... | Setter method for redist_isis, mapped from YANG variable /isis_state/router_isis_config/is_address_family_v4/redist_isis (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_redist_isis is considered as a private
method. Backends looking to populate this variable shou... | [
"Setter",
"method",
"for",
"redist_isis",
"mapped",
"from",
"YANG",
"variable",
"/",
"isis_state",
"/",
"router_isis_config",
"/",
"is_address_family_v4",
"/",
"redist_isis",
"(",
"container",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"confi... | python | train |
StackStorm/pybind | pybind/slxos/v17s_1_02/openflow_state/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/openflow_state/__init__.py#L151-L174 | def _set_flow(self, v, load=False):
"""
Setter method for flow, mapped from YANG variable /openflow_state/flow (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_flow is considered as a private
method. Backends looking to populate this variable should
do... | [
"def",
"_set_flow",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"base",
... | Setter method for flow, mapped from YANG variable /openflow_state/flow (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_flow is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._set_flow() directly.
... | [
"Setter",
"method",
"for",
"flow",
"mapped",
"from",
"YANG",
"variable",
"/",
"openflow_state",
"/",
"flow",
"(",
"container",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"in",
"the",
"source",
"YANG",
"fil... | python | train |
johnnoone/json-spec | src/jsonspec/cli.py | https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/cli.py#L45-L61 | def format_output(func):
return func
"""
Format output.
"""
@wraps(func)
def wrapper(*args, **kwargs):
try:
response = func(*args, **kwargs)
except Exception as error:
print(colored(error, 'red'), file=sys.stderr)
sys.exit(1)
else:
... | [
"def",
"format_output",
"(",
"func",
")",
":",
"return",
"func",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"response",
"=",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs"... | Format output. | [
"Format",
"output",
"."
] | python | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Executor.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Executor.py#L645-L650 | def _morph(self):
"""Morph this Null executor to a real Executor object."""
batches = self.batches
self.__class__ = Executor
self.__init__([])
self.batches = batches | [
"def",
"_morph",
"(",
"self",
")",
":",
"batches",
"=",
"self",
".",
"batches",
"self",
".",
"__class__",
"=",
"Executor",
"self",
".",
"__init__",
"(",
"[",
"]",
")",
"self",
".",
"batches",
"=",
"batches"
] | Morph this Null executor to a real Executor object. | [
"Morph",
"this",
"Null",
"executor",
"to",
"a",
"real",
"Executor",
"object",
"."
] | python | train |
sony/nnabla | python/src/nnabla/experimental/parametric_function_class/module.py | https://github.com/sony/nnabla/blob/aaf3d33b7cbb38f2a03aa754178ba8f7c8481320/python/src/nnabla/experimental/parametric_function_class/module.py#L97-L120 | def load_parameters(self, path):
"""Load parameters from a file with the specified format.
Args:
path : path or file object
"""
nn.load_parameters(path)
for v in self.get_modules():
if not isinstance(v, tuple):
continue
prefix,... | [
"def",
"load_parameters",
"(",
"self",
",",
"path",
")",
":",
"nn",
".",
"load_parameters",
"(",
"path",
")",
"for",
"v",
"in",
"self",
".",
"get_modules",
"(",
")",
":",
"if",
"not",
"isinstance",
"(",
"v",
",",
"tuple",
")",
":",
"continue",
"prefi... | Load parameters from a file with the specified format.
Args:
path : path or file object | [
"Load",
"parameters",
"from",
"a",
"file",
"with",
"the",
"specified",
"format",
"."
] | python | train |
googleapis/google-cloud-python | dns/google/cloud/dns/zone.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/dns/google/cloud/dns/zone.py#L165-L175 | def name_server_set(self, value):
"""Update named set of DNS name servers.
:type value: str
:param value: (Optional) new title
:raises: ValueError for invalid value types.
"""
if not isinstance(value, six.string_types) and value is not None:
raise ValueError... | [
"def",
"name_server_set",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"six",
".",
"string_types",
")",
"and",
"value",
"is",
"not",
"None",
":",
"raise",
"ValueError",
"(",
"\"Pass a string, or None\"",
")",
"self",
"... | Update named set of DNS name servers.
:type value: str
:param value: (Optional) new title
:raises: ValueError for invalid value types. | [
"Update",
"named",
"set",
"of",
"DNS",
"name",
"servers",
"."
] | python | train |
Kozea/wdb | client/wdb/__init__.py | https://github.com/Kozea/wdb/blob/6af7901b02e866d76f8b0a697a8c078e5b70d1aa/client/wdb/__init__.py#L974-L984 | def die(self):
"""Time to quit"""
log.info('Time to die')
if self.connected:
try:
self.send('Die')
except Exception:
pass
if self._socket:
self._socket.close()
self.pop() | [
"def",
"die",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"'Time to die'",
")",
"if",
"self",
".",
"connected",
":",
"try",
":",
"self",
".",
"send",
"(",
"'Die'",
")",
"except",
"Exception",
":",
"pass",
"if",
"self",
".",
"_socket",
":",
"sel... | Time to quit | [
"Time",
"to",
"quit"
] | python | train |
goldmann/docker-squash | docker_squash/image.py | https://github.com/goldmann/docker-squash/blob/89e0297942be268791aff2098b7ebfa50d82f8e8/docker_squash/image.py#L501-L521 | def _marker_files(self, tar, members):
"""
Searches for marker files in the specified archive.
Docker marker files are files taht have the .wh. prefix in the name.
These files mark the corresponding file to be removed (hidden) when
we start a container from the image.
""... | [
"def",
"_marker_files",
"(",
"self",
",",
"tar",
",",
"members",
")",
":",
"marker_files",
"=",
"{",
"}",
"self",
".",
"log",
".",
"debug",
"(",
"\"Searching for marker files in '%s' archive...\"",
"%",
"tar",
".",
"name",
")",
"for",
"member",
"in",
"member... | Searches for marker files in the specified archive.
Docker marker files are files taht have the .wh. prefix in the name.
These files mark the corresponding file to be removed (hidden) when
we start a container from the image. | [
"Searches",
"for",
"marker",
"files",
"in",
"the",
"specified",
"archive",
"."
] | python | train |
aaugustin/websockets | src/websockets/headers.py | https://github.com/aaugustin/websockets/blob/17b3f47549b6f752a1be07fa1ba3037cb59c7d56/src/websockets/headers.py#L54-L66 | def parse_OWS(header: str, pos: int) -> int:
"""
Parse optional whitespace from ``header`` at the given position.
Return the new position.
The whitespace itself isn't returned because it isn't significant.
"""
# There's always a match, possibly empty, whose content doesn't matter.
match =... | [
"def",
"parse_OWS",
"(",
"header",
":",
"str",
",",
"pos",
":",
"int",
")",
"->",
"int",
":",
"# There's always a match, possibly empty, whose content doesn't matter.",
"match",
"=",
"_OWS_re",
".",
"match",
"(",
"header",
",",
"pos",
")",
"assert",
"match",
"is... | Parse optional whitespace from ``header`` at the given position.
Return the new position.
The whitespace itself isn't returned because it isn't significant. | [
"Parse",
"optional",
"whitespace",
"from",
"header",
"at",
"the",
"given",
"position",
"."
] | python | train |
Titan-C/slaveparticles | slaveparticles/quantum/dos.py | https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/slaveparticles/quantum/dos.py#L11-L14 | def bethe_lattice(energy, hopping):
"""Bethe lattice in inf dim density of states"""
energy = np.asarray(energy).clip(-2*hopping, 2*hopping)
return np.sqrt(4*hopping**2 - energy**2) / (2*np.pi*hopping**2) | [
"def",
"bethe_lattice",
"(",
"energy",
",",
"hopping",
")",
":",
"energy",
"=",
"np",
".",
"asarray",
"(",
"energy",
")",
".",
"clip",
"(",
"-",
"2",
"*",
"hopping",
",",
"2",
"*",
"hopping",
")",
"return",
"np",
".",
"sqrt",
"(",
"4",
"*",
"hopp... | Bethe lattice in inf dim density of states | [
"Bethe",
"lattice",
"in",
"inf",
"dim",
"density",
"of",
"states"
] | python | train |
ZELLMECHANIK-DRESDEN/dclab | dclab/rtdc_dataset/export.py | https://github.com/ZELLMECHANIK-DRESDEN/dclab/blob/79002c4356e7020c2ba73ab0a3819c9abd4affec/dclab/rtdc_dataset/export.py#L26-L85 | def avi(self, path, filtered=True, override=False):
"""Exports filtered event images to an avi file
Parameters
----------
path: str
Path to a .tsv file. The ending .tsv is added automatically.
filtered: bool
If set to `True`, only the filtered data (index... | [
"def",
"avi",
"(",
"self",
",",
"path",
",",
"filtered",
"=",
"True",
",",
"override",
"=",
"False",
")",
":",
"path",
"=",
"pathlib",
".",
"Path",
"(",
"path",
")",
"ds",
"=",
"self",
".",
"rtdc_ds",
"# Make sure that path ends with .avi",
"if",
"path",... | Exports filtered event images to an avi file
Parameters
----------
path: str
Path to a .tsv file. The ending .tsv is added automatically.
filtered: bool
If set to `True`, only the filtered data (index in ds._filter)
are used.
override: bool
... | [
"Exports",
"filtered",
"event",
"images",
"to",
"an",
"avi",
"file"
] | python | train |
openstack/networking-cisco | networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py | https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/apps/saf/server/services/firewall/native/fabric_setup_base.py#L164-L174 | def update_fw_local_result_str(self, os_result=None, dcnm_result=None,
dev_result=None):
"""Update the FW result in the dict. """
fw_dict = self.get_fw_dict()
if os_result is not None:
fw_dict['os_status'] = os_result
if dcnm_result is not N... | [
"def",
"update_fw_local_result_str",
"(",
"self",
",",
"os_result",
"=",
"None",
",",
"dcnm_result",
"=",
"None",
",",
"dev_result",
"=",
"None",
")",
":",
"fw_dict",
"=",
"self",
".",
"get_fw_dict",
"(",
")",
"if",
"os_result",
"is",
"not",
"None",
":",
... | Update the FW result in the dict. | [
"Update",
"the",
"FW",
"result",
"in",
"the",
"dict",
"."
] | python | train |
klen/muffin-session | muffin_session.py | https://github.com/klen/muffin-session/blob/f1d14d12b7d09d8cc40be14b0dfa0b1e2f4ae8e9/muffin_session.py#L191-L197 | def encrypt(self, value):
"""Encrypt session data."""
timestamp = str(int(time.time()))
value = base64.b64encode(value.encode(self.encoding))
signature = create_signature(self.secret, value + timestamp.encode(),
encoding=self.encoding)
return ... | [
"def",
"encrypt",
"(",
"self",
",",
"value",
")",
":",
"timestamp",
"=",
"str",
"(",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
")",
"value",
"=",
"base64",
".",
"b64encode",
"(",
"value",
".",
"encode",
"(",
"self",
".",
"encoding",
")",
")... | Encrypt session data. | [
"Encrypt",
"session",
"data",
"."
] | python | train |
bennylope/django-organizations | organizations/base.py | https://github.com/bennylope/django-organizations/blob/85f753a8f7a8f0f31636c9209fb69e7030a5c79a/organizations/base.py#L311-L318 | def name(self):
"""
Returns the connected user's full name or string representation if the
full name method is unavailable (e.g. on a custom user class).
"""
if hasattr(self.user, "get_full_name"):
return self.user.get_full_name()
return "{0}".format(self.user... | [
"def",
"name",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"user",
",",
"\"get_full_name\"",
")",
":",
"return",
"self",
".",
"user",
".",
"get_full_name",
"(",
")",
"return",
"\"{0}\"",
".",
"format",
"(",
"self",
".",
"user",
")"
] | Returns the connected user's full name or string representation if the
full name method is unavailable (e.g. on a custom user class). | [
"Returns",
"the",
"connected",
"user",
"s",
"full",
"name",
"or",
"string",
"representation",
"if",
"the",
"full",
"name",
"method",
"is",
"unavailable",
"(",
"e",
".",
"g",
".",
"on",
"a",
"custom",
"user",
"class",
")",
"."
] | python | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/compiler_frontend.py | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/compiler_frontend.py#L341-L376 | def _validate_recurse_directive_types(current_schema_type, field_schema_type, context):
"""Perform type checks on the enclosing type and the recursed type for a recurse directive.
Args:
current_schema_type: GraphQLType, the schema type at the current location
field_schema_type: GraphQLType, the... | [
"def",
"_validate_recurse_directive_types",
"(",
"current_schema_type",
",",
"field_schema_type",
",",
"context",
")",
":",
"# Get the set of all allowed types in the current scope.",
"type_hints",
"=",
"context",
"[",
"'type_equivalence_hints'",
"]",
".",
"get",
"(",
"field_... | Perform type checks on the enclosing type and the recursed type for a recurse directive.
Args:
current_schema_type: GraphQLType, the schema type at the current location
field_schema_type: GraphQLType, the schema type at the inner scope
context: dict, various per-compilation data (e.g. decla... | [
"Perform",
"type",
"checks",
"on",
"the",
"enclosing",
"type",
"and",
"the",
"recursed",
"type",
"for",
"a",
"recurse",
"directive",
"."
] | python | train |
sdispater/pendulum | pendulum/duration.py | https://github.com/sdispater/pendulum/blob/94d28b0d3cb524ae02361bd1ed7ea03e2e655e4e/pendulum/duration.py#L19-L36 | def _divide_and_round(a, b):
"""divide a by b and round result to the nearest integer
When the ratio is exactly half-way between two integers,
the even integer is returned.
"""
# Based on the reference implementation for divmod_near
# in Objects/longobject.c.
q, r = divmod(a, b)
# round... | [
"def",
"_divide_and_round",
"(",
"a",
",",
"b",
")",
":",
"# Based on the reference implementation for divmod_near",
"# in Objects/longobject.c.",
"q",
",",
"r",
"=",
"divmod",
"(",
"a",
",",
"b",
")",
"# round up if either r / b > 0.5, or r / b == 0.5 and q is odd.",
"# Th... | divide a by b and round result to the nearest integer
When the ratio is exactly half-way between two integers,
the even integer is returned. | [
"divide",
"a",
"by",
"b",
"and",
"round",
"result",
"to",
"the",
"nearest",
"integer"
] | python | train |
phoebe-project/phoebe2 | phoebe/backend/backends.py | https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/backend/backends.py#L349-L368 | def get_packet_and_syns(self, b, compute, times=[], **kwargs):
"""
get_packet is called by the master and must get all information necessary
to send to all workers. The returned packet will be passed on as
_run_chunk(**packet) with the following exceptions:
* b: the bundle will... | [
"def",
"get_packet_and_syns",
"(",
"self",
",",
"b",
",",
"compute",
",",
"times",
"=",
"[",
"]",
",",
"*",
"*",
"kwargs",
")",
":",
"packet",
",",
"new_syns",
"=",
"self",
".",
"_get_packet_and_syns",
"(",
"b",
",",
"compute",
",",
"times",
",",
"*"... | get_packet is called by the master and must get all information necessary
to send to all workers. The returned packet will be passed on as
_run_chunk(**packet) with the following exceptions:
* b: the bundle will be included in the packet serialized
* compute: the label of the compute o... | [
"get_packet",
"is",
"called",
"by",
"the",
"master",
"and",
"must",
"get",
"all",
"information",
"necessary",
"to",
"send",
"to",
"all",
"workers",
".",
"The",
"returned",
"packet",
"will",
"be",
"passed",
"on",
"as",
"_run_chunk",
"(",
"**",
"packet",
")"... | python | train |
briney/abutils | abutils/core/pair.py | https://github.com/briney/abutils/blob/944755fc7d28bfc7d4f1ffad94ca0bf9d74ec54b/abutils/core/pair.py#L278-L291 | def _refine_j(seq, species):
'''
Completes the 3' end of a a truncated sequence with germline nucleotides.
Input is a MongoDB dict (seq) and the species.
'''
jgerm = germlines.get_germline(seq['j_gene']['full'], species)
aln = global_alignment(seq['vdj_nt'], jgerm)
... | [
"def",
"_refine_j",
"(",
"seq",
",",
"species",
")",
":",
"jgerm",
"=",
"germlines",
".",
"get_germline",
"(",
"seq",
"[",
"'j_gene'",
"]",
"[",
"'full'",
"]",
",",
"species",
")",
"aln",
"=",
"global_alignment",
"(",
"seq",
"[",
"'vdj_nt'",
"]",
",",
... | Completes the 3' end of a a truncated sequence with germline nucleotides.
Input is a MongoDB dict (seq) and the species. | [
"Completes",
"the",
"3",
"end",
"of",
"a",
"a",
"truncated",
"sequence",
"with",
"germline",
"nucleotides",
".",
"Input",
"is",
"a",
"MongoDB",
"dict",
"(",
"seq",
")",
"and",
"the",
"species",
"."
] | python | train |
horazont/aioxmpp | aioxmpp/forms/fields.py | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/forms/fields.py#L384-L398 | def value(self):
"""
A tuple of values. This attribute can be set with any iterable; the
iterable is then evaluated into a tuple and stored at the bound field.
Whenever values are written to this attribute, they are passed through
the :meth:`~.AbstractCDataType.coerce` method of... | [
"def",
"value",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_value",
"except",
"AttributeError",
":",
"self",
".",
"value",
"=",
"self",
".",
"_field",
".",
"default",
"(",
")",
"return",
"self",
".",
"_value"
] | A tuple of values. This attribute can be set with any iterable; the
iterable is then evaluated into a tuple and stored at the bound field.
Whenever values are written to this attribute, they are passed through
the :meth:`~.AbstractCDataType.coerce` method of the
:attr:`~.AbstractField.t... | [
"A",
"tuple",
"of",
"values",
".",
"This",
"attribute",
"can",
"be",
"set",
"with",
"any",
"iterable",
";",
"the",
"iterable",
"is",
"then",
"evaluated",
"into",
"a",
"tuple",
"and",
"stored",
"at",
"the",
"bound",
"field",
"."
] | python | train |
django-fluent/django-fluent-dashboard | fluent_dashboard/items.py | https://github.com/django-fluent/django-fluent-dashboard/blob/aee7ef39e0586cd160036b13b7944b69cd2b4b8c/fluent_dashboard/items.py#L101-L122 | def get_edited_object(self, request):
"""
Return the object which is currently being edited.
Returns ``None`` if the match could not be made.
"""
resolvermatch = urls.resolve(request.path_info)
if resolvermatch.namespace == 'admin' and resolvermatch.url_name and resolverm... | [
"def",
"get_edited_object",
"(",
"self",
",",
"request",
")",
":",
"resolvermatch",
"=",
"urls",
".",
"resolve",
"(",
"request",
".",
"path_info",
")",
"if",
"resolvermatch",
".",
"namespace",
"==",
"'admin'",
"and",
"resolvermatch",
".",
"url_name",
"and",
... | Return the object which is currently being edited.
Returns ``None`` if the match could not be made. | [
"Return",
"the",
"object",
"which",
"is",
"currently",
"being",
"edited",
".",
"Returns",
"None",
"if",
"the",
"match",
"could",
"not",
"be",
"made",
"."
] | python | train |
openstack/networking-arista | networking_arista/ml2/security_groups/security_group_sync.py | https://github.com/openstack/networking-arista/blob/07ce6b1fc62ff74308a6eabfc4cc0ee09fb7b0fe/networking_arista/ml2/security_groups/security_group_sync.py#L63-L88 | def synchronize_switch(self, switch_ip, expected_acls, expected_bindings):
"""Update ACL config on a switch to match expected config
This is done as follows:
1. Get switch ACL config using show commands
2. Update expected bindings based on switch LAGs
3. Get commands to synchron... | [
"def",
"synchronize_switch",
"(",
"self",
",",
"switch_ip",
",",
"expected_acls",
",",
"expected_bindings",
")",
":",
"# Get ACL rules and interface mappings from the switch",
"switch_acls",
",",
"switch_bindings",
"=",
"self",
".",
"_get_dynamic_acl_info",
"(",
"switch_ip"... | Update ACL config on a switch to match expected config
This is done as follows:
1. Get switch ACL config using show commands
2. Update expected bindings based on switch LAGs
3. Get commands to synchronize switch ACLs
4. Get commands to synchronize switch ACL bindings
5. ... | [
"Update",
"ACL",
"config",
"on",
"a",
"switch",
"to",
"match",
"expected",
"config"
] | python | train |
jmbhughes/suvi-trainer | suvitrainer/gui.py | https://github.com/jmbhughes/suvi-trainer/blob/3d89894a4a037286221974c7eb5634d229b4f5d4/suvitrainer/gui.py#L596-L648 | def setup_multicolor(self):
""" initial setup of multicolor options and variables"""
# Setup the options for multicolor
multicolormasterframe = tk.Frame(self.tab_configure)
channel_choices = sorted(list(self.data.keys()))
rgb = ['red', 'green', 'blue']
self.multicolorfram... | [
"def",
"setup_multicolor",
"(",
"self",
")",
":",
"# Setup the options for multicolor",
"multicolormasterframe",
"=",
"tk",
".",
"Frame",
"(",
"self",
".",
"tab_configure",
")",
"channel_choices",
"=",
"sorted",
"(",
"list",
"(",
"self",
".",
"data",
".",
"keys"... | initial setup of multicolor options and variables | [
"initial",
"setup",
"of",
"multicolor",
"options",
"and",
"variables"
] | python | train |
Toilal/rebulk | rebulk/match.py | https://github.com/Toilal/rebulk/blob/7511a4671f2fd9493e3df1e5177b7656789069e8/rebulk/match.py#L791-L816 | def split(self, seps, predicate=None, index=None):
"""
Split this match in multiple matches using given separators.
:param seps:
:type seps: string containing separator characters
:return: list of new Match objects
:rtype: list
"""
split_match = copy.deepc... | [
"def",
"split",
"(",
"self",
",",
"seps",
",",
"predicate",
"=",
"None",
",",
"index",
"=",
"None",
")",
":",
"split_match",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
")",
"current_match",
"=",
"split_match",
"ret",
"=",
"[",
"]",
"for",
"i",
"in",
... | Split this match in multiple matches using given separators.
:param seps:
:type seps: string containing separator characters
:return: list of new Match objects
:rtype: list | [
"Split",
"this",
"match",
"in",
"multiple",
"matches",
"using",
"given",
"separators",
".",
":",
"param",
"seps",
":",
":",
"type",
"seps",
":",
"string",
"containing",
"separator",
"characters",
":",
"return",
":",
"list",
"of",
"new",
"Match",
"objects",
... | python | train |
AkihikoITOH/capybara | capybara/virtualenv/lib/python2.7/site-packages/flask/app.py | https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/flask/app.py#L639-L663 | def create_jinja_environment(self):
"""Creates the Jinja2 environment based on :attr:`jinja_options`
and :meth:`select_jinja_autoescape`. Since 0.7 this also adds
the Jinja2 globals and filters after initialization. Override
this function to customize the behavior.
.. versiona... | [
"def",
"create_jinja_environment",
"(",
"self",
")",
":",
"options",
"=",
"dict",
"(",
"self",
".",
"jinja_options",
")",
"if",
"'autoescape'",
"not",
"in",
"options",
":",
"options",
"[",
"'autoescape'",
"]",
"=",
"self",
".",
"select_jinja_autoescape",
"rv",... | Creates the Jinja2 environment based on :attr:`jinja_options`
and :meth:`select_jinja_autoescape`. Since 0.7 this also adds
the Jinja2 globals and filters after initialization. Override
this function to customize the behavior.
.. versionadded:: 0.5 | [
"Creates",
"the",
"Jinja2",
"environment",
"based",
"on",
":",
"attr",
":",
"jinja_options",
"and",
":",
"meth",
":",
"select_jinja_autoescape",
".",
"Since",
"0",
".",
"7",
"this",
"also",
"adds",
"the",
"Jinja2",
"globals",
"and",
"filters",
"after",
"init... | python | test |
hydpy-dev/hydpy | hydpy/core/timetools.py | https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/timetools.py#L1562-L1591 | def assignrepr(self, prefix, style=None, utcoffset=None):
"""Return a |repr| string with an prefixed assignement.
Without option arguments given, printing the returned string
looks like:
>>> from hydpy import Timegrid
>>> timegrid = Timegrid('1996-11-01 00:00:00',
... ... | [
"def",
"assignrepr",
"(",
"self",
",",
"prefix",
",",
"style",
"=",
"None",
",",
"utcoffset",
"=",
"None",
")",
":",
"skip",
"=",
"len",
"(",
"prefix",
")",
"+",
"9",
"blanks",
"=",
"' '",
"*",
"skip",
"return",
"(",
"f\"{prefix}Timegrid('\"",
"f\"{sel... | Return a |repr| string with an prefixed assignement.
Without option arguments given, printing the returned string
looks like:
>>> from hydpy import Timegrid
>>> timegrid = Timegrid('1996-11-01 00:00:00',
... '1997-11-01 00:00:00',
... ... | [
"Return",
"a",
"|repr|",
"string",
"with",
"an",
"prefixed",
"assignement",
"."
] | python | train |
dmlc/gluon-nlp | src/gluonnlp/model/translation.py | https://github.com/dmlc/gluon-nlp/blob/4b83eb6bcc8881e5f1081a3675adaa19fac5c0ba/src/gluonnlp/model/translation.py#L129-L143 | def encode(self, inputs, states=None, valid_length=None):
"""Encode the input sequence.
Parameters
----------
inputs : NDArray
states : list of NDArrays or None, default None
valid_length : NDArray or None, default None
Returns
-------
outputs : ... | [
"def",
"encode",
"(",
"self",
",",
"inputs",
",",
"states",
"=",
"None",
",",
"valid_length",
"=",
"None",
")",
":",
"return",
"self",
".",
"encoder",
"(",
"self",
".",
"src_embed",
"(",
"inputs",
")",
",",
"states",
",",
"valid_length",
")"
] | Encode the input sequence.
Parameters
----------
inputs : NDArray
states : list of NDArrays or None, default None
valid_length : NDArray or None, default None
Returns
-------
outputs : list
Outputs of the encoder. | [
"Encode",
"the",
"input",
"sequence",
"."
] | python | train |
heroku/sf-suds | suds/sax/__init__.py | https://github.com/heroku/sf-suds/blob/44b6743a45ff4447157605d6fecc9bf5922ce68a/suds/sax/__init__.py#L40-L53 | def splitPrefix(name):
"""
Split the name into a tuple (I{prefix}, I{name}). The first element in
the tuple is I{None} when the name does't have a prefix.
@param name: A node name containing an optional prefix.
@type name: basestring
@return: A tuple containing the (2) parts of I{name}
@rty... | [
"def",
"splitPrefix",
"(",
"name",
")",
":",
"if",
"isinstance",
"(",
"name",
",",
"basestring",
")",
"and",
"':'",
"in",
"name",
":",
"return",
"tuple",
"(",
"name",
".",
"split",
"(",
"':'",
",",
"1",
")",
")",
"else",
":",
"return",
"(",
"None",... | Split the name into a tuple (I{prefix}, I{name}). The first element in
the tuple is I{None} when the name does't have a prefix.
@param name: A node name containing an optional prefix.
@type name: basestring
@return: A tuple containing the (2) parts of I{name}
@rtype: (I{prefix}, I{name}) | [
"Split",
"the",
"name",
"into",
"a",
"tuple",
"(",
"I",
"{",
"prefix",
"}",
"I",
"{",
"name",
"}",
")",
".",
"The",
"first",
"element",
"in",
"the",
"tuple",
"is",
"I",
"{",
"None",
"}",
"when",
"the",
"name",
"does",
"t",
"have",
"a",
"prefix",
... | python | train |
mk-fg/feedjack | feedjack/models.py | https://github.com/mk-fg/feedjack/blob/3fe65c0f66dc2cfdf45834aaa7235ec9f81b3ca3/feedjack/models.py#L783-L814 | def _filtering_result_checked(self, by_or):
'''Check if post passes all / at_least_one (by_or parameter) filter(s).
Filters are evaluated on only-if-necessary ("lazy") basis.'''
filters, results = it.imap(set, ( self.feed.filters.all(),
self.filtering_results.values_list('filter', flat=True) ))
# Check if ... | [
"def",
"_filtering_result_checked",
"(",
"self",
",",
"by_or",
")",
":",
"filters",
",",
"results",
"=",
"it",
".",
"imap",
"(",
"set",
",",
"(",
"self",
".",
"feed",
".",
"filters",
".",
"all",
"(",
")",
",",
"self",
".",
"filtering_results",
".",
"... | Check if post passes all / at_least_one (by_or parameter) filter(s).
Filters are evaluated on only-if-necessary ("lazy") basis. | [
"Check",
"if",
"post",
"passes",
"all",
"/",
"at_least_one",
"(",
"by_or",
"parameter",
")",
"filter",
"(",
"s",
")",
".",
"Filters",
"are",
"evaluated",
"on",
"only",
"-",
"if",
"-",
"necessary",
"(",
"lazy",
")",
"basis",
"."
] | python | train |
a1ezzz/wasp-general | wasp_general/crypto/hash.py | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/crypto/hash.py#L161-L169 | def generator_family(cls):
""" :meth:`.WHashGeneratorProto.generator_family` implementation
"""
if cls.__generator_family__ is not None:
if isinstance(cls.__generator_family__, str) is False:
raise TypeError('"__generator_class__" if defined must be a str instance')
if cls.__generator_family__ is not N... | [
"def",
"generator_family",
"(",
"cls",
")",
":",
"if",
"cls",
".",
"__generator_family__",
"is",
"not",
"None",
":",
"if",
"isinstance",
"(",
"cls",
".",
"__generator_family__",
",",
"str",
")",
"is",
"False",
":",
"raise",
"TypeError",
"(",
"'\"__generator_... | :meth:`.WHashGeneratorProto.generator_family` implementation | [
":",
"meth",
":",
".",
"WHashGeneratorProto",
".",
"generator_family",
"implementation"
] | python | train |
Jaymon/captain | captain/__init__.py | https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/__init__.py#L198-L202 | def body(self):
"""get the contents of the script"""
if not hasattr(self, '_body'):
self._body = inspect.getsource(self.module)
return self._body | [
"def",
"body",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_body'",
")",
":",
"self",
".",
"_body",
"=",
"inspect",
".",
"getsource",
"(",
"self",
".",
"module",
")",
"return",
"self",
".",
"_body"
] | get the contents of the script | [
"get",
"the",
"contents",
"of",
"the",
"script"
] | python | valid |
BlueBrain/NeuroM | neurom/fst/sectionfunc.py | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/neurom/fst/sectionfunc.py#L101-L105 | def section_meander_angles(section):
'''Inter-segment opening angles in a section'''
p = section.points
return [mm.angle_3points(p[i - 1], p[i - 2], p[i])
for i in range(2, len(p))] | [
"def",
"section_meander_angles",
"(",
"section",
")",
":",
"p",
"=",
"section",
".",
"points",
"return",
"[",
"mm",
".",
"angle_3points",
"(",
"p",
"[",
"i",
"-",
"1",
"]",
",",
"p",
"[",
"i",
"-",
"2",
"]",
",",
"p",
"[",
"i",
"]",
")",
"for",... | Inter-segment opening angles in a section | [
"Inter",
"-",
"segment",
"opening",
"angles",
"in",
"a",
"section"
] | python | train |
klavinslab/coral | coral/design/_oligo_synthesis/oligo_assembly.py | https://github.com/klavinslab/coral/blob/17f59591211562a59a051f474cd6cecba4829df9/coral/design/_oligo_synthesis/oligo_assembly.py#L412-L432 | def _adjust_overlap(positions_list, index, direction):
'''Increase overlap to the right or left of an index.
:param positions_list: list of overlap positions
:type positions_list: list
:param index: index of the overlap to increase.
:type index: int
:param direction: which side of the overlap t... | [
"def",
"_adjust_overlap",
"(",
"positions_list",
",",
"index",
",",
"direction",
")",
":",
"if",
"direction",
"==",
"'left'",
":",
"positions_list",
"[",
"index",
"+",
"1",
"]",
"-=",
"1",
"elif",
"direction",
"==",
"'right'",
":",
"positions_list",
"[",
"... | Increase overlap to the right or left of an index.
:param positions_list: list of overlap positions
:type positions_list: list
:param index: index of the overlap to increase.
:type index: int
:param direction: which side of the overlap to increase - left or right.
:type direction: str
:retu... | [
"Increase",
"overlap",
"to",
"the",
"right",
"or",
"left",
"of",
"an",
"index",
"."
] | python | train |
luckydonald/pytgbot | code_generation/code_generator_template.py | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/code_generator_template.py#L86-L115 | def func(command, description, link, params_string, returns="On success, the sent Message is returned.", return_type="Message"):
"""
Live template for pycharm:
y = func(command="$cmd$", description="$desc$", link="$lnk$", params_string="$first_param$", returns="$returns$", return_type="$returntype$")
"... | [
"def",
"func",
"(",
"command",
",",
"description",
",",
"link",
",",
"params_string",
",",
"returns",
"=",
"\"On success, the sent Message is returned.\"",
",",
"return_type",
"=",
"\"Message\"",
")",
":",
"variables_needed",
"=",
"[",
"]",
"variables_optional",
"="... | Live template for pycharm:
y = func(command="$cmd$", description="$desc$", link="$lnk$", params_string="$first_param$", returns="$returns$", return_type="$returntype$") | [
"Live",
"template",
"for",
"pycharm",
":"
] | python | train |
jxtech/wechatpy | wechatpy/client/api/merchant/__init__.py | https://github.com/jxtech/wechatpy/blob/4df0da795618c0895a10f1c2cde9e9d5c0a93aaa/wechatpy/client/api/merchant/__init__.py#L398-L410 | def set_delivery(self, order_id, delivery_data):
"""
修改货架
:param order_id: 订单ID
:param delivery_data: 商品物流信息
:return: 返回的 JSON 数据包
"""
delivery_data['order_id'] = order_id
return self._post(
'merchant/shelf/setdeliverymod',
data=de... | [
"def",
"set_delivery",
"(",
"self",
",",
"order_id",
",",
"delivery_data",
")",
":",
"delivery_data",
"[",
"'order_id'",
"]",
"=",
"order_id",
"return",
"self",
".",
"_post",
"(",
"'merchant/shelf/setdeliverymod'",
",",
"data",
"=",
"delivery_data",
")"
] | 修改货架
:param order_id: 订单ID
:param delivery_data: 商品物流信息
:return: 返回的 JSON 数据包 | [
"修改货架"
] | python | train |
Alignak-monitoring/alignak | alignak/dependencynode.py | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/dependencynode.py#L259-L354 | def get_complex_xof_node_state(self, hosts, services):
# pylint: disable=too-many-locals, too-many-return-statements, too-many-branches
"""Get state , handle X of aggregation ::
* Count the number of OK, WARNING, CRITICAL
* Try too apply, in this order, Critical, Warning, OK rule
... | [
"def",
"get_complex_xof_node_state",
"(",
"self",
",",
"hosts",
",",
"services",
")",
":",
"# pylint: disable=too-many-locals, too-many-return-statements, too-many-branches",
"# First we get the state of all our sons",
"states",
"=",
"[",
"s",
".",
"get_state",
"(",
"hosts",
... | Get state , handle X of aggregation ::
* Count the number of OK, WARNING, CRITICAL
* Try too apply, in this order, Critical, Warning, OK rule
* Return the code for first match (2, 1, 0)
* If no rule apply, return OK for simple X of and worst state for multiple X of
... | [
"Get",
"state",
"handle",
"X",
"of",
"aggregation",
"::"
] | python | train |
ray-project/ray | python/ray/worker.py | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/worker.py#L759-L794 | def _get_arguments_for_execution(self, function_name, serialized_args):
"""Retrieve the arguments for the remote function.
This retrieves the values for the arguments to the remote function that
were passed in as object IDs. Arguments that were passed by value are
not changed. This is c... | [
"def",
"_get_arguments_for_execution",
"(",
"self",
",",
"function_name",
",",
"serialized_args",
")",
":",
"arguments",
"=",
"[",
"]",
"for",
"(",
"i",
",",
"arg",
")",
"in",
"enumerate",
"(",
"serialized_args",
")",
":",
"if",
"isinstance",
"(",
"arg",
"... | Retrieve the arguments for the remote function.
This retrieves the values for the arguments to the remote function that
were passed in as object IDs. Arguments that were passed by value are
not changed. This is called by the worker that is executing the remote
function.
Args:
... | [
"Retrieve",
"the",
"arguments",
"for",
"the",
"remote",
"function",
"."
] | python | train |
janpipek/physt | physt/histogram_base.py | https://github.com/janpipek/physt/blob/6dd441b073514e7728235f50b2352d56aacf38d4/physt/histogram_base.py#L522-L532 | def has_same_bins(self, other: "HistogramBase") -> bool:
"""Whether two histograms share the same binning."""
if self.shape != other.shape:
return False
elif self.ndim == 1:
return np.allclose(self.bins, other.bins)
elif self.ndim > 1:
for i in range(s... | [
"def",
"has_same_bins",
"(",
"self",
",",
"other",
":",
"\"HistogramBase\"",
")",
"->",
"bool",
":",
"if",
"self",
".",
"shape",
"!=",
"other",
".",
"shape",
":",
"return",
"False",
"elif",
"self",
".",
"ndim",
"==",
"1",
":",
"return",
"np",
".",
"a... | Whether two histograms share the same binning. | [
"Whether",
"two",
"histograms",
"share",
"the",
"same",
"binning",
"."
] | python | train |
cmap/cmapPy | cmapPy/set_io/gmt.py | https://github.com/cmap/cmapPy/blob/59d833b64fd2c3a494cdf67fe1eb11fc8008bf76/cmapPy/set_io/gmt.py#L93-L109 | def write(gmt, out_path):
""" Write a GMT to a text file.
Args:
gmt (GMT object): list of dicts
out_path (string): output path
Returns:
None
"""
with open(out_path, 'w') as f:
for _, each_dict in enumerate(gmt):
f.write(each_dict[SET_IDENTIFIER_FIELD] +... | [
"def",
"write",
"(",
"gmt",
",",
"out_path",
")",
":",
"with",
"open",
"(",
"out_path",
",",
"'w'",
")",
"as",
"f",
":",
"for",
"_",
",",
"each_dict",
"in",
"enumerate",
"(",
"gmt",
")",
":",
"f",
".",
"write",
"(",
"each_dict",
"[",
"SET_IDENTIFIE... | Write a GMT to a text file.
Args:
gmt (GMT object): list of dicts
out_path (string): output path
Returns:
None | [
"Write",
"a",
"GMT",
"to",
"a",
"text",
"file",
"."
] | python | train |
bukun/TorCMS | ext_script/autocrud/func_gen_html.py | https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/ext_script/autocrud/func_gen_html.py#L69-L92 | def gen_select_view(sig_dic):
'''
HTML view, for selection.
'''
option_str = ''
dic_tmp = sig_dic['dic']
for key, val in dic_tmp.items():
tmp_str = '''
{{% if '{sig_en}' in postinfo.extinfo %}}
{{% set tmp_var = postinfo.extinfo["{sig_en}"] %}}
{{% if tmp_var... | [
"def",
"gen_select_view",
"(",
"sig_dic",
")",
":",
"option_str",
"=",
"''",
"dic_tmp",
"=",
"sig_dic",
"[",
"'dic'",
"]",
"for",
"key",
",",
"val",
"in",
"dic_tmp",
".",
"items",
"(",
")",
":",
"tmp_str",
"=",
"'''\n {{% if '{sig_en}' in postinfo.exti... | HTML view, for selection. | [
"HTML",
"view",
"for",
"selection",
"."
] | python | train |
ethereum/py-evm | eth/vm/base.py | https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/base.py#L710-L727 | def generate_block_from_parent_header_and_coinbase(cls,
parent_header: BlockHeader,
coinbase: Address) -> BaseBlock:
"""
Generate block from parent header and coinbase.
"""
block... | [
"def",
"generate_block_from_parent_header_and_coinbase",
"(",
"cls",
",",
"parent_header",
":",
"BlockHeader",
",",
"coinbase",
":",
"Address",
")",
"->",
"BaseBlock",
":",
"block_header",
"=",
"generate_header_from_parent_header",
"(",
"cls",
".",
"compute_difficulty",
... | Generate block from parent header and coinbase. | [
"Generate",
"block",
"from",
"parent",
"header",
"and",
"coinbase",
"."
] | python | train |
UCSBarchlab/PyRTL | pyrtl/compilesim.py | https://github.com/UCSBarchlab/PyRTL/blob/0988e5c9c10ededd5e1f58d5306603f9edf4b3e2/pyrtl/compilesim.py#L236-L242 | def _makeini(self, w, v):
"""C initializer string for a wire with a given value."""
pieces = []
for n in range(self._limbs(w)):
pieces.append(hex(v & ((1 << 64)-1)))
v >>= 64
return ','.join(pieces).join('{}') | [
"def",
"_makeini",
"(",
"self",
",",
"w",
",",
"v",
")",
":",
"pieces",
"=",
"[",
"]",
"for",
"n",
"in",
"range",
"(",
"self",
".",
"_limbs",
"(",
"w",
")",
")",
":",
"pieces",
".",
"append",
"(",
"hex",
"(",
"v",
"&",
"(",
"(",
"1",
"<<",
... | C initializer string for a wire with a given value. | [
"C",
"initializer",
"string",
"for",
"a",
"wire",
"with",
"a",
"given",
"value",
"."
] | python | train |
bitesofcode/projexui | projexui/widgets/xviewwidget/xviewpanel.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xviewpanel.py#L1452-L1459 | def setCurrentIndex(self, index):
"""
Sets the current index on self and on the tab bar to keep the two insync.
:param index | <int>
"""
super(XViewPanel, self).setCurrentIndex(index)
self.tabBar().setCurrentIndex(index) | [
"def",
"setCurrentIndex",
"(",
"self",
",",
"index",
")",
":",
"super",
"(",
"XViewPanel",
",",
"self",
")",
".",
"setCurrentIndex",
"(",
"index",
")",
"self",
".",
"tabBar",
"(",
")",
".",
"setCurrentIndex",
"(",
"index",
")"
] | Sets the current index on self and on the tab bar to keep the two insync.
:param index | <int> | [
"Sets",
"the",
"current",
"index",
"on",
"self",
"and",
"on",
"the",
"tab",
"bar",
"to",
"keep",
"the",
"two",
"insync",
"."
] | python | train |
versae/neo4j-rest-client | neo4jrestclient/client.py | https://github.com/versae/neo4j-rest-client/blob/b03c09c8f598fa4dbad8ea8998ffb1c885805074/neo4jrestclient/client.py#L1788-L1813 | def query(self, *args):
"""
Query a fulltext index by key and query or just a plain Lucene query,
i1 = gdb.nodes.indexes.get('people',type='fulltext', provider='lucene')
i1.query('name','do*')
i1.query('name:do*')
In this example, the last two line are equivalent.
... | [
"def",
"query",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"not",
"args",
"or",
"len",
"(",
"args",
")",
">",
"2",
":",
"raise",
"TypeError",
"(",
"'query() takes 2 or 3 arguments (a query or a key '",
"'and a query) (%d given)'",
"%",
"(",
"len",
"(",
"... | Query a fulltext index by key and query or just a plain Lucene query,
i1 = gdb.nodes.indexes.get('people',type='fulltext', provider='lucene')
i1.query('name','do*')
i1.query('name:do*')
In this example, the last two line are equivalent. | [
"Query",
"a",
"fulltext",
"index",
"by",
"key",
"and",
"query",
"or",
"just",
"a",
"plain",
"Lucene",
"query"
] | python | train |
cloud-custodian/cloud-custodian | tools/c7n_policystream/policystream.py | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_policystream/policystream.py#L298-L325 | def delta_commits(self, baseline, target):
"""Show policies changes between arbitrary commits.
The common use form is comparing the heads of two branches.
"""
baseline_files = self._get_policy_fents(baseline.tree)
target_files = self._get_policy_fents(target.tree)
basel... | [
"def",
"delta_commits",
"(",
"self",
",",
"baseline",
",",
"target",
")",
":",
"baseline_files",
"=",
"self",
".",
"_get_policy_fents",
"(",
"baseline",
".",
"tree",
")",
"target_files",
"=",
"self",
".",
"_get_policy_fents",
"(",
"target",
".",
"tree",
")",... | Show policies changes between arbitrary commits.
The common use form is comparing the heads of two branches. | [
"Show",
"policies",
"changes",
"between",
"arbitrary",
"commits",
"."
] | python | train |
valency/deeputils | deeputils/common.py | https://github.com/valency/deeputils/blob/27efd91668de0223ed8b07cfadf2151632521520/deeputils/common.py#L85-L92 | def dict_sort(d, k):
"""
Sort a dictionary list by key
:param d: dictionary list
:param k: key
:return: sorted dictionary list
"""
return sorted(d.copy(), key=lambda i: i[k]) | [
"def",
"dict_sort",
"(",
"d",
",",
"k",
")",
":",
"return",
"sorted",
"(",
"d",
".",
"copy",
"(",
")",
",",
"key",
"=",
"lambda",
"i",
":",
"i",
"[",
"k",
"]",
")"
] | Sort a dictionary list by key
:param d: dictionary list
:param k: key
:return: sorted dictionary list | [
"Sort",
"a",
"dictionary",
"list",
"by",
"key",
":",
"param",
"d",
":",
"dictionary",
"list",
":",
"param",
"k",
":",
"key",
":",
"return",
":",
"sorted",
"dictionary",
"list"
] | python | valid |
rcarmo/pngcanvas | pngcanvas.py | https://github.com/rcarmo/pngcanvas/blob/e2eaa0d5ba353005b3b658f6ee453c1956340670/pngcanvas.py#L133-L139 | def vertical_gradient(self, x0, y0, x1, y1, start, end):
"""Draw a vertical gradient"""
x0, y0, x1, y1 = self.rect_helper(x0, y0, x1, y1)
grad = gradient_list(start, end, y1 - y0)
for x in range(x0, x1 + 1):
for y in range(y0, y1 + 1):
self.point(x, y, grad[y ... | [
"def",
"vertical_gradient",
"(",
"self",
",",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
",",
"start",
",",
"end",
")",
":",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
"=",
"self",
".",
"rect_helper",
"(",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
")",
... | Draw a vertical gradient | [
"Draw",
"a",
"vertical",
"gradient"
] | python | train |
limix/numpy-sugar | numpy_sugar/_array.py | https://github.com/limix/numpy-sugar/blob/4bdfa26913135c76ef3cd542a332f4e5861e948b/numpy_sugar/_array.py#L132-L149 | def unique(ar):
r"""Find the unique elements of an array.
It uses ``dask.array.unique`` if necessary.
Args:
ar (array_like): Input array.
Returns:
array_like: the sorted unique elements.
"""
import dask.array as da
if isinstance(ar, da.core.Array):
return da.uniq... | [
"def",
"unique",
"(",
"ar",
")",
":",
"import",
"dask",
".",
"array",
"as",
"da",
"if",
"isinstance",
"(",
"ar",
",",
"da",
".",
"core",
".",
"Array",
")",
":",
"return",
"da",
".",
"unique",
"(",
"ar",
")",
"return",
"_unique",
"(",
"ar",
")"
] | r"""Find the unique elements of an array.
It uses ``dask.array.unique`` if necessary.
Args:
ar (array_like): Input array.
Returns:
array_like: the sorted unique elements. | [
"r",
"Find",
"the",
"unique",
"elements",
"of",
"an",
"array",
"."
] | python | train |
angr/angr | angr/annocfg.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/annocfg.py#L262-L292 | def successor_func(self, path):
"""
Callback routine that takes in a path, and returns all feasible successors to path group. This callback routine
should be passed to the keyword argument "successor_func" of PathGroup.step().
:param path: A Path instance.
:return: A list of all... | [
"def",
"successor_func",
"(",
"self",
",",
"path",
")",
":",
"whitelist",
"=",
"self",
".",
"get_whitelisted_statements",
"(",
"path",
".",
"addr",
")",
"last_stmt",
"=",
"self",
".",
"get_last_statement_index",
"(",
"path",
".",
"addr",
")",
"# pass in those ... | Callback routine that takes in a path, and returns all feasible successors to path group. This callback routine
should be passed to the keyword argument "successor_func" of PathGroup.step().
:param path: A Path instance.
:return: A list of all feasible Path successors. | [
"Callback",
"routine",
"that",
"takes",
"in",
"a",
"path",
"and",
"returns",
"all",
"feasible",
"successors",
"to",
"path",
"group",
".",
"This",
"callback",
"routine",
"should",
"be",
"passed",
"to",
"the",
"keyword",
"argument",
"successor_func",
"of",
"Path... | python | train |
odlgroup/odl | odl/set/space.py | https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/set/space.py#L937-L946 | def divide(self, other, out=None):
"""Return ``out = self / other``.
If ``out`` is provided, the result is written to it.
See Also
--------
LinearSpace.divide
"""
return self.space.divide(self, other, out=out) | [
"def",
"divide",
"(",
"self",
",",
"other",
",",
"out",
"=",
"None",
")",
":",
"return",
"self",
".",
"space",
".",
"divide",
"(",
"self",
",",
"other",
",",
"out",
"=",
"out",
")"
] | Return ``out = self / other``.
If ``out`` is provided, the result is written to it.
See Also
--------
LinearSpace.divide | [
"Return",
"out",
"=",
"self",
"/",
"other",
"."
] | python | train |
wandb/client | wandb/util.py | https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/util.py#L637-L652 | def downsample(values, target_length):
"""Downsamples 1d values to target_length, including start and end.
Algorithm just rounds index down.
Values can be any sequence, including a generator.
"""
assert target_length > 1
values = list(values)
if len(values) < target_length:
return ... | [
"def",
"downsample",
"(",
"values",
",",
"target_length",
")",
":",
"assert",
"target_length",
">",
"1",
"values",
"=",
"list",
"(",
"values",
")",
"if",
"len",
"(",
"values",
")",
"<",
"target_length",
":",
"return",
"values",
"ratio",
"=",
"float",
"("... | Downsamples 1d values to target_length, including start and end.
Algorithm just rounds index down.
Values can be any sequence, including a generator. | [
"Downsamples",
"1d",
"values",
"to",
"target_length",
"including",
"start",
"and",
"end",
"."
] | python | train |
PyCQA/pyflakes | pyflakes/checker.py | https://github.com/PyCQA/pyflakes/blob/232cb1d27ee134bf96adc8f37e53589dc259b159/pyflakes/checker.py#L1309-L1337 | def GLOBAL(self, node):
"""
Keep track of globals declarations.
"""
global_scope_index = 1 if self._in_doctest() else 0
global_scope = self.scopeStack[global_scope_index]
# Ignore 'global' statement in global scope.
if self.scope is not global_scope:
... | [
"def",
"GLOBAL",
"(",
"self",
",",
"node",
")",
":",
"global_scope_index",
"=",
"1",
"if",
"self",
".",
"_in_doctest",
"(",
")",
"else",
"0",
"global_scope",
"=",
"self",
".",
"scopeStack",
"[",
"global_scope_index",
"]",
"# Ignore 'global' statement in global s... | Keep track of globals declarations. | [
"Keep",
"track",
"of",
"globals",
"declarations",
"."
] | python | train |
cenkalti/kuyruk | kuyruk/kuyruk.py | https://github.com/cenkalti/kuyruk/blob/c99d66be9d8fb077610f2fa883d5a1d268b42f04/kuyruk/kuyruk.py#L65-L87 | def connection(self) -> Iterator[amqp.Connection]:
"""Returns a new connection as a context manager."""
TCP_USER_TIMEOUT = 18 # constant is available on Python 3.6+.
socket_settings = {TCP_USER_TIMEOUT: self.config.TCP_USER_TIMEOUT}
if sys.platform.startswith('darwin'):
del... | [
"def",
"connection",
"(",
"self",
")",
"->",
"Iterator",
"[",
"amqp",
".",
"Connection",
"]",
":",
"TCP_USER_TIMEOUT",
"=",
"18",
"# constant is available on Python 3.6+.",
"socket_settings",
"=",
"{",
"TCP_USER_TIMEOUT",
":",
"self",
".",
"config",
".",
"TCP_USER... | Returns a new connection as a context manager. | [
"Returns",
"a",
"new",
"connection",
"as",
"a",
"context",
"manager",
"."
] | python | train |
AndrewAnnex/SpiceyPy | spiceypy/spiceypy.py | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L14698-L14722 | def vlcom(a, v1, b, v2):
"""
Compute a vector linear combination of two double precision,
3-dimensional vectors.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vlcom_c.html
:param a: Coefficient of v1
:type a: float
:param v1: Vector in 3-space
:type v1: 3-Element Array of f... | [
"def",
"vlcom",
"(",
"a",
",",
"v1",
",",
"b",
",",
"v2",
")",
":",
"v1",
"=",
"stypes",
".",
"toDoubleVector",
"(",
"v1",
")",
"v2",
"=",
"stypes",
".",
"toDoubleVector",
"(",
"v2",
")",
"sumv",
"=",
"stypes",
".",
"emptyDoubleVector",
"(",
"3",
... | Compute a vector linear combination of two double precision,
3-dimensional vectors.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/vlcom_c.html
:param a: Coefficient of v1
:type a: float
:param v1: Vector in 3-space
:type v1: 3-Element Array of floats
:param b: Coefficient of v2... | [
"Compute",
"a",
"vector",
"linear",
"combination",
"of",
"two",
"double",
"precision",
"3",
"-",
"dimensional",
"vectors",
"."
] | python | train |
twneale/uni | uni/checker.py | https://github.com/twneale/uni/blob/1d2f3ef2cb97f544e878b8a1cde37ca8420af4e5/uni/checker.py#L43-L63 | def path_eval(self, obj, keypath):
'''Given an object and a mongo-style dotted key path, return the
object value referenced by that key path.
'''
segs = keypath.split('.')
this = obj
for seg in segs:
if isinstance(this, dict):
try:
... | [
"def",
"path_eval",
"(",
"self",
",",
"obj",
",",
"keypath",
")",
":",
"segs",
"=",
"keypath",
".",
"split",
"(",
"'.'",
")",
"this",
"=",
"obj",
"for",
"seg",
"in",
"segs",
":",
"if",
"isinstance",
"(",
"this",
",",
"dict",
")",
":",
"try",
":",... | Given an object and a mongo-style dotted key path, return the
object value referenced by that key path. | [
"Given",
"an",
"object",
"and",
"a",
"mongo",
"-",
"style",
"dotted",
"key",
"path",
"return",
"the",
"object",
"value",
"referenced",
"by",
"that",
"key",
"path",
"."
] | python | train |
Jajcus/pyxmpp2 | pyxmpp2/streamsasl.py | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/streamsasl.py#L299-L331 | def _process_sasl_success(self, stream, element):
"""Process incoming <sasl:success/> element.
[initiating entity only]
"""
if not self.authenticator:
logger.debug("Unexpected SASL response")
return False
content = element.text
if content:
... | [
"def",
"_process_sasl_success",
"(",
"self",
",",
"stream",
",",
"element",
")",
":",
"if",
"not",
"self",
".",
"authenticator",
":",
"logger",
".",
"debug",
"(",
"\"Unexpected SASL response\"",
")",
"return",
"False",
"content",
"=",
"element",
".",
"text",
... | Process incoming <sasl:success/> element.
[initiating entity only] | [
"Process",
"incoming",
"<sasl",
":",
"success",
"/",
">",
"element",
"."
] | python | valid |
lrq3000/pyFileFixity | pyFileFixity/lib/profilers/visual/runsnakerun/meliaeadapter.py | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/runsnakerun/meliaeadapter.py#L93-L106 | def best_parent( self, node, tree_type=None ):
"""Choose the best parent for a given node"""
parents = self.parents(node)
selected_parent = None
if node['type'] == 'type':
module = ".".join( node['name'].split( '.' )[:-1] )
if module:
for mod in pa... | [
"def",
"best_parent",
"(",
"self",
",",
"node",
",",
"tree_type",
"=",
"None",
")",
":",
"parents",
"=",
"self",
".",
"parents",
"(",
"node",
")",
"selected_parent",
"=",
"None",
"if",
"node",
"[",
"'type'",
"]",
"==",
"'type'",
":",
"module",
"=",
"... | Choose the best parent for a given node | [
"Choose",
"the",
"best",
"parent",
"for",
"a",
"given",
"node"
] | python | train |
boriel/zxbasic | arch/zx48k/backend/__init__.py | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1600-L1605 | def _paramf(ins):
""" Pushes 40bit (float) param into the stack
"""
output = _float_oper(ins.quad[1])
output.extend(_fpush())
return output | [
"def",
"_paramf",
"(",
"ins",
")",
":",
"output",
"=",
"_float_oper",
"(",
"ins",
".",
"quad",
"[",
"1",
"]",
")",
"output",
".",
"extend",
"(",
"_fpush",
"(",
")",
")",
"return",
"output"
] | Pushes 40bit (float) param into the stack | [
"Pushes",
"40bit",
"(",
"float",
")",
"param",
"into",
"the",
"stack"
] | python | train |
googleapis/gax-python | google/gax/__init__.py | https://github.com/googleapis/gax-python/blob/309aedfcfd48e4c8fa22dd60e9c84c3cc71bb20e/google/gax/__init__.py#L601-L608 | def exception(self, timeout=None):
"""Similar to result(), except returns the exception if any."""
# Check exceptional case: return none if no error
if not self._poll(timeout).HasField('error'):
return None
# Return expected error
return self._operation.error | [
"def",
"exception",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"# Check exceptional case: return none if no error",
"if",
"not",
"self",
".",
"_poll",
"(",
"timeout",
")",
".",
"HasField",
"(",
"'error'",
")",
":",
"return",
"None",
"# Return expected e... | Similar to result(), except returns the exception if any. | [
"Similar",
"to",
"result",
"()",
"except",
"returns",
"the",
"exception",
"if",
"any",
"."
] | python | train |
saltstack/salt | salt/modules/netbox.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netbox.py#L700-L766 | def create_interface(device_name,
interface_name,
mac_address=None,
description=None,
enabled=None,
lag=None,
lag_parent=None,
form_factor=None):
'''
.. versionadded... | [
"def",
"create_interface",
"(",
"device_name",
",",
"interface_name",
",",
"mac_address",
"=",
"None",
",",
"description",
"=",
"None",
",",
"enabled",
"=",
"None",
",",
"lag",
"=",
"None",
",",
"lag_parent",
"=",
"None",
",",
"form_factor",
"=",
"None",
"... | .. versionadded:: 2019.2.0
Attach an interface to a device. If not all arguments are provided,
they will default to Netbox defaults.
device_name
The name of the device, e.g., ``edge_router``
interface_name
The name of the interface, e.g., ``TenGigE0/0/0/0``
mac_address
Stri... | [
"..",
"versionadded",
"::",
"2019",
".",
"2",
".",
"0"
] | python | train |
zaturox/glin | glin/app.py | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/app.py#L288-L292 | def publish_scene_name(self, scene_id, name):
"""publish a changed scene name"""
self.sequence_number += 1
self.publisher.send_multipart(msgs.MessageBuilder.scene_name(self.sequence_number, scene_id, name))
return self.sequence_number | [
"def",
"publish_scene_name",
"(",
"self",
",",
"scene_id",
",",
"name",
")",
":",
"self",
".",
"sequence_number",
"+=",
"1",
"self",
".",
"publisher",
".",
"send_multipart",
"(",
"msgs",
".",
"MessageBuilder",
".",
"scene_name",
"(",
"self",
".",
"sequence_n... | publish a changed scene name | [
"publish",
"a",
"changed",
"scene",
"name"
] | python | train |
tcalmant/ipopo | pelix/shell/report.py | https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/shell/report.py#L307-L347 | def os_details():
"""
Returns a dictionary containing details about the operating system
"""
# Compute architecture and linkage
bits, linkage = platform.architecture()
results = {
# Machine details
"platform.arch.bits": bits,
"platform.... | [
"def",
"os_details",
"(",
")",
":",
"# Compute architecture and linkage",
"bits",
",",
"linkage",
"=",
"platform",
".",
"architecture",
"(",
")",
"results",
"=",
"{",
"# Machine details",
"\"platform.arch.bits\"",
":",
"bits",
",",
"\"platform.arch.linkage\"",
":",
... | Returns a dictionary containing details about the operating system | [
"Returns",
"a",
"dictionary",
"containing",
"details",
"about",
"the",
"operating",
"system"
] | python | train |
saltstack/salt | salt/utils/state.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/state.py#L126-L161 | def check_result(running, recurse=False, highstate=None):
'''
Check the total return value of the run and determine if the running
dict has any issues
'''
if not isinstance(running, dict):
return False
if not running:
return False
ret = True
for state_id, state_result i... | [
"def",
"check_result",
"(",
"running",
",",
"recurse",
"=",
"False",
",",
"highstate",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"running",
",",
"dict",
")",
":",
"return",
"False",
"if",
"not",
"running",
":",
"return",
"False",
"ret",
"=... | Check the total return value of the run and determine if the running
dict has any issues | [
"Check",
"the",
"total",
"return",
"value",
"of",
"the",
"run",
"and",
"determine",
"if",
"the",
"running",
"dict",
"has",
"any",
"issues"
] | python | train |
IRC-SPHERE/HyperStream | hyperstream/utils/time_utils.py | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/utils/time_utils.py#L105-L124 | def json_serial(obj):
"""JSON serializer for objects not serializable by default json code"""
if isinstance(obj, (datetime, date)):
serial = obj.isoformat()
return serial
from ..time_interval import TimeInterval, TimeIntervals
if isinstance(obj, (TimeInterval, TimeIntervals)):
... | [
"def",
"json_serial",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"(",
"datetime",
",",
"date",
")",
")",
":",
"serial",
"=",
"obj",
".",
"isoformat",
"(",
")",
"return",
"serial",
"from",
".",
".",
"time_interval",
"import",
"TimeInterv... | JSON serializer for objects not serializable by default json code | [
"JSON",
"serializer",
"for",
"objects",
"not",
"serializable",
"by",
"default",
"json",
"code"
] | python | train |
ekzhu/datasketch | datasketch/experimental/aio/lsh.py | https://github.com/ekzhu/datasketch/blob/b3e4129987890a2beb04f2c0b6dc618ae35f2e14/datasketch/experimental/aio/lsh.py#L275-L287 | async def query(self, minhash):
"""
see :class:`datasketch.MinHashLSH`.
"""
if len(minhash) != self.h:
raise ValueError("Expecting minhash with length %d, "
"got %d" % (self.h, len(minhash)))
fs = (hashtable.get(self._H(minhash.hashvalues... | [
"async",
"def",
"query",
"(",
"self",
",",
"minhash",
")",
":",
"if",
"len",
"(",
"minhash",
")",
"!=",
"self",
".",
"h",
":",
"raise",
"ValueError",
"(",
"\"Expecting minhash with length %d, \"",
"\"got %d\"",
"%",
"(",
"self",
".",
"h",
",",
"len",
"("... | see :class:`datasketch.MinHashLSH`. | [
"see",
":",
"class",
":",
"datasketch",
".",
"MinHashLSH",
"."
] | python | test |
saltstack/salt | salt/utils/schedule.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/schedule.py#L283-L304 | def delete_job(self, name, persist=True):
'''
Deletes a job from the scheduler. Ignore jobs from pillar
'''
# ensure job exists, then delete it
if name in self.opts['schedule']:
del self.opts['schedule'][name]
elif name in self._get_schedule(include_opts=False... | [
"def",
"delete_job",
"(",
"self",
",",
"name",
",",
"persist",
"=",
"True",
")",
":",
"# ensure job exists, then delete it",
"if",
"name",
"in",
"self",
".",
"opts",
"[",
"'schedule'",
"]",
":",
"del",
"self",
".",
"opts",
"[",
"'schedule'",
"]",
"[",
"n... | Deletes a job from the scheduler. Ignore jobs from pillar | [
"Deletes",
"a",
"job",
"from",
"the",
"scheduler",
".",
"Ignore",
"jobs",
"from",
"pillar"
] | python | train |
sarugaku/vistir | tasks/__init__.py | https://github.com/sarugaku/vistir/blob/96c008ee62a43608d1e70797f74634cb66a004c1/tasks/__init__.py#L26-L33 | def clean(ctx):
"""Clean previously built package artifacts.
"""
ctx.run(f"python setup.py clean")
dist = ROOT.joinpath("dist")
print(f"[clean] Removing {dist}")
if dist.exists():
shutil.rmtree(str(dist)) | [
"def",
"clean",
"(",
"ctx",
")",
":",
"ctx",
".",
"run",
"(",
"f\"python setup.py clean\"",
")",
"dist",
"=",
"ROOT",
".",
"joinpath",
"(",
"\"dist\"",
")",
"print",
"(",
"f\"[clean] Removing {dist}\"",
")",
"if",
"dist",
".",
"exists",
"(",
")",
":",
"s... | Clean previously built package artifacts. | [
"Clean",
"previously",
"built",
"package",
"artifacts",
"."
] | python | train |
agoragames/haigha | haigha/connection.py | https://github.com/agoragames/haigha/blob/7b004e1c0316ec14b94fec1c54554654c38b1a25/haigha/connection.py#L314-L348 | def channel(self, channel_id=None, synchronous=False):
"""
Fetch a Channel object identified by the numeric channel_id, or
create that object if it doesn't already exist. If channel_id is not
None but no channel exists for that id, will raise InvalidChannel. If
there are alread... | [
"def",
"channel",
"(",
"self",
",",
"channel_id",
"=",
"None",
",",
"synchronous",
"=",
"False",
")",
":",
"if",
"channel_id",
"is",
"None",
":",
"# adjust for channel 0",
"if",
"len",
"(",
"self",
".",
"_channels",
")",
"-",
"1",
">=",
"self",
".",
"_... | Fetch a Channel object identified by the numeric channel_id, or
create that object if it doesn't already exist. If channel_id is not
None but no channel exists for that id, will raise InvalidChannel. If
there are already too many channels open, will raise TooManyChannels.
If synchrono... | [
"Fetch",
"a",
"Channel",
"object",
"identified",
"by",
"the",
"numeric",
"channel_id",
"or",
"create",
"that",
"object",
"if",
"it",
"doesn",
"t",
"already",
"exist",
".",
"If",
"channel_id",
"is",
"not",
"None",
"but",
"no",
"channel",
"exists",
"for",
"t... | python | train |
collectiveacuity/jsonModel | jsonmodel/validators.py | https://github.com/collectiveacuity/jsonModel/blob/1ea64c36d78add3faa7b85ff82c5ec685458c940/jsonmodel/validators.py#L1327-L1347 | def _ingest_number(self, input_number, path_to_root):
'''
a helper method for ingesting a number
:return: valid_number
'''
valid_number = 0.0
try:
valid_number = self._validate_number(input_number, path_to_root)
except:
rules_path_t... | [
"def",
"_ingest_number",
"(",
"self",
",",
"input_number",
",",
"path_to_root",
")",
":",
"valid_number",
"=",
"0.0",
"try",
":",
"valid_number",
"=",
"self",
".",
"_validate_number",
"(",
"input_number",
",",
"path_to_root",
")",
"except",
":",
"rules_path_to_r... | a helper method for ingesting a number
:return: valid_number | [
"a",
"helper",
"method",
"for",
"ingesting",
"a",
"number"
] | python | train |
bcbio/bcbio-nextgen | scripts/utils/hla_loh_comparison.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/scripts/utils/hla_loh_comparison.py#L294-L309 | def get_hla_choice(h, hlas, normal_bam, tumor_bam):
"""Retrieve matching HLA with best read support in both tumor and normal
"""
def get_counts(bam_file):
counts = {}
for line in subprocess.check_output(["samtools", "idxstats", bam_file]).split("\n"):
if line.startswith(h):
... | [
"def",
"get_hla_choice",
"(",
"h",
",",
"hlas",
",",
"normal_bam",
",",
"tumor_bam",
")",
":",
"def",
"get_counts",
"(",
"bam_file",
")",
":",
"counts",
"=",
"{",
"}",
"for",
"line",
"in",
"subprocess",
".",
"check_output",
"(",
"[",
"\"samtools\"",
",",... | Retrieve matching HLA with best read support in both tumor and normal | [
"Retrieve",
"matching",
"HLA",
"with",
"best",
"read",
"support",
"in",
"both",
"tumor",
"and",
"normal"
] | python | train |
kstaniek/condoor | condoor/device.py | https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/device.py#L92-L104 | def clear_info(self):
"""Clear the device info."""
self._version_text = None
self._inventory_text = None
self._users_text = None
self.os_version = None
self.os_type = None
self.family = None
self.platform = None
self.udi = None
# self.is_co... | [
"def",
"clear_info",
"(",
"self",
")",
":",
"self",
".",
"_version_text",
"=",
"None",
"self",
".",
"_inventory_text",
"=",
"None",
"self",
".",
"_users_text",
"=",
"None",
"self",
".",
"os_version",
"=",
"None",
"self",
".",
"os_type",
"=",
"None",
"sel... | Clear the device info. | [
"Clear",
"the",
"device",
"info",
"."
] | python | train |
instagrambot/instabot | instabot/bot/bot_support.py | https://github.com/instagrambot/instabot/blob/d734f892ac4cc35d22746a4f2680425ffaff0927/instabot/bot/bot_support.py#L23-L39 | def read_list_from_file(file_path, quiet=False):
"""
Reads list from file. One line - one item.
Returns the list if file items.
"""
try:
if not check_if_file_exists(file_path, quiet=quiet):
return []
with codecs.open(file_path, "r", encoding="utf-8") as f:
... | [
"def",
"read_list_from_file",
"(",
"file_path",
",",
"quiet",
"=",
"False",
")",
":",
"try",
":",
"if",
"not",
"check_if_file_exists",
"(",
"file_path",
",",
"quiet",
"=",
"quiet",
")",
":",
"return",
"[",
"]",
"with",
"codecs",
".",
"open",
"(",
"file_p... | Reads list from file. One line - one item.
Returns the list if file items. | [
"Reads",
"list",
"from",
"file",
".",
"One",
"line",
"-",
"one",
"item",
".",
"Returns",
"the",
"list",
"if",
"file",
"items",
"."
] | python | test |
BDNYC/astrodbkit | astrodbkit/astrodb.py | https://github.com/BDNYC/astrodbkit/blob/02c03c5e91aa7c7b0f3b5fa95bcf71e33ffcee09/astrodbkit/astrodb.py#L2124-L2141 | def adapt_array(arr):
"""
Adapts a Numpy array into an ARRAY string to put into the database.
Parameters
----------
arr: array
The Numpy array to be adapted into an ARRAY type that can be inserted into a SQL file.
Returns
-------
ARRAY
The adapted array object
... | [
"def",
"adapt_array",
"(",
"arr",
")",
":",
"out",
"=",
"io",
".",
"BytesIO",
"(",
")",
"np",
".",
"save",
"(",
"out",
",",
"arr",
")",
",",
"out",
".",
"seek",
"(",
"0",
")",
"return",
"buffer",
"(",
"out",
".",
"read",
"(",
")",
")"
] | Adapts a Numpy array into an ARRAY string to put into the database.
Parameters
----------
arr: array
The Numpy array to be adapted into an ARRAY type that can be inserted into a SQL file.
Returns
-------
ARRAY
The adapted array object | [
"Adapts",
"a",
"Numpy",
"array",
"into",
"an",
"ARRAY",
"string",
"to",
"put",
"into",
"the",
"database",
"."
] | python | train |
ladybug-tools/ladybug | ladybug/datacollection.py | https://github.com/ladybug-tools/ladybug/blob/c08b7308077a48d5612f644943f92d5b5dade583/ladybug/datacollection.py#L1207-L1256 | def validate_analysis_period(self):
"""Get a collection where the header analysis_period aligns with datetimes.
This means that checks for three criteria will be performed:
1) All months in the data collection are chronological starting from the
analysis_period start month to the en... | [
"def",
"validate_analysis_period",
"(",
"self",
")",
":",
"a_per",
"=",
"self",
".",
"header",
".",
"analysis_period",
"n_ap",
"=",
"[",
"a_per",
".",
"st_month",
",",
"a_per",
".",
"end_month",
"]",
"# make sure that months are in chronological order.",
"sort_datet... | Get a collection where the header analysis_period aligns with datetimes.
This means that checks for three criteria will be performed:
1) All months in the data collection are chronological starting from the
analysis_period start month to the end month.
2) No duplicate months exist i... | [
"Get",
"a",
"collection",
"where",
"the",
"header",
"analysis_period",
"aligns",
"with",
"datetimes",
"."
] | python | train |
pyca/pynacl | src/nacl/bindings/crypto_secretstream.py | https://github.com/pyca/pynacl/blob/0df0c2c7693fa5d316846111ce510702756f5feb/src/nacl/bindings/crypto_secretstream.py#L117-L178 | def crypto_secretstream_xchacha20poly1305_push(
state,
m,
ad=None,
tag=crypto_secretstream_xchacha20poly1305_TAG_MESSAGE,
):
"""
Add an encrypted message to the secret stream.
:param state: a secretstream state object
:type state: crypto_secretstream_xchacha20poly1305_state
:param m... | [
"def",
"crypto_secretstream_xchacha20poly1305_push",
"(",
"state",
",",
"m",
",",
"ad",
"=",
"None",
",",
"tag",
"=",
"crypto_secretstream_xchacha20poly1305_TAG_MESSAGE",
",",
")",
":",
"ensure",
"(",
"isinstance",
"(",
"state",
",",
"crypto_secretstream_xchacha20poly13... | Add an encrypted message to the secret stream.
:param state: a secretstream state object
:type state: crypto_secretstream_xchacha20poly1305_state
:param m: the message to encrypt, the maximum length of an individual
message is
:data:`.crypto_secretstream_xchacha20poly1305_MESSAG... | [
"Add",
"an",
"encrypted",
"message",
"to",
"the",
"secret",
"stream",
"."
] | python | train |
HDI-Project/MLBlocks | mlblocks/datasets.py | https://github.com/HDI-Project/MLBlocks/blob/e1ca77bce3c4537c0800a4c1395e1b6bbde5465d/mlblocks/datasets.py#L237-L251 | def load_usps():
"""USPs Digits Dataset.
The data of this dataset is a 3d numpy array vector with shape (224, 224, 3)
containing 9298 224x224 RGB photos of handwritten digits, and the target is
a 1d numpy integer array containing the label of the digit represented in
the image.
"""
dataset_... | [
"def",
"load_usps",
"(",
")",
":",
"dataset_path",
"=",
"_load",
"(",
"'usps'",
")",
"df",
"=",
"_load_csv",
"(",
"dataset_path",
",",
"'data'",
")",
"X",
"=",
"_load_images",
"(",
"os",
".",
"path",
".",
"join",
"(",
"dataset_path",
",",
"'images'",
"... | USPs Digits Dataset.
The data of this dataset is a 3d numpy array vector with shape (224, 224, 3)
containing 9298 224x224 RGB photos of handwritten digits, and the target is
a 1d numpy integer array containing the label of the digit represented in
the image. | [
"USPs",
"Digits",
"Dataset",
"."
] | python | train |
cmheisel/basecampreporting | src/basecampreporting/basecamp.py | https://github.com/cmheisel/basecampreporting/blob/88ecfc6e835608650ff6be23cbf2421d224c122b/src/basecampreporting/basecamp.py#L239-L255 | def update_message(self, message_id, category_id, title, body,
extended_body, use_textile=False, private=False, notify=None):
"""
Updates an existing message, optionally sending notifications to a
selected list of people. Note that you can also upload files using
this function, b... | [
"def",
"update_message",
"(",
"self",
",",
"message_id",
",",
"category_id",
",",
"title",
",",
"body",
",",
"extended_body",
",",
"use_textile",
"=",
"False",
",",
"private",
"=",
"False",
",",
"notify",
"=",
"None",
")",
":",
"path",
"=",
"'/msg/update/%... | Updates an existing message, optionally sending notifications to a
selected list of people. Note that you can also upload files using
this function, but you have to format the request as
multipart/form-data. (See the ruby Basecamp API wrapper for an example
of how to do this.) | [
"Updates",
"an",
"existing",
"message",
"optionally",
"sending",
"notifications",
"to",
"a",
"selected",
"list",
"of",
"people",
".",
"Note",
"that",
"you",
"can",
"also",
"upload",
"files",
"using",
"this",
"function",
"but",
"you",
"have",
"to",
"format",
... | python | train |
trailofbits/manticore | manticore/core/smtlib/solver.py | https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/smtlib/solver.py#L383-L423 | def get_all_values(self, constraints, expression, maxcnt=None, silent=False):
"""Returns a list with all the possible values for the symbol x"""
if not isinstance(expression, Expression):
return [expression]
assert isinstance(constraints, ConstraintSet)
assert isinstance(expr... | [
"def",
"get_all_values",
"(",
"self",
",",
"constraints",
",",
"expression",
",",
"maxcnt",
"=",
"None",
",",
"silent",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"expression",
",",
"Expression",
")",
":",
"return",
"[",
"expression",
"]",
"... | Returns a list with all the possible values for the symbol x | [
"Returns",
"a",
"list",
"with",
"all",
"the",
"possible",
"values",
"for",
"the",
"symbol",
"x"
] | python | valid |
ibm-watson-iot/iot-python | src/wiotp/sdk/application/client.py | https://github.com/ibm-watson-iot/iot-python/blob/195f05adce3fba4ec997017e41e02ebd85c0c4cc/src/wiotp/sdk/application/client.py#L253-L264 | def _onDeviceStatus(self, client, userdata, pahoMessage):
"""
Internal callback for device status messages, parses source device from topic string and
passes the information on to the registerd device status callback
"""
try:
status = Status(pahoMessage)
s... | [
"def",
"_onDeviceStatus",
"(",
"self",
",",
"client",
",",
"userdata",
",",
"pahoMessage",
")",
":",
"try",
":",
"status",
"=",
"Status",
"(",
"pahoMessage",
")",
"self",
".",
"logger",
".",
"debug",
"(",
"\"Received %s action from %s\"",
"%",
"(",
"status",... | Internal callback for device status messages, parses source device from topic string and
passes the information on to the registerd device status callback | [
"Internal",
"callback",
"for",
"device",
"status",
"messages",
"parses",
"source",
"device",
"from",
"topic",
"string",
"and",
"passes",
"the",
"information",
"on",
"to",
"the",
"registerd",
"device",
"status",
"callback"
] | python | test |
QuantEcon/QuantEcon.py | quantecon/graph_tools.py | https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/graph_tools.py#L375-L410 | def random_tournament_graph(n, random_state=None):
"""
Return a random tournament graph [1]_ with n nodes.
Parameters
----------
n : scalar(int)
Number of nodes.
random_state : int or np.random.RandomState, optional
Random seed (integer) or np.random.RandomState instance to set... | [
"def",
"random_tournament_graph",
"(",
"n",
",",
"random_state",
"=",
"None",
")",
":",
"random_state",
"=",
"check_random_state",
"(",
"random_state",
")",
"num_edges",
"=",
"n",
"*",
"(",
"n",
"-",
"1",
")",
"//",
"2",
"r",
"=",
"random_state",
".",
"r... | Return a random tournament graph [1]_ with n nodes.
Parameters
----------
n : scalar(int)
Number of nodes.
random_state : int or np.random.RandomState, optional
Random seed (integer) or np.random.RandomState instance to set
the initial state of the random number generator for
... | [
"Return",
"a",
"random",
"tournament",
"graph",
"[",
"1",
"]",
"_",
"with",
"n",
"nodes",
"."
] | python | train |
UDST/urbansim | urbansim/models/dcm.py | https://github.com/UDST/urbansim/blob/79f815a6503e109f50be270cee92d0f4a34f49ef/urbansim/models/dcm.py#L962-L984 | def _iter_groups(self, data):
"""
Iterate over the groups in `data` after grouping by
`segmentation_col`. Skips any groups for which there
is no model stored.
Yields tuples of (name, df) where name is the group key
and df is the group DataFrame.
Parameters
... | [
"def",
"_iter_groups",
"(",
"self",
",",
"data",
")",
":",
"groups",
"=",
"data",
".",
"groupby",
"(",
"self",
".",
"segmentation_col",
")",
"for",
"name",
",",
"group",
"in",
"groups",
":",
"if",
"name",
"not",
"in",
"self",
".",
"models",
":",
"con... | Iterate over the groups in `data` after grouping by
`segmentation_col`. Skips any groups for which there
is no model stored.
Yields tuples of (name, df) where name is the group key
and df is the group DataFrame.
Parameters
----------
data : pandas.DataFrame
... | [
"Iterate",
"over",
"the",
"groups",
"in",
"data",
"after",
"grouping",
"by",
"segmentation_col",
".",
"Skips",
"any",
"groups",
"for",
"which",
"there",
"is",
"no",
"model",
"stored",
"."
] | python | train |
fracpete/python-weka-wrapper3 | python/weka/flow/sink.py | https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/sink.py#L240-L257 | def fix_config(self, options):
"""
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary.
:param options: the options to fix
:type options: dict
:return: the (potentially) fixed options
:rtype: dict
"""
options = super(Dum... | [
"def",
"fix_config",
"(",
"self",
",",
"options",
")",
":",
"options",
"=",
"super",
"(",
"DumpFile",
",",
"self",
")",
".",
"fix_config",
"(",
"options",
")",
"opt",
"=",
"\"append\"",
"if",
"opt",
"not",
"in",
"options",
":",
"options",
"[",
"opt",
... | Fixes the options, if necessary. I.e., it adds all required elements to the dictionary.
:param options: the options to fix
:type options: dict
:return: the (potentially) fixed options
:rtype: dict | [
"Fixes",
"the",
"options",
"if",
"necessary",
".",
"I",
".",
"e",
".",
"it",
"adds",
"all",
"required",
"elements",
"to",
"the",
"dictionary",
"."
] | python | train |
emilydolson/avida-spatial-tools | avidaspatial/transform_data.py | https://github.com/emilydolson/avida-spatial-tools/blob/7beb0166ccefad5fa722215b030ac2a53d62b59e/avidaspatial/transform_data.py#L251-L277 | def make_optimal_phenotype_grid(environment, phenotypes):
"""
Takes an EnvironmentFile object and a 2d array of phenotypes and returns
a 2d array in which each location contains an index representing the
distance between the phenotype in that location and the optimal phenotype
for that location.
... | [
"def",
"make_optimal_phenotype_grid",
"(",
"environment",
",",
"phenotypes",
")",
":",
"world_size",
"=",
"environment",
".",
"size",
"phenotypes",
"=",
"deepcopy",
"(",
"phenotypes",
")",
"for",
"i",
"in",
"range",
"(",
"world_size",
"[",
"1",
"]",
")",
":"... | Takes an EnvironmentFile object and a 2d array of phenotypes and returns
a 2d array in which each location contains an index representing the
distance between the phenotype in that location and the optimal phenotype
for that location.
This is acheived by using the task list in the EnvironmentFile to co... | [
"Takes",
"an",
"EnvironmentFile",
"object",
"and",
"a",
"2d",
"array",
"of",
"phenotypes",
"and",
"returns",
"a",
"2d",
"array",
"in",
"which",
"each",
"location",
"contains",
"an",
"index",
"representing",
"the",
"distance",
"between",
"the",
"phenotype",
"in... | python | train |
python-openxml/python-docx | docx/opc/pkgwriter.py | https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/pkgwriter.py#L100-L109 | def _add_content_type(self, partname, content_type):
"""
Add a content type for the part with *partname* and *content_type*,
using a default or override as appropriate.
"""
ext = partname.ext
if (ext.lower(), content_type) in default_content_types:
self._defau... | [
"def",
"_add_content_type",
"(",
"self",
",",
"partname",
",",
"content_type",
")",
":",
"ext",
"=",
"partname",
".",
"ext",
"if",
"(",
"ext",
".",
"lower",
"(",
")",
",",
"content_type",
")",
"in",
"default_content_types",
":",
"self",
".",
"_defaults",
... | Add a content type for the part with *partname* and *content_type*,
using a default or override as appropriate. | [
"Add",
"a",
"content",
"type",
"for",
"the",
"part",
"with",
"*",
"partname",
"*",
"and",
"*",
"content_type",
"*",
"using",
"a",
"default",
"or",
"override",
"as",
"appropriate",
"."
] | python | train |
OnroerendErfgoed/crabpy | crabpy/gateway/capakey.py | https://github.com/OnroerendErfgoed/crabpy/blob/3a6fd8bc5aca37c2a173e3ea94e4e468b8aa79c1/crabpy/gateway/capakey.py#L135-L164 | def get_gemeente_by_id(self, id):
'''
Retrieve a `gemeente` by id (the NIScode).
:rtype: :class:`Gemeente`
'''
def creator():
url = self.base_url + '/municipality/%s' % id
h = self.base_headers
p = {
'geometry': 'full',
... | [
"def",
"get_gemeente_by_id",
"(",
"self",
",",
"id",
")",
":",
"def",
"creator",
"(",
")",
":",
"url",
"=",
"self",
".",
"base_url",
"+",
"'/municipality/%s'",
"%",
"id",
"h",
"=",
"self",
".",
"base_headers",
"p",
"=",
"{",
"'geometry'",
":",
"'full'"... | Retrieve a `gemeente` by id (the NIScode).
:rtype: :class:`Gemeente` | [
"Retrieve",
"a",
"gemeente",
"by",
"id",
"(",
"the",
"NIScode",
")",
"."
] | python | train |
saltstack/salt | salt/modules/proxy.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/proxy.py#L306-L352 | def set_ftp_proxy(server,
port,
user=None,
password=None,
network_service="Ethernet",
bypass_hosts=None):
'''
Sets the ftp proxy settings
server
The proxy server to use
port
The port used by the p... | [
"def",
"set_ftp_proxy",
"(",
"server",
",",
"port",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
",",
"network_service",
"=",
"\"Ethernet\"",
",",
"bypass_hosts",
"=",
"None",
")",
":",
"if",
"__grains__",
"[",
"'os'",
"]",
"==",
"'Windows'",
... | Sets the ftp proxy settings
server
The proxy server to use
port
The port used by the proxy server
user
The username to use for the proxy server if required
password
The password to use if required by the server
network_service
The network service to apply... | [
"Sets",
"the",
"ftp",
"proxy",
"settings"
] | python | train |
jtwhite79/pyemu | pyemu/mc.py | https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/mc.py#L93-L121 | def get_null_proj(self,nsing=None):
""" get a null-space projection matrix of XTQX
Parameters
----------
nsing: int
optional number of singular components to use
If Nonte, then nsing is determined from
call to MonteCarlo.get_nsing()
R... | [
"def",
"get_null_proj",
"(",
"self",
",",
"nsing",
"=",
"None",
")",
":",
"if",
"nsing",
"is",
"None",
":",
"nsing",
"=",
"self",
".",
"get_nsing",
"(",
")",
"if",
"nsing",
"is",
"None",
":",
"raise",
"Exception",
"(",
"\"nsing is None\"",
")",
"print"... | get a null-space projection matrix of XTQX
Parameters
----------
nsing: int
optional number of singular components to use
If Nonte, then nsing is determined from
call to MonteCarlo.get_nsing()
Returns
-------
v2_proj : pyemu.M... | [
"get",
"a",
"null",
"-",
"space",
"projection",
"matrix",
"of",
"XTQX"
] | python | train |
sassoftware/saspy | saspy/sasdata.py | https://github.com/sassoftware/saspy/blob/e433f71990f249d3a6c3db323ceb11cb2d462cf9/saspy/sasdata.py#L929-L966 | def score(self, file: str = '', code: str = '', out: 'SASdata' = None) -> 'SASdata':
"""
This method is meant to update a SAS Data object with a model score file.
:param file: a file reference to the SAS score code
:param code: a string of the valid SAS score code
:param out: Wh... | [
"def",
"score",
"(",
"self",
",",
"file",
":",
"str",
"=",
"''",
",",
"code",
":",
"str",
"=",
"''",
",",
"out",
":",
"'SASdata'",
"=",
"None",
")",
"->",
"'SASdata'",
":",
"if",
"out",
"is",
"not",
"None",
":",
"outTable",
"=",
"out",
".",
"ta... | This method is meant to update a SAS Data object with a model score file.
:param file: a file reference to the SAS score code
:param code: a string of the valid SAS score code
:param out: Where to the write the file. Defaults to update in place
:return: The Scored SAS Data object. | [
"This",
"method",
"is",
"meant",
"to",
"update",
"a",
"SAS",
"Data",
"object",
"with",
"a",
"model",
"score",
"file",
"."
] | python | train |
denisenkom/pytds | src/pytds/__init__.py | https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/__init__.py#L421-L455 | def cursor(self):
"""
Return cursor object that can be used to make queries and fetch
results from the database.
"""
self._assert_open()
if self.mars_enabled:
in_tran = self._conn.tds72_transaction
if in_tran and self._dirty:
try:
... | [
"def",
"cursor",
"(",
"self",
")",
":",
"self",
".",
"_assert_open",
"(",
")",
"if",
"self",
".",
"mars_enabled",
":",
"in_tran",
"=",
"self",
".",
"_conn",
".",
"tds72_transaction",
"if",
"in_tran",
"and",
"self",
".",
"_dirty",
":",
"try",
":",
"retu... | Return cursor object that can be used to make queries and fetch
results from the database. | [
"Return",
"cursor",
"object",
"that",
"can",
"be",
"used",
"to",
"make",
"queries",
"and",
"fetch",
"results",
"from",
"the",
"database",
"."
] | python | train |
miku/gluish | examples/newspapers.py | https://github.com/miku/gluish/blob/56d3ac4f41a944e31ecac0aa3b6d1dc2ce705e29/examples/newspapers.py#L67-L70 | def run(self):
""" Just run wget quietly. """
output = shellout('wget -q "{url}" -O {output}', url=self.url)
luigi.LocalTarget(output).move(self.output().path) | [
"def",
"run",
"(",
"self",
")",
":",
"output",
"=",
"shellout",
"(",
"'wget -q \"{url}\" -O {output}'",
",",
"url",
"=",
"self",
".",
"url",
")",
"luigi",
".",
"LocalTarget",
"(",
"output",
")",
".",
"move",
"(",
"self",
".",
"output",
"(",
")",
".",
... | Just run wget quietly. | [
"Just",
"run",
"wget",
"quietly",
"."
] | python | train |
nilp0inter/cpe | cpe/cpelang2_3.py | https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/cpelang2_3.py#L81-L114 | def _check_fact_ref_eval(cls, cpel_dom):
"""
Returns the result (True, False, Error) of performing the specified
check, unless the check isnt supported, in which case it returns
False. Error is a catch-all for all results other than True and
False.
:param string cpel_do... | [
"def",
"_check_fact_ref_eval",
"(",
"cls",
",",
"cpel_dom",
")",
":",
"CHECK_SYSTEM",
"=",
"\"check-system\"",
"CHECK_LOCATION",
"=",
"\"check-location\"",
"CHECK_ID",
"=",
"\"check-id\"",
"checksystemID",
"=",
"cpel_dom",
".",
"getAttribute",
"(",
"CHECK_SYSTEM",
")"... | Returns the result (True, False, Error) of performing the specified
check, unless the check isnt supported, in which case it returns
False. Error is a catch-all for all results other than True and
False.
:param string cpel_dom: XML infoset for the check_fact_ref element.
:retur... | [
"Returns",
"the",
"result",
"(",
"True",
"False",
"Error",
")",
"of",
"performing",
"the",
"specified",
"check",
"unless",
"the",
"check",
"isnt",
"supported",
"in",
"which",
"case",
"it",
"returns",
"False",
".",
"Error",
"is",
"a",
"catch",
"-",
"all",
... | python | train |
zaturox/glin | glin/zmq/messages.py | https://github.com/zaturox/glin/blob/55214a579c4e4b4d74765f3f6aa2eb815bac1c3b/glin/zmq/messages.py#L19-L21 | def animation_add(sequence_number, animation_id, name):
"""Create a animation.add message"""
return MessageWriter().string("animation.add").uint64(sequence_number).uint32(animation_id).string(name).get() | [
"def",
"animation_add",
"(",
"sequence_number",
",",
"animation_id",
",",
"name",
")",
":",
"return",
"MessageWriter",
"(",
")",
".",
"string",
"(",
"\"animation.add\"",
")",
".",
"uint64",
"(",
"sequence_number",
")",
".",
"uint32",
"(",
"animation_id",
")",
... | Create a animation.add message | [
"Create",
"a",
"animation",
".",
"add",
"message"
] | python | train |
slarse/clanimtk | clanimtk/core.py | https://github.com/slarse/clanimtk/blob/cb93d2e914c3ecc4e0007745ff4d546318cf3902/clanimtk/core.py#L61-L77 | def _raise_if_annotated(self, func):
"""Raise TypeError if a function is decorated with Annotate, as such
functions cause visual bugs when decorated with Animate.
Animate should be wrapped by Annotate instead.
Args:
func (function): Any callable.
Raises:
... | [
"def",
"_raise_if_annotated",
"(",
"self",
",",
"func",
")",
":",
"if",
"hasattr",
"(",
"func",
",",
"ANNOTATED",
")",
"and",
"getattr",
"(",
"func",
",",
"ANNOTATED",
")",
":",
"msg",
"=",
"(",
"'Functions decorated with {!r} '",
"'should not be decorated with ... | Raise TypeError if a function is decorated with Annotate, as such
functions cause visual bugs when decorated with Animate.
Animate should be wrapped by Annotate instead.
Args:
func (function): Any callable.
Raises:
TypeError | [
"Raise",
"TypeError",
"if",
"a",
"function",
"is",
"decorated",
"with",
"Annotate",
"as",
"such",
"functions",
"cause",
"visual",
"bugs",
"when",
"decorated",
"with",
"Animate",
"."
] | python | train |
hyperledger/sawtooth-core | validator/sawtooth_validator/journal/consensus/batch_publisher.py | https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/consensus/batch_publisher.py#L38-L56 | def send(self, transactions):
""" Package up transactions into a batch and send them to the
network via the provided batch_sender.
:param transactions: list of transactions to package and broadcast.
:return: None
"""
txn_signatures = [txn.header_signature for txn in trans... | [
"def",
"send",
"(",
"self",
",",
"transactions",
")",
":",
"txn_signatures",
"=",
"[",
"txn",
".",
"header_signature",
"for",
"txn",
"in",
"transactions",
"]",
"header",
"=",
"BatchHeader",
"(",
"signer_public_key",
"=",
"self",
".",
"_identity_signer",
".",
... | Package up transactions into a batch and send them to the
network via the provided batch_sender.
:param transactions: list of transactions to package and broadcast.
:return: None | [
"Package",
"up",
"transactions",
"into",
"a",
"batch",
"and",
"send",
"them",
"to",
"the",
"network",
"via",
"the",
"provided",
"batch_sender",
".",
":",
"param",
"transactions",
":",
"list",
"of",
"transactions",
"to",
"package",
"and",
"broadcast",
".",
":... | python | train |
RudolfCardinal/pythonlib | cardinal_pythonlib/sizeformatter.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/sizeformatter.py#L52-L113 | def bytes2human(n: Union[int, float],
format: str = '%(value).1f %(symbol)s',
symbols: str = 'customary') -> str:
"""
Converts a number of bytes into a human-readable format.
From http://code.activestate.com/recipes/578019-bytes-to-human-human-to-bytes-converter/.
Ar... | [
"def",
"bytes2human",
"(",
"n",
":",
"Union",
"[",
"int",
",",
"float",
"]",
",",
"format",
":",
"str",
"=",
"'%(value).1f %(symbol)s'",
",",
"symbols",
":",
"str",
"=",
"'customary'",
")",
"->",
"str",
":",
"# noqa",
"n",
"=",
"int",
"(",
"n",
")",
... | Converts a number of bytes into a human-readable format.
From http://code.activestate.com/recipes/578019-bytes-to-human-human-to-bytes-converter/.
Args:
n: number of bytes
format: a format specification string
symbols: can be one of ``"customary"``, ``"customary_ext"``, ``"iec"``
... | [
"Converts",
"a",
"number",
"of",
"bytes",
"into",
"a",
"human",
"-",
"readable",
"format",
".",
"From",
"http",
":",
"//",
"code",
".",
"activestate",
".",
"com",
"/",
"recipes",
"/",
"578019",
"-",
"bytes",
"-",
"to",
"-",
"human",
"-",
"human",
"-"... | python | train |
dmlc/xgboost | python-package/xgboost/sklearn.py | https://github.com/dmlc/xgboost/blob/253fdd8a42d5ec6b819788199584d27bf9ea6253/python-package/xgboost/sklearn.py#L282-L300 | def load_model(self, fname):
"""
Load the model from a file.
The model is loaded from an XGBoost internal binary format which is
universal among the various XGBoost interfaces. Auxiliary attributes of
the Python Booster object (such as feature names) will not be loaded.
... | [
"def",
"load_model",
"(",
"self",
",",
"fname",
")",
":",
"if",
"self",
".",
"_Booster",
"is",
"None",
":",
"self",
".",
"_Booster",
"=",
"Booster",
"(",
"{",
"'nthread'",
":",
"self",
".",
"n_jobs",
"}",
")",
"self",
".",
"_Booster",
".",
"load_mode... | Load the model from a file.
The model is loaded from an XGBoost internal binary format which is
universal among the various XGBoost interfaces. Auxiliary attributes of
the Python Booster object (such as feature names) will not be loaded.
Label encodings (text labels to numeric labels) w... | [
"Load",
"the",
"model",
"from",
"a",
"file",
"."
] | python | train |
aparo/pyes | pyes/es.py | https://github.com/aparo/pyes/blob/712eb6095961755067b2b5baa262008ade6584b3/pyes/es.py#L931-L936 | def exists(self, index, doc_type, id, **query_params):
"""
Return if a document exists
"""
path = make_path(index, doc_type, id)
return self._send_request('HEAD', path, params=query_params) | [
"def",
"exists",
"(",
"self",
",",
"index",
",",
"doc_type",
",",
"id",
",",
"*",
"*",
"query_params",
")",
":",
"path",
"=",
"make_path",
"(",
"index",
",",
"doc_type",
",",
"id",
")",
"return",
"self",
".",
"_send_request",
"(",
"'HEAD'",
",",
"pat... | Return if a document exists | [
"Return",
"if",
"a",
"document",
"exists"
] | python | train |
wandb/client | wandb/vendor/prompt_toolkit/interface.py | https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/vendor/prompt_toolkit/interface.py#L363-L373 | def _on_resize(self):
"""
When the window size changes, we erase the current output and request
again the cursor position. When the CPR answer arrives, the output is
drawn again.
"""
# Erase, request position (when cursor is at the start position)
# and redraw aga... | [
"def",
"_on_resize",
"(",
"self",
")",
":",
"# Erase, request position (when cursor is at the start position)",
"# and redraw again. -- The order is important.",
"self",
".",
"renderer",
".",
"erase",
"(",
"leave_alternate_screen",
"=",
"False",
",",
"erase_title",
"=",
"Fals... | When the window size changes, we erase the current output and request
again the cursor position. When the CPR answer arrives, the output is
drawn again. | [
"When",
"the",
"window",
"size",
"changes",
"we",
"erase",
"the",
"current",
"output",
"and",
"request",
"again",
"the",
"cursor",
"position",
".",
"When",
"the",
"CPR",
"answer",
"arrives",
"the",
"output",
"is",
"drawn",
"again",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.