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
oblalex/verboselib
verboselib/management/utils.py
https://github.com/oblalex/verboselib/blob/3c108bef060b091e1f7c08861ab07672c87ddcff/verboselib/management/utils.py#L10-L39
def find_command(cmd, path=None, pathext=None): """ Taken `from Django http://bit.ly/1njB3Y9>`_. """ if path is None: path = os.environ.get('PATH', '').split(os.pathsep) if isinstance(path, string_types): path = [path] # check if there are path extensions for Windows executables...
[ "def", "find_command", "(", "cmd", ",", "path", "=", "None", ",", "pathext", "=", "None", ")", ":", "if", "path", "is", "None", ":", "path", "=", "os", ".", "environ", ".", "get", "(", "'PATH'", ",", "''", ")", ".", "split", "(", "os", ".", "pa...
Taken `from Django http://bit.ly/1njB3Y9>`_.
[ "Taken", "from", "Django", "http", ":", "//", "bit", ".", "ly", "/", "1njB3Y9", ">", "_", "." ]
python
train
DataDog/integrations-core
varnish/datadog_checks/varnish/varnish.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/varnish/datadog_checks/varnish/varnish.py#L256-L333
def _parse_varnishadm(self, output, tags): """ Parse out service checks from varnishadm. Example output: Backend b0 is Sick Current states good: 2 threshold: 3 window: 5 Average responsetime of good probes: 0.000000 Oldest ...
[ "def", "_parse_varnishadm", "(", "self", ",", "output", ",", "tags", ")", ":", "# Process status by backend.", "backends_by_status", "=", "defaultdict", "(", "list", ")", "for", "line", "in", "output", ".", "split", "(", "\"\\n\"", ")", ":", "backend", ",", ...
Parse out service checks from varnishadm. Example output: Backend b0 is Sick Current states good: 2 threshold: 3 window: 5 Average responsetime of good probes: 0.000000 Oldest Newest ============...
[ "Parse", "out", "service", "checks", "from", "varnishadm", "." ]
python
train
05bit/peewee-async
peewee_async.py
https://github.com/05bit/peewee-async/blob/d15f4629da1d9975da4ec37306188e68d288c862/peewee_async.py#L1168-L1175
async def connect(self): """Create connection pool asynchronously. """ self.pool = await aiomysql.create_pool( loop=self.loop, db=self.database, connect_timeout=self.timeout, **self.connect_params)
[ "async", "def", "connect", "(", "self", ")", ":", "self", ".", "pool", "=", "await", "aiomysql", ".", "create_pool", "(", "loop", "=", "self", ".", "loop", ",", "db", "=", "self", ".", "database", ",", "connect_timeout", "=", "self", ".", "timeout", ...
Create connection pool asynchronously.
[ "Create", "connection", "pool", "asynchronously", "." ]
python
train
KieranWynn/pyquaternion
pyquaternion/quaternion.py
https://github.com/KieranWynn/pyquaternion/blob/d2aad7f3fb0d4b9cc23aa72b390e9b2e1273eae9/pyquaternion/quaternion.py#L237-L257
def _from_axis_angle(cls, axis, angle): """Initialise from axis and angle representation Create a Quaternion by specifying the 3-vector rotation axis and rotation angle (in radians) from which the quaternion's rotation should be created. Params: axis: a valid numpy 3-vector...
[ "def", "_from_axis_angle", "(", "cls", ",", "axis", ",", "angle", ")", ":", "mag_sq", "=", "np", ".", "dot", "(", "axis", ",", "axis", ")", "if", "mag_sq", "==", "0.0", ":", "raise", "ZeroDivisionError", "(", "\"Provided rotation axis has no length\"", ")", ...
Initialise from axis and angle representation Create a Quaternion by specifying the 3-vector rotation axis and rotation angle (in radians) from which the quaternion's rotation should be created. Params: axis: a valid numpy 3-vector angle: a real valued angle in radians
[ "Initialise", "from", "axis", "and", "angle", "representation" ]
python
train
Nic30/hwt
hwt/serializer/verilog/serializer.py
https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/serializer/verilog/serializer.py#L55-L95
def hardcodeRomIntoProcess(cls, rom): """ Due to verilog restrictions it is not posible to use array constants and rom memories has to be hardcoded as process """ processes = [] signals = [] for e in rom.endpoints: assert isinstance(e, Operator) and e....
[ "def", "hardcodeRomIntoProcess", "(", "cls", ",", "rom", ")", ":", "processes", "=", "[", "]", "signals", "=", "[", "]", "for", "e", "in", "rom", ".", "endpoints", ":", "assert", "isinstance", "(", "e", ",", "Operator", ")", "and", "e", ".", "operato...
Due to verilog restrictions it is not posible to use array constants and rom memories has to be hardcoded as process
[ "Due", "to", "verilog", "restrictions", "it", "is", "not", "posible", "to", "use", "array", "constants", "and", "rom", "memories", "has", "to", "be", "hardcoded", "as", "process" ]
python
test
openpermissions/perch
perch/organisation.py
https://github.com/openpermissions/perch/blob/36d78994133918f3c52c187f19e50132960a0156/perch/organisation.py#L176-L195
def all(cls, state=None, include_deactivated=False): """ Get all organisations :param state: State of organisation :param include_deactivated: Flag to include deactivated :returns: list of Organisation instances :raises: SocketError, CouchException """ if...
[ "def", "all", "(", "cls", ",", "state", "=", "None", ",", "include_deactivated", "=", "False", ")", ":", "if", "state", "and", "state", "not", "in", "validators", ".", "VALID_STATES", ":", "raise", "exceptions", ".", "ValidationError", "(", "'Invalid \"state...
Get all organisations :param state: State of organisation :param include_deactivated: Flag to include deactivated :returns: list of Organisation instances :raises: SocketError, CouchException
[ "Get", "all", "organisations" ]
python
train
assemblerflow/flowcraft
flowcraft/generator/inspect.py
https://github.com/assemblerflow/flowcraft/blob/fc3f4bddded1efc76006600016dc71a06dd908c0/flowcraft/generator/inspect.py#L937-L1018
def log_parser(self): """Method that parses the nextflow log file once and updates the submitted number of samples for each process """ # Check the timestamp of the log file. Only proceed with the parsing # if it changed from the previous time. size_stamp = os.path.getsi...
[ "def", "log_parser", "(", "self", ")", ":", "# Check the timestamp of the log file. Only proceed with the parsing", "# if it changed from the previous time.", "size_stamp", "=", "os", ".", "path", ".", "getsize", "(", "self", ".", "log_file", ")", "self", ".", "log_retry"...
Method that parses the nextflow log file once and updates the submitted number of samples for each process
[ "Method", "that", "parses", "the", "nextflow", "log", "file", "once", "and", "updates", "the", "submitted", "number", "of", "samples", "for", "each", "process" ]
python
test
openstack/networking-cisco
networking_cisco/plugins/cisco/db/device_manager/hosting_device_manager_db.py
https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/plugins/cisco/db/device_manager/hosting_device_manager_db.py#L502-L507
def delete_all_hosting_devices(self, context, force_delete=False): """Deletes all hosting devices.""" for item in self._get_collection_query( context, hd_models.HostingDeviceTemplate): self.delete_all_hosting_devices_by_template( context, template=item, force_...
[ "def", "delete_all_hosting_devices", "(", "self", ",", "context", ",", "force_delete", "=", "False", ")", ":", "for", "item", "in", "self", ".", "_get_collection_query", "(", "context", ",", "hd_models", ".", "HostingDeviceTemplate", ")", ":", "self", ".", "de...
Deletes all hosting devices.
[ "Deletes", "all", "hosting", "devices", "." ]
python
train
chaoss/grimoirelab-perceval
perceval/backends/core/bugzillarest.py
https://github.com/chaoss/grimoirelab-perceval/blob/41c908605e88b7ebc3a536c643fa0f212eaf9e0e/perceval/backends/core/bugzillarest.py#L429-L448
def sanitize_for_archive(url, headers, payload): """Sanitize payload of a HTTP request by removing the login, password and token information before storing/retrieving archived items :param: url: HTTP url request :param: headers: HTTP headers request :param: payload: HTTP payload...
[ "def", "sanitize_for_archive", "(", "url", ",", "headers", ",", "payload", ")", ":", "if", "BugzillaRESTClient", ".", "PBUGZILLA_LOGIN", "in", "payload", ":", "payload", ".", "pop", "(", "BugzillaRESTClient", ".", "PBUGZILLA_LOGIN", ")", "if", "BugzillaRESTClient"...
Sanitize payload of a HTTP request by removing the login, password and token information before storing/retrieving archived items :param: url: HTTP url request :param: headers: HTTP headers request :param: payload: HTTP payload request :returns url, headers and the sanitized pa...
[ "Sanitize", "payload", "of", "a", "HTTP", "request", "by", "removing", "the", "login", "password", "and", "token", "information", "before", "storing", "/", "retrieving", "archived", "items" ]
python
test
LionelAuroux/pyrser
pyrser/parsing/node.py
https://github.com/LionelAuroux/pyrser/blob/f153a97ef2b6bf915a1ed468c0252a9a59b754d5/pyrser/parsing/node.py#L81-L89
def set(self, othernode): """allow to completly mutate the node into any subclasses of Node""" self.__class__ = othernode.__class__ self.clean() if len(othernode) > 0: for k, v in othernode.items(): self[k] = v for k, v in vars(othernode).items(): ...
[ "def", "set", "(", "self", ",", "othernode", ")", ":", "self", ".", "__class__", "=", "othernode", ".", "__class__", "self", ".", "clean", "(", ")", "if", "len", "(", "othernode", ")", ">", "0", ":", "for", "k", ",", "v", "in", "othernode", ".", ...
allow to completly mutate the node into any subclasses of Node
[ "allow", "to", "completly", "mutate", "the", "node", "into", "any", "subclasses", "of", "Node" ]
python
test
TestInABox/stackInABox
stackinabox/services/service.py
https://github.com/TestInABox/stackInABox/blob/63ee457401e9a88d987f85f513eb512dcb12d984/stackinabox/services/service.py#L316-L322
def reset(self): """Reset the service to its' initial state.""" logger.debug('StackInABoxService ({0}): Reset' .format(self.__id, self.name)) self.base_url = '/{0}'.format(self.name) logger.debug('StackInABoxService ({0}): Hosting Service {1}' .f...
[ "def", "reset", "(", "self", ")", ":", "logger", ".", "debug", "(", "'StackInABoxService ({0}): Reset'", ".", "format", "(", "self", ".", "__id", ",", "self", ".", "name", ")", ")", "self", ".", "base_url", "=", "'/{0}'", ".", "format", "(", "self", "....
Reset the service to its' initial state.
[ "Reset", "the", "service", "to", "its", "initial", "state", "." ]
python
train
jvamvas/rhymediscovery
rhymediscovery/evaluate_schemes.py
https://github.com/jvamvas/rhymediscovery/blob/b76509c98554b12efa06fe9ab557cca5fa5e4a79/rhymediscovery/evaluate_schemes.py#L107-L155
def compare(stanzas, gold_schemes, found_schemes): """get accuracy and precision/recall""" result = SuccessMeasure() total = float(len(gold_schemes)) correct = 0.0 for (g, f) in zip(gold_schemes, found_schemes): if g == f: correct += 1 result.accuracy = correct / total #...
[ "def", "compare", "(", "stanzas", ",", "gold_schemes", ",", "found_schemes", ")", ":", "result", "=", "SuccessMeasure", "(", ")", "total", "=", "float", "(", "len", "(", "gold_schemes", ")", ")", "correct", "=", "0.0", "for", "(", "g", ",", "f", ")", ...
get accuracy and precision/recall
[ "get", "accuracy", "and", "precision", "/", "recall" ]
python
train
osilkin98/PyBRY
generator.py
https://github.com/osilkin98/PyBRY/blob/af86805a8077916f72f3fe980943d4cd741e61f0/generator.py#L167-L205
def generate_lbryd_wrapper(url=LBRY_API_RAW_JSON_URL, read_file=__LBRYD_BASE_FPATH__, write_file=LBRYD_FPATH): """ Generates the actual functions for lbryd_api.py based on lbry's documentation :param str url: URL to the documentation we need to obtain, pybry.constants.LBRY_API_RAW_JSON_URL by default ...
[ "def", "generate_lbryd_wrapper", "(", "url", "=", "LBRY_API_RAW_JSON_URL", ",", "read_file", "=", "__LBRYD_BASE_FPATH__", ",", "write_file", "=", "LBRYD_FPATH", ")", ":", "functions", "=", "get_lbry_api_function_docs", "(", "url", ")", "# Open the actual file for appendin...
Generates the actual functions for lbryd_api.py based on lbry's documentation :param str url: URL to the documentation we need to obtain, pybry.constants.LBRY_API_RAW_JSON_URL by default :param str read_file: This is the path to the file from which we will be reading :param str write_file: Path from p...
[ "Generates", "the", "actual", "functions", "for", "lbryd_api", ".", "py", "based", "on", "lbry", "s", "documentation" ]
python
train
tensorflow/tensor2tensor
tensor2tensor/data_generators/generator_utils.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/data_generators/generator_utils.py#L906-L943
def tfrecord_iterator(filenames, gzipped=False, example_spec=None): """Yields records from TFRecord files. Args: filenames: list<str>, list of TFRecord filenames to read from. gzipped: bool, whether the TFRecord files are gzip-encoded. example_spec: dict<str feature name, tf.VarLenFeature/tf.FixedLenFe...
[ "def", "tfrecord_iterator", "(", "filenames", ",", "gzipped", "=", "False", ",", "example_spec", "=", "None", ")", ":", "with", "tf", ".", "Graph", "(", ")", ".", "as_default", "(", ")", ":", "dataset", "=", "tf", ".", "data", ".", "Dataset", ".", "f...
Yields records from TFRecord files. Args: filenames: list<str>, list of TFRecord filenames to read from. gzipped: bool, whether the TFRecord files are gzip-encoded. example_spec: dict<str feature name, tf.VarLenFeature/tf.FixedLenFeature>, if provided, will parse each record as a tensorflow.Example...
[ "Yields", "records", "from", "TFRecord", "files", "." ]
python
train
etingof/pysmi
pysmi/lexer/smi.py
https://github.com/etingof/pysmi/blob/379a0a384c81875731be51a054bdacced6260fd8/pysmi/lexer/smi.py#L256-L259
def t_QUOTED_STRING(self, t): r'\"[^\"]*\"' t.lexer.lineno += len(re.findall(r'\r\n|\n|\r', t.value)) return t
[ "def", "t_QUOTED_STRING", "(", "self", ",", "t", ")", ":", "t", ".", "lexer", ".", "lineno", "+=", "len", "(", "re", ".", "findall", "(", "r'\\r\\n|\\n|\\r'", ",", "t", ".", "value", ")", ")", "return", "t" ]
r'\"[^\"]*\"
[ "r", "\\", "[", "^", "\\", "]", "*", "\\" ]
python
valid
bryanwweber/thermohw
thermohw/filters.py
https://github.com/bryanwweber/thermohw/blob/b6be276c14f8adf6ae23f5498065de74f868ccaa/thermohw/filters.py#L25-L54
def div_filter(key: str, value: list, format: str, meta: Any) -> Optional[list]: """Filter the JSON ``value`` for alert divs. Arguments --------- key Key of the structure value Values in the structure format Output format of the processing meta Meta informati...
[ "def", "div_filter", "(", "key", ":", "str", ",", "value", ":", "list", ",", "format", ":", "str", ",", "meta", ":", "Any", ")", "->", "Optional", "[", "list", "]", ":", "if", "key", "!=", "\"Div\"", "or", "format", "!=", "\"latex\"", ":", "return"...
Filter the JSON ``value`` for alert divs. Arguments --------- key Key of the structure value Values in the structure format Output format of the processing meta Meta information
[ "Filter", "the", "JSON", "value", "for", "alert", "divs", "." ]
python
train
Yubico/yubikey-manager
ykman/cli/piv.py
https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/piv.py#L677-L711
def change_puk(ctx, puk, new_puk): """ Change the PUK code. If the PIN is lost or blocked it can be reset using a PUK. The PUK must be between 6 and 8 characters long, and supports any type of alphanumeric characters. """ controller = ctx.obj['controller'] if not puk: puk = _pro...
[ "def", "change_puk", "(", "ctx", ",", "puk", ",", "new_puk", ")", ":", "controller", "=", "ctx", ".", "obj", "[", "'controller'", "]", "if", "not", "puk", ":", "puk", "=", "_prompt_pin", "(", "ctx", ",", "prompt", "=", "'Enter your current PUK'", ")", ...
Change the PUK code. If the PIN is lost or blocked it can be reset using a PUK. The PUK must be between 6 and 8 characters long, and supports any type of alphanumeric characters.
[ "Change", "the", "PUK", "code", "." ]
python
train
bitesofcode/projexui
projexui/widgets/xquerybuilderwidget/xquerylinewidget.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xquerybuilderwidget/xquerylinewidget.py#L263-L276
def setTerms( self, terms ): """ Sets the term options for this widget. :param terms | [<str>, ..] """ self.uiTermDDL.blockSignals(True) term = self.uiTermDDL.currentText() self.uiTermDDL.clear() self.uiTermDDL.addItems(terms) ...
[ "def", "setTerms", "(", "self", ",", "terms", ")", ":", "self", ".", "uiTermDDL", ".", "blockSignals", "(", "True", ")", "term", "=", "self", ".", "uiTermDDL", ".", "currentText", "(", ")", "self", ".", "uiTermDDL", ".", "clear", "(", ")", "self", "....
Sets the term options for this widget. :param terms | [<str>, ..]
[ "Sets", "the", "term", "options", "for", "this", "widget", ".", ":", "param", "terms", "|", "[", "<str", ">", "..", "]" ]
python
train
lepture/flask-oauthlib
flask_oauthlib/provider/oauth1.py
https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L673-L683
def get_default_realms(self, client_key, request): """Default realms of the client.""" log.debug('Get realms for %r', client_key) if not request.client: request.client = self._clientgetter(client_key=client_key) client = request.client if hasattr(client, 'default_re...
[ "def", "get_default_realms", "(", "self", ",", "client_key", ",", "request", ")", ":", "log", ".", "debug", "(", "'Get realms for %r'", ",", "client_key", ")", "if", "not", "request", ".", "client", ":", "request", ".", "client", "=", "self", ".", "_client...
Default realms of the client.
[ "Default", "realms", "of", "the", "client", "." ]
python
test
Unidata/siphon
siphon/cdmr/ncstream.py
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/cdmr/ncstream.py#L201-L221
def process_vlen(data_header, array): """Process vlen coming back from NCStream v2. This takes the array of values and slices into an object array, with entries containing the appropriate pieces of the original array. Sizes are controlled by the passed in `data_header`. Parameters ---------- ...
[ "def", "process_vlen", "(", "data_header", ",", "array", ")", ":", "source", "=", "iter", "(", "array", ")", "return", "np", ".", "array", "(", "[", "np", ".", "fromiter", "(", "itertools", ".", "islice", "(", "source", ",", "size", ")", ",", "dtype"...
Process vlen coming back from NCStream v2. This takes the array of values and slices into an object array, with entries containing the appropriate pieces of the original array. Sizes are controlled by the passed in `data_header`. Parameters ---------- data_header : Header array : :class:`n...
[ "Process", "vlen", "coming", "back", "from", "NCStream", "v2", "." ]
python
train
StackStorm/pybind
pybind/nos/v6_0_2f/rbridge_id/global_lc_holder/linecard/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/rbridge_id/global_lc_holder/linecard/__init__.py#L92-L113
def _set_linecards(self, v, load=False): """ Setter method for linecards, mapped from YANG variable /rbridge_id/global_lc_holder/linecard/linecards (list) If this variable is read-only (config: false) in the source YANG file, then _set_linecards is considered as a private method. Backends looking to...
[ "def", "_set_linecards", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "base...
Setter method for linecards, mapped from YANG variable /rbridge_id/global_lc_holder/linecard/linecards (list) If this variable is read-only (config: false) in the source YANG file, then _set_linecards is considered as a private method. Backends looking to populate this variable should do so via calling ...
[ "Setter", "method", "for", "linecards", "mapped", "from", "YANG", "variable", "/", "rbridge_id", "/", "global_lc_holder", "/", "linecard", "/", "linecards", "(", "list", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ...
python
train
diging/tethne
tethne/model/corpus/mallet.py
https://github.com/diging/tethne/blob/ba10eeb264b7a3f2dbcce71cfd5cb2d6bbf7055f/tethne/model/corpus/mallet.py#L151-L161
def _generate_corpus(self): """ Writes a corpus to disk amenable to MALLET topic modeling. """ target = self.temp + 'mallet' paths = write_documents(self.corpus, target, self.featureset_name, ['date', 'title']) self.corpus_path, self.metap...
[ "def", "_generate_corpus", "(", "self", ")", ":", "target", "=", "self", ".", "temp", "+", "'mallet'", "paths", "=", "write_documents", "(", "self", ".", "corpus", ",", "target", ",", "self", ".", "featureset_name", ",", "[", "'date'", ",", "'title'", "]...
Writes a corpus to disk amenable to MALLET topic modeling.
[ "Writes", "a", "corpus", "to", "disk", "amenable", "to", "MALLET", "topic", "modeling", "." ]
python
train
pvlib/pvlib-python
pvlib/location.py
https://github.com/pvlib/pvlib-python/blob/2e844a595b820b43d1170269781fa66bd0ccc8a3/pvlib/location.py#L282-L319
def get_sun_rise_set_transit(self, times, method='pyephem', **kwargs): """ Calculate sunrise, sunset and transit times. Parameters ---------- times : DatetimeIndex Must be localized to the Location method : str, default 'pyephem' 'pyephem', 'spa',...
[ "def", "get_sun_rise_set_transit", "(", "self", ",", "times", ",", "method", "=", "'pyephem'", ",", "*", "*", "kwargs", ")", ":", "if", "method", "==", "'pyephem'", ":", "result", "=", "solarposition", ".", "sun_rise_set_transit_ephem", "(", "times", ",", "s...
Calculate sunrise, sunset and transit times. Parameters ---------- times : DatetimeIndex Must be localized to the Location method : str, default 'pyephem' 'pyephem', 'spa', or 'geometric' kwargs are passed to the relevant functions. See solarposi...
[ "Calculate", "sunrise", "sunset", "and", "transit", "times", "." ]
python
train
berkeley-cocosci/Wallace
examples/rogers/experiment.py
https://github.com/berkeley-cocosci/Wallace/blob/3650c0bc3b0804d0adb1d178c5eba9992babb1b0/examples/rogers/experiment.py#L40-L61
def setup(self): """First time setup.""" super(RogersExperiment, self).setup() for net in random.sample(self.networks(role="experiment"), self.catch_repeats): net.role = "catch" for net in self.networks(): source = RogersSource(n...
[ "def", "setup", "(", "self", ")", ":", "super", "(", "RogersExperiment", ",", "self", ")", ".", "setup", "(", ")", "for", "net", "in", "random", ".", "sample", "(", "self", ".", "networks", "(", "role", "=", "\"experiment\"", ")", ",", "self", ".", ...
First time setup.
[ "First", "time", "setup", "." ]
python
train
Microsoft/nni
tools/nni_cmd/nnictl.py
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/tools/nni_cmd/nnictl.py#L46-L198
def parse_args(): '''Definite the arguments users need to follow and input''' parser = argparse.ArgumentParser(prog='nnictl', description='use nnictl command to control nni experiments') parser.add_argument('--version', '-v', action='store_true') parser.set_defaults(func=nni_info) # create subparse...
[ "def", "parse_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "prog", "=", "'nnictl'", ",", "description", "=", "'use nnictl command to control nni experiments'", ")", "parser", ".", "add_argument", "(", "'--version'", ",", "'-v'", ","...
Definite the arguments users need to follow and input
[ "Definite", "the", "arguments", "users", "need", "to", "follow", "and", "input" ]
python
train
johnnoone/aioconsul
aioconsul/common/util.py
https://github.com/johnnoone/aioconsul/blob/02f7a529d7dc2e49bed942111067aa5faf320e90/aioconsul/common/util.py#L39-L48
def duration_to_timedelta(obj): """Converts duration to timedelta >>> duration_to_timedelta("10m") >>> datetime.timedelta(0, 600) """ matches = DURATION_PATTERN.search(obj) matches = matches.groupdict(default="0") matches = {k: int(v) for k, v in matches.items()} return timedelta(**matc...
[ "def", "duration_to_timedelta", "(", "obj", ")", ":", "matches", "=", "DURATION_PATTERN", ".", "search", "(", "obj", ")", "matches", "=", "matches", ".", "groupdict", "(", "default", "=", "\"0\"", ")", "matches", "=", "{", "k", ":", "int", "(", "v", ")...
Converts duration to timedelta >>> duration_to_timedelta("10m") >>> datetime.timedelta(0, 600)
[ "Converts", "duration", "to", "timedelta" ]
python
train
iwanbk/nyamuk
nyamuk/base_nyamuk.py
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/base_nyamuk.py#L232-L236
def socket_close(self): """Close our socket.""" if self.sock != NC.INVALID_SOCKET: self.sock.close() self.sock = NC.INVALID_SOCKET
[ "def", "socket_close", "(", "self", ")", ":", "if", "self", ".", "sock", "!=", "NC", ".", "INVALID_SOCKET", ":", "self", ".", "sock", ".", "close", "(", ")", "self", ".", "sock", "=", "NC", ".", "INVALID_SOCKET" ]
Close our socket.
[ "Close", "our", "socket", "." ]
python
train
tensorflow/tensor2tensor
tensor2tensor/models/mtf_image_transformer.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/models/mtf_image_transformer.py#L514-L520
def mtf_image_transformer_cifar_4x(): """Data parallel CIFAR parameters.""" hparams = mtf_image_transformer_base_cifar() hparams.mesh_shape = "batch:32" hparams.layout = "batch:batch" hparams.batch_size = 128 return hparams
[ "def", "mtf_image_transformer_cifar_4x", "(", ")", ":", "hparams", "=", "mtf_image_transformer_base_cifar", "(", ")", "hparams", ".", "mesh_shape", "=", "\"batch:32\"", "hparams", ".", "layout", "=", "\"batch:batch\"", "hparams", ".", "batch_size", "=", "128", "retu...
Data parallel CIFAR parameters.
[ "Data", "parallel", "CIFAR", "parameters", "." ]
python
train
theolind/pymysensors
mysensors/__init__.py
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L433-L437
def handle_line(self, line): """Handle incoming string data one line at a time.""" if not self.gateway.can_log: _LOGGER.debug('Receiving %s', line) self.gateway.add_job(self.gateway.logic, line)
[ "def", "handle_line", "(", "self", ",", "line", ")", ":", "if", "not", "self", ".", "gateway", ".", "can_log", ":", "_LOGGER", ".", "debug", "(", "'Receiving %s'", ",", "line", ")", "self", ".", "gateway", ".", "add_job", "(", "self", ".", "gateway", ...
Handle incoming string data one line at a time.
[ "Handle", "incoming", "string", "data", "one", "line", "at", "a", "time", "." ]
python
train
common-workflow-language/cwltool
cwltool/provenance.py
https://github.com/common-workflow-language/cwltool/blob/cb81b22abc52838823da9945f04d06739ab32fda/cwltool/provenance.py#L568-L660
def declare_directory(self, value): # type: (MutableMapping) -> ProvEntity """Register any nested files/directories.""" # FIXME: Calculate a hash-like identifier for directory # so we get same value if it's the same filenames/hashes # in a different location. # For now, mint a n...
[ "def", "declare_directory", "(", "self", ",", "value", ")", ":", "# type: (MutableMapping) -> ProvEntity", "# FIXME: Calculate a hash-like identifier for directory", "# so we get same value if it's the same filenames/hashes", "# in a different location.", "# For now, mint a new UUID to ident...
Register any nested files/directories.
[ "Register", "any", "nested", "files", "/", "directories", "." ]
python
train
redhat-openstack/python-tripleo-helper
tripleohelper/ssh.py
https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ssh.py#L163-L221
def run(self, cmd, sudo=False, ignore_error=False, success_status=(0,), error_callback=None, custom_log=None, retry=0): """Run a command on the remote host. The command is run on the remote host, if there is a redirected host then the command will be run on that redirected host. See...
[ "def", "run", "(", "self", ",", "cmd", ",", "sudo", "=", "False", ",", "ignore_error", "=", "False", ",", "success_status", "=", "(", "0", ",", ")", ",", "error_callback", "=", "None", ",", "custom_log", "=", "None", ",", "retry", "=", "0", ")", ":...
Run a command on the remote host. The command is run on the remote host, if there is a redirected host then the command will be run on that redirected host. See __init__. :param cmd: the command to run :type cmd: str :param sudo: True if the command should be run with sudo, thi...
[ "Run", "a", "command", "on", "the", "remote", "host", "." ]
python
train
mbj4668/pyang
pyang/statements.py
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/statements.py#L537-L556
def v_grammar_unique_defs(ctx, stmt): """Verify that all typedefs and groupings are unique Called for every statement. Stores all typedefs in stmt.i_typedef, groupings in stmt.i_grouping """ defs = [('typedef', 'TYPE_ALREADY_DEFINED', stmt.i_typedefs), ('grouping', 'GROUPING_ALREADY_DEFI...
[ "def", "v_grammar_unique_defs", "(", "ctx", ",", "stmt", ")", ":", "defs", "=", "[", "(", "'typedef'", ",", "'TYPE_ALREADY_DEFINED'", ",", "stmt", ".", "i_typedefs", ")", ",", "(", "'grouping'", ",", "'GROUPING_ALREADY_DEFINED'", ",", "stmt", ".", "i_groupings...
Verify that all typedefs and groupings are unique Called for every statement. Stores all typedefs in stmt.i_typedef, groupings in stmt.i_grouping
[ "Verify", "that", "all", "typedefs", "and", "groupings", "are", "unique", "Called", "for", "every", "statement", ".", "Stores", "all", "typedefs", "in", "stmt", ".", "i_typedef", "groupings", "in", "stmt", ".", "i_grouping" ]
python
train
ClericPy/torequests
torequests/utils.py
https://github.com/ClericPy/torequests/blob/1793261688d7a47e1c3a0830d83f8552f5e3e5d9/torequests/utils.py#L261-L268
def slice_by_size(seq, size): """Slice a sequence into chunks, return as a generation of chunks with `size`.""" filling = null for it in zip(*(itertools_chain(seq, [filling] * size),) * size): if filling in it: it = tuple(i for i in it if i is not filling) if it: yiel...
[ "def", "slice_by_size", "(", "seq", ",", "size", ")", ":", "filling", "=", "null", "for", "it", "in", "zip", "(", "*", "(", "itertools_chain", "(", "seq", ",", "[", "filling", "]", "*", "size", ")", ",", ")", "*", "size", ")", ":", "if", "filling...
Slice a sequence into chunks, return as a generation of chunks with `size`.
[ "Slice", "a", "sequence", "into", "chunks", "return", "as", "a", "generation", "of", "chunks", "with", "size", "." ]
python
train
blockcypher/blockcypher-python
blockcypher/api.py
https://github.com/blockcypher/blockcypher-python/blob/7601ea21916957ff279384fd699527ff9c28a56e/blockcypher/api.py#L1174-L1192
def get_wallet_balance(wallet_name, api_key, omit_addresses=False, coin_symbol='btc'): ''' This is particularly useful over get_wallet_transactions and get_wallet_addresses in cases where you have lots of addresses/transactions. Much less data to return. ''' assert is_valid_coin_symbol(coin_symb...
[ "def", "get_wallet_balance", "(", "wallet_name", ",", "api_key", ",", "omit_addresses", "=", "False", ",", "coin_symbol", "=", "'btc'", ")", ":", "assert", "is_valid_coin_symbol", "(", "coin_symbol", ")", "assert", "api_key", "assert", "len", "(", "wallet_name", ...
This is particularly useful over get_wallet_transactions and get_wallet_addresses in cases where you have lots of addresses/transactions. Much less data to return.
[ "This", "is", "particularly", "useful", "over", "get_wallet_transactions", "and", "get_wallet_addresses", "in", "cases", "where", "you", "have", "lots", "of", "addresses", "/", "transactions", ".", "Much", "less", "data", "to", "return", "." ]
python
train
johnnoone/json-spec
src/jsonspec/operations/bases.py
https://github.com/johnnoone/json-spec/blob/f91981724cea0c366bd42a6670eb07bbe31c0e0c/src/jsonspec/operations/bases.py#L189-L203
def copy(self, dest, src): """Copy element from sequence, member from mapping. :param dest: the destination :type dest: Pointer :param src: the source :type src: Pointer :return: resolved document :rtype: Target """ doc = fragment = deepcopy(self....
[ "def", "copy", "(", "self", ",", "dest", ",", "src", ")", ":", "doc", "=", "fragment", "=", "deepcopy", "(", "self", ".", "document", ")", "for", "token", "in", "Pointer", "(", "src", ")", ":", "fragment", "=", "token", ".", "extract", "(", "fragme...
Copy element from sequence, member from mapping. :param dest: the destination :type dest: Pointer :param src: the source :type src: Pointer :return: resolved document :rtype: Target
[ "Copy", "element", "from", "sequence", "member", "from", "mapping", "." ]
python
train
UpCloudLtd/upcloud-python-api
upcloud_api/tag.py
https://github.com/UpCloudLtd/upcloud-python-api/blob/954b0ad7c4b932b2be31a95d88975f6b0eeac8ed/upcloud_api/tag.py#L30-L47
def _reset(self, **kwargs): """ Reset the objects attributes. Accepts servers as either unflattened or flattened UUID strings or Server objects. """ super(Tag, self)._reset(**kwargs) # backup name for changing it (look: Tag.save) self._api_name = self.name ...
[ "def", "_reset", "(", "self", ",", "*", "*", "kwargs", ")", ":", "super", "(", "Tag", ",", "self", ")", ".", "_reset", "(", "*", "*", "kwargs", ")", "# backup name for changing it (look: Tag.save)", "self", ".", "_api_name", "=", "self", ".", "name", "# ...
Reset the objects attributes. Accepts servers as either unflattened or flattened UUID strings or Server objects.
[ "Reset", "the", "objects", "attributes", "." ]
python
train
bwohlberg/sporco
sporco/prox/_l1proj.py
https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/prox/_l1proj.py#L110-L154
def _proj_l1_sortsum(v, gamma, axis=None): r"""Projection operator of the :math:`\ell_1` norm. The solution is computed via the method of :cite:`duchi-2008-efficient`. Parameters ---------- v : array_like Input array :math:`\mathbf{v}` gamma : float Parameter :math:`\gamma` axi...
[ "def", "_proj_l1_sortsum", "(", "v", ",", "gamma", ",", "axis", "=", "None", ")", ":", "if", "axis", "is", "None", "and", "norm_l1", "(", "v", ")", "<=", "gamma", ":", "return", "v", "if", "axis", "is", "not", "None", "and", "axis", "<", "0", ":"...
r"""Projection operator of the :math:`\ell_1` norm. The solution is computed via the method of :cite:`duchi-2008-efficient`. Parameters ---------- v : array_like Input array :math:`\mathbf{v}` gamma : float Parameter :math:`\gamma` axis : None or int, optional (default None) ...
[ "r", "Projection", "operator", "of", "the", ":", "math", ":", "\\", "ell_1", "norm", ".", "The", "solution", "is", "computed", "via", "the", "method", "of", ":", "cite", ":", "duchi", "-", "2008", "-", "efficient", "." ]
python
train
cytoscape/py2cytoscape
py2cytoscape/cyrest/view.py
https://github.com/cytoscape/py2cytoscape/blob/dd34de8d028f512314d0057168df7fef7c5d5195/py2cytoscape/cyrest/view.py#L46-L85
def export(self, Height=None, options=None, outputFile=None, Resolution=None,\ Units=None, Width=None, Zoom=None, view="current", verbose=False): """ Exports the current view to a graphics file and returns the path to the saved file. PNG and JPEG formats have options for scaling, whi...
[ "def", "export", "(", "self", ",", "Height", "=", "None", ",", "options", "=", "None", ",", "outputFile", "=", "None", ",", "Resolution", "=", "None", ",", "Units", "=", "None", ",", "Width", "=", "None", ",", "Zoom", "=", "None", ",", "view", "=",...
Exports the current view to a graphics file and returns the path to the saved file. PNG and JPEG formats have options for scaling, while other formats only have the option 'exportTextAsFont'. For the PDF format, exporting text as font does not work for two-byte characters such as ...
[ "Exports", "the", "current", "view", "to", "a", "graphics", "file", "and", "returns", "the", "path", "to", "the", "saved", "file", ".", "PNG", "and", "JPEG", "formats", "have", "options", "for", "scaling", "while", "other", "formats", "only", "have", "the"...
python
train
djm/python-scrapyd-api
scrapyd_api/wrapper.py
https://github.com/djm/python-scrapyd-api/blob/42f287cf83c3a5bd46795f4f85cce02a56829921/scrapyd_api/wrapper.py#L161-L169
def list_versions(self, project): """ Lists all deployed versions of a specific project. First class, maps to Scrapyd's list versions endpoint. """ url = self._build_url(constants.LIST_VERSIONS_ENDPOINT) params = {'project': project} json = self.client.get(url, pa...
[ "def", "list_versions", "(", "self", ",", "project", ")", ":", "url", "=", "self", ".", "_build_url", "(", "constants", ".", "LIST_VERSIONS_ENDPOINT", ")", "params", "=", "{", "'project'", ":", "project", "}", "json", "=", "self", ".", "client", ".", "ge...
Lists all deployed versions of a specific project. First class, maps to Scrapyd's list versions endpoint.
[ "Lists", "all", "deployed", "versions", "of", "a", "specific", "project", ".", "First", "class", "maps", "to", "Scrapyd", "s", "list", "versions", "endpoint", "." ]
python
train
aaugustin/websockets
src/websockets/protocol.py
https://github.com/aaugustin/websockets/blob/17b3f47549b6f752a1be07fa1ba3037cb59c7d56/src/websockets/protocol.py#L1011-L1074
async def close_connection(self) -> None: """ 7.1.1. Close the WebSocket Connection When the opening handshake succeeds, :meth:`connection_open` starts this coroutine in a task. It waits for the data transfer phase to complete then it closes the TCP connection cleanly. ...
[ "async", "def", "close_connection", "(", "self", ")", "->", "None", ":", "try", ":", "# Wait for the data transfer phase to complete.", "if", "hasattr", "(", "self", ",", "\"transfer_data_task\"", ")", ":", "try", ":", "await", "self", ".", "transfer_data_task", "...
7.1.1. Close the WebSocket Connection When the opening handshake succeeds, :meth:`connection_open` starts this coroutine in a task. It waits for the data transfer phase to complete then it closes the TCP connection cleanly. When the opening handshake fails, :meth:`fail_connection` does...
[ "7", ".", "1", ".", "1", ".", "Close", "the", "WebSocket", "Connection" ]
python
train
f3at/feat
src/feat/agencies/common.py
https://github.com/f3at/feat/blob/15da93fc9d6ec8154f52a9172824e25821195ef8/src/feat/agencies/common.py#L294-L317
def call_agent_side(self, method, *args, **kwargs): ''' Call the method, wrap it in Deferred and bind error handler. ''' assert not self._finalize_called, ("Attempt to call agent side code " "after finalize() method has been " ...
[ "def", "call_agent_side", "(", "self", ",", "method", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "assert", "not", "self", ".", "_finalize_called", ",", "(", "\"Attempt to call agent side code \"", "\"after finalize() method has been \"", "\"called. Method: %...
Call the method, wrap it in Deferred and bind error handler.
[ "Call", "the", "method", "wrap", "it", "in", "Deferred", "and", "bind", "error", "handler", "." ]
python
train
luckydonald/pytgbot
pytgbot/api_types/sendable/passport.py
https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/sendable/passport.py#L754-L774
def from_array(array): """ Deserialize a new PassportElementErrorFiles from a given dictionary. :return: new PassportElementErrorFiles instance. :rtype: PassportElementErrorFiles """ if array is None or not array: return None # end if assert_t...
[ "def", "from_array", "(", "array", ")", ":", "if", "array", "is", "None", "or", "not", "array", ":", "return", "None", "# end if", "assert_type_or_raise", "(", "array", ",", "dict", ",", "parameter_name", "=", "\"array\"", ")", "data", "=", "{", "}", "da...
Deserialize a new PassportElementErrorFiles from a given dictionary. :return: new PassportElementErrorFiles instance. :rtype: PassportElementErrorFiles
[ "Deserialize", "a", "new", "PassportElementErrorFiles", "from", "a", "given", "dictionary", "." ]
python
train
open-mmlab/mmcv
mmcv/video/io.py
https://github.com/open-mmlab/mmcv/blob/0d77f61450aab4dde8b8585a577cc496acb95d7f/mmcv/video/io.py#L288-L332
def frames2video(frame_dir, video_file, fps=30, fourcc='XVID', filename_tmpl='{:06d}.jpg', start=0, end=0, show_progress=True): """Read the frame images from a directory and join them as a video ...
[ "def", "frames2video", "(", "frame_dir", ",", "video_file", ",", "fps", "=", "30", ",", "fourcc", "=", "'XVID'", ",", "filename_tmpl", "=", "'{:06d}.jpg'", ",", "start", "=", "0", ",", "end", "=", "0", ",", "show_progress", "=", "True", ")", ":", "if",...
Read the frame images from a directory and join them as a video Args: frame_dir (str): The directory containing video frames. video_file (str): Output filename. fps (float): FPS of the output video. fourcc (str): Fourcc of the output video, this should be compatible with...
[ "Read", "the", "frame", "images", "from", "a", "directory", "and", "join", "them", "as", "a", "video" ]
python
test
jasonbot/arcrest
arcrest/server.py
https://github.com/jasonbot/arcrest/blob/b1ba71fd59bb6349415e7879d753d307dbc0da26/arcrest/server.py#L2052-L2083
def SolveClosestFacility(self, facilities=None, incidents=None, barriers=None, polylineBarriers=None, polygonBarriers=None, attributeParameterValues=None, ...
[ "def", "SolveClosestFacility", "(", "self", ",", "facilities", "=", "None", ",", "incidents", "=", "None", ",", "barriers", "=", "None", ",", "polylineBarriers", "=", "None", ",", "polygonBarriers", "=", "None", ",", "attributeParameterValues", "=", "None", ",...
The solve operation is performed on a network layer resource of type closest facility.
[ "The", "solve", "operation", "is", "performed", "on", "a", "network", "layer", "resource", "of", "type", "closest", "facility", "." ]
python
train
onecodex/onecodex
onecodex/models/collection.py
https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/models/collection.py#L294-L371
def to_otu(self, biom_id=None): """Converts a list of objects associated with a classification result into a `dict` resembling an OTU table. Parameters ---------- biom_id : `string`, optional Optionally specify an `id` field for the generated v1 BIOM file. R...
[ "def", "to_otu", "(", "self", ",", "biom_id", "=", "None", ")", ":", "otu_format", "=", "\"Biological Observation Matrix 1.0.0\"", "# Note: This is exact format URL is required by https://github.com/biocore/biom-format", "otu_url", "=", "\"http://biom-format.org\"", "otu", "=", ...
Converts a list of objects associated with a classification result into a `dict` resembling an OTU table. Parameters ---------- biom_id : `string`, optional Optionally specify an `id` field for the generated v1 BIOM file. Returns ------- otu_table : ...
[ "Converts", "a", "list", "of", "objects", "associated", "with", "a", "classification", "result", "into", "a", "dict", "resembling", "an", "OTU", "table", "." ]
python
train
RedHatInsights/insights-core
insights/client/connection.py
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/connection.py#L171-L245
def get_proxies(self): """ Determine proxy configuration """ # Get proxy from ENV or Config proxies = None proxy_auth = None no_proxy = os.environ.get('NO_PROXY') logger.debug("NO PROXY: %s", no_proxy) # CONF PROXY TAKES PRECEDENCE OVER ENV PROXY ...
[ "def", "get_proxies", "(", "self", ")", ":", "# Get proxy from ENV or Config", "proxies", "=", "None", "proxy_auth", "=", "None", "no_proxy", "=", "os", ".", "environ", ".", "get", "(", "'NO_PROXY'", ")", "logger", ".", "debug", "(", "\"NO PROXY: %s\"", ",", ...
Determine proxy configuration
[ "Determine", "proxy", "configuration" ]
python
train
ellmetha/django-machina
machina/apps/forum_conversation/forms.py
https://github.com/ellmetha/django-machina/blob/89ac083c1eaf1cfdeae6686ee094cc86362e8c69/machina/apps/forum_conversation/forms.py#L79-L87
def clean(self): """ Validates the form. """ if not self.instance.pk: # Only set user on post creation if not self.user.is_anonymous: self.instance.poster = self.user else: self.instance.anonymous_key = get_anonymous_user_forum_key(self...
[ "def", "clean", "(", "self", ")", ":", "if", "not", "self", ".", "instance", ".", "pk", ":", "# Only set user on post creation", "if", "not", "self", ".", "user", ".", "is_anonymous", ":", "self", ".", "instance", ".", "poster", "=", "self", ".", "user",...
Validates the form.
[ "Validates", "the", "form", "." ]
python
train
xtuml/pyxtuml
bridgepoint/ooaofooa.py
https://github.com/xtuml/pyxtuml/blob/7dd9343b9a0191d1db1887ab9288d0a026608d9a/bridgepoint/ooaofooa.py#L521-L541
def build_component(self, name=None, derived_attributes=False): ''' Instantiate and build a component from ooaofooa named *name* as a pyxtuml model. Classes, associations, attributes and unique identifers, i.e. O_OBJ, R_REL, O_ATTR in ooaofooa, are defined in the resulting pyxtum...
[ "def", "build_component", "(", "self", ",", "name", "=", "None", ",", "derived_attributes", "=", "False", ")", ":", "mm", "=", "self", ".", "build_metamodel", "(", ")", "c_c", "=", "mm", ".", "select_any", "(", "'C_C'", ",", "where", "(", "Name", "=", ...
Instantiate and build a component from ooaofooa named *name* as a pyxtuml model. Classes, associations, attributes and unique identifers, i.e. O_OBJ, R_REL, O_ATTR in ooaofooa, are defined in the resulting pyxtuml model. Optionally, control whether *derived attributes* shall be ...
[ "Instantiate", "and", "build", "a", "component", "from", "ooaofooa", "named", "*", "name", "*", "as", "a", "pyxtuml", "model", ".", "Classes", "associations", "attributes", "and", "unique", "identifers", "i", ".", "e", ".", "O_OBJ", "R_REL", "O_ATTR", "in", ...
python
test
caseyjlaw/sdmreader
sdmreader/sdmreader.py
https://github.com/caseyjlaw/sdmreader/blob/b6c3498f1915138727819715ee00d2c46353382d/sdmreader/sdmreader.py#L469-L483
def calc_intsize(self): """ Calculates the size of an integration (cross + auto) in bytes """ # assume first cross blob starts after headxml and second is one int of bytes later for k in self.binarychunks.iterkeys(): if int(k.split('/')[3]) == 1 and 'cross' in k.split(...
[ "def", "calc_intsize", "(", "self", ")", ":", "# assume first cross blob starts after headxml and second is one int of bytes later\r", "for", "k", "in", "self", ".", "binarychunks", ".", "iterkeys", "(", ")", ":", "if", "int", "(", "k", ".", "split", "(", "'/'", "...
Calculates the size of an integration (cross + auto) in bytes
[ "Calculates", "the", "size", "of", "an", "integration", "(", "cross", "+", "auto", ")", "in", "bytes" ]
python
train
base4sistemas/satcfe
satcfe/resposta/padrao.py
https://github.com/base4sistemas/satcfe/blob/cb8e8815f4133d3e3d94cf526fa86767b4521ed9/satcfe/resposta/padrao.py#L104-L112
def configurar_interface_de_rede(retorno): """Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.configurar_interface_de_rede`. """ resposta = analisar_retorno(forcar_unicode(retorno), funcao='ConfigurarInterfaceDeRede') ...
[ "def", "configurar_interface_de_rede", "(", "retorno", ")", ":", "resposta", "=", "analisar_retorno", "(", "forcar_unicode", "(", "retorno", ")", ",", "funcao", "=", "'ConfigurarInterfaceDeRede'", ")", "if", "resposta", ".", "EEEEE", "not", "in", "(", "'12000'", ...
Constrói uma :class:`RespostaSAT` para o retorno (unicode) da função :meth:`~satcfe.base.FuncoesSAT.configurar_interface_de_rede`.
[ "Constrói", "uma", ":", "class", ":", "RespostaSAT", "para", "o", "retorno", "(", "unicode", ")", "da", "função", ":", "meth", ":", "~satcfe", ".", "base", ".", "FuncoesSAT", ".", "configurar_interface_de_rede", "." ]
python
train
mbr/latex
latex/build.py
https://github.com/mbr/latex/blob/f96cb9125b4f570fc2ffc5ae628e2f4069b2f3cf/latex/build.py#L207-L235
def build_pdf(source, texinputs=[], builder=None): """Builds a LaTeX source to PDF. Will automatically instantiate an available builder (or raise a :class:`exceptions.RuntimeError` if none are available) and build the supplied source with it. Parameters are passed on to the builder's :meth:`~l...
[ "def", "build_pdf", "(", "source", ",", "texinputs", "=", "[", "]", ",", "builder", "=", "None", ")", ":", "if", "builder", "is", "None", ":", "builders", "=", "PREFERRED_BUILDERS", "elif", "builder", "not", "in", "BUILDERS", ":", "raise", "RuntimeError", ...
Builds a LaTeX source to PDF. Will automatically instantiate an available builder (or raise a :class:`exceptions.RuntimeError` if none are available) and build the supplied source with it. Parameters are passed on to the builder's :meth:`~latex.build.LatexBuilder.build_pdf` function. :param b...
[ "Builds", "a", "LaTeX", "source", "to", "PDF", "." ]
python
train
a1ezzz/wasp-general
wasp_general/thread.py
https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/thread.py#L76-L93
def critical_section_lock(lock=None, blocking=True, timeout=None, raise_exception=True): """ An a wrapper for :func:`.critical_section_dynamic_lock` function call, but uses a static lock object instead of a function that returns a lock with which a function protection will be made :param lock: lock with which a fun...
[ "def", "critical_section_lock", "(", "lock", "=", "None", ",", "blocking", "=", "True", ",", "timeout", "=", "None", ",", "raise_exception", "=", "True", ")", ":", "def", "lock_getter", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "lo...
An a wrapper for :func:`.critical_section_dynamic_lock` function call, but uses a static lock object instead of a function that returns a lock with which a function protection will be made :param lock: lock with which a function will be protected :param blocking: same as blocking in :func:`.critical_section_dynamic...
[ "An", "a", "wrapper", "for", ":", "func", ":", ".", "critical_section_dynamic_lock", "function", "call", "but", "uses", "a", "static", "lock", "object", "instead", "of", "a", "function", "that", "returns", "a", "lock", "with", "which", "a", "function", "prot...
python
train
saltstack/salt
salt/utils/hashutils.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/hashutils.py#L87-L93
def md5_digest(instr): ''' Generate an md5 hash of a given string. ''' return salt.utils.stringutils.to_unicode( hashlib.md5(salt.utils.stringutils.to_bytes(instr)).hexdigest() )
[ "def", "md5_digest", "(", "instr", ")", ":", "return", "salt", ".", "utils", ".", "stringutils", ".", "to_unicode", "(", "hashlib", ".", "md5", "(", "salt", ".", "utils", ".", "stringutils", ".", "to_bytes", "(", "instr", ")", ")", ".", "hexdigest", "(...
Generate an md5 hash of a given string.
[ "Generate", "an", "md5", "hash", "of", "a", "given", "string", "." ]
python
train
openpaperwork/paperwork-backend
paperwork_backend/common/doc.py
https://github.com/openpaperwork/paperwork-backend/blob/114b831e94e039e68b339751fd18250877abad76/paperwork_backend/common/doc.py#L308-L324
def __get_name(self): """ Returns the localized name of the document (see l10n) """ if self.is_new: return _("New document") try: split = self.__docid.split("_") short_docid = "_".join(split[:3]) datetime_obj = datetime.datetime.str...
[ "def", "__get_name", "(", "self", ")", ":", "if", "self", ".", "is_new", ":", "return", "_", "(", "\"New document\"", ")", "try", ":", "split", "=", "self", ".", "__docid", ".", "split", "(", "\"_\"", ")", "short_docid", "=", "\"_\"", ".", "join", "(...
Returns the localized name of the document (see l10n)
[ "Returns", "the", "localized", "name", "of", "the", "document", "(", "see", "l10n", ")" ]
python
train
openstack/quark
quark/plugin_modules/floating_ips.py
https://github.com/openstack/quark/blob/1112e6a66917d3e98e44cb7b33b107fd5a74bb2e/quark/plugin_modules/floating_ips.py#L394-L420
def update_floatingip(context, id, content): """Update an existing floating IP. :param context: neutron api request context. :param id: id of the floating ip :param content: dictionary with keys indicating fields to update. valid keys are those that have a value of True for 'allow_put' ...
[ "def", "update_floatingip", "(", "context", ",", "id", ",", "content", ")", ":", "LOG", ".", "info", "(", "'update_floatingip %s for tenant %s and body %s'", "%", "(", "id", ",", "context", ".", "tenant_id", ",", "content", ")", ")", "if", "'port_id'", "not", ...
Update an existing floating IP. :param context: neutron api request context. :param id: id of the floating ip :param content: dictionary with keys indicating fields to update. valid keys are those that have a value of True for 'allow_put' as listed in the RESOURCE_ATTRIBUTE_MAP object in ...
[ "Update", "an", "existing", "floating", "IP", "." ]
python
valid
ThreatConnect-Inc/tcex
tcex/tcex.py
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex.py#L724-L733
def playbook(self): """Include the Playbook Module. .. Note:: Playbook methods can be accessed using ``tcex.playbook.<method>``. """ if self._playbook is None: from .tcex_playbook import TcExPlaybook self._playbook = TcExPlaybook(self) return self._playb...
[ "def", "playbook", "(", "self", ")", ":", "if", "self", ".", "_playbook", "is", "None", ":", "from", ".", "tcex_playbook", "import", "TcExPlaybook", "self", ".", "_playbook", "=", "TcExPlaybook", "(", "self", ")", "return", "self", ".", "_playbook" ]
Include the Playbook Module. .. Note:: Playbook methods can be accessed using ``tcex.playbook.<method>``.
[ "Include", "the", "Playbook", "Module", "." ]
python
train
harlowja/constructs
constructs/tree.py
https://github.com/harlowja/constructs/blob/53f20a8422bbd56294d5c0161081cb5875511fab/constructs/tree.py#L119-L128
def child_count(self, only_direct=True): """Returns how many children this node has, either only the direct children of this node or inclusive of all children nodes of this node. """ if not only_direct: count = 0 for _node in self.dfs_iter(): count...
[ "def", "child_count", "(", "self", ",", "only_direct", "=", "True", ")", ":", "if", "not", "only_direct", ":", "count", "=", "0", "for", "_node", "in", "self", ".", "dfs_iter", "(", ")", ":", "count", "+=", "1", "return", "count", "return", "len", "(...
Returns how many children this node has, either only the direct children of this node or inclusive of all children nodes of this node.
[ "Returns", "how", "many", "children", "this", "node", "has", "either", "only", "the", "direct", "children", "of", "this", "node", "or", "inclusive", "of", "all", "children", "nodes", "of", "this", "node", "." ]
python
train
programa-stic/barf-project
barf/analysis/gadgets/finder.py
https://github.com/programa-stic/barf-project/blob/18ed9e5eace55f7bf6015ec57f037c364099021c/barf/analysis/gadgets/finder.py#L74-L88
def find(self, start_address, end_address, byte_depth=20, instrs_depth=2): """Find gadgets. """ self._max_bytes = byte_depth self._instrs_depth = instrs_depth if self._architecture == ARCH_X86: candidates = self._find_x86_candidates(start_address, end_address) ...
[ "def", "find", "(", "self", ",", "start_address", ",", "end_address", ",", "byte_depth", "=", "20", ",", "instrs_depth", "=", "2", ")", ":", "self", ".", "_max_bytes", "=", "byte_depth", "self", ".", "_instrs_depth", "=", "instrs_depth", "if", "self", ".",...
Find gadgets.
[ "Find", "gadgets", "." ]
python
train
scanny/python-pptx
pptx/oxml/text.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/oxml/text.py#L273-L281
def text(self): """ The text of the ``<a:t>`` child element. """ t = self.t if t is None: return u'' text = t.text return to_unicode(text) if text is not None else u''
[ "def", "text", "(", "self", ")", ":", "t", "=", "self", ".", "t", "if", "t", "is", "None", ":", "return", "u''", "text", "=", "t", ".", "text", "return", "to_unicode", "(", "text", ")", "if", "text", "is", "not", "None", "else", "u''" ]
The text of the ``<a:t>`` child element.
[ "The", "text", "of", "the", "<a", ":", "t", ">", "child", "element", "." ]
python
train
uogbuji/versa
tools/py/contrib/datachefids.py
https://github.com/uogbuji/versa/blob/f092ffc7ed363a5b170890955168500f32de0dd5/tools/py/contrib/datachefids.py#L35-L55
def simple_hashstring(obj, bits=64): ''' Creates a simple hash in brief string form from obj bits is an optional bit width, defaulting to 64, and should be in multiples of 8 with a maximum of 64 >>> from bibframe.contrib.datachefids import simple_hashstring >>> simple_hashstring("The quick brown fo...
[ "def", "simple_hashstring", "(", "obj", ",", "bits", "=", "64", ")", ":", "#Useful discussion of techniques here: http://stackoverflow.com/questions/1303021/shortest-hash-in-python-to-name-cache-files", "#Use MurmurHash3", "#Get a 64-bit integer, the first half of the 128-bit tuple from mmh ...
Creates a simple hash in brief string form from obj bits is an optional bit width, defaulting to 64, and should be in multiples of 8 with a maximum of 64 >>> from bibframe.contrib.datachefids import simple_hashstring >>> simple_hashstring("The quick brown fox jumps over the lazy dog") 'bBsHvHu8S-M' ...
[ "Creates", "a", "simple", "hash", "in", "brief", "string", "form", "from", "obj", "bits", "is", "an", "optional", "bit", "width", "defaulting", "to", "64", "and", "should", "be", "in", "multiples", "of", "8", "with", "a", "maximum", "of", "64" ]
python
train
DavidMStraub/pylha
pylha/parse.py
https://github.com/DavidMStraub/pylha/blob/8d65074609321e5eaf97fe962c56f6d79a3ad2b6/pylha/parse.py#L80-L88
def load(stream): """Parse the LHA document and produce the corresponding Python object. Accepts a string or a file-like object.""" if isinstance(stream, str): string = stream else: string = stream.read() tokens = tokenize(string) return parse(tokens)
[ "def", "load", "(", "stream", ")", ":", "if", "isinstance", "(", "stream", ",", "str", ")", ":", "string", "=", "stream", "else", ":", "string", "=", "stream", ".", "read", "(", ")", "tokens", "=", "tokenize", "(", "string", ")", "return", "parse", ...
Parse the LHA document and produce the corresponding Python object. Accepts a string or a file-like object.
[ "Parse", "the", "LHA", "document", "and", "produce", "the", "corresponding", "Python", "object", ".", "Accepts", "a", "string", "or", "a", "file", "-", "like", "object", "." ]
python
train
pybel/pybel
src/pybel/parser/utils.py
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/parser/utils.py#L57-L75
def one_of_tags(tags, canonical_tag, name=None): """Define the tags usable in the :class:`BelParser`. For example, statements like ``g(HGNC:SNCA)`` can be expressed also as ``geneAbundance(HGNC:SNCA)``. The language must define multiple different tags that get normalized to the same thing. :param list...
[ "def", "one_of_tags", "(", "tags", ",", "canonical_tag", ",", "name", "=", "None", ")", ":", "element", "=", "oneOf", "(", "tags", ")", ".", "setParseAction", "(", "replaceWith", "(", "canonical_tag", ")", ")", "if", "name", "is", "None", ":", "return", ...
Define the tags usable in the :class:`BelParser`. For example, statements like ``g(HGNC:SNCA)`` can be expressed also as ``geneAbundance(HGNC:SNCA)``. The language must define multiple different tags that get normalized to the same thing. :param list[str] tags: a list of strings that are the tags for a fu...
[ "Define", "the", "tags", "usable", "in", "the", ":", "class", ":", "BelParser", "." ]
python
train
jbeluch/xbmcswift2
xbmcswift2/xbmcmixin.py
https://github.com/jbeluch/xbmcswift2/blob/0e7a3642499554edc8265fdf1ba6c5ee567daa78/xbmcswift2/xbmcmixin.py#L160-L169
def get_string(self, stringid): '''Returns the localized string from strings.xml for the given stringid. ''' stringid = int(stringid) if not hasattr(self, '_strings'): self._strings = {} if not stringid in self._strings: self._strings[stringid] = s...
[ "def", "get_string", "(", "self", ",", "stringid", ")", ":", "stringid", "=", "int", "(", "stringid", ")", "if", "not", "hasattr", "(", "self", ",", "'_strings'", ")", ":", "self", ".", "_strings", "=", "{", "}", "if", "not", "stringid", "in", "self"...
Returns the localized string from strings.xml for the given stringid.
[ "Returns", "the", "localized", "string", "from", "strings", ".", "xml", "for", "the", "given", "stringid", "." ]
python
train
datastax/python-driver
cassandra/cqlengine/query.py
https://github.com/datastax/python-driver/blob/30a80d0b798b1f45f8cb77163b1fa791f3e3ca29/cassandra/cqlengine/query.py#L1072-L1100
def _validate_select_where(self): """ Checks that a filterset will not create invalid select statement """ # check that there's either a =, a IN or a CONTAINS (collection) # relationship with a primary key or indexed field. We also allow # custom indexes to be queried with any operator (...
[ "def", "_validate_select_where", "(", "self", ")", ":", "# check that there's either a =, a IN or a CONTAINS (collection)", "# relationship with a primary key or indexed field. We also allow", "# custom indexes to be queried with any operator (a difference", "# between a secondary index)", "equa...
Checks that a filterset will not create invalid select statement
[ "Checks", "that", "a", "filterset", "will", "not", "create", "invalid", "select", "statement" ]
python
train
manns/pyspread
pyspread/src/gui/_gui_interfaces.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_gui_interfaces.py#L91-L111
def get_preferences_from_user(self): """Launches preferences dialog and returns dict with preferences""" dlg = PreferencesDialog(self.main_window) change_choice = dlg.ShowModal() preferences = {} if change_choice == wx.ID_OK: for (parameter, _), ctrl in zip(dlg.pa...
[ "def", "get_preferences_from_user", "(", "self", ")", ":", "dlg", "=", "PreferencesDialog", "(", "self", ".", "main_window", ")", "change_choice", "=", "dlg", ".", "ShowModal", "(", ")", "preferences", "=", "{", "}", "if", "change_choice", "==", "wx", ".", ...
Launches preferences dialog and returns dict with preferences
[ "Launches", "preferences", "dialog", "and", "returns", "dict", "with", "preferences" ]
python
train
ungarj/mapchete
mapchete/io/vector.py
https://github.com/ungarj/mapchete/blob/d482918d0e66a5b414dff6aa7cc854e01fc60ee4/mapchete/io/vector.py#L166-L195
def read_vector_window(input_files, tile, validity_check=True): """ Read a window of an input vector dataset. Also clips geometry. Parameters: ----------- input_file : string path to vector file tile : ``Tile`` tile extent to read data from validity_check : bool ...
[ "def", "read_vector_window", "(", "input_files", ",", "tile", ",", "validity_check", "=", "True", ")", ":", "if", "not", "isinstance", "(", "input_files", ",", "list", ")", ":", "input_files", "=", "[", "input_files", "]", "return", "[", "feature", "for", ...
Read a window of an input vector dataset. Also clips geometry. Parameters: ----------- input_file : string path to vector file tile : ``Tile`` tile extent to read data from validity_check : bool checks if reprojected geometry is valid and throws ``RuntimeError`` if ...
[ "Read", "a", "window", "of", "an", "input", "vector", "dataset", "." ]
python
valid
libtcod/python-tcod
tcod/bsp.py
https://github.com/libtcod/python-tcod/blob/8ba10c5cfb813eaf3e834de971ba2d6acb7838e4/tcod/bsp.py#L215-L226
def level_order(self) -> Iterator["BSP"]: """Iterate over this BSP's hierarchy in level order. .. versionadded:: 8.3 """ next = [self] # type: List['BSP'] while next: level = next # type: List['BSP'] next = [] yield from level fo...
[ "def", "level_order", "(", "self", ")", "->", "Iterator", "[", "\"BSP\"", "]", ":", "next", "=", "[", "self", "]", "# type: List['BSP']", "while", "next", ":", "level", "=", "next", "# type: List['BSP']", "next", "=", "[", "]", "yield", "from", "level", ...
Iterate over this BSP's hierarchy in level order. .. versionadded:: 8.3
[ "Iterate", "over", "this", "BSP", "s", "hierarchy", "in", "level", "order", "." ]
python
train
oceanprotocol/squid-py
squid_py/agreements/service_agreement_template.py
https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/agreements/service_agreement_template.py#L110-L128
def as_dictionary(self): """ Return the service agreement template as a dictionary. :return: dict """ template = { 'contractName': self.contract_name, 'events': [e.as_dictionary() for e in self.agreement_events], 'fulfillmentOrder': self.fulfi...
[ "def", "as_dictionary", "(", "self", ")", ":", "template", "=", "{", "'contractName'", ":", "self", ".", "contract_name", ",", "'events'", ":", "[", "e", ".", "as_dictionary", "(", ")", "for", "e", "in", "self", ".", "agreement_events", "]", ",", "'fulfi...
Return the service agreement template as a dictionary. :return: dict
[ "Return", "the", "service", "agreement", "template", "as", "a", "dictionary", "." ]
python
train
KelSolaar/Umbra
umbra/ui/widgets/codeEditor_QPlainTextEdit.py
https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/ui/widgets/codeEditor_QPlainTextEdit.py#L986-L1006
def set_highlighter(self, highlighter): """ Sets given highlighter as the current document highlighter. :param highlighter: Highlighter. :type highlighter: QSyntaxHighlighter :return: Method success. :rtype: bool """ if not issubclass(highlighter.__class...
[ "def", "set_highlighter", "(", "self", ",", "highlighter", ")", ":", "if", "not", "issubclass", "(", "highlighter", ".", "__class__", ",", "QSyntaxHighlighter", ")", ":", "raise", "foundations", ".", "exceptions", ".", "ProgrammingError", "(", "\"{0} | '{1}' is no...
Sets given highlighter as the current document highlighter. :param highlighter: Highlighter. :type highlighter: QSyntaxHighlighter :return: Method success. :rtype: bool
[ "Sets", "given", "highlighter", "as", "the", "current", "document", "highlighter", "." ]
python
train
erikrose/more-itertools
more_itertools/more.py
https://github.com/erikrose/more-itertools/blob/6a91b4e25c8e12fcf9fc2b53cf8ee0fba293e6f9/more_itertools/more.py#L1016-L1032
def sliced(seq, n): """Yield slices of length *n* from the sequence *seq*. >>> list(sliced((1, 2, 3, 4, 5, 6), 3)) [(1, 2, 3), (4, 5, 6)] If the length of the sequence is not divisible by the requested slice length, the last slice will be shorter. >>> list(sliced((1, 2, 3, 4, 5, 6...
[ "def", "sliced", "(", "seq", ",", "n", ")", ":", "return", "takewhile", "(", "bool", ",", "(", "seq", "[", "i", ":", "i", "+", "n", "]", "for", "i", "in", "count", "(", "0", ",", "n", ")", ")", ")" ]
Yield slices of length *n* from the sequence *seq*. >>> list(sliced((1, 2, 3, 4, 5, 6), 3)) [(1, 2, 3), (4, 5, 6)] If the length of the sequence is not divisible by the requested slice length, the last slice will be shorter. >>> list(sliced((1, 2, 3, 4, 5, 6, 7, 8), 3)) [(1, 2...
[ "Yield", "slices", "of", "length", "*", "n", "*", "from", "the", "sequence", "*", "seq", "*", "." ]
python
train
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/mavutil.py#L1657-L1670
def accumulate(self, buf): '''add in some more bytes''' bytes = array.array('B') if isinstance(buf, array.array): bytes.extend(buf) else: bytes.fromstring(buf) accum = self.crc for b in bytes: tmp = b ^ (accum & 0xff) tmp = ...
[ "def", "accumulate", "(", "self", ",", "buf", ")", ":", "bytes", "=", "array", ".", "array", "(", "'B'", ")", "if", "isinstance", "(", "buf", ",", "array", ".", "array", ")", ":", "bytes", ".", "extend", "(", "buf", ")", "else", ":", "bytes", "."...
add in some more bytes
[ "add", "in", "some", "more", "bytes" ]
python
train
allenai/allennlp
allennlp/modules/conditional_random_field.py
https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/modules/conditional_random_field.py#L324-L384
def viterbi_tags(self, logits: torch.Tensor, mask: torch.Tensor) -> List[Tuple[List[int], float]]: """ Uses viterbi algorithm to find most likely tags for the given inputs. If constraints are applied, disallows all other transitions. """ ...
[ "def", "viterbi_tags", "(", "self", ",", "logits", ":", "torch", ".", "Tensor", ",", "mask", ":", "torch", ".", "Tensor", ")", "->", "List", "[", "Tuple", "[", "List", "[", "int", "]", ",", "float", "]", "]", ":", "_", ",", "max_seq_length", ",", ...
Uses viterbi algorithm to find most likely tags for the given inputs. If constraints are applied, disallows all other transitions.
[ "Uses", "viterbi", "algorithm", "to", "find", "most", "likely", "tags", "for", "the", "given", "inputs", ".", "If", "constraints", "are", "applied", "disallows", "all", "other", "transitions", "." ]
python
train
etingof/pyasn1
pyasn1/type/tag.py
https://github.com/etingof/pyasn1/blob/25cf116ef8d11bb0e08454c0f3635c9f4002c2d6/pyasn1/type/tag.py#L262-L283
def tagExplicitly(self, superTag): """Return explicitly tagged *TagSet* Create a new *TagSet* representing callee *TagSet* explicitly tagged with passed tag(s). With explicit tagging mode, new tags are appended to existing tag(s). Parameters ---------- superTag:...
[ "def", "tagExplicitly", "(", "self", ",", "superTag", ")", ":", "if", "superTag", ".", "tagClass", "==", "tagClassUniversal", ":", "raise", "error", ".", "PyAsn1Error", "(", "\"Can't tag with UNIVERSAL class tag\"", ")", "if", "superTag", ".", "tagFormat", "!=", ...
Return explicitly tagged *TagSet* Create a new *TagSet* representing callee *TagSet* explicitly tagged with passed tag(s). With explicit tagging mode, new tags are appended to existing tag(s). Parameters ---------- superTag: :class:`~pyasn1.type.tag.Tag` *Ta...
[ "Return", "explicitly", "tagged", "*", "TagSet", "*" ]
python
train
iotile/coretools
iotileship/iotile/ship/autobuild/ship_file.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileship/iotile/ship/autobuild/ship_file.py#L113-L125
def create_shipfile(target, source, env): """Create a .ship file with all dependencies.""" source_dir = os.path.dirname(str(source[0])) recipe_name = os.path.basename(str(source[0]))[:-5] resman = RecipeManager() resman.add_recipe_actions(env['CUSTOM_STEPS']) resman.add_recipe_folder(source_d...
[ "def", "create_shipfile", "(", "target", ",", "source", ",", "env", ")", ":", "source_dir", "=", "os", ".", "path", ".", "dirname", "(", "str", "(", "source", "[", "0", "]", ")", ")", "recipe_name", "=", "os", ".", "path", ".", "basename", "(", "st...
Create a .ship file with all dependencies.
[ "Create", "a", ".", "ship", "file", "with", "all", "dependencies", "." ]
python
train
cjdrake/pyeda
pyeda/boolalg/table.py
https://github.com/cjdrake/pyeda/blob/554ee53aa678f4b61bcd7e07ba2c74ddc749d665/pyeda/boolalg/table.py#L86-L96
def _truthtable(inputs, pcdata): """Return a truth table.""" if len(inputs) == 0 and pcdata[0] in {PC_ZERO, PC_ONE}: return { PC_ZERO : TTZERO, PC_ONE : TTONE }[pcdata[0]] elif len(inputs) == 1 and pcdata[0] == PC_ZERO and pcdata[1] == PC_ONE: return inputs[0...
[ "def", "_truthtable", "(", "inputs", ",", "pcdata", ")", ":", "if", "len", "(", "inputs", ")", "==", "0", "and", "pcdata", "[", "0", "]", "in", "{", "PC_ZERO", ",", "PC_ONE", "}", ":", "return", "{", "PC_ZERO", ":", "TTZERO", ",", "PC_ONE", ":", ...
Return a truth table.
[ "Return", "a", "truth", "table", "." ]
python
train
AdvancedClimateSystems/uModbus
umodbus/client/serial/rtu.py
https://github.com/AdvancedClimateSystems/uModbus/blob/0560a42308003f4072d988f28042b8d55b694ad4/umodbus/client/serial/rtu.py#L205-L225
def send_message(adu, serial_port): """ Send ADU over serial to to server and return parsed response. :param adu: Request ADU. :param sock: Serial port instance. :return: Parsed response from server. """ serial_port.write(adu) serial_port.flush() # Check exception ADU (which is shorter...
[ "def", "send_message", "(", "adu", ",", "serial_port", ")", ":", "serial_port", ".", "write", "(", "adu", ")", "serial_port", ".", "flush", "(", ")", "# Check exception ADU (which is shorter than all other responses) first.", "exception_adu_size", "=", "5", "response_er...
Send ADU over serial to to server and return parsed response. :param adu: Request ADU. :param sock: Serial port instance. :return: Parsed response from server.
[ "Send", "ADU", "over", "serial", "to", "to", "server", "and", "return", "parsed", "response", "." ]
python
train
spotify/luigi
luigi/contrib/azureblob.py
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/azureblob.py#L275-L292
def open(self, mode): """ Open the target for reading or writing :param char mode: 'r' for reading and 'w' for writing. 'b' is not supported and will be stripped if used. For binary mode, use `format` :return: * :class:`.ReadableAzureBlobFile` if 'r'...
[ "def", "open", "(", "self", ",", "mode", ")", ":", "if", "mode", "not", "in", "(", "'r'", ",", "'w'", ")", ":", "raise", "ValueError", "(", "\"Unsupported open mode '%s'\"", "%", "mode", ")", "if", "mode", "==", "'r'", ":", "return", "self", ".", "fo...
Open the target for reading or writing :param char mode: 'r' for reading and 'w' for writing. 'b' is not supported and will be stripped if used. For binary mode, use `format` :return: * :class:`.ReadableAzureBlobFile` if 'r' * :class:`.AtomicAzureBlobFil...
[ "Open", "the", "target", "for", "reading", "or", "writing" ]
python
train
bugra/angel-list
angel/angel.py
https://github.com/bugra/angel-list/blob/75ac453e873727675ba18e1f45b5bc0cfda26fd7/angel/angel.py#L413-L420
def get_startups_filtered_by(self, filter_='raising'): """ Get startups based on which companies are raising funding """ url = _STARTUP_RAISING.format(c_api=_C_API_BEGINNING, api=_API_VERSION, ...
[ "def", "get_startups_filtered_by", "(", "self", ",", "filter_", "=", "'raising'", ")", ":", "url", "=", "_STARTUP_RAISING", ".", "format", "(", "c_api", "=", "_C_API_BEGINNING", ",", "api", "=", "_API_VERSION", ",", "filter_", "=", "filter_", ",", "at", "=",...
Get startups based on which companies are raising funding
[ "Get", "startups", "based", "on", "which", "companies", "are", "raising", "funding" ]
python
train
synw/dataswim
dataswim/report.py
https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/report.py#L133-L160
def get_html(self, chart_obj=None, slug=None): """ Get the html and script tag for a chart """ if chart_obj is None: if self.chart_obj is None: self.err( "No chart object registered, please provide " "one in parameters" ...
[ "def", "get_html", "(", "self", ",", "chart_obj", "=", "None", ",", "slug", "=", "None", ")", ":", "if", "chart_obj", "is", "None", ":", "if", "self", ".", "chart_obj", "is", "None", ":", "self", ".", "err", "(", "\"No chart object registered, please provi...
Get the html and script tag for a chart
[ "Get", "the", "html", "and", "script", "tag", "for", "a", "chart" ]
python
train
google/apitools
apitools/base/py/credentials_lib.py
https://github.com/google/apitools/blob/f3745a7ea535aa0e88b0650c16479b696d6fd446/apitools/base/py/credentials_lib.py#L670-L680
def _EnsureFileExists(self): """Touches a file; returns False on error, True on success.""" if not os.path.exists(self._filename): old_umask = os.umask(0o177) try: open(self._filename, 'a+b').close() except OSError: return False ...
[ "def", "_EnsureFileExists", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "_filename", ")", ":", "old_umask", "=", "os", ".", "umask", "(", "0o177", ")", "try", ":", "open", "(", "self", ".", "_filename", "...
Touches a file; returns False on error, True on success.
[ "Touches", "a", "file", ";", "returns", "False", "on", "error", "True", "on", "success", "." ]
python
train
pytroll/trollimage
trollimage/colorspaces.py
https://github.com/pytroll/trollimage/blob/d35a7665ad475ff230e457085523e21f2cd3f454/trollimage/colorspaces.py#L87-L111
def rgb2xyz(r__, g__, b__): """RGB to XYZ """ r2_ = r__ / 255.0 g2_ = g__ / 255.0 b2_ = b__ / 255.0 def f__(arr): """Forward """ return np.where(arr > 0.04045, ((arr + 0.055) / 1.055) ** 2.4, arr / 12.92) r2_ = f__(r...
[ "def", "rgb2xyz", "(", "r__", ",", "g__", ",", "b__", ")", ":", "r2_", "=", "r__", "/", "255.0", "g2_", "=", "g__", "/", "255.0", "b2_", "=", "b__", "/", "255.0", "def", "f__", "(", "arr", ")", ":", "\"\"\"Forward\n \"\"\"", "return", "np", ...
RGB to XYZ
[ "RGB", "to", "XYZ" ]
python
train
niklasf/python-chess
chess/pgn.py
https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/pgn.py#L441-L466
def setup(self, board: Union[chess.Board, str]) -> None: """ Sets up a specific starting position. This sets (or resets) the ``FEN``, ``SetUp``, and ``Variant`` header tags. """ try: fen = board.fen() except AttributeError: board = chess.Board(boar...
[ "def", "setup", "(", "self", ",", "board", ":", "Union", "[", "chess", ".", "Board", ",", "str", "]", ")", "->", "None", ":", "try", ":", "fen", "=", "board", ".", "fen", "(", ")", "except", "AttributeError", ":", "board", "=", "chess", ".", "Boa...
Sets up a specific starting position. This sets (or resets) the ``FEN``, ``SetUp``, and ``Variant`` header tags.
[ "Sets", "up", "a", "specific", "starting", "position", ".", "This", "sets", "(", "or", "resets", ")", "the", "FEN", "SetUp", "and", "Variant", "header", "tags", "." ]
python
train
scikit-learn-contrib/categorical-encoding
examples/benchmarking_large/util.py
https://github.com/scikit-learn-contrib/categorical-encoding/blob/5e9e803c9131b377af305d5302723ba2415001da/examples/benchmarking_large/util.py#L58-L96
def train_model(folds, model): """ Evaluation with: Matthews correlation coefficient: represents thresholding measures AUC: represents ranking measures Brier score: represents calibration measures """ scores = [] fit_model_time = 0 # Sum of all the time spend on fitting the tr...
[ "def", "train_model", "(", "folds", ",", "model", ")", ":", "scores", "=", "[", "]", "fit_model_time", "=", "0", "# Sum of all the time spend on fitting the training data, later on normalized", "score_model_time", "=", "0", "# Sum of all the time spend on scoring the testing da...
Evaluation with: Matthews correlation coefficient: represents thresholding measures AUC: represents ranking measures Brier score: represents calibration measures
[ "Evaluation", "with", ":", "Matthews", "correlation", "coefficient", ":", "represents", "thresholding", "measures", "AUC", ":", "represents", "ranking", "measures", "Brier", "score", ":", "represents", "calibration", "measures" ]
python
valid
delph-in/pydelphin
delphin/interfaces/ace.py
https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/interfaces/ace.py#L505-L519
def transfer_from_iterable(grm, data, **kwargs): """ Transfer from each MRS in *data* with ACE using grammar *grm*. Args: grm (str): path to a compiled grammar image data (iterable): source MRSs as SimpleMRS strings **kwargs: additional keyword arguments to pass to the A...
[ "def", "transfer_from_iterable", "(", "grm", ",", "data", ",", "*", "*", "kwargs", ")", ":", "with", "AceTransferer", "(", "grm", ",", "*", "*", "kwargs", ")", "as", "transferer", ":", "for", "datum", "in", "data", ":", "yield", "transferer", ".", "int...
Transfer from each MRS in *data* with ACE using grammar *grm*. Args: grm (str): path to a compiled grammar image data (iterable): source MRSs as SimpleMRS strings **kwargs: additional keyword arguments to pass to the AceTransferer Yields: :class:`~delphin.interfaces....
[ "Transfer", "from", "each", "MRS", "in", "*", "data", "*", "with", "ACE", "using", "grammar", "*", "grm", "*", "." ]
python
train
VorskiImagineering/C3PO
c3po/converters/po_ods.py
https://github.com/VorskiImagineering/C3PO/blob/e3e35835e5ac24158848afed4f905ca44ac3ae00/c3po/converters/po_ods.py#L142-L166
def csv_to_ods(trans_csv, meta_csv, local_ods): """ Converts csv files to one ods file :param trans_csv: path to csv file with translations :param meta_csv: path to csv file with metadata :param local_ods: path to new ods file """ trans_reader = UnicodeReader(trans_csv) meta_reader = Uni...
[ "def", "csv_to_ods", "(", "trans_csv", ",", "meta_csv", ",", "local_ods", ")", ":", "trans_reader", "=", "UnicodeReader", "(", "trans_csv", ")", "meta_reader", "=", "UnicodeReader", "(", "meta_csv", ")", "ods", "=", "ODS", "(", ")", "trans_title", "=", "tran...
Converts csv files to one ods file :param trans_csv: path to csv file with translations :param meta_csv: path to csv file with metadata :param local_ods: path to new ods file
[ "Converts", "csv", "files", "to", "one", "ods", "file", ":", "param", "trans_csv", ":", "path", "to", "csv", "file", "with", "translations", ":", "param", "meta_csv", ":", "path", "to", "csv", "file", "with", "metadata", ":", "param", "local_ods", ":", "...
python
test
googleapis/google-cloud-python
api_core/google/api_core/iam.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/api_core/google/api_core/iam.py#L120-L128
def editors(self): """Legacy access to editor role. DEPRECATED: use ``policy["roles/editors"]`` instead.""" result = set() for role in self._EDITOR_ROLES: for member in self._bindings.get(role, ()): result.add(member) return frozenset(result)
[ "def", "editors", "(", "self", ")", ":", "result", "=", "set", "(", ")", "for", "role", "in", "self", ".", "_EDITOR_ROLES", ":", "for", "member", "in", "self", ".", "_bindings", ".", "get", "(", "role", ",", "(", ")", ")", ":", "result", ".", "ad...
Legacy access to editor role. DEPRECATED: use ``policy["roles/editors"]`` instead.
[ "Legacy", "access", "to", "editor", "role", "." ]
python
train
nyaruka/smartmin
smartmin/views.py
https://github.com/nyaruka/smartmin/blob/488a676a4960555e4d216a7b95d6e01a4ad4efd8/smartmin/views.py#L531-L540
def derive_title(self): """ Derives our title from our list """ title = super(SmartListView, self).derive_title() if not title: return force_text(self.model._meta.verbose_name_plural).title() else: return title
[ "def", "derive_title", "(", "self", ")", ":", "title", "=", "super", "(", "SmartListView", ",", "self", ")", ".", "derive_title", "(", ")", "if", "not", "title", ":", "return", "force_text", "(", "self", ".", "model", ".", "_meta", ".", "verbose_name_plu...
Derives our title from our list
[ "Derives", "our", "title", "from", "our", "list" ]
python
train
spyder-ide/spyder
spyder/widgets/mixins.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/widgets/mixins.py#L482-L487
def extend_selection_to_next(self, what='word', direction='left'): """ Extend selection to next *what* ('word' or 'character') toward *direction* ('left' or 'right') """ self.__move_cursor_anchor(what, direction, QTextCursor.KeepAnchor)
[ "def", "extend_selection_to_next", "(", "self", ",", "what", "=", "'word'", ",", "direction", "=", "'left'", ")", ":", "self", ".", "__move_cursor_anchor", "(", "what", ",", "direction", ",", "QTextCursor", ".", "KeepAnchor", ")" ]
Extend selection to next *what* ('word' or 'character') toward *direction* ('left' or 'right')
[ "Extend", "selection", "to", "next", "*", "what", "*", "(", "word", "or", "character", ")", "toward", "*", "direction", "*", "(", "left", "or", "right", ")" ]
python
train
svetlyak40wt/python-cl-conditions
example/example.py
https://github.com/svetlyak40wt/python-cl-conditions/blob/709dfd55f2b8cf7eb9b7d86a6b70c8a3feed4b10/example/example.py#L93-L102
def log_analyzer(path): """This procedure replaces every line which can't be parsed with special object MalformedLogEntry. """ with handle(MalformedLogEntryError, lambda (c): invoke_restart('use_value', MalformedLogEntry(c.text...
[ "def", "log_analyzer", "(", "path", ")", ":", "with", "handle", "(", "MalformedLogEntryError", ",", "lambda", "(", "c", ")", ":", "invoke_restart", "(", "'use_value'", ",", "MalformedLogEntry", "(", "c", ".", "text", ")", ")", ")", ":", "for", "filename", ...
This procedure replaces every line which can't be parsed with special object MalformedLogEntry.
[ "This", "procedure", "replaces", "every", "line", "which", "can", "t", "be", "parsed", "with", "special", "object", "MalformedLogEntry", "." ]
python
train
jilljenn/tryalgo
tryalgo/freivalds.py
https://github.com/jilljenn/tryalgo/blob/89a4dd9655e7b6b0a176f72b4c60d0196420dfe1/tryalgo/freivalds.py#L36-L49
def freivalds(A, B, C): """Tests matrix product AB=C by Freivalds :param A: n by n numerical matrix :param B: same :param C: same :returns: False with high probability if AB != C :complexity: :math:`O(n^2)` """ n = len(A) x = [randint(0, 1000000) for j in range(n)] retu...
[ "def", "freivalds", "(", "A", ",", "B", ",", "C", ")", ":", "n", "=", "len", "(", "A", ")", "x", "=", "[", "randint", "(", "0", ",", "1000000", ")", "for", "j", "in", "range", "(", "n", ")", "]", "return", "mult", "(", "A", ",", "mult", "...
Tests matrix product AB=C by Freivalds :param A: n by n numerical matrix :param B: same :param C: same :returns: False with high probability if AB != C :complexity: :math:`O(n^2)`
[ "Tests", "matrix", "product", "AB", "=", "C", "by", "Freivalds" ]
python
train
digidotcom/python-devicecloud
devicecloud/sci.py
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/sci.py#L133-L220
def send_sci(self, operation, target, payload, reply=None, synchronous=None, sync_timeout=None, cache=None, allow_offline=None, wait_for_reconnect=None): """Send SCI request to 1 or more targets :param str operation: The operation is one of {send_message, update_firmware, disconnect, q...
[ "def", "send_sci", "(", "self", ",", "operation", ",", "target", ",", "payload", ",", "reply", "=", "None", ",", "synchronous", "=", "None", ",", "sync_timeout", "=", "None", ",", "cache", "=", "None", ",", "allow_offline", "=", "None", ",", "wait_for_re...
Send SCI request to 1 or more targets :param str operation: The operation is one of {send_message, update_firmware, disconnect, query_firmware_targets, file_system, data_service, and reboot} :param target: The device(s) to be targeted with this request :type target: :class:`~.Target...
[ "Send", "SCI", "request", "to", "1", "or", "more", "targets" ]
python
train
lreis2415/PyGeoC
pygeoc/vector.py
https://github.com/lreis2415/PyGeoC/blob/9a92d1a229bb74298e3c57f27c97079980b5f729/pygeoc/vector.py#L36-L77
def raster2shp(rasterfile, vectorshp, layername=None, fieldname=None, band_num=1, mask='default'): """Convert raster to ESRI shapefile""" FileClass.remove_files(vectorshp) FileClass.check_file_exists(rasterfile) # this allows GDAL to throw Python Exceptions gda...
[ "def", "raster2shp", "(", "rasterfile", ",", "vectorshp", ",", "layername", "=", "None", ",", "fieldname", "=", "None", ",", "band_num", "=", "1", ",", "mask", "=", "'default'", ")", ":", "FileClass", ".", "remove_files", "(", "vectorshp", ")", "FileClass"...
Convert raster to ESRI shapefile
[ "Convert", "raster", "to", "ESRI", "shapefile" ]
python
train
stratis-storage/into-dbus-python
src/into_dbus_python/_xformer.py
https://github.com/stratis-storage/into-dbus-python/blob/81366049671f79116bbb81c97bf621800a2f6315/src/into_dbus_python/_xformer.py#L27-L48
def _wrapper(func): """ Wraps a generated function so that it catches all Type- and ValueErrors and raises IntoDPValueErrors. :param func: the transforming function """ @functools.wraps(func) def the_func(expr): """ The actual function. :param object expr: the expr...
[ "def", "_wrapper", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "the_func", "(", "expr", ")", ":", "\"\"\"\n The actual function.\n\n :param object expr: the expression to be xformed to dbus-python types\n \"\"\"", "try"...
Wraps a generated function so that it catches all Type- and ValueErrors and raises IntoDPValueErrors. :param func: the transforming function
[ "Wraps", "a", "generated", "function", "so", "that", "it", "catches", "all", "Type", "-", "and", "ValueErrors", "and", "raises", "IntoDPValueErrors", "." ]
python
valid
CamDavidsonPilon/lifelines
lifelines/fitters/aalen_additive_fitter.py
https://github.com/CamDavidsonPilon/lifelines/blob/bdf6be6f1d10eea4c46365ee0ee6a47d8c30edf8/lifelines/fitters/aalen_additive_fitter.py#L531-L579
def print_summary(self, decimals=2, **kwargs): """ Print summary statistics describing the fit, the coefficients, and the error bounds. Parameters ----------- decimals: int, optional (default=2) specify the number of decimal places to show kwargs: ...
[ "def", "print_summary", "(", "self", ",", "decimals", "=", "2", ",", "*", "*", "kwargs", ")", ":", "# Print information about data first", "justify", "=", "string_justify", "(", "18", ")", "print", "(", "self", ")", "print", "(", "\"{} = '{}'\"", ".", "forma...
Print summary statistics describing the fit, the coefficients, and the error bounds. Parameters ----------- decimals: int, optional (default=2) specify the number of decimal places to show kwargs: print additional meta data in the output (useful to provide model ...
[ "Print", "summary", "statistics", "describing", "the", "fit", "the", "coefficients", "and", "the", "error", "bounds", "." ]
python
train
pyrocat101/moo
moo/__init__.py
https://github.com/pyrocat101/moo/blob/39e86d4ecb329309260bc30876c77aa3a7a2cfb1/moo/__init__.py#L209-L229
def main(port, export, css, files): """ \b Examples: $ moo README.md # live preview README.md $ moo -e *.md # export all markdown files $ moo --no-css -e README.md # export README.md without CSS $ cat README.md | moo -e - | less # export ST...
[ "def", "main", "(", "port", ",", "export", ",", "css", ",", "files", ")", ":", "options", "=", "{", "'css'", ":", "css", ",", "'port'", ":", "port", "}", "try", ":", "if", "not", "export", ":", "if", "len", "(", "files", ")", "!=", "1", ":", ...
\b Examples: $ moo README.md # live preview README.md $ moo -e *.md # export all markdown files $ moo --no-css -e README.md # export README.md without CSS $ cat README.md | moo -e - | less # export STDIN to STDOUT
[ "\\", "b", "Examples", ":", "$", "moo", "README", ".", "md", "#", "live", "preview", "README", ".", "md", "$", "moo", "-", "e", "*", ".", "md", "#", "export", "all", "markdown", "files", "$", "moo", "--", "no", "-", "css", "-", "e", "README", "...
python
test
PRIArobotics/HedgehogUtils
hedgehog/utils/zmq/__init__.py
https://github.com/PRIArobotics/HedgehogUtils/blob/cc368df270288c870cc66d707696ccb62823ca9c/hedgehog/utils/zmq/__init__.py#L11-L23
def configure(self, *, hwm: int=None, rcvtimeo: int=None, sndtimeo: int=None, linger: int=None) -> 'Socket': """ Allows to configure some common socket options and configurations, while allowing method chaining """ if hwm is not None: self.set_hwm(hwm) if rcvtimeo is ...
[ "def", "configure", "(", "self", ",", "*", ",", "hwm", ":", "int", "=", "None", ",", "rcvtimeo", ":", "int", "=", "None", ",", "sndtimeo", ":", "int", "=", "None", ",", "linger", ":", "int", "=", "None", ")", "->", "'Socket'", ":", "if", "hwm", ...
Allows to configure some common socket options and configurations, while allowing method chaining
[ "Allows", "to", "configure", "some", "common", "socket", "options", "and", "configurations", "while", "allowing", "method", "chaining" ]
python
train
welbornprod/colr
colr/colr.py
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1439-L1460
def color_code(self, fore=None, back=None, style=None): """ Return the codes for this style/colors. """ # Map from style type to raw code formatter function. colorcodes = [] resetcodes = [] userstyles = {'style': style, 'back': back, 'fore': fore} for stype in userstyles:...
[ "def", "color_code", "(", "self", ",", "fore", "=", "None", ",", "back", "=", "None", ",", "style", "=", "None", ")", ":", "# Map from style type to raw code formatter function.", "colorcodes", "=", "[", "]", "resetcodes", "=", "[", "]", "userstyles", "=", "...
Return the codes for this style/colors.
[ "Return", "the", "codes", "for", "this", "style", "/", "colors", "." ]
python
train
HIPS/autograd
examples/data.py
https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/examples/data.py#L53-L67
def make_pinwheel(radial_std, tangential_std, num_classes, num_per_class, rate, rs=npr.RandomState(0)): """Based on code by Ryan P. Adams.""" rads = np.linspace(0, 2*np.pi, num_classes, endpoint=False) features = rs.randn(num_classes*num_per_class, 2) \ * np.array([radial_std, tan...
[ "def", "make_pinwheel", "(", "radial_std", ",", "tangential_std", ",", "num_classes", ",", "num_per_class", ",", "rate", ",", "rs", "=", "npr", ".", "RandomState", "(", "0", ")", ")", ":", "rads", "=", "np", ".", "linspace", "(", "0", ",", "2", "*", ...
Based on code by Ryan P. Adams.
[ "Based", "on", "code", "by", "Ryan", "P", ".", "Adams", "." ]
python
train
ReFirmLabs/binwalk
src/binwalk/core/module.py
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L1010-L1019
def show_help(fd=sys.stdout): ''' Convenience wrapper around binwalk.core.module.Modules.help. @fd - An object with a write method (e.g., sys.stdout, sys.stderr, etc). Returns None. ''' with Modules() as m: fd.write(m.help())
[ "def", "show_help", "(", "fd", "=", "sys", ".", "stdout", ")", ":", "with", "Modules", "(", ")", "as", "m", ":", "fd", ".", "write", "(", "m", ".", "help", "(", ")", ")" ]
Convenience wrapper around binwalk.core.module.Modules.help. @fd - An object with a write method (e.g., sys.stdout, sys.stderr, etc). Returns None.
[ "Convenience", "wrapper", "around", "binwalk", ".", "core", ".", "module", ".", "Modules", ".", "help", "." ]
python
train
wdm0006/git-pandas
gitpandas/project.py
https://github.com/wdm0006/git-pandas/blob/e56b817b1d66b8296d1d5e703d5db0e181d25899/gitpandas/project.py#L236-L279
def commit_history(self, branch, limit=None, days=None, ignore_globs=None, include_globs=None): """ Returns a pandas DataFrame containing all of the commits for a given branch. The results from all repositories are appended to each other, resulting in one large data frame of size <limit>. If a ...
[ "def", "commit_history", "(", "self", ",", "branch", ",", "limit", "=", "None", ",", "days", "=", "None", ",", "ignore_globs", "=", "None", ",", "include_globs", "=", "None", ")", ":", "if", "limit", "is", "not", "None", ":", "limit", "=", "int", "("...
Returns a pandas DataFrame containing all of the commits for a given branch. The results from all repositories are appended to each other, resulting in one large data frame of size <limit>. If a limit is provided, it is divided by the number of repositories in the project directory to find out how many...
[ "Returns", "a", "pandas", "DataFrame", "containing", "all", "of", "the", "commits", "for", "a", "given", "branch", ".", "The", "results", "from", "all", "repositories", "are", "appended", "to", "each", "other", "resulting", "in", "one", "large", "data", "fra...
python
train