repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
loganasherjones/yapconf | yapconf/items.py | YapconfBoolItem.convert_config_value | def convert_config_value(self, value, label):
"""Converts all 'Truthy' values to True and 'Falsy' values to False.
Args:
value: Value to convert
label: Label of the config which this item was found.
Returns:
"""
if isinstance(value, six.string_types):
... | python | def convert_config_value(self, value, label):
"""Converts all 'Truthy' values to True and 'Falsy' values to False.
Args:
value: Value to convert
label: Label of the config which this item was found.
Returns:
"""
if isinstance(value, six.string_types):
... | [
"def",
"convert_config_value",
"(",
"self",
",",
"value",
",",
"label",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"six",
".",
"string_types",
")",
":",
"value",
"=",
"value",
".",
"lower",
"(",
")",
"if",
"value",
"in",
"self",
".",
"TRUTHY_VALU... | Converts all 'Truthy' values to True and 'Falsy' values to False.
Args:
value: Value to convert
label: Label of the config which this item was found.
Returns: | [
"Converts",
"all",
"Truthy",
"values",
"to",
"True",
"and",
"Falsy",
"values",
"to",
"False",
"."
] | d2970e6e7e3334615d4d978d8b0ca33006d79d16 | https://github.com/loganasherjones/yapconf/blob/d2970e6e7e3334615d4d978d8b0ca33006d79d16/yapconf/items.py#L622-L643 | train |
loganasherjones/yapconf | yapconf/items.py | YapconfListItem.add_argument | def add_argument(self, parser, bootstrap=False):
"""Add list-style item as an argument to the given parser.
Generally speaking, this works mostly like the normal append
action, but there are special rules for boolean cases. See the
AppendReplace action for more details.
Example... | python | def add_argument(self, parser, bootstrap=False):
"""Add list-style item as an argument to the given parser.
Generally speaking, this works mostly like the normal append
action, but there are special rules for boolean cases. See the
AppendReplace action for more details.
Example... | [
"def",
"add_argument",
"(",
"self",
",",
"parser",
",",
"bootstrap",
"=",
"False",
")",
":",
"if",
"self",
".",
"cli_expose",
":",
"if",
"isinstance",
"(",
"self",
".",
"child",
",",
"YapconfBoolItem",
")",
":",
"original_default",
"=",
"self",
".",
"chi... | Add list-style item as an argument to the given parser.
Generally speaking, this works mostly like the normal append
action, but there are special rules for boolean cases. See the
AppendReplace action for more details.
Examples:
A non-nested list value with the name 'values... | [
"Add",
"list",
"-",
"style",
"item",
"as",
"an",
"argument",
"to",
"the",
"given",
"parser",
"."
] | d2970e6e7e3334615d4d978d8b0ca33006d79d16 | https://github.com/loganasherjones/yapconf/blob/d2970e6e7e3334615d4d978d8b0ca33006d79d16/yapconf/items.py#L729-L764 | train |
loganasherjones/yapconf | yapconf/items.py | YapconfDictItem.add_argument | def add_argument(self, parser, bootstrap=False):
"""Add dict-style item as an argument to the given parser.
The dict item will take all the nested items in the dictionary and
namespace them with the dict name, adding each child item as
their own CLI argument.
Examples:
... | python | def add_argument(self, parser, bootstrap=False):
"""Add dict-style item as an argument to the given parser.
The dict item will take all the nested items in the dictionary and
namespace them with the dict name, adding each child item as
their own CLI argument.
Examples:
... | [
"def",
"add_argument",
"(",
"self",
",",
"parser",
",",
"bootstrap",
"=",
"False",
")",
":",
"if",
"self",
".",
"cli_expose",
":",
"for",
"child",
"in",
"self",
".",
"children",
".",
"values",
"(",
")",
":",
"child",
".",
"add_argument",
"(",
"parser",... | Add dict-style item as an argument to the given parser.
The dict item will take all the nested items in the dictionary and
namespace them with the dict name, adding each child item as
their own CLI argument.
Examples:
A non-nested dict item with the name 'db' and children n... | [
"Add",
"dict",
"-",
"style",
"item",
"as",
"an",
"argument",
"to",
"the",
"given",
"parser",
"."
] | d2970e6e7e3334615d4d978d8b0ca33006d79d16 | https://github.com/loganasherjones/yapconf/blob/d2970e6e7e3334615d4d978d8b0ca33006d79d16/yapconf/items.py#L817-L838 | train |
sirfoga/pyhal | hal/wrappers/profile.py | log_time | def log_time(func):
"""Executes function and logs time
:param func: function to call
:return: function result
"""
@functools.wraps(func)
def _execute(*args, **kwargs):
"""Executes function and logs time
:param args: args of function
:param kwargs: extra args of functio... | python | def log_time(func):
"""Executes function and logs time
:param func: function to call
:return: function result
"""
@functools.wraps(func)
def _execute(*args, **kwargs):
"""Executes function and logs time
:param args: args of function
:param kwargs: extra args of functio... | [
"def",
"log_time",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"_execute",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"func_name",
"=",
"get_method_name",
"(",
"func",
")",
"timer",
"=",
"Timer",
"(",
")",
... | Executes function and logs time
:param func: function to call
:return: function result | [
"Executes",
"function",
"and",
"logs",
"time"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/wrappers/profile.py#L12-L42 | train |
raymondEhlers/pachyderm | pachyderm/generic_config.py | load_configuration | def load_configuration(yaml: yaml.ruamel.yaml.YAML, filename: str) -> DictLike:
""" Load an analysis configuration from a file.
Args:
yaml: YAML object to use in loading the configuration.
filename: Filename of the YAML configuration file.
Returns:
dict-like object containing the lo... | python | def load_configuration(yaml: yaml.ruamel.yaml.YAML, filename: str) -> DictLike:
""" Load an analysis configuration from a file.
Args:
yaml: YAML object to use in loading the configuration.
filename: Filename of the YAML configuration file.
Returns:
dict-like object containing the lo... | [
"def",
"load_configuration",
"(",
"yaml",
":",
"yaml",
".",
"ruamel",
".",
"yaml",
".",
"YAML",
",",
"filename",
":",
"str",
")",
"->",
"DictLike",
":",
"with",
"open",
"(",
"filename",
",",
"\"r\"",
")",
"as",
"f",
":",
"config",
"=",
"yaml",
".",
... | Load an analysis configuration from a file.
Args:
yaml: YAML object to use in loading the configuration.
filename: Filename of the YAML configuration file.
Returns:
dict-like object containing the loaded configuration | [
"Load",
"an",
"analysis",
"configuration",
"from",
"a",
"file",
"."
] | aaa1d8374fd871246290ce76f1796f2f7582b01d | https://github.com/raymondEhlers/pachyderm/blob/aaa1d8374fd871246290ce76f1796f2f7582b01d/pachyderm/generic_config.py#L23-L35 | train |
raymondEhlers/pachyderm | pachyderm/generic_config.py | override_options | def override_options(config: DictLike, selected_options: Tuple[Any, ...], set_of_possible_options: Tuple[enum.Enum, ...], config_containing_override: DictLike = None) -> DictLike:
""" Determine override options for a particular configuration.
The options are determined by searching following the order specifie... | python | def override_options(config: DictLike, selected_options: Tuple[Any, ...], set_of_possible_options: Tuple[enum.Enum, ...], config_containing_override: DictLike = None) -> DictLike:
""" Determine override options for a particular configuration.
The options are determined by searching following the order specifie... | [
"def",
"override_options",
"(",
"config",
":",
"DictLike",
",",
"selected_options",
":",
"Tuple",
"[",
"Any",
",",
"...",
"]",
",",
"set_of_possible_options",
":",
"Tuple",
"[",
"enum",
".",
"Enum",
",",
"...",
"]",
",",
"config_containing_override",
":",
"D... | Determine override options for a particular configuration.
The options are determined by searching following the order specified in selected_options.
For the example config,
.. code-block:: yaml
config:
value: 3
override:
2.76:
track:
... | [
"Determine",
"override",
"options",
"for",
"a",
"particular",
"configuration",
"."
] | aaa1d8374fd871246290ce76f1796f2f7582b01d | https://github.com/raymondEhlers/pachyderm/blob/aaa1d8374fd871246290ce76f1796f2f7582b01d/pachyderm/generic_config.py#L37-L122 | train |
raymondEhlers/pachyderm | pachyderm/generic_config.py | simplify_data_representations | def simplify_data_representations(config: DictLike) -> DictLike:
""" Convert one entry lists to the scalar value
This step is necessary because anchors are not kept for scalar values - just for lists and dictionaries.
Now that we are done with all of our anchor references, we can convert these single entry... | python | def simplify_data_representations(config: DictLike) -> DictLike:
""" Convert one entry lists to the scalar value
This step is necessary because anchors are not kept for scalar values - just for lists and dictionaries.
Now that we are done with all of our anchor references, we can convert these single entry... | [
"def",
"simplify_data_representations",
"(",
"config",
":",
"DictLike",
")",
"->",
"DictLike",
":",
"for",
"k",
",",
"v",
"in",
"config",
".",
"items",
"(",
")",
":",
"if",
"v",
"and",
"isinstance",
"(",
"v",
",",
"list",
")",
"and",
"len",
"(",
"v",... | Convert one entry lists to the scalar value
This step is necessary because anchors are not kept for scalar values - just for lists and dictionaries.
Now that we are done with all of our anchor references, we can convert these single entry lists to
just the scalar entry, which is more usable.
Some note... | [
"Convert",
"one",
"entry",
"lists",
"to",
"the",
"scalar",
"value"
] | aaa1d8374fd871246290ce76f1796f2f7582b01d | https://github.com/raymondEhlers/pachyderm/blob/aaa1d8374fd871246290ce76f1796f2f7582b01d/pachyderm/generic_config.py#L124-L143 | train |
raymondEhlers/pachyderm | pachyderm/generic_config.py | determine_selection_of_iterable_values_from_config | def determine_selection_of_iterable_values_from_config(config: DictLike, possible_iterables: Mapping[str, Type[enum.Enum]]) -> Dict[str, List[Any]]:
""" Determine iterable values to use to create objects for a given configuration.
All values of an iterable can be included be setting the value to ``True`` (Not ... | python | def determine_selection_of_iterable_values_from_config(config: DictLike, possible_iterables: Mapping[str, Type[enum.Enum]]) -> Dict[str, List[Any]]:
""" Determine iterable values to use to create objects for a given configuration.
All values of an iterable can be included be setting the value to ``True`` (Not ... | [
"def",
"determine_selection_of_iterable_values_from_config",
"(",
"config",
":",
"DictLike",
",",
"possible_iterables",
":",
"Mapping",
"[",
"str",
",",
"Type",
"[",
"enum",
".",
"Enum",
"]",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"List",
"[",
"Any",
"]",
... | Determine iterable values to use to create objects for a given configuration.
All values of an iterable can be included be setting the value to ``True`` (Not as a single value list,
but as the only value.). Alternatively, an iterator can be disabled by setting the value to ``False``.
Args:
config:... | [
"Determine",
"iterable",
"values",
"to",
"use",
"to",
"create",
"objects",
"for",
"a",
"given",
"configuration",
"."
] | aaa1d8374fd871246290ce76f1796f2f7582b01d | https://github.com/raymondEhlers/pachyderm/blob/aaa1d8374fd871246290ce76f1796f2f7582b01d/pachyderm/generic_config.py#L193-L234 | train |
raymondEhlers/pachyderm | pachyderm/generic_config.py | _key_index_iter | def _key_index_iter(self) -> Iterator[Tuple[str, Any]]:
""" Allows for iteration over the ``KeyIndex`` values.
This function is intended to be assigned to a newly created KeyIndex class. It enables iteration
over the ``KeyIndex`` names and values. We don't use a mixin to avoid issues with YAML.
Note:
... | python | def _key_index_iter(self) -> Iterator[Tuple[str, Any]]:
""" Allows for iteration over the ``KeyIndex`` values.
This function is intended to be assigned to a newly created KeyIndex class. It enables iteration
over the ``KeyIndex`` names and values. We don't use a mixin to avoid issues with YAML.
Note:
... | [
"def",
"_key_index_iter",
"(",
"self",
")",
"->",
"Iterator",
"[",
"Tuple",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"for",
"k",
",",
"v",
"in",
"vars",
"(",
"self",
")",
".",
"items",
"(",
")",
":",
"yield",
"k",
",",
"v"
] | Allows for iteration over the ``KeyIndex`` values.
This function is intended to be assigned to a newly created KeyIndex class. It enables iteration
over the ``KeyIndex`` names and values. We don't use a mixin to avoid issues with YAML.
Note:
This isn't recursive like ``dataclasses.asdict(...)``. G... | [
"Allows",
"for",
"iteration",
"over",
"the",
"KeyIndex",
"values",
"."
] | aaa1d8374fd871246290ce76f1796f2f7582b01d | https://github.com/raymondEhlers/pachyderm/blob/aaa1d8374fd871246290ce76f1796f2f7582b01d/pachyderm/generic_config.py#L236-L247 | train |
raymondEhlers/pachyderm | pachyderm/generic_config.py | create_key_index_object | def create_key_index_object(key_index_name: str, iterables: Dict[str, Any]) -> Any:
""" Create a ``KeyIndex`` class based on the passed attributes.
This is wrapped into a helper function to allow for the ``__itter__`` to be specified for the object.
Further, this allows it to be called outside the package ... | python | def create_key_index_object(key_index_name: str, iterables: Dict[str, Any]) -> Any:
""" Create a ``KeyIndex`` class based on the passed attributes.
This is wrapped into a helper function to allow for the ``__itter__`` to be specified for the object.
Further, this allows it to be called outside the package ... | [
"def",
"create_key_index_object",
"(",
"key_index_name",
":",
"str",
",",
"iterables",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Any",
":",
"for",
"name",
",",
"iterable",
"in",
"iterables",
".",
"items",
"(",
")",
":",
"if",
"iter",
"(",
... | Create a ``KeyIndex`` class based on the passed attributes.
This is wrapped into a helper function to allow for the ``__itter__`` to be specified for the object.
Further, this allows it to be called outside the package when it is needed in analysis tasks..
Args:
key_index_name: Name of the iterabl... | [
"Create",
"a",
"KeyIndex",
"class",
"based",
"on",
"the",
"passed",
"attributes",
"."
] | aaa1d8374fd871246290ce76f1796f2f7582b01d | https://github.com/raymondEhlers/pachyderm/blob/aaa1d8374fd871246290ce76f1796f2f7582b01d/pachyderm/generic_config.py#L249-L293 | train |
raymondEhlers/pachyderm | pachyderm/generic_config.py | create_objects_from_iterables | def create_objects_from_iterables(obj, args: dict, iterables: Dict[str, Any], formatting_options: Dict[str, Any], key_index_name: str = "KeyIndex") -> Tuple[Any, Dict[str, Any], dict]:
""" Create objects for each set of values based on the given arguments.
The iterable values are available under a key index ``... | python | def create_objects_from_iterables(obj, args: dict, iterables: Dict[str, Any], formatting_options: Dict[str, Any], key_index_name: str = "KeyIndex") -> Tuple[Any, Dict[str, Any], dict]:
""" Create objects for each set of values based on the given arguments.
The iterable values are available under a key index ``... | [
"def",
"create_objects_from_iterables",
"(",
"obj",
",",
"args",
":",
"dict",
",",
"iterables",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"formatting_options",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"key_index_name",
":",
"str",
"=",
"\"KeyI... | Create objects for each set of values based on the given arguments.
The iterable values are available under a key index ``dataclass`` which is used to index the returned
dictionary. The names of the fields are determined by the keys of iterables dictionary. The values are
the newly created object. Note tha... | [
"Create",
"objects",
"for",
"each",
"set",
"of",
"values",
"based",
"on",
"the",
"given",
"arguments",
"."
] | aaa1d8374fd871246290ce76f1796f2f7582b01d | https://github.com/raymondEhlers/pachyderm/blob/aaa1d8374fd871246290ce76f1796f2f7582b01d/pachyderm/generic_config.py#L295-L390 | train |
raymondEhlers/pachyderm | pachyderm/generic_config.py | apply_formatting_dict | def apply_formatting_dict(obj: Any, formatting: Dict[str, Any]) -> Any:
""" Recursively apply a formatting dict to all strings in a configuration.
Note that it skips applying the formatting if the string appears to contain latex (specifically,
if it contains an "$"), since the formatting fails on nested br... | python | def apply_formatting_dict(obj: Any, formatting: Dict[str, Any]) -> Any:
""" Recursively apply a formatting dict to all strings in a configuration.
Note that it skips applying the formatting if the string appears to contain latex (specifically,
if it contains an "$"), since the formatting fails on nested br... | [
"def",
"apply_formatting_dict",
"(",
"obj",
":",
"Any",
",",
"formatting",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Any",
":",
"new_obj",
"=",
"obj",
"if",
"isinstance",
"(",
"obj",
",",
"str",
")",
":",
"if",
"\"$\"",
"not",
"in",
"ob... | Recursively apply a formatting dict to all strings in a configuration.
Note that it skips applying the formatting if the string appears to contain latex (specifically,
if it contains an "$"), since the formatting fails on nested brackets.
Args:
obj: Some configuration object to recursively applyin... | [
"Recursively",
"apply",
"a",
"formatting",
"dict",
"to",
"all",
"strings",
"in",
"a",
"configuration",
"."
] | aaa1d8374fd871246290ce76f1796f2f7582b01d | https://github.com/raymondEhlers/pachyderm/blob/aaa1d8374fd871246290ce76f1796f2f7582b01d/pachyderm/generic_config.py#L400-L449 | train |
raymondEhlers/pachyderm | pachyderm/generic_config.py | iterate_with_selected_objects | def iterate_with_selected_objects(analysis_objects: Mapping[Any, Any], **selections: Mapping[str, Any]) -> Iterator[Tuple[Any, Any]]:
""" Iterate over an analysis dictionary with selected attributes.
Args:
analysis_objects: Analysis objects dictionary.
selections: Keyword arguments used to sele... | python | def iterate_with_selected_objects(analysis_objects: Mapping[Any, Any], **selections: Mapping[str, Any]) -> Iterator[Tuple[Any, Any]]:
""" Iterate over an analysis dictionary with selected attributes.
Args:
analysis_objects: Analysis objects dictionary.
selections: Keyword arguments used to sele... | [
"def",
"iterate_with_selected_objects",
"(",
"analysis_objects",
":",
"Mapping",
"[",
"Any",
",",
"Any",
"]",
",",
"**",
"selections",
":",
"Mapping",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Iterator",
"[",
"Tuple",
"[",
"Any",
",",
"Any",
"]",
"]",
"... | Iterate over an analysis dictionary with selected attributes.
Args:
analysis_objects: Analysis objects dictionary.
selections: Keyword arguments used to select attributes from the analysis dictionary.
Yields:
object: Matching analysis object. | [
"Iterate",
"over",
"an",
"analysis",
"dictionary",
"with",
"selected",
"attributes",
"."
] | aaa1d8374fd871246290ce76f1796f2f7582b01d | https://github.com/raymondEhlers/pachyderm/blob/aaa1d8374fd871246290ce76f1796f2f7582b01d/pachyderm/generic_config.py#L451-L466 | train |
raymondEhlers/pachyderm | pachyderm/generic_config.py | iterate_with_selected_objects_in_order | def iterate_with_selected_objects_in_order(analysis_objects: Mapping[Any, Any],
analysis_iterables: Dict[str, Sequence[Any]],
selection: Union[str, Sequence[str]]) -> Iterator[List[Tuple[Any, Any]]]:
""" Iterate over an analysis d... | python | def iterate_with_selected_objects_in_order(analysis_objects: Mapping[Any, Any],
analysis_iterables: Dict[str, Sequence[Any]],
selection: Union[str, Sequence[str]]) -> Iterator[List[Tuple[Any, Any]]]:
""" Iterate over an analysis d... | [
"def",
"iterate_with_selected_objects_in_order",
"(",
"analysis_objects",
":",
"Mapping",
"[",
"Any",
",",
"Any",
"]",
",",
"analysis_iterables",
":",
"Dict",
"[",
"str",
",",
"Sequence",
"[",
"Any",
"]",
"]",
",",
"selection",
":",
"Union",
"[",
"str",
",",... | Iterate over an analysis dictionary, yielding the selected attributes in order.
So if there are three iterables, a, b, and c, if we selected c, then we iterate over a and b,
and return c in the same order each time for each set of values of a and b. As an example, consider
the set of iterables:
.. cod... | [
"Iterate",
"over",
"an",
"analysis",
"dictionary",
"yielding",
"the",
"selected",
"attributes",
"in",
"order",
"."
] | aaa1d8374fd871246290ce76f1796f2f7582b01d | https://github.com/raymondEhlers/pachyderm/blob/aaa1d8374fd871246290ce76f1796f2f7582b01d/pachyderm/generic_config.py#L468-L556 | train |
dpa-newslab/livebridge | livebridge/base/sources.py | BaseSource._db | def _db(self):
"""Database client for accessing storage.
:returns: :class:`livebridge.storages.base.BaseStorage` """
if not hasattr(self, "_db_client") or getattr(self, "_db_client") is None:
self._db_client = get_db_client()
return self._db_client | python | def _db(self):
"""Database client for accessing storage.
:returns: :class:`livebridge.storages.base.BaseStorage` """
if not hasattr(self, "_db_client") or getattr(self, "_db_client") is None:
self._db_client = get_db_client()
return self._db_client | [
"def",
"_db",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"_db_client\"",
")",
"or",
"getattr",
"(",
"self",
",",
"\"_db_client\"",
")",
"is",
"None",
":",
"self",
".",
"_db_client",
"=",
"get_db_client",
"(",
")",
"return",
"sel... | Database client for accessing storage.
:returns: :class:`livebridge.storages.base.BaseStorage` | [
"Database",
"client",
"for",
"accessing",
"storage",
"."
] | d930e887faa2f882d15b574f0f1fe4a580d7c5fa | https://github.com/dpa-newslab/livebridge/blob/d930e887faa2f882d15b574f0f1fe4a580d7c5fa/livebridge/base/sources.py#L38-L44 | train |
dpa-newslab/livebridge | livebridge/base/sources.py | BaseSource.filter_new_posts | async def filter_new_posts(self, source_id, post_ids):
"""Filters ist of post_id for new ones.
:param source_id: id of the source
:type string:
:param post_ids: list of post ids
:type list:
:returns: list of unknown post ids."""
new_ids = []
try:
... | python | async def filter_new_posts(self, source_id, post_ids):
"""Filters ist of post_id for new ones.
:param source_id: id of the source
:type string:
:param post_ids: list of post ids
:type list:
:returns: list of unknown post ids."""
new_ids = []
try:
... | [
"async",
"def",
"filter_new_posts",
"(",
"self",
",",
"source_id",
",",
"post_ids",
")",
":",
"new_ids",
"=",
"[",
"]",
"try",
":",
"db_client",
"=",
"self",
".",
"_db",
"posts_in_db",
"=",
"await",
"db_client",
".",
"get_known_posts",
"(",
"source_id",
",... | Filters ist of post_id for new ones.
:param source_id: id of the source
:type string:
:param post_ids: list of post ids
:type list:
:returns: list of unknown post ids. | [
"Filters",
"ist",
"of",
"post_id",
"for",
"new",
"ones",
"."
] | d930e887faa2f882d15b574f0f1fe4a580d7c5fa | https://github.com/dpa-newslab/livebridge/blob/d930e887faa2f882d15b574f0f1fe4a580d7c5fa/livebridge/base/sources.py#L46-L62 | train |
dpa-newslab/livebridge | livebridge/base/sources.py | BaseSource.get_last_updated | async def get_last_updated(self, source_id):
"""Returns latest update-timestamp from storage for source.
:param source_id: id of the source (source_id, ticker_id, blog_id pp)
:type string:
:returns: :py:class:`datetime.datetime` object of latest update datetime in db."""
last_up... | python | async def get_last_updated(self, source_id):
"""Returns latest update-timestamp from storage for source.
:param source_id: id of the source (source_id, ticker_id, blog_id pp)
:type string:
:returns: :py:class:`datetime.datetime` object of latest update datetime in db."""
last_up... | [
"async",
"def",
"get_last_updated",
"(",
"self",
",",
"source_id",
")",
":",
"last_updated",
"=",
"await",
"self",
".",
"_db",
".",
"get_last_updated",
"(",
"source_id",
")",
"logger",
".",
"info",
"(",
"\"LAST UPDATED: {} {}\"",
".",
"format",
"(",
"last_upda... | Returns latest update-timestamp from storage for source.
:param source_id: id of the source (source_id, ticker_id, blog_id pp)
:type string:
:returns: :py:class:`datetime.datetime` object of latest update datetime in db. | [
"Returns",
"latest",
"update",
"-",
"timestamp",
"from",
"storage",
"for",
"source",
"."
] | d930e887faa2f882d15b574f0f1fe4a580d7c5fa | https://github.com/dpa-newslab/livebridge/blob/d930e887faa2f882d15b574f0f1fe4a580d7c5fa/livebridge/base/sources.py#L64-L72 | train |
portfors-lab/sparkle | sparkle/gui/stim/qauto_parameter_model.py | QAutoParameterModel.clearParameters | def clearParameters(self):
"""Removes all parameters from model"""
self.beginRemoveRows(QtCore.QModelIndex(), 0, self.rowCount())
self.model.clear_parameters()
self.endRemoveRows() | python | def clearParameters(self):
"""Removes all parameters from model"""
self.beginRemoveRows(QtCore.QModelIndex(), 0, self.rowCount())
self.model.clear_parameters()
self.endRemoveRows() | [
"def",
"clearParameters",
"(",
"self",
")",
":",
"self",
".",
"beginRemoveRows",
"(",
"QtCore",
".",
"QModelIndex",
"(",
")",
",",
"0",
",",
"self",
".",
"rowCount",
"(",
")",
")",
"self",
".",
"model",
".",
"clear_parameters",
"(",
")",
"self",
".",
... | Removes all parameters from model | [
"Removes",
"all",
"parameters",
"from",
"model"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/qauto_parameter_model.py#L51-L55 | train |
portfors-lab/sparkle | sparkle/gui/stim/qauto_parameter_model.py | QAutoParameterModel.insertRows | def insertRows(self, position, rows, parent = QtCore.QModelIndex()):
"""Inserts new parameters and emits an emptied False signal
:param position: row location to insert new parameter
:type position: int
:param rows: number of new parameters to insert
:type rows: int
:par... | python | def insertRows(self, position, rows, parent = QtCore.QModelIndex()):
"""Inserts new parameters and emits an emptied False signal
:param position: row location to insert new parameter
:type position: int
:param rows: number of new parameters to insert
:type rows: int
:par... | [
"def",
"insertRows",
"(",
"self",
",",
"position",
",",
"rows",
",",
"parent",
"=",
"QtCore",
".",
"QModelIndex",
"(",
")",
")",
":",
"self",
".",
"beginInsertRows",
"(",
"parent",
",",
"position",
",",
"position",
"+",
"rows",
"-",
"1",
")",
"for",
... | Inserts new parameters and emits an emptied False signal
:param position: row location to insert new parameter
:type position: int
:param rows: number of new parameters to insert
:type rows: int
:param parent: Required by QAbstractItemModel, can be safely ignored | [
"Inserts",
"new",
"parameters",
"and",
"emits",
"an",
"emptied",
"False",
"signal"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/qauto_parameter_model.py#L152-L168 | train |
portfors-lab/sparkle | sparkle/gui/stim/qauto_parameter_model.py | QAutoParameterModel.removeRows | def removeRows(self, position, rows, parent = QtCore.QModelIndex()):
"""Removes parameters from the model. Emits and emptied True signal, if there are no parameters left.
:param position: row location of parameters to remove
:type position: int
:param rows: number of parameters to remov... | python | def removeRows(self, position, rows, parent = QtCore.QModelIndex()):
"""Removes parameters from the model. Emits and emptied True signal, if there are no parameters left.
:param position: row location of parameters to remove
:type position: int
:param rows: number of parameters to remov... | [
"def",
"removeRows",
"(",
"self",
",",
"position",
",",
"rows",
",",
"parent",
"=",
"QtCore",
".",
"QModelIndex",
"(",
")",
")",
":",
"self",
".",
"beginRemoveRows",
"(",
"parent",
",",
"position",
",",
"position",
"+",
"rows",
"-",
"1",
")",
"for",
... | Removes parameters from the model. Emits and emptied True signal, if there are no parameters left.
:param position: row location of parameters to remove
:type position: int
:param rows: number of parameters to remove
:type rows: int
:param parent: Required by QAbstractItemModel,... | [
"Removes",
"parameters",
"from",
"the",
"model",
".",
"Emits",
"and",
"emptied",
"True",
"signal",
"if",
"there",
"are",
"no",
"parameters",
"left",
"."
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/qauto_parameter_model.py#L170-L187 | train |
portfors-lab/sparkle | sparkle/gui/stim/qauto_parameter_model.py | QAutoParameterModel.toggleSelection | def toggleSelection(self, index, comp):
"""Toggles a component in or out of the currently
selected parameter's compnents list"""
self.model.toggleSelection(index.row(), comp) | python | def toggleSelection(self, index, comp):
"""Toggles a component in or out of the currently
selected parameter's compnents list"""
self.model.toggleSelection(index.row(), comp) | [
"def",
"toggleSelection",
"(",
"self",
",",
"index",
",",
"comp",
")",
":",
"self",
".",
"model",
".",
"toggleSelection",
"(",
"index",
".",
"row",
"(",
")",
",",
"comp",
")"
] | Toggles a component in or out of the currently
selected parameter's compnents list | [
"Toggles",
"a",
"component",
"in",
"or",
"out",
"of",
"the",
"currently",
"selected",
"parameter",
"s",
"compnents",
"list"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/stim/qauto_parameter_model.py#L220-L223 | train |
lowandrew/OLCTools | spadespipeline/runMetadata.py | Metadata.parseruninfo | def parseruninfo(self):
"""Extracts the flowcell ID, as well as the instrument name from RunInfo.xml. If this file is not provided,
NA values are substituted"""
# Check if the RunInfo.xml file is provided, otherwise, yield N/A
try:
runinfo = ElementTree.ElementTree(file=self.... | python | def parseruninfo(self):
"""Extracts the flowcell ID, as well as the instrument name from RunInfo.xml. If this file is not provided,
NA values are substituted"""
# Check if the RunInfo.xml file is provided, otherwise, yield N/A
try:
runinfo = ElementTree.ElementTree(file=self.... | [
"def",
"parseruninfo",
"(",
"self",
")",
":",
"try",
":",
"runinfo",
"=",
"ElementTree",
".",
"ElementTree",
"(",
"file",
"=",
"self",
".",
"runinfo",
")",
"for",
"elem",
"in",
"runinfo",
".",
"iter",
"(",
")",
":",
"for",
"run",
"in",
"elem",
":",
... | Extracts the flowcell ID, as well as the instrument name from RunInfo.xml. If this file is not provided,
NA values are substituted | [
"Extracts",
"the",
"flowcell",
"ID",
"as",
"well",
"as",
"the",
"instrument",
"name",
"from",
"RunInfo",
".",
"xml",
".",
"If",
"this",
"file",
"is",
"not",
"provided",
"NA",
"values",
"are",
"substituted"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/spadespipeline/runMetadata.py#L16-L38 | train |
sirfoga/pyhal | hal/files/parsers.py | Parser.get_lines | def get_lines(self):
"""Gets lines in file
:return: Lines in file
"""
with open(self.path, "r") as data:
self.lines = data.readlines() # store data in arrays
return self.lines | python | def get_lines(self):
"""Gets lines in file
:return: Lines in file
"""
with open(self.path, "r") as data:
self.lines = data.readlines() # store data in arrays
return self.lines | [
"def",
"get_lines",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"path",
",",
"\"r\"",
")",
"as",
"data",
":",
"self",
".",
"lines",
"=",
"data",
".",
"readlines",
"(",
")",
"return",
"self",
".",
"lines"
] | Gets lines in file
:return: Lines in file | [
"Gets",
"lines",
"in",
"file"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/files/parsers.py#L19-L27 | train |
sirfoga/pyhal | hal/files/parsers.py | CSVParser.get_matrix | def get_matrix(self):
"""Stores values in array, store lines in array
:return: 2D matrix
"""
data = []
with open(self.path, encoding=self.encoding) as csv_file:
csv_reader = csv.reader(csv_file, delimiter=",", quotechar="\"")
for row in csv_reader:
... | python | def get_matrix(self):
"""Stores values in array, store lines in array
:return: 2D matrix
"""
data = []
with open(self.path, encoding=self.encoding) as csv_file:
csv_reader = csv.reader(csv_file, delimiter=",", quotechar="\"")
for row in csv_reader:
... | [
"def",
"get_matrix",
"(",
"self",
")",
":",
"data",
"=",
"[",
"]",
"with",
"open",
"(",
"self",
".",
"path",
",",
"encoding",
"=",
"self",
".",
"encoding",
")",
"as",
"csv_file",
":",
"csv_reader",
"=",
"csv",
".",
"reader",
"(",
"csv_file",
",",
"... | Stores values in array, store lines in array
:return: 2D matrix | [
"Stores",
"values",
"in",
"array",
"store",
"lines",
"in",
"array"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/files/parsers.py#L41-L52 | train |
sirfoga/pyhal | hal/files/parsers.py | CSVParser.get_dicts | def get_dicts(self):
"""Gets dicts in file
:return: (generator of) of dicts with data from .csv file
"""
reader = csv.DictReader(open(self.path, "r", encoding=self.encoding))
for row in reader:
if row:
yield row | python | def get_dicts(self):
"""Gets dicts in file
:return: (generator of) of dicts with data from .csv file
"""
reader = csv.DictReader(open(self.path, "r", encoding=self.encoding))
for row in reader:
if row:
yield row | [
"def",
"get_dicts",
"(",
"self",
")",
":",
"reader",
"=",
"csv",
".",
"DictReader",
"(",
"open",
"(",
"self",
".",
"path",
",",
"\"r\"",
",",
"encoding",
"=",
"self",
".",
"encoding",
")",
")",
"for",
"row",
"in",
"reader",
":",
"if",
"row",
":",
... | Gets dicts in file
:return: (generator of) of dicts with data from .csv file | [
"Gets",
"dicts",
"in",
"file"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/files/parsers.py#L62-L70 | train |
Egregors/cbrf | cbrf/models.py | CurrenciesInfo.get_by_id | def get_by_id(self, id_code: str) -> Currency or None:
""" Get currency by ID
:param id_code: set, like "R01305"
:return: currency or None.
"""
try:
return [_ for _ in self.currencies if _.id == id_code][0]
except IndexError:
return None | python | def get_by_id(self, id_code: str) -> Currency or None:
""" Get currency by ID
:param id_code: set, like "R01305"
:return: currency or None.
"""
try:
return [_ for _ in self.currencies if _.id == id_code][0]
except IndexError:
return None | [
"def",
"get_by_id",
"(",
"self",
",",
"id_code",
":",
"str",
")",
"->",
"Currency",
"or",
"None",
":",
"try",
":",
"return",
"[",
"_",
"for",
"_",
"in",
"self",
".",
"currencies",
"if",
"_",
".",
"id",
"==",
"id_code",
"]",
"[",
"0",
"]",
"except... | Get currency by ID
:param id_code: set, like "R01305"
:return: currency or None. | [
"Get",
"currency",
"by",
"ID"
] | e4ce332fcead83c75966337c97c0ae070fb7e576 | https://github.com/Egregors/cbrf/blob/e4ce332fcead83c75966337c97c0ae070fb7e576/cbrf/models.py#L125-L134 | train |
portfors-lab/sparkle | sparkle/stim/types/__init__.py | get_stimuli_models | def get_stimuli_models():
"""
Returns all subclasses of AbstractStimulusComponent in python files,
in this package
"""
package_path = os.path.dirname(__file__)
mod = '.'.join(get_stimuli_models.__module__.split('.'))
if mod == '__main__':
mod = ''
else:
mod = mod + '.'
... | python | def get_stimuli_models():
"""
Returns all subclasses of AbstractStimulusComponent in python files,
in this package
"""
package_path = os.path.dirname(__file__)
mod = '.'.join(get_stimuli_models.__module__.split('.'))
if mod == '__main__':
mod = ''
else:
mod = mod + '.'
... | [
"def",
"get_stimuli_models",
"(",
")",
":",
"package_path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
"mod",
"=",
"'.'",
".",
"join",
"(",
"get_stimuli_models",
".",
"__module__",
".",
"split",
"(",
"'.'",
")",
")",
"if",
"mod",
"==... | Returns all subclasses of AbstractStimulusComponent in python files,
in this package | [
"Returns",
"all",
"subclasses",
"of",
"AbstractStimulusComponent",
"in",
"python",
"files",
"in",
"this",
"package"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/stim/types/__init__.py#L5-L33 | train |
steven-lang/bottr | bottr/util.py | parse_wait_time | def parse_wait_time(text: str) -> int:
"""Parse the waiting time from the exception"""
val = RATELIMIT.findall(text)
if len(val) > 0:
try:
res = val[0]
if res[1] == 'minutes':
return int(res[0]) * 60
if res[1] == 'seconds':
return ... | python | def parse_wait_time(text: str) -> int:
"""Parse the waiting time from the exception"""
val = RATELIMIT.findall(text)
if len(val) > 0:
try:
res = val[0]
if res[1] == 'minutes':
return int(res[0]) * 60
if res[1] == 'seconds':
return ... | [
"def",
"parse_wait_time",
"(",
"text",
":",
"str",
")",
"->",
"int",
":",
"val",
"=",
"RATELIMIT",
".",
"findall",
"(",
"text",
")",
"if",
"len",
"(",
"val",
")",
">",
"0",
":",
"try",
":",
"res",
"=",
"val",
"[",
"0",
"]",
"if",
"res",
"[",
... | Parse the waiting time from the exception | [
"Parse",
"the",
"waiting",
"time",
"from",
"the",
"exception"
] | c1b92becc31adfbd5a7b77179b852a51da70b193 | https://github.com/steven-lang/bottr/blob/c1b92becc31adfbd5a7b77179b852a51da70b193/bottr/util.py#L13-L26 | train |
steven-lang/bottr | bottr/util.py | check_comment_depth | def check_comment_depth(comment: praw.models.Comment, max_depth=3) -> bool:
"""
Check if comment is in a allowed depth range
:param comment: :class:`praw.models.Comment` to count the depth of
:param max_depth: Maximum allowed depth
:return: True if comment is in depth range between 0 and max_depth
... | python | def check_comment_depth(comment: praw.models.Comment, max_depth=3) -> bool:
"""
Check if comment is in a allowed depth range
:param comment: :class:`praw.models.Comment` to count the depth of
:param max_depth: Maximum allowed depth
:return: True if comment is in depth range between 0 and max_depth
... | [
"def",
"check_comment_depth",
"(",
"comment",
":",
"praw",
".",
"models",
".",
"Comment",
",",
"max_depth",
"=",
"3",
")",
"->",
"bool",
":",
"count",
"=",
"0",
"while",
"not",
"comment",
".",
"is_root",
":",
"count",
"+=",
"1",
"if",
"count",
">",
"... | Check if comment is in a allowed depth range
:param comment: :class:`praw.models.Comment` to count the depth of
:param max_depth: Maximum allowed depth
:return: True if comment is in depth range between 0 and max_depth | [
"Check",
"if",
"comment",
"is",
"in",
"a",
"allowed",
"depth",
"range"
] | c1b92becc31adfbd5a7b77179b852a51da70b193 | https://github.com/steven-lang/bottr/blob/c1b92becc31adfbd5a7b77179b852a51da70b193/bottr/util.py#L59-L75 | train |
steven-lang/bottr | bottr/util.py | get_subs | def get_subs(subs_file='subreddits.txt', blacklist_file='blacklist.txt') -> List[str]:
"""
Get subs based on a file of subreddits and a file of blacklisted subreddits.
:param subs_file: List of subreddits. Each sub in a new line.
:param blacklist_file: List of blacklisted subreddits. Each sub in a new... | python | def get_subs(subs_file='subreddits.txt', blacklist_file='blacklist.txt') -> List[str]:
"""
Get subs based on a file of subreddits and a file of blacklisted subreddits.
:param subs_file: List of subreddits. Each sub in a new line.
:param blacklist_file: List of blacklisted subreddits. Each sub in a new... | [
"def",
"get_subs",
"(",
"subs_file",
"=",
"'subreddits.txt'",
",",
"blacklist_file",
"=",
"'blacklist.txt'",
")",
"->",
"List",
"[",
"str",
"]",
":",
"subsf",
"=",
"open",
"(",
"subs_file",
")",
"blacklf",
"=",
"open",
"(",
"blacklist_file",
")",
"subs",
"... | Get subs based on a file of subreddits and a file of blacklisted subreddits.
:param subs_file: List of subreddits. Each sub in a new line.
:param blacklist_file: List of blacklisted subreddits. Each sub in a new line.
:return: List of subreddits filtered with the blacklisted subs.
**Example files**::... | [
"Get",
"subs",
"based",
"on",
"a",
"file",
"of",
"subreddits",
"and",
"a",
"file",
"of",
"blacklisted",
"subreddits",
"."
] | c1b92becc31adfbd5a7b77179b852a51da70b193 | https://github.com/steven-lang/bottr/blob/c1b92becc31adfbd5a7b77179b852a51da70b193/bottr/util.py#L98-L123 | train |
yamcs/yamcs-python | yamcs-client/examples/data_links.py | enable_all_links | def enable_all_links():
"""Enable all links."""
for link in client.list_data_links(instance='simulator'):
client.enable_data_link(instance=link.instance, link=link.name) | python | def enable_all_links():
"""Enable all links."""
for link in client.list_data_links(instance='simulator'):
client.enable_data_link(instance=link.instance, link=link.name) | [
"def",
"enable_all_links",
"(",
")",
":",
"for",
"link",
"in",
"client",
".",
"list_data_links",
"(",
"instance",
"=",
"'simulator'",
")",
":",
"client",
".",
"enable_data_link",
"(",
"instance",
"=",
"link",
".",
"instance",
",",
"link",
"=",
"link",
".",... | Enable all links. | [
"Enable",
"all",
"links",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/examples/data_links.py#L8-L11 | train |
ElofssonLab/pyGaussDCA | src/gaussdca/_load_data.py | load_a3m | def load_a3m(fasta, max_gap_fraction=0.9):
""" load alignment with the alphabet used in GaussDCA """
mapping = {'-': 21, 'A': 1, 'B': 21, 'C': 2, 'D': 3, 'E': 4, 'F': 5,
'G': 6, 'H': 7, 'I': 8, 'K': 9, 'L': 10, 'M': 11,
'N': 12, 'O': 21, 'P': 13, 'Q': 14, 'R': 15, 'S': 16, 'T': 17,... | python | def load_a3m(fasta, max_gap_fraction=0.9):
""" load alignment with the alphabet used in GaussDCA """
mapping = {'-': 21, 'A': 1, 'B': 21, 'C': 2, 'D': 3, 'E': 4, 'F': 5,
'G': 6, 'H': 7, 'I': 8, 'K': 9, 'L': 10, 'M': 11,
'N': 12, 'O': 21, 'P': 13, 'Q': 14, 'R': 15, 'S': 16, 'T': 17,... | [
"def",
"load_a3m",
"(",
"fasta",
",",
"max_gap_fraction",
"=",
"0.9",
")",
":",
"mapping",
"=",
"{",
"'-'",
":",
"21",
",",
"'A'",
":",
"1",
",",
"'B'",
":",
"21",
",",
"'C'",
":",
"2",
",",
"'D'",
":",
"3",
",",
"'E'",
":",
"4",
",",
"'F'",
... | load alignment with the alphabet used in GaussDCA | [
"load",
"alignment",
"with",
"the",
"alphabet",
"used",
"in",
"GaussDCA"
] | 0c1a16dbbb2f4fbe039b36f37f9c7c3989e2e84c | https://github.com/ElofssonLab/pyGaussDCA/blob/0c1a16dbbb2f4fbe039b36f37f9c7c3989e2e84c/src/gaussdca/_load_data.py#L7-L39 | train |
lowandrew/OLCTools | spadespipeline/typingclasses.py | PlasmidExtractor.run_plasmid_extractor | def run_plasmid_extractor(self):
"""
Create and run the plasmid extractor system call
"""
logging.info('Extracting plasmids')
# Define the system call
extract_command = 'PlasmidExtractor.py -i {inf} -o {outf} -p {plasdb} -d {db} -t {cpus} -nc' \
.format(inf=se... | python | def run_plasmid_extractor(self):
"""
Create and run the plasmid extractor system call
"""
logging.info('Extracting plasmids')
# Define the system call
extract_command = 'PlasmidExtractor.py -i {inf} -o {outf} -p {plasdb} -d {db} -t {cpus} -nc' \
.format(inf=se... | [
"def",
"run_plasmid_extractor",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Extracting plasmids'",
")",
"extract_command",
"=",
"'PlasmidExtractor.py -i {inf} -o {outf} -p {plasdb} -d {db} -t {cpus} -nc'",
".",
"format",
"(",
"inf",
"=",
"self",
".",
"path",
"... | Create and run the plasmid extractor system call | [
"Create",
"and",
"run",
"the",
"plasmid",
"extractor",
"system",
"call"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/spadespipeline/typingclasses.py#L224-L244 | train |
lowandrew/OLCTools | spadespipeline/typingclasses.py | PlasmidExtractor.parse_report | def parse_report(self):
"""
Parse the plasmid extractor report, and populate metadata objects
"""
logging.info('Parsing Plasmid Extractor outputs')
# A dictionary to store the parsed excel file in a more readable format
nesteddictionary = dict()
# Use pandas to re... | python | def parse_report(self):
"""
Parse the plasmid extractor report, and populate metadata objects
"""
logging.info('Parsing Plasmid Extractor outputs')
# A dictionary to store the parsed excel file in a more readable format
nesteddictionary = dict()
# Use pandas to re... | [
"def",
"parse_report",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Parsing Plasmid Extractor outputs'",
")",
"nesteddictionary",
"=",
"dict",
"(",
")",
"dictionary",
"=",
"pandas",
".",
"read_csv",
"(",
"self",
".",
"plasmid_report",
")",
".",
"to_di... | Parse the plasmid extractor report, and populate metadata objects | [
"Parse",
"the",
"plasmid",
"extractor",
"report",
"and",
"populate",
"metadata",
"objects"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/spadespipeline/typingclasses.py#L246-L287 | train |
lowandrew/OLCTools | spadespipeline/typingclasses.py | ResFinder.object_clean | def object_clean(self):
"""
Remove large attributes from the metadata objects
"""
for sample in self.metadata:
try:
delattr(sample[self.analysistype], 'aaidentity')
delattr(sample[self.analysistype], 'aaalign')
delattr(sample[se... | python | def object_clean(self):
"""
Remove large attributes from the metadata objects
"""
for sample in self.metadata:
try:
delattr(sample[self.analysistype], 'aaidentity')
delattr(sample[self.analysistype], 'aaalign')
delattr(sample[se... | [
"def",
"object_clean",
"(",
"self",
")",
":",
"for",
"sample",
"in",
"self",
".",
"metadata",
":",
"try",
":",
"delattr",
"(",
"sample",
"[",
"self",
".",
"analysistype",
"]",
",",
"'aaidentity'",
")",
"delattr",
"(",
"sample",
"[",
"self",
".",
"analy... | Remove large attributes from the metadata objects | [
"Remove",
"large",
"attributes",
"from",
"the",
"metadata",
"objects"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/spadespipeline/typingclasses.py#L803-L817 | train |
portfors-lab/sparkle | sparkle/gui/dialogs/scale_dlg.py | ScaleDialog.values | def values(self):
"""Gets the scales that the user chose
| For frequency: 1 = Hz, 1000 = kHz
| For time: 1 = seconds, 0.001 = ms
:returns: float, float -- frequency scaling, time scaling
"""
if self.ui.hzBtn.isChecked():
fscale = SmartSpinBox.Hz
else... | python | def values(self):
"""Gets the scales that the user chose
| For frequency: 1 = Hz, 1000 = kHz
| For time: 1 = seconds, 0.001 = ms
:returns: float, float -- frequency scaling, time scaling
"""
if self.ui.hzBtn.isChecked():
fscale = SmartSpinBox.Hz
else... | [
"def",
"values",
"(",
"self",
")",
":",
"if",
"self",
".",
"ui",
".",
"hzBtn",
".",
"isChecked",
"(",
")",
":",
"fscale",
"=",
"SmartSpinBox",
".",
"Hz",
"else",
":",
"fscale",
"=",
"SmartSpinBox",
".",
"kHz",
"if",
"self",
".",
"ui",
".",
"msBtn",... | Gets the scales that the user chose
| For frequency: 1 = Hz, 1000 = kHz
| For time: 1 = seconds, 0.001 = ms
:returns: float, float -- frequency scaling, time scaling | [
"Gets",
"the",
"scales",
"that",
"the",
"user",
"chose"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/dialogs/scale_dlg.py#L28-L46 | train |
tgbugs/ontquery | ontquery/trie.py | insert_trie | def insert_trie(trie, value): # aka get_subtrie_or_insert
""" Insert a value into the trie if it is not already contained in the trie.
Return the subtree for the value regardless of whether it is a new value
or not. """
if value in trie:
return trie[value]
multi_check = False
fo... | python | def insert_trie(trie, value): # aka get_subtrie_or_insert
""" Insert a value into the trie if it is not already contained in the trie.
Return the subtree for the value regardless of whether it is a new value
or not. """
if value in trie:
return trie[value]
multi_check = False
fo... | [
"def",
"insert_trie",
"(",
"trie",
",",
"value",
")",
":",
"if",
"value",
"in",
"trie",
":",
"return",
"trie",
"[",
"value",
"]",
"multi_check",
"=",
"False",
"for",
"key",
"in",
"tuple",
"(",
"trie",
".",
"keys",
"(",
")",
")",
":",
"if",
"len",
... | Insert a value into the trie if it is not already contained in the trie.
Return the subtree for the value regardless of whether it is a new value
or not. | [
"Insert",
"a",
"value",
"into",
"the",
"trie",
"if",
"it",
"is",
"not",
"already",
"contained",
"in",
"the",
"trie",
".",
"Return",
"the",
"subtree",
"for",
"the",
"value",
"regardless",
"of",
"whether",
"it",
"is",
"a",
"new",
"value",
"or",
"not",
".... | bcf4863cb2bf221afe2b093c5dc7da1377300041 | https://github.com/tgbugs/ontquery/blob/bcf4863cb2bf221afe2b093c5dc7da1377300041/ontquery/trie.py#L31-L49 | train |
jason-weirather/pythologist | pythologist/__init__.py | CellDataFrame.get_valid_cell_indecies | def get_valid_cell_indecies(self):
"""
Return a dataframe of images present with 'valid' being a list of cell indecies that can be included
"""
return pd.DataFrame(self).groupby(self.frame_columns).apply(lambda x: list(x['cell_index'])).\
reset_index().rename(columns={0:'vali... | python | def get_valid_cell_indecies(self):
"""
Return a dataframe of images present with 'valid' being a list of cell indecies that can be included
"""
return pd.DataFrame(self).groupby(self.frame_columns).apply(lambda x: list(x['cell_index'])).\
reset_index().rename(columns={0:'vali... | [
"def",
"get_valid_cell_indecies",
"(",
"self",
")",
":",
"return",
"pd",
".",
"DataFrame",
"(",
"self",
")",
".",
"groupby",
"(",
"self",
".",
"frame_columns",
")",
".",
"apply",
"(",
"lambda",
"x",
":",
"list",
"(",
"x",
"[",
"'cell_index'",
"]",
")",... | Return a dataframe of images present with 'valid' being a list of cell indecies that can be included | [
"Return",
"a",
"dataframe",
"of",
"images",
"present",
"with",
"valid",
"being",
"a",
"list",
"of",
"cell",
"indecies",
"that",
"can",
"be",
"included"
] | 6eb4082be9dffa9570e4ceaa06d97845eac4c006 | https://github.com/jason-weirather/pythologist/blob/6eb4082be9dffa9570e4ceaa06d97845eac4c006/pythologist/__init__.py#L49-L54 | train |
jason-weirather/pythologist | pythologist/__init__.py | CellDataFrame.prune_neighbors | def prune_neighbors(self):
"""
If the CellDataFrame has been subsetted, some of the cell-cell contacts may no longer be part of the the dataset. This prunes those no-longer existant connections.
Returns:
CellDataFrame: A CellDataFrame with only valid cell-cell contacts
"""
... | python | def prune_neighbors(self):
"""
If the CellDataFrame has been subsetted, some of the cell-cell contacts may no longer be part of the the dataset. This prunes those no-longer existant connections.
Returns:
CellDataFrame: A CellDataFrame with only valid cell-cell contacts
"""
... | [
"def",
"prune_neighbors",
"(",
"self",
")",
":",
"def",
"_neighbor_check",
"(",
"neighbors",
",",
"valid",
")",
":",
"if",
"not",
"neighbors",
"==",
"neighbors",
":",
"return",
"np",
".",
"nan",
"valid_keys",
"=",
"set",
"(",
"valid",
")",
"&",
"set",
... | If the CellDataFrame has been subsetted, some of the cell-cell contacts may no longer be part of the the dataset. This prunes those no-longer existant connections.
Returns:
CellDataFrame: A CellDataFrame with only valid cell-cell contacts | [
"If",
"the",
"CellDataFrame",
"has",
"been",
"subsetted",
"some",
"of",
"the",
"cell",
"-",
"cell",
"contacts",
"may",
"no",
"longer",
"be",
"part",
"of",
"the",
"the",
"dataset",
".",
"This",
"prunes",
"those",
"no",
"-",
"longer",
"existant",
"connection... | 6eb4082be9dffa9570e4ceaa06d97845eac4c006 | https://github.com/jason-weirather/pythologist/blob/6eb4082be9dffa9570e4ceaa06d97845eac4c006/pythologist/__init__.py#L56-L78 | train |
jason-weirather/pythologist | pythologist/__init__.py | CellDataFrame.to_hdf | def to_hdf(self,path,key,mode='a'):
"""
Save the CellDataFrame to an hdf5 file.
Args:
path (str): the path to save to
key (str): the name of the location to save it to
mode (str): write mode
"""
pd.DataFrame(self.serialize()).to_hdf(path,key,m... | python | def to_hdf(self,path,key,mode='a'):
"""
Save the CellDataFrame to an hdf5 file.
Args:
path (str): the path to save to
key (str): the name of the location to save it to
mode (str): write mode
"""
pd.DataFrame(self.serialize()).to_hdf(path,key,m... | [
"def",
"to_hdf",
"(",
"self",
",",
"path",
",",
"key",
",",
"mode",
"=",
"'a'",
")",
":",
"pd",
".",
"DataFrame",
"(",
"self",
".",
"serialize",
"(",
")",
")",
".",
"to_hdf",
"(",
"path",
",",
"key",
",",
"mode",
"=",
"mode",
",",
"format",
"="... | Save the CellDataFrame to an hdf5 file.
Args:
path (str): the path to save to
key (str): the name of the location to save it to
mode (str): write mode | [
"Save",
"the",
"CellDataFrame",
"to",
"an",
"hdf5",
"file",
"."
] | 6eb4082be9dffa9570e4ceaa06d97845eac4c006 | https://github.com/jason-weirather/pythologist/blob/6eb4082be9dffa9570e4ceaa06d97845eac4c006/pythologist/__init__.py#L102-L114 | train |
jason-weirather/pythologist | pythologist/__init__.py | CellDataFrame.phenotypes_to_scored | def phenotypes_to_scored(self,phenotypes=None,overwrite=False):
"""
Add mutually exclusive phenotypes to the scored calls
Args:
phenotypes (list): a list of phenotypes to add to scored calls. if none or not set, add them all
overwrite (bool): if True allow the overwrite... | python | def phenotypes_to_scored(self,phenotypes=None,overwrite=False):
"""
Add mutually exclusive phenotypes to the scored calls
Args:
phenotypes (list): a list of phenotypes to add to scored calls. if none or not set, add them all
overwrite (bool): if True allow the overwrite... | [
"def",
"phenotypes_to_scored",
"(",
"self",
",",
"phenotypes",
"=",
"None",
",",
"overwrite",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"is_uniform",
"(",
")",
":",
"raise",
"ValueError",
"(",
"\"inconsistent phenotypes\"",
")",
"if",
"phenotypes",
"... | Add mutually exclusive phenotypes to the scored calls
Args:
phenotypes (list): a list of phenotypes to add to scored calls. if none or not set, add them all
overwrite (bool): if True allow the overwrite of a phenotype, if False, the phenotype must not exist in the scored calls
... | [
"Add",
"mutually",
"exclusive",
"phenotypes",
"to",
"the",
"scored",
"calls"
] | 6eb4082be9dffa9570e4ceaa06d97845eac4c006 | https://github.com/jason-weirather/pythologist/blob/6eb4082be9dffa9570e4ceaa06d97845eac4c006/pythologist/__init__.py#L116-L143 | train |
jason-weirather/pythologist | pythologist/__init__.py | CellDataFrame.concat | def concat(self,array_like):
"""
Concatonate multiple CellDataFrames
throws an error if the microns_per_pixel is not uniform across the frames
Args:
array_like (list): a list of CellDataFrames with 1 or more CellDataFrames
Returns:
CellDataFrame
... | python | def concat(self,array_like):
"""
Concatonate multiple CellDataFrames
throws an error if the microns_per_pixel is not uniform across the frames
Args:
array_like (list): a list of CellDataFrames with 1 or more CellDataFrames
Returns:
CellDataFrame
... | [
"def",
"concat",
"(",
"self",
",",
"array_like",
")",
":",
"arr",
"=",
"list",
"(",
"array_like",
")",
"if",
"len",
"(",
"set",
"(",
"[",
"x",
".",
"microns_per_pixel",
"for",
"x",
"in",
"arr",
"]",
")",
")",
"!=",
"1",
":",
"raise",
"ValueError",
... | Concatonate multiple CellDataFrames
throws an error if the microns_per_pixel is not uniform across the frames
Args:
array_like (list): a list of CellDataFrames with 1 or more CellDataFrames
Returns:
CellDataFrame | [
"Concatonate",
"multiple",
"CellDataFrames"
] | 6eb4082be9dffa9570e4ceaa06d97845eac4c006 | https://github.com/jason-weirather/pythologist/blob/6eb4082be9dffa9570e4ceaa06d97845eac4c006/pythologist/__init__.py#L147-L164 | train |
jason-weirather/pythologist | pythologist/__init__.py | CellDataFrame.read_hdf | def read_hdf(cls,path,key=None):
"""
Read a CellDataFrame from an hdf5 file.
Args:
path (str): the path to read from
key (str): the name of the location to read from
Returns:
CellDataFrame
"""
df = pd.read_hdf(path,key)
df['sc... | python | def read_hdf(cls,path,key=None):
"""
Read a CellDataFrame from an hdf5 file.
Args:
path (str): the path to read from
key (str): the name of the location to read from
Returns:
CellDataFrame
"""
df = pd.read_hdf(path,key)
df['sc... | [
"def",
"read_hdf",
"(",
"cls",
",",
"path",
",",
"key",
"=",
"None",
")",
":",
"df",
"=",
"pd",
".",
"read_hdf",
"(",
"path",
",",
"key",
")",
"df",
"[",
"'scored_calls'",
"]",
"=",
"df",
"[",
"'scored_calls'",
"]",
".",
"apply",
"(",
"lambda",
"... | Read a CellDataFrame from an hdf5 file.
Args:
path (str): the path to read from
key (str): the name of the location to read from
Returns:
CellDataFrame | [
"Read",
"a",
"CellDataFrame",
"from",
"an",
"hdf5",
"file",
"."
] | 6eb4082be9dffa9570e4ceaa06d97845eac4c006 | https://github.com/jason-weirather/pythologist/blob/6eb4082be9dffa9570e4ceaa06d97845eac4c006/pythologist/__init__.py#L168-L194 | train |
jason-weirather/pythologist | pythologist/__init__.py | CellDataFrame.serialize | def serialize(self):
"""
Convert the data to one that can be saved in h5 structures
Returns:
pandas.DataFrame: like a cell data frame but serialized. columns
"""
df = self.copy()
df['scored_calls'] = df['scored_calls'].apply(lambda x: json.dumps(x))
d... | python | def serialize(self):
"""
Convert the data to one that can be saved in h5 structures
Returns:
pandas.DataFrame: like a cell data frame but serialized. columns
"""
df = self.copy()
df['scored_calls'] = df['scored_calls'].apply(lambda x: json.dumps(x))
d... | [
"def",
"serialize",
"(",
"self",
")",
":",
"df",
"=",
"self",
".",
"copy",
"(",
")",
"df",
"[",
"'scored_calls'",
"]",
"=",
"df",
"[",
"'scored_calls'",
"]",
".",
"apply",
"(",
"lambda",
"x",
":",
"json",
".",
"dumps",
"(",
"x",
")",
")",
"df",
... | Convert the data to one that can be saved in h5 structures
Returns:
pandas.DataFrame: like a cell data frame but serialized. columns | [
"Convert",
"the",
"data",
"to",
"one",
"that",
"can",
"be",
"saved",
"in",
"h5",
"structures"
] | 6eb4082be9dffa9570e4ceaa06d97845eac4c006 | https://github.com/jason-weirather/pythologist/blob/6eb4082be9dffa9570e4ceaa06d97845eac4c006/pythologist/__init__.py#L196-L210 | train |
jason-weirather/pythologist | pythologist/__init__.py | CellDataFrame.contacts | def contacts(self,*args,**kwargs):
"""
Use assess the cell-to-cell contacts recorded in the celldataframe
Returns:
Contacts: returns a class that holds cell-to-cell contact information for whatever phenotypes were in the CellDataFrame before execution.
"""
n = Cont... | python | def contacts(self,*args,**kwargs):
"""
Use assess the cell-to-cell contacts recorded in the celldataframe
Returns:
Contacts: returns a class that holds cell-to-cell contact information for whatever phenotypes were in the CellDataFrame before execution.
"""
n = Cont... | [
"def",
"contacts",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"n",
"=",
"Contacts",
".",
"read_cellframe",
"(",
"self",
",",
"prune_neighbors",
"=",
"True",
")",
"if",
"'measured_regions'",
"in",
"kwargs",
":",
"n",
".",
"measured_regi... | Use assess the cell-to-cell contacts recorded in the celldataframe
Returns:
Contacts: returns a class that holds cell-to-cell contact information for whatever phenotypes were in the CellDataFrame before execution. | [
"Use",
"assess",
"the",
"cell",
"-",
"to",
"-",
"cell",
"contacts",
"recorded",
"in",
"the",
"celldataframe"
] | 6eb4082be9dffa9570e4ceaa06d97845eac4c006 | https://github.com/jason-weirather/pythologist/blob/6eb4082be9dffa9570e4ceaa06d97845eac4c006/pythologist/__init__.py#L332-L345 | train |
jason-weirather/pythologist | pythologist/__init__.py | CellDataFrame.cartesian | def cartesian(self,subsets=None,step_pixels=100,max_distance_pixels=150,*args,**kwargs):
"""
Return a class that can be used to create honeycomb plots
Args:
subsets (list): list of SubsetLogic objects
step_pixels (int): distance between hexagons
max_distance_... | python | def cartesian(self,subsets=None,step_pixels=100,max_distance_pixels=150,*args,**kwargs):
"""
Return a class that can be used to create honeycomb plots
Args:
subsets (list): list of SubsetLogic objects
step_pixels (int): distance between hexagons
max_distance_... | [
"def",
"cartesian",
"(",
"self",
",",
"subsets",
"=",
"None",
",",
"step_pixels",
"=",
"100",
",",
"max_distance_pixels",
"=",
"150",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"n",
"=",
"Cartesian",
".",
"read_cellframe",
"(",
"self",
",",
"subs... | Return a class that can be used to create honeycomb plots
Args:
subsets (list): list of SubsetLogic objects
step_pixels (int): distance between hexagons
max_distance_pixels (int): the distance from each point by which to caclulate the quanitty of the phenotype for that area
... | [
"Return",
"a",
"class",
"that",
"can",
"be",
"used",
"to",
"create",
"honeycomb",
"plots"
] | 6eb4082be9dffa9570e4ceaa06d97845eac4c006 | https://github.com/jason-weirather/pythologist/blob/6eb4082be9dffa9570e4ceaa06d97845eac4c006/pythologist/__init__.py#L347-L365 | train |
jason-weirather/pythologist | pythologist/__init__.py | CellDataFrame.counts | def counts(self,*args,**kwargs):
"""
Return a class that can be used to access count densities
Args:
measured_regions (pandas.DataFrame): Dataframe of regions that are being measured (defaults to all the regions)
measured_phenotypes (list): List of phenotypes present (de... | python | def counts(self,*args,**kwargs):
"""
Return a class that can be used to access count densities
Args:
measured_regions (pandas.DataFrame): Dataframe of regions that are being measured (defaults to all the regions)
measured_phenotypes (list): List of phenotypes present (de... | [
"def",
"counts",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"n",
"=",
"Counts",
".",
"read_cellframe",
"(",
"self",
",",
"prune_neighbors",
"=",
"False",
")",
"if",
"'measured_regions'",
"in",
"kwargs",
":",
"n",
".",
"measured_regions... | Return a class that can be used to access count densities
Args:
measured_regions (pandas.DataFrame): Dataframe of regions that are being measured (defaults to all the regions)
measured_phenotypes (list): List of phenotypes present (defaults to all the phenotypes)
minimum_reg... | [
"Return",
"a",
"class",
"that",
"can",
"be",
"used",
"to",
"access",
"count",
"densities"
] | 6eb4082be9dffa9570e4ceaa06d97845eac4c006 | https://github.com/jason-weirather/pythologist/blob/6eb4082be9dffa9570e4ceaa06d97845eac4c006/pythologist/__init__.py#L367-L387 | train |
jason-weirather/pythologist | pythologist/__init__.py | CellDataFrame.merge_scores | def merge_scores(self,df_addition,reference_markers='all',
addition_markers='all',on=['project_name','sample_name','frame_name','cell_index']):
"""
Combine CellDataFrames that differ by score composition
Args:
df_addition (CellDataFrame): The Ce... | python | def merge_scores(self,df_addition,reference_markers='all',
addition_markers='all',on=['project_name','sample_name','frame_name','cell_index']):
"""
Combine CellDataFrames that differ by score composition
Args:
df_addition (CellDataFrame): The Ce... | [
"def",
"merge_scores",
"(",
"self",
",",
"df_addition",
",",
"reference_markers",
"=",
"'all'",
",",
"addition_markers",
"=",
"'all'",
",",
"on",
"=",
"[",
"'project_name'",
",",
"'sample_name'",
",",
"'frame_name'",
",",
"'cell_index'",
"]",
")",
":",
"if",
... | Combine CellDataFrames that differ by score composition
Args:
df_addition (CellDataFrame): The CellDataFrame to merge scores in from
reference_markers (list): which scored call names to keep in the this object (default: all)
addition_markers (list): which scored call names t... | [
"Combine",
"CellDataFrames",
"that",
"differ",
"by",
"score",
"composition"
] | 6eb4082be9dffa9570e4ceaa06d97845eac4c006 | https://github.com/jason-weirather/pythologist/blob/6eb4082be9dffa9570e4ceaa06d97845eac4c006/pythologist/__init__.py#L409-L451 | train |
jason-weirather/pythologist | pythologist/__init__.py | CellDataFrame.zero_fill_missing_phenotypes | def zero_fill_missing_phenotypes(self):
"""
Fill in missing phenotypes and scored types by listing any missing data as negative
Returns:
CellDataFrame: The CellDataFrame modified.
"""
if self.is_uniform(verbose=False): return self.copy()
output = self.copy()
... | python | def zero_fill_missing_phenotypes(self):
"""
Fill in missing phenotypes and scored types by listing any missing data as negative
Returns:
CellDataFrame: The CellDataFrame modified.
"""
if self.is_uniform(verbose=False): return self.copy()
output = self.copy()
... | [
"def",
"zero_fill_missing_phenotypes",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_uniform",
"(",
"verbose",
"=",
"False",
")",
":",
"return",
"self",
".",
"copy",
"(",
")",
"output",
"=",
"self",
".",
"copy",
"(",
")",
"def",
"_do_fill",
"(",
"d",
... | Fill in missing phenotypes and scored types by listing any missing data as negative
Returns:
CellDataFrame: The CellDataFrame modified. | [
"Fill",
"in",
"missing",
"phenotypes",
"and",
"scored",
"types",
"by",
"listing",
"any",
"missing",
"data",
"as",
"negative"
] | 6eb4082be9dffa9570e4ceaa06d97845eac4c006 | https://github.com/jason-weirather/pythologist/blob/6eb4082be9dffa9570e4ceaa06d97845eac4c006/pythologist/__init__.py#L469-L488 | train |
jason-weirather/pythologist | pythologist/__init__.py | CellDataFrame.drop_scored_calls | def drop_scored_calls(self,names):
"""
Take a name or list of scored call names and drop those from the scored calls
Args:
names (list): list of names to drop or a single string name to drop
Returns:
CellDataFrame: The CellDataFrame modified.
"""
... | python | def drop_scored_calls(self,names):
"""
Take a name or list of scored call names and drop those from the scored calls
Args:
names (list): list of names to drop or a single string name to drop
Returns:
CellDataFrame: The CellDataFrame modified.
"""
... | [
"def",
"drop_scored_calls",
"(",
"self",
",",
"names",
")",
":",
"def",
"_remove",
"(",
"calls",
",",
"names",
")",
":",
"d",
"=",
"dict",
"(",
"[",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"calls",
".",
"items",
"(",
")",
"if",
"... | Take a name or list of scored call names and drop those from the scored calls
Args:
names (list): list of names to drop or a single string name to drop
Returns:
CellDataFrame: The CellDataFrame modified. | [
"Take",
"a",
"name",
"or",
"list",
"of",
"scored",
"call",
"names",
"and",
"drop",
"those",
"from",
"the",
"scored",
"calls"
] | 6eb4082be9dffa9570e4ceaa06d97845eac4c006 | https://github.com/jason-weirather/pythologist/blob/6eb4082be9dffa9570e4ceaa06d97845eac4c006/pythologist/__init__.py#L490-L508 | train |
jason-weirather/pythologist | pythologist/__init__.py | CellDataFrame.subset | def subset(self,logic,update=False):
"""
subset create a specific phenotype based on a logic,
logic is a 'SubsetLogic' class,
take union of all the phenotypes listed. If none are listed use all phenotypes.
take the intersection of all the scored calls.
Args:
... | python | def subset(self,logic,update=False):
"""
subset create a specific phenotype based on a logic,
logic is a 'SubsetLogic' class,
take union of all the phenotypes listed. If none are listed use all phenotypes.
take the intersection of all the scored calls.
Args:
... | [
"def",
"subset",
"(",
"self",
",",
"logic",
",",
"update",
"=",
"False",
")",
":",
"pnames",
"=",
"self",
".",
"phenotypes",
"snames",
"=",
"self",
".",
"scored_names",
"data",
"=",
"self",
".",
"copy",
"(",
")",
"values",
"=",
"[",
"]",
"phenotypes"... | subset create a specific phenotype based on a logic,
logic is a 'SubsetLogic' class,
take union of all the phenotypes listed. If none are listed use all phenotypes.
take the intersection of all the scored calls.
Args:
logic (SubsetLogic): A subsetlogic object to slice on... | [
"subset",
"create",
"a",
"specific",
"phenotype",
"based",
"on",
"a",
"logic",
"logic",
"is",
"a",
"SubsetLogic",
"class",
"take",
"union",
"of",
"all",
"the",
"phenotypes",
"listed",
".",
"If",
"none",
"are",
"listed",
"use",
"all",
"phenotypes",
".",
"ta... | 6eb4082be9dffa9570e4ceaa06d97845eac4c006 | https://github.com/jason-weirather/pythologist/blob/6eb4082be9dffa9570e4ceaa06d97845eac4c006/pythologist/__init__.py#L511-L550 | train |
jason-weirather/pythologist | pythologist/__init__.py | CellDataFrame.collapse_phenotypes | def collapse_phenotypes(self,input_phenotype_labels,output_phenotype_label,verbose=True):
"""
Rename one or more input phenotypes to a single output phenotype
Args:
input_phenotype_labels (list): A str name or list of names to combine
output_phenotype_label (list): A str... | python | def collapse_phenotypes(self,input_phenotype_labels,output_phenotype_label,verbose=True):
"""
Rename one or more input phenotypes to a single output phenotype
Args:
input_phenotype_labels (list): A str name or list of names to combine
output_phenotype_label (list): A str... | [
"def",
"collapse_phenotypes",
"(",
"self",
",",
"input_phenotype_labels",
",",
"output_phenotype_label",
",",
"verbose",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"input_phenotype_labels",
",",
"str",
")",
":",
"input_phenotype_labels",
"=",
"[",
"input_phenot... | Rename one or more input phenotypes to a single output phenotype
Args:
input_phenotype_labels (list): A str name or list of names to combine
output_phenotype_label (list): A str name to change the phenotype names to
verbose (bool): output more details
Returns:
... | [
"Rename",
"one",
"or",
"more",
"input",
"phenotypes",
"to",
"a",
"single",
"output",
"phenotype"
] | 6eb4082be9dffa9570e4ceaa06d97845eac4c006 | https://github.com/jason-weirather/pythologist/blob/6eb4082be9dffa9570e4ceaa06d97845eac4c006/pythologist/__init__.py#L601-L635 | train |
jason-weirather/pythologist | pythologist/__init__.py | CellDataFrame.fill_phenotype_label | def fill_phenotype_label(self,inplace=False):
"""
Set the phenotype_label column according to our rules for mutual exclusion
"""
def _get_phenotype(d):
vals = [k for k,v in d.items() if v == 1]
return np.nan if len(vals) == 0 else vals[0]
if inplace:
... | python | def fill_phenotype_label(self,inplace=False):
"""
Set the phenotype_label column according to our rules for mutual exclusion
"""
def _get_phenotype(d):
vals = [k for k,v in d.items() if v == 1]
return np.nan if len(vals) == 0 else vals[0]
if inplace:
... | [
"def",
"fill_phenotype_label",
"(",
"self",
",",
"inplace",
"=",
"False",
")",
":",
"def",
"_get_phenotype",
"(",
"d",
")",
":",
"vals",
"=",
"[",
"k",
"for",
"k",
",",
"v",
"in",
"d",
".",
"items",
"(",
")",
"if",
"v",
"==",
"1",
"]",
"return",
... | Set the phenotype_label column according to our rules for mutual exclusion | [
"Set",
"the",
"phenotype_label",
"column",
"according",
"to",
"our",
"rules",
"for",
"mutual",
"exclusion"
] | 6eb4082be9dffa9570e4ceaa06d97845eac4c006 | https://github.com/jason-weirather/pythologist/blob/6eb4082be9dffa9570e4ceaa06d97845eac4c006/pythologist/__init__.py#L676-L690 | train |
jason-weirather/pythologist | pythologist/__init__.py | CellDataFrame.fill_phenotype_calls | def fill_phenotype_calls(self,phenotypes=None,inplace=False):
"""
Set the phenotype_calls according to the phenotype names
"""
if phenotypes is None: phenotypes = list(self['phenotype_label'].unique())
def _get_calls(label,phenos):
d = dict([(x,0) for x in phenos])
... | python | def fill_phenotype_calls(self,phenotypes=None,inplace=False):
"""
Set the phenotype_calls according to the phenotype names
"""
if phenotypes is None: phenotypes = list(self['phenotype_label'].unique())
def _get_calls(label,phenos):
d = dict([(x,0) for x in phenos])
... | [
"def",
"fill_phenotype_calls",
"(",
"self",
",",
"phenotypes",
"=",
"None",
",",
"inplace",
"=",
"False",
")",
":",
"if",
"phenotypes",
"is",
"None",
":",
"phenotypes",
"=",
"list",
"(",
"self",
"[",
"'phenotype_label'",
"]",
".",
"unique",
"(",
")",
")"... | Set the phenotype_calls according to the phenotype names | [
"Set",
"the",
"phenotype_calls",
"according",
"to",
"the",
"phenotype",
"names"
] | 6eb4082be9dffa9570e4ceaa06d97845eac4c006 | https://github.com/jason-weirather/pythologist/blob/6eb4082be9dffa9570e4ceaa06d97845eac4c006/pythologist/__init__.py#L691-L706 | train |
jason-weirather/pythologist | pythologist/__init__.py | CellDataFrame.scored_to_phenotype | def scored_to_phenotype(self,phenotypes):
"""
Convert binary pehnotypes to mutually exclusive phenotypes.
If none of the phenotypes are set, then phenotype_label becomes nan
If any of the phenotypes are multiply set then it throws a fatal error.
Args:
phenotypes (li... | python | def scored_to_phenotype(self,phenotypes):
"""
Convert binary pehnotypes to mutually exclusive phenotypes.
If none of the phenotypes are set, then phenotype_label becomes nan
If any of the phenotypes are multiply set then it throws a fatal error.
Args:
phenotypes (li... | [
"def",
"scored_to_phenotype",
"(",
"self",
",",
"phenotypes",
")",
":",
"def",
"_apply_score",
"(",
"scored_calls",
",",
"phenotypes",
")",
":",
"present",
"=",
"sorted",
"(",
"list",
"(",
"set",
"(",
"phenotypes",
")",
"&",
"set",
"(",
"scored_calls",
"."... | Convert binary pehnotypes to mutually exclusive phenotypes.
If none of the phenotypes are set, then phenotype_label becomes nan
If any of the phenotypes are multiply set then it throws a fatal error.
Args:
phenotypes (list): a list of scored_names to convert to phenotypes
... | [
"Convert",
"binary",
"pehnotypes",
"to",
"mutually",
"exclusive",
"phenotypes",
".",
"If",
"none",
"of",
"the",
"phenotypes",
"are",
"set",
"then",
"phenotype_label",
"becomes",
"nan",
"If",
"any",
"of",
"the",
"phenotypes",
"are",
"multiply",
"set",
"then",
"... | 6eb4082be9dffa9570e4ceaa06d97845eac4c006 | https://github.com/jason-weirather/pythologist/blob/6eb4082be9dffa9570e4ceaa06d97845eac4c006/pythologist/__init__.py#L724-L751 | train |
yamcs/yamcs-python | yamcs-client/examples/commanding.py | issue_and_listen_to_command_history | def issue_and_listen_to_command_history():
"""Listen to command history updates of a single issued command."""
def tc_callback(rec):
print('TC:', rec)
command = processor.issue_command('/YSS/SIMULATOR/SWITCH_VOLTAGE_OFF', args={
'voltage_num': 1,
}, comment='im a comment')
command.c... | python | def issue_and_listen_to_command_history():
"""Listen to command history updates of a single issued command."""
def tc_callback(rec):
print('TC:', rec)
command = processor.issue_command('/YSS/SIMULATOR/SWITCH_VOLTAGE_OFF', args={
'voltage_num': 1,
}, comment='im a comment')
command.c... | [
"def",
"issue_and_listen_to_command_history",
"(",
")",
":",
"def",
"tc_callback",
"(",
"rec",
")",
":",
"print",
"(",
"'TC:'",
",",
"rec",
")",
"command",
"=",
"processor",
".",
"issue_command",
"(",
"'/YSS/SIMULATOR/SWITCH_VOLTAGE_OFF'",
",",
"args",
"=",
"{",... | Listen to command history updates of a single issued command. | [
"Listen",
"to",
"command",
"history",
"updates",
"of",
"a",
"single",
"issued",
"command",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/examples/commanding.py#L24-L32 | train |
LeKono/pyhgnc | src/pyhgnc/manager/models.py | get_many2many_table | def get_many2many_table(table1, table2):
"""Creates a many-to-many table that links the given tables table1 and table2.
:param str table1: Tablename of left hand table without TABLE_PREFIX.
:param str table2: Tablename of right hand table without TABLE_PREFIX.
:return:
"""
table_name = ('{}{}__... | python | def get_many2many_table(table1, table2):
"""Creates a many-to-many table that links the given tables table1 and table2.
:param str table1: Tablename of left hand table without TABLE_PREFIX.
:param str table2: Tablename of right hand table without TABLE_PREFIX.
:return:
"""
table_name = ('{}{}__... | [
"def",
"get_many2many_table",
"(",
"table1",
",",
"table2",
")",
":",
"table_name",
"=",
"(",
"'{}{}__{}'",
".",
"format",
"(",
"TABLE_PREFIX",
",",
"table1",
",",
"table2",
")",
")",
"return",
"Table",
"(",
"table_name",
",",
"Base",
".",
"metadata",
",",... | Creates a many-to-many table that links the given tables table1 and table2.
:param str table1: Tablename of left hand table without TABLE_PREFIX.
:param str table2: Tablename of right hand table without TABLE_PREFIX.
:return: | [
"Creates",
"a",
"many",
"-",
"to",
"-",
"many",
"table",
"that",
"links",
"the",
"given",
"tables",
"table1",
"and",
"table2",
"."
] | 1cae20c40874bfb51581b7c5c1481707e942b5d0 | https://github.com/LeKono/pyhgnc/blob/1cae20c40874bfb51581b7c5c1481707e942b5d0/src/pyhgnc/manager/models.py#L25-L36 | train |
Frzk/Ellis | ellis/search_matches.py | SearchMatches.search | async def search(self, regex):
"""
Wraps the search for a match in an `executor`_ and awaits for it.
.. _executor: https://docs.python.org/3/library/asyncio-eventloop.html#executor
"""
coro = self._loop.run_in_executor(None, self._search, regex)
match = await coro
... | python | async def search(self, regex):
"""
Wraps the search for a match in an `executor`_ and awaits for it.
.. _executor: https://docs.python.org/3/library/asyncio-eventloop.html#executor
"""
coro = self._loop.run_in_executor(None, self._search, regex)
match = await coro
... | [
"async",
"def",
"search",
"(",
"self",
",",
"regex",
")",
":",
"coro",
"=",
"self",
".",
"_loop",
".",
"run_in_executor",
"(",
"None",
",",
"self",
".",
"_search",
",",
"regex",
")",
"match",
"=",
"await",
"coro",
"return",
"match"
] | Wraps the search for a match in an `executor`_ and awaits for it.
.. _executor: https://docs.python.org/3/library/asyncio-eventloop.html#executor | [
"Wraps",
"the",
"search",
"for",
"a",
"match",
"in",
"an",
"executor",
"_",
"and",
"awaits",
"for",
"it",
"."
] | 39ce8987cbc503354cf1f45927344186a8b18363 | https://github.com/Frzk/Ellis/blob/39ce8987cbc503354cf1f45927344186a8b18363/ellis/search_matches.py#L45-L54 | train |
sirfoga/pyhal | hal/streams/user.py | UserInput.show_help | def show_help(self):
"""Prints to stdout help on how to answer properly"""
print("Sorry, not well understood.")
print("- use", str(self.yes_input), "to answer 'YES'")
print("- use", str(self.no_input), "to answer 'NO'") | python | def show_help(self):
"""Prints to stdout help on how to answer properly"""
print("Sorry, not well understood.")
print("- use", str(self.yes_input), "to answer 'YES'")
print("- use", str(self.no_input), "to answer 'NO'") | [
"def",
"show_help",
"(",
"self",
")",
":",
"print",
"(",
"\"Sorry, not well understood.\"",
")",
"print",
"(",
"\"- use\"",
",",
"str",
"(",
"self",
".",
"yes_input",
")",
",",
"\"to answer 'YES'\"",
")",
"print",
"(",
"\"- use\"",
",",
"str",
"(",
"self",
... | Prints to stdout help on how to answer properly | [
"Prints",
"to",
"stdout",
"help",
"on",
"how",
"to",
"answer",
"properly"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/streams/user.py#L61-L65 | train |
sirfoga/pyhal | hal/streams/user.py | UserInput.re_ask | def re_ask(self, with_help=True):
"""Re-asks user the last question
:param with_help: True iff you want to show help on how to answer
questions
:return: user answer
"""
if with_help:
self.show_help()
return self.get_answer(self.last_question) | python | def re_ask(self, with_help=True):
"""Re-asks user the last question
:param with_help: True iff you want to show help on how to answer
questions
:return: user answer
"""
if with_help:
self.show_help()
return self.get_answer(self.last_question) | [
"def",
"re_ask",
"(",
"self",
",",
"with_help",
"=",
"True",
")",
":",
"if",
"with_help",
":",
"self",
".",
"show_help",
"(",
")",
"return",
"self",
".",
"get_answer",
"(",
"self",
".",
"last_question",
")"
] | Re-asks user the last question
:param with_help: True iff you want to show help on how to answer
questions
:return: user answer | [
"Re",
"-",
"asks",
"user",
"the",
"last",
"question"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/streams/user.py#L67-L77 | train |
sirfoga/pyhal | hal/streams/user.py | UserInput.get_answer | def get_answer(self, question):
"""Asks user a question, then gets user answer
:param question: Question: to ask user
:return: User answer
"""
self.last_question = str(question).strip()
user_answer = input(self.last_question)
return user_answer.strip() | python | def get_answer(self, question):
"""Asks user a question, then gets user answer
:param question: Question: to ask user
:return: User answer
"""
self.last_question = str(question).strip()
user_answer = input(self.last_question)
return user_answer.strip() | [
"def",
"get_answer",
"(",
"self",
",",
"question",
")",
":",
"self",
".",
"last_question",
"=",
"str",
"(",
"question",
")",
".",
"strip",
"(",
")",
"user_answer",
"=",
"input",
"(",
"self",
".",
"last_question",
")",
"return",
"user_answer",
".",
"strip... | Asks user a question, then gets user answer
:param question: Question: to ask user
:return: User answer | [
"Asks",
"user",
"a",
"question",
"then",
"gets",
"user",
"answer"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/streams/user.py#L79-L87 | train |
sirfoga/pyhal | hal/streams/user.py | UserInput.get_number | def get_number(self, question, min_i=float("-inf"), max_i=float("inf"),
just_these=None):
"""Parses answer and gets number
:param question: Question: to ask user
:param min_i: min acceptable number
:param max_i: max acceptable number
:param just_these: Accept ... | python | def get_number(self, question, min_i=float("-inf"), max_i=float("inf"),
just_these=None):
"""Parses answer and gets number
:param question: Question: to ask user
:param min_i: min acceptable number
:param max_i: max acceptable number
:param just_these: Accept ... | [
"def",
"get_number",
"(",
"self",
",",
"question",
",",
"min_i",
"=",
"float",
"(",
"\"-inf\"",
")",
",",
"max_i",
"=",
"float",
"(",
"\"inf\"",
")",
",",
"just_these",
"=",
"None",
")",
":",
"try",
":",
"user_answer",
"=",
"self",
".",
"get_answer",
... | Parses answer and gets number
:param question: Question: to ask user
:param min_i: min acceptable number
:param max_i: max acceptable number
:param just_these: Accept only these numbers
:return: User answer | [
"Parses",
"answer",
"and",
"gets",
"number"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/streams/user.py#L116-L151 | train |
sirfoga/pyhal | hal/streams/user.py | UserInput.get_list | def get_list(self, question,
splitter=",", at_least=0, at_most=float("inf")):
"""Parses answer and gets list
:param question: Question: to ask user
:param splitter: Split list elements with this char
:param at_least: List must have at least this amount of elements
... | python | def get_list(self, question,
splitter=",", at_least=0, at_most=float("inf")):
"""Parses answer and gets list
:param question: Question: to ask user
:param splitter: Split list elements with this char
:param at_least: List must have at least this amount of elements
... | [
"def",
"get_list",
"(",
"self",
",",
"question",
",",
"splitter",
"=",
"\",\"",
",",
"at_least",
"=",
"0",
",",
"at_most",
"=",
"float",
"(",
"\"inf\"",
")",
")",
":",
"try",
":",
"user_answer",
"=",
"self",
".",
"get_answer",
"(",
"question",
")",
"... | Parses answer and gets list
:param question: Question: to ask user
:param splitter: Split list elements with this char
:param at_least: List must have at least this amount of elements
:param at_most: List must have at most this amount of elements
:return: User answer | [
"Parses",
"answer",
"and",
"gets",
"list"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/streams/user.py#L153-L182 | train |
portfors-lab/sparkle | sparkle/data/batlabdata.py | batlab2sparkle | def batlab2sparkle(experiment_data):
"""Sparkle expects meta data to have a certain heirarchial organization,
reformat batlab experiment data to fit.
"""
# This is mostly for convention.. attribute that matters most is samplerate,
# since it is used in the GUI to calculate things like duration
... | python | def batlab2sparkle(experiment_data):
"""Sparkle expects meta data to have a certain heirarchial organization,
reformat batlab experiment data to fit.
"""
# This is mostly for convention.. attribute that matters most is samplerate,
# since it is used in the GUI to calculate things like duration
... | [
"def",
"batlab2sparkle",
"(",
"experiment_data",
")",
":",
"nsdata",
"=",
"{",
"}",
"for",
"attr",
"in",
"[",
"'computername'",
",",
"'pst_filename'",
",",
"'title'",
",",
"'who'",
",",
"'date'",
",",
"'program_date'",
"]",
":",
"nsdata",
"[",
"attr",
"]",... | Sparkle expects meta data to have a certain heirarchial organization,
reformat batlab experiment data to fit. | [
"Sparkle",
"expects",
"meta",
"data",
"to",
"have",
"a",
"certain",
"heirarchial",
"organization",
"reformat",
"batlab",
"experiment",
"data",
"to",
"fit",
"."
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/data/batlabdata.py#L118-L187 | train |
NoviceLive/intellicoder | intellicoder/intellisense/sanitizers.py | sanitize_type | def sanitize_type(raw_type):
"""Sanitize the raw type string."""
cleaned = get_printable(raw_type).strip()
for bad in [
r'__drv_aliasesMem', r'__drv_freesMem',
r'__drv_strictTypeMatch\(\w+\)',
r'__out_data_source\(\w+\)',
r'_In_NLS_string_\(\w+\)',
... | python | def sanitize_type(raw_type):
"""Sanitize the raw type string."""
cleaned = get_printable(raw_type).strip()
for bad in [
r'__drv_aliasesMem', r'__drv_freesMem',
r'__drv_strictTypeMatch\(\w+\)',
r'__out_data_source\(\w+\)',
r'_In_NLS_string_\(\w+\)',
... | [
"def",
"sanitize_type",
"(",
"raw_type",
")",
":",
"cleaned",
"=",
"get_printable",
"(",
"raw_type",
")",
".",
"strip",
"(",
")",
"for",
"bad",
"in",
"[",
"r'__drv_aliasesMem'",
",",
"r'__drv_freesMem'",
",",
"r'__drv_strictTypeMatch\\(\\w+\\)'",
",",
"r'__out_dat... | Sanitize the raw type string. | [
"Sanitize",
"the",
"raw",
"type",
"string",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/intellisense/sanitizers.py#L32-L47 | train |
NoviceLive/intellicoder | intellicoder/intellisense/sanitizers.py | clean_ret_type | def clean_ret_type(ret_type):
"""Clean the erraneous parsed return type."""
ret_type = get_printable(ret_type).strip()
if ret_type == 'LRESULT LRESULT':
ret_type = 'LRESULT'
for bad in [
'DECLSPEC_NORETURN', 'NTSYSCALLAPI', '__kernel_entry',
'__analysis_noreturn', '_Post_... | python | def clean_ret_type(ret_type):
"""Clean the erraneous parsed return type."""
ret_type = get_printable(ret_type).strip()
if ret_type == 'LRESULT LRESULT':
ret_type = 'LRESULT'
for bad in [
'DECLSPEC_NORETURN', 'NTSYSCALLAPI', '__kernel_entry',
'__analysis_noreturn', '_Post_... | [
"def",
"clean_ret_type",
"(",
"ret_type",
")",
":",
"ret_type",
"=",
"get_printable",
"(",
"ret_type",
")",
".",
"strip",
"(",
")",
"if",
"ret_type",
"==",
"'LRESULT LRESULT'",
":",
"ret_type",
"=",
"'LRESULT'",
"for",
"bad",
"in",
"[",
"'DECLSPEC_NORETURN'",
... | Clean the erraneous parsed return type. | [
"Clean",
"the",
"erraneous",
"parsed",
"return",
"type",
"."
] | 6cac5ebfce65c370dbebe47756a1789b120ef982 | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/intellisense/sanitizers.py#L50-L64 | train |
dpa-newslab/livebridge | livebridge/storages/dynamo.py | DynamoClient.setup | async def setup(self):
"""Setting up DynamoDB table, if it not exists."""
try:
client = await self.db
response = await client.list_tables()
created = False
# create table if not already created.
if self.table_name not in response["TableNames"]:... | python | async def setup(self):
"""Setting up DynamoDB table, if it not exists."""
try:
client = await self.db
response = await client.list_tables()
created = False
# create table if not already created.
if self.table_name not in response["TableNames"]:... | [
"async",
"def",
"setup",
"(",
"self",
")",
":",
"try",
":",
"client",
"=",
"await",
"self",
".",
"db",
"response",
"=",
"await",
"client",
".",
"list_tables",
"(",
")",
"created",
"=",
"False",
"if",
"self",
".",
"table_name",
"not",
"in",
"response",
... | Setting up DynamoDB table, if it not exists. | [
"Setting",
"up",
"DynamoDB",
"table",
"if",
"it",
"not",
"exists",
"."
] | d930e887faa2f882d15b574f0f1fe4a580d7c5fa | https://github.com/dpa-newslab/livebridge/blob/d930e887faa2f882d15b574f0f1fe4a580d7c5fa/livebridge/storages/dynamo.py#L106-L130 | train |
portfors-lab/sparkle | sparkle/gui/dialogs/calibration_dlg.py | CalibrationDialog.maxRange | def maxRange(self):
"""Sets the maximum range for the currently selection calibration,
determined from its range of values store on file
"""
try:
x, freqs = self.datafile.get_calibration(str(self.ui.calChoiceCmbbx.currentText()), self.calf)
self.ui.frangeLowSpnbx.... | python | def maxRange(self):
"""Sets the maximum range for the currently selection calibration,
determined from its range of values store on file
"""
try:
x, freqs = self.datafile.get_calibration(str(self.ui.calChoiceCmbbx.currentText()), self.calf)
self.ui.frangeLowSpnbx.... | [
"def",
"maxRange",
"(",
"self",
")",
":",
"try",
":",
"x",
",",
"freqs",
"=",
"self",
".",
"datafile",
".",
"get_calibration",
"(",
"str",
"(",
"self",
".",
"ui",
".",
"calChoiceCmbbx",
".",
"currentText",
"(",
")",
")",
",",
"self",
".",
"calf",
"... | Sets the maximum range for the currently selection calibration,
determined from its range of values store on file | [
"Sets",
"the",
"maximum",
"range",
"for",
"the",
"currently",
"selection",
"calibration",
"determined",
"from",
"its",
"range",
"of",
"values",
"store",
"on",
"file"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/dialogs/calibration_dlg.py#L34-L46 | train |
portfors-lab/sparkle | sparkle/gui/dialogs/calibration_dlg.py | CalibrationDialog.plotCurve | def plotCurve(self):
"""Shows a calibration curve, in a separate window, of the currently selected calibration"""
try:
attenuations, freqs = self.datafile.get_calibration(str(self.ui.calChoiceCmbbx.currentText()), self.calf)
self.pw = SimplePlotWidget(freqs, attenuations, parent=... | python | def plotCurve(self):
"""Shows a calibration curve, in a separate window, of the currently selected calibration"""
try:
attenuations, freqs = self.datafile.get_calibration(str(self.ui.calChoiceCmbbx.currentText()), self.calf)
self.pw = SimplePlotWidget(freqs, attenuations, parent=... | [
"def",
"plotCurve",
"(",
"self",
")",
":",
"try",
":",
"attenuations",
",",
"freqs",
"=",
"self",
".",
"datafile",
".",
"get_calibration",
"(",
"str",
"(",
"self",
".",
"ui",
".",
"calChoiceCmbbx",
".",
"currentText",
"(",
")",
")",
",",
"self",
".",
... | Shows a calibration curve, in a separate window, of the currently selected calibration | [
"Shows",
"a",
"calibration",
"curve",
"in",
"a",
"separate",
"window",
"of",
"the",
"currently",
"selected",
"calibration"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/dialogs/calibration_dlg.py#L48-L59 | train |
portfors-lab/sparkle | sparkle/gui/dialogs/calibration_dlg.py | CalibrationDialog.values | def values(self):
"""Gets the values the user input to this dialog
:returns: dict of inputs:
| *'use_calfile'*: bool, -- whether to apply calibration at all
| *'calname'*: str, -- the name of the calibration dataset to use
| *'frange'*: ... | python | def values(self):
"""Gets the values the user input to this dialog
:returns: dict of inputs:
| *'use_calfile'*: bool, -- whether to apply calibration at all
| *'calname'*: str, -- the name of the calibration dataset to use
| *'frange'*: ... | [
"def",
"values",
"(",
"self",
")",
":",
"results",
"=",
"{",
"}",
"results",
"[",
"'use_calfile'",
"]",
"=",
"self",
".",
"ui",
".",
"calfileRadio",
".",
"isChecked",
"(",
")",
"results",
"[",
"'calname'",
"]",
"=",
"str",
"(",
"self",
".",
"ui",
"... | Gets the values the user input to this dialog
:returns: dict of inputs:
| *'use_calfile'*: bool, -- whether to apply calibration at all
| *'calname'*: str, -- the name of the calibration dataset to use
| *'frange'*: (int, int), -- (min, max) of ... | [
"Gets",
"the",
"values",
"the",
"user",
"input",
"to",
"this",
"dialog"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/dialogs/calibration_dlg.py#L61-L73 | train |
portfors-lab/sparkle | sparkle/gui/dialogs/calibration_dlg.py | CalibrationDialog.conditional_accept | def conditional_accept(self):
"""Accepts the inputs if all values are valid and congruent.
i.e. Valid datafile and frequency range within the given calibration dataset."""
if self.ui.calfileRadio.isChecked() and str(self.ui.calChoiceCmbbx.currentText()) == '':
self.ui.noneRadio.setCh... | python | def conditional_accept(self):
"""Accepts the inputs if all values are valid and congruent.
i.e. Valid datafile and frequency range within the given calibration dataset."""
if self.ui.calfileRadio.isChecked() and str(self.ui.calChoiceCmbbx.currentText()) == '':
self.ui.noneRadio.setCh... | [
"def",
"conditional_accept",
"(",
"self",
")",
":",
"if",
"self",
".",
"ui",
".",
"calfileRadio",
".",
"isChecked",
"(",
")",
"and",
"str",
"(",
"self",
".",
"ui",
".",
"calChoiceCmbbx",
".",
"currentText",
"(",
")",
")",
"==",
"''",
":",
"self",
"."... | Accepts the inputs if all values are valid and congruent.
i.e. Valid datafile and frequency range within the given calibration dataset. | [
"Accepts",
"the",
"inputs",
"if",
"all",
"values",
"are",
"valid",
"and",
"congruent",
".",
"i",
".",
"e",
".",
"Valid",
"datafile",
"and",
"frequency",
"range",
"within",
"the",
"given",
"calibration",
"dataset",
"."
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/dialogs/calibration_dlg.py#L75-L95 | train |
Frzk/Ellis | ellis/main.py | customized_warning | def customized_warning(message, category=UserWarning,
filename='', lineno=-1, file=None, line=None):
"""
Customized function to display warnings.
Monkey patch for `warnings.showwarning`.
"""
print("WARNING: {0}".format(message)) | python | def customized_warning(message, category=UserWarning,
filename='', lineno=-1, file=None, line=None):
"""
Customized function to display warnings.
Monkey patch for `warnings.showwarning`.
"""
print("WARNING: {0}".format(message)) | [
"def",
"customized_warning",
"(",
"message",
",",
"category",
"=",
"UserWarning",
",",
"filename",
"=",
"''",
",",
"lineno",
"=",
"-",
"1",
",",
"file",
"=",
"None",
",",
"line",
"=",
"None",
")",
":",
"print",
"(",
"\"WARNING: {0}\"",
".",
"format",
"... | Customized function to display warnings.
Monkey patch for `warnings.showwarning`. | [
"Customized",
"function",
"to",
"display",
"warnings",
".",
"Monkey",
"patch",
"for",
"warnings",
".",
"showwarning",
"."
] | 39ce8987cbc503354cf1f45927344186a8b18363 | https://github.com/Frzk/Ellis/blob/39ce8987cbc503354cf1f45927344186a8b18363/ellis/main.py#L20-L26 | train |
Frzk/Ellis | ellis/main.py | read_cmdline | def read_cmdline():
"""
Parses optional command line arguments.
"""
info = {
"prog": "Ellis",
"description": "%(prog)s version {0}".format(__version__),
"epilog": "For further help please head over to {0}"
.format(__url__),
"usage": a... | python | def read_cmdline():
"""
Parses optional command line arguments.
"""
info = {
"prog": "Ellis",
"description": "%(prog)s version {0}".format(__version__),
"epilog": "For further help please head over to {0}"
.format(__url__),
"usage": a... | [
"def",
"read_cmdline",
"(",
")",
":",
"info",
"=",
"{",
"\"prog\"",
":",
"\"Ellis\"",
",",
"\"description\"",
":",
"\"%(prog)s version {0}\"",
".",
"format",
"(",
"__version__",
")",
",",
"\"epilog\"",
":",
"\"For further help please head over to {0}\"",
".",
"forma... | Parses optional command line arguments. | [
"Parses",
"optional",
"command",
"line",
"arguments",
"."
] | 39ce8987cbc503354cf1f45927344186a8b18363 | https://github.com/Frzk/Ellis/blob/39ce8987cbc503354cf1f45927344186a8b18363/ellis/main.py#L36-L60 | train |
Frzk/Ellis | ellis/main.py | main | def main():
"""
Entry point for Ellis.
"""
# Monkey patch warnings.showwarning:
warnings.showwarning = customized_warning
# Read command line args, if any:
args = read_cmdline()
# Configuration file, if given on the command line:
config_file = args['config_file']
try:
... | python | def main():
"""
Entry point for Ellis.
"""
# Monkey patch warnings.showwarning:
warnings.showwarning = customized_warning
# Read command line args, if any:
args = read_cmdline()
# Configuration file, if given on the command line:
config_file = args['config_file']
try:
... | [
"def",
"main",
"(",
")",
":",
"warnings",
".",
"showwarning",
"=",
"customized_warning",
"args",
"=",
"read_cmdline",
"(",
")",
"config_file",
"=",
"args",
"[",
"'config_file'",
"]",
"try",
":",
"ellis",
"=",
"Ellis",
"(",
"config_file",
")",
"except",
"No... | Entry point for Ellis. | [
"Entry",
"point",
"for",
"Ellis",
"."
] | 39ce8987cbc503354cf1f45927344186a8b18363 | https://github.com/Frzk/Ellis/blob/39ce8987cbc503354cf1f45927344186a8b18363/ellis/main.py#L63-L83 | train |
AllTheWayDown/turgles | turgles/turgle.py | Turgle.shape | def shape(self, shape=None):
"""We need to shift buffers in order to change shape"""
if shape is None:
return self._shape
data, color = self.renderer.manager.set_shape(self.model.id, shape)
self.model.data = data
self.color = color
self._shape = shape | python | def shape(self, shape=None):
"""We need to shift buffers in order to change shape"""
if shape is None:
return self._shape
data, color = self.renderer.manager.set_shape(self.model.id, shape)
self.model.data = data
self.color = color
self._shape = shape | [
"def",
"shape",
"(",
"self",
",",
"shape",
"=",
"None",
")",
":",
"if",
"shape",
"is",
"None",
":",
"return",
"self",
".",
"_shape",
"data",
",",
"color",
"=",
"self",
".",
"renderer",
".",
"manager",
".",
"set_shape",
"(",
"self",
".",
"model",
".... | We need to shift buffers in order to change shape | [
"We",
"need",
"to",
"shift",
"buffers",
"in",
"order",
"to",
"change",
"shape"
] | 1bb17abe9b3aa0953d9a8e9b05a23369c5bf8852 | https://github.com/AllTheWayDown/turgles/blob/1bb17abe9b3aa0953d9a8e9b05a23369c5bf8852/turgles/turgle.py#L18-L25 | train |
yamcs/yamcs-python | yamcs-client/yamcs/core/futures.py | WebSocketSubscriptionFuture.reply | def reply(self, timeout=None):
"""
Returns the initial reply. This is emitted before any subscription
data is emitted. This function raises an exception if the subscription
attempt failed.
"""
self._wait_on_signal(self._response_received)
if self._response_excepti... | python | def reply(self, timeout=None):
"""
Returns the initial reply. This is emitted before any subscription
data is emitted. This function raises an exception if the subscription
attempt failed.
"""
self._wait_on_signal(self._response_received)
if self._response_excepti... | [
"def",
"reply",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"self",
".",
"_wait_on_signal",
"(",
"self",
".",
"_response_received",
")",
"if",
"self",
".",
"_response_exception",
"is",
"not",
"None",
":",
"msg",
"=",
"self",
".",
"_response_excepti... | Returns the initial reply. This is emitted before any subscription
data is emitted. This function raises an exception if the subscription
attempt failed. | [
"Returns",
"the",
"initial",
"reply",
".",
"This",
"is",
"emitted",
"before",
"any",
"subscription",
"data",
"is",
"emitted",
".",
"This",
"function",
"raises",
"an",
"exception",
"if",
"the",
"subscription",
"attempt",
"failed",
"."
] | 1082fee8a299010cc44416bbb7518fac0ef08b48 | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/yamcs/core/futures.py#L166-L176 | train |
dpa-newslab/livebridge | livebridge/controller.py | Controller.stop_bridges | async def stop_bridges(self):
"""Stop all sleep tasks to allow bridges to end."""
for task in self.sleep_tasks:
task.cancel()
for bridge in self.bridges:
bridge.stop() | python | async def stop_bridges(self):
"""Stop all sleep tasks to allow bridges to end."""
for task in self.sleep_tasks:
task.cancel()
for bridge in self.bridges:
bridge.stop() | [
"async",
"def",
"stop_bridges",
"(",
"self",
")",
":",
"for",
"task",
"in",
"self",
".",
"sleep_tasks",
":",
"task",
".",
"cancel",
"(",
")",
"for",
"bridge",
"in",
"self",
".",
"bridges",
":",
"bridge",
".",
"stop",
"(",
")"
] | Stop all sleep tasks to allow bridges to end. | [
"Stop",
"all",
"sleep",
"tasks",
"to",
"allow",
"bridges",
"to",
"end",
"."
] | d930e887faa2f882d15b574f0f1fe4a580d7c5fa | https://github.com/dpa-newslab/livebridge/blob/d930e887faa2f882d15b574f0f1fe4a580d7c5fa/livebridge/controller.py#L50-L55 | train |
Egregors/cbrf | cbrf/utils.py | str_to_date | def str_to_date(date: str) -> datetime.datetime:
""" Convert cbr.ru API date ste to python datetime
:param date: date from API response
:return: date like datetime
:rtype: datetime
"""
date = date.split('.')
date.reverse()
y, m, d = date
return datetime.datetime(int(y), int(m), int... | python | def str_to_date(date: str) -> datetime.datetime:
""" Convert cbr.ru API date ste to python datetime
:param date: date from API response
:return: date like datetime
:rtype: datetime
"""
date = date.split('.')
date.reverse()
y, m, d = date
return datetime.datetime(int(y), int(m), int... | [
"def",
"str_to_date",
"(",
"date",
":",
"str",
")",
"->",
"datetime",
".",
"datetime",
":",
"date",
"=",
"date",
".",
"split",
"(",
"'.'",
")",
"date",
".",
"reverse",
"(",
")",
"y",
",",
"m",
",",
"d",
"=",
"date",
"return",
"datetime",
".",
"da... | Convert cbr.ru API date ste to python datetime
:param date: date from API response
:return: date like datetime
:rtype: datetime | [
"Convert",
"cbr",
".",
"ru",
"API",
"date",
"ste",
"to",
"python",
"datetime"
] | e4ce332fcead83c75966337c97c0ae070fb7e576 | https://github.com/Egregors/cbrf/blob/e4ce332fcead83c75966337c97c0ae070fb7e576/cbrf/utils.py#L24-L35 | train |
AllTheWayDown/turgles | turgles/gl/buffer.py | Buffer.load | def load(self, data, size=None):
"""Data is cffi array"""
self.bind()
if size is None:
# ffi's sizeof understands arrays
size = sizeof(data)
if size == self.buffer_size:
# same size - no need to allocate new buffer, just copy
glBufferSubDat... | python | def load(self, data, size=None):
"""Data is cffi array"""
self.bind()
if size is None:
# ffi's sizeof understands arrays
size = sizeof(data)
if size == self.buffer_size:
# same size - no need to allocate new buffer, just copy
glBufferSubDat... | [
"def",
"load",
"(",
"self",
",",
"data",
",",
"size",
"=",
"None",
")",
":",
"self",
".",
"bind",
"(",
")",
"if",
"size",
"is",
"None",
":",
"size",
"=",
"sizeof",
"(",
"data",
")",
"if",
"size",
"==",
"self",
".",
"buffer_size",
":",
"glBufferSu... | Data is cffi array | [
"Data",
"is",
"cffi",
"array"
] | 1bb17abe9b3aa0953d9a8e9b05a23369c5bf8852 | https://github.com/AllTheWayDown/turgles/blob/1bb17abe9b3aa0953d9a8e9b05a23369c5bf8852/turgles/gl/buffer.py#L43-L66 | train |
JukeboxPipeline/jukeboxmaya | src/jukeboxmaya/main.py | init | def init():
"""Initialize the pipeline in maya so everything works
Init environment and load plugins.
This also creates the initial Jukebox Menu entry.
:returns: None
:rtype: None
:raises: None
"""
main.init_environment()
pluginpath = os.pathsep.join((os.environ.get('JUKEBOX_PLUGIN... | python | def init():
"""Initialize the pipeline in maya so everything works
Init environment and load plugins.
This also creates the initial Jukebox Menu entry.
:returns: None
:rtype: None
:raises: None
"""
main.init_environment()
pluginpath = os.pathsep.join((os.environ.get('JUKEBOX_PLUGIN... | [
"def",
"init",
"(",
")",
":",
"main",
".",
"init_environment",
"(",
")",
"pluginpath",
"=",
"os",
".",
"pathsep",
".",
"join",
"(",
"(",
"os",
".",
"environ",
".",
"get",
"(",
"'JUKEBOX_PLUGIN_PATH'",
",",
"''",
")",
",",
"BUILTIN_PLUGIN_PATH",
")",
")... | Initialize the pipeline in maya so everything works
Init environment and load plugins.
This also creates the initial Jukebox Menu entry.
:returns: None
:rtype: None
:raises: None | [
"Initialize",
"the",
"pipeline",
"in",
"maya",
"so",
"everything",
"works"
] | c8d6318d53cdb5493453c4a6b65ef75bdb2d5f2c | https://github.com/JukeboxPipeline/jukeboxmaya/blob/c8d6318d53cdb5493453c4a6b65ef75bdb2d5f2c/src/jukeboxmaya/main.py#L43-L68 | train |
TorkamaniLab/metapipe | metapipe/models/queue.py | BaseQueue.all_jobs | def all_jobs(self):
""" Returns a list of all jobs submitted to the queue, complete,
in-progess or failed.
"""
return list(set(self.complete + self.failed + self.queue + self.running)) | python | def all_jobs(self):
""" Returns a list of all jobs submitted to the queue, complete,
in-progess or failed.
"""
return list(set(self.complete + self.failed + self.queue + self.running)) | [
"def",
"all_jobs",
"(",
"self",
")",
":",
"return",
"list",
"(",
"set",
"(",
"self",
".",
"complete",
"+",
"self",
".",
"failed",
"+",
"self",
".",
"queue",
"+",
"self",
".",
"running",
")",
")"
] | Returns a list of all jobs submitted to the queue, complete,
in-progess or failed. | [
"Returns",
"a",
"list",
"of",
"all",
"jobs",
"submitted",
"to",
"the",
"queue",
"complete",
"in",
"-",
"progess",
"or",
"failed",
"."
] | 15592e5b0c217afb00ac03503f8d0d7453d4baf4 | https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/models/queue.py#L40-L44 | train |
TorkamaniLab/metapipe | metapipe/models/queue.py | BaseQueue.progress | def progress(self):
""" Returns the percentage, current and total number of
jobs in the queue.
"""
total = len(self.all_jobs)
remaining = total - len(self.active_jobs) if total > 0 else 0
percent = int(100 * (float(remaining) / total)) if total > 0 else 0
return p... | python | def progress(self):
""" Returns the percentage, current and total number of
jobs in the queue.
"""
total = len(self.all_jobs)
remaining = total - len(self.active_jobs) if total > 0 else 0
percent = int(100 * (float(remaining) / total)) if total > 0 else 0
return p... | [
"def",
"progress",
"(",
"self",
")",
":",
"total",
"=",
"len",
"(",
"self",
".",
"all_jobs",
")",
"remaining",
"=",
"total",
"-",
"len",
"(",
"self",
".",
"active_jobs",
")",
"if",
"total",
">",
"0",
"else",
"0",
"percent",
"=",
"int",
"(",
"100",
... | Returns the percentage, current and total number of
jobs in the queue. | [
"Returns",
"the",
"percentage",
"current",
"and",
"total",
"number",
"of",
"jobs",
"in",
"the",
"queue",
"."
] | 15592e5b0c217afb00ac03503f8d0d7453d4baf4 | https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/models/queue.py#L47-L54 | train |
TorkamaniLab/metapipe | metapipe/models/queue.py | BaseQueue.ready | def ready(self, job):
""" Determines if the job is ready to be sumitted to the
queue. It checks if the job depends on any currently
running or queued operations.
"""
no_deps = len(job.depends_on) == 0
all_complete = all(j.is_complete() for j in self.active_jobs
... | python | def ready(self, job):
""" Determines if the job is ready to be sumitted to the
queue. It checks if the job depends on any currently
running or queued operations.
"""
no_deps = len(job.depends_on) == 0
all_complete = all(j.is_complete() for j in self.active_jobs
... | [
"def",
"ready",
"(",
"self",
",",
"job",
")",
":",
"no_deps",
"=",
"len",
"(",
"job",
".",
"depends_on",
")",
"==",
"0",
"all_complete",
"=",
"all",
"(",
"j",
".",
"is_complete",
"(",
")",
"for",
"j",
"in",
"self",
".",
"active_jobs",
"if",
"j",
... | Determines if the job is ready to be sumitted to the
queue. It checks if the job depends on any currently
running or queued operations. | [
"Determines",
"if",
"the",
"job",
"is",
"ready",
"to",
"be",
"sumitted",
"to",
"the",
"queue",
".",
"It",
"checks",
"if",
"the",
"job",
"depends",
"on",
"any",
"currently",
"running",
"or",
"queued",
"operations",
"."
] | 15592e5b0c217afb00ac03503f8d0d7453d4baf4 | https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/models/queue.py#L56-L67 | train |
TorkamaniLab/metapipe | metapipe/models/queue.py | BaseQueue.locked | def locked(self):
""" Determines if the queue is locked. """
if len(self.failed) == 0:
return False
for fail in self.failed:
for job in self.active_jobs:
if fail.alias in job.depends_on:
return True | python | def locked(self):
""" Determines if the queue is locked. """
if len(self.failed) == 0:
return False
for fail in self.failed:
for job in self.active_jobs:
if fail.alias in job.depends_on:
return True | [
"def",
"locked",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"failed",
")",
"==",
"0",
":",
"return",
"False",
"for",
"fail",
"in",
"self",
".",
"failed",
":",
"for",
"job",
"in",
"self",
".",
"active_jobs",
":",
"if",
"fail",
".",
"ali... | Determines if the queue is locked. | [
"Determines",
"if",
"the",
"queue",
"is",
"locked",
"."
] | 15592e5b0c217afb00ac03503f8d0d7453d4baf4 | https://github.com/TorkamaniLab/metapipe/blob/15592e5b0c217afb00ac03503f8d0d7453d4baf4/metapipe/models/queue.py#L69-L76 | train |
dpa-newslab/livebridge | livebridge/run.py | read_args | def read_args(**kwargs):
"""Read controlfile parameter."""
if kwargs.get("control"):
args = Namespace(control=kwargs["control"])
elif config.CONTROLFILE:
args = Namespace(control=config.CONTROLFILE)
elif config.DB.get("control_table_name"):
args = Namespace(control="sql")
eli... | python | def read_args(**kwargs):
"""Read controlfile parameter."""
if kwargs.get("control"):
args = Namespace(control=kwargs["control"])
elif config.CONTROLFILE:
args = Namespace(control=config.CONTROLFILE)
elif config.DB.get("control_table_name"):
args = Namespace(control="sql")
eli... | [
"def",
"read_args",
"(",
"**",
"kwargs",
")",
":",
"if",
"kwargs",
".",
"get",
"(",
"\"control\"",
")",
":",
"args",
"=",
"Namespace",
"(",
"control",
"=",
"kwargs",
"[",
"\"control\"",
"]",
")",
"elif",
"config",
".",
"CONTROLFILE",
":",
"args",
"=",
... | Read controlfile parameter. | [
"Read",
"controlfile",
"parameter",
"."
] | d930e887faa2f882d15b574f0f1fe4a580d7c5fa | https://github.com/dpa-newslab/livebridge/blob/d930e887faa2f882d15b574f0f1fe4a580d7c5fa/livebridge/run.py#L30-L45 | train |
lowandrew/OLCTools | spadespipeline/spadesRun.py | Spades.best_assemblyfile | def best_assemblyfile(self):
"""
Determine whether the contigs.fasta output file from SPAdes is present. If not, set the .bestassembly
attribute to 'NA'
"""
for sample in self.metadata:
# Set the name of the unfiltered spades assembly output file
assembly_... | python | def best_assemblyfile(self):
"""
Determine whether the contigs.fasta output file from SPAdes is present. If not, set the .bestassembly
attribute to 'NA'
"""
for sample in self.metadata:
# Set the name of the unfiltered spades assembly output file
assembly_... | [
"def",
"best_assemblyfile",
"(",
"self",
")",
":",
"for",
"sample",
"in",
"self",
".",
"metadata",
":",
"assembly_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"sample",
".",
"general",
".",
"spadesoutput",
",",
"'contigs.fasta'",
")",
"if",
"os",
"."... | Determine whether the contigs.fasta output file from SPAdes is present. If not, set the .bestassembly
attribute to 'NA' | [
"Determine",
"whether",
"the",
"contigs",
".",
"fasta",
"output",
"file",
"from",
"SPAdes",
"is",
"present",
".",
"If",
"not",
"set",
"the",
".",
"bestassembly",
"attribute",
"to",
"NA"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/spadespipeline/spadesRun.py#L124-L139 | train |
lowandrew/OLCTools | spadespipeline/spadesRun.py | Spades.assemble | def assemble(self):
"""Run the assembly command in a multi-threaded fashion"""
threadlock = threading.Lock()
while True:
(sample, command) = self.assemblequeue.get()
if command and not os.path.isfile(os.path.join(sample.general.spadesoutput, 'contigs.fasta')):
... | python | def assemble(self):
"""Run the assembly command in a multi-threaded fashion"""
threadlock = threading.Lock()
while True:
(sample, command) = self.assemblequeue.get()
if command and not os.path.isfile(os.path.join(sample.general.spadesoutput, 'contigs.fasta')):
... | [
"def",
"assemble",
"(",
"self",
")",
":",
"threadlock",
"=",
"threading",
".",
"Lock",
"(",
")",
"while",
"True",
":",
"(",
"sample",
",",
"command",
")",
"=",
"self",
".",
"assemblequeue",
".",
"get",
"(",
")",
"if",
"command",
"and",
"not",
"os",
... | Run the assembly command in a multi-threaded fashion | [
"Run",
"the",
"assembly",
"command",
"in",
"a",
"multi",
"-",
"threaded",
"fashion"
] | 88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a | https://github.com/lowandrew/OLCTools/blob/88aa90ac85f84d0bbeb03e43c29b0a9d36e4ce2a/spadespipeline/spadesRun.py#L141-L158 | train |
sirfoga/pyhal | hal/cvs/gits.py | Repository.get_diff_amounts | def get_diff_amounts(self):
"""Gets list of total diff
:return: List of total diff between 2 consecutive commits since start
"""
diffs = []
last_commit = None
for commit in self.repo.iter_commits():
if last_commit is not None:
diff = self.get... | python | def get_diff_amounts(self):
"""Gets list of total diff
:return: List of total diff between 2 consecutive commits since start
"""
diffs = []
last_commit = None
for commit in self.repo.iter_commits():
if last_commit is not None:
diff = self.get... | [
"def",
"get_diff_amounts",
"(",
"self",
")",
":",
"diffs",
"=",
"[",
"]",
"last_commit",
"=",
"None",
"for",
"commit",
"in",
"self",
".",
"repo",
".",
"iter_commits",
"(",
")",
":",
"if",
"last_commit",
"is",
"not",
"None",
":",
"diff",
"=",
"self",
... | Gets list of total diff
:return: List of total diff between 2 consecutive commits since start | [
"Gets",
"list",
"of",
"total",
"diff"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/cvs/gits.py#L106-L122 | train |
sirfoga/pyhal | hal/cvs/gits.py | Repository.get_new_version | def get_new_version(self, last_version, last_commit,
diff_to_increase_ratio):
"""Gets new version
:param last_version: last version known
:param last_commit: hash of commit of last version
:param diff_to_increase_ratio: Ratio to convert number of changes into
... | python | def get_new_version(self, last_version, last_commit,
diff_to_increase_ratio):
"""Gets new version
:param last_version: last version known
:param last_commit: hash of commit of last version
:param diff_to_increase_ratio: Ratio to convert number of changes into
... | [
"def",
"get_new_version",
"(",
"self",
",",
"last_version",
",",
"last_commit",
",",
"diff_to_increase_ratio",
")",
":",
"version",
"=",
"Version",
"(",
"last_version",
")",
"diff",
"=",
"self",
".",
"get_diff",
"(",
"last_commit",
",",
"self",
".",
"get_last_... | Gets new version
:param last_version: last version known
:param last_commit: hash of commit of last version
:param diff_to_increase_ratio: Ratio to convert number of changes into
:return: new version | [
"Gets",
"new",
"version"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/cvs/gits.py#L149-L164 | train |
sirfoga/pyhal | hal/internet/email/gmail.py | get_mime_message | def get_mime_message(subject, text):
"""Creates MIME message
:param subject: Subject of email
:param text: Email content
:return: Email formatted as HTML ready to be sent
"""
message = MIMEText(
"<html>" +
str(text).replace("\n", "<br>") +
"</html>", "html"
)
mes... | python | def get_mime_message(subject, text):
"""Creates MIME message
:param subject: Subject of email
:param text: Email content
:return: Email formatted as HTML ready to be sent
"""
message = MIMEText(
"<html>" +
str(text).replace("\n", "<br>") +
"</html>", "html"
)
mes... | [
"def",
"get_mime_message",
"(",
"subject",
",",
"text",
")",
":",
"message",
"=",
"MIMEText",
"(",
"\"<html>\"",
"+",
"str",
"(",
"text",
")",
".",
"replace",
"(",
"\"\\n\"",
",",
"\"<br>\"",
")",
"+",
"\"</html>\"",
",",
"\"html\"",
")",
"message",
"[",... | Creates MIME message
:param subject: Subject of email
:param text: Email content
:return: Email formatted as HTML ready to be sent | [
"Creates",
"MIME",
"message"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/internet/email/gmail.py#L36-L49 | train |
sirfoga/pyhal | hal/internet/email/gmail.py | send_email | def send_email(sender, msg, driver):
"""Sends email to me with this message
:param sender: Sender of email
:param msg: Message to send to me
:param driver: GMail authenticator
"""
driver.users().messages().send(
userId=sender,
body=msg
).execute() | python | def send_email(sender, msg, driver):
"""Sends email to me with this message
:param sender: Sender of email
:param msg: Message to send to me
:param driver: GMail authenticator
"""
driver.users().messages().send(
userId=sender,
body=msg
).execute() | [
"def",
"send_email",
"(",
"sender",
",",
"msg",
",",
"driver",
")",
":",
"driver",
".",
"users",
"(",
")",
".",
"messages",
"(",
")",
".",
"send",
"(",
"userId",
"=",
"sender",
",",
"body",
"=",
"msg",
")",
".",
"execute",
"(",
")"
] | Sends email to me with this message
:param sender: Sender of email
:param msg: Message to send to me
:param driver: GMail authenticator | [
"Sends",
"email",
"to",
"me",
"with",
"this",
"message"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/internet/email/gmail.py#L52-L62 | train |
kgritesh/pip-save | setup.py | get_readme | def get_readme():
"""Get the contents of the ``README.rst`` file as a Unicode string."""
try:
import pypandoc
description = pypandoc.convert('README.md', 'rst')
except (IOError, ImportError):
description = open('README.md').read()
return description | python | def get_readme():
"""Get the contents of the ``README.rst`` file as a Unicode string."""
try:
import pypandoc
description = pypandoc.convert('README.md', 'rst')
except (IOError, ImportError):
description = open('README.md').read()
return description | [
"def",
"get_readme",
"(",
")",
":",
"try",
":",
"import",
"pypandoc",
"description",
"=",
"pypandoc",
".",
"convert",
"(",
"'README.md'",
",",
"'rst'",
")",
"except",
"(",
"IOError",
",",
"ImportError",
")",
":",
"description",
"=",
"open",
"(",
"'README.m... | Get the contents of the ``README.rst`` file as a Unicode string. | [
"Get",
"the",
"contents",
"of",
"the",
"README",
".",
"rst",
"file",
"as",
"a",
"Unicode",
"string",
"."
] | 70a1269db5db05bb850c2caa00222ebe40b2f2fd | https://github.com/kgritesh/pip-save/blob/70a1269db5db05bb850c2caa00222ebe40b2f2fd/setup.py#L9-L17 | train |
kgritesh/pip-save | setup.py | get_absolute_path | def get_absolute_path(*args):
"""Transform relative pathnames into absolute pathnames."""
directory = os.path.dirname(os.path.abspath(__file__))
return os.path.join(directory, *args) | python | def get_absolute_path(*args):
"""Transform relative pathnames into absolute pathnames."""
directory = os.path.dirname(os.path.abspath(__file__))
return os.path.join(directory, *args) | [
"def",
"get_absolute_path",
"(",
"*",
"args",
")",
":",
"directory",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"__file__",
")",
")",
"return",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"*",
"a... | Transform relative pathnames into absolute pathnames. | [
"Transform",
"relative",
"pathnames",
"into",
"absolute",
"pathnames",
"."
] | 70a1269db5db05bb850c2caa00222ebe40b2f2fd | https://github.com/kgritesh/pip-save/blob/70a1269db5db05bb850c2caa00222ebe40b2f2fd/setup.py#L19-L22 | train |
portfors-lab/sparkle | sparkle/data/hdf5data.py | HDF5Data.trim | def trim(self, key):
"""
Removes empty rows from dataset... I am still wanting to use this???
:param key: the dataset to trim
:type key: str
"""
current_index = self.meta[key]['cursor']
self.hdf5[key].resize(current_index, axis=0) | python | def trim(self, key):
"""
Removes empty rows from dataset... I am still wanting to use this???
:param key: the dataset to trim
:type key: str
"""
current_index = self.meta[key]['cursor']
self.hdf5[key].resize(current_index, axis=0) | [
"def",
"trim",
"(",
"self",
",",
"key",
")",
":",
"current_index",
"=",
"self",
".",
"meta",
"[",
"key",
"]",
"[",
"'cursor'",
"]",
"self",
".",
"hdf5",
"[",
"key",
"]",
".",
"resize",
"(",
"current_index",
",",
"axis",
"=",
"0",
")"
] | Removes empty rows from dataset... I am still wanting to use this???
:param key: the dataset to trim
:type key: str | [
"Removes",
"empty",
"rows",
"from",
"dataset",
"...",
"I",
"am",
"still",
"wanting",
"to",
"use",
"this???"
] | 5fad1cf2bec58ec6b15d91da20f6236a74826110 | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/data/hdf5data.py#L278-L286 | train |
sirfoga/pyhal | hal/internet/services/youtube.py | YoutubeChannel.get_channel_page | def get_channel_page(self):
"""Fetches source page
:return: source page of youtube channel
"""
channel_url = YOUTUBE_USER_BASE_URL + self.channel_name # url
source_page = Webpage(
channel_url).get_html_source() # get source page of channel
return source_pag... | python | def get_channel_page(self):
"""Fetches source page
:return: source page of youtube channel
"""
channel_url = YOUTUBE_USER_BASE_URL + self.channel_name # url
source_page = Webpage(
channel_url).get_html_source() # get source page of channel
return source_pag... | [
"def",
"get_channel_page",
"(",
"self",
")",
":",
"channel_url",
"=",
"YOUTUBE_USER_BASE_URL",
"+",
"self",
".",
"channel_name",
"source_page",
"=",
"Webpage",
"(",
"channel_url",
")",
".",
"get_html_source",
"(",
")",
"return",
"source_page"
] | Fetches source page
:return: source page of youtube channel | [
"Fetches",
"source",
"page"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/internet/services/youtube.py#L19-L27 | train |
sirfoga/pyhal | hal/internet/services/youtube.py | YoutubeChannel.get_feed_url_from_video | def get_feed_url_from_video(video_url):
"""Gets channel id and then creates feed url
:param video_url: Url of video
:return: feed url
"""
web_page = Webpage(video_url)
web_page.get_html_source()
channel_id = \
web_page.soup.find_all("div", {"class": "... | python | def get_feed_url_from_video(video_url):
"""Gets channel id and then creates feed url
:param video_url: Url of video
:return: feed url
"""
web_page = Webpage(video_url)
web_page.get_html_source()
channel_id = \
web_page.soup.find_all("div", {"class": "... | [
"def",
"get_feed_url_from_video",
"(",
"video_url",
")",
":",
"web_page",
"=",
"Webpage",
"(",
"video_url",
")",
"web_page",
".",
"get_html_source",
"(",
")",
"channel_id",
"=",
"web_page",
".",
"soup",
".",
"find_all",
"(",
"\"div\"",
",",
"{",
"\"class\"",
... | Gets channel id and then creates feed url
:param video_url: Url of video
:return: feed url | [
"Gets",
"channel",
"id",
"and",
"then",
"creates",
"feed",
"url"
] | 4394d8a1f7e45bea28a255ec390f4962ee64d33a | https://github.com/sirfoga/pyhal/blob/4394d8a1f7e45bea28a255ec390f4962ee64d33a/hal/internet/services/youtube.py#L66-L79 | train |
jmbhughes/suvi-trainer | scripts/update_database.py | process_file | def process_file(path):
""" Open a single labeled image at path and get needed information, return as a dictionary"""
info = dict()
with fits.open(path) as hdu:
head = hdu[0].header
data = hdu[0].data
labels = {theme: value for value, theme in list(hdu[1].data)}
info['filename'] ... | python | def process_file(path):
""" Open a single labeled image at path and get needed information, return as a dictionary"""
info = dict()
with fits.open(path) as hdu:
head = hdu[0].header
data = hdu[0].data
labels = {theme: value for value, theme in list(hdu[1].data)}
info['filename'] ... | [
"def",
"process_file",
"(",
"path",
")",
":",
"info",
"=",
"dict",
"(",
")",
"with",
"fits",
".",
"open",
"(",
"path",
")",
"as",
"hdu",
":",
"head",
"=",
"hdu",
"[",
"0",
"]",
".",
"header",
"data",
"=",
"hdu",
"[",
"0",
"]",
".",
"data",
"l... | Open a single labeled image at path and get needed information, return as a dictionary | [
"Open",
"a",
"single",
"labeled",
"image",
"at",
"path",
"and",
"get",
"needed",
"information",
"return",
"as",
"a",
"dictionary"
] | 3d89894a4a037286221974c7eb5634d229b4f5d4 | https://github.com/jmbhughes/suvi-trainer/blob/3d89894a4a037286221974c7eb5634d229b4f5d4/scripts/update_database.py#L29-L42 | train |
jmbhughes/suvi-trainer | scripts/update_database.py | plot_counts | def plot_counts(df, theme):
""" plot the counts of a given theme from a created database over time"""
dates, counts = df['date-observation'], df[theme + "_count"]
fig, ax = plt.subplots()
ax.set_ylabel("{} pixel counts".format(" ".join(theme.split("_"))))
ax.set_xlabel("observation date")
ax.plo... | python | def plot_counts(df, theme):
""" plot the counts of a given theme from a created database over time"""
dates, counts = df['date-observation'], df[theme + "_count"]
fig, ax = plt.subplots()
ax.set_ylabel("{} pixel counts".format(" ".join(theme.split("_"))))
ax.set_xlabel("observation date")
ax.plo... | [
"def",
"plot_counts",
"(",
"df",
",",
"theme",
")",
":",
"dates",
",",
"counts",
"=",
"df",
"[",
"'date-observation'",
"]",
",",
"df",
"[",
"theme",
"+",
"\"_count\"",
"]",
"fig",
",",
"ax",
"=",
"plt",
".",
"subplots",
"(",
")",
"ax",
".",
"set_yl... | plot the counts of a given theme from a created database over time | [
"plot",
"the",
"counts",
"of",
"a",
"given",
"theme",
"from",
"a",
"created",
"database",
"over",
"time"
] | 3d89894a4a037286221974c7eb5634d229b4f5d4 | https://github.com/jmbhughes/suvi-trainer/blob/3d89894a4a037286221974c7eb5634d229b4f5d4/scripts/update_database.py#L45-L53 | train |
klahnakoski/mo-logs | mo_logs/strings.py | deformat | def deformat(value):
"""
REMOVE NON-ALPHANUMERIC CHARACTERS
FOR SOME REASON translate CAN NOT BE CALLED:
ERROR: translate() takes exactly one argument (2 given)
File "C:\Python27\lib\string.py", line 493, in translate
"""
output = []
for c in value:
if c in delchars:
... | python | def deformat(value):
"""
REMOVE NON-ALPHANUMERIC CHARACTERS
FOR SOME REASON translate CAN NOT BE CALLED:
ERROR: translate() takes exactly one argument (2 given)
File "C:\Python27\lib\string.py", line 493, in translate
"""
output = []
for c in value:
if c in delchars:
... | [
"def",
"deformat",
"(",
"value",
")",
":",
"output",
"=",
"[",
"]",
"for",
"c",
"in",
"value",
":",
"if",
"c",
"in",
"delchars",
":",
"continue",
"output",
".",
"append",
"(",
"c",
")",
"return",
"\"\"",
".",
"join",
"(",
"output",
")"
] | REMOVE NON-ALPHANUMERIC CHARACTERS
FOR SOME REASON translate CAN NOT BE CALLED:
ERROR: translate() takes exactly one argument (2 given)
File "C:\Python27\lib\string.py", line 493, in translate | [
"REMOVE",
"NON",
"-",
"ALPHANUMERIC",
"CHARACTERS"
] | 0971277ac9caf28a755b766b70621916957d4fea | https://github.com/klahnakoski/mo-logs/blob/0971277ac9caf28a755b766b70621916957d4fea/mo_logs/strings.py#L567-L580 | train |
klahnakoski/mo-logs | mo_logs/strings.py | _expand | def _expand(template, seq):
"""
seq IS TUPLE OF OBJECTS IN PATH ORDER INTO THE DATA TREE
"""
if is_text(template):
return _simple_expand(template, seq)
elif is_data(template):
# EXPAND LISTS OF ITEMS USING THIS FORM
# {"from":from, "template":template, "separator":separator}
... | python | def _expand(template, seq):
"""
seq IS TUPLE OF OBJECTS IN PATH ORDER INTO THE DATA TREE
"""
if is_text(template):
return _simple_expand(template, seq)
elif is_data(template):
# EXPAND LISTS OF ITEMS USING THIS FORM
# {"from":from, "template":template, "separator":separator}
... | [
"def",
"_expand",
"(",
"template",
",",
"seq",
")",
":",
"if",
"is_text",
"(",
"template",
")",
":",
"return",
"_simple_expand",
"(",
"template",
",",
"seq",
")",
"elif",
"is_data",
"(",
"template",
")",
":",
"template",
"=",
"wrap",
"(",
"template",
"... | seq IS TUPLE OF OBJECTS IN PATH ORDER INTO THE DATA TREE | [
"seq",
"IS",
"TUPLE",
"OF",
"OBJECTS",
"IN",
"PATH",
"ORDER",
"INTO",
"THE",
"DATA",
"TREE"
] | 0971277ac9caf28a755b766b70621916957d4fea | https://github.com/klahnakoski/mo-logs/blob/0971277ac9caf28a755b766b70621916957d4fea/mo_logs/strings.py#L586-L611 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.