repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
mojaie/chorus | chorus/draw/helper.py | format_ring_double_bond | def format_ring_double_bond(mol):
"""Set double bonds around the ring.
"""
mol.require("Topology")
mol.require("ScaleAndCenter")
for r in sorted(mol.rings, key=len, reverse=True):
vertices = [mol.atom(n).coords for n in r]
try:
if geometry.is_clockwise(vertices):
... | python | def format_ring_double_bond(mol):
"""Set double bonds around the ring.
"""
mol.require("Topology")
mol.require("ScaleAndCenter")
for r in sorted(mol.rings, key=len, reverse=True):
vertices = [mol.atom(n).coords for n in r]
try:
if geometry.is_clockwise(vertices):
... | [
"def",
"format_ring_double_bond",
"(",
"mol",
")",
":",
"mol",
".",
"require",
"(",
"\"Topology\"",
")",
"mol",
".",
"require",
"(",
"\"ScaleAndCenter\"",
")",
"for",
"r",
"in",
"sorted",
"(",
"mol",
".",
"rings",
",",
"key",
"=",
"len",
",",
"reverse",
... | Set double bonds around the ring. | [
"Set",
"double",
"bonds",
"around",
"the",
"ring",
"."
] | fc7fe23a0272554c67671645ab07830b315eeb1b | https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/draw/helper.py#L46-L64 | train | Set double bonds around the ring. |
mojaie/chorus | chorus/draw/helper.py | scale_and_center | def scale_and_center(mol):
"""Center and Scale molecule 2D coordinates.
This method changes mol coordinates directly to center but not scale.
This method returns width, height and MLB(median length of bond)
and scaling will be done by drawer method with these values.
Returns:
width: float
... | python | def scale_and_center(mol):
"""Center and Scale molecule 2D coordinates.
This method changes mol coordinates directly to center but not scale.
This method returns width, height and MLB(median length of bond)
and scaling will be done by drawer method with these values.
Returns:
width: float
... | [
"def",
"scale_and_center",
"(",
"mol",
")",
":",
"cnt",
"=",
"mol",
".",
"atom_count",
"(",
")",
"if",
"cnt",
"<",
"2",
":",
"mol",
".",
"size2d",
"=",
"(",
"0",
",",
"0",
",",
"1",
")",
"mol",
".",
"descriptors",
".",
"add",
"(",
"\"ScaleAndCent... | Center and Scale molecule 2D coordinates.
This method changes mol coordinates directly to center but not scale.
This method returns width, height and MLB(median length of bond)
and scaling will be done by drawer method with these values.
Returns:
width: float
height: float
mlb: ... | [
"Center",
"and",
"Scale",
"molecule",
"2D",
"coordinates",
".",
"This",
"method",
"changes",
"mol",
"coordinates",
"directly",
"to",
"center",
"but",
"not",
"scale",
".",
"This",
"method",
"returns",
"width",
"height",
"and",
"MLB",
"(",
"median",
"length",
... | fc7fe23a0272554c67671645ab07830b315eeb1b | https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/draw/helper.py#L67-L110 | train | Center and Scale molecule 2D coordinates. |
mojaie/chorus | chorus/draw/helper.py | ready_to_draw | def ready_to_draw(mol):
"""Shortcut function to prepare molecule to draw.
Overwrite this function for customized appearance.
It is recommended to clone the molecule before draw
because all the methods above are destructive.
"""
copied = molutil.clone(mol)
# display_terminal_carbon(mol)
e... | python | def ready_to_draw(mol):
"""Shortcut function to prepare molecule to draw.
Overwrite this function for customized appearance.
It is recommended to clone the molecule before draw
because all the methods above are destructive.
"""
copied = molutil.clone(mol)
# display_terminal_carbon(mol)
e... | [
"def",
"ready_to_draw",
"(",
"mol",
")",
":",
"copied",
"=",
"molutil",
".",
"clone",
"(",
"mol",
")",
"# display_terminal_carbon(mol)",
"equalize_terminal_double_bond",
"(",
"copied",
")",
"# spine_to_terminal_wedge(copied)",
"scale_and_center",
"(",
"copied",
")",
"... | Shortcut function to prepare molecule to draw.
Overwrite this function for customized appearance.
It is recommended to clone the molecule before draw
because all the methods above are destructive. | [
"Shortcut",
"function",
"to",
"prepare",
"molecule",
"to",
"draw",
".",
"Overwrite",
"this",
"function",
"for",
"customized",
"appearance",
".",
"It",
"is",
"recommended",
"to",
"clone",
"the",
"molecule",
"before",
"draw",
"because",
"all",
"the",
"methods",
... | fc7fe23a0272554c67671645ab07830b315eeb1b | https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/draw/helper.py#L113-L125 | train | Shortcut function to prepare molecule to draw. |
adblair/configloader | configloader/__init__.py | ConfigLoader.update_from_object | def update_from_object(self, obj, criterion=lambda key: key.isupper()):
"""
Update dict from the attributes of a module, class or other object.
By default only attributes with all-uppercase names will be retrieved.
Use the ``criterion`` argument to modify that behaviour.
:arg o... | python | def update_from_object(self, obj, criterion=lambda key: key.isupper()):
"""
Update dict from the attributes of a module, class or other object.
By default only attributes with all-uppercase names will be retrieved.
Use the ``criterion`` argument to modify that behaviour.
:arg o... | [
"def",
"update_from_object",
"(",
"self",
",",
"obj",
",",
"criterion",
"=",
"lambda",
"key",
":",
"key",
".",
"isupper",
"(",
")",
")",
":",
"log",
".",
"debug",
"(",
"'Loading config from {0}'",
".",
"format",
"(",
"obj",
")",
")",
"if",
"isinstance",
... | Update dict from the attributes of a module, class or other object.
By default only attributes with all-uppercase names will be retrieved.
Use the ``criterion`` argument to modify that behaviour.
:arg obj: Either the actual module/object, or its absolute name, e.g.
'my_app.settings... | [
"Update",
"dict",
"from",
"the",
"attributes",
"of",
"a",
"module",
"class",
"or",
"other",
"object",
"."
] | c56eb568a376243400bb72992ca927c35922c827 | https://github.com/adblair/configloader/blob/c56eb568a376243400bb72992ca927c35922c827/configloader/__init__.py#L46-L73 | train | Update the dict with the contents of the object obj. |
adblair/configloader | configloader/__init__.py | ConfigLoader.update_from_env_namespace | def update_from_env_namespace(self, namespace):
"""
Update dict from any environment variables that have a given prefix.
The common prefix is removed when converting the variable names to
dictionary keys. For example, if the following environment variables
were set::
... | python | def update_from_env_namespace(self, namespace):
"""
Update dict from any environment variables that have a given prefix.
The common prefix is removed when converting the variable names to
dictionary keys. For example, if the following environment variables
were set::
... | [
"def",
"update_from_env_namespace",
"(",
"self",
",",
"namespace",
")",
":",
"self",
".",
"update",
"(",
"ConfigLoader",
"(",
"os",
".",
"environ",
")",
".",
"namespace",
"(",
"namespace",
")",
")"
] | Update dict from any environment variables that have a given prefix.
The common prefix is removed when converting the variable names to
dictionary keys. For example, if the following environment variables
were set::
MY_APP_SETTING1=foo
MY_APP_SETTING2=bar
Then ... | [
"Update",
"dict",
"from",
"any",
"environment",
"variables",
"that",
"have",
"a",
"given",
"prefix",
"."
] | c56eb568a376243400bb72992ca927c35922c827 | https://github.com/adblair/configloader/blob/c56eb568a376243400bb72992ca927c35922c827/configloader/__init__.py#L119-L137 | train | Update the dictionary with the values from any environment variables that have a given prefix. |
adblair/configloader | configloader/__init__.py | ConfigLoader.update_from | def update_from(
self,
obj=None,
yaml_env=None,
yaml_file=None,
json_env=None,
json_file=None,
env_namespace=None,
):
"""
Update dict from several sources at once.
This is simply a convenience method... | python | def update_from(
self,
obj=None,
yaml_env=None,
yaml_file=None,
json_env=None,
json_file=None,
env_namespace=None,
):
"""
Update dict from several sources at once.
This is simply a convenience method... | [
"def",
"update_from",
"(",
"self",
",",
"obj",
"=",
"None",
",",
"yaml_env",
"=",
"None",
",",
"yaml_file",
"=",
"None",
",",
"json_env",
"=",
"None",
",",
"json_file",
"=",
"None",
",",
"env_namespace",
"=",
"None",
",",
")",
":",
"if",
"obj",
":",
... | Update dict from several sources at once.
This is simply a convenience method that can be used as an alternative
to making several calls to the various
:meth:`~ConfigLoader.update_from_*` methods.
Updates will be applied in the order that the parameters are listed
below, with e... | [
"Update",
"dict",
"from",
"several",
"sources",
"at",
"once",
"."
] | c56eb568a376243400bb72992ca927c35922c827 | https://github.com/adblair/configloader/blob/c56eb568a376243400bb72992ca927c35922c827/configloader/__init__.py#L139-L179 | train | Updates the internal dictionary with the values from the specified sources. |
adblair/configloader | configloader/__init__.py | ConfigLoader.namespace | def namespace(self, namespace, key_transform=lambda key: key):
"""
Return a copy with only the keys from a given namespace.
The common prefix will be removed in the returned dict. Example::
>>> from configloader import ConfigLoader
>>> config = ConfigLoader(
... | python | def namespace(self, namespace, key_transform=lambda key: key):
"""
Return a copy with only the keys from a given namespace.
The common prefix will be removed in the returned dict. Example::
>>> from configloader import ConfigLoader
>>> config = ConfigLoader(
... | [
"def",
"namespace",
"(",
"self",
",",
"namespace",
",",
"key_transform",
"=",
"lambda",
"key",
":",
"key",
")",
":",
"namespace",
"=",
"namespace",
".",
"rstrip",
"(",
"'_'",
")",
"+",
"'_'",
"return",
"ConfigLoader",
"(",
"(",
"key_transform",
"(",
"key... | Return a copy with only the keys from a given namespace.
The common prefix will be removed in the returned dict. Example::
>>> from configloader import ConfigLoader
>>> config = ConfigLoader(
... MY_APP_SETTING1='a',
... EXTERNAL_LIB_SETTING1='b',
... | [
"Return",
"a",
"copy",
"with",
"only",
"the",
"keys",
"from",
"a",
"given",
"namespace",
"."
] | c56eb568a376243400bb72992ca927c35922c827 | https://github.com/adblair/configloader/blob/c56eb568a376243400bb72992ca927c35922c827/configloader/__init__.py#L181-L208 | train | Return a copy of the config dictionary with only the keys from a given namespace. |
adblair/configloader | configloader/__init__.py | ConfigLoader.namespace_lower | def namespace_lower(self, namespace):
"""
Return a copy with only the keys from a given namespace, lower-cased.
The keys in the returned dict will be transformed to lower case after
filtering, so they can be easily passed as keyword arguments to other
functions. This is just syn... | python | def namespace_lower(self, namespace):
"""
Return a copy with only the keys from a given namespace, lower-cased.
The keys in the returned dict will be transformed to lower case after
filtering, so they can be easily passed as keyword arguments to other
functions. This is just syn... | [
"def",
"namespace_lower",
"(",
"self",
",",
"namespace",
")",
":",
"return",
"self",
".",
"namespace",
"(",
"namespace",
",",
"key_transform",
"=",
"lambda",
"key",
":",
"key",
".",
"lower",
"(",
")",
")"
] | Return a copy with only the keys from a given namespace, lower-cased.
The keys in the returned dict will be transformed to lower case after
filtering, so they can be easily passed as keyword arguments to other
functions. This is just syntactic sugar for calling
:meth:`~ConfigLoader.name... | [
"Return",
"a",
"copy",
"with",
"only",
"the",
"keys",
"from",
"a",
"given",
"namespace",
"lower",
"-",
"cased",
"."
] | c56eb568a376243400bb72992ca927c35922c827 | https://github.com/adblair/configloader/blob/c56eb568a376243400bb72992ca927c35922c827/configloader/__init__.py#L210-L236 | train | Return a copy with only the keys from a given namespace lower - cased. |
redhat-cip/python-dciclient | dciclient/v1/shell_commands/user.py | list | def list(context, sort, limit, offset, where, verbose):
"""list(context, sort, limit, offset, where, verbose)
List all users.
>>> dcictl user-list
:param string sort: Field to apply sort
:param integer limit: Max number of rows to return
:param integer offset: Offset associated with the limit... | python | def list(context, sort, limit, offset, where, verbose):
"""list(context, sort, limit, offset, where, verbose)
List all users.
>>> dcictl user-list
:param string sort: Field to apply sort
:param integer limit: Max number of rows to return
:param integer offset: Offset associated with the limit... | [
"def",
"list",
"(",
"context",
",",
"sort",
",",
"limit",
",",
"offset",
",",
"where",
",",
"verbose",
")",
":",
"result",
"=",
"user",
".",
"list",
"(",
"context",
",",
"sort",
"=",
"sort",
",",
"limit",
"=",
"limit",
",",
"offset",
"=",
"offset",... | list(context, sort, limit, offset, where, verbose)
List all users.
>>> dcictl user-list
:param string sort: Field to apply sort
:param integer limit: Max number of rows to return
:param integer offset: Offset associated with the limit
:param string where: An optional filter criteria
:para... | [
"list",
"(",
"context",
"sort",
"limit",
"offset",
"where",
"verbose",
")"
] | a4aa5899062802bbe4c30a075d8447f8d222d214 | https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/user.py#L35-L55 | train | list - List all users in the system |
redhat-cip/python-dciclient | dciclient/v1/shell_commands/user.py | create | def create(context, name, password, team_id, active, email, fullname):
"""create(context, name, password, team_id, active, email, fullname)
Create a user.
>>> dcictl user-create [OPTIONS]
:param string name: Name of the user [required]
:param string password: Password for the user [required]
... | python | def create(context, name, password, team_id, active, email, fullname):
"""create(context, name, password, team_id, active, email, fullname)
Create a user.
>>> dcictl user-create [OPTIONS]
:param string name: Name of the user [required]
:param string password: Password for the user [required]
... | [
"def",
"create",
"(",
"context",
",",
"name",
",",
"password",
",",
"team_id",
",",
"active",
",",
"email",
",",
"fullname",
")",
":",
"team_id",
"=",
"team_id",
"or",
"identity",
".",
"my_team_id",
"(",
"context",
")",
"fullname",
"=",
"fullname",
"or",... | create(context, name, password, team_id, active, email, fullname)
Create a user.
>>> dcictl user-create [OPTIONS]
:param string name: Name of the user [required]
:param string password: Password for the user [required]
:param string email: Email of the user [required]
:param string fullname: ... | [
"create",
"(",
"context",
"name",
"password",
"team_id",
"active",
"email",
"fullname",
")"
] | a4aa5899062802bbe4c30a075d8447f8d222d214 | https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/user.py#L66-L85 | train | Create a user in the nova user list |
redhat-cip/python-dciclient | dciclient/v1/shell_commands/user.py | update | def update(context, id, etag, name, password, email, fullname,
team_id, active):
"""update(context, id, etag, name, password, email, fullname, team_id,
active)
Update a user.
>>> dcictl user-update [OPTIONS]
:param string id: ID of the user to update [required]
:param str... | python | def update(context, id, etag, name, password, email, fullname,
team_id, active):
"""update(context, id, etag, name, password, email, fullname, team_id,
active)
Update a user.
>>> dcictl user-update [OPTIONS]
:param string id: ID of the user to update [required]
:param str... | [
"def",
"update",
"(",
"context",
",",
"id",
",",
"etag",
",",
"name",
",",
"password",
",",
"email",
",",
"fullname",
",",
"team_id",
",",
"active",
")",
":",
"result",
"=",
"user",
".",
"update",
"(",
"context",
",",
"id",
"=",
"id",
",",
"etag",
... | update(context, id, etag, name, password, email, fullname, team_id,
active)
Update a user.
>>> dcictl user-update [OPTIONS]
:param string id: ID of the user to update [required]
:param string etag: Entity tag of the user resource [required]
:param string name: Name of the user
:... | [
"update",
"(",
"context",
"id",
"etag",
"name",
"password",
"email",
"fullname",
"team_id",
"active",
")"
] | a4aa5899062802bbe4c30a075d8447f8d222d214 | https://github.com/redhat-cip/python-dciclient/blob/a4aa5899062802bbe4c30a075d8447f8d222d214/dciclient/v1/shell_commands/user.py#L98-L121 | train | Update a user in a node. |
ehansis/ozelot | ozelot/etl/util.py | render_diagram | def render_diagram(root_task, out_base, max_param_len=20, horizontal=False, colored=False):
"""Render a diagram of the ETL pipeline
All upstream tasks (i.e. requirements) of :attr:`root_task` are rendered.
Nodes are, by default, styled as simple rects. This style is augmented by any
:attr:`diagram_sty... | python | def render_diagram(root_task, out_base, max_param_len=20, horizontal=False, colored=False):
"""Render a diagram of the ETL pipeline
All upstream tasks (i.e. requirements) of :attr:`root_task` are rendered.
Nodes are, by default, styled as simple rects. This style is augmented by any
:attr:`diagram_sty... | [
"def",
"render_diagram",
"(",
"root_task",
",",
"out_base",
",",
"max_param_len",
"=",
"20",
",",
"horizontal",
"=",
"False",
",",
"colored",
"=",
"False",
")",
":",
"import",
"re",
"import",
"codecs",
"import",
"subprocess",
"from",
"ozelot",
"import",
"con... | Render a diagram of the ETL pipeline
All upstream tasks (i.e. requirements) of :attr:`root_task` are rendered.
Nodes are, by default, styled as simple rects. This style is augmented by any
:attr:`diagram_style` attributes of the tasks.
.. note:: This function requires the 'dot' executable from the Gr... | [
"Render",
"a",
"diagram",
"of",
"the",
"ETL",
"pipeline"
] | 948675e02eb6fca940450f5cb814f53e97159e5b | https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/util.py#L12-L127 | train | Render a diagram of the ETL pipeline. |
ehansis/ozelot | ozelot/etl/util.py | sanitize | def sanitize(s,
normalize_whitespace=True,
normalize_unicode=True,
form='NFKC',
enforce_encoding=True,
encoding='utf-8'):
"""Normalize a string
Args:
s (unicode string): input unicode string
normalize_whitespace (bool): if True, n... | python | def sanitize(s,
normalize_whitespace=True,
normalize_unicode=True,
form='NFKC',
enforce_encoding=True,
encoding='utf-8'):
"""Normalize a string
Args:
s (unicode string): input unicode string
normalize_whitespace (bool): if True, n... | [
"def",
"sanitize",
"(",
"s",
",",
"normalize_whitespace",
"=",
"True",
",",
"normalize_unicode",
"=",
"True",
",",
"form",
"=",
"'NFKC'",
",",
"enforce_encoding",
"=",
"True",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"if",
"enforce_encoding",
":",
"s",
"... | Normalize a string
Args:
s (unicode string): input unicode string
normalize_whitespace (bool): if True, normalize all whitespace to single spaces (including newlines),
strip whitespace at start/end
normalize_unicode (bool): if True, normalize unicode for... | [
"Normalize",
"a",
"string"
] | 948675e02eb6fca940450f5cb814f53e97159e5b | https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/ozelot/etl/util.py#L130-L161 | train | Normalize a string containing a unicode string containing only whitespace and unicode characters. |
potash/drain | drain/serialize.py | load | def load(filename):
"""
Load step from yaml file
Args:
filename: a target or step.yaml filename
"""
yaml_filename = os.path.join(os.path.dirname(filename), 'step.yaml')
with open(yaml_filename) as f:
return yaml.load(f) | python | def load(filename):
"""
Load step from yaml file
Args:
filename: a target or step.yaml filename
"""
yaml_filename = os.path.join(os.path.dirname(filename), 'step.yaml')
with open(yaml_filename) as f:
return yaml.load(f) | [
"def",
"load",
"(",
"filename",
")",
":",
"yaml_filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"filename",
")",
",",
"'step.yaml'",
")",
"with",
"open",
"(",
"yaml_filename",
")",
"as",
"f",
":",
"return"... | Load step from yaml file
Args:
filename: a target or step.yaml filename | [
"Load",
"step",
"from",
"yaml",
"file",
"Args",
":",
"filename",
":",
"a",
"target",
"or",
"step",
".",
"yaml",
"filename"
] | ddd62081cb9317beb5d21f86c8b4bb196ca3d222 | https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/serialize.py#L8-L16 | train | Load a single step from a file |
potash/drain | drain/serialize.py | configure | def configure():
"""
Configures YAML parser for Step serialization and deserialization
Called in drain/__init__.py
"""
yaml.add_multi_representer(Step, step_multi_representer)
yaml.add_multi_constructor('!step', step_multi_constructor)
yaml.Dumper.ignore_aliases = lambda *args: True | python | def configure():
"""
Configures YAML parser for Step serialization and deserialization
Called in drain/__init__.py
"""
yaml.add_multi_representer(Step, step_multi_representer)
yaml.add_multi_constructor('!step', step_multi_constructor)
yaml.Dumper.ignore_aliases = lambda *args: True | [
"def",
"configure",
"(",
")",
":",
"yaml",
".",
"add_multi_representer",
"(",
"Step",
",",
"step_multi_representer",
")",
"yaml",
".",
"add_multi_constructor",
"(",
"'!step'",
",",
"step_multi_constructor",
")",
"yaml",
".",
"Dumper",
".",
"ignore_aliases",
"=",
... | Configures YAML parser for Step serialization and deserialization
Called in drain/__init__.py | [
"Configures",
"YAML",
"parser",
"for",
"Step",
"serialization",
"and",
"deserialization",
"Called",
"in",
"drain",
"/",
"__init__",
".",
"py"
] | ddd62081cb9317beb5d21f86c8b4bb196ca3d222 | https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/serialize.py#L32-L39 | train | Configures YAML parser for Step serialization and deserialization
Called in drain. py |
cuenca-mx/clabe-python | clabe/__init__.py | compute_control_digit | def compute_control_digit(clabe: str) -> str:
"""
Compute CLABE control digit according to
https://es.wikipedia.org/wiki/CLABE#D.C3.ADgito_control
"""
clabe = [int(i) for i in clabe]
weighted = [c * w % 10 for c, w in
zip(clabe[:CLABE_LENGTH - 1], CLABE_WEIGHTS)]
summed = sum... | python | def compute_control_digit(clabe: str) -> str:
"""
Compute CLABE control digit according to
https://es.wikipedia.org/wiki/CLABE#D.C3.ADgito_control
"""
clabe = [int(i) for i in clabe]
weighted = [c * w % 10 for c, w in
zip(clabe[:CLABE_LENGTH - 1], CLABE_WEIGHTS)]
summed = sum... | [
"def",
"compute_control_digit",
"(",
"clabe",
":",
"str",
")",
"->",
"str",
":",
"clabe",
"=",
"[",
"int",
"(",
"i",
")",
"for",
"i",
"in",
"clabe",
"]",
"weighted",
"=",
"[",
"c",
"*",
"w",
"%",
"10",
"for",
"c",
",",
"w",
"in",
"zip",
"(",
... | Compute CLABE control digit according to
https://es.wikipedia.org/wiki/CLABE#D.C3.ADgito_control | [
"Compute",
"CLABE",
"control",
"digit",
"according",
"to",
"https",
":",
"//",
"es",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"CLABE#D",
".",
"C3",
".",
"ADgito_control"
] | 6a8fe4d306cb3f4f29d30efedabe5d82b442da99 | https://github.com/cuenca-mx/clabe-python/blob/6a8fe4d306cb3f4f29d30efedabe5d82b442da99/clabe/__init__.py#L11-L21 | train | Compute CLABE control digit according to
https://es. wikidoc. org / wiki / CLABE#D. C3. ADgito_control
|
cuenca-mx/clabe-python | clabe/__init__.py | validate_clabe | def validate_clabe(clabe: str) -> bool:
"""
Validate CLABE according to
https://es.wikipedia.org/wiki/CLABE#D.C3.ADgito_control
"""
return (clabe.isdigit() and
len(clabe) == CLABE_LENGTH and
clabe[:3] in BANKS.keys() and
clabe[-1] == compute_control_digit(clabe)) | python | def validate_clabe(clabe: str) -> bool:
"""
Validate CLABE according to
https://es.wikipedia.org/wiki/CLABE#D.C3.ADgito_control
"""
return (clabe.isdigit() and
len(clabe) == CLABE_LENGTH and
clabe[:3] in BANKS.keys() and
clabe[-1] == compute_control_digit(clabe)) | [
"def",
"validate_clabe",
"(",
"clabe",
":",
"str",
")",
"->",
"bool",
":",
"return",
"(",
"clabe",
".",
"isdigit",
"(",
")",
"and",
"len",
"(",
"clabe",
")",
"==",
"CLABE_LENGTH",
"and",
"clabe",
"[",
":",
"3",
"]",
"in",
"BANKS",
".",
"keys",
"(",... | Validate CLABE according to
https://es.wikipedia.org/wiki/CLABE#D.C3.ADgito_control | [
"Validate",
"CLABE",
"according",
"to",
"https",
":",
"//",
"es",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"CLABE#D",
".",
"C3",
".",
"ADgito_control"
] | 6a8fe4d306cb3f4f29d30efedabe5d82b442da99 | https://github.com/cuenca-mx/clabe-python/blob/6a8fe4d306cb3f4f29d30efedabe5d82b442da99/clabe/__init__.py#L24-L32 | train | Validate CLABE according to Agito Control - digit. |
cuenca-mx/clabe-python | clabe/__init__.py | get_bank_name | def get_bank_name(clabe: str) -> str:
"""
Regresa el nombre del banco basado en los primeros 3 digitos
https://es.wikipedia.org/wiki/CLABE#D.C3.ADgito_control
"""
code = clabe[:3]
try:
bank_name = BANK_NAMES[BANKS[code]]
except KeyError:
raise ValueError(f"Ningún banco tiene ... | python | def get_bank_name(clabe: str) -> str:
"""
Regresa el nombre del banco basado en los primeros 3 digitos
https://es.wikipedia.org/wiki/CLABE#D.C3.ADgito_control
"""
code = clabe[:3]
try:
bank_name = BANK_NAMES[BANKS[code]]
except KeyError:
raise ValueError(f"Ningún banco tiene ... | [
"def",
"get_bank_name",
"(",
"clabe",
":",
"str",
")",
"->",
"str",
":",
"code",
"=",
"clabe",
"[",
":",
"3",
"]",
"try",
":",
"bank_name",
"=",
"BANK_NAMES",
"[",
"BANKS",
"[",
"code",
"]",
"]",
"except",
"KeyError",
":",
"raise",
"ValueError",
"(",... | Regresa el nombre del banco basado en los primeros 3 digitos
https://es.wikipedia.org/wiki/CLABE#D.C3.ADgito_control | [
"Regresa",
"el",
"nombre",
"del",
"banco",
"basado",
"en",
"los",
"primeros",
"3",
"digitos",
"https",
":",
"//",
"es",
".",
"wikipedia",
".",
"org",
"/",
"wiki",
"/",
"CLABE#D",
".",
"C3",
".",
"ADgito_control"
] | 6a8fe4d306cb3f4f29d30efedabe5d82b442da99 | https://github.com/cuenca-mx/clabe-python/blob/6a8fe4d306cb3f4f29d30efedabe5d82b442da99/clabe/__init__.py#L35-L46 | train | Get the bank name for a given clabe |
gmdzy2010/dingtalk_sdk_gmdzy2010 | dingtalk_sdk_gmdzy2010/authority_request.py | PersistentCodeRequest.get_ticket_for_sns_token | def get_ticket_for_sns_token(self):
"""This is a shortcut for getting the sns_token, as a post data of
request body."""
self.logger.info("%s\t%s" % (self.request_method, self.request_url))
return {
"openid": self.get_openid(),
"persistent_code": self.get_per... | python | def get_ticket_for_sns_token(self):
"""This is a shortcut for getting the sns_token, as a post data of
request body."""
self.logger.info("%s\t%s" % (self.request_method, self.request_url))
return {
"openid": self.get_openid(),
"persistent_code": self.get_per... | [
"def",
"get_ticket_for_sns_token",
"(",
"self",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"%s\\t%s\"",
"%",
"(",
"self",
".",
"request_method",
",",
"self",
".",
"request_url",
")",
")",
"return",
"{",
"\"openid\"",
":",
"self",
".",
"get_openid... | This is a shortcut for getting the sns_token, as a post data of
request body. | [
"This",
"is",
"a",
"shortcut",
"for",
"getting",
"the",
"sns_token",
"as",
"a",
"post",
"data",
"of",
"request",
"body",
"."
] | b06cb1f78f89be9554dcb6101af8bc72718a9ecd | https://github.com/gmdzy2010/dingtalk_sdk_gmdzy2010/blob/b06cb1f78f89be9554dcb6101af8bc72718a9ecd/dingtalk_sdk_gmdzy2010/authority_request.py#L86-L93 | train | This method is a shortcut for getting the sns_token as a post data of the request body. |
potash/drain | drain/aggregation.py | AggregationBase.fillna_value | def fillna_value(self, df, left, **concat_args):
"""
This method gives subclasses the opportunity to define how
join() fills missing values. Return value must be compatible with
DataFrame.fillna() value argument. Examples:
- return 0: replace missing values with zero
... | python | def fillna_value(self, df, left, **concat_args):
"""
This method gives subclasses the opportunity to define how
join() fills missing values. Return value must be compatible with
DataFrame.fillna() value argument. Examples:
- return 0: replace missing values with zero
... | [
"def",
"fillna_value",
"(",
"self",
",",
"df",
",",
"left",
",",
"*",
"*",
"concat_args",
")",
":",
"value",
"=",
"pd",
".",
"Series",
"(",
"0",
",",
"index",
"=",
"[",
"c",
"for",
"c",
"in",
"df",
".",
"columns",
"if",
"c",
".",
"endswith",
"(... | This method gives subclasses the opportunity to define how
join() fills missing values. Return value must be compatible with
DataFrame.fillna() value argument. Examples:
- return 0: replace missing values with zero
- return df.mean(): replace missing values with column mean
... | [
"This",
"method",
"gives",
"subclasses",
"the",
"opportunity",
"to",
"define",
"how",
"join",
"()",
"fills",
"missing",
"values",
".",
"Return",
"value",
"must",
"be",
"compatible",
"with",
"DataFrame",
".",
"fillna",
"()",
"value",
"argument",
".",
"Examples"... | ddd62081cb9317beb5d21f86c8b4bb196ca3d222 | https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/aggregation.py#L102-L119 | train | This method fills missing values with zero and returns a DataFrame with the missing values. |
potash/drain | drain/aggregation.py | AggregationBase.select | def select(self, df, args, inplace=False):
"""
After joining, selects a subset of arguments
df: the result of a call to self.join(left)
args: a collcetion of arguments to select, as accepted by drain.util.list_expand:
- a tuple corresponding to concat_args,
e.... | python | def select(self, df, args, inplace=False):
"""
After joining, selects a subset of arguments
df: the result of a call to self.join(left)
args: a collcetion of arguments to select, as accepted by drain.util.list_expand:
- a tuple corresponding to concat_args,
e.... | [
"def",
"select",
"(",
"self",
",",
"df",
",",
"args",
",",
"inplace",
"=",
"False",
")",
":",
"if",
"self",
".",
"prefix",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Cannot do selection on an Aggregation without a prefix'",
")",
"# run list_expand and ensure... | After joining, selects a subset of arguments
df: the result of a call to self.join(left)
args: a collcetion of arguments to select, as accepted by drain.util.list_expand:
- a tuple corresponding to concat_args,
e.g. [('District', '12h'), ('Distict', '24h')]
- a di... | [
"After",
"joining",
"selects",
"a",
"subset",
"of",
"arguments",
"df",
":",
"the",
"result",
"of",
"a",
"call",
"to",
"self",
".",
"join",
"(",
"left",
")",
"args",
":",
"a",
"collcetion",
"of",
"arguments",
"to",
"select",
"as",
"accepted",
"by",
"dra... | ddd62081cb9317beb5d21f86c8b4bb196ca3d222 | https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/aggregation.py#L121-L151 | train | Select a subset of arguments from the DataFrame |
ehansis/ozelot | examples/superheroes/superheroes/models.py | reinitialize | def reinitialize():
"""Drop all tables for all models, then re-create them
"""
from ozelot import client
# import all additional models needed in this project
# noinspection PyUnresolvedReferences
from ozelot.orm.target import ORMTargetMarker
client = client.get_client()
base.Base.drop... | python | def reinitialize():
"""Drop all tables for all models, then re-create them
"""
from ozelot import client
# import all additional models needed in this project
# noinspection PyUnresolvedReferences
from ozelot.orm.target import ORMTargetMarker
client = client.get_client()
base.Base.drop... | [
"def",
"reinitialize",
"(",
")",
":",
"from",
"ozelot",
"import",
"client",
"# import all additional models needed in this project",
"# noinspection PyUnresolvedReferences",
"from",
"ozelot",
".",
"orm",
".",
"target",
"import",
"ORMTargetMarker",
"client",
"=",
"client",
... | Drop all tables for all models, then re-create them | [
"Drop",
"all",
"tables",
"for",
"all",
"models",
"then",
"re",
"-",
"create",
"them"
] | 948675e02eb6fca940450f5cb814f53e97159e5b | https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/examples/superheroes/superheroes/models.py#L130-L141 | train | Drop all tables for all models then create them
|
mojaie/chorus | chorus/mcsdr.py | comparison_graph_py | def comparison_graph_py(arr1, arr2):
""" DEPRECATED: Generate comparison graph
Comparison graph is a modular product of molecule edges
"""
# timeout is not implemented
u1, v1, c1 = zip(*arr1)
u2, v2, c2 = zip(*arr2)
c1 = np.array(c1, dtype=int)
c2 = np.array(c2, dtype=int)
product = ... | python | def comparison_graph_py(arr1, arr2):
""" DEPRECATED: Generate comparison graph
Comparison graph is a modular product of molecule edges
"""
# timeout is not implemented
u1, v1, c1 = zip(*arr1)
u2, v2, c2 = zip(*arr2)
c1 = np.array(c1, dtype=int)
c2 = np.array(c2, dtype=int)
product = ... | [
"def",
"comparison_graph_py",
"(",
"arr1",
",",
"arr2",
")",
":",
"# timeout is not implemented",
"u1",
",",
"v1",
",",
"c1",
"=",
"zip",
"(",
"*",
"arr1",
")",
"u2",
",",
"v2",
",",
"c2",
"=",
"zip",
"(",
"*",
"arr2",
")",
"c1",
"=",
"np",
".",
... | DEPRECATED: Generate comparison graph
Comparison graph is a modular product of molecule edges | [
"DEPRECATED",
":",
"Generate",
"comparison",
"graph",
"Comparison",
"graph",
"is",
"a",
"modular",
"product",
"of",
"molecule",
"edges"
] | fc7fe23a0272554c67671645ab07830b315eeb1b | https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/mcsdr.py#L148-L178 | train | Generate comparison graph using Python. |
mojaie/chorus | chorus/mcsdr.py | DescriptorArray.node_desc | def node_desc(self, atoms):
"""default 9 bits descriptor
7 bits of atomic number (0-127) and 2 bits of pi electrons (0-3)
"""
a1 = self.mol.atom(atoms[0])
a2 = self.mol.atom(atoms[1])
a1t = a1.number << 2 | a1.pi
a2t = a2.number << 2 | a2.pi
pair = sorted(... | python | def node_desc(self, atoms):
"""default 9 bits descriptor
7 bits of atomic number (0-127) and 2 bits of pi electrons (0-3)
"""
a1 = self.mol.atom(atoms[0])
a2 = self.mol.atom(atoms[1])
a1t = a1.number << 2 | a1.pi
a2t = a2.number << 2 | a2.pi
pair = sorted(... | [
"def",
"node_desc",
"(",
"self",
",",
"atoms",
")",
":",
"a1",
"=",
"self",
".",
"mol",
".",
"atom",
"(",
"atoms",
"[",
"0",
"]",
")",
"a2",
"=",
"self",
".",
"mol",
".",
"atom",
"(",
"atoms",
"[",
"1",
"]",
")",
"a1t",
"=",
"a1",
".",
"num... | default 9 bits descriptor
7 bits of atomic number (0-127) and 2 bits of pi electrons (0-3) | [
"default",
"9",
"bits",
"descriptor",
"7",
"bits",
"of",
"atomic",
"number",
"(",
"0",
"-",
"127",
")",
"and",
"2",
"bits",
"of",
"pi",
"electrons",
"(",
"0",
"-",
"3",
")"
] | fc7fe23a0272554c67671645ab07830b315eeb1b | https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/mcsdr.py#L117-L126 | train | get node_desc - returns node_desc for given atoms |
ncraike/fang | fang/dependency_register.py | DependencyRegister._unwrap_func | def _unwrap_func(cls, decorated_func):
'''
This unwraps a decorated func, returning the inner wrapped func.
This may become unnecessary with Python 3.4's inspect.unwrap().
'''
if click is not None:
# Workaround for click.command() decorator not setting
# ... | python | def _unwrap_func(cls, decorated_func):
'''
This unwraps a decorated func, returning the inner wrapped func.
This may become unnecessary with Python 3.4's inspect.unwrap().
'''
if click is not None:
# Workaround for click.command() decorator not setting
# ... | [
"def",
"_unwrap_func",
"(",
"cls",
",",
"decorated_func",
")",
":",
"if",
"click",
"is",
"not",
"None",
":",
"# Workaround for click.command() decorator not setting",
"# __wrapped__",
"if",
"isinstance",
"(",
"decorated_func",
",",
"click",
".",
"Command",
")",
":",... | This unwraps a decorated func, returning the inner wrapped func.
This may become unnecessary with Python 3.4's inspect.unwrap(). | [
"This",
"unwraps",
"a",
"decorated",
"func",
"returning",
"the",
"inner",
"wrapped",
"func",
"."
] | 2d9e1216c866e450059017f83ab775f7716eda7a | https://github.com/ncraike/fang/blob/2d9e1216c866e450059017f83ab775f7716eda7a/fang/dependency_register.py#L21-L39 | train | This unwraps a decorated function returning the inner wrapped function. |
ncraike/fang | fang/dependency_register.py | DependencyRegister._register_dependent | def _register_dependent(self, dependent, resource_name):
'''
Register a mapping of the dependent to resource name.
After calling, dependency_register.dependents[dependent] should
contain resource_name.
'''
if dependent not in self.dependents:
self.dependents[... | python | def _register_dependent(self, dependent, resource_name):
'''
Register a mapping of the dependent to resource name.
After calling, dependency_register.dependents[dependent] should
contain resource_name.
'''
if dependent not in self.dependents:
self.dependents[... | [
"def",
"_register_dependent",
"(",
"self",
",",
"dependent",
",",
"resource_name",
")",
":",
"if",
"dependent",
"not",
"in",
"self",
".",
"dependents",
":",
"self",
".",
"dependents",
"[",
"dependent",
"]",
"=",
"[",
"]",
"self",
".",
"dependents",
"[",
... | Register a mapping of the dependent to resource name.
After calling, dependency_register.dependents[dependent] should
contain resource_name. | [
"Register",
"a",
"mapping",
"of",
"the",
"dependent",
"to",
"resource",
"name",
"."
] | 2d9e1216c866e450059017f83ab775f7716eda7a | https://github.com/ncraike/fang/blob/2d9e1216c866e450059017f83ab775f7716eda7a/fang/dependency_register.py#L50-L59 | train | Register a mapping of the dependent to resource name. |
ncraike/fang | fang/dependency_register.py | DependencyRegister.register | def register(self, resource_name, dependent=None):
'''
Register the given dependent as depending on the "resource"
named by resource_name.
'''
if dependent is None:
# Give a partial usable as a decorator
return partial(self.register, resource_name)
... | python | def register(self, resource_name, dependent=None):
'''
Register the given dependent as depending on the "resource"
named by resource_name.
'''
if dependent is None:
# Give a partial usable as a decorator
return partial(self.register, resource_name)
... | [
"def",
"register",
"(",
"self",
",",
"resource_name",
",",
"dependent",
"=",
"None",
")",
":",
"if",
"dependent",
"is",
"None",
":",
"# Give a partial usable as a decorator",
"return",
"partial",
"(",
"self",
".",
"register",
",",
"resource_name",
")",
"dependen... | Register the given dependent as depending on the "resource"
named by resource_name. | [
"Register",
"the",
"given",
"dependent",
"as",
"depending",
"on",
"the",
"resource",
"named",
"by",
"resource_name",
"."
] | 2d9e1216c866e450059017f83ab775f7716eda7a | https://github.com/ncraike/fang/blob/2d9e1216c866e450059017f83ab775f7716eda7a/fang/dependency_register.py#L66-L80 | train | Register the given dependent as depending on the resource_name. |
zsimic/runez | src/runez/represent.py | header | def header(text, border="--"):
"""
Args:
text (str | unicode): Text to turn into a header
border (str | unicode): Characters to use to decorate header
Returns:
(str): Decorated
"""
if not text or not border:
return text
if border.endswith(" "):
decorated... | python | def header(text, border="--"):
"""
Args:
text (str | unicode): Text to turn into a header
border (str | unicode): Characters to use to decorate header
Returns:
(str): Decorated
"""
if not text or not border:
return text
if border.endswith(" "):
decorated... | [
"def",
"header",
"(",
"text",
",",
"border",
"=",
"\"--\"",
")",
":",
"if",
"not",
"text",
"or",
"not",
"border",
":",
"return",
"text",
"if",
"border",
".",
"endswith",
"(",
"\" \"",
")",
":",
"decorated",
"=",
"\"%s%s\"",
"%",
"(",
"border",
",",
... | Args:
text (str | unicode): Text to turn into a header
border (str | unicode): Characters to use to decorate header
Returns:
(str): Decorated | [
"Args",
":",
"text",
"(",
"str",
"|",
"unicode",
")",
":",
"Text",
"to",
"turn",
"into",
"a",
"header",
"border",
"(",
"str",
"|",
"unicode",
")",
":",
"Characters",
"to",
"use",
"to",
"decorate",
"header"
] | 14363b719a1aae1528859a501a22d075ce0abfcc | https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/represent.py#L1-L21 | train | Return a string that is a header of the current node. |
lsst-sqre/documenteer | documenteer/requestsutils.py | requests_retry_session | def requests_retry_session(
retries=3,
backoff_factor=0.3,
status_forcelist=(500, 502, 504),
session=None):
"""Create a requests session that handles errors by retrying.
Parameters
----------
retries : `int`, optional
Number of retries to attempt.
backoff_fac... | python | def requests_retry_session(
retries=3,
backoff_factor=0.3,
status_forcelist=(500, 502, 504),
session=None):
"""Create a requests session that handles errors by retrying.
Parameters
----------
retries : `int`, optional
Number of retries to attempt.
backoff_fac... | [
"def",
"requests_retry_session",
"(",
"retries",
"=",
"3",
",",
"backoff_factor",
"=",
"0.3",
",",
"status_forcelist",
"=",
"(",
"500",
",",
"502",
",",
"504",
")",
",",
"session",
"=",
"None",
")",
":",
"session",
"=",
"session",
"or",
"requests",
".",
... | Create a requests session that handles errors by retrying.
Parameters
----------
retries : `int`, optional
Number of retries to attempt.
backoff_factor : `float`, optional
Backoff factor.
status_forcelist : sequence of `str`, optional
Status codes that must be retried.
s... | [
"Create",
"a",
"requests",
"session",
"that",
"handles",
"errors",
"by",
"retrying",
"."
] | 75f02901a80042b28d074df1cc1dca32eb8e38c8 | https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/requestsutils.py#L11-L52 | train | Create a requests. Session that handles errors by retrying. |
acatton/python-spm | docs/files/shell.py | lookup | def lookup(command):
"""
Lookup a command in PATH. For example::
>>> lookup('ls')
'/usr/bin/ls'
>>> lookup('usermod')
'/usr/sbin/usermod'
>>> lookup('foobar')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Inv... | python | def lookup(command):
"""
Lookup a command in PATH. For example::
>>> lookup('ls')
'/usr/bin/ls'
>>> lookup('usermod')
'/usr/sbin/usermod'
>>> lookup('foobar')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Inv... | [
"def",
"lookup",
"(",
"command",
")",
":",
"for",
"path",
"in",
"os",
".",
"environ",
".",
"get",
"(",
"'PATH'",
",",
"''",
")",
".",
"split",
"(",
"':'",
")",
":",
"fname",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"command",
")",... | Lookup a command in PATH. For example::
>>> lookup('ls')
'/usr/bin/ls'
>>> lookup('usermod')
'/usr/sbin/usermod'
>>> lookup('foobar')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Invalid command
This function i... | [
"Lookup",
"a",
"command",
"in",
"PATH",
".",
"For",
"example",
"::"
] | 0d4e7177aef17c90f7676ae2e099bb4137a0226f | https://github.com/acatton/python-spm/blob/0d4e7177aef17c90f7676ae2e099bb4137a0226f/docs/files/shell.py#L12-L32 | train | Lookup a command in PATH. |
acatton/python-spm | docs/files/shell.py | run | def run(line):
"""
Run a shell line: run('ls /tmp') will execv('/usr/bin/ls', ['ls', '/tmp'])
"""
arguments = shlex.split(line)
path = lookup(arguments[0]) # Lookup the first arguments in PATH
execute(path, arguments) | python | def run(line):
"""
Run a shell line: run('ls /tmp') will execv('/usr/bin/ls', ['ls', '/tmp'])
"""
arguments = shlex.split(line)
path = lookup(arguments[0]) # Lookup the first arguments in PATH
execute(path, arguments) | [
"def",
"run",
"(",
"line",
")",
":",
"arguments",
"=",
"shlex",
".",
"split",
"(",
"line",
")",
"path",
"=",
"lookup",
"(",
"arguments",
"[",
"0",
"]",
")",
"# Lookup the first arguments in PATH",
"execute",
"(",
"path",
",",
"arguments",
")"
] | Run a shell line: run('ls /tmp') will execv('/usr/bin/ls', ['ls', '/tmp']) | [
"Run",
"a",
"shell",
"line",
":",
"run",
"(",
"ls",
"/",
"tmp",
")",
"will",
"execv",
"(",
"/",
"usr",
"/",
"bin",
"/",
"ls",
"[",
"ls",
"/",
"tmp",
"]",
")"
] | 0d4e7177aef17c90f7676ae2e099bb4137a0226f | https://github.com/acatton/python-spm/blob/0d4e7177aef17c90f7676ae2e099bb4137a0226f/docs/files/shell.py#L35-L41 | train | Run a shell line |
acatton/python-spm | docs/files/shell.py | execute | def execute(path, arguments):
"""
Wrapper around execv():
* fork()s before exec()ing (in order to run the command in a subprocess)
* wait for the subprocess to finish before returning (blocks the parent
process)
This is **hyper** simplistic. This *does not* handle **many** edge cases.
*... | python | def execute(path, arguments):
"""
Wrapper around execv():
* fork()s before exec()ing (in order to run the command in a subprocess)
* wait for the subprocess to finish before returning (blocks the parent
process)
This is **hyper** simplistic. This *does not* handle **many** edge cases.
*... | [
"def",
"execute",
"(",
"path",
",",
"arguments",
")",
":",
"pid",
"=",
"os",
".",
"fork",
"(",
")",
"if",
"pid",
"==",
"0",
":",
"try",
":",
"os",
".",
"execv",
"(",
"path",
",",
"arguments",
")",
"finally",
":",
"sys",
".",
"exit",
"(",
"1",
... | Wrapper around execv():
* fork()s before exec()ing (in order to run the command in a subprocess)
* wait for the subprocess to finish before returning (blocks the parent
process)
This is **hyper** simplistic. This *does not* handle **many** edge cases.
*DO NOT DO THIS*: subprocess.check_call() d... | [
"Wrapper",
"around",
"execv",
"()",
":"
] | 0d4e7177aef17c90f7676ae2e099bb4137a0226f | https://github.com/acatton/python-spm/blob/0d4e7177aef17c90f7676ae2e099bb4137a0226f/docs/files/shell.py#L44-L69 | train | Execute a command in a new process. |
lsst-sqre/documenteer | documenteer/sphinxconfig/technoteconf.py | configure_technote | def configure_technote(meta_stream):
"""Builds a ``dict`` of Sphinx configuration variables given a central
configuration for LSST Design Documents and a metadata YAML file.
This function refactors the common Sphinx ``conf.py`` script so that basic
configurations are managed centrally in this module, w... | python | def configure_technote(meta_stream):
"""Builds a ``dict`` of Sphinx configuration variables given a central
configuration for LSST Design Documents and a metadata YAML file.
This function refactors the common Sphinx ``conf.py`` script so that basic
configurations are managed centrally in this module, w... | [
"def",
"configure_technote",
"(",
"meta_stream",
")",
":",
"_metadata",
"=",
"yaml",
".",
"load",
"(",
"meta_stream",
")",
"confs",
"=",
"_build_confs",
"(",
"_metadata",
")",
"return",
"confs"
] | Builds a ``dict`` of Sphinx configuration variables given a central
configuration for LSST Design Documents and a metadata YAML file.
This function refactors the common Sphinx ``conf.py`` script so that basic
configurations are managed centrally in this module, while author-updatable
metadata is stored... | [
"Builds",
"a",
"dict",
"of",
"Sphinx",
"configuration",
"variables",
"given",
"a",
"central",
"configuration",
"for",
"LSST",
"Design",
"Documents",
"and",
"a",
"metadata",
"YAML",
"file",
"."
] | 75f02901a80042b28d074df1cc1dca32eb8e38c8 | https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxconfig/technoteconf.py#L17-L67 | train | This function creates a Sphinx configuration object for the central central |
thorgate/django-esteid | esteid/config.py | ocsp_responder_certificate_path | def ocsp_responder_certificate_path():
"""Get ocsp responder certificate path
Test: TEST_of_SK_OCSP_RESPONDER_2011.pem
Live: sk-ocsp-responder-certificates.pem
Note: These files are distributed under esteid/certs
:return:
"""
certificate_path = getattr(settings, 'ESTEID_OCSP_RESPONDER_CER... | python | def ocsp_responder_certificate_path():
"""Get ocsp responder certificate path
Test: TEST_of_SK_OCSP_RESPONDER_2011.pem
Live: sk-ocsp-responder-certificates.pem
Note: These files are distributed under esteid/certs
:return:
"""
certificate_path = getattr(settings, 'ESTEID_OCSP_RESPONDER_CER... | [
"def",
"ocsp_responder_certificate_path",
"(",
")",
":",
"certificate_path",
"=",
"getattr",
"(",
"settings",
",",
"'ESTEID_OCSP_RESPONDER_CERTIFICATE_PATH'",
",",
"'TEST_of_SK_OCSP_RESPONDER_2011.pem'",
")",
"if",
"certificate_path",
"in",
"[",
"'TEST_of_SK_OCSP_RESPONDER_2011... | Get ocsp responder certificate path
Test: TEST_of_SK_OCSP_RESPONDER_2011.pem
Live: sk-ocsp-responder-certificates.pem
Note: These files are distributed under esteid/certs
:return: | [
"Get",
"ocsp",
"responder",
"certificate",
"path"
] | 407ae513e357fedea0e3e42198df8eb9d9ff0646 | https://github.com/thorgate/django-esteid/blob/407ae513e357fedea0e3e42198df8eb9d9ff0646/esteid/config.py#L40-L55 | train | Get ocsp responder certificate path |
miguelgrinberg/Flask-MarrowMailer | flask_marrowmailer.py | Message.render_template | def render_template(self, plain, rich = None, **context):
'''Render the body of the message from a template. The plain
body will be rendered from a template named ``plain`` or
``plain + '.txt'`` (in that order of preference). The rich
body will be rendered from ``rich`` if given, or el... | python | def render_template(self, plain, rich = None, **context):
'''Render the body of the message from a template. The plain
body will be rendered from a template named ``plain`` or
``plain + '.txt'`` (in that order of preference). The rich
body will be rendered from ``rich`` if given, or el... | [
"def",
"render_template",
"(",
"self",
",",
"plain",
",",
"rich",
"=",
"None",
",",
"*",
"*",
"context",
")",
":",
"self",
".",
"plain",
"=",
"render_template",
"(",
"[",
"plain",
",",
"plain",
"+",
"'.txt'",
"]",
",",
"*",
"*",
"context",
")",
"if... | Render the body of the message from a template. The plain
body will be rendered from a template named ``plain`` or
``plain + '.txt'`` (in that order of preference). The rich
body will be rendered from ``rich`` if given, or else from
``plain + '.html'``. If neither exists, then the mes... | [
"Render",
"the",
"body",
"of",
"the",
"message",
"from",
"a",
"template",
".",
"The",
"plain",
"body",
"will",
"be",
"rendered",
"from",
"a",
"template",
"named",
"plain",
"or",
"plain",
"+",
".",
"txt",
"(",
"in",
"that",
"order",
"of",
"preference",
... | daf1ac0745fb31db2f43f4f7dc24c6f50ae96764 | https://github.com/miguelgrinberg/Flask-MarrowMailer/blob/daf1ac0745fb31db2f43f4f7dc24c6f50ae96764/flask_marrowmailer.py#L11-L25 | train | Render the body of the message from a template named plain or rich. |
miguelgrinberg/Flask-MarrowMailer | flask_marrowmailer.py | Message.render_template_string | def render_template_string(self, plain, rich = None, **context):
'''Render the body of the message from a string. If ``rich`` isn’t
provided then the message will not have a rich body.'''
self.plain = render_template_string(plain, **context)
if rich is not None:
self.rich = ... | python | def render_template_string(self, plain, rich = None, **context):
'''Render the body of the message from a string. If ``rich`` isn’t
provided then the message will not have a rich body.'''
self.plain = render_template_string(plain, **context)
if rich is not None:
self.rich = ... | [
"def",
"render_template_string",
"(",
"self",
",",
"plain",
",",
"rich",
"=",
"None",
",",
"*",
"*",
"context",
")",
":",
"self",
".",
"plain",
"=",
"render_template_string",
"(",
"plain",
",",
"*",
"*",
"context",
")",
"if",
"rich",
"is",
"not",
"None... | Render the body of the message from a string. If ``rich`` isn’t
provided then the message will not have a rich body. | [
"Render",
"the",
"body",
"of",
"the",
"message",
"from",
"a",
"string",
".",
"If",
"rich",
"isn’t",
"provided",
"then",
"the",
"message",
"will",
"not",
"have",
"a",
"rich",
"body",
"."
] | daf1ac0745fb31db2f43f4f7dc24c6f50ae96764 | https://github.com/miguelgrinberg/Flask-MarrowMailer/blob/daf1ac0745fb31db2f43f4f7dc24c6f50ae96764/flask_marrowmailer.py#L27-L32 | train | Render the body of the message from a string. |
miguelgrinberg/Flask-MarrowMailer | flask_marrowmailer.py | Mailer.init_app | def init_app(self, app):
'''Initialize the extension. Configuration will be
obtained from ``app.config['MARROWMAILER_CONFIG']``. If no
configuration is found the mailer will be configured to
send emails asynchrously via SMTP on localhost without
authentication. The created ``... | python | def init_app(self, app):
'''Initialize the extension. Configuration will be
obtained from ``app.config['MARROWMAILER_CONFIG']``. If no
configuration is found the mailer will be configured to
send emails asynchrously via SMTP on localhost without
authentication. The created ``... | [
"def",
"init_app",
"(",
"self",
",",
"app",
")",
":",
"if",
"not",
"hasattr",
"(",
"app",
",",
"'extensions'",
")",
":",
"app",
".",
"extensions",
"=",
"{",
"}",
"mailer",
"=",
"BaseMailer",
"(",
"app",
".",
"config",
".",
"get",
"(",
"'MARROWMAILER_... | Initialize the extension. Configuration will be
obtained from ``app.config['MARROWMAILER_CONFIG']``. If no
configuration is found the mailer will be configured to
send emails asynchrously via SMTP on localhost without
authentication. The created ``Mailer`` instance is written
... | [
"Initialize",
"the",
"extension",
".",
"Configuration",
"will",
"be",
"obtained",
"from",
"app",
".",
"config",
"[",
"MARROWMAILER_CONFIG",
"]",
".",
"If",
"no",
"configuration",
"is",
"found",
"the",
"mailer",
"will",
"be",
"configured",
"to",
"send",
"emails... | daf1ac0745fb31db2f43f4f7dc24c6f50ae96764 | https://github.com/miguelgrinberg/Flask-MarrowMailer/blob/daf1ac0745fb31db2f43f4f7dc24c6f50ae96764/flask_marrowmailer.py#L49-L60 | train | Initialize the extension. |
miguelgrinberg/Flask-MarrowMailer | flask_marrowmailer.py | Mailer.new | def new(self, **kwargs):
'''Return a new ``Message`` instance. The arguments are
passed to the ``marrow.mailer.Message`` constructor.'''
app = self.app or current_app
mailer = app.extensions['marrowmailer']
msg = mailer.new(**kwargs)
msg.__class__ = Message
retur... | python | def new(self, **kwargs):
'''Return a new ``Message`` instance. The arguments are
passed to the ``marrow.mailer.Message`` constructor.'''
app = self.app or current_app
mailer = app.extensions['marrowmailer']
msg = mailer.new(**kwargs)
msg.__class__ = Message
retur... | [
"def",
"new",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"app",
"=",
"self",
".",
"app",
"or",
"current_app",
"mailer",
"=",
"app",
".",
"extensions",
"[",
"'marrowmailer'",
"]",
"msg",
"=",
"mailer",
".",
"new",
"(",
"*",
"*",
"kwargs",
")",
... | Return a new ``Message`` instance. The arguments are
passed to the ``marrow.mailer.Message`` constructor. | [
"Return",
"a",
"new",
"Message",
"instance",
".",
"The",
"arguments",
"are",
"passed",
"to",
"the",
"marrow",
".",
"mailer",
".",
"Message",
"constructor",
"."
] | daf1ac0745fb31db2f43f4f7dc24c6f50ae96764 | https://github.com/miguelgrinberg/Flask-MarrowMailer/blob/daf1ac0745fb31db2f43f4f7dc24c6f50ae96764/flask_marrowmailer.py#L62-L69 | train | Return a new Message instance. The arguments are
passed to the MARCLE_MESSAGE constructor. |
miguelgrinberg/Flask-MarrowMailer | flask_marrowmailer.py | Mailer.send | def send(self, msg):
'''Send the message. If message is an iterable, then send
all the messages.'''
app = self.app or current_app
mailer = app.extensions['marrowmailer']
mailer.start()
if not hasattr(msg, '__iter__'):
result = mailer.send(msg)
else:
... | python | def send(self, msg):
'''Send the message. If message is an iterable, then send
all the messages.'''
app = self.app or current_app
mailer = app.extensions['marrowmailer']
mailer.start()
if not hasattr(msg, '__iter__'):
result = mailer.send(msg)
else:
... | [
"def",
"send",
"(",
"self",
",",
"msg",
")",
":",
"app",
"=",
"self",
".",
"app",
"or",
"current_app",
"mailer",
"=",
"app",
".",
"extensions",
"[",
"'marrowmailer'",
"]",
"mailer",
".",
"start",
"(",
")",
"if",
"not",
"hasattr",
"(",
"msg",
",",
"... | Send the message. If message is an iterable, then send
all the messages. | [
"Send",
"the",
"message",
".",
"If",
"message",
"is",
"an",
"iterable",
"then",
"send",
"all",
"the",
"messages",
"."
] | daf1ac0745fb31db2f43f4f7dc24c6f50ae96764 | https://github.com/miguelgrinberg/Flask-MarrowMailer/blob/daf1ac0745fb31db2f43f4f7dc24c6f50ae96764/flask_marrowmailer.py#L71-L82 | train | Send the message. If message is an iterable then send
all the messages. |
brutus/wdiffhtml | wdiffhtml/__init__.py | wdiff | def wdiff(
settings, wrap_with_html=False, fold_breaks=False, hard_breaks=False
):
"""
Returns the results of `wdiff` in a HTML compatible format.
Needs a :cls:`settings.Settings` object.
If *wrap_with_html* is set, the *diff* is returned in a full HTML document
structure.
If *fold_breaks* is set, `<in... | python | def wdiff(
settings, wrap_with_html=False, fold_breaks=False, hard_breaks=False
):
"""
Returns the results of `wdiff` in a HTML compatible format.
Needs a :cls:`settings.Settings` object.
If *wrap_with_html* is set, the *diff* is returned in a full HTML document
structure.
If *fold_breaks* is set, `<in... | [
"def",
"wdiff",
"(",
"settings",
",",
"wrap_with_html",
"=",
"False",
",",
"fold_breaks",
"=",
"False",
",",
"hard_breaks",
"=",
"False",
")",
":",
"diff",
"=",
"generate_wdiff",
"(",
"settings",
".",
"org_file",
",",
"settings",
".",
"new_file",
",",
"fol... | Returns the results of `wdiff` in a HTML compatible format.
Needs a :cls:`settings.Settings` object.
If *wrap_with_html* is set, the *diff* is returned in a full HTML document
structure.
If *fold_breaks* is set, `<ins>` and `<del>` tags are allowed to span line
breaks
If *hard_breaks* is set, line break... | [
"Returns",
"the",
"results",
"of",
"wdiff",
"in",
"a",
"HTML",
"compatible",
"format",
"."
] | e97b524a7945f7a626e33ec141343120c524d9fa | https://github.com/brutus/wdiffhtml/blob/e97b524a7945f7a626e33ec141343120c524d9fa/wdiffhtml/__init__.py#L62-L83 | train | Returns the diff of the current file and the new file. |
mesbahamin/chronophore | chronophore/config.py | _load_config | def _load_config(config_file):
"""Load settings from config file and return them as a dict. If the
config file is not found, or if it is invalid, create and use a
default config file.
:param config_file: `pathlib.Path` object. Path to config file.
:return: Dictionary of config options.
"""
... | python | def _load_config(config_file):
"""Load settings from config file and return them as a dict. If the
config file is not found, or if it is invalid, create and use a
default config file.
:param config_file: `pathlib.Path` object. Path to config file.
:return: Dictionary of config options.
"""
... | [
"def",
"_load_config",
"(",
"config_file",
")",
":",
"logger",
".",
"debug",
"(",
"'Config file: {}'",
".",
"format",
"(",
"config_file",
")",
")",
"parser",
"=",
"configparser",
".",
"ConfigParser",
"(",
")",
"try",
":",
"with",
"config_file",
".",
"open",
... | Load settings from config file and return them as a dict. If the
config file is not found, or if it is invalid, create and use a
default config file.
:param config_file: `pathlib.Path` object. Path to config file.
:return: Dictionary of config options. | [
"Load",
"settings",
"from",
"config",
"file",
"and",
"return",
"them",
"as",
"a",
"dict",
".",
"If",
"the",
"config",
"file",
"is",
"not",
"found",
"or",
"if",
"it",
"is",
"invalid",
"create",
"and",
"use",
"a",
"default",
"config",
"file",
"."
] | ee140c61b4dfada966f078de8304bac737cec6f7 | https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/config.py#L13-L44 | train | Load settings from config file and return them as a dict. |
mesbahamin/chronophore | chronophore/config.py | _load_options | def _load_options(parser):
"""Load config options from parser and return them as a dict.
:param parser: `ConfigParser` object with the values loaded.
:return: Dictionary of config options.
"""
config = dict(
MESSAGE_DURATION=parser.getint('gui', 'message_duration'),
GUI_WELCOME_LABL... | python | def _load_options(parser):
"""Load config options from parser and return them as a dict.
:param parser: `ConfigParser` object with the values loaded.
:return: Dictionary of config options.
"""
config = dict(
MESSAGE_DURATION=parser.getint('gui', 'message_duration'),
GUI_WELCOME_LABL... | [
"def",
"_load_options",
"(",
"parser",
")",
":",
"config",
"=",
"dict",
"(",
"MESSAGE_DURATION",
"=",
"parser",
".",
"getint",
"(",
"'gui'",
",",
"'message_duration'",
")",
",",
"GUI_WELCOME_LABLE",
"=",
"parser",
".",
"get",
"(",
"'gui'",
",",
"'gui_welcome... | Load config options from parser and return them as a dict.
:param parser: `ConfigParser` object with the values loaded.
:return: Dictionary of config options. | [
"Load",
"config",
"options",
"from",
"parser",
"and",
"return",
"them",
"as",
"a",
"dict",
"."
] | ee140c61b4dfada966f078de8304bac737cec6f7 | https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/config.py#L47-L63 | train | Load config options from parser and return them as a dict. |
mesbahamin/chronophore | chronophore/config.py | _use_default | def _use_default(config_file):
"""Write default values to a config file. If another config file
already exists, back it up before replacing it with the new file.
:param config_file: `pathlib.Path` object. Path to config file.
:return: `ConfigParser` object with the values loaded.
"""
default_co... | python | def _use_default(config_file):
"""Write default values to a config file. If another config file
already exists, back it up before replacing it with the new file.
:param config_file: `pathlib.Path` object. Path to config file.
:return: `ConfigParser` object with the values loaded.
"""
default_co... | [
"def",
"_use_default",
"(",
"config_file",
")",
":",
"default_config",
"=",
"OrderedDict",
"(",
"(",
"(",
"'gui'",
",",
"OrderedDict",
"(",
"(",
"(",
"'message_duration'",
",",
"5",
")",
",",
"(",
"'gui_welcome_label'",
",",
"'Welcome to the STEM Learning Center!'... | Write default values to a config file. If another config file
already exists, back it up before replacing it with the new file.
:param config_file: `pathlib.Path` object. Path to config file.
:return: `ConfigParser` object with the values loaded. | [
"Write",
"default",
"values",
"to",
"a",
"config",
"file",
".",
"If",
"another",
"config",
"file",
"already",
"exists",
"back",
"it",
"up",
"before",
"replacing",
"it",
"with",
"the",
"new",
"file",
"."
] | ee140c61b4dfada966f078de8304bac737cec6f7 | https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/config.py#L66-L104 | train | Write default values to a config file. |
mojaie/chorus | chorus/model/graphmol.py | Compound.add_atom | def add_atom(self, key, atom):
"""Set an atom. Existing atom will be overwritten."""
self.graph.add_node(key, atom=atom) | python | def add_atom(self, key, atom):
"""Set an atom. Existing atom will be overwritten."""
self.graph.add_node(key, atom=atom) | [
"def",
"add_atom",
"(",
"self",
",",
"key",
",",
"atom",
")",
":",
"self",
".",
"graph",
".",
"add_node",
"(",
"key",
",",
"atom",
"=",
"atom",
")"
] | Set an atom. Existing atom will be overwritten. | [
"Set",
"an",
"atom",
".",
"Existing",
"atom",
"will",
"be",
"overwritten",
"."
] | fc7fe23a0272554c67671645ab07830b315eeb1b | https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/model/graphmol.py#L79-L81 | train | Set an atom. Existing atom will be overwritten. |
mojaie/chorus | chorus/model/graphmol.py | Compound.atoms_iter | def atoms_iter(self):
"""Iterate over atoms."""
for n, atom in self.graph.nodes.data("atom"):
yield n, atom | python | def atoms_iter(self):
"""Iterate over atoms."""
for n, atom in self.graph.nodes.data("atom"):
yield n, atom | [
"def",
"atoms_iter",
"(",
"self",
")",
":",
"for",
"n",
",",
"atom",
"in",
"self",
".",
"graph",
".",
"nodes",
".",
"data",
"(",
"\"atom\"",
")",
":",
"yield",
"n",
",",
"atom"
] | Iterate over atoms. | [
"Iterate",
"over",
"atoms",
"."
] | fc7fe23a0272554c67671645ab07830b315eeb1b | https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/model/graphmol.py#L87-L90 | train | Iterate over atoms. |
mojaie/chorus | chorus/model/graphmol.py | Compound.add_bond | def add_bond(self, key1, key2, bond):
"""Set a bond. Existing bond will be overwritten."""
self.graph.add_edge(key1, key2, bond=bond) | python | def add_bond(self, key1, key2, bond):
"""Set a bond. Existing bond will be overwritten."""
self.graph.add_edge(key1, key2, bond=bond) | [
"def",
"add_bond",
"(",
"self",
",",
"key1",
",",
"key2",
",",
"bond",
")",
":",
"self",
".",
"graph",
".",
"add_edge",
"(",
"key1",
",",
"key2",
",",
"bond",
"=",
"bond",
")"
] | Set a bond. Existing bond will be overwritten. | [
"Set",
"a",
"bond",
".",
"Existing",
"bond",
"will",
"be",
"overwritten",
"."
] | fc7fe23a0272554c67671645ab07830b315eeb1b | https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/model/graphmol.py#L100-L102 | train | Set a bond. |
mojaie/chorus | chorus/model/graphmol.py | Compound.bonds_iter | def bonds_iter(self):
"""Iterate over bonds."""
for u, v, bond in self.graph.edges.data("bond"):
yield u, v, bond | python | def bonds_iter(self):
"""Iterate over bonds."""
for u, v, bond in self.graph.edges.data("bond"):
yield u, v, bond | [
"def",
"bonds_iter",
"(",
"self",
")",
":",
"for",
"u",
",",
"v",
",",
"bond",
"in",
"self",
".",
"graph",
".",
"edges",
".",
"data",
"(",
"\"bond\"",
")",
":",
"yield",
"u",
",",
"v",
",",
"bond"
] | Iterate over bonds. | [
"Iterate",
"over",
"bonds",
"."
] | fc7fe23a0272554c67671645ab07830b315eeb1b | https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/model/graphmol.py#L108-L111 | train | Iterate over bonds. |
mojaie/chorus | chorus/model/graphmol.py | Compound.neighbors | def neighbors(self, key):
"""Return dict of neighbor atom index and connecting bond."""
return {n: attr["bond"] for n, attr in self.graph[key].items()} | python | def neighbors(self, key):
"""Return dict of neighbor atom index and connecting bond."""
return {n: attr["bond"] for n, attr in self.graph[key].items()} | [
"def",
"neighbors",
"(",
"self",
",",
"key",
")",
":",
"return",
"{",
"n",
":",
"attr",
"[",
"\"bond\"",
"]",
"for",
"n",
",",
"attr",
"in",
"self",
".",
"graph",
"[",
"key",
"]",
".",
"items",
"(",
")",
"}"
] | Return dict of neighbor atom index and connecting bond. | [
"Return",
"dict",
"of",
"neighbor",
"atom",
"index",
"and",
"connecting",
"bond",
"."
] | fc7fe23a0272554c67671645ab07830b315eeb1b | https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/model/graphmol.py#L121-L123 | train | Return dict of neighbor atom index and connecting bond. |
mojaie/chorus | chorus/model/graphmol.py | Compound.neighbors_iter | def neighbors_iter(self):
"""Iterate over atoms and return its neighbors."""
for n, adj in self.graph.adj.items():
yield n, {n: attr["bond"] for n, attr in adj.items()} | python | def neighbors_iter(self):
"""Iterate over atoms and return its neighbors."""
for n, adj in self.graph.adj.items():
yield n, {n: attr["bond"] for n, attr in adj.items()} | [
"def",
"neighbors_iter",
"(",
"self",
")",
":",
"for",
"n",
",",
"adj",
"in",
"self",
".",
"graph",
".",
"adj",
".",
"items",
"(",
")",
":",
"yield",
"n",
",",
"{",
"n",
":",
"attr",
"[",
"\"bond\"",
"]",
"for",
"n",
",",
"attr",
"in",
"adj",
... | Iterate over atoms and return its neighbors. | [
"Iterate",
"over",
"atoms",
"and",
"return",
"its",
"neighbors",
"."
] | fc7fe23a0272554c67671645ab07830b315eeb1b | https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/model/graphmol.py#L129-L132 | train | Iterate over atoms and return its neighbors. |
mojaie/chorus | chorus/model/graphmol.py | Compound.clear | def clear(self):
"""Empty the instance """
# self.graph = nx.Graph()
self.graph.clear()
self.data.clear()
self.descriptors.clear()
self.size2d = None
self.rings = None
self.scaffolds = None
self.isolated = None | python | def clear(self):
"""Empty the instance """
# self.graph = nx.Graph()
self.graph.clear()
self.data.clear()
self.descriptors.clear()
self.size2d = None
self.rings = None
self.scaffolds = None
self.isolated = None | [
"def",
"clear",
"(",
"self",
")",
":",
"# self.graph = nx.Graph()",
"self",
".",
"graph",
".",
"clear",
"(",
")",
"self",
".",
"data",
".",
"clear",
"(",
")",
"self",
".",
"descriptors",
".",
"clear",
"(",
")",
"self",
".",
"size2d",
"=",
"None",
"se... | Empty the instance | [
"Empty",
"the",
"instance"
] | fc7fe23a0272554c67671645ab07830b315eeb1b | https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/model/graphmol.py#L134-L143 | train | Clear the instance of the current object |
mojaie/chorus | chorus/model/graphmol.py | Compound.add_molecule | def add_molecule(self, mol, bond=None, base=None, target=None):
"""connect atom group (for SMILES parser)
May requires recalculation of 2D coordinate for drawing
Args:
mol: graphmol.Compound()
the original object will be copied.
bond: Bond object to be c... | python | def add_molecule(self, mol, bond=None, base=None, target=None):
"""connect atom group (for SMILES parser)
May requires recalculation of 2D coordinate for drawing
Args:
mol: graphmol.Compound()
the original object will be copied.
bond: Bond object to be c... | [
"def",
"add_molecule",
"(",
"self",
",",
"mol",
",",
"bond",
"=",
"None",
",",
"base",
"=",
"None",
",",
"target",
"=",
"None",
")",
":",
"ai",
"=",
"self",
".",
"available_idx",
"(",
")",
"mapping",
"=",
"{",
"n",
":",
"n",
"+",
"ai",
"-",
"1"... | connect atom group (for SMILES parser)
May requires recalculation of 2D coordinate for drawing
Args:
mol: graphmol.Compound()
the original object will be copied.
bond: Bond object to be connected.
the original will not be copied so be careful.
... | [
"connect",
"atom",
"group",
"(",
"for",
"SMILES",
"parser",
")"
] | fc7fe23a0272554c67671645ab07830b315eeb1b | https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/model/graphmol.py#L145-L166 | train | add a molecule to the atom group |
mojaie/chorus | chorus/draw/qt.py | Qt.save_png_bytes_io | def save_png_bytes_io(self):
""" Save contents as PNG format file(BytesIO object)
Note: DPI is platform dependent due to QPaintDevice DPI handling.
Mac -> 72dpi, Ubuntu -> 96dpi
"""
bytearr = QtCore.QByteArray()
buf = QtCore.QBuffer(bytearr)
buf.open(QtCore.QIODev... | python | def save_png_bytes_io(self):
""" Save contents as PNG format file(BytesIO object)
Note: DPI is platform dependent due to QPaintDevice DPI handling.
Mac -> 72dpi, Ubuntu -> 96dpi
"""
bytearr = QtCore.QByteArray()
buf = QtCore.QBuffer(bytearr)
buf.open(QtCore.QIODev... | [
"def",
"save_png_bytes_io",
"(",
"self",
")",
":",
"bytearr",
"=",
"QtCore",
".",
"QByteArray",
"(",
")",
"buf",
"=",
"QtCore",
".",
"QBuffer",
"(",
"bytearr",
")",
"buf",
".",
"open",
"(",
"QtCore",
".",
"QIODevice",
".",
"WriteOnly",
")",
"self",
"."... | Save contents as PNG format file(BytesIO object)
Note: DPI is platform dependent due to QPaintDevice DPI handling.
Mac -> 72dpi, Ubuntu -> 96dpi | [
"Save",
"contents",
"as",
"PNG",
"format",
"file",
"(",
"BytesIO",
"object",
")",
"Note",
":",
"DPI",
"is",
"platform",
"dependent",
"due",
"to",
"QPaintDevice",
"DPI",
"handling",
".",
"Mac",
"-",
">",
"72dpi",
"Ubuntu",
"-",
">",
"96dpi"
] | fc7fe23a0272554c67671645ab07830b315eeb1b | https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/draw/qt.py#L63-L80 | train | Save the contents as PNG format file and return a bytesIO object. |
mojaie/chorus | chorus/draw/qt.py | Qt._convert | def _convert(self, pos):
""" For QPainter coordinate system, reflect over X axis and
translate from center to top-left
"""
px = pos[0] + self.logical_size.width() / 2
py = self.logical_size.height() / 2 - pos[1]
return px, py | python | def _convert(self, pos):
""" For QPainter coordinate system, reflect over X axis and
translate from center to top-left
"""
px = pos[0] + self.logical_size.width() / 2
py = self.logical_size.height() / 2 - pos[1]
return px, py | [
"def",
"_convert",
"(",
"self",
",",
"pos",
")",
":",
"px",
"=",
"pos",
"[",
"0",
"]",
"+",
"self",
".",
"logical_size",
".",
"width",
"(",
")",
"/",
"2",
"py",
"=",
"self",
".",
"logical_size",
".",
"height",
"(",
")",
"/",
"2",
"-",
"pos",
... | For QPainter coordinate system, reflect over X axis and
translate from center to top-left | [
"For",
"QPainter",
"coordinate",
"system",
"reflect",
"over",
"X",
"axis",
"and",
"translate",
"from",
"center",
"to",
"top",
"-",
"left"
] | fc7fe23a0272554c67671645ab07830b315eeb1b | https://github.com/mojaie/chorus/blob/fc7fe23a0272554c67671645ab07830b315eeb1b/chorus/draw/qt.py#L181-L187 | train | Convert from X axis to Y axis |
lsst-sqre/documenteer | documenteer/sphinxrunner.py | run_sphinx | def run_sphinx(root_dir):
"""Run the Sphinx build process.
Parameters
----------
root_dir : `str`
Root directory of the Sphinx project and content source. This directory
conatains both the root ``index.rst`` file and the ``conf.py``
configuration file.
Returns
-------
... | python | def run_sphinx(root_dir):
"""Run the Sphinx build process.
Parameters
----------
root_dir : `str`
Root directory of the Sphinx project and content source. This directory
conatains both the root ``index.rst`` file and the ``conf.py``
configuration file.
Returns
-------
... | [
"def",
"run_sphinx",
"(",
"root_dir",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"# This replicates what Sphinx's internal command line hander does in",
"# https://github.com/sphinx-doc/sphinx/blob/master/sphinx/cmd/build.py",
"# build_main()",
"# c... | Run the Sphinx build process.
Parameters
----------
root_dir : `str`
Root directory of the Sphinx project and content source. This directory
conatains both the root ``index.rst`` file and the ``conf.py``
configuration file.
Returns
-------
status : `int`
Sphinx ... | [
"Run",
"the",
"Sphinx",
"build",
"process",
"."
] | 75f02901a80042b28d074df1cc1dca32eb8e38c8 | https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxrunner.py#L19-L90 | train | Run the Sphinx build process. |
ehansis/ozelot | examples/leonardo/leonardo/inheritance/pipeline.py | LoadArtists.run | def run(self):
"""Load all artists into the database
"""
df = ArtistsInputData().load()
# get base model instances, merge ID column via the unique wiki ID
# (base and derived model instances must have the same ID values)
base_data = self.client.df_query(self.session.que... | python | def run(self):
"""Load all artists into the database
"""
df = ArtistsInputData().load()
# get base model instances, merge ID column via the unique wiki ID
# (base and derived model instances must have the same ID values)
base_data = self.client.df_query(self.session.que... | [
"def",
"run",
"(",
"self",
")",
":",
"df",
"=",
"ArtistsInputData",
"(",
")",
".",
"load",
"(",
")",
"# get base model instances, merge ID column via the unique wiki ID",
"# (base and derived model instances must have the same ID values)",
"base_data",
"=",
"self",
".",
"cl... | Load all artists into the database | [
"Load",
"all",
"artists",
"into",
"the",
"database"
] | 948675e02eb6fca940450f5cb814f53e97159e5b | https://github.com/ehansis/ozelot/blob/948675e02eb6fca940450f5cb814f53e97159e5b/examples/leonardo/leonardo/inheritance/pipeline.py#L65-L97 | train | Load all artists into the database |
Antojitos/guacamole-cli | src/guacamole_cli/__init__.py | get_settings | def get_settings(config_file):
"""Search and load a configuration file."""
default_settings = {
'general': {
'endpoint': 'http://guacamole.antojitos.io/files/',
'shortener': 'http://t.antojitos.io/api/v1/urls',
}
}
settings = configparser.ConfigParser()
try:
... | python | def get_settings(config_file):
"""Search and load a configuration file."""
default_settings = {
'general': {
'endpoint': 'http://guacamole.antojitos.io/files/',
'shortener': 'http://t.antojitos.io/api/v1/urls',
}
}
settings = configparser.ConfigParser()
try:
... | [
"def",
"get_settings",
"(",
"config_file",
")",
":",
"default_settings",
"=",
"{",
"'general'",
":",
"{",
"'endpoint'",
":",
"'http://guacamole.antojitos.io/files/'",
",",
"'shortener'",
":",
"'http://t.antojitos.io/api/v1/urls'",
",",
"}",
"}",
"settings",
"=",
"conf... | Search and load a configuration file. | [
"Search",
"and",
"load",
"a",
"configuration",
"file",
"."
] | e3ae6b8eb08379ffb784978587bf24b168af73d0 | https://github.com/Antojitos/guacamole-cli/blob/e3ae6b8eb08379ffb784978587bf24b168af73d0/src/guacamole_cli/__init__.py#L16-L41 | train | Search and load a configuration file. |
ShadowBlip/Neteria | neteria/encryption.py | Encryption.encrypt | def encrypt(self, message, public_key):
"""Encrypts a string using a given rsa.PublicKey object. If the message
is larger than the key, it will split it up into a list and encrypt
each line in the list.
Args:
message (string): The string to encrypt.
public_key (rsa.P... | python | def encrypt(self, message, public_key):
"""Encrypts a string using a given rsa.PublicKey object. If the message
is larger than the key, it will split it up into a list and encrypt
each line in the list.
Args:
message (string): The string to encrypt.
public_key (rsa.P... | [
"def",
"encrypt",
"(",
"self",
",",
"message",
",",
"public_key",
")",
":",
"# Get the maximum message length based on the key",
"max_str_len",
"=",
"rsa",
".",
"common",
".",
"byte_size",
"(",
"public_key",
".",
"n",
")",
"-",
"11",
"# If the message is longer than... | Encrypts a string using a given rsa.PublicKey object. If the message
is larger than the key, it will split it up into a list and encrypt
each line in the list.
Args:
message (string): The string to encrypt.
public_key (rsa.PublicKey): The key object used to encrypt the
... | [
"Encrypts",
"a",
"string",
"using",
"a",
"given",
"rsa",
".",
"PublicKey",
"object",
".",
"If",
"the",
"message",
"is",
"larger",
"than",
"the",
"key",
"it",
"will",
"split",
"it",
"up",
"into",
"a",
"list",
"and",
"encrypt",
"each",
"line",
"in",
"the... | 1a8c976eb2beeca0a5a272a34ac58b2c114495a4 | https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/encryption.py#L43-L87 | train | Encrypts a string using a given rsa. PublicKey object. |
ShadowBlip/Neteria | neteria/encryption.py | Encryption.decrypt | def decrypt(self, message):
"""Decrypts a string using our own private key object.
Args:
message (string): The string of the message to decrypt.
Returns:
The unencrypted string.
"""
# Unserialize the encrypted message
message = json.loads(message)
... | python | def decrypt(self, message):
"""Decrypts a string using our own private key object.
Args:
message (string): The string of the message to decrypt.
Returns:
The unencrypted string.
"""
# Unserialize the encrypted message
message = json.loads(message)
... | [
"def",
"decrypt",
"(",
"self",
",",
"message",
")",
":",
"# Unserialize the encrypted message",
"message",
"=",
"json",
".",
"loads",
"(",
"message",
")",
"# Set up a list for the unencrypted lines of the message",
"unencrypted_msg",
"=",
"[",
"]",
"for",
"line",
"in"... | Decrypts a string using our own private key object.
Args:
message (string): The string of the message to decrypt.
Returns:
The unencrypted string. | [
"Decrypts",
"a",
"string",
"using",
"our",
"own",
"private",
"key",
"object",
"."
] | 1a8c976eb2beeca0a5a272a34ac58b2c114495a4 | https://github.com/ShadowBlip/Neteria/blob/1a8c976eb2beeca0a5a272a34ac58b2c114495a4/neteria/encryption.py#L90-L120 | train | Decrypts a string using our own private key object. |
mastro35/flows | flows/Actions/InputWatchdogAction.py | DannyFileSystemEventHandler.on_any_event | def on_any_event(self, event):
"""On any event method"""
for delegate in self.delegates:
if hasattr(delegate, "on_any_event"):
delegate.on_any_event(event) | python | def on_any_event(self, event):
"""On any event method"""
for delegate in self.delegates:
if hasattr(delegate, "on_any_event"):
delegate.on_any_event(event) | [
"def",
"on_any_event",
"(",
"self",
",",
"event",
")",
":",
"for",
"delegate",
"in",
"self",
".",
"delegates",
":",
"if",
"hasattr",
"(",
"delegate",
",",
"\"on_any_event\"",
")",
":",
"delegate",
".",
"on_any_event",
"(",
"event",
")"
] | On any event method | [
"On",
"any",
"event",
"method"
] | 05e488385673a69597b5b39c7728795aa4d5eb18 | https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/Actions/InputWatchdogAction.py#L28-L32 | train | On any event method |
mastro35/flows | flows/Actions/InputWatchdogAction.py | DannyFileSystemEventHandler.on_created | def on_created(self, event):
"""On created method"""
for delegate in self.delegates:
if hasattr(delegate, "on_created"):
delegate.on_created(event) | python | def on_created(self, event):
"""On created method"""
for delegate in self.delegates:
if hasattr(delegate, "on_created"):
delegate.on_created(event) | [
"def",
"on_created",
"(",
"self",
",",
"event",
")",
":",
"for",
"delegate",
"in",
"self",
".",
"delegates",
":",
"if",
"hasattr",
"(",
"delegate",
",",
"\"on_created\"",
")",
":",
"delegate",
".",
"on_created",
"(",
"event",
")"
] | On created method | [
"On",
"created",
"method"
] | 05e488385673a69597b5b39c7728795aa4d5eb18 | https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/Actions/InputWatchdogAction.py#L34-L38 | train | On created method |
mastro35/flows | flows/Actions/InputWatchdogAction.py | DannyFileSystemEventHandler.on_deleted | def on_deleted(self, event):
"""On deleted method"""
for delegate in self.delegates:
if hasattr(delegate, "on_deleted"):
delegate.on_deleted(event) | python | def on_deleted(self, event):
"""On deleted method"""
for delegate in self.delegates:
if hasattr(delegate, "on_deleted"):
delegate.on_deleted(event) | [
"def",
"on_deleted",
"(",
"self",
",",
"event",
")",
":",
"for",
"delegate",
"in",
"self",
".",
"delegates",
":",
"if",
"hasattr",
"(",
"delegate",
",",
"\"on_deleted\"",
")",
":",
"delegate",
".",
"on_deleted",
"(",
"event",
")"
] | On deleted method | [
"On",
"deleted",
"method"
] | 05e488385673a69597b5b39c7728795aa4d5eb18 | https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/Actions/InputWatchdogAction.py#L40-L44 | train | On deleted method |
mastro35/flows | flows/Actions/InputWatchdogAction.py | DannyFileSystemEventHandler.on_modified | def on_modified(self, event):
"""On modified method"""
for delegate in self.delegates:
if hasattr(delegate, "on_modified"):
delegate.on_modified(event) | python | def on_modified(self, event):
"""On modified method"""
for delegate in self.delegates:
if hasattr(delegate, "on_modified"):
delegate.on_modified(event) | [
"def",
"on_modified",
"(",
"self",
",",
"event",
")",
":",
"for",
"delegate",
"in",
"self",
".",
"delegates",
":",
"if",
"hasattr",
"(",
"delegate",
",",
"\"on_modified\"",
")",
":",
"delegate",
".",
"on_modified",
"(",
"event",
")"
] | On modified method | [
"On",
"modified",
"method"
] | 05e488385673a69597b5b39c7728795aa4d5eb18 | https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/Actions/InputWatchdogAction.py#L46-L50 | train | On modified method |
mastro35/flows | flows/Actions/InputWatchdogAction.py | DannyFileSystemEventHandler.on_moved | def on_moved(self, event):
"""On moved method"""
for delegate in self.delegates:
if hasattr(delegate, "on_moved"):
delegate.on_moved(event) | python | def on_moved(self, event):
"""On moved method"""
for delegate in self.delegates:
if hasattr(delegate, "on_moved"):
delegate.on_moved(event) | [
"def",
"on_moved",
"(",
"self",
",",
"event",
")",
":",
"for",
"delegate",
"in",
"self",
".",
"delegates",
":",
"if",
"hasattr",
"(",
"delegate",
",",
"\"on_moved\"",
")",
":",
"delegate",
".",
"on_moved",
"(",
"event",
")"
] | On moved method | [
"On",
"moved",
"method"
] | 05e488385673a69597b5b39c7728795aa4d5eb18 | https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/Actions/InputWatchdogAction.py#L52-L56 | train | On moved method |
mastro35/flows | flows/Actions/InputWatchdogAction.py | WatchdogAction.on_created | def on_created(self, event):
'''Fired when something's been created'''
if self.trigger != "create":
return
action_input = ActionInput(event, "", self.name)
flows.Global.MESSAGE_DISPATCHER.send_message(action_input) | python | def on_created(self, event):
'''Fired when something's been created'''
if self.trigger != "create":
return
action_input = ActionInput(event, "", self.name)
flows.Global.MESSAGE_DISPATCHER.send_message(action_input) | [
"def",
"on_created",
"(",
"self",
",",
"event",
")",
":",
"if",
"self",
".",
"trigger",
"!=",
"\"create\"",
":",
"return",
"action_input",
"=",
"ActionInput",
"(",
"event",
",",
"\"\"",
",",
"self",
".",
"name",
")",
"flows",
".",
"Global",
".",
"MESSA... | Fired when something's been created | [
"Fired",
"when",
"something",
"s",
"been",
"created"
] | 05e488385673a69597b5b39c7728795aa4d5eb18 | https://github.com/mastro35/flows/blob/05e488385673a69597b5b39c7728795aa4d5eb18/flows/Actions/InputWatchdogAction.py#L118-L123 | train | Fired when something s been created |
zsimic/runez | src/runez/heartbeat.py | Heartbeat.start | def start(cls):
"""Start background thread if not already started"""
if cls._thread is None:
cls._thread = threading.Thread(target=cls._run, name="Heartbeat")
cls._thread.daemon = True
cls._thread.start() | python | def start(cls):
"""Start background thread if not already started"""
if cls._thread is None:
cls._thread = threading.Thread(target=cls._run, name="Heartbeat")
cls._thread.daemon = True
cls._thread.start() | [
"def",
"start",
"(",
"cls",
")",
":",
"if",
"cls",
".",
"_thread",
"is",
"None",
":",
"cls",
".",
"_thread",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"cls",
".",
"_run",
",",
"name",
"=",
"\"Heartbeat\"",
")",
"cls",
".",
"_thread",
"."... | Start background thread if not already started | [
"Start",
"background",
"thread",
"if",
"not",
"already",
"started"
] | 14363b719a1aae1528859a501a22d075ce0abfcc | https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/heartbeat.py#L82-L87 | train | Start background thread if not already started |
zsimic/runez | src/runez/heartbeat.py | Heartbeat.add_task | def add_task(cls, task, frequency=None):
"""
:param Task|callable task: Add 'task' to the list of tasks to run periodically
:param int|float|None frequency: Frequency at which to execute the task
"""
with cls._lock:
if not isinstance(task, Task):
t = T... | python | def add_task(cls, task, frequency=None):
"""
:param Task|callable task: Add 'task' to the list of tasks to run periodically
:param int|float|None frequency: Frequency at which to execute the task
"""
with cls._lock:
if not isinstance(task, Task):
t = T... | [
"def",
"add_task",
"(",
"cls",
",",
"task",
",",
"frequency",
"=",
"None",
")",
":",
"with",
"cls",
".",
"_lock",
":",
"if",
"not",
"isinstance",
"(",
"task",
",",
"Task",
")",
":",
"t",
"=",
"Task",
"(",
"name",
"=",
"task",
".",
"__name__",
","... | :param Task|callable task: Add 'task' to the list of tasks to run periodically
:param int|float|None frequency: Frequency at which to execute the task | [
":",
"param",
"Task|callable",
"task",
":",
"Add",
"task",
"to",
"the",
"list",
"of",
"tasks",
"to",
"run",
"periodically",
":",
"param",
"int|float|None",
"frequency",
":",
"Frequency",
"at",
"which",
"to",
"execute",
"the",
"task"
] | 14363b719a1aae1528859a501a22d075ce0abfcc | https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/heartbeat.py#L101-L115 | train | Add a task to the list of tasks to run periodically |
zsimic/runez | src/runez/heartbeat.py | Heartbeat.resolved_task | def resolved_task(cls, task):
"""Task instance representing 'task', if any"""
for t in cls.tasks:
if t is task or t.execute is task:
return t | python | def resolved_task(cls, task):
"""Task instance representing 'task', if any"""
for t in cls.tasks:
if t is task or t.execute is task:
return t | [
"def",
"resolved_task",
"(",
"cls",
",",
"task",
")",
":",
"for",
"t",
"in",
"cls",
".",
"tasks",
":",
"if",
"t",
"is",
"task",
"or",
"t",
".",
"execute",
"is",
"task",
":",
"return",
"t"
] | Task instance representing 'task', if any | [
"Task",
"instance",
"representing",
"task",
"if",
"any"
] | 14363b719a1aae1528859a501a22d075ce0abfcc | https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/heartbeat.py#L118-L122 | train | Return the task instance representing task. |
zsimic/runez | src/runez/heartbeat.py | Heartbeat.remove_task | def remove_task(cls, task):
"""
:param Task|callable task: Remove 'task' from the list of tasks to run periodically
"""
with cls._lock:
if not isinstance(task, Task):
task = cls.resolved_task(task)
if task:
cls.tasks.remove(task)
... | python | def remove_task(cls, task):
"""
:param Task|callable task: Remove 'task' from the list of tasks to run periodically
"""
with cls._lock:
if not isinstance(task, Task):
task = cls.resolved_task(task)
if task:
cls.tasks.remove(task)
... | [
"def",
"remove_task",
"(",
"cls",
",",
"task",
")",
":",
"with",
"cls",
".",
"_lock",
":",
"if",
"not",
"isinstance",
"(",
"task",
",",
"Task",
")",
":",
"task",
"=",
"cls",
".",
"resolved_task",
"(",
"task",
")",
"if",
"task",
":",
"cls",
".",
"... | :param Task|callable task: Remove 'task' from the list of tasks to run periodically | [
":",
"param",
"Task|callable",
"task",
":",
"Remove",
"task",
"from",
"the",
"list",
"of",
"tasks",
"to",
"run",
"periodically"
] | 14363b719a1aae1528859a501a22d075ce0abfcc | https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/heartbeat.py#L125-L136 | train | Removes the task from the list of tasks to run periodically |
zsimic/runez | src/runez/heartbeat.py | Heartbeat._run | def _run(cls):
"""Background thread's main function, execute registered tasks accordingly to their frequencies"""
if cls._thread:
with cls._lock:
# First run: execute each task once to get it started
for task in cls.tasks:
cls._execute_task... | python | def _run(cls):
"""Background thread's main function, execute registered tasks accordingly to their frequencies"""
if cls._thread:
with cls._lock:
# First run: execute each task once to get it started
for task in cls.tasks:
cls._execute_task... | [
"def",
"_run",
"(",
"cls",
")",
":",
"if",
"cls",
".",
"_thread",
":",
"with",
"cls",
".",
"_lock",
":",
"# First run: execute each task once to get it started",
"for",
"task",
"in",
"cls",
".",
"tasks",
":",
"cls",
".",
"_execute_task",
"(",
"task",
")",
... | Background thread's main function, execute registered tasks accordingly to their frequencies | [
"Background",
"thread",
"s",
"main",
"function",
"execute",
"registered",
"tasks",
"accordingly",
"to",
"their",
"frequencies"
] | 14363b719a1aae1528859a501a22d075ce0abfcc | https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/heartbeat.py#L149-L177 | train | This function is called by the background thread when the thread is running. |
wesleybeckner/salty | salty/visualization.py | parity_plot | def parity_plot(X, Y, model, devmodel, axes_labels=None):
"""
A standard method of creating parity plots between predicted and
experimental values for trained models.
Parameters
----------
X: array
experimental input data
Y: array
experimental output data
model: model ob... | python | def parity_plot(X, Y, model, devmodel, axes_labels=None):
"""
A standard method of creating parity plots between predicted and
experimental values for trained models.
Parameters
----------
X: array
experimental input data
Y: array
experimental output data
model: model ob... | [
"def",
"parity_plot",
"(",
"X",
",",
"Y",
",",
"model",
",",
"devmodel",
",",
"axes_labels",
"=",
"None",
")",
":",
"model_outputs",
"=",
"Y",
".",
"shape",
"[",
"1",
"]",
"with",
"plt",
".",
"style",
".",
"context",
"(",
"'seaborn-whitegrid'",
")",
... | A standard method of creating parity plots between predicted and
experimental values for trained models.
Parameters
----------
X: array
experimental input data
Y: array
experimental output data
model: model object
either sklearn or keras ML model
devmodel: dev_model ... | [
"A",
"standard",
"method",
"of",
"creating",
"parity",
"plots",
"between",
"predicted",
"and",
"experimental",
"values",
"for",
"trained",
"models",
"."
] | ef17a97aea3e4f81fcd0359ce85b3438c0e6499b | https://github.com/wesleybeckner/salty/blob/ef17a97aea3e4f81fcd0359ce85b3438c0e6499b/salty/visualization.py#L6-L60 | train | Creates a parity plot between predicted and experimental values for trained models. |
elabftw/elabapy | elabapy/baseapi.py | BaseAPI.__perform_request | def __perform_request(self, url, type=GET, params=None):
"""
This method will perform the real request,
in this way we can customize only the "output" of the API call by
using self.__call_api method.
This method will return the request object.
"""
... | python | def __perform_request(self, url, type=GET, params=None):
"""
This method will perform the real request,
in this way we can customize only the "output" of the API call by
using self.__call_api method.
This method will return the request object.
"""
... | [
"def",
"__perform_request",
"(",
"self",
",",
"url",
",",
"type",
"=",
"GET",
",",
"params",
"=",
"None",
")",
":",
"if",
"params",
"is",
"None",
":",
"params",
"=",
"{",
"}",
"# check we have a token",
"if",
"not",
"self",
".",
"token",
":",
"raise",
... | This method will perform the real request,
in this way we can customize only the "output" of the API call by
using self.__call_api method.
This method will return the request object. | [
"This",
"method",
"will",
"perform",
"the",
"real",
"request",
"in",
"this",
"way",
"we",
"can",
"customize",
"only",
"the",
"output",
"of",
"the",
"API",
"call",
"by",
"using",
"self",
".",
"__call_api",
"method",
".",
"This",
"method",
"will",
"return",
... | 1b970806cccb62d15e307ac7d5783220be1942fb | https://github.com/elabftw/elabapy/blob/1b970806cccb62d15e307ac7d5783220be1942fb/elabapy/baseapi.py#L54-L102 | train | This method will perform the real request by calling the API method with the given url and params. |
elabftw/elabapy | elabapy/baseapi.py | BaseAPI.get_data | def get_data(self, url, type=GET, params=None):
"""
This method is a basic implementation of __call_api that checks
errors too. In cas of success the method will return True or the
content of the response to the request.
"""
if params is None:
para... | python | def get_data(self, url, type=GET, params=None):
"""
This method is a basic implementation of __call_api that checks
errors too. In cas of success the method will return True or the
content of the response to the request.
"""
if params is None:
para... | [
"def",
"get_data",
"(",
"self",
",",
"url",
",",
"type",
"=",
"GET",
",",
"params",
"=",
"None",
")",
":",
"if",
"params",
"is",
"None",
":",
"params",
"=",
"dict",
"(",
")",
"req",
"=",
"self",
".",
"__perform_request",
"(",
"url",
",",
"type",
... | This method is a basic implementation of __call_api that checks
errors too. In cas of success the method will return True or the
content of the response to the request. | [
"This",
"method",
"is",
"a",
"basic",
"implementation",
"of",
"__call_api",
"that",
"checks",
"errors",
"too",
".",
"In",
"cas",
"of",
"success",
"the",
"method",
"will",
"return",
"True",
"or",
"the",
"content",
"of",
"the",
"response",
"to",
"the",
"requ... | 1b970806cccb62d15e307ac7d5783220be1942fb | https://github.com/elabftw/elabapy/blob/1b970806cccb62d15e307ac7d5783220be1942fb/elabapy/baseapi.py#L104-L131 | train | This method is a basic implementation of the get_data method that checks for errors and returns True or the content of the response to the request. |
elabftw/elabapy | elabapy/baseapi.py | BaseAPI.post_data | def post_data(self, url, params):
"""
POST some stuff to change title/date/body or create experiment
"""
url = urljoin(self.endpoint, url)
headers = {'Authorization': self.token}
req = requests.post(url, headers=headers, data=params, verify=False)
if req.stat... | python | def post_data(self, url, params):
"""
POST some stuff to change title/date/body or create experiment
"""
url = urljoin(self.endpoint, url)
headers = {'Authorization': self.token}
req = requests.post(url, headers=headers, data=params, verify=False)
if req.stat... | [
"def",
"post_data",
"(",
"self",
",",
"url",
",",
"params",
")",
":",
"url",
"=",
"urljoin",
"(",
"self",
".",
"endpoint",
",",
"url",
")",
"headers",
"=",
"{",
"'Authorization'",
":",
"self",
".",
"token",
"}",
"req",
"=",
"requests",
".",
"post",
... | POST some stuff to change title/date/body or create experiment | [
"POST",
"some",
"stuff",
"to",
"change",
"title",
"/",
"date",
"/",
"body",
"or",
"create",
"experiment"
] | 1b970806cccb62d15e307ac7d5783220be1942fb | https://github.com/elabftw/elabapy/blob/1b970806cccb62d15e307ac7d5783220be1942fb/elabapy/baseapi.py#L133-L158 | train | POST some stuff to change title date body or create experiment
|
potash/drain | drain/data.py | expand_dates | def expand_dates(df, columns=[]):
"""
generate year, month, day features from specified date features
"""
columns = df.columns.intersection(columns)
df2 = df.reindex(columns=set(df.columns).difference(columns))
for column in columns:
df2[column + '_year'] = df[column].apply(lambda x: x.y... | python | def expand_dates(df, columns=[]):
"""
generate year, month, day features from specified date features
"""
columns = df.columns.intersection(columns)
df2 = df.reindex(columns=set(df.columns).difference(columns))
for column in columns:
df2[column + '_year'] = df[column].apply(lambda x: x.y... | [
"def",
"expand_dates",
"(",
"df",
",",
"columns",
"=",
"[",
"]",
")",
":",
"columns",
"=",
"df",
".",
"columns",
".",
"intersection",
"(",
"columns",
")",
"df2",
"=",
"df",
".",
"reindex",
"(",
"columns",
"=",
"set",
"(",
"df",
".",
"columns",
")",... | generate year, month, day features from specified date features | [
"generate",
"year",
"month",
"day",
"features",
"from",
"specified",
"date",
"features"
] | ddd62081cb9317beb5d21f86c8b4bb196ca3d222 | https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/data.py#L203-L213 | train | Generate year month day features from specified date features |
potash/drain | drain/data.py | binarize | def binarize(df, category_classes, all_classes=True, drop=True,
astype=None, inplace=True, min_freq=None):
"""
Binarize specified categoricals. Works inplace!
Args:
- df: the DataFrame whose columns to binarize
- category_classes: either a dict of (column : [class1, class2, ...... | python | def binarize(df, category_classes, all_classes=True, drop=True,
astype=None, inplace=True, min_freq=None):
"""
Binarize specified categoricals. Works inplace!
Args:
- df: the DataFrame whose columns to binarize
- category_classes: either a dict of (column : [class1, class2, ...... | [
"def",
"binarize",
"(",
"df",
",",
"category_classes",
",",
"all_classes",
"=",
"True",
",",
"drop",
"=",
"True",
",",
"astype",
"=",
"None",
",",
"inplace",
"=",
"True",
",",
"min_freq",
"=",
"None",
")",
":",
"if",
"type",
"(",
"category_classes",
")... | Binarize specified categoricals. Works inplace!
Args:
- df: the DataFrame whose columns to binarize
- category_classes: either a dict of (column : [class1, class2, ...]) pairs
or a collection of column names, in which case classes are
given using df[column].unique()
... | [
"Binarize",
"specified",
"categoricals",
".",
"Works",
"inplace!"
] | ddd62081cb9317beb5d21f86c8b4bb196ca3d222 | https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/data.py#L216-L255 | train | Binarize specified categoricals into a new DataFrame where the columns of the resulting DataFrame are the same. |
potash/drain | drain/data.py | binarize_sets | def binarize_sets(df, columns, cast=False, drop=True, min_freq=None):
"""
Create dummies for the elements of a set-valued column. Operates in place.
Args:
df: data frame
columns: either a dictionary of column: values pairs or a collection of columns.
cast: whether or not to cast valu... | python | def binarize_sets(df, columns, cast=False, drop=True, min_freq=None):
"""
Create dummies for the elements of a set-valued column. Operates in place.
Args:
df: data frame
columns: either a dictionary of column: values pairs or a collection of columns.
cast: whether or not to cast valu... | [
"def",
"binarize_sets",
"(",
"df",
",",
"columns",
",",
"cast",
"=",
"False",
",",
"drop",
"=",
"True",
",",
"min_freq",
"=",
"None",
")",
":",
"for",
"column",
"in",
"columns",
":",
"d",
"=",
"df",
"[",
"column",
"]",
".",
"dropna",
"(",
")",
"#... | Create dummies for the elements of a set-valued column. Operates in place.
Args:
df: data frame
columns: either a dictionary of column: values pairs or a collection of columns.
cast: whether or not to cast values to set
drop: whether or not to drop the binarized columns
TODO: mak... | [
"Create",
"dummies",
"for",
"the",
"elements",
"of",
"a",
"set",
"-",
"valued",
"column",
".",
"Operates",
"in",
"place",
".",
"Args",
":",
"df",
":",
"data",
"frame",
"columns",
":",
"either",
"a",
"dictionary",
"of",
"column",
":",
"values",
"pairs",
... | ddd62081cb9317beb5d21f86c8b4bb196ca3d222 | https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/data.py#L258-L286 | train | Binarize a set of items into a set of items. |
potash/drain | drain/data.py | counts_to_dicts | def counts_to_dicts(df, column):
"""
convert (values, counts) as returned by aggregate.aggregate_counts() to dicts
makes expand_counts much faster
"""
# index where there are counts and they aren't null
d = df[column].apply(lambda c: pd.notnull(c) and len(c[0]) > 0)
return df.loc[d, column].... | python | def counts_to_dicts(df, column):
"""
convert (values, counts) as returned by aggregate.aggregate_counts() to dicts
makes expand_counts much faster
"""
# index where there are counts and they aren't null
d = df[column].apply(lambda c: pd.notnull(c) and len(c[0]) > 0)
return df.loc[d, column].... | [
"def",
"counts_to_dicts",
"(",
"df",
",",
"column",
")",
":",
"# index where there are counts and they aren't null",
"d",
"=",
"df",
"[",
"column",
"]",
".",
"apply",
"(",
"lambda",
"c",
":",
"pd",
".",
"notnull",
"(",
"c",
")",
"and",
"len",
"(",
"c",
"... | convert (values, counts) as returned by aggregate.aggregate_counts() to dicts
makes expand_counts much faster | [
"convert",
"(",
"values",
"counts",
")",
"as",
"returned",
"by",
"aggregate",
".",
"aggregate_counts",
"()",
"to",
"dicts",
"makes",
"expand_counts",
"much",
"faster"
] | ddd62081cb9317beb5d21f86c8b4bb196ca3d222 | https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/data.py#L289-L296 | train | converts counts as returned by aggregate. aggregate_counts to dicts
makes expand_counts much faster |
potash/drain | drain/data.py | expand_counts | def expand_counts(df, column, values=None):
"""
expand a column containing value:count dictionaries
"""
d = counts_to_dicts(df, column)
if len(d) > 0:
if values is None:
values = set(np.concatenate(d.apply(lambda c: c.keys()).values))
for value in values:
name... | python | def expand_counts(df, column, values=None):
"""
expand a column containing value:count dictionaries
"""
d = counts_to_dicts(df, column)
if len(d) > 0:
if values is None:
values = set(np.concatenate(d.apply(lambda c: c.keys()).values))
for value in values:
name... | [
"def",
"expand_counts",
"(",
"df",
",",
"column",
",",
"values",
"=",
"None",
")",
":",
"d",
"=",
"counts_to_dicts",
"(",
"df",
",",
"column",
")",
"if",
"len",
"(",
"d",
")",
">",
"0",
":",
"if",
"values",
"is",
"None",
":",
"values",
"=",
"set"... | expand a column containing value:count dictionaries | [
"expand",
"a",
"column",
"containing",
"value",
":",
"count",
"dictionaries"
] | ddd62081cb9317beb5d21f86c8b4bb196ca3d222 | https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/data.py#L299-L311 | train | expand a column containing value : count dictionaries |
potash/drain | drain/data.py | impute | def impute(X, value=None, train=None, dropna=True, inplace=True):
"""
Performs mean imputation on a pandas dataframe.
Args:
train: an optional training mask with which to compute the mean
value: instead of computing the mean, use this as the value argument to fillna
dropna: whether t... | python | def impute(X, value=None, train=None, dropna=True, inplace=True):
"""
Performs mean imputation on a pandas dataframe.
Args:
train: an optional training mask with which to compute the mean
value: instead of computing the mean, use this as the value argument to fillna
dropna: whether t... | [
"def",
"impute",
"(",
"X",
",",
"value",
"=",
"None",
",",
"train",
"=",
"None",
",",
"dropna",
"=",
"True",
",",
"inplace",
"=",
"True",
")",
":",
"if",
"value",
"is",
"None",
":",
"Xfit",
"=",
"X",
"[",
"train",
"]",
"if",
"train",
"is",
"not... | Performs mean imputation on a pandas dataframe.
Args:
train: an optional training mask with which to compute the mean
value: instead of computing the mean, use this as the value argument to fillna
dropna: whether to drop all null columns
inplace: whether to perform the imputation inp... | [
"Performs",
"mean",
"imputation",
"on",
"a",
"pandas",
"dataframe",
".",
"Args",
":",
"train",
":",
"an",
"optional",
"training",
"mask",
"with",
"which",
"to",
"compute",
"the",
"mean",
"value",
":",
"instead",
"of",
"computing",
"the",
"mean",
"use",
"th... | ddd62081cb9317beb5d21f86c8b4bb196ca3d222 | https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/data.py#L365-L396 | train | Performs mean imputation on a pandas dataframe. |
potash/drain | drain/data.py | select_regexes | def select_regexes(strings, regexes):
"""
select subset of strings matching a regex
treats strings as a set
"""
strings = set(strings)
select = set()
if isinstance(strings, collections.Iterable):
for r in regexes:
s = set(filter(re.compile('^' + r + '$').search, strings))... | python | def select_regexes(strings, regexes):
"""
select subset of strings matching a regex
treats strings as a set
"""
strings = set(strings)
select = set()
if isinstance(strings, collections.Iterable):
for r in regexes:
s = set(filter(re.compile('^' + r + '$').search, strings))... | [
"def",
"select_regexes",
"(",
"strings",
",",
"regexes",
")",
":",
"strings",
"=",
"set",
"(",
"strings",
")",
"select",
"=",
"set",
"(",
")",
"if",
"isinstance",
"(",
"strings",
",",
"collections",
".",
"Iterable",
")",
":",
"for",
"r",
"in",
"regexes... | select subset of strings matching a regex
treats strings as a set | [
"select",
"subset",
"of",
"strings",
"matching",
"a",
"regex",
"treats",
"strings",
"as",
"a",
"set"
] | ddd62081cb9317beb5d21f86c8b4bb196ca3d222 | https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/data.py#L399-L413 | train | select subset of strings matching a regex
treats strings as a set
|
potash/drain | drain/data.py | date_censor_sql | def date_censor_sql(date_column, today, column=None):
"""
if today is None, then no censoring
otherwise replace each column with:
CASE WHEN {date_column} < '{today}' THEN {column} ELSE null END
"""
if column is None:
column = date_column
if today is None:
return column
... | python | def date_censor_sql(date_column, today, column=None):
"""
if today is None, then no censoring
otherwise replace each column with:
CASE WHEN {date_column} < '{today}' THEN {column} ELSE null END
"""
if column is None:
column = date_column
if today is None:
return column
... | [
"def",
"date_censor_sql",
"(",
"date_column",
",",
"today",
",",
"column",
"=",
"None",
")",
":",
"if",
"column",
"is",
"None",
":",
"column",
"=",
"date_column",
"if",
"today",
"is",
"None",
":",
"return",
"column",
"else",
":",
"return",
"\"(CASE WHEN {d... | if today is None, then no censoring
otherwise replace each column with:
CASE WHEN {date_column} < '{today}' THEN {column} ELSE null END | [
"if",
"today",
"is",
"None",
"then",
"no",
"censoring",
"otherwise",
"replace",
"each",
"column",
"with",
":",
"CASE",
"WHEN",
"{",
"date_column",
"}",
"<",
"{",
"today",
"}",
"THEN",
"{",
"column",
"}",
"ELSE",
"null",
"END"
] | ddd62081cb9317beb5d21f86c8b4bb196ca3d222 | https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/data.py#L457-L470 | train | Return a SQL statement that can be used to censor the log entries for a given date. |
potash/drain | drain/data.py | revise_helper | def revise_helper(query):
"""
given sql containing a "CREATE TABLE {table_name} AS ({query})"
returns table_name, query
"""
match = re.search(extract_sql_regex, query, re.DOTALL | re.I)
return match.group(1), match.group(2) | python | def revise_helper(query):
"""
given sql containing a "CREATE TABLE {table_name} AS ({query})"
returns table_name, query
"""
match = re.search(extract_sql_regex, query, re.DOTALL | re.I)
return match.group(1), match.group(2) | [
"def",
"revise_helper",
"(",
"query",
")",
":",
"match",
"=",
"re",
".",
"search",
"(",
"extract_sql_regex",
",",
"query",
",",
"re",
".",
"DOTALL",
"|",
"re",
".",
"I",
")",
"return",
"match",
".",
"group",
"(",
"1",
")",
",",
"match",
".",
"group... | given sql containing a "CREATE TABLE {table_name} AS ({query})"
returns table_name, query | [
"given",
"sql",
"containing",
"a",
"CREATE",
"TABLE",
"{",
"table_name",
"}",
"AS",
"(",
"{",
"query",
"}",
")",
"returns",
"table_name",
"query"
] | ddd62081cb9317beb5d21f86c8b4bb196ca3d222 | https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/data.py#L477-L483 | train | This is a helper function that is used to revise the table name and the query. |
potash/drain | drain/data.py | revise_sql | def revise_sql(query, id_column, output_table, max_date_column,
min_date_column, date_column, date, source_id_column=None):
"""
Given an expensive query that aggregates temporal data,
Revise the results to censor before a particular date
"""
if source_id_column is None:
source... | python | def revise_sql(query, id_column, output_table, max_date_column,
min_date_column, date_column, date, source_id_column=None):
"""
Given an expensive query that aggregates temporal data,
Revise the results to censor before a particular date
"""
if source_id_column is None:
source... | [
"def",
"revise_sql",
"(",
"query",
",",
"id_column",
",",
"output_table",
",",
"max_date_column",
",",
"min_date_column",
",",
"date_column",
",",
"date",
",",
"source_id_column",
"=",
"None",
")",
":",
"if",
"source_id_column",
"is",
"None",
":",
"source_id_col... | Given an expensive query that aggregates temporal data,
Revise the results to censor before a particular date | [
"Given",
"an",
"expensive",
"query",
"that",
"aggregates",
"temporal",
"data",
"Revise",
"the",
"results",
"to",
"censor",
"before",
"a",
"particular",
"date"
] | ddd62081cb9317beb5d21f86c8b4bb196ca3d222 | https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/data.py#L486-L518 | train | Given an expensive query that aggregates temporal data and a particular date revise the results to censor before a particular date. |
potash/drain | drain/data.py | date_select | def date_select(df, date_column, date, delta, max_date_column=None):
"""
given a series an end date and number of days, return subset in the date range
if delta is None then there is no starting date
if max_date_column is specified then look for rows where the interval
[date_column, max_date_col... | python | def date_select(df, date_column, date, delta, max_date_column=None):
"""
given a series an end date and number of days, return subset in the date range
if delta is None then there is no starting date
if max_date_column is specified then look for rows where the interval
[date_column, max_date_col... | [
"def",
"date_select",
"(",
"df",
",",
"date_column",
",",
"date",
",",
"delta",
",",
"max_date_column",
"=",
"None",
")",
":",
"delta",
"=",
"parse_delta",
"(",
"delta",
")",
"if",
"delta",
":",
"start_date",
"=",
"date",
"-",
"delta",
"if",
"not",
"ma... | given a series an end date and number of days, return subset in the date range
if delta is None then there is no starting date
if max_date_column is specified then look for rows where the interval
[date_column, max_date_column] intersects [date-delta, date+delta) | [
"given",
"a",
"series",
"an",
"end",
"date",
"and",
"number",
"of",
"days",
"return",
"subset",
"in",
"the",
"date",
"range",
"if",
"delta",
"is",
"None",
"then",
"there",
"is",
"no",
"starting",
"date",
"if",
"max_date_column",
"is",
"specified",
"then",
... | ddd62081cb9317beb5d21f86c8b4bb196ca3d222 | https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/data.py#L573-L597 | train | return subset of the date range
given a series an end date and number of days |
potash/drain | drain/data.py | date_censor | def date_censor(df, date_columns, date):
"""
a dictionary of date_column: [dependent_column1, ...] pairs
censor the dependent columns when the date column is before the given end_date
then censor the date column itself
"""
for date_column, censor_columns in date_columns.items():
for cens... | python | def date_censor(df, date_columns, date):
"""
a dictionary of date_column: [dependent_column1, ...] pairs
censor the dependent columns when the date column is before the given end_date
then censor the date column itself
"""
for date_column, censor_columns in date_columns.items():
for cens... | [
"def",
"date_censor",
"(",
"df",
",",
"date_columns",
",",
"date",
")",
":",
"for",
"date_column",
",",
"censor_columns",
"in",
"date_columns",
".",
"items",
"(",
")",
":",
"for",
"censor_column",
"in",
"censor_columns",
":",
"df",
"[",
"censor_column",
"]",... | a dictionary of date_column: [dependent_column1, ...] pairs
censor the dependent columns when the date column is before the given end_date
then censor the date column itself | [
"a",
"dictionary",
"of",
"date_column",
":",
"[",
"dependent_column1",
"...",
"]",
"pairs",
"censor",
"the",
"dependent",
"columns",
"when",
"the",
"date",
"column",
"is",
"before",
"the",
"given",
"end_date",
"then",
"censor",
"the",
"date",
"column",
"itself... | ddd62081cb9317beb5d21f86c8b4bb196ca3d222 | https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/data.py#L600-L612 | train | censor the censored items in a dataframe that are before a given date |
potash/drain | drain/data.py | parse_delta | def parse_delta(s):
"""
parse a string to a delta
'all' is represented by None
"""
if s == 'all':
return None
else:
ls = delta_regex.findall(s)
if len(ls) == 1:
return relativedelta(**{delta_chars[ls[0][1]]: int(ls[0][0])})
else:
raise Valu... | python | def parse_delta(s):
"""
parse a string to a delta
'all' is represented by None
"""
if s == 'all':
return None
else:
ls = delta_regex.findall(s)
if len(ls) == 1:
return relativedelta(**{delta_chars[ls[0][1]]: int(ls[0][0])})
else:
raise Valu... | [
"def",
"parse_delta",
"(",
"s",
")",
":",
"if",
"s",
"==",
"'all'",
":",
"return",
"None",
"else",
":",
"ls",
"=",
"delta_regex",
".",
"findall",
"(",
"s",
")",
"if",
"len",
"(",
"ls",
")",
"==",
"1",
":",
"return",
"relativedelta",
"(",
"*",
"*"... | parse a string to a delta
'all' is represented by None | [
"parse",
"a",
"string",
"to",
"a",
"delta",
"all",
"is",
"represented",
"by",
"None"
] | ddd62081cb9317beb5d21f86c8b4bb196ca3d222 | https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/data.py#L623-L635 | train | parse a string to a delta
elastic elastic |
potash/drain | drain/data.py | Column.apply | def apply(self, df):
"""Takes a pd.DataFrame and returns the newly defined column, i.e.
a pd.Series that has the same index as `df`.
"""
if hasattr(self.definition, '__call__'):
r = self.definition(df)
elif self.definition in df.columns:
r = df[self.defini... | python | def apply(self, df):
"""Takes a pd.DataFrame and returns the newly defined column, i.e.
a pd.Series that has the same index as `df`.
"""
if hasattr(self.definition, '__call__'):
r = self.definition(df)
elif self.definition in df.columns:
r = df[self.defini... | [
"def",
"apply",
"(",
"self",
",",
"df",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"definition",
",",
"'__call__'",
")",
":",
"r",
"=",
"self",
".",
"definition",
"(",
"df",
")",
"elif",
"self",
".",
"definition",
"in",
"df",
".",
"columns",
":",... | Takes a pd.DataFrame and returns the newly defined column, i.e.
a pd.Series that has the same index as `df`. | [
"Takes",
"a",
"pd",
".",
"DataFrame",
"and",
"returns",
"the",
"newly",
"defined",
"column",
"i",
".",
"e",
".",
"a",
"pd",
".",
"Series",
"that",
"has",
"the",
"same",
"index",
"as",
"df",
"."
] | ddd62081cb9317beb5d21f86c8b4bb196ca3d222 | https://github.com/potash/drain/blob/ddd62081cb9317beb5d21f86c8b4bb196ca3d222/drain/data.py#L44-L56 | train | Takes a pd. DataFrame and returns the newly defined column i. e. a pd. Series that has the same index as df. |
lingz/pyphone | pyphone/pyphone.py | phonex | def phonex(word, language="english"):
"""
Short for phone index, maps a word onto a sequence of phone clusters
Strips non supported characters (for english, non alpha characters)
"""
phone_variants = phoneticize(word)
mappings = cluster_phones(language)
results = []
for phone_variant in ... | python | def phonex(word, language="english"):
"""
Short for phone index, maps a word onto a sequence of phone clusters
Strips non supported characters (for english, non alpha characters)
"""
phone_variants = phoneticize(word)
mappings = cluster_phones(language)
results = []
for phone_variant in ... | [
"def",
"phonex",
"(",
"word",
",",
"language",
"=",
"\"english\"",
")",
":",
"phone_variants",
"=",
"phoneticize",
"(",
"word",
")",
"mappings",
"=",
"cluster_phones",
"(",
"language",
")",
"results",
"=",
"[",
"]",
"for",
"phone_variant",
"in",
"phone_varia... | Short for phone index, maps a word onto a sequence of phone clusters
Strips non supported characters (for english, non alpha characters) | [
"Short",
"for",
"phone",
"index",
"maps",
"a",
"word",
"onto",
"a",
"sequence",
"of",
"phone",
"clusters",
"Strips",
"non",
"supported",
"characters",
"(",
"for",
"english",
"non",
"alpha",
"characters",
")"
] | 719fbf5518c7c045db8e786339c69ba9780da405 | https://github.com/lingz/pyphone/blob/719fbf5518c7c045db8e786339c69ba9780da405/pyphone/pyphone.py#L166-L182 | train | Short for phone index maps a word onto a sequence of phone clusters. |
untwisted/untwisted | untwisted/iputils.py | ip_to_long | def ip_to_long (ip):
"""
Convert ip address to a network byte order 32-bit integer.
"""
quad = ip.split('.')
if len(quad) == 1:
quad = quad + [0, 0, 0]
elif len(quad) < 4:
host = quad[-1:]
quad = quad[:-1] + [0,] * (4 - len(quad)) + host
lip = 0
for q in quad:
... | python | def ip_to_long (ip):
"""
Convert ip address to a network byte order 32-bit integer.
"""
quad = ip.split('.')
if len(quad) == 1:
quad = quad + [0, 0, 0]
elif len(quad) < 4:
host = quad[-1:]
quad = quad[:-1] + [0,] * (4 - len(quad)) + host
lip = 0
for q in quad:
... | [
"def",
"ip_to_long",
"(",
"ip",
")",
":",
"quad",
"=",
"ip",
".",
"split",
"(",
"'.'",
")",
"if",
"len",
"(",
"quad",
")",
"==",
"1",
":",
"quad",
"=",
"quad",
"+",
"[",
"0",
",",
"0",
",",
"0",
"]",
"elif",
"len",
"(",
"quad",
")",
"<",
... | Convert ip address to a network byte order 32-bit integer. | [
"Convert",
"ip",
"address",
"to",
"a",
"network",
"byte",
"order",
"32",
"-",
"bit",
"integer",
"."
] | 8a8d9c8a8d0f3452d5de67cd760297bb5759f637 | https://github.com/untwisted/untwisted/blob/8a8d9c8a8d0f3452d5de67cd760297bb5759f637/untwisted/iputils.py#L1-L15 | train | Convert an ip address to a network byte order 32 - bit integer. |
lsst-sqre/documenteer | documenteer/sphinxext/lsstdocushare.py | lsst_doc_shortlink_role | def lsst_doc_shortlink_role(name, rawtext, text, lineno, inliner,
options=None, content=None):
"""Link to LSST documents given their handle using LSST's ls.st link
shortener.
Example::
:ldm:`151`
"""
options = options or {}
content = content or []
node =... | python | def lsst_doc_shortlink_role(name, rawtext, text, lineno, inliner,
options=None, content=None):
"""Link to LSST documents given their handle using LSST's ls.st link
shortener.
Example::
:ldm:`151`
"""
options = options or {}
content = content or []
node =... | [
"def",
"lsst_doc_shortlink_role",
"(",
"name",
",",
"rawtext",
",",
"text",
",",
"lineno",
",",
"inliner",
",",
"options",
"=",
"None",
",",
"content",
"=",
"None",
")",
":",
"options",
"=",
"options",
"or",
"{",
"}",
"content",
"=",
"content",
"or",
"... | Link to LSST documents given their handle using LSST's ls.st link
shortener.
Example::
:ldm:`151` | [
"Link",
"to",
"LSST",
"documents",
"given",
"their",
"handle",
"using",
"LSST",
"s",
"ls",
".",
"st",
"link",
"shortener",
"."
] | 75f02901a80042b28d074df1cc1dca32eb8e38c8 | https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/lsstdocushare.py#L6-L21 | train | Link to LSST documents given their handle using LSST s ls. st link
shortener. |
lsst-sqre/documenteer | documenteer/sphinxext/lsstdocushare.py | lsst_doc_shortlink_titlecase_display_role | def lsst_doc_shortlink_titlecase_display_role(
name, rawtext, text, lineno, inliner, options=None, content=None):
"""Link to LSST documents given their handle using LSST's ls.st link
shortener with the document handle displayed in title case.
This role is useful for Document, Report, Minutes, and C... | python | def lsst_doc_shortlink_titlecase_display_role(
name, rawtext, text, lineno, inliner, options=None, content=None):
"""Link to LSST documents given their handle using LSST's ls.st link
shortener with the document handle displayed in title case.
This role is useful for Document, Report, Minutes, and C... | [
"def",
"lsst_doc_shortlink_titlecase_display_role",
"(",
"name",
",",
"rawtext",
",",
"text",
",",
"lineno",
",",
"inliner",
",",
"options",
"=",
"None",
",",
"content",
"=",
"None",
")",
":",
"options",
"=",
"options",
"or",
"{",
"}",
"content",
"=",
"con... | Link to LSST documents given their handle using LSST's ls.st link
shortener with the document handle displayed in title case.
This role is useful for Document, Report, Minutes, and Collection
DocuShare handles.
Example::
:document:`1` | [
"Link",
"to",
"LSST",
"documents",
"given",
"their",
"handle",
"using",
"LSST",
"s",
"ls",
".",
"st",
"link",
"shortener",
"with",
"the",
"document",
"handle",
"displayed",
"in",
"title",
"case",
"."
] | 75f02901a80042b28d074df1cc1dca32eb8e38c8 | https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/sphinxext/lsstdocushare.py#L24-L42 | train | Link to LSST documents given their handle using LSST s ls. st link
shortener with the document handle displayed in title case. |
lsst-sqre/documenteer | documenteer/bin/refreshlsstbib.py | run | def run():
"""Command line entrypoint for the ``refresh-lsst-bib`` program.
"""
args = parse_args()
if args.verbose:
log_level = logging.DEBUG
else:
log_level = logging.INFO
logging.basicConfig(
level=log_level,
format='%(asctime)s %(levelname)s %(name)s: %(messa... | python | def run():
"""Command line entrypoint for the ``refresh-lsst-bib`` program.
"""
args = parse_args()
if args.verbose:
log_level = logging.DEBUG
else:
log_level = logging.INFO
logging.basicConfig(
level=log_level,
format='%(asctime)s %(levelname)s %(name)s: %(messa... | [
"def",
"run",
"(",
")",
":",
"args",
"=",
"parse_args",
"(",
")",
"if",
"args",
".",
"verbose",
":",
"log_level",
"=",
"logging",
".",
"DEBUG",
"else",
":",
"log_level",
"=",
"logging",
".",
"INFO",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"... | Command line entrypoint for the ``refresh-lsst-bib`` program. | [
"Command",
"line",
"entrypoint",
"for",
"the",
"refresh",
"-",
"lsst",
"-",
"bib",
"program",
"."
] | 75f02901a80042b28d074df1cc1dca32eb8e38c8 | https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/bin/refreshlsstbib.py#L20-L43 | train | Command line entrypoint for the refresh - lsst - bib program. |
lsst-sqre/documenteer | documenteer/bin/refreshlsstbib.py | process_bib_files | def process_bib_files(local_dir):
"""Run the refresh-lsst-bib program's logic: iterates through bib URLs,
downloads the file from GitHub, and writes it to a local directory.
Parameters
----------
local_dir : `str`
Directory to write bib files into.
Returns
-------
error_count :... | python | def process_bib_files(local_dir):
"""Run the refresh-lsst-bib program's logic: iterates through bib URLs,
downloads the file from GitHub, and writes it to a local directory.
Parameters
----------
local_dir : `str`
Directory to write bib files into.
Returns
-------
error_count :... | [
"def",
"process_bib_files",
"(",
"local_dir",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"# check the output directory exists",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"local_dir",
")",
":",
"logger",
".",
"error",
... | Run the refresh-lsst-bib program's logic: iterates through bib URLs,
downloads the file from GitHub, and writes it to a local directory.
Parameters
----------
local_dir : `str`
Directory to write bib files into.
Returns
-------
error_count : `int`
Number of download errors. | [
"Run",
"the",
"refresh",
"-",
"lsst",
"-",
"bib",
"program",
"s",
"logic",
":",
"iterates",
"through",
"bib",
"URLs",
"downloads",
"the",
"file",
"from",
"GitHub",
"and",
"writes",
"it",
"to",
"a",
"local",
"directory",
"."
] | 75f02901a80042b28d074df1cc1dca32eb8e38c8 | https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/bin/refreshlsstbib.py#L73-L115 | train | Download and process the bib files from GitHub and write them to a local directory. |
lsst-sqre/documenteer | documenteer/stackdocs/build.py | run_build_cli | def run_build_cli():
"""Command line entrypoint for the ``build-stack-docs`` program.
"""
args = parse_args()
if args.verbose:
log_level = logging.DEBUG
else:
log_level = logging.INFO
logging.basicConfig(
level=log_level,
format='%(asctime)s %(levelname)s %(name)... | python | def run_build_cli():
"""Command line entrypoint for the ``build-stack-docs`` program.
"""
args = parse_args()
if args.verbose:
log_level = logging.DEBUG
else:
log_level = logging.INFO
logging.basicConfig(
level=log_level,
format='%(asctime)s %(levelname)s %(name)... | [
"def",
"run_build_cli",
"(",
")",
":",
"args",
"=",
"parse_args",
"(",
")",
"if",
"args",
".",
"verbose",
":",
"log_level",
"=",
"logging",
".",
"DEBUG",
"else",
":",
"log_level",
"=",
"logging",
".",
"INFO",
"logging",
".",
"basicConfig",
"(",
"level",
... | Command line entrypoint for the ``build-stack-docs`` program. | [
"Command",
"line",
"entrypoint",
"for",
"the",
"build",
"-",
"stack",
"-",
"docs",
"program",
"."
] | 75f02901a80042b28d074df1cc1dca32eb8e38c8 | https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/stackdocs/build.py#L25-L48 | train | Command line entrypoint for the build - stack - docs program. |
lsst-sqre/documenteer | documenteer/stackdocs/build.py | build_stack_docs | def build_stack_docs(root_project_dir, skippedNames=None):
"""Build stack Sphinx documentation (main entrypoint).
Parameters
----------
root_project_dir : `str`
Path to the root directory of the main documentation project. This
is the directory containing the ``conf.py`` file.
skipp... | python | def build_stack_docs(root_project_dir, skippedNames=None):
"""Build stack Sphinx documentation (main entrypoint).
Parameters
----------
root_project_dir : `str`
Path to the root directory of the main documentation project. This
is the directory containing the ``conf.py`` file.
skipp... | [
"def",
"build_stack_docs",
"(",
"root_project_dir",
",",
"skippedNames",
"=",
"None",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"# Create the directory where module content is symlinked",
"# NOTE: this path is hard-wired in for pipelines.lsst.i... | Build stack Sphinx documentation (main entrypoint).
Parameters
----------
root_project_dir : `str`
Path to the root directory of the main documentation project. This
is the directory containing the ``conf.py`` file.
skippedNames : `list`, optional
Optional list of packages to sk... | [
"Build",
"stack",
"Sphinx",
"documentation",
"(",
"main",
"entrypoint",
")",
"."
] | 75f02901a80042b28d074df1cc1dca32eb8e38c8 | https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/stackdocs/build.py#L51-L130 | train | Build the stack Sphinx documentation for the given project. |
lsst-sqre/documenteer | documenteer/stackdocs/build.py | parse_args | def parse_args():
"""Create an argument parser for the ``build-stack-docs`` program.
Returns
-------
args : `argparse.Namespace`
Parsed argument object.
"""
parser = argparse.ArgumentParser(
description="Build a Sphinx documentation site for an EUPS stack, "
... | python | def parse_args():
"""Create an argument parser for the ``build-stack-docs`` program.
Returns
-------
args : `argparse.Namespace`
Parsed argument object.
"""
parser = argparse.ArgumentParser(
description="Build a Sphinx documentation site for an EUPS stack, "
... | [
"def",
"parse_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Build a Sphinx documentation site for an EUPS stack, \"",
"\"such as pipelines.lsst.io.\"",
",",
"epilog",
"=",
"\"Version {0}\"",
".",
"format",
"(",
"__vers... | Create an argument parser for the ``build-stack-docs`` program.
Returns
-------
args : `argparse.Namespace`
Parsed argument object. | [
"Create",
"an",
"argument",
"parser",
"for",
"the",
"build",
"-",
"stack",
"-",
"docs",
"program",
"."
] | 75f02901a80042b28d074df1cc1dca32eb8e38c8 | https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/stackdocs/build.py#L133-L156 | train | Create an argument parser for the build - stack - docs program. |
lsst-sqre/documenteer | documenteer/stackdocs/build.py | discover_setup_packages | def discover_setup_packages():
"""Summarize packages currently set up by EUPS, listing their
set up directories and EUPS version names.
Returns
-------
packages : `dict`
Dictionary with keys that are EUPS package names. Values are
dictionaries with fields:
- ``'dir'``: absolut... | python | def discover_setup_packages():
"""Summarize packages currently set up by EUPS, listing their
set up directories and EUPS version names.
Returns
-------
packages : `dict`
Dictionary with keys that are EUPS package names. Values are
dictionaries with fields:
- ``'dir'``: absolut... | [
"def",
"discover_setup_packages",
"(",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"# Not a PyPI dependency; assumed to be available in the build environment.",
"import",
"eups",
"eups_client",
"=",
"eups",
".",
"Eups",
"(",
")",
"product... | Summarize packages currently set up by EUPS, listing their
set up directories and EUPS version names.
Returns
-------
packages : `dict`
Dictionary with keys that are EUPS package names. Values are
dictionaries with fields:
- ``'dir'``: absolute directory path of the set up package... | [
"Summarize",
"packages",
"currently",
"set",
"up",
"by",
"EUPS",
"listing",
"their",
"set",
"up",
"directories",
"and",
"EUPS",
"version",
"names",
"."
] | 75f02901a80042b28d074df1cc1dca32eb8e38c8 | https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/stackdocs/build.py#L159-L198 | train | Return a dictionary with keys that are set up by EUPS listing theirir
ridge set up directories and EUPS version names. |
lsst-sqre/documenteer | documenteer/stackdocs/build.py | find_table_file | def find_table_file(root_project_dir):
"""Find the EUPS table file for a project.
Parameters
----------
root_project_dir : `str`
Path to the root directory of the main documentation project. This
is the directory containing the ``conf.py`` file and a ``ups``
directory.
Retu... | python | def find_table_file(root_project_dir):
"""Find the EUPS table file for a project.
Parameters
----------
root_project_dir : `str`
Path to the root directory of the main documentation project. This
is the directory containing the ``conf.py`` file and a ``ups``
directory.
Retu... | [
"def",
"find_table_file",
"(",
"root_project_dir",
")",
":",
"ups_dir_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"root_project_dir",
",",
"'ups'",
")",
"table_path",
"=",
"None",
"for",
"name",
"in",
"os",
".",
"listdir",
"(",
"ups_dir_path",
")",
":... | Find the EUPS table file for a project.
Parameters
----------
root_project_dir : `str`
Path to the root directory of the main documentation project. This
is the directory containing the ``conf.py`` file and a ``ups``
directory.
Returns
-------
table_path : `str`
... | [
"Find",
"the",
"EUPS",
"table",
"file",
"for",
"a",
"project",
"."
] | 75f02901a80042b28d074df1cc1dca32eb8e38c8 | https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/stackdocs/build.py#L201-L225 | train | Find the EUPS table file for a project. |
lsst-sqre/documenteer | documenteer/stackdocs/build.py | list_packages_in_eups_table | def list_packages_in_eups_table(table_text):
"""List the names of packages that are required by an EUPS table file.
Parameters
----------
table_text : `str`
The text content of an EUPS table file.
Returns
-------
names : `list` [`str`]
List of package names that are require... | python | def list_packages_in_eups_table(table_text):
"""List the names of packages that are required by an EUPS table file.
Parameters
----------
table_text : `str`
The text content of an EUPS table file.
Returns
-------
names : `list` [`str`]
List of package names that are require... | [
"def",
"list_packages_in_eups_table",
"(",
"table_text",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"# This pattern matches required product names in EUPS table files.",
"pattern",
"=",
"re",
".",
"compile",
"(",
"r'setupRequired\\((?P<name>... | List the names of packages that are required by an EUPS table file.
Parameters
----------
table_text : `str`
The text content of an EUPS table file.
Returns
-------
names : `list` [`str`]
List of package names that are required byy the EUPS table file. | [
"List",
"the",
"names",
"of",
"packages",
"that",
"are",
"required",
"by",
"an",
"EUPS",
"table",
"file",
"."
] | 75f02901a80042b28d074df1cc1dca32eb8e38c8 | https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/stackdocs/build.py#L228-L246 | train | List the names of packages that are required by an EUPS table file. |
lsst-sqre/documenteer | documenteer/stackdocs/build.py | find_package_docs | def find_package_docs(package_dir, skippedNames=None):
"""Find documentation directories in a package using ``manifest.yaml``.
Parameters
----------
package_dir : `str`
Directory of an EUPS package.
skippedNames : `list` of `str`, optional
List of package or module names to skip whe... | python | def find_package_docs(package_dir, skippedNames=None):
"""Find documentation directories in a package using ``manifest.yaml``.
Parameters
----------
package_dir : `str`
Directory of an EUPS package.
skippedNames : `list` of `str`, optional
List of package or module names to skip whe... | [
"def",
"find_package_docs",
"(",
"package_dir",
",",
"skippedNames",
"=",
"None",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"if",
"skippedNames",
"is",
"None",
":",
"skippedNames",
"=",
"[",
"]",
"doc_dir",
"=",
"os",
".",... | Find documentation directories in a package using ``manifest.yaml``.
Parameters
----------
package_dir : `str`
Directory of an EUPS package.
skippedNames : `list` of `str`, optional
List of package or module names to skip when creating links.
Returns
-------
doc_dirs : name... | [
"Find",
"documentation",
"directories",
"in",
"a",
"package",
"using",
"manifest",
".",
"yaml",
"."
] | 75f02901a80042b28d074df1cc1dca32eb8e38c8 | https://github.com/lsst-sqre/documenteer/blob/75f02901a80042b28d074df1cc1dca32eb8e38c8/documenteer/stackdocs/build.py#L249-L395 | train | Find documentation directories in a package using manifest. yaml. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.