repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
asmodehn/filefinder2
filefinder2/_encoding_utils.py
https://github.com/asmodehn/filefinder2/blob/3f0b211ce11a34562e2a2160e039ae5290b68d6b/filefinder2/_encoding_utils.py#L107-L123
def strip_encoding_cookie(filelike): """Generator to pull lines from a text-mode file, skipping the encoding cookie if it is found in the first two lines. """ it = iter(filelike) try: first = next(it) if not cookie_comment_re.match(first): yield first second = nex...
[ "def", "strip_encoding_cookie", "(", "filelike", ")", ":", "it", "=", "iter", "(", "filelike", ")", "try", ":", "first", "=", "next", "(", "it", ")", "if", "not", "cookie_comment_re", ".", "match", "(", "first", ")", ":", "yield", "first", "second", "=...
Generator to pull lines from a text-mode file, skipping the encoding cookie if it is found in the first two lines.
[ "Generator", "to", "pull", "lines", "from", "a", "text", "-", "mode", "file", "skipping", "the", "encoding", "cookie", "if", "it", "is", "found", "in", "the", "first", "two", "lines", "." ]
python
train
27.235294
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/models.py
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/models.py#L346-L353
def to_dict(self): """Return a dict representation of KnwKBRVAL.""" # FIXME remove 'id' dependency from invenio modules return {'id': self.m_key + "_" + str(self.id_knwKB), 'key': self.m_key, 'value': self.m_value, 'kbid': self.kb.id if self.kb els...
[ "def", "to_dict", "(", "self", ")", ":", "# FIXME remove 'id' dependency from invenio modules", "return", "{", "'id'", ":", "self", ".", "m_key", "+", "\"_\"", "+", "str", "(", "self", ".", "id_knwKB", ")", ",", "'key'", ":", "self", ".", "m_key", ",", "'v...
Return a dict representation of KnwKBRVAL.
[ "Return", "a", "dict", "representation", "of", "KnwKBRVAL", "." ]
python
train
47.625
IdentityPython/pysaml2
src/saml2/__init__.py
https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/__init__.py#L748-L771
def set_text(self, val, base64encode=False): """ Sets the text property of this instance. :param val: The value of the text property :param base64encode: Whether the value should be base64encoded :return: The instance """ # print("set_text: %s" % (val,)) if isin...
[ "def", "set_text", "(", "self", ",", "val", ",", "base64encode", "=", "False", ")", ":", "# print(\"set_text: %s\" % (val,))", "if", "isinstance", "(", "val", ",", "bool", ")", ":", "if", "val", ":", "setattr", "(", "self", ",", "\"text\"", ",", "\"true\""...
Sets the text property of this instance. :param val: The value of the text property :param base64encode: Whether the value should be base64encoded :return: The instance
[ "Sets", "the", "text", "property", "of", "this", "instance", "." ]
python
train
31.5
wandb/client
wandb/vendor/prompt_toolkit/key_binding/registry.py
https://github.com/wandb/client/blob/7d08954ed5674fee223cd85ed0d8518fe47266b2/wandb/vendor/prompt_toolkit/key_binding/registry.py#L162-L193
def get_bindings_for_keys(self, keys): """ Return a list of key bindings that can handle this key. (This return also inactive bindings, so the `filter` still has to be called, for checking it.) :param keys: tuple of keys. """ def get(): result = [] ...
[ "def", "get_bindings_for_keys", "(", "self", ",", "keys", ")", ":", "def", "get", "(", ")", ":", "result", "=", "[", "]", "for", "b", "in", "self", ".", "key_bindings", ":", "if", "len", "(", "keys", ")", "==", "len", "(", "b", ".", "keys", ")", ...
Return a list of key bindings that can handle this key. (This return also inactive bindings, so the `filter` still has to be called, for checking it.) :param keys: tuple of keys.
[ "Return", "a", "list", "of", "key", "bindings", "that", "can", "handle", "this", "key", ".", "(", "This", "return", "also", "inactive", "bindings", "so", "the", "filter", "still", "has", "to", "be", "called", "for", "checking", "it", ".", ")" ]
python
train
32.78125
google/sentencepiece
tensorflow/tf_sentencepiece/sentencepiece_processor_ops.py
https://github.com/google/sentencepiece/blob/ffa2c8218f7afbb06d0c1bb87c82efb6867db41a/tensorflow/tf_sentencepiece/sentencepiece_processor_ops.py#L46-L59
def piece_size(model_file=None, model_proto=None, name=None): """Returns the piece size (vocabulary size). Args: model_file: The sentencepiece model file path. model_proto: The sentencepiece model serialized proto. Either `model_file` or `model_proto` must be set. name: The name argume...
[ "def", "piece_size", "(", "model_file", "=", "None", ",", "model_proto", "=", "None", ",", "name", "=", "None", ")", ":", "return", "_gen_sentencepiece_processor_op", ".", "sentencepiece_get_piece_size", "(", "model_file", "=", "model_file", ",", "model_proto", "=...
Returns the piece size (vocabulary size). Args: model_file: The sentencepiece model file path. model_proto: The sentencepiece model serialized proto. Either `model_file` or `model_proto` must be set. name: The name argument that is passed to the op function. Returns: A scalar repre...
[ "Returns", "the", "piece", "size", "(", "vocabulary", "size", ")", "." ]
python
train
38.928571
openstax/cnx-publishing
cnxpublishing/views/user_actions.py
https://github.com/openstax/cnx-publishing/blob/f55b4a2c45d8618737288f1b74b4139d5ac74154/cnxpublishing/views/user_actions.py#L126-L137
def delete_license_request(request): """Submission to remove a license acceptance request.""" uuid_ = request.matchdict['uuid'] posted_uids = [x['uid'] for x in request.json.get('licensors', [])] with db_connect() as db_conn: with db_conn.cursor() as cursor: remove_license_requests(...
[ "def", "delete_license_request", "(", "request", ")", ":", "uuid_", "=", "request", ".", "matchdict", "[", "'uuid'", "]", "posted_uids", "=", "[", "x", "[", "'uid'", "]", "for", "x", "in", "request", ".", "json", ".", "get", "(", "'licensors'", ",", "[...
Submission to remove a license acceptance request.
[ "Submission", "to", "remove", "a", "license", "acceptance", "request", "." ]
python
valid
33.916667
google/brotli
research/brotlidump.py
https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L274-L301
def setDecode(self, decodeTable): """Store decodeTable, and compute lengthTable, minLength, maxLength from encodings. """ self.decodeTable = decodeTable #set of symbols with unknown length todo = set(decodeTable) #bit size under investigation maskLength = ...
[ "def", "setDecode", "(", "self", ",", "decodeTable", ")", ":", "self", ".", "decodeTable", "=", "decodeTable", "#set of symbols with unknown length", "todo", "=", "set", "(", "decodeTable", ")", "#bit size under investigation", "maskLength", "=", "0", "lengthTable", ...
Store decodeTable, and compute lengthTable, minLength, maxLength from encodings.
[ "Store", "decodeTable", "and", "compute", "lengthTable", "minLength", "maxLength", "from", "encodings", "." ]
python
test
39.785714
tensorpack/tensorpack
examples/FasterRCNN/backbone.py
https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/examples/FasterRCNN/backbone.py#L66-L93
def backbone_scope(freeze): """ Args: freeze (bool): whether to freeze all the variables under the scope """ def nonlin(x): x = get_norm()(x) return tf.nn.relu(x) with argscope([Conv2D, MaxPooling, BatchNorm], data_format='channels_first'), \ argscope(Conv2D, use...
[ "def", "backbone_scope", "(", "freeze", ")", ":", "def", "nonlin", "(", "x", ")", ":", "x", "=", "get_norm", "(", ")", "(", "x", ")", "return", "tf", ".", "nn", ".", "relu", "(", "x", ")", "with", "argscope", "(", "[", "Conv2D", ",", "MaxPooling"...
Args: freeze (bool): whether to freeze all the variables under the scope
[ "Args", ":", "freeze", "(", "bool", ")", ":", "whether", "to", "freeze", "all", "the", "variables", "under", "the", "scope" ]
python
train
42.785714
xsleonard/pystmark
pystmark.py
https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L379-L387
def add_header(self, name, value): '''Attach an email header to send with the message. :param name: The name of the header value. :param value: The header value. ''' if self.headers is None: self.headers = [] self.headers.append(dict(Name=name, Value=value))
[ "def", "add_header", "(", "self", ",", "name", ",", "value", ")", ":", "if", "self", ".", "headers", "is", "None", ":", "self", ".", "headers", "=", "[", "]", "self", ".", "headers", ".", "append", "(", "dict", "(", "Name", "=", "name", ",", "Val...
Attach an email header to send with the message. :param name: The name of the header value. :param value: The header value.
[ "Attach", "an", "email", "header", "to", "send", "with", "the", "message", "." ]
python
train
34.555556
MatiasSM/fcb
fcb/sending/SentLog.py
https://github.com/MatiasSM/fcb/blob/92a6c535287ea1c1ef986954a5d66e7905fb6221/fcb/sending/SentLog.py#L19-L32
def process_data(self, block): """expects Block from Compressor""" if hasattr(block, 'send_destinations') and block.send_destinations: self.fire(events.FileProcessed(block)) self._log_in_db(block) if self._sent_log_file: self._log_in_sent_log(block) ...
[ "def", "process_data", "(", "self", ",", "block", ")", ":", "if", "hasattr", "(", "block", ",", "'send_destinations'", ")", "and", "block", ".", "send_destinations", ":", "self", ".", "fire", "(", "events", ".", "FileProcessed", "(", "block", ")", ")", "...
expects Block from Compressor
[ "expects", "Block", "from", "Compressor" ]
python
train
51.142857
quodlibet/mutagen
mutagen/aac.py
https://github.com/quodlibet/mutagen/blob/e393df5971ba41ba5a50de9c2c9e7e5484d82c4e/mutagen/aac.py#L54-L75
def sync(self, max_bytes): """Find the next sync. Returns True if found.""" # at least 2 bytes for the sync max_bytes = max(max_bytes, 2) r = self._r r.align() while max_bytes > 0: try: b = r.bytes(1) if b == b"\xff": ...
[ "def", "sync", "(", "self", ",", "max_bytes", ")", ":", "# at least 2 bytes for the sync", "max_bytes", "=", "max", "(", "max_bytes", ",", "2", ")", "r", "=", "self", ".", "_r", "r", ".", "align", "(", ")", "while", "max_bytes", ">", "0", ":", "try", ...
Find the next sync. Returns True if found.
[ "Find", "the", "next", "sync", ".", "Returns", "True", "if", "found", "." ]
python
train
26.454545
networks-lab/metaknowledge
metaknowledge/mkCollection.py
https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/mkCollection.py#L168-L180
def pop(self): """Removes a random element from the collection and returns it # Returns `object` > A random object from the collection """ try: return self._collection.pop() except KeyError: raise KeyError("Nothing left in the {}: '{}'."...
[ "def", "pop", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_collection", ".", "pop", "(", ")", "except", "KeyError", ":", "raise", "KeyError", "(", "\"Nothing left in the {}: '{}'.\"", ".", "format", "(", "type", "(", "self", ")", ".", "__n...
Removes a random element from the collection and returns it # Returns `object` > A random object from the collection
[ "Removes", "a", "random", "element", "from", "the", "collection", "and", "returns", "it" ]
python
train
27.153846
vstconsulting/vstutils
vstutils/utils.py
https://github.com/vstconsulting/vstutils/blob/3d6d140c2463952dc9835a4e40caf758468b3049/vstutils/utils.py#L718-L739
def get_object(self, name, *argv, **kwargs): """ Get url object tuple for url :param name: url regexp from :type name: str :param argv: overrided args :param kwargs: overrided kwargs :return: url object :rtype: django.conf.urls.url """ reg...
[ "def", "get_object", "(", "self", ",", "name", ",", "*", "argv", ",", "*", "*", "kwargs", ")", ":", "regexp", "=", "name", "options", "=", "self", ".", "opts", "(", "regexp", ")", "options", ".", "update", "(", "kwargs", ")", "args", "=", "options"...
Get url object tuple for url :param name: url regexp from :type name: str :param argv: overrided args :param kwargs: overrided kwargs :return: url object :rtype: django.conf.urls.url
[ "Get", "url", "object", "tuple", "for", "url" ]
python
train
34.772727
shaypal5/utilp
utilp/func/_path.py
https://github.com/shaypal5/utilp/blob/932abaf8ccfd06557632b7dbebc7775da1de8430/utilp/func/_path.py#L25-L91
def is_pathname_valid(pathname: str) -> bool: """Checks if the given path name is valid. Returns ------- `True` if the passed pathname is a valid pathname for the current OS; `False` otherwise. """ # If this pathname is either not a string or is but is empty, this pathname # is invalid....
[ "def", "is_pathname_valid", "(", "pathname", ":", "str", ")", "->", "bool", ":", "# If this pathname is either not a string or is but is empty, this pathname", "# is invalid.", "try", ":", "if", "not", "isinstance", "(", "pathname", ",", "str", ")", "or", "not", "path...
Checks if the given path name is valid. Returns ------- `True` if the passed pathname is a valid pathname for the current OS; `False` otherwise.
[ "Checks", "if", "the", "given", "path", "name", "is", "valid", "." ]
python
train
50.014925
xflows/rdm
rdm/wrappers/aleph/aleph.py
https://github.com/xflows/rdm/blob/d984e2a0297e5fa8d799953bbd0dba79b05d403d/rdm/wrappers/aleph/aleph.py#L102-L111
def setPostScript(self, goal, script): """ After learning call the given script using 'goal'. :param goal: goal name :param script: prolog script to call """ self.postGoal = goal self.postScript = script
[ "def", "setPostScript", "(", "self", ",", "goal", ",", "script", ")", ":", "self", ".", "postGoal", "=", "goal", "self", ".", "postScript", "=", "script" ]
After learning call the given script using 'goal'. :param goal: goal name :param script: prolog script to call
[ "After", "learning", "call", "the", "given", "script", "using", "goal", "." ]
python
train
26
gmr/tredis
tredis/keys.py
https://github.com/gmr/tredis/blob/2e91c6a58a35460be0525c51ac6a98fde3b506ad/tredis/keys.py#L12-L30
def delete(self, *keys): """Removes the specified keys. A key is ignored if it does not exist. Returns :data:`True` if all keys are removed. .. note:: **Time complexity**: ``O(N)`` where ``N`` is the number of keys that will be removed. When a key to remove holds a value ...
[ "def", "delete", "(", "self", ",", "*", "keys", ")", ":", "return", "self", ".", "_execute", "(", "[", "b'DEL'", "]", "+", "list", "(", "keys", ")", ",", "len", "(", "keys", ")", ")" ]
Removes the specified keys. A key is ignored if it does not exist. Returns :data:`True` if all keys are removed. .. note:: **Time complexity**: ``O(N)`` where ``N`` is the number of keys that will be removed. When a key to remove holds a value other than a string, the ...
[ "Removes", "the", "specified", "keys", ".", "A", "key", "is", "ignored", "if", "it", "does", "not", "exist", ".", "Returns", ":", "data", ":", "True", "if", "all", "keys", "are", "removed", "." ]
python
train
41.684211
ceph/ceph-deploy
ceph_deploy/hosts/remotes.py
https://github.com/ceph/ceph-deploy/blob/86943fcc454cd4c99a86e3493e9e93a59c661fef/ceph_deploy/hosts/remotes.py#L358-L368
def safe_mkdir(path, uid=-1, gid=-1): """ create path if it doesn't exist """ try: os.mkdir(path) except OSError as e: if e.errno == errno.EEXIST: pass else: raise else: os.chown(path, uid, gid)
[ "def", "safe_mkdir", "(", "path", ",", "uid", "=", "-", "1", ",", "gid", "=", "-", "1", ")", ":", "try", ":", "os", ".", "mkdir", "(", "path", ")", "except", "OSError", "as", "e", ":", "if", "e", ".", "errno", "==", "errno", ".", "EEXIST", ":...
create path if it doesn't exist
[ "create", "path", "if", "it", "doesn", "t", "exist" ]
python
train
23.272727
StagPython/StagPy
stagpy/args.py
https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/args.py#L35-L62
def _steps_to_slices(): """parse timesteps and snapshots arguments and return slices""" if not (conf.core.timesteps or conf.core.snapshots): # default to the last snap conf.core.timesteps = None conf.core.snapshots = slice(-1, None, None) return elif conf.core.snapshots: ...
[ "def", "_steps_to_slices", "(", ")", ":", "if", "not", "(", "conf", ".", "core", ".", "timesteps", "or", "conf", ".", "core", ".", "snapshots", ")", ":", "# default to the last snap", "conf", ".", "core", ".", "timesteps", "=", "None", "conf", ".", "core...
parse timesteps and snapshots arguments and return slices
[ "parse", "timesteps", "and", "snapshots", "arguments", "and", "return", "slices" ]
python
train
34.535714
chaoss/grimoirelab-perceval
perceval/backends/core/launchpad.py
https://github.com/chaoss/grimoirelab-perceval/blob/41c908605e88b7ebc3a536c643fa0f212eaf9e0e/perceval/backends/core/launchpad.py#L221-L227
def __fetch_issue_data(self, issue_id): """Get data associated to an issue""" raw_issue = self.client.issue(issue_id) issue = json.loads(raw_issue) return issue
[ "def", "__fetch_issue_data", "(", "self", ",", "issue_id", ")", ":", "raw_issue", "=", "self", ".", "client", ".", "issue", "(", "issue_id", ")", "issue", "=", "json", ".", "loads", "(", "raw_issue", ")", "return", "issue" ]
Get data associated to an issue
[ "Get", "data", "associated", "to", "an", "issue" ]
python
test
26.857143
jic-dtool/dtool-azure
dtool_azure/storagebroker.py
https://github.com/jic-dtool/dtool-azure/blob/5f5f1faa040e047e619380faf437a74cdfa09737/dtool_azure/storagebroker.py#L264-L276
def list_overlay_names(self): """Return list of overlay names.""" overlay_names = [] for blob in self._blobservice.list_blobs( self.uuid, prefix=self.overlays_key_prefix ): overlay_file = blob.name.rsplit('/', 1)[-1] overlay_name, ext = ov...
[ "def", "list_overlay_names", "(", "self", ")", ":", "overlay_names", "=", "[", "]", "for", "blob", "in", "self", ".", "_blobservice", ".", "list_blobs", "(", "self", ".", "uuid", ",", "prefix", "=", "self", ".", "overlays_key_prefix", ")", ":", "overlay_fi...
Return list of overlay names.
[ "Return", "list", "of", "overlay", "names", "." ]
python
test
31.230769
Esri/ArcREST
src/arcrest/ags/services.py
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/ags/services.py#L271-L287
def _getLayers(self): """ gets layers for the featuer service """ params = {"f": "json"} json_dict = self._get(self._url, params, securityHandler=self._securityHandler, proxy_url=self._proxy_url, ...
[ "def", "_getLayers", "(", "self", ")", ":", "params", "=", "{", "\"f\"", ":", "\"json\"", "}", "json_dict", "=", "self", ".", "_get", "(", "self", ".", "_url", ",", "params", ",", "securityHandler", "=", "self", ".", "_securityHandler", ",", "proxy_url",...
gets layers for the featuer service
[ "gets", "layers", "for", "the", "featuer", "service" ]
python
train
45.470588
ramses-tech/nefertari
nefertari/view.py
https://github.com/ramses-tech/nefertari/blob/c7caffe11576c11aa111adbdbadeff70ce66b1dd/nefertari/view.py#L200-L212
def fill_null_values(self): """ Fill missing model fields in JSON with {key: null value}. Only run for PUT requests. """ if not self.Model: log.info("%s has no model defined" % self.__class__.__name__) return empty_values = self.Model.get_null_values() ...
[ "def", "fill_null_values", "(", "self", ")", ":", "if", "not", "self", ".", "Model", ":", "log", ".", "info", "(", "\"%s has no model defined\"", "%", "self", ".", "__class__", ".", "__name__", ")", "return", "empty_values", "=", "self", ".", "Model", ".",...
Fill missing model fields in JSON with {key: null value}. Only run for PUT requests.
[ "Fill", "missing", "model", "fields", "in", "JSON", "with", "{", "key", ":", "null", "value", "}", "." ]
python
train
34.769231
iotile/typedargs
typedargs/utils.py
https://github.com/iotile/typedargs/blob/0a5091a664b9b4d836e091e9ba583e944f438fd8/typedargs/utils.py#L69-L111
def find_all(container): """Find all annotated function inside of a container. Annotated functions are identified as those that: - do not start with a _ character - are either annotated with metadata - or strings that point to lazily loaded modules Args: container (object): The contain...
[ "def", "find_all", "(", "container", ")", ":", "if", "isinstance", "(", "container", ",", "dict", ")", ":", "names", "=", "container", ".", "keys", "(", ")", "else", ":", "names", "=", "dir", "(", "container", ")", "built_context", "=", "BasicContext", ...
Find all annotated function inside of a container. Annotated functions are identified as those that: - do not start with a _ character - are either annotated with metadata - or strings that point to lazily loaded modules Args: container (object): The container to search for annotated funct...
[ "Find", "all", "annotated", "function", "inside", "of", "a", "container", "." ]
python
test
33.209302
Robin8Put/pmes
storage/rpc_methods.py
https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/storage/rpc_methods.py#L461-L530
async def mailed_confirm(self, **params): """Sends mail to user after offer receiveing Accepts: - cid - buyer address - price - offer_type - point - coinid """ if not params: return {"error":400, "reason":"Missed required fields"} # Check if required fields exists cid = params.get("cid...
[ "async", "def", "mailed_confirm", "(", "self", ",", "*", "*", "params", ")", ":", "if", "not", "params", ":", "return", "{", "\"error\"", ":", "400", ",", "\"reason\"", ":", "\"Missed required fields\"", "}", "# Check if required fields exists", "cid", "=", "p...
Sends mail to user after offer receiveing Accepts: - cid - buyer address - price - offer_type - point - coinid
[ "Sends", "mail", "to", "user", "after", "offer", "receiveing", "Accepts", ":", "-", "cid", "-", "buyer", "address", "-", "price", "-", "offer_type", "-", "point", "-", "coinid" ]
python
train
25.714286
hubo1016/vlcp
vlcp/config/config.py
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/config/config.py#L172-L177
def setdefault(self, key, defaultvalue = None): """ Support dict-like setdefault (create if not existed) """ (t, k) = self._getsubitem(key, True) return t.__dict__.setdefault(k, defaultvalue)
[ "def", "setdefault", "(", "self", ",", "key", ",", "defaultvalue", "=", "None", ")", ":", "(", "t", ",", "k", ")", "=", "self", ".", "_getsubitem", "(", "key", ",", "True", ")", "return", "t", ".", "__dict__", ".", "setdefault", "(", "k", ",", "d...
Support dict-like setdefault (create if not existed)
[ "Support", "dict", "-", "like", "setdefault", "(", "create", "if", "not", "existed", ")" ]
python
train
37.666667
senaite/senaite.core
bika/lims/browser/analyses/view.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/analyses/view.py#L1158-L1174
def _folder_item_fieldicons(self, analysis_brain): """Resolves if field-specific icons must be displayed for the object passed in. :param analysis_brain: Brain that represents an analysis """ full_obj = self.get_object(analysis_brain) uid = api.get_uid(full_obj) ...
[ "def", "_folder_item_fieldicons", "(", "self", ",", "analysis_brain", ")", ":", "full_obj", "=", "self", ".", "get_object", "(", "analysis_brain", ")", "uid", "=", "api", ".", "get_uid", "(", "full_obj", ")", "for", "name", ",", "adapter", "in", "getAdapters...
Resolves if field-specific icons must be displayed for the object passed in. :param analysis_brain: Brain that represents an analysis
[ "Resolves", "if", "field", "-", "specific", "icons", "must", "be", "displayed", "for", "the", "object", "passed", "in", "." ]
python
train
39.117647
StanfordVL/robosuite
robosuite/environments/sawyer_pick_place.py
https://github.com/StanfordVL/robosuite/blob/65cd16810e2ed647e3ec88746af3412065b7f278/robosuite/environments/sawyer_pick_place.py#L313-L406
def staged_rewards(self): """ Returns staged rewards based on current physical states. Stages consist of reaching, grasping, lifting, and hovering. """ reach_mult = 0.1 grasp_mult = 0.35 lift_mult = 0.5 hover_mult = 0.7 # filter out objects that ...
[ "def", "staged_rewards", "(", "self", ")", ":", "reach_mult", "=", "0.1", "grasp_mult", "=", "0.35", "lift_mult", "=", "0.5", "hover_mult", "=", "0.7", "# filter out objects that are already in the correct bins", "objs_to_reach", "=", "[", "]", "geoms_to_grasp", "=", ...
Returns staged rewards based on current physical states. Stages consist of reaching, grasping, lifting, and hovering.
[ "Returns", "staged", "rewards", "based", "on", "current", "physical", "states", ".", "Stages", "consist", "of", "reaching", "grasping", "lifting", "and", "hovering", "." ]
python
train
43.531915
pantsbuild/pants
src/python/pants/reporting/html_reporter.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/reporting/html_reporter.py#L78-L81
def open(self): """Implementation of Reporter callback.""" safe_mkdir(os.path.dirname(self._html_dir)) self._report_file = open(self.report_path(), 'w')
[ "def", "open", "(", "self", ")", ":", "safe_mkdir", "(", "os", ".", "path", ".", "dirname", "(", "self", ".", "_html_dir", ")", ")", "self", ".", "_report_file", "=", "open", "(", "self", ".", "report_path", "(", ")", ",", "'w'", ")" ]
Implementation of Reporter callback.
[ "Implementation", "of", "Reporter", "callback", "." ]
python
train
40.25
tensorflow/datasets
tensorflow_datasets/image/corruptions.py
https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/image/corruptions.py#L349-L364
def contrast(x, severity=1): """Change contrast of images. Args: x: numpy array, uncorrupted image, assumed to have uint8 pixel in [0,255]. severity: integer, severity of corruption. Returns: numpy array, image with uint8 pixels in [0,255]. Changed contrast. """ c = [0.4, .3, .2, .1, .05][severi...
[ "def", "contrast", "(", "x", ",", "severity", "=", "1", ")", ":", "c", "=", "[", "0.4", ",", ".3", ",", ".2", ",", ".1", ",", ".05", "]", "[", "severity", "-", "1", "]", "x", "=", "np", ".", "array", "(", "x", ")", "/", "255.", "means", "...
Change contrast of images. Args: x: numpy array, uncorrupted image, assumed to have uint8 pixel in [0,255]. severity: integer, severity of corruption. Returns: numpy array, image with uint8 pixels in [0,255]. Changed contrast.
[ "Change", "contrast", "of", "images", "." ]
python
train
29.875
olsoneric/pedemath
pedemath/vec2.py
https://github.com/olsoneric/pedemath/blob/4bffcfe7089e421d603eb0a9708b84789c2d16be/pedemath/vec2.py#L208-L214
def truncate(self, max_length): """Truncate this vector so it's length does not exceed max.""" if self.length() > max_length: # If it's longer than the max_length, scale to the max_length. self.scale(max_length / self.length())
[ "def", "truncate", "(", "self", ",", "max_length", ")", ":", "if", "self", ".", "length", "(", ")", ">", "max_length", ":", "# If it's longer than the max_length, scale to the max_length.", "self", ".", "scale", "(", "max_length", "/", "self", ".", "length", "("...
Truncate this vector so it's length does not exceed max.
[ "Truncate", "this", "vector", "so", "it", "s", "length", "does", "not", "exceed", "max", "." ]
python
train
37.571429
glormph/msstitch
src/app/drivers/pycolator/splitmerge.py
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/drivers/pycolator/splitmerge.py#L94-L99
def set_features(self): """"Merge all psms and peptides""" allpsms_str = readers.generate_psms_multiple_fractions_strings( self.mergefiles, self.ns) allpeps = preparation.merge_peptides(self.mergefiles, self.ns) self.features = {'psm': allpsms_str, 'peptide': allpeps}
[ "def", "set_features", "(", "self", ")", ":", "allpsms_str", "=", "readers", ".", "generate_psms_multiple_fractions_strings", "(", "self", ".", "mergefiles", ",", "self", ".", "ns", ")", "allpeps", "=", "preparation", ".", "merge_peptides", "(", "self", ".", "...
Merge all psms and peptides
[ "Merge", "all", "psms", "and", "peptides" ]
python
train
51.166667
noahbenson/neuropythy
neuropythy/mri/images.py
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/mri/images.py#L17-L29
def to_image_header(img): ''' to_image_header(img) yields img.header if img is a nibabel image object. to_image_header(hdr) yields hdr if hdr is a nibabel header object. to_image_header(obj) raises an error for other input types. ''' if not img.__module__.startswith('nibabel.'): raise Va...
[ "def", "to_image_header", "(", "img", ")", ":", "if", "not", "img", ".", "__module__", ".", "startswith", "(", "'nibabel.'", ")", ":", "raise", "ValueError", "(", "'to_image_header: only nibabel obejcts can be coerced to headers'", ")", "if", "type", "(", "img", "...
to_image_header(img) yields img.header if img is a nibabel image object. to_image_header(hdr) yields hdr if hdr is a nibabel header object. to_image_header(obj) raises an error for other input types.
[ "to_image_header", "(", "img", ")", "yields", "img", ".", "header", "if", "img", "is", "a", "nibabel", "image", "object", ".", "to_image_header", "(", "hdr", ")", "yields", "hdr", "if", "hdr", "is", "a", "nibabel", "header", "object", ".", "to_image_header...
python
train
48.923077
square/pylink
pylink/jlink.py
https://github.com/square/pylink/blob/81dda0a191d923a8b2627c52cb778aba24d279d7/pylink/jlink.py#L3510-L3542
def breakpoint_set(self, addr, thumb=False, arm=False): """Sets a breakpoint at the specified address. If ``thumb`` is ``True``, the breakpoint is set in THUMB-mode, while if ``arm`` is ``True``, the breakpoint is set in ARM-mode, otherwise a normal breakpoint is set. Args: ...
[ "def", "breakpoint_set", "(", "self", ",", "addr", ",", "thumb", "=", "False", ",", "arm", "=", "False", ")", ":", "flags", "=", "enums", ".", "JLinkBreakpoint", ".", "ANY", "if", "thumb", ":", "flags", "=", "flags", "|", "enums", ".", "JLinkBreakpoint...
Sets a breakpoint at the specified address. If ``thumb`` is ``True``, the breakpoint is set in THUMB-mode, while if ``arm`` is ``True``, the breakpoint is set in ARM-mode, otherwise a normal breakpoint is set. Args: self (JLink): the ``JLink`` instance addr (int): t...
[ "Sets", "a", "breakpoint", "at", "the", "specified", "address", "." ]
python
train
37.090909
sethmlarson/virtualbox-python
virtualbox/library.py
https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L9585-L9628
def set_final_values(self, enabled, v_box_values, extra_config_values): """This method allows the appliance's user to change the configuration for the virtual system descriptions. For each array item returned from :py:func:`get_description` , you must pass in one boolean value and one configurat...
[ "def", "set_final_values", "(", "self", ",", "enabled", ",", "v_box_values", ",", "extra_config_values", ")", ":", "if", "not", "isinstance", "(", "enabled", ",", "list", ")", ":", "raise", "TypeError", "(", "\"enabled can only be an instance of type list\"", ")", ...
This method allows the appliance's user to change the configuration for the virtual system descriptions. For each array item returned from :py:func:`get_description` , you must pass in one boolean value and one configuration value. Each item in the boolean array determines whether the p...
[ "This", "method", "allows", "the", "appliance", "s", "user", "to", "change", "the", "configuration", "for", "the", "virtual", "system", "descriptions", ".", "For", "each", "array", "item", "returned", "from", ":", "py", ":", "func", ":", "get_description", "...
python
train
52.318182
csparpa/pyowm
pyowm/weatherapi25/cityidregistry.py
https://github.com/csparpa/pyowm/blob/cdd59eb72f32f7238624ceef9b2e2329a5ebd472/pyowm/weatherapi25/cityidregistry.py#L49-L76
def ids_for(self, city_name, country=None, matching='nocase'): """ Returns a list of tuples in the form (long, str, str) corresponding to the int IDs and relative toponyms and 2-chars country of the cities matching the provided city name. The rule for identifying matchings is acc...
[ "def", "ids_for", "(", "self", ",", "city_name", ",", "country", "=", "None", ",", "matching", "=", "'nocase'", ")", ":", "if", "not", "city_name", ":", "return", "[", "]", "if", "matching", "not", "in", "self", ".", "MATCHINGS", ":", "raise", "ValueEr...
Returns a list of tuples in the form (long, str, str) corresponding to the int IDs and relative toponyms and 2-chars country of the cities matching the provided city name. The rule for identifying matchings is according to the provided `matching` parameter value. If `country` is ...
[ "Returns", "a", "list", "of", "tuples", "in", "the", "form", "(", "long", "str", "str", ")", "corresponding", "to", "the", "int", "IDs", "and", "relative", "toponyms", "and", "2", "-", "chars", "country", "of", "the", "cities", "matching", "the", "provid...
python
train
54.214286
zalando/patroni
patroni/utils.py
https://github.com/zalando/patroni/blob/f6d29081c90af52064b981cdd877a07338d86038/patroni/utils.py#L269-L277
def polling_loop(timeout, interval=1): """Returns an iterator that returns values until timeout has passed. Timeout is measured from start of iteration.""" start_time = time.time() iteration = 0 end_time = start_time + timeout while time.time() < end_time: yield iteration iteration +...
[ "def", "polling_loop", "(", "timeout", ",", "interval", "=", "1", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "iteration", "=", "0", "end_time", "=", "start_time", "+", "timeout", "while", "time", ".", "time", "(", ")", "<", "end_time",...
Returns an iterator that returns values until timeout has passed. Timeout is measured from start of iteration.
[ "Returns", "an", "iterator", "that", "returns", "values", "until", "timeout", "has", "passed", ".", "Timeout", "is", "measured", "from", "start", "of", "iteration", "." ]
python
train
38.222222
rosenbrockc/fortpy
fortpy/interop/ftypes.py
https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/interop/ftypes.py#L402-L422
def _format_docstring(self, text): """Formats the specified text for display within 90 characters. Returns a list of *un-joined* lines. :arg text: the text to format. """ #The only complication we have here is that we don't want to break words up. words = text.split() ...
[ "def", "_format_docstring", "(", "self", ",", "text", ")", ":", "#The only complication we have here is that we don't want to break words up.", "words", "=", "text", ".", "split", "(", ")", "result", "=", "[", "]", "line", "=", "[", "]", "cumline", "=", "0", "fo...
Formats the specified text for display within 90 characters. Returns a list of *un-joined* lines. :arg text: the text to format.
[ "Formats", "the", "specified", "text", "for", "display", "within", "90", "characters", ".", "Returns", "a", "list", "of", "*", "un", "-", "joined", "*", "lines", "." ]
python
train
31.380952
jaraco/keyring
keyring/cli.py
https://github.com/jaraco/keyring/blob/71c798378e365286b7cc03c06e4d7d24c7de8fc4/keyring/cli.py#L101-L105
def pass_from_pipe(cls): """Return password from pipe if not on TTY, else False. """ is_pipe = not sys.stdin.isatty() return is_pipe and cls.strip_last_newline(sys.stdin.read())
[ "def", "pass_from_pipe", "(", "cls", ")", ":", "is_pipe", "=", "not", "sys", ".", "stdin", ".", "isatty", "(", ")", "return", "is_pipe", "and", "cls", ".", "strip_last_newline", "(", "sys", ".", "stdin", ".", "read", "(", ")", ")" ]
Return password from pipe if not on TTY, else False.
[ "Return", "password", "from", "pipe", "if", "not", "on", "TTY", "else", "False", "." ]
python
valid
41
ARMmbed/yotta
yotta/lib/github_access.py
https://github.com/ARMmbed/yotta/blob/56bc1e56c602fa20307b23fe27518e9cd6c11af1/yotta/lib/github_access.py#L278-L285
def availableBranches(self): ''' return a list of GithubComponentVersion objects for the tip of each branch ''' return [ GithubComponentVersion( '', b[0], b[1], self.name, cache_key=None ) for b in _getBranchHeads(self.repo).items() ]
[ "def", "availableBranches", "(", "self", ")", ":", "return", "[", "GithubComponentVersion", "(", "''", ",", "b", "[", "0", "]", ",", "b", "[", "1", "]", ",", "self", ".", "name", ",", "cache_key", "=", "None", ")", "for", "b", "in", "_getBranchHeads"...
return a list of GithubComponentVersion objects for the tip of each branch
[ "return", "a", "list", "of", "GithubComponentVersion", "objects", "for", "the", "tip", "of", "each", "branch" ]
python
valid
37.375
pydsigner/taskit
taskit/frontend.py
https://github.com/pydsigner/taskit/blob/3b228e2dbac16b3b84b2581f5b46e027d1d8fa7f/taskit/frontend.py#L84-L91
def _canceling_task(self, backend): """ Used internally to decrement `backend`s current and total task counts when `backend` could not be reached. """ with self.backend_mutex: self.backends[backend] -= 1 self.task_counter[backend] -= 1
[ "def", "_canceling_task", "(", "self", ",", "backend", ")", ":", "with", "self", ".", "backend_mutex", ":", "self", ".", "backends", "[", "backend", "]", "-=", "1", "self", ".", "task_counter", "[", "backend", "]", "-=", "1" ]
Used internally to decrement `backend`s current and total task counts when `backend` could not be reached.
[ "Used", "internally", "to", "decrement", "backend", "s", "current", "and", "total", "task", "counts", "when", "backend", "could", "not", "be", "reached", "." ]
python
train
36.625
angr/claripy
claripy/smtlib_utils.py
https://github.com/angr/claripy/blob/4ed61924880af1ea8fb778047d896ec0156412a6/claripy/smtlib_utils.py#L35-L51
def consume_assignment_list(self): self.expect('(') self.expect('model') """Parses a list of expressions from the tokens""" assignments = [] while True: next_token = self.tokens.consume() self.tokens.add_extra_token(next_token) # push it back ...
[ "def", "consume_assignment_list", "(", "self", ")", ":", "self", ".", "expect", "(", "'('", ")", "self", ".", "expect", "(", "'model'", ")", "assignments", "=", "[", "]", "while", "True", ":", "next_token", "=", "self", ".", "tokens", ".", "consume", "...
Parses a list of expressions from the tokens
[ "Parses", "a", "list", "of", "expressions", "from", "the", "tokens" ]
python
train
27.411765
brocade/pynos
pynos/versions/ver_7/ver_7_1_0/yang/brocade_snmp.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_snmp.py#L92-L102
def snmp_server_user_username(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") snmp_server = ET.SubElement(config, "snmp-server", xmlns="urn:brocade.com:mgmt:brocade-snmp") user = ET.SubElement(snmp_server, "user") username = ET.SubElement(user, "...
[ "def", "snmp_server_user_username", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "snmp_server", "=", "ET", ".", "SubElement", "(", "config", ",", "\"snmp-server\"", ",", "xmlns", "=", "\"urn:b...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
41.636364
NICTA/revrand
revrand/btypes.py
https://github.com/NICTA/revrand/blob/4c1881b6c1772d2b988518e49dde954f165acfb6/revrand/btypes.py#L49-L80
def clip(self, value): """ Clip a value to a bound. Parameters ---------- value : scalar or ndarray value to clip Returns ------- scalar or ndarray : of the same shape as value, bit with each element clipped to fall wi...
[ "def", "clip", "(", "self", ",", "value", ")", ":", "if", "not", "self", ".", "lower", "and", "not", "self", ".", "upper", ":", "return", "value", "return", "np", ".", "clip", "(", "value", ",", "self", ".", "lower", ",", "self", ".", "upper", ")...
Clip a value to a bound. Parameters ---------- value : scalar or ndarray value to clip Returns ------- scalar or ndarray : of the same shape as value, bit with each element clipped to fall within the specified bounds Example ...
[ "Clip", "a", "value", "to", "a", "bound", "." ]
python
train
24.34375
rhayes777/PyAutoFit
autofit/mapper/model_mapper.py
https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L520-L532
def info(self): """ Use the priors that make up the model_mapper to generate information on each parameter of the overall model. This information is extracted from each priors *model_info* property. """ info = [] for prior_model_name, prior_model in self.prior_model_tup...
[ "def", "info", "(", "self", ")", ":", "info", "=", "[", "]", "for", "prior_model_name", ",", "prior_model", "in", "self", ".", "prior_model_tuples", ":", "info", ".", "append", "(", "prior_model", ".", "name", "+", "'\\n'", ")", "info", ".", "extend", ...
Use the priors that make up the model_mapper to generate information on each parameter of the overall model. This information is extracted from each priors *model_info* property.
[ "Use", "the", "priors", "that", "make", "up", "the", "model_mapper", "to", "generate", "information", "on", "each", "parameter", "of", "the", "overall", "model", "." ]
python
train
36.769231
jazzband/django-ddp
dddp/accounts/ddp.py
https://github.com/jazzband/django-ddp/blob/1e1954b06fe140346acea43582515991685e4e01/dddp/accounts/ddp.py#L255-L301
def update_subs(new_user_id): """Update subs to send added/removed for collections with user_rel.""" for sub in Subscription.objects.filter(connection=this.ws.connection): params = loads(sub.params_ejson) pub = API.get_pub_by_name(sub.publication) # calculate the que...
[ "def", "update_subs", "(", "new_user_id", ")", ":", "for", "sub", "in", "Subscription", ".", "objects", ".", "filter", "(", "connection", "=", "this", ".", "ws", ".", "connection", ")", ":", "params", "=", "loads", "(", "sub", ".", "params_ejson", ")", ...
Update subs to send added/removed for collections with user_rel.
[ "Update", "subs", "to", "send", "added", "/", "removed", "for", "collections", "with", "user_rel", "." ]
python
test
40.553191
Yubico/python-yubico
yubico/yubikey_config.py
https://github.com/Yubico/python-yubico/blob/a72e8eddb90da6ee96e29f60912ca1f2872c9aea/yubico/yubikey_config.py#L32-L39
def command2str(num): """ Turn command number into name """ for attr in SLOT.__dict__.keys(): if not attr.startswith('_') and attr == attr.upper(): if getattr(SLOT, attr) == num: return 'SLOT_%s' % attr return "0x%02x" % (num)
[ "def", "command2str", "(", "num", ")", ":", "for", "attr", "in", "SLOT", ".", "__dict__", ".", "keys", "(", ")", ":", "if", "not", "attr", ".", "startswith", "(", "'_'", ")", "and", "attr", "==", "attr", ".", "upper", "(", ")", ":", "if", "getatt...
Turn command number into name
[ "Turn", "command", "number", "into", "name" ]
python
train
33.5
bitesofcode/projexui
projexui/widgets/xlistwidget.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xlistwidget.py#L235-L246
def setText(self, text): """ Sets the text for this item. :param text | <str> """ self._text = text # update the label btn = self.widget() if btn: btn.setText(text)
[ "def", "setText", "(", "self", ",", "text", ")", ":", "self", ".", "_text", "=", "text", "# update the label\r", "btn", "=", "self", ".", "widget", "(", ")", "if", "btn", ":", "btn", ".", "setText", "(", "text", ")" ]
Sets the text for this item. :param text | <str>
[ "Sets", "the", "text", "for", "this", "item", ".", ":", "param", "text", "|", "<str", ">" ]
python
train
21.916667
miccoli/pyownet
src/pyownet/protocol.py
https://github.com/miccoli/pyownet/blob/190afea6a72705772b942d7929bc0aa6561043e0/src/pyownet/protocol.py#L586-L595
def present(self, path, timeout=0): """returns True if there is an entity at path""" ret, data = self.sendmess(MSG_PRESENCE, str2bytez(path), timeout=timeout) assert ret <= 0 and not data, (ret, data) if ret < 0: return False else: ...
[ "def", "present", "(", "self", ",", "path", ",", "timeout", "=", "0", ")", ":", "ret", ",", "data", "=", "self", ".", "sendmess", "(", "MSG_PRESENCE", ",", "str2bytez", "(", "path", ")", ",", "timeout", "=", "timeout", ")", "assert", "ret", "<=", "...
returns True if there is an entity at path
[ "returns", "True", "if", "there", "is", "an", "entity", "at", "path" ]
python
train
33.3
brechtm/rinohtype
src/rinoh/text.py
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/text.py#L237-L244
def is_script(self, container): """Returns `True` if this styled text is super/subscript.""" try: style = self._style(container) return style.get_value('position', container) != TextPosition.NORMAL except StyleException: retu...
[ "def", "is_script", "(", "self", ",", "container", ")", ":", "try", ":", "style", "=", "self", ".", "_style", "(", "container", ")", "return", "style", ".", "get_value", "(", "'position'", ",", "container", ")", "!=", "TextPosition", ".", "NORMAL", "exce...
Returns `True` if this styled text is super/subscript.
[ "Returns", "True", "if", "this", "styled", "text", "is", "super", "/", "subscript", "." ]
python
train
40.125
sorgerlab/indra
indra/preassembler/grounding_mapper.py
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/preassembler/grounding_mapper.py#L674-L707
def save_sentences(twg, stmts, filename, agent_limit=300): """Write evidence sentences for stmts with ungrounded agents to csv file. Parameters ---------- twg: list of tuple list of tuples of ungrounded agent_texts with counts of the number of times they are mentioned in the list of sta...
[ "def", "save_sentences", "(", "twg", ",", "stmts", ",", "filename", ",", "agent_limit", "=", "300", ")", ":", "sentences", "=", "[", "]", "unmapped_texts", "=", "[", "t", "[", "0", "]", "for", "t", "in", "twg", "]", "counter", "=", "0", "logger", "...
Write evidence sentences for stmts with ungrounded agents to csv file. Parameters ---------- twg: list of tuple list of tuples of ungrounded agent_texts with counts of the number of times they are mentioned in the list of statements. Should be sorted in descending order by the count...
[ "Write", "evidence", "sentences", "for", "stmts", "with", "ungrounded", "agents", "to", "csv", "file", "." ]
python
train
36.941176
napalm-automation/napalm
napalm/ios/ios.py
https://github.com/napalm-automation/napalm/blob/c11ae8bb5ce395698704a0051cdf8d144fbb150d/napalm/ios/ios.py#L1217-L1461
def get_bgp_config(self, group="", neighbor=""): """ Parse BGP config params into a dict :param group='': :param neighbor='': """ bgp_config = {} def build_prefix_limit(af_table, limit, prefix_percent, prefix_timeout): prefix_limit = {} ...
[ "def", "get_bgp_config", "(", "self", ",", "group", "=", "\"\"", ",", "neighbor", "=", "\"\"", ")", ":", "bgp_config", "=", "{", "}", "def", "build_prefix_limit", "(", "af_table", ",", "limit", ",", "prefix_percent", ",", "prefix_timeout", ")", ":", "prefi...
Parse BGP config params into a dict :param group='': :param neighbor='':
[ "Parse", "BGP", "config", "params", "into", "a", "dict", ":", "param", "group", "=", ":", ":", "param", "neighbor", "=", ":" ]
python
train
41.293878
molmod/molmod
molmod/ic.py
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/ic.py#L713-L721
def _opdist_low(av, bv, cv, deriv): """Similar to opdist, but with relative vectors""" a = Vector3(9, deriv, av, (0, 1, 2)) b = Vector3(9, deriv, bv, (3, 4, 5)) c = Vector3(9, deriv, cv, (6, 7, 8)) n = cross(a, b) n /= n.norm() dist = dot(c, n) return dist.results()
[ "def", "_opdist_low", "(", "av", ",", "bv", ",", "cv", ",", "deriv", ")", ":", "a", "=", "Vector3", "(", "9", ",", "deriv", ",", "av", ",", "(", "0", ",", "1", ",", "2", ")", ")", "b", "=", "Vector3", "(", "9", ",", "deriv", ",", "bv", ",...
Similar to opdist, but with relative vectors
[ "Similar", "to", "opdist", "but", "with", "relative", "vectors" ]
python
train
32.333333
6809/MC6809
MC6809/components/mc6809_base.py
https://github.com/6809/MC6809/blob/6ba2f5106df46689017b5d0b6d84d43b7ee6a240/MC6809/components/mc6809_base.py#L672-L685
def instruction_INC_memory(self, opcode, ea, m): """ Adds to the register. The carry bit is not affected, thus allowing this instruction to be used as a loop counter in multiple-precision computations. When operating on unsigned values, only the BEQ and BNE branches can be expect...
[ "def", "instruction_INC_memory", "(", "self", ",", "opcode", ",", "ea", ",", "m", ")", ":", "r", "=", "self", ".", "INC", "(", "m", ")", "return", "ea", ",", "r", "&", "0xff" ]
Adds to the register. The carry bit is not affected, thus allowing this instruction to be used as a loop counter in multiple-precision computations. When operating on unsigned values, only the BEQ and BNE branches can be expected to behave consistently. When operating on twos complement ...
[ "Adds", "to", "the", "register", ".", "The", "carry", "bit", "is", "not", "affected", "thus", "allowing", "this", "instruction", "to", "be", "used", "as", "a", "loop", "counter", "in", "multiple", "-", "precision", "computations", ".", "When", "operating", ...
python
train
40.714286
GNS3/gns3-server
gns3server/controller/__init__.py
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/__init__.py#L458-L464
def close_compute_projects(self, compute): """ Close projects running on a compute """ for project in self._projects.values(): if compute in project.computes: yield from project.close()
[ "def", "close_compute_projects", "(", "self", ",", "compute", ")", ":", "for", "project", "in", "self", ".", "_projects", ".", "values", "(", ")", ":", "if", "compute", "in", "project", ".", "computes", ":", "yield", "from", "project", ".", "close", "(",...
Close projects running on a compute
[ "Close", "projects", "running", "on", "a", "compute" ]
python
train
34.142857
edeposit/marcxml2mods
src/marcxml2mods/transformators.py
https://github.com/edeposit/marcxml2mods/blob/7b44157e859b4d2a372f79598ddbf77e43d39812/src/marcxml2mods/transformators.py#L32-L51
def _apply_postprocessing(marc_xml, xml, func, uuid, url): """ Apply `func` to all ``<mods:mods>`` tags from `xml`. Insert UUID. Args: marc_xml (str): Original Aleph record. xml (str): XML which will be postprocessed. func (fn): Function, which will be used for postprocessing. ...
[ "def", "_apply_postprocessing", "(", "marc_xml", ",", "xml", ",", "func", ",", "uuid", ",", "url", ")", ":", "dom", "=", "dhtmlparser", ".", "parseString", "(", "xml", ")", "return", "[", "func", "(", "marc_xml", ",", "mods_tag", ",", "uuid", ",", "cnt...
Apply `func` to all ``<mods:mods>`` tags from `xml`. Insert UUID. Args: marc_xml (str): Original Aleph record. xml (str): XML which will be postprocessed. func (fn): Function, which will be used for postprocessing. uuid (str): UUID, which will be inserted to `xml`. url (str)...
[ "Apply", "func", "to", "all", "<mods", ":", "mods", ">", "tags", "from", "xml", ".", "Insert", "UUID", "." ]
python
train
32.9
hyperledger/indy-plenum
stp_zmq/zstack.py
https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/stp_zmq/zstack.py#L445-L462
async def service(self, limit=None, quota: Optional[Quota] = None) -> int: """ Service `limit` number of received messages in this stack. :param limit: the maximum number of messages to be processed. If None, processes all of the messages in rxMsgs. :return: the number of messag...
[ "async", "def", "service", "(", "self", ",", "limit", "=", "None", ",", "quota", ":", "Optional", "[", "Quota", "]", "=", "None", ")", "->", "int", ":", "if", "self", ".", "listener", ":", "await", "self", ".", "_serviceStack", "(", "self", ".", "a...
Service `limit` number of received messages in this stack. :param limit: the maximum number of messages to be processed. If None, processes all of the messages in rxMsgs. :return: the number of messages processed.
[ "Service", "limit", "number", "of", "received", "messages", "in", "this", "stack", "." ]
python
train
36
uber/tchannel-python
tchannel/container/heap.py
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/container/heap.py#L141-L179
def smallest(heap, predicate): """Finds the index of the smallest item in the heap that matches the given predicate. :param heap: Heap on which this search is being performed. :param predicate: Function that accepts an item from the heap and returns true or false. :returns: ...
[ "def", "smallest", "(", "heap", ",", "predicate", ")", ":", "n", "=", "heap", ".", "size", "(", ")", "# items contains indexes of items yet to be checked.", "items", "=", "deque", "(", "[", "0", "]", ")", "while", "items", ":", "current", "=", "items", "."...
Finds the index of the smallest item in the heap that matches the given predicate. :param heap: Heap on which this search is being performed. :param predicate: Function that accepts an item from the heap and returns true or false. :returns: Index of the first item for which ``pr...
[ "Finds", "the", "index", "of", "the", "smallest", "item", "in", "the", "heap", "that", "matches", "the", "given", "predicate", "." ]
python
train
27.128205
sanger-pathogens/ariba
ariba/link.py
https://github.com/sanger-pathogens/ariba/blob/16a0b1916ce0e886bd22550ba2d648542977001b/ariba/link.py#L100-L107
def insert_size(self): '''Returns insert size, defined as distance from outer edges of reads (and assumes gap length of zero)''' try: distances = self._distance_to_contig_ends() except: raise Error('Error getting insert size from Link:\n' + str(self)) return sum(...
[ "def", "insert_size", "(", "self", ")", ":", "try", ":", "distances", "=", "self", ".", "_distance_to_contig_ends", "(", ")", "except", ":", "raise", "Error", "(", "'Error getting insert size from Link:\\n'", "+", "str", "(", "self", ")", ")", "return", "sum",...
Returns insert size, defined as distance from outer edges of reads (and assumes gap length of zero)
[ "Returns", "insert", "size", "defined", "as", "distance", "from", "outer", "edges", "of", "reads", "(", "and", "assumes", "gap", "length", "of", "zero", ")" ]
python
train
40.375
onnx/onnx-mxnet
onnx_mxnet/import_onnx.py
https://github.com/onnx/onnx-mxnet/blob/b602d75c5a01f5ed8f68b11150a06374f058a86b/onnx_mxnet/import_onnx.py#L21-L55
def _convert_operator(op_name, attrs, identity_list=None, convert_map=None): """Convert from onnx operator to mxnet operator. The converter must specify conversions explicitly for incompatible name, and apply handlers to operator attributes. Parameters ---------- op_name : str Operator ...
[ "def", "_convert_operator", "(", "op_name", ",", "attrs", ",", "identity_list", "=", "None", ",", "convert_map", "=", "None", ")", ":", "identity_list", "=", "identity_list", "if", "identity_list", "else", "_identity_list", "convert_map", "=", "convert_map", "if",...
Convert from onnx operator to mxnet operator. The converter must specify conversions explicitly for incompatible name, and apply handlers to operator attributes. Parameters ---------- op_name : str Operator name, such as Convolution, FullyConnected attrs : dict Dict of operator ...
[ "Convert", "from", "onnx", "operator", "to", "mxnet", "operator", ".", "The", "converter", "must", "specify", "conversions", "explicitly", "for", "incompatible", "name", "and", "apply", "handlers", "to", "operator", "attributes", "." ]
python
train
36.657143
KxSystems/pyq
setup.py
https://github.com/KxSystems/pyq/blob/ad7b807abde94615a7344aaa930bb01fb1552cc5/setup.py#L145-L154
def add_data_file(data_files, target, source): """Add an entry to data_files""" for t, f in data_files: if t == target: break else: data_files.append((target, [])) f = data_files[-1][1] if source not in f: f.append(source)
[ "def", "add_data_file", "(", "data_files", ",", "target", ",", "source", ")", ":", "for", "t", ",", "f", "in", "data_files", ":", "if", "t", "==", "target", ":", "break", "else", ":", "data_files", ".", "append", "(", "(", "target", ",", "[", "]", ...
Add an entry to data_files
[ "Add", "an", "entry", "to", "data_files" ]
python
train
27.3
enkore/i3pystatus
i3pystatus/core/command.py
https://github.com/enkore/i3pystatus/blob/14cfde967cecf79b40e223e35a04600f4c875af7/i3pystatus/core/command.py#L9-L50
def run_through_shell(command, enable_shell=False): """ Retrieve output of a command. Returns a named tuple with three elements: * ``rc`` (integer) Return code of command. * ``out`` (string) Everything that was printed to stdout. * ``err`` (string) Everything that was printed to stderr. Do...
[ "def", "run_through_shell", "(", "command", ",", "enable_shell", "=", "False", ")", ":", "if", "not", "enable_shell", "and", "isinstance", "(", "command", ",", "str", ")", ":", "command", "=", "shlex", ".", "split", "(", "command", ")", "returncode", "=", ...
Retrieve output of a command. Returns a named tuple with three elements: * ``rc`` (integer) Return code of command. * ``out`` (string) Everything that was printed to stdout. * ``err`` (string) Everything that was printed to stderr. Don't use this function with programs that outputs lots of data si...
[ "Retrieve", "output", "of", "a", "command", ".", "Returns", "a", "named", "tuple", "with", "three", "elements", ":" ]
python
train
35.095238
SoCo/SoCo
soco/services.py
https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/services.py#L318-L371
def compose_args(self, action_name, in_argdict): """Compose the argument list from an argument dictionary, with respect for default values. Args: action_name (str): The name of the action to be performed. in_argdict (dict): Arguments as a dict, eg ``{'Ins...
[ "def", "compose_args", "(", "self", ",", "action_name", ",", "in_argdict", ")", ":", "for", "action", "in", "self", ".", "actions", ":", "if", "action", ".", "name", "==", "action_name", ":", "# The found 'action' will be visible from outside the loop", "break", "...
Compose the argument list from an argument dictionary, with respect for default values. Args: action_name (str): The name of the action to be performed. in_argdict (dict): Arguments as a dict, eg ``{'InstanceID': 0, 'Speed': 1}. The values can be ...
[ "Compose", "the", "argument", "list", "from", "an", "argument", "dictionary", "with", "respect", "for", "default", "values", "." ]
python
train
38.833333
alixnovosi/botskeleton
botskeleton/botskeleton.py
https://github.com/alixnovosi/botskeleton/blob/55bfc1b8a3623c10437e4ab2cd0b0ec8d35907a9/botskeleton/botskeleton.py#L373-L395
def update_history(self) -> None: """ Update messaging history on disk. :returns: None """ self.log.debug(f"Saving history. History is: \n{self.history}") jsons = [] for item in self.history: json_item = item.__dict__ # Convert sub-entri...
[ "def", "update_history", "(", "self", ")", "->", "None", ":", "self", ".", "log", ".", "debug", "(", "f\"Saving history. History is: \\n{self.history}\"", ")", "jsons", "=", "[", "]", "for", "item", "in", "self", ".", "history", ":", "json_item", "=", "item"...
Update messaging history on disk. :returns: None
[ "Update", "messaging", "history", "on", "disk", "." ]
python
train
30.913043
djgagne/hagelslag
hagelslag/processing/STObject.py
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/processing/STObject.py#L385-L419
def calc_attribute_statistic(self, attribute, statistic, time): """ Calculate statistics based on the values of an attribute. The following statistics are supported: mean, max, min, std, ptp (range), median, skew (mean - median), and percentile_(percentile value). Args: attr...
[ "def", "calc_attribute_statistic", "(", "self", ",", "attribute", ",", "statistic", ",", "time", ")", ":", "ti", "=", "np", ".", "where", "(", "self", ".", "times", "==", "time", ")", "[", "0", "]", "[", "0", "]", "ma", "=", "np", ".", "where", "...
Calculate statistics based on the values of an attribute. The following statistics are supported: mean, max, min, std, ptp (range), median, skew (mean - median), and percentile_(percentile value). Args: attribute: Attribute extracted from model grid statistic: Name of statistic ...
[ "Calculate", "statistics", "based", "on", "the", "values", "of", "an", "attribute", ".", "The", "following", "statistics", "are", "supported", ":", "mean", "max", "min", "std", "ptp", "(", "range", ")", "median", "skew", "(", "mean", "-", "median", ")", ...
python
train
46.171429
programa-stic/barf-project
barf/core/smt/smttranslator.py
https://github.com/programa-stic/barf-project/blob/18ed9e5eace55f7bf6015ec57f037c364099021c/barf/core/smt/smttranslator.py#L534-L554
def _translate_stm(self, oprnd1, oprnd2, oprnd3): """Return a formula representation of a STM instruction. """ assert oprnd1.size and oprnd3.size assert oprnd3.size == self._address_size op1_var = self._translate_src_oprnd(oprnd1) op3_var = self._translate_src_oprnd(oprn...
[ "def", "_translate_stm", "(", "self", ",", "oprnd1", ",", "oprnd2", ",", "oprnd3", ")", ":", "assert", "oprnd1", ".", "size", "and", "oprnd3", ".", "size", "assert", "oprnd3", ".", "size", "==", "self", ".", "_address_size", "op1_var", "=", "self", ".", ...
Return a formula representation of a STM instruction.
[ "Return", "a", "formula", "representation", "of", "a", "STM", "instruction", "." ]
python
train
32.619048
eaton-lab/toytree
toytree/Drawing.py
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Drawing.py#L693-L707
def get_dims_from_tree_size(self): "Calculate reasonable canvas height and width for tree given N tips" ntips = len(self.ttree) if self.style.orient in ("right", "left"): # height is long tip-wise dimension if not self.style.height: self.style.height = ma...
[ "def", "get_dims_from_tree_size", "(", "self", ")", ":", "ntips", "=", "len", "(", "self", ".", "ttree", ")", "if", "self", ".", "style", ".", "orient", "in", "(", "\"right\"", ",", "\"left\"", ")", ":", "# height is long tip-wise dimension", "if", "not", ...
Calculate reasonable canvas height and width for tree given N tips
[ "Calculate", "reasonable", "canvas", "height", "and", "width", "for", "tree", "given", "N", "tips" ]
python
train
47.2
benvanwerkhoven/kernel_tuner
kernel_tuner/strategies/minimize.py
https://github.com/benvanwerkhoven/kernel_tuner/blob/cfcb5da5e510db494f8219c22566ab65d5fcbd9f/kernel_tuner/strategies/minimize.py#L186-L204
def unscale_and_snap_to_nearest(x, tune_params, eps): """helper func that snaps a scaled variable to the nearest config""" x_u = [i for i in x] for i, v in enumerate(tune_params.values()): #create an evenly spaced linear space to map [0,1]-interval #to actual values, giving each value an equ...
[ "def", "unscale_and_snap_to_nearest", "(", "x", ",", "tune_params", ",", "eps", ")", ":", "x_u", "=", "[", "i", "for", "i", "in", "x", "]", "for", "i", ",", "v", "in", "enumerate", "(", "tune_params", ".", "values", "(", ")", ")", ":", "#create an ev...
helper func that snaps a scaled variable to the nearest config
[ "helper", "func", "that", "snaps", "a", "scaled", "variable", "to", "the", "nearest", "config" ]
python
train
40.947368
sernst/cauldron
cauldron/cli/sync/comm.py
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/sync/comm.py#L40-L65
def parse_http_response(http_response: HttpResponse) -> 'environ.Response': """ Returns a Cauldron response object parsed from the serialized JSON data specified in the http_response argument. If the response doesn't contain valid Cauldron response data, an error Cauldron response object is returned...
[ "def", "parse_http_response", "(", "http_response", ":", "HttpResponse", ")", "->", "'environ.Response'", ":", "try", ":", "response", "=", "environ", ".", "Response", ".", "deserialize", "(", "http_response", ".", "json", "(", ")", ")", "except", "Exception", ...
Returns a Cauldron response object parsed from the serialized JSON data specified in the http_response argument. If the response doesn't contain valid Cauldron response data, an error Cauldron response object is returned instead. :param http_response: The response object from an http request th...
[ "Returns", "a", "Cauldron", "response", "object", "parsed", "from", "the", "serialized", "JSON", "data", "specified", "in", "the", "http_response", "argument", ".", "If", "the", "response", "doesn", "t", "contain", "valid", "Cauldron", "response", "data", "an", ...
python
train
36.923077
lacava/few
few/variation.py
https://github.com/lacava/few/blob/5c72044425e9a5d73b8dc2cbb9b96e873dcb5b4a/few/variation.py#L111-L171
def cross(self,p_i,p_j, max_depth = 2): """subtree-like swap crossover between programs p_i and p_j.""" # only choose crossover points for out_types available in both programs # pdb.set_trace() # determine possible outttypes types_p_i = [t for t in [p.out_type for p in p_i]] ...
[ "def", "cross", "(", "self", ",", "p_i", ",", "p_j", ",", "max_depth", "=", "2", ")", ":", "# only choose crossover points for out_types available in both programs", "# pdb.set_trace()", "# determine possible outttypes", "types_p_i", "=", "[", "t", "for", "t", "in", "...
subtree-like swap crossover between programs p_i and p_j.
[ "subtree", "-", "like", "swap", "crossover", "between", "programs", "p_i", "and", "p_j", "." ]
python
train
41.754098
bcbio/bcbio-nextgen
bcbio/variation/prioritize.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/prioritize.py#L148-L161
def _calc_priority_filter(row, pops): """Calculate the priority filter based on external associated data. - Pass high/medium impact variants not found in population databases - Pass variants found in COSMIC or Clinvar provided they don't have two additional reasons to filter (found in multiple extern...
[ "def", "_calc_priority_filter", "(", "row", ",", "pops", ")", ":", "filters", "=", "[", "]", "passes", "=", "[", "]", "passes", ".", "extend", "(", "_find_known", "(", "row", ")", ")", "filters", ".", "extend", "(", "_known_populations", "(", "row", ",...
Calculate the priority filter based on external associated data. - Pass high/medium impact variants not found in population databases - Pass variants found in COSMIC or Clinvar provided they don't have two additional reasons to filter (found in multiple external populations)
[ "Calculate", "the", "priority", "filter", "based", "on", "external", "associated", "data", "." ]
python
train
42
MonashBI/arcana
arcana/processor/base.py
https://github.com/MonashBI/arcana/blob/d6271a29d13733d00422d11417af8d200be62acc/arcana/processor/base.py#L935-L964
def _dialate_array(self, array, iterators): """ 'Dialates' a to_process/to_protect array to include all subject and/or visits if the pipeline contains any joins over the corresponding iterators. Parameters ---------- array : np.array[M, N] The array t...
[ "def", "_dialate_array", "(", "self", ",", "array", ",", "iterators", ")", ":", "if", "not", "iterators", ":", "return", "array", "dialated", "=", "np", ".", "copy", "(", "array", ")", "if", "self", ".", "study", ".", "SUBJECT_ID", "in", "iterators", "...
'Dialates' a to_process/to_protect array to include all subject and/or visits if the pipeline contains any joins over the corresponding iterators. Parameters ---------- array : np.array[M, N] The array to potentially dialate iterators : set[str] T...
[ "Dialates", "a", "to_process", "/", "to_protect", "array", "to", "include", "all", "subject", "and", "/", "or", "visits", "if", "the", "pipeline", "contains", "any", "joins", "over", "the", "corresponding", "iterators", "." ]
python
train
35.266667
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L912-L944
def _at(self, idx): """Returns a view of the array sliced at `idx` in the first dim. This is called through ``x[idx]``. Parameters ---------- idx : int index for slicing the `NDArray` in the first dim. Returns ------- NDArray `NDA...
[ "def", "_at", "(", "self", ",", "idx", ")", ":", "handle", "=", "NDArrayHandle", "(", ")", "if", "idx", "<", "0", ":", "length", "=", "self", ".", "shape", "[", "0", "]", "idx", "+=", "length", "if", "idx", "<", "0", ":", "raise", "IndexError", ...
Returns a view of the array sliced at `idx` in the first dim. This is called through ``x[idx]``. Parameters ---------- idx : int index for slicing the `NDArray` in the first dim. Returns ------- NDArray `NDArray` sharing the memory with t...
[ "Returns", "a", "view", "of", "the", "array", "sliced", "at", "idx", "in", "the", "first", "dim", ".", "This", "is", "called", "through", "x", "[", "idx", "]", "." ]
python
train
32.515152
jmoiron/johnny-cache
johnny/cache.py
https://github.com/jmoiron/johnny-cache/blob/d96ea94c5dfcde517ff8f65d6ba4e435d8a0168c/johnny/cache.py#L67-L76
def invalidate(*tables, **kwargs): """Invalidate the current generation for one or more tables. The arguments can be either strings representing database table names or models. Pass in kwarg ``using`` to set the database.""" backend = get_backend() db = kwargs.get('using', 'default') if backe...
[ "def", "invalidate", "(", "*", "tables", ",", "*", "*", "kwargs", ")", ":", "backend", "=", "get_backend", "(", ")", "db", "=", "kwargs", ".", "get", "(", "'using'", ",", "'default'", ")", "if", "backend", ".", "_patched", ":", "for", "t", "in", "m...
Invalidate the current generation for one or more tables. The arguments can be either strings representing database table names or models. Pass in kwarg ``using`` to set the database.
[ "Invalidate", "the", "current", "generation", "for", "one", "or", "more", "tables", ".", "The", "arguments", "can", "be", "either", "strings", "representing", "database", "table", "names", "or", "models", ".", "Pass", "in", "kwarg", "using", "to", "set", "th...
python
train
42.3
phaethon/kamene
kamene/pton_ntop.py
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/pton_ntop.py#L64-L90
def inet_ntop(af, addr): """Convert an IP address from binary form into text represenation""" if af == socket.AF_INET: return inet_ntoa(addr) elif af == socket.AF_INET6: # IPv6 addresses have 128bits (16 bytes) if len(addr) != 16: raise Exception("Illegal syntax for IP ad...
[ "def", "inet_ntop", "(", "af", ",", "addr", ")", ":", "if", "af", "==", "socket", ".", "AF_INET", ":", "return", "inet_ntoa", "(", "addr", ")", "elif", "af", "==", "socket", ".", "AF_INET6", ":", "# IPv6 addresses have 128bits (16 bytes)", "if", "len", "("...
Convert an IP address from binary form into text represenation
[ "Convert", "an", "IP", "address", "from", "binary", "form", "into", "text", "represenation" ]
python
train
41.740741
bretth/woven
woven/virtualenv.py
https://github.com/bretth/woven/blob/ec1da7b401a335f43129e7115fe7a4d145649f1e/woven/virtualenv.py#L223-L329
def pip_install_requirements(): """ Install on current installed virtualenv version from a pip bundle [dist/project name-version].zip or pip ``req.txt``|``requirements.txt`` or a env.pip_requirements list. By default it will look for a zip bundle in the dist directory first then a requirements file...
[ "def", "pip_install_requirements", "(", ")", ":", "if", "not", "version_state", "(", "'mkvirtualenv'", ")", ":", "print", "env", ".", "host", ",", "'Error: Cannot run pip_install_requirements. A virtualenv is not created for this version. Run mkvirtualenv first'", "return", "if...
Install on current installed virtualenv version from a pip bundle [dist/project name-version].zip or pip ``req.txt``|``requirements.txt`` or a env.pip_requirements list. By default it will look for a zip bundle in the dist directory first then a requirements file. The limitations of installing re...
[ "Install", "on", "current", "installed", "virtualenv", "version", "from", "a", "pip", "bundle", "[", "dist", "/", "project", "name", "-", "version", "]", ".", "zip", "or", "pip", "req", ".", "txt", "|", "requirements", ".", "txt", "or", "a", "env", "."...
python
train
42.504673
mwshinn/paranoidscientist
paranoid/decorators.py
https://github.com/mwshinn/paranoidscientist/blob/a5e9198bc40b0a985174ad643cc5d6d0c46efdcd/paranoid/decorators.py#L379-L399
def paranoidconfig(**kwargs): """A function decorator to set a local setting. Settings may be set either globally (using settings.Settings.set()) or locally using this decorator. The setting name should be passed as a keyword argument, and the value to assign the setting should be passed as the va...
[ "def", "paranoidconfig", "(", "*", "*", "kwargs", ")", ":", "def", "_decorator", "(", "func", ")", ":", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", ":", "Settings", ".", "_set", "(", "k", ",", "v", ",", "function", "=", "func", ...
A function decorator to set a local setting. Settings may be set either globally (using settings.Settings.set()) or locally using this decorator. The setting name should be passed as a keyword argument, and the value to assign the setting should be passed as the value. See settings.Settings for t...
[ "A", "function", "decorator", "to", "set", "a", "local", "setting", "." ]
python
train
32.142857
PyAr/fades
fades/logger.py
https://github.com/PyAr/fades/blob/e5ea457b09b105f321d4f81772f25e8695159604/fades/logger.py#L45-L50
def emit(self, record): """Call father's emit, but salute first (just once).""" if not self._already_saluted: self._already_saluted = True self._logger.info(SALUTATION) super().emit(record)
[ "def", "emit", "(", "self", ",", "record", ")", ":", "if", "not", "self", ".", "_already_saluted", ":", "self", ".", "_already_saluted", "=", "True", "self", ".", "_logger", ".", "info", "(", "SALUTATION", ")", "super", "(", ")", ".", "emit", "(", "r...
Call father's emit, but salute first (just once).
[ "Call", "father", "s", "emit", "but", "salute", "first", "(", "just", "once", ")", "." ]
python
train
38.666667
materialsproject/pymatgen-db
matgendb/util.py
https://github.com/materialsproject/pymatgen-db/blob/02e4351c2cea431407644f49193e8bf43ed39b9a/matgendb/util.py#L102-L108
def csv_dict(d): """Format dict to a string with comma-separated values. """ if len(d) == 0: return "{}" return "{" + ', '.join(["'{}': {}".format(k, quotable(v)) for k, v in d.items()]) + "}"
[ "def", "csv_dict", "(", "d", ")", ":", "if", "len", "(", "d", ")", "==", "0", ":", "return", "\"{}\"", "return", "\"{\"", "+", "', '", ".", "join", "(", "[", "\"'{}': {}\"", ".", "format", "(", "k", ",", "quotable", "(", "v", ")", ")", "for", "...
Format dict to a string with comma-separated values.
[ "Format", "dict", "to", "a", "string", "with", "comma", "-", "separated", "values", "." ]
python
train
34
coursera-dl/coursera-dl
fabfile.py
https://github.com/coursera-dl/coursera-dl/blob/9b434bcf3c4011bf3181429fe674633ae5fb7d4d/fabfile.py#L84-L93
def release(): """Release a new version""" release_check() build() print("Releasing %s version %s." % (env.projname, env.version)) local("git tag %s" % env.version) local('gpg --detach-sign --armor dist/coursera-*.tar.gz*') local('twine upload dist/coursera-*.tar.gz*') local("git push") ...
[ "def", "release", "(", ")", ":", "release_check", "(", ")", "build", "(", ")", "print", "(", "\"Releasing %s version %s.\"", "%", "(", "env", ".", "projname", ",", "env", ".", "version", ")", ")", "local", "(", "\"git tag %s\"", "%", "env", ".", "version...
Release a new version
[ "Release", "a", "new", "version" ]
python
train
33.9
basho/riak-python-client
riak/transports/http/transport.py
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/http/transport.py#L781-L801
def get_preflist(self, bucket, key): """ Get the preflist for a bucket/key :param bucket: Riak Bucket :type bucket: :class:`~riak.bucket.RiakBucket` :param key: Riak Key :type key: string :rtype: list of dicts """ if not self.preflists(): ...
[ "def", "get_preflist", "(", "self", ",", "bucket", ",", "key", ")", ":", "if", "not", "self", ".", "preflists", "(", ")", ":", "raise", "NotImplementedError", "(", "\"fetching preflists is not supported.\"", ")", "bucket_type", "=", "self", ".", "_get_bucket_typ...
Get the preflist for a bucket/key :param bucket: Riak Bucket :type bucket: :class:`~riak.bucket.RiakBucket` :param key: Riak Key :type key: string :rtype: list of dicts
[ "Get", "the", "preflist", "for", "a", "bucket", "/", "key" ]
python
train
36.571429
tkrajina/git-plus
gitutils/__init__.py
https://github.com/tkrajina/git-plus/blob/6adf9ae5c695feab5e8ed18f93777ac05dd4957c/gitutils/__init__.py#L108-L112
def is_changed(): """ Checks if current project has any noncommited changes. """ executed, changed_lines = execute_git('status --porcelain', output=False) merge_not_finished = mod_path.exists('.git/MERGE_HEAD') return changed_lines.strip() or merge_not_finished
[ "def", "is_changed", "(", ")", ":", "executed", ",", "changed_lines", "=", "execute_git", "(", "'status --porcelain'", ",", "output", "=", "False", ")", "merge_not_finished", "=", "mod_path", ".", "exists", "(", "'.git/MERGE_HEAD'", ")", "return", "changed_lines",...
Checks if current project has any noncommited changes.
[ "Checks", "if", "current", "project", "has", "any", "noncommited", "changes", "." ]
python
train
54.6
atlassian-api/atlassian-python-api
atlassian/jira.py
https://github.com/atlassian-api/atlassian-python-api/blob/540d269905c3e7547b666fe30c647b2d512cf358/atlassian/jira.py#L143-L147
def user_disable_throw_rest_endpoint(self, username, url='rest/scriptrunner/latest/custom/disableUser', param='userName'): """The disable method throw own rest enpoint""" url = "{}?{}={}".format(url, param, username) return self.get(path=url)
[ "def", "user_disable_throw_rest_endpoint", "(", "self", ",", "username", ",", "url", "=", "'rest/scriptrunner/latest/custom/disableUser'", ",", "param", "=", "'userName'", ")", ":", "url", "=", "\"{}?{}={}\"", ".", "format", "(", "url", ",", "param", ",", "usernam...
The disable method throw own rest enpoint
[ "The", "disable", "method", "throw", "own", "rest", "enpoint" ]
python
train
60.6
materialsproject/pymatgen
pymatgen/electronic_structure/boltztrap.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/electronic_structure/boltztrap.py#L2312-L2319
def seebeck_spb(eta,Lambda=0.5): """ Seebeck analytic formula in the single parabolic model """ from fdint import fdk return constants.k/constants.e * ((2. + Lambda) * fdk( 1.+ Lambda, eta)/ ((1.+Lambda)*fdk(Lambda, eta))- eta) * 1e+6
[ "def", "seebeck_spb", "(", "eta", ",", "Lambda", "=", "0.5", ")", ":", "from", "fdint", "import", "fdk", "return", "constants", ".", "k", "/", "constants", ".", "e", "*", "(", "(", "2.", "+", "Lambda", ")", "*", "fdk", "(", "1.", "+", "Lambda", "...
Seebeck analytic formula in the single parabolic model
[ "Seebeck", "analytic", "formula", "in", "the", "single", "parabolic", "model" ]
python
train
34.25
apple/turicreate
deps/src/libxml2-2.9.1/python/libxml2.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L6041-L6045
def htmlDocContentDumpOutput(self, cur, encoding): """Dump an HTML document. Formating return/spaces are added. """ if cur is None: cur__o = None else: cur__o = cur._o libxml2mod.htmlDocContentDumpOutput(self._o, cur__o, encoding)
[ "def", "htmlDocContentDumpOutput", "(", "self", ",", "cur", ",", "encoding", ")", ":", "if", "cur", "is", "None", ":", "cur__o", "=", "None", "else", ":", "cur__o", "=", "cur", ".", "_o", "libxml2mod", ".", "htmlDocContentDumpOutput", "(", "self", ".", "...
Dump an HTML document. Formating return/spaces are added.
[ "Dump", "an", "HTML", "document", ".", "Formating", "return", "/", "spaces", "are", "added", "." ]
python
train
51.6
shmuelamar/cbox
examples/head.py
https://github.com/shmuelamar/cbox/blob/2d0cda5b3f61a55e530251430bf3d460dcd3732e/examples/head.py#L8-L15
def head(line, n: int): """returns the first `n` lines""" global counter counter += 1 if counter > n: raise cbox.Stop() # can also raise StopIteration() return line
[ "def", "head", "(", "line", ",", "n", ":", "int", ")", ":", "global", "counter", "counter", "+=", "1", "if", "counter", ">", "n", ":", "raise", "cbox", ".", "Stop", "(", ")", "# can also raise StopIteration()", "return", "line" ]
returns the first `n` lines
[ "returns", "the", "first", "n", "lines" ]
python
train
23.375
accraze/python-markov-novel
src/markov_novel/novel.py
https://github.com/accraze/python-markov-novel/blob/ff451639e93a3ac11fb0268b92bc0cffc00bfdbe/src/markov_novel/novel.py#L23-L31
def _compose_chapters(self): """ Creates a chapters and appends them to list """ for count in range(self.chapter_count): chapter_num = count + 1 c = Chapter(self.markov, chapter_num) self.chapters.append(c)
[ "def", "_compose_chapters", "(", "self", ")", ":", "for", "count", "in", "range", "(", "self", ".", "chapter_count", ")", ":", "chapter_num", "=", "count", "+", "1", "c", "=", "Chapter", "(", "self", ".", "markov", ",", "chapter_num", ")", "self", ".",...
Creates a chapters and appends them to list
[ "Creates", "a", "chapters", "and", "appends", "them", "to", "list" ]
python
train
30.444444
mathiasertl/django-ca
ca/django_ca/utils.py
https://github.com/mathiasertl/django-ca/blob/976d7ea05276320f20daed2a6d59c8f5660fe976/ca/django_ca/utils.py#L320-L342
def validate_email(addr): """Validate an email address. This function raises ``ValueError`` if the email address is not valid. >>> validate_email('foo@bar.com') 'foo@bar.com' >>> validate_email('foo@bar com') Traceback (most recent call last): ... ValueError: Invalid domain: bar co...
[ "def", "validate_email", "(", "addr", ")", ":", "if", "'@'", "not", "in", "addr", ":", "raise", "ValueError", "(", "'Invalid email address: %s'", "%", "addr", ")", "node", ",", "domain", "=", "addr", ".", "split", "(", "'@'", ",", "1", ")", "try", ":",...
Validate an email address. This function raises ``ValueError`` if the email address is not valid. >>> validate_email('foo@bar.com') 'foo@bar.com' >>> validate_email('foo@bar com') Traceback (most recent call last): ... ValueError: Invalid domain: bar com
[ "Validate", "an", "email", "address", "." ]
python
train
27.26087
tehmaze/ipcalc
ipcalc.py
https://github.com/tehmaze/ipcalc/blob/d436b95d2783347c3e0084d76ec3c52d1f5d2f0b/ipcalc.py#L544-L558
def to_reverse(self): """Convert the IP address to a PTR record. Using the .in-addr.arpa zone for IPv4 and .ip6.arpa for IPv6 addresses. >>> ip = IP('192.0.2.42') >>> print(ip.to_reverse()) 42.2.0.192.in-addr.arpa >>> print(ip.to_ipv6().to_reverse()) 0.0.0.0.0.0...
[ "def", "to_reverse", "(", "self", ")", ":", "if", "self", ".", "v", "==", "4", ":", "return", "'.'", ".", "join", "(", "list", "(", "self", ".", "dq", ".", "split", "(", "'.'", ")", "[", ":", ":", "-", "1", "]", ")", "+", "[", "'in-addr'", ...
Convert the IP address to a PTR record. Using the .in-addr.arpa zone for IPv4 and .ip6.arpa for IPv6 addresses. >>> ip = IP('192.0.2.42') >>> print(ip.to_reverse()) 42.2.0.192.in-addr.arpa >>> print(ip.to_ipv6().to_reverse()) 0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.a.2....
[ "Convert", "the", "IP", "address", "to", "a", "PTR", "record", "." ]
python
train
37.933333
ergo/ziggurat_foundations
ziggurat_foundations/models/user.py
https://github.com/ergo/ziggurat_foundations/blob/9eeec894d08e8d7defa60ddc04b63f69cd4cbeba/ziggurat_foundations/models/user.py#L77-L83
def security_code_date(self): """ Date of user's security code update """ return sa.Column( sa.TIMESTAMP(timezone=False), default=datetime(2000, 1, 1), server_default="2000-01-01 01:01", )
[ "def", "security_code_date", "(", "self", ")", ":", "return", "sa", ".", "Column", "(", "sa", ".", "TIMESTAMP", "(", "timezone", "=", "False", ")", ",", "default", "=", "datetime", "(", "2000", ",", "1", ",", "1", ")", ",", "server_default", "=", "\"...
Date of user's security code update
[ "Date", "of", "user", "s", "security", "code", "update" ]
python
train
34.571429
boriel/zxbasic
arch/zx48k/backend/__pload.py
https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__pload.py#L270-L333
def _pstore16(ins): """ Stores 2nd parameter at stack pointer (SP) + X, being X 1st parameter. 1st operand must be a SIGNED integer. """ value = ins.quad[2] offset = ins.quad[1] indirect = offset[0] == '*' size = 1 if indirect: offset = offset[1:] I = int(offset) if...
[ "def", "_pstore16", "(", "ins", ")", ":", "value", "=", "ins", ".", "quad", "[", "2", "]", "offset", "=", "ins", ".", "quad", "[", "1", "]", "indirect", "=", "offset", "[", "0", "]", "==", "'*'", "size", "=", "1", "if", "indirect", ":", "offset...
Stores 2nd parameter at stack pointer (SP) + X, being X 1st parameter. 1st operand must be a SIGNED integer.
[ "Stores", "2nd", "parameter", "at", "stack", "pointer", "(", "SP", ")", "+", "X", "being", "X", "1st", "parameter", "." ]
python
train
26.03125
devassistant/devassistant
devassistant/cli/cli_runner.py
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/cli/cli_runner.py#L84-L93
def inform_of_short_bin_name(cls, binary): """Historically, we had "devassistant" binary, but we chose to go with shorter "da". We still allow "devassistant", but we recommend using "da". """ binary = os.path.splitext(os.path.basename(binary))[0] if binary != 'da': ms...
[ "def", "inform_of_short_bin_name", "(", "cls", ",", "binary", ")", ":", "binary", "=", "os", ".", "path", ".", "splitext", "(", "os", ".", "path", ".", "basename", "(", "binary", ")", ")", "[", "0", "]", "if", "binary", "!=", "'da'", ":", "msg", "=...
Historically, we had "devassistant" binary, but we chose to go with shorter "da". We still allow "devassistant", but we recommend using "da".
[ "Historically", "we", "had", "devassistant", "binary", "but", "we", "chose", "to", "go", "with", "shorter", "da", ".", "We", "still", "allow", "devassistant", "but", "we", "recommend", "using", "da", "." ]
python
train
51.7
saltstack/salt
salt/states/pyenv.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/pyenv.py#L200-L219
def install_pyenv(name, user=None): ''' Install pyenv if not installed. Allows you to require pyenv be installed prior to installing the plugins. Useful if you want to install pyenv plugins via the git or file modules and need them installed before installing any rubies. Use the pyenv.root conf...
[ "def", "install_pyenv", "(", "name", ",", "user", "=", "None", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'result'", ":", "None", ",", "'comment'", ":", "''", ",", "'changes'", ":", "{", "}", "}", "if", "__opts__", "[", "'test'", "]", ...
Install pyenv if not installed. Allows you to require pyenv be installed prior to installing the plugins. Useful if you want to install pyenv plugins via the git or file modules and need them installed before installing any rubies. Use the pyenv.root configuration option to set the path for pyenv if yo...
[ "Install", "pyenv", "if", "not", "installed", ".", "Allows", "you", "to", "require", "pyenv", "be", "installed", "prior", "to", "installing", "the", "plugins", ".", "Useful", "if", "you", "want", "to", "install", "pyenv", "plugins", "via", "the", "git", "o...
python
train
34.6
spotify/luigi
luigi/contrib/ecs.py
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/ecs.py#L68-L85
def _get_task_statuses(task_ids, cluster): """ Retrieve task statuses from ECS API Returns list of {RUNNING|PENDING|STOPPED} for each id in task_ids """ response = client.describe_tasks(tasks=task_ids, cluster=cluster) # Error checking if response['failures'] != []: raise Exception...
[ "def", "_get_task_statuses", "(", "task_ids", ",", "cluster", ")", ":", "response", "=", "client", ".", "describe_tasks", "(", "tasks", "=", "task_ids", ",", "cluster", "=", "cluster", ")", "# Error checking", "if", "response", "[", "'failures'", "]", "!=", ...
Retrieve task statuses from ECS API Returns list of {RUNNING|PENDING|STOPPED} for each id in task_ids
[ "Retrieve", "task", "statuses", "from", "ECS", "API" ]
python
train
36.333333
BlueBrain/hpcbench
hpcbench/cli/benumb.py
https://github.com/BlueBrain/hpcbench/blob/192d0ec142b897157ec25f131d1ef28f84752592/hpcbench/cli/benumb.py#L19-L25
def main(argv=None): """ben-umb entry point""" arguments = cli_common(__doc__, argv=argv) driver = CampaignDriver(arguments['CAMPAIGN-DIR'], expandcampvars=False) driver(no_exec=True) if argv is not None: return driver
[ "def", "main", "(", "argv", "=", "None", ")", ":", "arguments", "=", "cli_common", "(", "__doc__", ",", "argv", "=", "argv", ")", "driver", "=", "CampaignDriver", "(", "arguments", "[", "'CAMPAIGN-DIR'", "]", ",", "expandcampvars", "=", "False", ")", "dr...
ben-umb entry point
[ "ben", "-", "umb", "entry", "point" ]
python
train
34.285714
rwl/pylon
pylon/io/rst.py
https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/io/rst.py#L312-L355
def write_how_many(self, file): """ Writes component numbers to a table. """ report = CaseReport(self.case) # Map component labels to attribute names components = [("Bus", "n_buses"), ("Generator", "n_generators"), ("Committed Generator", "n_online_generators"), ...
[ "def", "write_how_many", "(", "self", ",", "file", ")", ":", "report", "=", "CaseReport", "(", "self", ".", "case", ")", "# Map component labels to attribute names", "components", "=", "[", "(", "\"Bus\"", ",", "\"n_buses\"", ")", ",", "(", "\"Generator\"", ",...
Writes component numbers to a table.
[ "Writes", "component", "numbers", "to", "a", "table", "." ]
python
train
31.159091
GPflow/GPflow
gpflow/kernels.py
https://github.com/GPflow/GPflow/blob/549394f0b1b0696c7b521a065e49bdae6e7acf27/gpflow/kernels.py#L330-L343
def K(self, X, X2=None, presliced=False): """ Calculates the kernel matrix K(X, X2) (or K(X, X) if X2 is None). Handles the slicing as well as scaling and computes k(x, x') = k(r), where r² = ((x - x')/lengthscales)². Internally, this calls self.K_r2(r²), which in turn computes ...
[ "def", "K", "(", "self", ",", "X", ",", "X2", "=", "None", ",", "presliced", "=", "False", ")", ":", "if", "not", "presliced", ":", "X", ",", "X2", "=", "self", ".", "_slice", "(", "X", ",", "X2", ")", "return", "self", ".", "K_r2", "(", "sel...
Calculates the kernel matrix K(X, X2) (or K(X, X) if X2 is None). Handles the slicing as well as scaling and computes k(x, x') = k(r), where r² = ((x - x')/lengthscales)². Internally, this calls self.K_r2(r²), which in turn computes the square-root and calls self.K_r(r). Classes impleme...
[ "Calculates", "the", "kernel", "matrix", "K", "(", "X", "X2", ")", "(", "or", "K", "(", "X", "X", ")", "if", "X2", "is", "None", ")", ".", "Handles", "the", "slicing", "as", "well", "as", "scaling", "and", "computes", "k", "(", "x", "x", ")", "...
python
train
48.071429
terrycain/aioboto3
aioboto3/s3/inject.py
https://github.com/terrycain/aioboto3/blob/0fd192175461f7bb192f3ed9a872591caf8474ac/aioboto3/s3/inject.py#L33-L95
async def download_fileobj(self, Bucket, Key, Fileobj, ExtraArgs=None, Callback=None, Config=None): """Download an object from S3 to a file-like object. The file-like object must be in binary mode. This is a managed transfer which will perform a multipart download in multiple threads if necessary. ...
[ "async", "def", "download_fileobj", "(", "self", ",", "Bucket", ",", "Key", ",", "Fileobj", ",", "ExtraArgs", "=", "None", ",", "Callback", "=", "None", ",", "Config", "=", "None", ")", ":", "try", ":", "resp", "=", "await", "self", ".", "get_object", ...
Download an object from S3 to a file-like object. The file-like object must be in binary mode. This is a managed transfer which will perform a multipart download in multiple threads if necessary. Usage:: import boto3 s3 = boto3.client('s3') with open('filename', 'wb') as dat...
[ "Download", "an", "object", "from", "S3", "to", "a", "file", "-", "like", "object", "." ]
python
train
29.396825
EconForge/dolo
dolo/algos/simulations.py
https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/dolo/algos/simulations.py#L47-L172
def simulate(model, dr, N=1, T=40, s0=None, i0=None, m0=None, driving_process=None, seed=42, stochastic=True): ''' Simulate a model using the specified decision rule. Parameters ---------- model: NumericModel dr: decision rule s0: ndarray initial state where all simulatio...
[ "def", "simulate", "(", "model", ",", "dr", ",", "N", "=", "1", ",", "T", "=", "40", ",", "s0", "=", "None", ",", "i0", "=", "None", ",", "m0", "=", "None", ",", "driving_process", "=", "None", ",", "seed", "=", "42", ",", "stochastic", "=", ...
Simulate a model using the specified decision rule. Parameters ---------- model: NumericModel dr: decision rule s0: ndarray initial state where all simulations start driving_process: ndarray realization of exogenous driving process (drawn randomly if None) N: int ...
[ "Simulate", "a", "model", "using", "the", "specified", "decision", "rule", "." ]
python
train
29.222222
jason-weirather/py-seq-tools
seqtools/simulation/emitter.py
https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/simulation/emitter.py#L166-L190
def emit(self,rlen=150): """Emit a read based on a source sequence""" source_tx = self._source.emit() source_read = self._cutter.cut(source_tx) if self._flip and self.options.rand.random() < 0.5: source_read = source_read.rc() srname = self.options.rand.uuid4() seqfull = FASTQ('@'+se...
[ "def", "emit", "(", "self", ",", "rlen", "=", "150", ")", ":", "source_tx", "=", "self", ".", "_source", ".", "emit", "(", ")", "source_read", "=", "self", ".", "_cutter", ".", "cut", "(", "source_tx", ")", "if", "self", ".", "_flip", "and", "self"...
Emit a read based on a source sequence
[ "Emit", "a", "read", "based", "on", "a", "source", "sequence" ]
python
train
45.4
ArangoDB-Community/pyArango
pyArango/database.py
https://github.com/ArangoDB-Community/pyArango/blob/dd72e5f6c540e5e148943d615ddf7553bb78ce0b/pyArango/database.py#L199-L204
def AQLQuery(self, query, batchSize = 100, rawResults = False, bindVars = {}, options = {}, count = False, fullCount = False, json_encoder = None, **moreArgs) : """Set rawResults = True if you want the query to return dictionnaries instead of Document objects. You can use **moreArgs to ...
[ "def", "AQLQuery", "(", "self", ",", "query", ",", "batchSize", "=", "100", ",", "rawResults", "=", "False", ",", "bindVars", "=", "{", "}", ",", "options", "=", "{", "}", ",", "count", "=", "False", ",", "fullCount", "=", "False", ",", "json_encoder...
Set rawResults = True if you want the query to return dictionnaries instead of Document objects. You can use **moreArgs to pass more arguments supported by the api, such as ttl=60 (time to live)
[ "Set", "rawResults", "=", "True", "if", "you", "want", "the", "query", "to", "return", "dictionnaries", "instead", "of", "Document", "objects", ".", "You", "can", "use", "**", "moreArgs", "to", "pass", "more", "arguments", "supported", "by", "the", "api", ...
python
train
103