repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
VonStruddle/PyHunter
pyhunter/pyhunter.py
https://github.com/VonStruddle/PyHunter/blob/e14882d22527102515458cddeb8e0aa1c02da549/pyhunter/pyhunter.py#L463-L478
def delete_leads_list(self, leads_list_id): """ Delete a leads list. :param leads_list_id: The id of the list to delete. :return: 204 Response. """ params = self.base_params endpoint = self.base_endpoint.format( 'leads_lists/' + str(lead...
[ "def", "delete_leads_list", "(", "self", ",", "leads_list_id", ")", ":", "params", "=", "self", ".", "base_params", "endpoint", "=", "self", ".", "base_endpoint", ".", "format", "(", "'leads_lists/'", "+", "str", "(", "leads_list_id", ")", ")", "return", "se...
Delete a leads list. :param leads_list_id: The id of the list to delete. :return: 204 Response.
[ "Delete", "a", "leads", "list", "." ]
python
train
sdispater/poetry
get-poetry.py
https://github.com/sdispater/poetry/blob/2d27acd76c165dd49f11934520a7973de7a3762a/get-poetry.py#L466-L490
def make_lib(self, version): """ Packs everything into a single lib/ directory. """ if os.path.exists(POETRY_LIB_BACKUP): shutil.rmtree(POETRY_LIB_BACKUP) # Backup the current installation if os.path.exists(POETRY_LIB): shutil.copytree(POETRY_LIB,...
[ "def", "make_lib", "(", "self", ",", "version", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "POETRY_LIB_BACKUP", ")", ":", "shutil", ".", "rmtree", "(", "POETRY_LIB_BACKUP", ")", "# Backup the current installation", "if", "os", ".", "path", ".", ...
Packs everything into a single lib/ directory.
[ "Packs", "everything", "into", "a", "single", "lib", "/", "directory", "." ]
python
train
saltstack/salt
salt/modules/omapi.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/omapi.py#L102-L130
def delete_host(mac=None, name=None): ''' Delete the host with the given mac or name. CLI Examples: .. code-block:: bash salt dhcp-server omapi.delete_host name=host1 salt dhcp-server omapi.delete_host mac=ab:ab:ab:ab:ab:ab ''' if not (mac or name): raise TypeError('At...
[ "def", "delete_host", "(", "mac", "=", "None", ",", "name", "=", "None", ")", ":", "if", "not", "(", "mac", "or", "name", ")", ":", "raise", "TypeError", "(", "'At least one argument is required'", ")", "o", "=", "_conn", "(", ")", "msg", "=", "omapi",...
Delete the host with the given mac or name. CLI Examples: .. code-block:: bash salt dhcp-server omapi.delete_host name=host1 salt dhcp-server omapi.delete_host mac=ab:ab:ab:ab:ab:ab
[ "Delete", "the", "host", "with", "the", "given", "mac", "or", "name", "." ]
python
train
elifesciences/elife-tools
elifetools/parseJATS.py
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L879-L906
def inline_graphics(soup): """ inline-graphic tags """ inline_graphics = [] inline_graphic_tags = raw_parser.inline_graphic(soup) position = 1 for tag in inline_graphic_tags: item = {} copy_attribute(tag.attrs, 'xlink:href', item, 'xlink_href') # Get the tag type...
[ "def", "inline_graphics", "(", "soup", ")", ":", "inline_graphics", "=", "[", "]", "inline_graphic_tags", "=", "raw_parser", ".", "inline_graphic", "(", "soup", ")", "position", "=", "1", "for", "tag", "in", "inline_graphic_tags", ":", "item", "=", "{", "}",...
inline-graphic tags
[ "inline", "-", "graphic", "tags" ]
python
train
pybel/pybel-tools
src/pybel_tools/utils.py
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/utils.py#L140-L159
def calculate_global_tanimoto_set_distances(dict_of_sets: Mapping[X, Set]) -> Mapping[X, Mapping[X, float]]: r"""Calculate an alternative distance matrix based on the following equation. .. math:: distance(A, B)=1- \|A \cup B\| / \| \cup_{s \in S} s\| :param dict_of_sets: A dict of {x: set of y} :retu...
[ "def", "calculate_global_tanimoto_set_distances", "(", "dict_of_sets", ":", "Mapping", "[", "X", ",", "Set", "]", ")", "->", "Mapping", "[", "X", ",", "Mapping", "[", "X", ",", "float", "]", "]", ":", "universe", "=", "set", "(", "itt", ".", "chain", "...
r"""Calculate an alternative distance matrix based on the following equation. .. math:: distance(A, B)=1- \|A \cup B\| / \| \cup_{s \in S} s\| :param dict_of_sets: A dict of {x: set of y} :return: A similarity matrix based on the alternative tanimoto distance as a dict of dicts
[ "r", "Calculate", "an", "alternative", "distance", "matrix", "based", "on", "the", "following", "equation", "." ]
python
valid
dw/mitogen
mitogen/fork.py
https://github.com/dw/mitogen/blob/a7fdb55e1300a7e0a5e404b09eb730cf9a525da7/mitogen/fork.py#L92-L105
def on_fork(): """ Should be called by any program integrating Mitogen each time the process is forked, in the context of the new child. """ reset_logging_framework() # Must be first! fixup_prngs() mitogen.core.Latch._on_fork() mitogen.core.Side._on_fork() mitogen.core.ExternalConte...
[ "def", "on_fork", "(", ")", ":", "reset_logging_framework", "(", ")", "# Must be first!", "fixup_prngs", "(", ")", "mitogen", ".", "core", ".", "Latch", ".", "_on_fork", "(", ")", "mitogen", ".", "core", ".", "Side", ".", "_on_fork", "(", ")", "mitogen", ...
Should be called by any program integrating Mitogen each time the process is forked, in the context of the new child.
[ "Should", "be", "called", "by", "any", "program", "integrating", "Mitogen", "each", "time", "the", "process", "is", "forked", "in", "the", "context", "of", "the", "new", "child", "." ]
python
train
kivy/python-for-android
pythonforandroid/toolchain.py
https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/toolchain.py#L818-L833
def clean_builds(self, _args): """Delete all build caches for each recipe, python-install, java code and compiled libs collection. This does *not* delete the package download cache or the final distributions. You can also use clean_recipe_build to delete the build of a specific...
[ "def", "clean_builds", "(", "self", ",", "_args", ")", ":", "ctx", "=", "self", ".", "ctx", "if", "exists", "(", "ctx", ".", "build_dir", ")", ":", "shutil", ".", "rmtree", "(", "ctx", ".", "build_dir", ")", "if", "exists", "(", "ctx", ".", "python...
Delete all build caches for each recipe, python-install, java code and compiled libs collection. This does *not* delete the package download cache or the final distributions. You can also use clean_recipe_build to delete the build of a specific recipe.
[ "Delete", "all", "build", "caches", "for", "each", "recipe", "python", "-", "install", "java", "code", "and", "compiled", "libs", "collection", "." ]
python
train
opendatateam/udata
udata/search/__init__.py
https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/search/__init__.py#L167-L170
def unindex_model_on_delete(sender, document, **kwargs): '''Unindex Mongo document on post_delete''' if current_app.config.get('AUTO_INDEX'): unindex.delay(document)
[ "def", "unindex_model_on_delete", "(", "sender", ",", "document", ",", "*", "*", "kwargs", ")", ":", "if", "current_app", ".", "config", ".", "get", "(", "'AUTO_INDEX'", ")", ":", "unindex", ".", "delay", "(", "document", ")" ]
Unindex Mongo document on post_delete
[ "Unindex", "Mongo", "document", "on", "post_delete" ]
python
train
ic-labs/django-icekit
icekit/content_collections/page_type_plugins.py
https://github.com/ic-labs/django-icekit/blob/c507ea5b1864303732c53ad7c5800571fca5fa94/icekit/content_collections/page_type_plugins.py#L13-L18
def get_context(self, request, page, **kwargs): """ Include in context items to be visible on listing page """ context = super(ListingPagePlugin, self).get_context( request, page, **kwargs) context['items_to_list'] = page.get_items_to_list(request) return context
[ "def", "get_context", "(", "self", ",", "request", ",", "page", ",", "*", "*", "kwargs", ")", ":", "context", "=", "super", "(", "ListingPagePlugin", ",", "self", ")", ".", "get_context", "(", "request", ",", "page", ",", "*", "*", "kwargs", ")", "co...
Include in context items to be visible on listing page
[ "Include", "in", "context", "items", "to", "be", "visible", "on", "listing", "page" ]
python
train
patarapolw/AnkiTools
AnkiTools/tools/sampling.py
https://github.com/patarapolw/AnkiTools/blob/fab6836dfd9cf5171d9cbff5c55fbb14d2786f05/AnkiTools/tools/sampling.py#L15-L90
def get_representative_json(file_input=None, formatted=False, annotate_is_json=False, sampling_substitution_regex=('(.+)', '\\1_sample'), do_not_sample=('sqlite_stat1', ), sampling_limits=None): """ :...
[ "def", "get_representative_json", "(", "file_input", "=", "None", ",", "formatted", "=", "False", ",", "annotate_is_json", "=", "False", ",", "sampling_substitution_regex", "=", "(", "'(.+)'", ",", "'\\\\1_sample'", ")", ",", "do_not_sample", "=", "(", "'sqlite_st...
:param None|str file_input: :param bool formatted: :param bool annotate_is_json: :param tuple sampling_substitution_regex: to shorten string by one, try ('(.+).{1}', '\\1') or ('(.+)s', '\\1') :param list|tuple do_not_sample: :param None|dict sampling_limits: :return:
[ ":", "param", "None|str", "file_input", ":", ":", "param", "bool", "formatted", ":", ":", "param", "bool", "annotate_is_json", ":", ":", "param", "tuple", "sampling_substitution_regex", ":", "to", "shorten", "string", "by", "one", "try", "(", "(", ".", "+", ...
python
train
Clinical-Genomics/scout
scout/adapter/mongo/case.py
https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/adapter/mongo/case.py#L142-L161
def nr_cases(self, institute_id=None): """Return the number of cases This function will change when we migrate to 3.7.1 Args: collaborator(str): Institute id Returns: nr_cases(int) """ query = {} if institute_id: query['coll...
[ "def", "nr_cases", "(", "self", ",", "institute_id", "=", "None", ")", ":", "query", "=", "{", "}", "if", "institute_id", ":", "query", "[", "'collaborators'", "]", "=", "institute_id", "LOG", ".", "debug", "(", "\"Fetch all cases with query {0}\"", ".", "fo...
Return the number of cases This function will change when we migrate to 3.7.1 Args: collaborator(str): Institute id Returns: nr_cases(int)
[ "Return", "the", "number", "of", "cases" ]
python
test
openstax/cnx-archive
cnxarchive/database.py
https://github.com/openstax/cnx-archive/blob/d31d34aa8bbc8a9fde6cd4227a0df92726e8daf4/cnxarchive/database.py#L174-L189
def get_minor_version(module_ident, plpy): """Retrieve minor version only given module_ident.""" # Make sure to always return the max minor version that is already in the # database, in case the given module_ident is not the latest version plan = plpy.prepare('''\ WITH t AS ( SELECT ...
[ "def", "get_minor_version", "(", "module_ident", ",", "plpy", ")", ":", "# Make sure to always return the max minor version that is already in the", "# database, in case the given module_ident is not the latest version", "plan", "=", "plpy", ".", "prepare", "(", "'''\\\n WITH ...
Retrieve minor version only given module_ident.
[ "Retrieve", "minor", "version", "only", "given", "module_ident", "." ]
python
train
metric-learn/metric-learn
metric_learn/mmc.py
https://github.com/metric-learn/metric-learn/blob/d945df1342c69012608bb70b92520392a0853de6/metric_learn/mmc.py#L305-L316
def _fS1(self, pos_pairs, A): """The gradient of the similarity constraint function w.r.t. A. f = \sum_{ij}(x_i-x_j)A(x_i-x_j)' = \sum_{ij}d_ij*A*d_ij' df/dA = d(d_ij*A*d_ij')/dA Note that d_ij*A*d_ij' = tr(d_ij*A*d_ij') = tr(d_ij'*d_ij*A) so, d(d_ij*A*d_ij')/dA = d_ij'*d_ij """ dim = pos_...
[ "def", "_fS1", "(", "self", ",", "pos_pairs", ",", "A", ")", ":", "dim", "=", "pos_pairs", ".", "shape", "[", "2", "]", "diff", "=", "pos_pairs", "[", ":", ",", "0", ",", ":", "]", "-", "pos_pairs", "[", ":", ",", "1", ",", ":", "]", "return"...
The gradient of the similarity constraint function w.r.t. A. f = \sum_{ij}(x_i-x_j)A(x_i-x_j)' = \sum_{ij}d_ij*A*d_ij' df/dA = d(d_ij*A*d_ij')/dA Note that d_ij*A*d_ij' = tr(d_ij*A*d_ij') = tr(d_ij'*d_ij*A) so, d(d_ij*A*d_ij')/dA = d_ij'*d_ij
[ "The", "gradient", "of", "the", "similarity", "constraint", "function", "w", ".", "r", ".", "t", ".", "A", "." ]
python
train
xray7224/PyPump
pypump/models/person.py
https://github.com/xray7224/PyPump/blob/f921f691c39fe021f4fd124b6bc91718c9e49b4a/pypump/models/person.py#L106-L120
def favorites(self): """ :class:`Feed <pypump.models.feed.Feed>` with all objects liked/favorited by the person. Example: >>> for like in pump.me.favorites[:3]: ... print(like) ... note by alice@example.org image by bob@example.org...
[ "def", "favorites", "(", "self", ")", ":", "if", "self", ".", "_favorites", "is", "None", ":", "self", ".", "_favorites", "=", "Favorites", "(", "self", ".", "links", "[", "'favorites'", "]", ",", "pypump", "=", "self", ".", "_pump", ")", "return", "...
:class:`Feed <pypump.models.feed.Feed>` with all objects liked/favorited by the person. Example: >>> for like in pump.me.favorites[:3]: ... print(like) ... note by alice@example.org image by bob@example.org comment by evan@e14n...
[ ":", "class", ":", "Feed", "<pypump", ".", "models", ".", "feed", ".", "Feed", ">", "with", "all", "objects", "liked", "/", "favorited", "by", "the", "person", "." ]
python
train
nephila/djangocms-installer
djangocms_installer/install/__init__.py
https://github.com/nephila/djangocms-installer/blob/9fec66d5f8b1e9a0f3c0ec66dd777db578fab07e/djangocms_installer/install/__init__.py#L15-L79
def check_install(config_data): """ Here we do some **really** basic environment sanity checks. Basically we test for the more delicate and failing-prone dependencies: * database driver * Pillow image format support Many other errors will go undetected """ errors = [] # PIL test...
[ "def", "check_install", "(", "config_data", ")", ":", "errors", "=", "[", "]", "# PIL tests", "try", ":", "from", "PIL", "import", "Image", "try", ":", "im", "=", "Image", ".", "open", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", "....
Here we do some **really** basic environment sanity checks. Basically we test for the more delicate and failing-prone dependencies: * database driver * Pillow image format support Many other errors will go undetected
[ "Here", "we", "do", "some", "**", "really", "**", "basic", "environment", "sanity", "checks", "." ]
python
valid
hid-io/layouts-python
layouts/__init__.py
https://github.com/hid-io/layouts-python/blob/b347578bfb4198fd812ecd7a2d9c7e551a856280/layouts/__init__.py#L413-L456
def compose(self, text, minimal_clears=False, no_clears=False): ''' Returns the sequence of combinations necessary to compose given text. If the text expression is not possible with the given layout an ComposeException is thrown. Iterate over the string, converting each character into ...
[ "def", "compose", "(", "self", ",", "text", ",", "minimal_clears", "=", "False", ",", "no_clears", "=", "False", ")", ":", "sequence", "=", "[", "]", "clear", "=", "self", ".", "json_data", "[", "'to_hid_keyboard'", "]", "[", "'0x00'", "]", "# No Event",...
Returns the sequence of combinations necessary to compose given text. If the text expression is not possible with the given layout an ComposeException is thrown. Iterate over the string, converting each character into a key sequence. Between each character, an empty combo is inserted to handle...
[ "Returns", "the", "sequence", "of", "combinations", "necessary", "to", "compose", "given", "text", "." ]
python
train
edx/ease
ease/feature_extractor.py
https://github.com/edx/ease/blob/a7890ed403da94d03726b0639cd8ebda45af6bbb/ease/feature_extractor.py#L75-L95
def get_good_pos_ngrams(self): """ Gets a set of gramatically correct part of speech sequences from an input file called essaycorpus.txt Returns the set and caches the file """ if(os.path.isfile(NGRAM_PATH)): good_pos_ngrams = pickle.load(open(NGRAM_PATH, 'rb')) ...
[ "def", "get_good_pos_ngrams", "(", "self", ")", ":", "if", "(", "os", ".", "path", ".", "isfile", "(", "NGRAM_PATH", ")", ")", ":", "good_pos_ngrams", "=", "pickle", ".", "load", "(", "open", "(", "NGRAM_PATH", ",", "'rb'", ")", ")", "elif", "os", "....
Gets a set of gramatically correct part of speech sequences from an input file called essaycorpus.txt Returns the set and caches the file
[ "Gets", "a", "set", "of", "gramatically", "correct", "part", "of", "speech", "sequences", "from", "an", "input", "file", "called", "essaycorpus", ".", "txt", "Returns", "the", "set", "and", "caches", "the", "file" ]
python
valid
raiden-network/raiden
raiden/utils/cli.py
https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/utils/cli.py#L354-L424
def apply_config_file( command_function: Union[click.Command, click.Group], cli_params: Dict[str, Any], ctx, config_file_option_name='config_file', ): """ Applies all options set in the config file to `cli_params` """ paramname_to_param = {param.name: param for param in command_f...
[ "def", "apply_config_file", "(", "command_function", ":", "Union", "[", "click", ".", "Command", ",", "click", ".", "Group", "]", ",", "cli_params", ":", "Dict", "[", "str", ",", "Any", "]", ",", "ctx", ",", "config_file_option_name", "=", "'config_file'", ...
Applies all options set in the config file to `cli_params`
[ "Applies", "all", "options", "set", "in", "the", "config", "file", "to", "cli_params" ]
python
train
h2oai/h2o-3
scripts/addjavamessage2ignore.py
https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/scripts/addjavamessage2ignore.py#L273-L285
def save_dict(): """ Save the ignored java message dict stored in g_ok_java_messages into a pickle file for future use. :return: none """ global g_ok_java_messages global g_save_java_message_filename global g_dict_changed if g_dict_changed: with open(g_save_java_message_filenam...
[ "def", "save_dict", "(", ")", ":", "global", "g_ok_java_messages", "global", "g_save_java_message_filename", "global", "g_dict_changed", "if", "g_dict_changed", ":", "with", "open", "(", "g_save_java_message_filename", ",", "'wb'", ")", "as", "ofile", ":", "pickle", ...
Save the ignored java message dict stored in g_ok_java_messages into a pickle file for future use. :return: none
[ "Save", "the", "ignored", "java", "message", "dict", "stored", "in", "g_ok_java_messages", "into", "a", "pickle", "file", "for", "future", "use", "." ]
python
test
awslabs/sockeye
sockeye/utils.py
https://github.com/awslabs/sockeye/blob/5d64a1ee1ef3cbba17c6d1d94bc061020c43f6ab/sockeye/utils.py#L791-L800
def read_metrics_file(path: str) -> List[Dict[str, Any]]: """ Reads lines metrics file and returns list of mappings of key and values. :param path: File to read metric values from. :return: Dictionary of metric names (e.g. perplexity-train) mapping to a list of values. """ with open(path) as fi...
[ "def", "read_metrics_file", "(", "path", ":", "str", ")", "->", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "with", "open", "(", "path", ")", "as", "fin", ":", "metrics", "=", "[", "parse_metrics_line", "(", "i", ",", "line", ".", ...
Reads lines metrics file and returns list of mappings of key and values. :param path: File to read metric values from. :return: Dictionary of metric names (e.g. perplexity-train) mapping to a list of values.
[ "Reads", "lines", "metrics", "file", "and", "returns", "list", "of", "mappings", "of", "key", "and", "values", "." ]
python
train
tammoippen/geohash-hilbert
geohash_hilbert/_int2str.py
https://github.com/tammoippen/geohash-hilbert/blob/b74f0fc1bff0234d8ff367e4129c3324676b0b36/geohash_hilbert/_int2str.py#L52-L71
def decode_int(tag, bits_per_char=6): """Decode string into int assuming encoding with `encode_int()` It is using 2, 4 or 6 bits per coding character (default 6). Parameters: tag: str Encoded integer. bits_per_char: int The number of bits per coding character. Returns: ...
[ "def", "decode_int", "(", "tag", ",", "bits_per_char", "=", "6", ")", ":", "if", "bits_per_char", "==", "6", ":", "return", "_decode_int64", "(", "tag", ")", "if", "bits_per_char", "==", "4", ":", "return", "_decode_int16", "(", "tag", ")", "if", "bits_p...
Decode string into int assuming encoding with `encode_int()` It is using 2, 4 or 6 bits per coding character (default 6). Parameters: tag: str Encoded integer. bits_per_char: int The number of bits per coding character. Returns: int: the decoded string
[ "Decode", "string", "into", "int", "assuming", "encoding", "with", "encode_int", "()" ]
python
train
hyperledger/sawtooth-core
validator/sawtooth_validator/journal/consensus/consensus_factory.py
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/journal/consensus/consensus_factory.py#L59-L78
def get_configured_consensus_module(block_id, state_view): """Returns the consensus_module based on the consensus module set by the "sawtooth_settings" transaction family. Args: block_id (str): the block id associated with the current state_view state_view (:obj:`StateVi...
[ "def", "get_configured_consensus_module", "(", "block_id", ",", "state_view", ")", ":", "settings_view", "=", "SettingsView", "(", "state_view", ")", "default_consensus", "=", "'genesis'", "if", "block_id", "==", "NULL_BLOCK_IDENTIFIER", "else", "'devmode'", "consensus_...
Returns the consensus_module based on the consensus module set by the "sawtooth_settings" transaction family. Args: block_id (str): the block id associated with the current state_view state_view (:obj:`StateView`): the current state view to use for setting values...
[ "Returns", "the", "consensus_module", "based", "on", "the", "consensus", "module", "set", "by", "the", "sawtooth_settings", "transaction", "family", "." ]
python
train
CI-WATER/gsshapy
gsshapy/orm/wms_dataset.py
https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/orm/wms_dataset.py#L144-L180
def write(self, session, directory, name, maskMap): """ Write from database to file. *session* = SQLAlchemy session object\n *directory* = to which directory will the files be written (e.g.: '/example/path')\n *name* = name of file that will be written (e.g.: 'my_project.ext')\n...
[ "def", "write", "(", "self", ",", "session", ",", "directory", ",", "name", ",", "maskMap", ")", ":", "# Assemble Path to file", "name_split", "=", "name", ".", "split", "(", "'.'", ")", "name", "=", "name_split", "[", "0", "]", "# Default extension", "ext...
Write from database to file. *session* = SQLAlchemy session object\n *directory* = to which directory will the files be written (e.g.: '/example/path')\n *name* = name of file that will be written (e.g.: 'my_project.ext')\n
[ "Write", "from", "database", "to", "file", "." ]
python
train
googleapis/google-cloud-python
dataproc/google/cloud/dataproc_v1beta2/gapic/cluster_controller_client.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/dataproc/google/cloud/dataproc_v1beta2/gapic/cluster_controller_client.py#L180-L278
def create_cluster( self, project_id, region, cluster, request_id=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None, ): """ Creates a cluster in a project. Examp...
[ "def", "create_cluster", "(", "self", ",", "project_id", ",", "region", ",", "cluster", ",", "request_id", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api...
Creates a cluster in a project. Example: >>> from google.cloud import dataproc_v1beta2 >>> >>> client = dataproc_v1beta2.ClusterControllerClient() >>> >>> # TODO: Initialize `project_id`: >>> project_id = '' >>> >>>...
[ "Creates", "a", "cluster", "in", "a", "project", "." ]
python
train
vtkiorg/vtki
vtki/filters.py
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/filters.py#L153-L196
def slice(dataset, normal='x', origin=None, generate_triangles=False, contour=False): """Slice a dataset by a plane at the specified origin and normal vector orientation. If no origin is specified, the center of the input dataset will be used. Parameters ----------...
[ "def", "slice", "(", "dataset", ",", "normal", "=", "'x'", ",", "origin", "=", "None", ",", "generate_triangles", "=", "False", ",", "contour", "=", "False", ")", ":", "if", "isinstance", "(", "normal", ",", "str", ")", ":", "normal", "=", "NORMALS", ...
Slice a dataset by a plane at the specified origin and normal vector orientation. If no origin is specified, the center of the input dataset will be used. Parameters ---------- normal : tuple(float) or str Length 3 tuple for the normal vector direction. Can also be ...
[ "Slice", "a", "dataset", "by", "a", "plane", "at", "the", "specified", "origin", "and", "normal", "vector", "orientation", ".", "If", "no", "origin", "is", "specified", "the", "center", "of", "the", "input", "dataset", "will", "be", "used", "." ]
python
train
mbedmicro/pyOCD
pyocd/__main__.py
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/__main__.py#L308-L340
def run(self, args=None): """! @brief Main entry point for command line processing.""" try: self._args = self.build_parser().parse_args(args) # Running without a subcommand will print usage. if self._args.cmd is None: if self._args.help_op...
[ "def", "run", "(", "self", ",", "args", "=", "None", ")", ":", "try", ":", "self", ".", "_args", "=", "self", ".", "build_parser", "(", ")", ".", "parse_args", "(", "args", ")", "# Running without a subcommand will print usage.", "if", "self", ".", "_args"...
! @brief Main entry point for command line processing.
[ "!" ]
python
train
serkanyersen/underscore.py
src/underscore.py
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1355-L1365
def mixin(self): """ Add your own custom functions to the Underscore object, ensuring that they're correctly added to the OOP wrapper as well. """ methods = self.obj for i, k in enumerate(methods): setattr(underscore, k, methods[k]) self.makeStatic() ...
[ "def", "mixin", "(", "self", ")", ":", "methods", "=", "self", ".", "obj", "for", "i", ",", "k", "in", "enumerate", "(", "methods", ")", ":", "setattr", "(", "underscore", ",", "k", ",", "methods", "[", "k", "]", ")", "self", ".", "makeStatic", "...
Add your own custom functions to the Underscore object, ensuring that they're correctly added to the OOP wrapper as well.
[ "Add", "your", "own", "custom", "functions", "to", "the", "Underscore", "object", "ensuring", "that", "they", "re", "correctly", "added", "to", "the", "OOP", "wrapper", "as", "well", "." ]
python
train
spacetelescope/drizzlepac
drizzlepac/util.py
https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/util.py#L1171-L1219
def base_taskname(taskname, packagename=None): """ Extract the base name of the task. Many tasks in the `drizzlepac` have "compound" names such as 'drizzlepac.sky'. This function will search for the presence of a dot in the input `taskname` and if found, it will return the string to the right o...
[ "def", "base_taskname", "(", "taskname", ",", "packagename", "=", "None", ")", ":", "if", "not", "isinstance", "(", "taskname", ",", "str", ")", ":", "return", "taskname", "indx", "=", "taskname", ".", "rfind", "(", "'.'", ")", "if", "indx", ">=", "0",...
Extract the base name of the task. Many tasks in the `drizzlepac` have "compound" names such as 'drizzlepac.sky'. This function will search for the presence of a dot in the input `taskname` and if found, it will return the string to the right of the right-most dot. If a dot is not found, it will return...
[ "Extract", "the", "base", "name", "of", "the", "task", "." ]
python
train
ninja-build/ninja
misc/ninja_syntax.py
https://github.com/ninja-build/ninja/blob/2e64645749ff91eff2f999f03f55da360ae5913d/misc/ninja_syntax.py#L116-L150
def _line(self, text, indent=0): """Write 'text' word-wrapped at self.width characters.""" leading_space = ' ' * indent while len(leading_space) + len(text) > self.width: # The text is too wide; wrap if possible. # Find the rightmost space that would obey our width cons...
[ "def", "_line", "(", "self", ",", "text", ",", "indent", "=", "0", ")", ":", "leading_space", "=", "' '", "*", "indent", "while", "len", "(", "leading_space", ")", "+", "len", "(", "text", ")", ">", "self", ".", "width", ":", "# The text is too wide; ...
Write 'text' word-wrapped at self.width characters.
[ "Write", "text", "word", "-", "wrapped", "at", "self", ".", "width", "characters", "." ]
python
train
coinbase/coinbase-python
coinbase/wallet/client.py
https://github.com/coinbase/coinbase-python/blob/497c28158f529e8c7d0228521b4386a890baf088/coinbase/wallet/client.py#L421-L426
def create_report(self, **params): """https://developers.coinbase.com/api/v2#generate-a-new-report""" if 'type' not in params and 'email' not in params: raise ValueError("Missing required parameter: 'type' or 'email'") response = self._post('v2', 'reports', data=params) retur...
[ "def", "create_report", "(", "self", ",", "*", "*", "params", ")", ":", "if", "'type'", "not", "in", "params", "and", "'email'", "not", "in", "params", ":", "raise", "ValueError", "(", "\"Missing required parameter: 'type' or 'email'\"", ")", "response", "=", ...
https://developers.coinbase.com/api/v2#generate-a-new-report
[ "https", ":", "//", "developers", ".", "coinbase", ".", "com", "/", "api", "/", "v2#generate", "-", "a", "-", "new", "-", "report" ]
python
train
DataDog/integrations-core
nginx/datadog_checks/nginx/nginx.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/nginx/datadog_checks/nginx/nginx.py#L275-L320
def _flatten_json(cls, metric_base, val, tags): """ Recursively flattens the nginx json object. Returns the following: [(metric_name, value, tags)] """ output = [] if isinstance(val, dict): # Pull out the server as a tag instead of trying to read as a metric ...
[ "def", "_flatten_json", "(", "cls", ",", "metric_base", ",", "val", ",", "tags", ")", ":", "output", "=", "[", "]", "if", "isinstance", "(", "val", ",", "dict", ")", ":", "# Pull out the server as a tag instead of trying to read as a metric", "if", "'server'", "...
Recursively flattens the nginx json object. Returns the following: [(metric_name, value, tags)]
[ "Recursively", "flattens", "the", "nginx", "json", "object", ".", "Returns", "the", "following", ":", "[", "(", "metric_name", "value", "tags", ")", "]" ]
python
train
nok/sklearn-porter
sklearn_porter/estimator/classifier/MLPClassifier/__init__.py
https://github.com/nok/sklearn-porter/blob/04673f768310bde31f9747a68a5e070592441ef2/sklearn_porter/estimator/classifier/MLPClassifier/__init__.py#L89-L156
def export(self, class_name, method_name, export_data=False, export_dir='.', export_filename='data.json', export_append_checksum=False, **kwargs): """ Port a trained estimator to the syntax of a chosen programming language. Parameters ---------- :pa...
[ "def", "export", "(", "self", ",", "class_name", ",", "method_name", ",", "export_data", "=", "False", ",", "export_dir", "=", "'.'", ",", "export_filename", "=", "'data.json'", ",", "export_append_checksum", "=", "False", ",", "*", "*", "kwargs", ")", ":", ...
Port a trained estimator to the syntax of a chosen programming language. Parameters ---------- :param class_name : string The name of the class in the returned result. :param method_name : string The name of the method in the returned result. :param expor...
[ "Port", "a", "trained", "estimator", "to", "the", "syntax", "of", "a", "chosen", "programming", "language", "." ]
python
train
jut-io/jut-python-tools
jut/api/data_engine.py
https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/data_engine.py#L79-L89
def get_juttle_data_url(deployment_name, token_manager=None, app_url=defaults.APP_URL): """ return the juttle data url """ return get_data_url(deployment_name, endpoint_type='juttle', app_url=app_url, ...
[ "def", "get_juttle_data_url", "(", "deployment_name", ",", "token_manager", "=", "None", ",", "app_url", "=", "defaults", ".", "APP_URL", ")", ":", "return", "get_data_url", "(", "deployment_name", ",", "endpoint_type", "=", "'juttle'", ",", "app_url", "=", "app...
return the juttle data url
[ "return", "the", "juttle", "data", "url" ]
python
train
vaexio/vaex
packages/vaex-core/vaex/functions.py
https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/functions.py#L1080-L1110
def str_repeat(x, repeats): """Duplicate each string in a column. :param int repeats: number of times each string sample is to be duplicated. :returns: an expression containing the duplicated strings Example: >>> import vaex >>> text = ['Something', 'very pretty', 'is coming', 'our', 'way.'] ...
[ "def", "str_repeat", "(", "x", ",", "repeats", ")", ":", "sl", "=", "_to_string_sequence", "(", "x", ")", ".", "repeat", "(", "repeats", ")", "return", "column", ".", "ColumnStringArrow", "(", "sl", ".", "bytes", ",", "sl", ".", "indices", ",", "sl", ...
Duplicate each string in a column. :param int repeats: number of times each string sample is to be duplicated. :returns: an expression containing the duplicated strings Example: >>> import vaex >>> text = ['Something', 'very pretty', 'is coming', 'our', 'way.'] >>> df = vaex.from_arrays(text=...
[ "Duplicate", "each", "string", "in", "a", "column", "." ]
python
test
intuition-io/intuition
intuition/api/algorithm.py
https://github.com/intuition-io/intuition/blob/cd517e6b3b315a743eb4d0d0dc294e264ab913ce/intuition/api/algorithm.py#L130-L139
def _call_one_middleware(self, middleware): ''' Evaluate arguments and execute the middleware function ''' args = {} for arg in middleware['args']: if hasattr(self, arg): # same as eval() but safer for arbitrary code execution args[arg] = reduce(getatt...
[ "def", "_call_one_middleware", "(", "self", ",", "middleware", ")", ":", "args", "=", "{", "}", "for", "arg", "in", "middleware", "[", "'args'", "]", ":", "if", "hasattr", "(", "self", ",", "arg", ")", ":", "# same as eval() but safer for arbitrary code execut...
Evaluate arguments and execute the middleware function
[ "Evaluate", "arguments", "and", "execute", "the", "middleware", "function" ]
python
train
minus7/asif
asif/bot.py
https://github.com/minus7/asif/blob/0d8acc5306ba93386ec679f69d466b56f099b877/asif/bot.py#L450-L457
def _bg(self, coro: coroutine) -> asyncio.Task: """Run coro in background, log errors""" async def runner(): try: await coro except: self._log.exception("async: Coroutine raised exception") return asyncio.ensure_future(runner())
[ "def", "_bg", "(", "self", ",", "coro", ":", "coroutine", ")", "->", "asyncio", ".", "Task", ":", "async", "def", "runner", "(", ")", ":", "try", ":", "await", "coro", "except", ":", "self", ".", "_log", ".", "exception", "(", "\"async: Coroutine raise...
Run coro in background, log errors
[ "Run", "coro", "in", "background", "log", "errors" ]
python
train
juju/charm-helpers
charmhelpers/contrib/database/mysql.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/database/mysql.py#L513-L520
def get_mem_total(self): """Calculate the total memory in the current service unit.""" with open('/proc/meminfo') as meminfo_file: for line in meminfo_file: key, mem = line.split(':', 2) if key == 'MemTotal': mtot, modifier = mem.strip().sp...
[ "def", "get_mem_total", "(", "self", ")", ":", "with", "open", "(", "'/proc/meminfo'", ")", "as", "meminfo_file", ":", "for", "line", "in", "meminfo_file", ":", "key", ",", "mem", "=", "line", ".", "split", "(", "':'", ",", "2", ")", "if", "key", "==...
Calculate the total memory in the current service unit.
[ "Calculate", "the", "total", "memory", "in", "the", "current", "service", "unit", "." ]
python
train
pandas-dev/pandas
pandas/core/dtypes/missing.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/missing.py#L157-L181
def _use_inf_as_na(key): """Option change callback for na/inf behaviour Choose which replacement for numpy.isnan / -numpy.isfinite is used. Parameters ---------- flag: bool True means treat None, NaN, INF, -INF as null (old way), False means None and NaN are null, but INF, -INF are ...
[ "def", "_use_inf_as_na", "(", "key", ")", ":", "from", "pandas", ".", "_config", "import", "get_option", "flag", "=", "get_option", "(", "key", ")", "if", "flag", ":", "globals", "(", ")", "[", "'_isna'", "]", "=", "_isna_old", "else", ":", "globals", ...
Option change callback for na/inf behaviour Choose which replacement for numpy.isnan / -numpy.isfinite is used. Parameters ---------- flag: bool True means treat None, NaN, INF, -INF as null (old way), False means None and NaN are null, but INF, -INF are not null (new way). ...
[ "Option", "change", "callback", "for", "na", "/", "inf", "behaviour", "Choose", "which", "replacement", "for", "numpy", ".", "isnan", "/", "-", "numpy", ".", "isfinite", "is", "used", "." ]
python
train
RJT1990/pyflux
pyflux/families/cauchy.py
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/families/cauchy.py#L188-L212
def markov_blanket(y, mean, scale, shape, skewness): """ Markov blanket for each likelihood term - used for state space models Parameters ---------- y : np.ndarray univariate time series mean : np.ndarray array of location parameters for the Cauchy distr...
[ "def", "markov_blanket", "(", "y", ",", "mean", ",", "scale", ",", "shape", ",", "skewness", ")", ":", "return", "ss", ".", "cauchy", ".", "logpdf", "(", "y", ",", "loc", "=", "mean", ",", "scale", "=", "scale", ")" ]
Markov blanket for each likelihood term - used for state space models Parameters ---------- y : np.ndarray univariate time series mean : np.ndarray array of location parameters for the Cauchy distribution scale : float scale parameter for th...
[ "Markov", "blanket", "for", "each", "likelihood", "term", "-", "used", "for", "state", "space", "models" ]
python
train
Capitains/flask-capitains-nemo
flask_nemo/chunker.py
https://github.com/Capitains/flask-capitains-nemo/blob/8d91f2c05b925a6c8ea8c997baf698c87257bc58/flask_nemo/chunker.py#L5-L17
def default_chunker(text, getreffs): """ This is the default chunker which will resolve the reference giving a callback (getreffs) and a text object with its metadata :param text: Text Object representing either an edition or a translation :type text: MyCapytains.resources.inventory.Text :param getreff...
[ "def", "default_chunker", "(", "text", ",", "getreffs", ")", ":", "level", "=", "len", "(", "text", ".", "citation", ")", "return", "[", "tuple", "(", "[", "reff", ".", "split", "(", "\":\"", ")", "[", "-", "1", "]", "]", "*", "2", ")", "for", ...
This is the default chunker which will resolve the reference giving a callback (getreffs) and a text object with its metadata :param text: Text Object representing either an edition or a translation :type text: MyCapytains.resources.inventory.Text :param getreffs: callback function which retrieves a list o...
[ "This", "is", "the", "default", "chunker", "which", "will", "resolve", "the", "reference", "giving", "a", "callback", "(", "getreffs", ")", "and", "a", "text", "object", "with", "its", "metadata" ]
python
valid
uchicago-cs/deepdish
deepdish/util/padding.py
https://github.com/uchicago-cs/deepdish/blob/01af93621fe082a3972fe53ba7375388c02b0085/deepdish/util/padding.py#L160-L197
def pad_repeat_border_corner(data, shape): """ Similar to `pad_repeat_border`, except the padding is always done on the upper end of each axis and the target size is specified. Parameters ---------- data : ndarray Numpy array of any dimension and type. shape : tuple Final sh...
[ "def", "pad_repeat_border_corner", "(", "data", ",", "shape", ")", ":", "new_data", "=", "np", ".", "empty", "(", "shape", ")", "new_data", "[", "[", "slice", "(", "upper", ")", "for", "upper", "in", "data", ".", "shape", "]", "]", "=", "data", "for"...
Similar to `pad_repeat_border`, except the padding is always done on the upper end of each axis and the target size is specified. Parameters ---------- data : ndarray Numpy array of any dimension and type. shape : tuple Final shape of padded array. Should be tuple of length ``data.n...
[ "Similar", "to", "pad_repeat_border", "except", "the", "padding", "is", "always", "done", "on", "the", "upper", "end", "of", "each", "axis", "and", "the", "target", "size", "is", "specified", "." ]
python
train
PolyJIT/benchbuild
benchbuild/container.py
https://github.com/PolyJIT/benchbuild/blob/9ad2ec54d96e97b642b1f06eddcbad9ba7aeaf58/benchbuild/container.py#L48-L81
def setup_container(builddir, _container): """Prepare the container and returns the path where it can be found.""" build_dir = local.path(builddir) in_dir = build_dir / "container-in" container_path = local.path(_container) with local.cwd(builddir): container_bin = container_path.basename ...
[ "def", "setup_container", "(", "builddir", ",", "_container", ")", ":", "build_dir", "=", "local", ".", "path", "(", "builddir", ")", "in_dir", "=", "build_dir", "/", "\"container-in\"", "container_path", "=", "local", ".", "path", "(", "_container", ")", "w...
Prepare the container and returns the path where it can be found.
[ "Prepare", "the", "container", "and", "returns", "the", "path", "where", "it", "can", "be", "found", "." ]
python
train
benoitkugler/abstractDataLibrary
pyDLib/GUI/list_views.py
https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/GUI/list_views.py#L361-L367
def _draw_placeholder(self): """To be used in QTreeView""" if self.model().rowCount() == 0: painter = QPainter(self.viewport()) painter.setFont(_custom_font(is_italic=True)) painter.drawText(self.rect().adjusted(0, 0, -5, -5), Qt.AlignCenter | Qt.TextWordWrap, ...
[ "def", "_draw_placeholder", "(", "self", ")", ":", "if", "self", ".", "model", "(", ")", ".", "rowCount", "(", ")", "==", "0", ":", "painter", "=", "QPainter", "(", "self", ".", "viewport", "(", ")", ")", "painter", ".", "setFont", "(", "_custom_font...
To be used in QTreeView
[ "To", "be", "used", "in", "QTreeView" ]
python
train
pycontribs/pyrax
pyrax/clouddatabases.py
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/clouddatabases.py#L509-L516
def enable_root_user(self): """ Enables login from any host for the root user and provides the user with a generated root password. """ uri = "/instances/%s/root" % self.id resp, body = self.manager.api.method_post(uri) return body["user"]["password"]
[ "def", "enable_root_user", "(", "self", ")", ":", "uri", "=", "\"/instances/%s/root\"", "%", "self", ".", "id", "resp", ",", "body", "=", "self", ".", "manager", ".", "api", ".", "method_post", "(", "uri", ")", "return", "body", "[", "\"user\"", "]", "...
Enables login from any host for the root user and provides the user with a generated root password.
[ "Enables", "login", "from", "any", "host", "for", "the", "root", "user", "and", "provides", "the", "user", "with", "a", "generated", "root", "password", "." ]
python
train
trec-kba/streamcorpus-pipeline
streamcorpus_pipeline/_lingpipe.py
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_lingpipe.py#L249-L254
def get_sentences(self, ner_dom): '''parse the sentences and tokens out of the XML''' lp_parser = LingPipeParser(self.config) lp_parser.set(ner_dom) sentences = list( lp_parser.sentences() ) return sentences, lp_parser.relations, lp_parser.attributes
[ "def", "get_sentences", "(", "self", ",", "ner_dom", ")", ":", "lp_parser", "=", "LingPipeParser", "(", "self", ".", "config", ")", "lp_parser", ".", "set", "(", "ner_dom", ")", "sentences", "=", "list", "(", "lp_parser", ".", "sentences", "(", ")", ")",...
parse the sentences and tokens out of the XML
[ "parse", "the", "sentences", "and", "tokens", "out", "of", "the", "XML" ]
python
test
datamachine/twx.botapi
twx/botapi/botapi.py
https://github.com/datamachine/twx.botapi/blob/c85184da738169e8f9d6d8e62970540f427c486e/twx/botapi/botapi.py#L4334-L4336
def edit_message_live_location(self, *args, **kwargs): """See :func:`edit_message_live_location`""" return edit_message_live_location(*args, **self._merge_overrides(**kwargs)).run()
[ "def", "edit_message_live_location", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "edit_message_live_location", "(", "*", "args", ",", "*", "*", "self", ".", "_merge_overrides", "(", "*", "*", "kwargs", ")", ")", ".", "run"...
See :func:`edit_message_live_location`
[ "See", ":", "func", ":", "edit_message_live_location" ]
python
train
mitsei/dlkit
dlkit/handcar/osid/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/osid/sessions.py#L295-L316
def get_effective_agent(self): """Gets the effective agent in use by this session. If is_authenticated() is true, then the effective agent may be the same as the agent returned by get_authenticated_agent(). If is_authenticated() is false, then the effective agent may be a default...
[ "def", "get_effective_agent", "(", "self", ")", ":", "if", "self", ".", "_proxy", "is", "not", "None", "and", "self", ".", "_proxy", ".", "has_authentication", "(", ")", ":", "return", "self", ".", "_proxy", ".", "get_authentication", "(", ")", ".", "get...
Gets the effective agent in use by this session. If is_authenticated() is true, then the effective agent may be the same as the agent returned by get_authenticated_agent(). If is_authenticated() is false, then the effective agent may be a default agent used for authorization by an unknwo...
[ "Gets", "the", "effective", "agent", "in", "use", "by", "this", "session", ".", "If", "is_authenticated", "()", "is", "true", "then", "the", "effective", "agent", "may", "be", "the", "same", "as", "the", "agent", "returned", "by", "get_authenticated_agent", ...
python
train
discontinue/django-secure-js-login
secure_js_login/utils/crypt.py
https://github.com/discontinue/django-secure-js-login/blob/4bfc592c48f381de115e592e721f31d2eb915968/secure_js_login/utils/crypt.py#L91-L101
def hexlify_pbkdf2(password, salt, iterations, length, digest=hashlib.sha1): """ >>> hash = hexlify_pbkdf2("not secret", "a salt value", iterations=100, length=16) >>> hash == '0b919231515dde16f76364666cf07107' True """ # log.debug("hexlify_pbkdf2 with iterations=%i", iterations) hash = cryp...
[ "def", "hexlify_pbkdf2", "(", "password", ",", "salt", ",", "iterations", ",", "length", ",", "digest", "=", "hashlib", ".", "sha1", ")", ":", "# log.debug(\"hexlify_pbkdf2 with iterations=%i\", iterations)", "hash", "=", "crypto", ".", "pbkdf2", "(", "password", ...
>>> hash = hexlify_pbkdf2("not secret", "a salt value", iterations=100, length=16) >>> hash == '0b919231515dde16f76364666cf07107' True
[ ">>>", "hash", "=", "hexlify_pbkdf2", "(", "not", "secret", "a", "salt", "value", "iterations", "=", "100", "length", "=", "16", ")", ">>>", "hash", "==", "0b919231515dde16f76364666cf07107", "True" ]
python
train
ktbyers/netmiko
netmiko/cisco/cisco_wlc_ssh.py
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_wlc_ssh.py#L15-L42
def special_login_handler(self, delay_factor=1): """WLC presents with the following on login (in certain OS versions) login as: user (Cisco Controller) User: user Password:**** """ delay_factor = self.select_delay_factor(delay_factor) i = 0 tim...
[ "def", "special_login_handler", "(", "self", ",", "delay_factor", "=", "1", ")", ":", "delay_factor", "=", "self", ".", "select_delay_factor", "(", "delay_factor", ")", "i", "=", "0", "time", ".", "sleep", "(", "delay_factor", "*", "0.5", ")", "output", "=...
WLC presents with the following on login (in certain OS versions) login as: user (Cisco Controller) User: user Password:****
[ "WLC", "presents", "with", "the", "following", "on", "login", "(", "in", "certain", "OS", "versions", ")" ]
python
train
JarryShaw/PyPCAPKit
src/protocols/internet/hopopt.py
https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hopopt.py#L974-L1014
def _read_opt_home(self, code, *, desc): """Read HOPOPT Home Address option. Structure of HOPOPT Home Address option [RFC 6275]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 ...
[ "def", "_read_opt_home", "(", "self", ",", "code", ",", "*", ",", "desc", ")", ":", "_type", "=", "self", ".", "_read_opt_type", "(", "code", ")", "_size", "=", "self", ".", "_read_unpack", "(", "1", ")", "if", "_size", "!=", "16", ":", "raise", "P...
Read HOPOPT Home Address option. Structure of HOPOPT Home Address option [RFC 6275]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...
[ "Read", "HOPOPT", "Home", "Address", "option", "." ]
python
train
briancappello/flask-unchained
flask_unchained/bundles/controller/utils.py
https://github.com/briancappello/flask-unchained/blob/4d536cb90e2cc4829c1c05f2c74d3e22901a1399/flask_unchained/bundles/controller/utils.py#L164-L182
def join(*args, trailing_slash=False): """ Return a url path joined from the arguments. It correctly handles blank/None arguments, and removes back-to-back slashes, eg:: assert join('/', 'foo', None, 'bar', '', 'baz') == '/foo/bar/baz' assert join('/', '/foo', '/', '/bar/') == '/foo/bar' ...
[ "def", "join", "(", "*", "args", ",", "trailing_slash", "=", "False", ")", ":", "dirty_path", "=", "'/'", ".", "join", "(", "map", "(", "lambda", "x", ":", "x", "and", "x", "or", "''", ",", "args", ")", ")", "path", "=", "re", ".", "sub", "(", ...
Return a url path joined from the arguments. It correctly handles blank/None arguments, and removes back-to-back slashes, eg:: assert join('/', 'foo', None, 'bar', '', 'baz') == '/foo/bar/baz' assert join('/', '/foo', '/', '/bar/') == '/foo/bar' Note that it removes trailing slashes by default...
[ "Return", "a", "url", "path", "joined", "from", "the", "arguments", ".", "It", "correctly", "handles", "blank", "/", "None", "arguments", "and", "removes", "back", "-", "to", "-", "back", "slashes", "eg", "::" ]
python
train
eaton-lab/toytree
toytree/Toytree.py
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L433-L447
def collapse_nodes(self, min_dist=1e-6, min_support=0): """ Returns a copy of the tree where internal nodes with dist <= min_dist are deleted, resulting in a collapsed tree. e.g.: newtre = tre.collapse_nodes(min_dist=0.001) newtre = tre.collapse_nodes(min_support=50) """...
[ "def", "collapse_nodes", "(", "self", ",", "min_dist", "=", "1e-6", ",", "min_support", "=", "0", ")", ":", "nself", "=", "self", ".", "copy", "(", ")", "for", "node", "in", "nself", ".", "treenode", ".", "traverse", "(", ")", ":", "if", "not", "no...
Returns a copy of the tree where internal nodes with dist <= min_dist are deleted, resulting in a collapsed tree. e.g.: newtre = tre.collapse_nodes(min_dist=0.001) newtre = tre.collapse_nodes(min_support=50)
[ "Returns", "a", "copy", "of", "the", "tree", "where", "internal", "nodes", "with", "dist", "<", "=", "min_dist", "are", "deleted", "resulting", "in", "a", "collapsed", "tree", ".", "e", ".", "g", ".", ":" ]
python
train
poldracklab/niworkflows
niworkflows/interfaces/mni.py
https://github.com/poldracklab/niworkflows/blob/254f4b4fcc5e6ecb29d2f4602a30786b913ecce5/niworkflows/interfaces/mni.py#L436-L502
def create_cfm(in_file, lesion_mask=None, global_mask=True, out_path=None): """ Create a mask to constrain registration. Parameters ---------- in_file : str Path to an existing image (usually a mask). If global_mask = True, this is used as a size/dimension reference. out_path : ...
[ "def", "create_cfm", "(", "in_file", ",", "lesion_mask", "=", "None", ",", "global_mask", "=", "True", ",", "out_path", "=", "None", ")", ":", "import", "os", "import", "numpy", "as", "np", "import", "nibabel", "as", "nb", "from", "nipype", ".", "utils",...
Create a mask to constrain registration. Parameters ---------- in_file : str Path to an existing image (usually a mask). If global_mask = True, this is used as a size/dimension reference. out_path : str Path/filename for the new cost function mask. lesion_mask : str, optiona...
[ "Create", "a", "mask", "to", "constrain", "registration", "." ]
python
train
NuGrid/NuGridPy
nugridpy/utils.py
https://github.com/NuGrid/NuGridPy/blob/eee8047446e398be77362d82c1d8b3310054fab0/nugridpy/utils.py#L789-L804
def isoratio_init(self,isos): ''' This file returns the isotopic ratio of two isotopes specified as iso1 and iso2. The isotopes are given as, e.g., ['Fe',56,'Fe',58] or ['Fe-56','Fe-58'] (for compatibility) -> list. ''' if len(isos) == 2: dumb = [] ...
[ "def", "isoratio_init", "(", "self", ",", "isos", ")", ":", "if", "len", "(", "isos", ")", "==", "2", ":", "dumb", "=", "[", "]", "dumb", "=", "isos", "[", "0", "]", ".", "split", "(", "'-'", ")", "dumb", ".", "append", "(", "isos", "[", "1",...
This file returns the isotopic ratio of two isotopes specified as iso1 and iso2. The isotopes are given as, e.g., ['Fe',56,'Fe',58] or ['Fe-56','Fe-58'] (for compatibility) -> list.
[ "This", "file", "returns", "the", "isotopic", "ratio", "of", "two", "isotopes", "specified", "as", "iso1", "and", "iso2", ".", "The", "isotopes", "are", "given", "as", "e", ".", "g", ".", "[", "Fe", "56", "Fe", "58", "]", "or", "[", "Fe", "-", "56"...
python
train
cbclab/MOT
mot/lib/utils.py
https://github.com/cbclab/MOT/blob/fb3243b65025705842e82704705c00902f9a35af/mot/lib/utils.py#L603-L653
def split_cl_function(cl_str): """Split an CL function into a return type, function name, parameters list and the body. Args: cl_str (str): the CL code to parse and plit into components Returns: tuple: string elements for the return type, function name, parameter list and the body """ ...
[ "def", "split_cl_function", "(", "cl_str", ")", ":", "class", "Semantics", ":", "def", "__init__", "(", "self", ")", ":", "self", ".", "_return_type", "=", "''", "self", ".", "_function_name", "=", "''", "self", ".", "_parameter_list", "=", "[", "]", "se...
Split an CL function into a return type, function name, parameters list and the body. Args: cl_str (str): the CL code to parse and plit into components Returns: tuple: string elements for the return type, function name, parameter list and the body
[ "Split", "an", "CL", "function", "into", "a", "return", "type", "function", "name", "parameters", "list", "and", "the", "body", "." ]
python
train
noxdafox/clipspy
clips/environment.py
https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/environment.py#L188-L202
def define_function(self, function, name=None): """Define the Python function within the CLIPS environment. If a name is given, it will be the function name within CLIPS. Otherwise, the name of the Python function will be used. The Python function will be accessible within CLIPS via it...
[ "def", "define_function", "(", "self", ",", "function", ",", "name", "=", "None", ")", ":", "name", "=", "name", "if", "name", "is", "not", "None", "else", "function", ".", "__name__", "ENVIRONMENT_DATA", "[", "self", ".", "_env", "]", ".", "user_functio...
Define the Python function within the CLIPS environment. If a name is given, it will be the function name within CLIPS. Otherwise, the name of the Python function will be used. The Python function will be accessible within CLIPS via its name as if it was defined via the `deffunction` c...
[ "Define", "the", "Python", "function", "within", "the", "CLIPS", "environment", "." ]
python
train
angr/pyvex
pyvex/lifting/util/instr_helper.py
https://github.com/angr/pyvex/blob/c418edc1146982b2a0579bf56e5993c1c7046b19/pyvex/lifting/util/instr_helper.py#L239-L253
def get(self, reg, ty): """ Load a value from a machine register into a VEX temporary register. All values must be loaded out of registers before they can be used with operations, etc and stored back into them when the instruction is over. See Put(). :param reg: Register number...
[ "def", "get", "(", "self", ",", "reg", ",", "ty", ")", ":", "offset", "=", "self", ".", "lookup_register", "(", "self", ".", "irsb_c", ".", "irsb", ".", "arch", ",", "reg", ")", "if", "offset", "==", "self", ".", "irsb_c", ".", "irsb", ".", "arch...
Load a value from a machine register into a VEX temporary register. All values must be loaded out of registers before they can be used with operations, etc and stored back into them when the instruction is over. See Put(). :param reg: Register number as an integer, or register string name ...
[ "Load", "a", "value", "from", "a", "machine", "register", "into", "a", "VEX", "temporary", "register", ".", "All", "values", "must", "be", "loaded", "out", "of", "registers", "before", "they", "can", "be", "used", "with", "operations", "etc", "and", "store...
python
train
bukun/TorCMS
torcms/handlers/user_handler.py
https://github.com/bukun/TorCMS/blob/6567c7fe2604a1d646d4570c017840958630ed2b/torcms/handlers/user_handler.py#L540-L582
def login(self): ''' user login. ''' post_data = self.get_post_data() if 'next' in post_data: next_url = post_data['next'] else: next_url = '/' u_name = post_data['user_name'] u_pass = post_data['user_pass'] result = MUse...
[ "def", "login", "(", "self", ")", ":", "post_data", "=", "self", ".", "get_post_data", "(", ")", "if", "'next'", "in", "post_data", ":", "next_url", "=", "post_data", "[", "'next'", "]", "else", ":", "next_url", "=", "'/'", "u_name", "=", "post_data", ...
user login.
[ "user", "login", "." ]
python
train
jaraco/jaraco.postgres
jaraco/postgres/__init__.py
https://github.com/jaraco/jaraco.postgres/blob/57375043314a3ce821ac3b0372ba2465135daa95/jaraco/postgres/__init__.py#L422-L450
def _is_running(self, tries=10): """ Return if the server is running according to pg_ctl. """ # We can't possibly be running if our base_pathname isn't defined. if not self.base_pathname: return False if tries < 1: raise ValueError('tries must be ...
[ "def", "_is_running", "(", "self", ",", "tries", "=", "10", ")", ":", "# We can't possibly be running if our base_pathname isn't defined.", "if", "not", "self", ".", "base_pathname", ":", "return", "False", "if", "tries", "<", "1", ":", "raise", "ValueError", "(",...
Return if the server is running according to pg_ctl.
[ "Return", "if", "the", "server", "is", "running", "according", "to", "pg_ctl", "." ]
python
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/install.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/install.py#L129-L147
def copyFuncVersionedLib(dest, source, env): """Install a versioned library into a destination by copying, (including copying permission/mode bits) and then creating required symlinks.""" if os.path.isdir(source): raise SCons.Errors.UserError("cannot install directory `%s' as a version library"...
[ "def", "copyFuncVersionedLib", "(", "dest", ",", "source", ",", "env", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "source", ")", ":", "raise", "SCons", ".", "Errors", ".", "UserError", "(", "\"cannot install directory `%s' as a version library\"", "...
Install a versioned library into a destination by copying, (including copying permission/mode bits) and then creating required symlinks.
[ "Install", "a", "versioned", "library", "into", "a", "destination", "by", "copying", "(", "including", "copying", "permission", "/", "mode", "bits", ")", "and", "then", "creating", "required", "symlinks", "." ]
python
train
ets-labs/python-dependency-injector
examples/providers/dependency.py
https://github.com/ets-labs/python-dependency-injector/blob/d04fe41eb17f667da38b97525e2d16c8f2d272fe/examples/providers/dependency.py#L40-L44
def get_by_id(self, id): """Return user info by user id.""" with contextlib.closing(self.database.cursor()) as cursor: cursor.execute('SELECT id, name FROM users WHERE id=?', (id,)) return cursor.fetchone()
[ "def", "get_by_id", "(", "self", ",", "id", ")", ":", "with", "contextlib", ".", "closing", "(", "self", ".", "database", ".", "cursor", "(", ")", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", "'SELECT id, name FROM users WHERE id=?'", ",", "(",...
Return user info by user id.
[ "Return", "user", "info", "by", "user", "id", "." ]
python
train
pymacaron/pymacaron
pymacaron/__init__.py
https://github.com/pymacaron/pymacaron/blob/af244f203f8216108b39d374d46bf8e1813f13d5/pymacaron/__init__.py#L177-L279
def start(self, serve=[]): """Load all apis, either as local apis served by the flask app, or as remote apis to be called from whithin the app's endpoints, then start the app server""" # Check arguments if type(serve) is str: serve = [serve] elif type(serve) ...
[ "def", "start", "(", "self", ",", "serve", "=", "[", "]", ")", ":", "# Check arguments", "if", "type", "(", "serve", ")", "is", "str", ":", "serve", "=", "[", "serve", "]", "elif", "type", "(", "serve", ")", "is", "list", ":", "pass", "else", ":"...
Load all apis, either as local apis served by the flask app, or as remote apis to be called from whithin the app's endpoints, then start the app server
[ "Load", "all", "apis", "either", "as", "local", "apis", "served", "by", "the", "flask", "app", "or", "as", "remote", "apis", "to", "be", "called", "from", "whithin", "the", "app", "s", "endpoints", "then", "start", "the", "app", "server" ]
python
train
zetaops/zengine
zengine/management_commands.py
https://github.com/zetaops/zengine/blob/b5bc32d3b37bca799f8985be916f04528ac79e4a/zengine/management_commands.py#L586-L599
def check_redis(): """ Redis checks the connection It displays on the screen whether or not you have a connection. """ from pyoko.db.connection import cache from redis.exceptions import ConnectionError try: cache.ping() print(Check...
[ "def", "check_redis", "(", ")", ":", "from", "pyoko", ".", "db", ".", "connection", "import", "cache", "from", "redis", ".", "exceptions", "import", "ConnectionError", "try", ":", "cache", ".", "ping", "(", ")", "print", "(", "CheckList", ".", "OKGREEN", ...
Redis checks the connection It displays on the screen whether or not you have a connection.
[ "Redis", "checks", "the", "connection", "It", "displays", "on", "the", "screen", "whether", "or", "not", "you", "have", "a", "connection", "." ]
python
train
google/grr
grr/server/grr_response_server/client_index.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/client_index.py#L531-L539
def RemoveAllClientLabels(self, client_id): """Removes all labels for a given client. Args: client_id: The client_id. """ labels_to_remove = set( [l.name for l in data_store.REL_DB.ReadClientLabels(client_id)]) self.RemoveClientLabels(client_id, labels_to_remove)
[ "def", "RemoveAllClientLabels", "(", "self", ",", "client_id", ")", ":", "labels_to_remove", "=", "set", "(", "[", "l", ".", "name", "for", "l", "in", "data_store", ".", "REL_DB", ".", "ReadClientLabels", "(", "client_id", ")", "]", ")", "self", ".", "Re...
Removes all labels for a given client. Args: client_id: The client_id.
[ "Removes", "all", "labels", "for", "a", "given", "client", "." ]
python
train
eng-tools/sfsimodels
sfsimodels/scores.py
https://github.com/eng-tools/sfsimodels/blob/65a690ca440d61307f5a9b8478e4704f203a5925/sfsimodels/scores.py#L4-L21
def lc_score(value): """ Evaluates the accuracy of a predictive measure (e.g. r-squared) :param value: float, between 0.0 and 1.0. :return: """ rebased = 2 * (value - 0.5) if rebased == 0: return 0 elif rebased > 0: compliment = 1.0 - rebased score = - np.log2(c...
[ "def", "lc_score", "(", "value", ")", ":", "rebased", "=", "2", "*", "(", "value", "-", "0.5", ")", "if", "rebased", "==", "0", ":", "return", "0", "elif", "rebased", ">", "0", ":", "compliment", "=", "1.0", "-", "rebased", "score", "=", "-", "np...
Evaluates the accuracy of a predictive measure (e.g. r-squared) :param value: float, between 0.0 and 1.0. :return:
[ "Evaluates", "the", "accuracy", "of", "a", "predictive", "measure", "(", "e", ".", "g", ".", "r", "-", "squared", ")" ]
python
train
genialis/resolwe
resolwe/flow/migrations/0012_recreate_empty_parents.py
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/migrations/0012_recreate_empty_parents.py#L10-L31
def recreate_parent_dependencies(apps, schema_editor): """Create empty dependency relation if parent has been deleted.""" Data = apps.get_model('flow', 'Data') DataDependency = apps.get_model('flow', 'DataDependency') def process_dependency(data, parent): if not Data.objects.filter(pk=parent).e...
[ "def", "recreate_parent_dependencies", "(", "apps", ",", "schema_editor", ")", ":", "Data", "=", "apps", ".", "get_model", "(", "'flow'", ",", "'Data'", ")", "DataDependency", "=", "apps", ".", "get_model", "(", "'flow'", ",", "'DataDependency'", ")", "def", ...
Create empty dependency relation if parent has been deleted.
[ "Create", "empty", "dependency", "relation", "if", "parent", "has", "been", "deleted", "." ]
python
train
great-expectations/great_expectations
great_expectations/data_asset/file_data_asset.py
https://github.com/great-expectations/great_expectations/blob/08385c40529d4f14a1c46916788aecc47f33ee9d/great_expectations/data_asset/file_data_asset.py#L259-L333
def expect_file_line_regex_match_count_to_equal(self, regex, expected_count=0, skip=None, mostly=None, nonnul...
[ "def", "expect_file_line_regex_match_count_to_equal", "(", "self", ",", "regex", ",", "expected_count", "=", "0", ",", "skip", "=", "None", ",", "mostly", "=", "None", ",", "nonnull_lines_regex", "=", "r\"^\\s*$\"", ",", "result_format", "=", "None", ",", "inclu...
Expect the number of times a regular expression appears on each line of a file to be between a maximum and minimum value. Args: regex: \ A string that can be compiled as valid regular expression to match expected_count (None or nonnegative integer): \ ...
[ "Expect", "the", "number", "of", "times", "a", "regular", "expression", "appears", "on", "each", "line", "of", "a", "file", "to", "be", "between", "a", "maximum", "and", "minimum", "value", "." ]
python
train
pymupdf/PyMuPDF
fitz/utils.py
https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/utils.py#L1100-L1128
def insertPage( doc, pno, text=None, fontsize=11, width=595, height=842, fontname="helv", fontfile=None, color=None, ): """ Create a new PDF page and insert some text. Notes: Function combining Document.newPage() and Page.inser...
[ "def", "insertPage", "(", "doc", ",", "pno", ",", "text", "=", "None", ",", "fontsize", "=", "11", ",", "width", "=", "595", ",", "height", "=", "842", ",", "fontname", "=", "\"helv\"", ",", "fontfile", "=", "None", ",", "color", "=", "None", ",", ...
Create a new PDF page and insert some text. Notes: Function combining Document.newPage() and Page.insertText(). For parameter details see these methods.
[ "Create", "a", "new", "PDF", "page", "and", "insert", "some", "text", "." ]
python
train
aarongarrett/inspyred
inspyred/ec/archivers.py
https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/archivers.py#L121-L256
def adaptive_grid_archiver(random, population, archive, args): """Archive only the best individual(s) using a fixed size grid. This function archives the best solutions by using a fixed-size grid to determine which existing solutions should be removed in order to make room for new ones. This archiv...
[ "def", "adaptive_grid_archiver", "(", "random", ",", "population", ",", "archive", ",", "args", ")", ":", "def", "get_grid_location", "(", "fitness", ",", "num_grid_divisions", ",", "global_smallest", ",", "global_largest", ")", ":", "loc", "=", "0", "n", "=",...
Archive only the best individual(s) using a fixed size grid. This function archives the best solutions by using a fixed-size grid to determine which existing solutions should be removed in order to make room for new ones. This archiver is designed specifically for use with the Pareto Archived Evolu...
[ "Archive", "only", "the", "best", "individual", "(", "s", ")", "using", "a", "fixed", "size", "grid", ".", "This", "function", "archives", "the", "best", "solutions", "by", "using", "a", "fixed", "-", "size", "grid", "to", "determine", "which", "existing",...
python
train
roclark/sportsreference
sportsreference/nhl/boxscore.py
https://github.com/roclark/sportsreference/blob/ea0bae432be76450e137671d2998eb38f962dffd/sportsreference/nhl/boxscore.py#L581-L664
def _parse_game_data(self, uri): """ Parses a value for every attribute. This function looks through every attribute and retrieves the value according to the parsing scheme and index of the attribute from the passed HTML data. Once the value is retrieved, the attribute's value i...
[ "def", "_parse_game_data", "(", "self", ",", "uri", ")", ":", "boxscore", "=", "self", ".", "_retrieve_html_page", "(", "uri", ")", "# If the boxscore is None, the game likely hasn't been played yet and", "# no information can be gathered. As there is nothing to grab, the", "# cl...
Parses a value for every attribute. This function looks through every attribute and retrieves the value according to the parsing scheme and index of the attribute from the passed HTML data. Once the value is retrieved, the attribute's value is updated with the returned result. ...
[ "Parses", "a", "value", "for", "every", "attribute", "." ]
python
train
tcalmant/ipopo
pelix/ipopo/handlers/requiresbest.py
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/ipopo/handlers/requiresbest.py#L54-L79
def get_handlers(self, component_context, instance): """ Sets up service providers for the given component :param component_context: The ComponentContext bean :param instance: The component instance :return: The list of handlers associated to the given component """ ...
[ "def", "get_handlers", "(", "self", ",", "component_context", ",", "instance", ")", ":", "# Extract information from the context", "requirements", "=", "component_context", ".", "get_handler", "(", "ipopo_constants", ".", "HANDLER_REQUIRES_BEST", ")", "requires_filters", ...
Sets up service providers for the given component :param component_context: The ComponentContext bean :param instance: The component instance :return: The list of handlers associated to the given component
[ "Sets", "up", "service", "providers", "for", "the", "given", "component" ]
python
train
odlgroup/odl
odl/discr/discretization.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/discr/discretization.py#L414-L439
def sampling(self, ufunc, **kwargs): """Sample a continuous function and assign to this element. Parameters ---------- ufunc : ``self.space.fspace`` element The continuous function that should be samplingicted. kwargs : Additional arugments for the sampli...
[ "def", "sampling", "(", "self", ",", "ufunc", ",", "*", "*", "kwargs", ")", ":", "self", ".", "space", ".", "sampling", "(", "ufunc", ",", "out", "=", "self", ".", "tensor", ",", "*", "*", "kwargs", ")" ]
Sample a continuous function and assign to this element. Parameters ---------- ufunc : ``self.space.fspace`` element The continuous function that should be samplingicted. kwargs : Additional arugments for the sampling operator implementation Examples ...
[ "Sample", "a", "continuous", "function", "and", "assign", "to", "this", "element", "." ]
python
train
jilljenn/tryalgo
tryalgo/max_interval_intersec.py
https://github.com/jilljenn/tryalgo/blob/89a4dd9655e7b6b0a176f72b4c60d0196420dfe1/tryalgo/max_interval_intersec.py#L8-L23
def max_interval_intersec(S): """determine a value that is contained in a largest number of given intervals :param S: list of half open intervals :complexity: O(n log n), where n = len(S) """ B = ([(left, +1) for left, right in S] + [(right, -1) for left, right in S]) B.sort() c =...
[ "def", "max_interval_intersec", "(", "S", ")", ":", "B", "=", "(", "[", "(", "left", ",", "+", "1", ")", "for", "left", ",", "right", "in", "S", "]", "+", "[", "(", "right", ",", "-", "1", ")", "for", "left", ",", "right", "in", "S", "]", "...
determine a value that is contained in a largest number of given intervals :param S: list of half open intervals :complexity: O(n log n), where n = len(S)
[ "determine", "a", "value", "that", "is", "contained", "in", "a", "largest", "number", "of", "given", "intervals" ]
python
train
googleapis/google-cloud-python
storage/google/cloud/storage/_helpers.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/storage/google/cloud/storage/_helpers.py#L216-L228
def _scalar_property(fieldname): """Create a property descriptor around the :class:`_PropertyMixin` helpers. """ def _getter(self): """Scalar property getter.""" return self._properties.get(fieldname) def _setter(self, value): """Scalar property setter.""" self._patch_p...
[ "def", "_scalar_property", "(", "fieldname", ")", ":", "def", "_getter", "(", "self", ")", ":", "\"\"\"Scalar property getter.\"\"\"", "return", "self", ".", "_properties", ".", "get", "(", "fieldname", ")", "def", "_setter", "(", "self", ",", "value", ")", ...
Create a property descriptor around the :class:`_PropertyMixin` helpers.
[ "Create", "a", "property", "descriptor", "around", "the", ":", "class", ":", "_PropertyMixin", "helpers", "." ]
python
train
wavycloud/pyboto3
pyboto3/machinelearning.py
https://github.com/wavycloud/pyboto3/blob/924957ccf994303713a4eed90b775ff2ab95b2e5/pyboto3/machinelearning.py#L752-L857
def describe_batch_predictions(FilterVariable=None, EQ=None, GT=None, LT=None, GE=None, LE=None, NE=None, Prefix=None, SortOrder=None, NextToken=None, Limit=None): """ Returns a list of BatchPrediction operations that match the search criteria in the request. See also: AWS API Documentation :e...
[ "def", "describe_batch_predictions", "(", "FilterVariable", "=", "None", ",", "EQ", "=", "None", ",", "GT", "=", "None", ",", "LT", "=", "None", ",", "GE", "=", "None", ",", "LE", "=", "None", ",", "NE", "=", "None", ",", "Prefix", "=", "None", ","...
Returns a list of BatchPrediction operations that match the search criteria in the request. See also: AWS API Documentation :example: response = client.describe_batch_predictions( FilterVariable='CreatedAt'|'LastUpdatedAt'|'Status'|'Name'|'IAMUser'|'MLModelId'|'DataSourceId'|'DataURI', ...
[ "Returns", "a", "list", "of", "BatchPrediction", "operations", "that", "match", "the", "search", "criteria", "in", "the", "request", ".", "See", "also", ":", "AWS", "API", "Documentation", ":", "example", ":", "response", "=", "client", ".", "describe_batch_pr...
python
train
JasonKessler/scattertext
scattertext/DeployedClassifier.py
https://github.com/JasonKessler/scattertext/blob/cacf1f687d218ee8cae3fc05cc901db824bb1b81/scattertext/DeployedClassifier.py#L80-L88
def build(self): '''Builds Depoyed Classifier ''' if self._clf is None: raise NeedToTrainExceptionBeforeDeployingException() return DeployedClassifier(self._category, self._term_doc_matrix._category_idx_store, self._term_doc_matrix._term_idx_store, ...
[ "def", "build", "(", "self", ")", ":", "if", "self", ".", "_clf", "is", "None", ":", "raise", "NeedToTrainExceptionBeforeDeployingException", "(", ")", "return", "DeployedClassifier", "(", "self", ".", "_category", ",", "self", ".", "_term_doc_matrix", ".", "_...
Builds Depoyed Classifier
[ "Builds", "Depoyed", "Classifier" ]
python
train
wandb/client
wandb/vendor/prompt_toolkit/layout/containers.py
https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/vendor/prompt_toolkit/layout/containers.py#L1004-L1035
def _merge_dimensions(dimension, preferred=None, dont_extend=False): """ Take the LayoutDimension from this `Window` class and the received preferred size from the `UIControl` and return a `LayoutDimension` to report to the parent container. """ dimension = dimension or L...
[ "def", "_merge_dimensions", "(", "dimension", ",", "preferred", "=", "None", ",", "dont_extend", "=", "False", ")", ":", "dimension", "=", "dimension", "or", "LayoutDimension", "(", ")", "# When a preferred dimension was explicitly given to the Window,", "# ignore the UIC...
Take the LayoutDimension from this `Window` class and the received preferred size from the `UIControl` and return a `LayoutDimension` to report to the parent container.
[ "Take", "the", "LayoutDimension", "from", "this", "Window", "class", "and", "the", "received", "preferred", "size", "from", "the", "UIControl", "and", "return", "a", "LayoutDimension", "to", "report", "to", "the", "parent", "container", "." ]
python
train
NickMonzillo/SmartCloud
SmartCloud/__init__.py
https://github.com/NickMonzillo/SmartCloud/blob/481d1ef428427b452a8a787999c1d4a8868a3824/SmartCloud/__init__.py#L87-L107
def text_cloud(self,text,max_text_size=72,min_text_size=12,expand_width=50,expand_height=50,max_count=100000): '''Creates a word cloud using plain text.''' worddict = assign_fonts(tuplecount(text),max_text_size,min_text_size,self.exclude_words) sorted_worddict = list(reversed(sorted(worddict.key...
[ "def", "text_cloud", "(", "self", ",", "text", ",", "max_text_size", "=", "72", ",", "min_text_size", "=", "12", ",", "expand_width", "=", "50", ",", "expand_height", "=", "50", ",", "max_count", "=", "100000", ")", ":", "worddict", "=", "assign_fonts", ...
Creates a word cloud using plain text.
[ "Creates", "a", "word", "cloud", "using", "plain", "text", "." ]
python
train
jobovy/galpy
galpy/orbit/OrbitTop.py
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/orbit/OrbitTop.py#L495-L516
def dec(self,*args,**kwargs): """ NAME: dec PURPOSE: return the declination INPUT: t - (optional) time at which to get dec obs=[X,Y,Z] - (optional) position of observer (in kpc) (default=Object-wide default) ...
[ "def", "dec", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "_check_roSet", "(", "self", ",", "kwargs", ",", "'dec'", ")", "radec", "=", "self", ".", "_radec", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "radec",...
NAME: dec PURPOSE: return the declination INPUT: t - (optional) time at which to get dec obs=[X,Y,Z] - (optional) position of observer (in kpc) (default=Object-wide default) OR Orbit object that corresponds to...
[ "NAME", ":", "dec", "PURPOSE", ":", "return", "the", "declination", "INPUT", ":", "t", "-", "(", "optional", ")", "time", "at", "which", "to", "get", "dec", "obs", "=", "[", "X", "Y", "Z", "]", "-", "(", "optional", ")", "position", "of", "observer...
python
train
vtkiorg/vtki
vtki/common.py
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/common.py#L864-L876
def overwrite(self, mesh): """ Overwrites this mesh inplace with the new mesh's geometries and data Parameters ---------- mesh : vtk.vtkDataSet The overwriting mesh. """ self.DeepCopy(mesh) if is_vtki_obj(mesh): self.copy_meta_fro...
[ "def", "overwrite", "(", "self", ",", "mesh", ")", ":", "self", ".", "DeepCopy", "(", "mesh", ")", "if", "is_vtki_obj", "(", "mesh", ")", ":", "self", ".", "copy_meta_from", "(", "mesh", ")" ]
Overwrites this mesh inplace with the new mesh's geometries and data Parameters ---------- mesh : vtk.vtkDataSet The overwriting mesh.
[ "Overwrites", "this", "mesh", "inplace", "with", "the", "new", "mesh", "s", "geometries", "and", "data" ]
python
train
Unity-Technologies/ml-agents
ml-agents/mlagents/trainers/ppo/models.py
https://github.com/Unity-Technologies/ml-agents/blob/37d139af636e4a2351751fbf0f2fca5a9ed7457f/ml-agents/mlagents/trainers/ppo/models.py#L56-L114
def create_curiosity_encoders(self): """ Creates state encoders for current and future observations. Used for implementation of Curiosity-driven Exploration by Self-supervised Prediction See https://arxiv.org/abs/1705.05363 for more details. :return: current and future state enc...
[ "def", "create_curiosity_encoders", "(", "self", ")", ":", "encoded_state_list", "=", "[", "]", "encoded_next_state_list", "=", "[", "]", "if", "self", ".", "vis_obs_size", ">", "0", ":", "self", ".", "next_visual_in", "=", "[", "]", "visual_encoders", "=", ...
Creates state encoders for current and future observations. Used for implementation of Curiosity-driven Exploration by Self-supervised Prediction See https://arxiv.org/abs/1705.05363 for more details. :return: current and future state encoder tensors.
[ "Creates", "state", "encoders", "for", "current", "and", "future", "observations", ".", "Used", "for", "implementation", "of", "Curiosity", "-", "driven", "Exploration", "by", "Self", "-", "supervised", "Prediction", "See", "https", ":", "//", "arxiv", ".", "...
python
train
F5Networks/f5-common-python
f5/multi_device/trust_domain.py
https://github.com/F5Networks/f5-common-python/blob/7e67d5acd757a60e3d5f8c88c534bd72208f5494/f5/multi_device/trust_domain.py#L208-L224
def _delete_iapp(self, iapp_name, deploying_device): '''Delete an iapp service and template on the root device. :param iapp_name: str -- name of iapp :param deploying_device: ManagementRoot object -- device where the iapp will be deleted ''' iap...
[ "def", "_delete_iapp", "(", "self", ",", "iapp_name", ",", "deploying_device", ")", ":", "iapp", "=", "deploying_device", ".", "tm", ".", "sys", ".", "application", "iapp_serv", "=", "iapp", ".", "services", ".", "service", ".", "load", "(", "name", "=", ...
Delete an iapp service and template on the root device. :param iapp_name: str -- name of iapp :param deploying_device: ManagementRoot object -- device where the iapp will be deleted
[ "Delete", "an", "iapp", "service", "and", "template", "on", "the", "root", "device", "." ]
python
train
ewiger/mlab
src/mlab/awmstools.py
https://github.com/ewiger/mlab/blob/72a98adf6499f548848ad44c604f74d68f07fe4f/src/mlab/awmstools.py#L829-L852
def splitAt(iterable, indices): r"""Yield chunks of `iterable`, split at the points in `indices`: >>> [l for l in splitAt(range(10), [2,5])] [[0, 1], [2, 3, 4], [5, 6, 7, 8, 9]] splits past the length of `iterable` are ignored: >>> [l for l in splitAt(range(10), [2,5,10])] [[0, 1], [2, 3, 4],...
[ "def", "splitAt", "(", "iterable", ",", "indices", ")", ":", "iterable", "=", "iter", "(", "iterable", ")", "now", "=", "0", "for", "to", "in", "indices", ":", "try", ":", "res", "=", "[", "]", "for", "i", "in", "range", "(", "now", ",", "to", ...
r"""Yield chunks of `iterable`, split at the points in `indices`: >>> [l for l in splitAt(range(10), [2,5])] [[0, 1], [2, 3, 4], [5, 6, 7, 8, 9]] splits past the length of `iterable` are ignored: >>> [l for l in splitAt(range(10), [2,5,10])] [[0, 1], [2, 3, 4], [5, 6, 7, 8, 9]]
[ "r", "Yield", "chunks", "of", "iterable", "split", "at", "the", "points", "in", "indices", ":" ]
python
train
gagneurlab/concise
concise/data/encode.py
https://github.com/gagneurlab/concise/blob/d15262eb1e590008bc96ba31e93bfbdbfa1a9fd4/concise/data/encode.py#L34-L47
def get_pwm_list(motif_name_list, pseudocountProb=0.0001): """Get a list of ENCODE PWM's. # Arguments pwm_id_list: List of id's from the `PWM_id` column in `get_metadata()` table pseudocountProb: Added pseudocount probabilities to the PWM # Returns List of `concise.utils.pwm.PWM` i...
[ "def", "get_pwm_list", "(", "motif_name_list", ",", "pseudocountProb", "=", "0.0001", ")", ":", "l", "=", "_load_motifs", "(", ")", "l", "=", "{", "k", ".", "split", "(", ")", "[", "0", "]", ":", "v", "for", "k", ",", "v", "in", "l", ".", "items"...
Get a list of ENCODE PWM's. # Arguments pwm_id_list: List of id's from the `PWM_id` column in `get_metadata()` table pseudocountProb: Added pseudocount probabilities to the PWM # Returns List of `concise.utils.pwm.PWM` instances.
[ "Get", "a", "list", "of", "ENCODE", "PWM", "s", "." ]
python
train
ray-project/ray
python/ray/tune/automlboard/run.py
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/run.py#L18-L43
def run_board(args): """ Run main entry for AutoMLBoard. Args: args: args parsed from command line """ init_config(args) # backend service, should import after django settings initialized from backend.collector import CollectorService service = CollectorService( args.l...
[ "def", "run_board", "(", "args", ")", ":", "init_config", "(", "args", ")", "# backend service, should import after django settings initialized", "from", "backend", ".", "collector", "import", "CollectorService", "service", "=", "CollectorService", "(", "args", ".", "lo...
Run main entry for AutoMLBoard. Args: args: args parsed from command line
[ "Run", "main", "entry", "for", "AutoMLBoard", "." ]
python
train
nugget/python-insteonplm
insteonplm/utils.py
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/utils.py#L28-L30
def byte_to_unitcode(bytecode): """Return an X10 unitcode value from a byte value.""" return list(UC_LOOKUP.keys())[list(UC_LOOKUP.values()).index(bytecode)]
[ "def", "byte_to_unitcode", "(", "bytecode", ")", ":", "return", "list", "(", "UC_LOOKUP", ".", "keys", "(", ")", ")", "[", "list", "(", "UC_LOOKUP", ".", "values", "(", ")", ")", ".", "index", "(", "bytecode", ")", "]" ]
Return an X10 unitcode value from a byte value.
[ "Return", "an", "X10", "unitcode", "value", "from", "a", "byte", "value", "." ]
python
train
tanghaibao/jcvi
jcvi/algorithms/lis.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/algorithms/lis.py#L78-L104
def longest_increasing_subsequence(xs): '''Return a longest increasing subsequence of xs. (Note that there may be more than one such subsequence.) >>> longest_increasing_subsequence(range(3)) [0, 1, 2] >>> longest_increasing_subsequence([3, 1, 2, 0]) [1, 2] ''' # Patience sort xs, stack...
[ "def", "longest_increasing_subsequence", "(", "xs", ")", ":", "# Patience sort xs, stacking (x, prev_ix) pairs on the piles.", "# Prev_ix indexes the element at the top of the previous pile,", "# which has a lower x value than the current x value.", "piles", "=", "[", "[", "]", "]", "#...
Return a longest increasing subsequence of xs. (Note that there may be more than one such subsequence.) >>> longest_increasing_subsequence(range(3)) [0, 1, 2] >>> longest_increasing_subsequence([3, 1, 2, 0]) [1, 2]
[ "Return", "a", "longest", "increasing", "subsequence", "of", "xs", "." ]
python
train
pandas-dev/pandas
pandas/core/series.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/series.py#L1575-L1588
def _set_name(self, name, inplace=False): """ Set the Series name. Parameters ---------- name : str inplace : bool whether to modify `self` directly or return a copy """ inplace = validate_bool_kwarg(inplace, 'inplace') ser = self if i...
[ "def", "_set_name", "(", "self", ",", "name", ",", "inplace", "=", "False", ")", ":", "inplace", "=", "validate_bool_kwarg", "(", "inplace", ",", "'inplace'", ")", "ser", "=", "self", "if", "inplace", "else", "self", ".", "copy", "(", ")", "ser", ".", ...
Set the Series name. Parameters ---------- name : str inplace : bool whether to modify `self` directly or return a copy
[ "Set", "the", "Series", "name", "." ]
python
train
myint/autoflake
autoflake.py
https://github.com/myint/autoflake/blob/68fea68646922b920d55975f9f2adaeafd84df4f/autoflake.py#L564-L574
def filter_useless_pass(source): """Yield code with useless "pass" lines removed.""" try: marked_lines = frozenset(useless_pass_line_numbers(source)) except (SyntaxError, tokenize.TokenError): marked_lines = frozenset() sio = io.StringIO(source) for line_number, line in enumerate(si...
[ "def", "filter_useless_pass", "(", "source", ")", ":", "try", ":", "marked_lines", "=", "frozenset", "(", "useless_pass_line_numbers", "(", "source", ")", ")", "except", "(", "SyntaxError", ",", "tokenize", ".", "TokenError", ")", ":", "marked_lines", "=", "fr...
Yield code with useless "pass" lines removed.
[ "Yield", "code", "with", "useless", "pass", "lines", "removed", "." ]
python
test
theislab/scanpy
scanpy/plotting/_anndata.py
https://github.com/theislab/scanpy/blob/9e4e5ee02e04cf618872d9b098e24f0542e8b227/scanpy/plotting/_anndata.py#L1320-L1620
def dotplot(adata, var_names, groupby=None, use_raw=None, log=False, num_categories=7, expression_cutoff=0., mean_only_expressed=False, color_map='Reds', dot_max=None, dot_min=None, figsize=None, dendrogram=False, gene_symbols=None, var_group_positions=None, standard_scale=None, smal...
[ "def", "dotplot", "(", "adata", ",", "var_names", ",", "groupby", "=", "None", ",", "use_raw", "=", "None", ",", "log", "=", "False", ",", "num_categories", "=", "7", ",", "expression_cutoff", "=", "0.", ",", "mean_only_expressed", "=", "False", ",", "co...
\ Makes a *dot plot* of the expression values of `var_names`. For each var_name and each `groupby` category a dot is plotted. Each dot represents two values: mean expression within each category (visualized by color) and fraction of cells expressing the var_name in the category (visualized by the s...
[ "\\", "Makes", "a", "*", "dot", "plot", "*", "of", "the", "expression", "values", "of", "var_names", "." ]
python
train
arne-cl/discoursegraphs
src/discoursegraphs/readwrite/salt/saltxmi.py
https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/salt/saltxmi.py#L264-L270
def print_token(self, token_node_index): """returns the string representation of a token.""" err_msg = "The given node is not a token node." assert isinstance(self.nodes[token_node_index], TokenNode), err_msg onset = self.nodes[token_node_index].onset offset = self.nodes[token_no...
[ "def", "print_token", "(", "self", ",", "token_node_index", ")", ":", "err_msg", "=", "\"The given node is not a token node.\"", "assert", "isinstance", "(", "self", ".", "nodes", "[", "token_node_index", "]", ",", "TokenNode", ")", ",", "err_msg", "onset", "=", ...
returns the string representation of a token.
[ "returns", "the", "string", "representation", "of", "a", "token", "." ]
python
train
adrn/gala
gala/dynamics/actionangle.py
https://github.com/adrn/gala/blob/ea95575a0df1581bb4b0986aebd6eea8438ab7eb/gala/dynamics/actionangle.py#L237-L283
def check_angle_sampling(nvecs, angles): """ Returns a list of the index of elements of n which do not have adequate toy angle coverage. The criterion is that we must have at least one sample in each Nyquist box when we project the toy angles along the vector n. Parameters ---------- nvecs ...
[ "def", "check_angle_sampling", "(", "nvecs", ",", "angles", ")", ":", "failed_nvecs", "=", "[", "]", "failures", "=", "[", "]", "for", "i", ",", "vec", "in", "enumerate", "(", "nvecs", ")", ":", "# N = np.linalg.norm(vec)", "# X = np.dot(angles,vec)", "X", "...
Returns a list of the index of elements of n which do not have adequate toy angle coverage. The criterion is that we must have at least one sample in each Nyquist box when we project the toy angles along the vector n. Parameters ---------- nvecs : array_like Array of integer vectors. an...
[ "Returns", "a", "list", "of", "the", "index", "of", "elements", "of", "n", "which", "do", "not", "have", "adequate", "toy", "angle", "coverage", ".", "The", "criterion", "is", "that", "we", "must", "have", "at", "least", "one", "sample", "in", "each", ...
python
train
jason-weirather/py-seq-tools
seqtools/format/sam/__init__.py
https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/__init__.py#L176-L184
def query_quality(self): """ Overrides align .. warning:: this returns the full query quality, not just the aligned portion """ if not self.entries.qual: return None if self.entries.qual == '*': return None if self.check_flag(0x10): return self.entries.qual[::-1] return self.entries.qual
[ "def", "query_quality", "(", "self", ")", ":", "if", "not", "self", ".", "entries", ".", "qual", ":", "return", "None", "if", "self", ".", "entries", ".", "qual", "==", "'*'", ":", "return", "None", "if", "self", ".", "check_flag", "(", "0x10", ")", ...
Overrides align .. warning:: this returns the full query quality, not just the aligned portion
[ "Overrides", "align" ]
python
train
wanji/bitmap
src/bitmap.py
https://github.com/wanji/bitmap/blob/beb750530045e4f7cf665675bfb28f82d6325007/src/bitmap.py#L140-L145
def fromhexstring(cls, hexstring): """ Construct BitMap from hex string """ bitstring = format(int(hexstring, 16), "0" + str(len(hexstring)/4) + "b") return cls.fromstring(bitstring)
[ "def", "fromhexstring", "(", "cls", ",", "hexstring", ")", ":", "bitstring", "=", "format", "(", "int", "(", "hexstring", ",", "16", ")", ",", "\"0\"", "+", "str", "(", "len", "(", "hexstring", ")", "/", "4", ")", "+", "\"b\"", ")", "return", "cls"...
Construct BitMap from hex string
[ "Construct", "BitMap", "from", "hex", "string" ]
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_common_def.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_common_def.py#L407-L425
def ip_hide_community_list_holder_community_list_extended_ip_action(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") ip = ET.SubElement(config, "ip", xmlns="urn:brocade.com:mgmt:brocade-common-def") hide_community_list_holder = ET.SubElement(ip, "hide-com...
[ "def", "ip_hide_community_list_holder_community_list_extended_ip_action", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "ip", "=", "ET", ".", "SubElement", "(", "config", ",", "\"ip\"", ",", "xmlns...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
nion-software/nionswift-io
nionswift_plugin/TIFF_IO/tifffile.py
https://github.com/nion-software/nionswift-io/blob/e9ae37f01faa9332c48b647f93afd5ef2166b155/nionswift_plugin/TIFF_IO/tifffile.py#L8384-L8391
def read_lsm_timestamps(fh): """Read LSM time stamps from file and return as list.""" size, count = struct.unpack('<ii', fh.read(8)) if size != (8 + 8 * count): log.warning('read_lsm_timestamps: invalid LSM TimeStamps block') return [] # return struct.unpack('<%dd' % count, fh.read(8*cou...
[ "def", "read_lsm_timestamps", "(", "fh", ")", ":", "size", ",", "count", "=", "struct", ".", "unpack", "(", "'<ii'", ",", "fh", ".", "read", "(", "8", ")", ")", "if", "size", "!=", "(", "8", "+", "8", "*", "count", ")", ":", "log", ".", "warnin...
Read LSM time stamps from file and return as list.
[ "Read", "LSM", "time", "stamps", "from", "file", "and", "return", "as", "list", "." ]
python
train
dlecocq/nsq-py
nsq/client.py
https://github.com/dlecocq/nsq-py/blob/3ecacf6ab7719d38031179277113d875554a0c16/nsq/client.py#L128-L139
def connection_checker(self): '''Run periodic reconnection checks''' thread = ConnectionChecker(self) logger.info('Starting connection-checker thread') thread.start() try: yield thread finally: logger.info('Stopping connection-checker') ...
[ "def", "connection_checker", "(", "self", ")", ":", "thread", "=", "ConnectionChecker", "(", "self", ")", "logger", ".", "info", "(", "'Starting connection-checker thread'", ")", "thread", ".", "start", "(", ")", "try", ":", "yield", "thread", "finally", ":", ...
Run periodic reconnection checks
[ "Run", "periodic", "reconnection", "checks" ]
python
train
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/module.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/module.py#L220-L237
def set_process(self, process = None): """ Manually set the parent process. Use with care! @type process: L{Process} @param process: (Optional) Process object. Use C{None} for no process. """ if process is None: self.__process = None else: ...
[ "def", "set_process", "(", "self", ",", "process", "=", "None", ")", ":", "if", "process", "is", "None", ":", "self", ".", "__process", "=", "None", "else", ":", "global", "Process", "# delayed import", "if", "Process", "is", "None", ":", "from", "winapp...
Manually set the parent process. Use with care! @type process: L{Process} @param process: (Optional) Process object. Use C{None} for no process.
[ "Manually", "set", "the", "parent", "process", ".", "Use", "with", "care!" ]
python
train
googleapis/google-cloud-python
spanner/google/cloud/spanner_v1/transaction.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/spanner/google/cloud/spanner_v1/transaction.py#L208-L258
def batch_update(self, statements): """Perform a batch of DML statements via an ``ExecuteBatchDml`` request. :type statements: Sequence[Union[ str, Tuple[str, Dict[str, Any], Dict[str, Union[dict, .types.Type]]]]] :param statements: List of DML statements, with optional...
[ "def", "batch_update", "(", "self", ",", "statements", ")", ":", "parsed", "=", "[", "]", "for", "statement", "in", "statements", ":", "if", "isinstance", "(", "statement", ",", "str", ")", ":", "parsed", ".", "append", "(", "{", "\"sql\"", ":", "state...
Perform a batch of DML statements via an ``ExecuteBatchDml`` request. :type statements: Sequence[Union[ str, Tuple[str, Dict[str, Any], Dict[str, Union[dict, .types.Type]]]]] :param statements: List of DML statements, with optional params / param types. If passed, '...
[ "Perform", "a", "batch", "of", "DML", "statements", "via", "an", "ExecuteBatchDml", "request", "." ]
python
train
carta/ldap_tools
src/ldap_tools/user.py
https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/user.py#L184-L192
def create(config, name, group, type): """Create an LDAP user.""" if type not in ('user', 'service'): raise click.BadOptionUsage("--type must be 'user' or 'service'") client = Client() client.prepare_connection() user_api = API(client) group_api = GroupApi(cli...
[ "def", "create", "(", "config", ",", "name", ",", "group", ",", "type", ")", ":", "if", "type", "not", "in", "(", "'user'", ",", "'service'", ")", ":", "raise", "click", ".", "BadOptionUsage", "(", "\"--type must be 'user' or 'service'\"", ")", "client", "...
Create an LDAP user.
[ "Create", "an", "LDAP", "user", "." ]
python
train