repo
stringlengths
7
54
path
stringlengths
4
192
url
stringlengths
87
284
code
stringlengths
78
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
monero-ecosystem/monero-python
monero/wallet.py
https://github.com/monero-ecosystem/monero-python/blob/64149f6323af57a3924f45ed87997d64387c5ee0/monero/wallet.py#L104-L119
def confirmations(self, txn_or_pmt): """ Returns the number of confirmations for given :class:`Transaction <monero.transaction.Transaction>` or :class:`Payment <monero.transaction.Payment>` object. :rtype: int """ if isinstance(txn_or_pmt, Payment): t...
[ "def", "confirmations", "(", "self", ",", "txn_or_pmt", ")", ":", "if", "isinstance", "(", "txn_or_pmt", ",", "Payment", ")", ":", "txn", "=", "txn_or_pmt", ".", "transaction", "else", ":", "txn", "=", "txn_or_pmt", "try", ":", "return", "max", "(", "0",...
Returns the number of confirmations for given :class:`Transaction <monero.transaction.Transaction>` or :class:`Payment <monero.transaction.Payment>` object. :rtype: int
[ "Returns", "the", "number", "of", "confirmations", "for", "given", ":", "class", ":", "Transaction", "<monero", ".", "transaction", ".", "Transaction", ">", "or", ":", "class", ":", "Payment", "<monero", ".", "transaction", ".", "Payment", ">", "object", "."...
python
valid
sethmlarson/virtualbox-python
virtualbox/library.py
https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L29858-L29890
def set_network_settings(self, mtu, sock_snd, sock_rcv, tcp_wnd_snd, tcp_wnd_rcv): """Sets network configuration of the NAT engine. in mtu of type int MTU (maximum transmission unit) of the NAT engine in bytes. in sock_snd of type int Capacity of the socket send buffer ...
[ "def", "set_network_settings", "(", "self", ",", "mtu", ",", "sock_snd", ",", "sock_rcv", ",", "tcp_wnd_snd", ",", "tcp_wnd_rcv", ")", ":", "if", "not", "isinstance", "(", "mtu", ",", "baseinteger", ")", ":", "raise", "TypeError", "(", "\"mtu can only be an in...
Sets network configuration of the NAT engine. in mtu of type int MTU (maximum transmission unit) of the NAT engine in bytes. in sock_snd of type int Capacity of the socket send buffer in bytes when creating a new socket. in sock_rcv of type int Capacity of ...
[ "Sets", "network", "configuration", "of", "the", "NAT", "engine", "." ]
python
train
AkihikoITOH/capybara
capybara/virtualenv/lib/python2.7/site-packages/flask/sessions.py
https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/flask/sessions.py#L198-L222
def get_cookie_domain(self, app): """Helpful helper method that returns the cookie domain that should be used for the session cookie if session cookies are used. """ if app.config['SESSION_COOKIE_DOMAIN'] is not None: return app.config['SESSION_COOKIE_DOMAIN'] if app....
[ "def", "get_cookie_domain", "(", "self", ",", "app", ")", ":", "if", "app", ".", "config", "[", "'SESSION_COOKIE_DOMAIN'", "]", "is", "not", "None", ":", "return", "app", ".", "config", "[", "'SESSION_COOKIE_DOMAIN'", "]", "if", "app", ".", "config", "[", ...
Helpful helper method that returns the cookie domain that should be used for the session cookie if session cookies are used.
[ "Helpful", "helper", "method", "that", "returns", "the", "cookie", "domain", "that", "should", "be", "used", "for", "the", "session", "cookie", "if", "session", "cookies", "are", "used", "." ]
python
test
Chilipp/model-organization
model_organization/__init__.py
https://github.com/Chilipp/model-organization/blob/694d1219c7ed7e1b2b17153afa11bdc21169bca2/model_organization/__init__.py#L1584-L1589
def get_parser(cls): """Function returning the command line parser for this class""" organizer = cls() organizer.setup_parser() organizer._finish_parser() return organizer.parser
[ "def", "get_parser", "(", "cls", ")", ":", "organizer", "=", "cls", "(", ")", "organizer", ".", "setup_parser", "(", ")", "organizer", ".", "_finish_parser", "(", ")", "return", "organizer", ".", "parser" ]
Function returning the command line parser for this class
[ "Function", "returning", "the", "command", "line", "parser", "for", "this", "class" ]
python
train
nion-software/nionswift
nion/swift/model/Utility.py
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/Utility.py#L127-L136
def clean_tuple(t0, clean_item_fn=None): """ Return a json-clean tuple. Will log info message for failures. """ clean_item_fn = clean_item_fn if clean_item_fn else clean_item l = list() for index, item in enumerate(t0): cleaned_item = clean_item_fn(item) l.append(cleaned_item...
[ "def", "clean_tuple", "(", "t0", ",", "clean_item_fn", "=", "None", ")", ":", "clean_item_fn", "=", "clean_item_fn", "if", "clean_item_fn", "else", "clean_item", "l", "=", "list", "(", ")", "for", "index", ",", "item", "in", "enumerate", "(", "t0", ")", ...
Return a json-clean tuple. Will log info message for failures.
[ "Return", "a", "json", "-", "clean", "tuple", ".", "Will", "log", "info", "message", "for", "failures", "." ]
python
train
bodylabs/lace
lace/serialization/dae.py
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/serialization/dae.py#L14-L25
def dumps(mesh): ''' Generates a UTF-8 XML string containing the mesh, in collada format. ''' from lxml import etree dae = mesh_to_collada(mesh) # Update the xmlnode. dae.save() return etree.tostring(dae.xmlnode, encoding='UTF-8')
[ "def", "dumps", "(", "mesh", ")", ":", "from", "lxml", "import", "etree", "dae", "=", "mesh_to_collada", "(", "mesh", ")", "# Update the xmlnode.", "dae", ".", "save", "(", ")", "return", "etree", ".", "tostring", "(", "dae", ".", "xmlnode", ",", "encodi...
Generates a UTF-8 XML string containing the mesh, in collada format.
[ "Generates", "a", "UTF", "-", "8", "XML", "string", "containing", "the", "mesh", "in", "collada", "format", "." ]
python
train
cytoscape/py2cytoscape
py2cytoscape/cyrest/layout.py
https://github.com/cytoscape/py2cytoscape/blob/dd34de8d028f512314d0057168df7fef7c5d5195/py2cytoscape/cyrest/layout.py#L607-L651
def isom(self,coolingFactor=None,EdgeAttribute=None,initialAdaptation=None,\ maxEpoch=None,minAdaptation=None,minRadius=None,network=None,NodeAttribute=None,\ nodeList=None,radius=None,radiusConstantTime=None,singlePartition=None,\ sizeFactor=None,verbose=None): """ Execute the Inverted Self-Organizing Map La...
[ "def", "isom", "(", "self", ",", "coolingFactor", "=", "None", ",", "EdgeAttribute", "=", "None", ",", "initialAdaptation", "=", "None", ",", "maxEpoch", "=", "None", ",", "minAdaptation", "=", "None", ",", "minRadius", "=", "None", ",", "network", "=", ...
Execute the Inverted Self-Organizing Map Layout on a network. :param coolingFactor (string, optional): Cooling factor, in numeric value :param EdgeAttribute (string, optional): The name of the edge column contai ning numeric values that will be used as weights in the layout algor ithm. Only columns containin...
[ "Execute", "the", "Inverted", "Self", "-", "Organizing", "Map", "Layout", "on", "a", "network", "." ]
python
train
twidi/django-extended-choices
extended_choices/helpers.py
https://github.com/twidi/django-extended-choices/blob/bb310c5da4d53685c69173541172e4b813a6afb2/extended_choices/helpers.py#L200-L222
def create_choice_attribute(creator_type, value, choice_entry): """Create an instance of a subclass of ChoiceAttributeMixin for the given value. Parameters ---------- creator_type : type ``ChoiceAttributeMixin`` or a subclass, from which we'll call the ``get_class_for_value`` class-meth...
[ "def", "create_choice_attribute", "(", "creator_type", ",", "value", ",", "choice_entry", ")", ":", "klass", "=", "creator_type", ".", "get_class_for_value", "(", "value", ")", "return", "klass", "(", "value", ",", "choice_entry", ")" ]
Create an instance of a subclass of ChoiceAttributeMixin for the given value. Parameters ---------- creator_type : type ``ChoiceAttributeMixin`` or a subclass, from which we'll call the ``get_class_for_value`` class-method. value : ? The value for which we want to create an inst...
[ "Create", "an", "instance", "of", "a", "subclass", "of", "ChoiceAttributeMixin", "for", "the", "given", "value", "." ]
python
train
GeorgeArgyros/sfalearn
sfalearn/observationtableinit.py
https://github.com/GeorgeArgyros/sfalearn/blob/68a93f507e2fb7d89ca04bd8a8f0da2d6c680443/sfalearn/observationtableinit.py#L155-L198
def _init_smi(self, graph, access_strings_map): """ Args: graph (DFA): The DFA states access_strings_map (list): a dict containing all the access strings for each state Return: list: SMI transition table """ smi = [] for selected_state ...
[ "def", "_init_smi", "(", "self", ",", "graph", ",", "access_strings_map", ")", ":", "smi", "=", "[", "]", "for", "selected_state", "in", "sorted", "(", "graph", ".", "states", ",", "key", "=", "attrgetter", "(", "'initial'", ")", ",", "reverse", "=", "...
Args: graph (DFA): The DFA states access_strings_map (list): a dict containing all the access strings for each state Return: list: SMI transition table
[ "Args", ":", "graph", "(", "DFA", ")", ":", "The", "DFA", "states", "access_strings_map", "(", "list", ")", ":", "a", "dict", "containing", "all", "the", "access", "strings", "for", "each", "state", "Return", ":", "list", ":", "SMI", "transition", "table...
python
train
QunarOPS/qg.core
qg/core/timeutils.py
https://github.com/QunarOPS/qg.core/blob/d5d7e36ea140cfe73e1b1850e8c96960b02a1ed3/qg/core/timeutils.py#L96-L103
def utcnow_ts(): """Timestamp version of our utcnow function.""" if utcnow.override_time is None: # NOTE(kgriffs): This is several times faster # than going through calendar.timegm(...) return int(time.time()) return calendar.timegm(utcnow().timetuple())
[ "def", "utcnow_ts", "(", ")", ":", "if", "utcnow", ".", "override_time", "is", "None", ":", "# NOTE(kgriffs): This is several times faster", "# than going through calendar.timegm(...)", "return", "int", "(", "time", ".", "time", "(", ")", ")", "return", "calendar", ...
Timestamp version of our utcnow function.
[ "Timestamp", "version", "of", "our", "utcnow", "function", "." ]
python
train
bitlabstudio/django-document-library
document_library/south_migrations/0022_move_from_simple_trans_to_hvad.py
https://github.com/bitlabstudio/django-document-library/blob/508737277455f182e81780cfca8d8eceb989a45b/document_library/south_migrations/0022_move_from_simple_trans_to_hvad.py#L27-L49
def forwards(self, orm): "Write your forwards methods here." for category in orm['document_library.DocumentCategory'].objects.all(): for trans_old in orm['document_library.DocumentCategoryTitle'].objects.filter(category=category): orm['document_library.DocumentCategoryTransla...
[ "def", "forwards", "(", "self", ",", "orm", ")", ":", "for", "category", "in", "orm", "[", "'document_library.DocumentCategory'", "]", ".", "objects", ".", "all", "(", ")", ":", "for", "trans_old", "in", "orm", "[", "'document_library.DocumentCategoryTitle'", ...
Write your forwards methods here.
[ "Write", "your", "forwards", "methods", "here", "." ]
python
train
vertexproject/synapse
synapse/lib/crypto/tinfoil.py
https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/lib/crypto/tinfoil.py#L53-L75
def dec(self, byts): ''' Decode an envelope dict and decrypt the given bytes. Args: byts (bytes): Bytes to decrypt. Returns: bytes: Decrypted message. ''' envl = s_msgpack.un(byts) iv = envl.get('iv', b'') asscd = envl.get('asscd'...
[ "def", "dec", "(", "self", ",", "byts", ")", ":", "envl", "=", "s_msgpack", ".", "un", "(", "byts", ")", "iv", "=", "envl", ".", "get", "(", "'iv'", ",", "b''", ")", "asscd", "=", "envl", ".", "get", "(", "'asscd'", ",", "b''", ")", "data", "...
Decode an envelope dict and decrypt the given bytes. Args: byts (bytes): Bytes to decrypt. Returns: bytes: Decrypted message.
[ "Decode", "an", "envelope", "dict", "and", "decrypt", "the", "given", "bytes", "." ]
python
train
log2timeline/dfvfs
dfvfs/vfs/os_file_entry.py
https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/vfs/os_file_entry.py#L209-L215
def access_time(self): """dfdatetime.DateTimeValues: access time or None if not available.""" if self._stat_info is None: return None timestamp = int(self._stat_info.st_atime) return dfdatetime_posix_time.PosixTime(timestamp=timestamp)
[ "def", "access_time", "(", "self", ")", ":", "if", "self", ".", "_stat_info", "is", "None", ":", "return", "None", "timestamp", "=", "int", "(", "self", ".", "_stat_info", ".", "st_atime", ")", "return", "dfdatetime_posix_time", ".", "PosixTime", "(", "tim...
dfdatetime.DateTimeValues: access time or None if not available.
[ "dfdatetime", ".", "DateTimeValues", ":", "access", "time", "or", "None", "if", "not", "available", "." ]
python
train
loli/medpy
medpy/features/intensity.py
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L59-L96
def centerdistance(image, voxelspacing = None, mask = slice(None)): r""" Takes a simple or multi-spectral image and returns its voxel-wise center distance in mm. A multi-spectral image must be supplied as a list or tuple of its spectra. Optionally a binary mask can be supplied to select the voxels ...
[ "def", "centerdistance", "(", "image", ",", "voxelspacing", "=", "None", ",", "mask", "=", "slice", "(", "None", ")", ")", ":", "if", "type", "(", "image", ")", "==", "tuple", "or", "type", "(", "image", ")", "==", "list", ":", "image", "=", "image...
r""" Takes a simple or multi-spectral image and returns its voxel-wise center distance in mm. A multi-spectral image must be supplied as a list or tuple of its spectra. Optionally a binary mask can be supplied to select the voxels for which the feature should be extracted. The center dista...
[ "r", "Takes", "a", "simple", "or", "multi", "-", "spectral", "image", "and", "returns", "its", "voxel", "-", "wise", "center", "distance", "in", "mm", ".", "A", "multi", "-", "spectral", "image", "must", "be", "supplied", "as", "a", "list", "or", "tupl...
python
train
MartinThoma/hwrt
hwrt/utils.py
https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/utils.py#L143-L153
def get_template_folder(): """Get path to the folder where th HTML templates are.""" cfg = get_project_configuration() if 'templates' not in cfg: home = os.path.expanduser("~") rcfile = os.path.join(home, ".hwrtrc") cfg['templates'] = pkg_resources.resource_filename('hwrt', ...
[ "def", "get_template_folder", "(", ")", ":", "cfg", "=", "get_project_configuration", "(", ")", "if", "'templates'", "not", "in", "cfg", ":", "home", "=", "os", ".", "path", ".", "expanduser", "(", "\"~\"", ")", "rcfile", "=", "os", ".", "path", ".", "...
Get path to the folder where th HTML templates are.
[ "Get", "path", "to", "the", "folder", "where", "th", "HTML", "templates", "are", "." ]
python
train
Dallinger/Dallinger
dallinger/heroku/tools.py
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/heroku/tools.py#L262-L270
def scale_down_dynos(self): """Turn off web and worker dynos, plus clock process if there is one and it's active. """ processes = ["web", "worker"] if self.clock_is_on: processes.append("clock") for process in processes: self.scale_down_dyno(proces...
[ "def", "scale_down_dynos", "(", "self", ")", ":", "processes", "=", "[", "\"web\"", ",", "\"worker\"", "]", "if", "self", ".", "clock_is_on", ":", "processes", ".", "append", "(", "\"clock\"", ")", "for", "process", "in", "processes", ":", "self", ".", "...
Turn off web and worker dynos, plus clock process if there is one and it's active.
[ "Turn", "off", "web", "and", "worker", "dynos", "plus", "clock", "process", "if", "there", "is", "one", "and", "it", "s", "active", "." ]
python
train
ThreatConnect-Inc/tcex
tcex/tcex_bin.py
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_bin.py#L96-L106
def db_update_record(self, table_name, column, value): """Insert records into DB. Args: table_name (str): The name of the table. column (str): The column name in which the value is to be updated. value (str): The value to update in the column. """ sql...
[ "def", "db_update_record", "(", "self", ",", "table_name", ",", "column", ",", "value", ")", ":", "sql", "=", "'UPDATE {} SET {} = \\'{}\\''", ".", "format", "(", "table_name", ",", "column", ",", "value", ")", "cur", "=", "self", ".", "db_conn", ".", "cur...
Insert records into DB. Args: table_name (str): The name of the table. column (str): The column name in which the value is to be updated. value (str): The value to update in the column.
[ "Insert", "records", "into", "DB", "." ]
python
train
projecthamster/hamster
src/hamster/widgets/facttree.py
https://github.com/projecthamster/hamster/blob/ca5254eff53172796ddafc72226c394ed1858245/src/hamster/widgets/facttree.py#L258-L261
def current_fact_index(self): """Current fact index in the self.facts list.""" facts_ids = [fact.id for fact in self.facts] return facts_ids.index(self.current_fact.id)
[ "def", "current_fact_index", "(", "self", ")", ":", "facts_ids", "=", "[", "fact", ".", "id", "for", "fact", "in", "self", ".", "facts", "]", "return", "facts_ids", ".", "index", "(", "self", ".", "current_fact", ".", "id", ")" ]
Current fact index in the self.facts list.
[ "Current", "fact", "index", "in", "the", "self", ".", "facts", "list", "." ]
python
train
johntruckenbrodt/spatialist
spatialist/raster.py
https://github.com/johntruckenbrodt/spatialist/blob/007f49296a156de8d7168ad235b5a5b8e8d3633d/spatialist/raster.py#L1037-L1254
def stack(srcfiles, dstfile, resampling, targetres, dstnodata, srcnodata=None, shapefile=None, layernames=None, sortfun=None, separate=False, overwrite=False, compress=True, cores=4): """ function for mosaicking, resampling and stacking of multiple raster files into a 3D data cube Parameters ...
[ "def", "stack", "(", "srcfiles", ",", "dstfile", ",", "resampling", ",", "targetres", ",", "dstnodata", ",", "srcnodata", "=", "None", ",", "shapefile", "=", "None", ",", "layernames", "=", "None", ",", "sortfun", "=", "None", ",", "separate", "=", "Fals...
function for mosaicking, resampling and stacking of multiple raster files into a 3D data cube Parameters ---------- srcfiles: list a list of file names or a list of lists; each sub-list is treated as a task to mosaic its containing files dstfile: str the destination file or a directory ...
[ "function", "for", "mosaicking", "resampling", "and", "stacking", "of", "multiple", "raster", "files", "into", "a", "3D", "data", "cube" ]
python
train
quantumlib/Cirq
cirq/protocols/resolve_parameters.py
https://github.com/quantumlib/Cirq/blob/0827da80dd7880e5b923eb69407e980ed9bc0bd2/cirq/protocols/resolve_parameters.py#L65-L99
def resolve_parameters( val: Any, param_resolver: 'cirq.ParamResolverOrSimilarType') -> Any: """Resolves symbol parameters in the effect using the param resolver. This function will use the `_resolve_parameters_` magic method of `val` to resolve any Symbols with concrete values from the giv...
[ "def", "resolve_parameters", "(", "val", ":", "Any", ",", "param_resolver", ":", "'cirq.ParamResolverOrSimilarType'", ")", "->", "Any", ":", "if", "not", "param_resolver", ":", "return", "val", "# Ensure its a dictionary wrapped in a ParamResolver.", "from", "cirq", "im...
Resolves symbol parameters in the effect using the param resolver. This function will use the `_resolve_parameters_` magic method of `val` to resolve any Symbols with concrete values from the given parameter resolver. Args: val: The object to resolve (e.g. the gate, operation, etc) par...
[ "Resolves", "symbol", "parameters", "in", "the", "effect", "using", "the", "param", "resolver", "." ]
python
train
fabioz/PyDev.Debugger
pydevd_attach_to_process/winappdbg/process.py
https://github.com/fabioz/PyDev.Debugger/blob/ed9c4307662a5593b8a7f1f3389ecd0e79b8c503/pydevd_attach_to_process/winappdbg/process.py#L2370-L2426
def peek_string(self, lpBaseAddress, fUnicode = False, dwMaxSize = 0x1000): """ Tries to read an ASCII or Unicode string from the address space of the process. @see: L{read_string} @type lpBaseAddress: int @param lpBaseAddress: Memory address to begin reading. ...
[ "def", "peek_string", "(", "self", ",", "lpBaseAddress", ",", "fUnicode", "=", "False", ",", "dwMaxSize", "=", "0x1000", ")", ":", "# Validate the parameters.", "if", "not", "lpBaseAddress", "or", "dwMaxSize", "==", "0", ":", "if", "fUnicode", ":", "return", ...
Tries to read an ASCII or Unicode string from the address space of the process. @see: L{read_string} @type lpBaseAddress: int @param lpBaseAddress: Memory address to begin reading. @type fUnicode: bool @param fUnicode: C{True} is the string is expected to be Unicode,...
[ "Tries", "to", "read", "an", "ASCII", "or", "Unicode", "string", "from", "the", "address", "space", "of", "the", "process", "." ]
python
train
matousc89/padasip
padasip/filters/gngd.py
https://github.com/matousc89/padasip/blob/c969eadd7fa181a84da0554d737fc13c6450d16f/padasip/filters/gngd.py#L158-L175
def adapt(self, d, x): """ Adapt weights according one desired value and its input. **Args:** * `d` : desired value (float) * `x` : input array (1-dimensional array) """ y = np.dot(self.w, x) e = d - y self.eps = self.eps - self.ro * self.mu * e...
[ "def", "adapt", "(", "self", ",", "d", ",", "x", ")", ":", "y", "=", "np", ".", "dot", "(", "self", ".", "w", ",", "x", ")", "e", "=", "d", "-", "y", "self", ".", "eps", "=", "self", ".", "eps", "-", "self", ".", "ro", "*", "self", ".",...
Adapt weights according one desired value and its input. **Args:** * `d` : desired value (float) * `x` : input array (1-dimensional array)
[ "Adapt", "weights", "according", "one", "desired", "value", "and", "its", "input", "." ]
python
train
ffcalculator/fantasydata-python
fantasy_data/FantasyData.py
https://github.com/ffcalculator/fantasydata-python/blob/af90cac1e80d8356cffaa80621ee513201f6c661/fantasy_data/FantasyData.py#L38-L70
def _method_call(self, method, category, **kwargs): """ Call API method. Generate request. Parse response. Process errors `method` str API method url for request. Contains parameters `params` dict parameters for method url """ session = requests.Session() try: ...
[ "def", "_method_call", "(", "self", ",", "method", ",", "category", ",", "*", "*", "kwargs", ")", ":", "session", "=", "requests", ".", "Session", "(", ")", "try", ":", "response", "=", "session", ".", "get", "(", "\"http://\"", "+", "self", ".", "_a...
Call API method. Generate request. Parse response. Process errors `method` str API method url for request. Contains parameters `params` dict parameters for method url
[ "Call", "API", "method", ".", "Generate", "request", ".", "Parse", "response", ".", "Process", "errors", "method", "str", "API", "method", "url", "for", "request", ".", "Contains", "parameters", "params", "dict", "parameters", "for", "method", "url" ]
python
train
hubo1016/vlcp
vlcp/utils/http.py
https://github.com/hubo1016/vlcp/blob/239055229ec93a99cc7e15208075724ccf543bd1/vlcp/utils/http.py#L567-L572
def outputjson(self, obj): """ Serialize `obj` with JSON and output to the client """ self.header('Content-Type', 'application/json') self.outputdata(json.dumps(obj).encode('ascii'))
[ "def", "outputjson", "(", "self", ",", "obj", ")", ":", "self", ".", "header", "(", "'Content-Type'", ",", "'application/json'", ")", "self", ".", "outputdata", "(", "json", ".", "dumps", "(", "obj", ")", ".", "encode", "(", "'ascii'", ")", ")" ]
Serialize `obj` with JSON and output to the client
[ "Serialize", "obj", "with", "JSON", "and", "output", "to", "the", "client" ]
python
train
mitsei/dlkit
dlkit/json_/assessment/objects.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment/objects.py#L1025-L1032
def _init_map(self, record_types=None, **kwargs): """Initialize form map""" osid_objects.OsidObjectForm._init_map(self, record_types=record_types) self._my_map['rubricId'] = self._rubric_default self._my_map['assignedBankIds'] = [str(kwargs['bank_id'])] self._my_map['levelId'] = ...
[ "def", "_init_map", "(", "self", ",", "record_types", "=", "None", ",", "*", "*", "kwargs", ")", ":", "osid_objects", ".", "OsidObjectForm", ".", "_init_map", "(", "self", ",", "record_types", "=", "record_types", ")", "self", ".", "_my_map", "[", "'rubric...
Initialize form map
[ "Initialize", "form", "map" ]
python
train
bcbio/bcbio-nextgen
bcbio/rnaseq/cufflinks.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/rnaseq/cufflinks.py#L156-L167
def strand_unknown(db, transcript): """ for unstranded data with novel transcripts single exon genes will have no strand information. single exon novel genes are also a source of noise in the Cufflinks assembly so this removes them """ features = list(db.children(transcript)) strand = featur...
[ "def", "strand_unknown", "(", "db", ",", "transcript", ")", ":", "features", "=", "list", "(", "db", ".", "children", "(", "transcript", ")", ")", "strand", "=", "features", "[", "0", "]", ".", "strand", "if", "strand", "==", "\".\"", ":", "return", ...
for unstranded data with novel transcripts single exon genes will have no strand information. single exon novel genes are also a source of noise in the Cufflinks assembly so this removes them
[ "for", "unstranded", "data", "with", "novel", "transcripts", "single", "exon", "genes", "will", "have", "no", "strand", "information", ".", "single", "exon", "novel", "genes", "are", "also", "a", "source", "of", "noise", "in", "the", "Cufflinks", "assembly", ...
python
train
alejandroautalan/pygubu
pygubudesigner/util/selecttool.py
https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/util/selecttool.py#L75-L89
def _finish_selecting(self, event): """Finaliza la seleccion. Marca como seleccionados todos los objetos que se encuentran dentro del recuadro de seleccion.""" self._selecting = False canvas = self._canvas x = canvas.canvasx(event.x) y = canvas.canvasy(event.y) ...
[ "def", "_finish_selecting", "(", "self", ",", "event", ")", ":", "self", ".", "_selecting", "=", "False", "canvas", "=", "self", ".", "_canvas", "x", "=", "canvas", ".", "canvasx", "(", "event", ".", "x", ")", "y", "=", "canvas", ".", "canvasy", "(",...
Finaliza la seleccion. Marca como seleccionados todos los objetos que se encuentran dentro del recuadro de seleccion.
[ "Finaliza", "la", "seleccion", ".", "Marca", "como", "seleccionados", "todos", "los", "objetos", "que", "se", "encuentran", "dentro", "del", "recuadro", "de", "seleccion", "." ]
python
train
Capitains/MyCapytain
MyCapytain/resources/prototypes/metadata.py
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/prototypes/metadata.py#L125-L140
def get_label(self, lang=None): """ Return label for given lang or any default :param lang: Language to request :return: Label value :rtype: Literal """ x = None if lang is None: for obj in self.graph.objects(self.asNode(), RDFS.label): ...
[ "def", "get_label", "(", "self", ",", "lang", "=", "None", ")", ":", "x", "=", "None", "if", "lang", "is", "None", ":", "for", "obj", "in", "self", ".", "graph", ".", "objects", "(", "self", ".", "asNode", "(", ")", ",", "RDFS", ".", "label", "...
Return label for given lang or any default :param lang: Language to request :return: Label value :rtype: Literal
[ "Return", "label", "for", "given", "lang", "or", "any", "default" ]
python
train
SatelliteQE/nailgun
nailgun/entities.py
https://github.com/SatelliteQE/nailgun/blob/c36d8c20862e87bf6975bd48ac1ca40a9e634eaa/nailgun/entities.py#L5767-L5777
def create(self, create_missing=None): """Do extra work to fetch a complete set of attributes for this entity. For more information, see `Bugzilla #1232855 <https://bugzilla.redhat.com/show_bug.cgi?id=1232855>`_. """ return Realm( self._server_config, id...
[ "def", "create", "(", "self", ",", "create_missing", "=", "None", ")", ":", "return", "Realm", "(", "self", ".", "_server_config", ",", "id", "=", "self", ".", "create_json", "(", "create_missing", ")", "[", "'id'", "]", ",", ")", ".", "read", "(", "...
Do extra work to fetch a complete set of attributes for this entity. For more information, see `Bugzilla #1232855 <https://bugzilla.redhat.com/show_bug.cgi?id=1232855>`_.
[ "Do", "extra", "work", "to", "fetch", "a", "complete", "set", "of", "attributes", "for", "this", "entity", "." ]
python
train
assemblerflow/flowcraft
flowcraft/generator/engine.py
https://github.com/assemblerflow/flowcraft/blob/fc3f4bddded1efc76006600016dc71a06dd908c0/flowcraft/generator/engine.py#L1589-L1643
def build(self): """Main pipeline builder This method is responsible for building the :py:attr:`NextflowGenerator.template` attribute that will contain the nextflow code of the pipeline. First it builds the header, then sets the main channels, the secondary inputs, seco...
[ "def", "build", "(", "self", ")", ":", "logger", ".", "info", "(", "colored_print", "(", "\"\\tSuccessfully connected {} process(es) with {} \"", "\"fork(s) across {} lane(s) \\u2713\"", ".", "format", "(", "len", "(", "self", ".", "processes", "[", "1", ":", "]", ...
Main pipeline builder This method is responsible for building the :py:attr:`NextflowGenerator.template` attribute that will contain the nextflow code of the pipeline. First it builds the header, then sets the main channels, the secondary inputs, secondary channels and finally t...
[ "Main", "pipeline", "builder" ]
python
test
Capitains/MyCapytain
MyCapytain/resources/prototypes/metadata.py
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/prototypes/metadata.py#L162-L172
def parents(self) -> List["Collection"]: """ Iterator to find parents of current collection, from closest to furthest :rtype: Generator[:class:`Collection`] """ p = self.parent parents = [] while p is not None: parents.append(p) p = p.parent ...
[ "def", "parents", "(", "self", ")", "->", "List", "[", "\"Collection\"", "]", ":", "p", "=", "self", ".", "parent", "parents", "=", "[", "]", "while", "p", "is", "not", "None", ":", "parents", ".", "append", "(", "p", ")", "p", "=", "p", ".", "...
Iterator to find parents of current collection, from closest to furthest :rtype: Generator[:class:`Collection`]
[ "Iterator", "to", "find", "parents", "of", "current", "collection", "from", "closest", "to", "furthest" ]
python
train
pyviz/holoviews
holoviews/util/parser.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/util/parser.py#L44-L47
def _strip_commas(cls, kw): "Strip out any leading/training commas from the token" kw = kw[:-1] if kw[-1]==',' else kw return kw[1:] if kw[0]==',' else kw
[ "def", "_strip_commas", "(", "cls", ",", "kw", ")", ":", "kw", "=", "kw", "[", ":", "-", "1", "]", "if", "kw", "[", "-", "1", "]", "==", "','", "else", "kw", "return", "kw", "[", "1", ":", "]", "if", "kw", "[", "0", "]", "==", "','", "els...
Strip out any leading/training commas from the token
[ "Strip", "out", "any", "leading", "/", "training", "commas", "from", "the", "token" ]
python
train
treyhunner/django-simple-history
simple_history/admin.py
https://github.com/treyhunner/django-simple-history/blob/85758ecfe608279508a3fb5b71654d3e202eb63d/simple_history/admin.py#L203-L206
def save_model(self, request, obj, form, change): """Set special model attribute to user for reference after save""" obj._history_user = request.user super(SimpleHistoryAdmin, self).save_model(request, obj, form, change)
[ "def", "save_model", "(", "self", ",", "request", ",", "obj", ",", "form", ",", "change", ")", ":", "obj", ".", "_history_user", "=", "request", ".", "user", "super", "(", "SimpleHistoryAdmin", ",", "self", ")", ".", "save_model", "(", "request", ",", ...
Set special model attribute to user for reference after save
[ "Set", "special", "model", "attribute", "to", "user", "for", "reference", "after", "save" ]
python
train
dnanexus/dx-toolkit
src/python/dxpy/app_builder.py
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/app_builder.py#L140-L165
def is_link_local(link_target): """ :param link_target: The target of a symbolic link, as given by os.readlink() :type link_target: string :returns: A boolean indicating the link is local to the current directory. This is defined to mean that os.path.isabs(link_target) == False ...
[ "def", "is_link_local", "(", "link_target", ")", ":", "is_local", "=", "(", "not", "os", ".", "path", ".", "isabs", "(", "link_target", ")", ")", "if", "is_local", ":", "# make sure that the path NEVER extends outside the resources directory!", "d", ",", "l", "=",...
:param link_target: The target of a symbolic link, as given by os.readlink() :type link_target: string :returns: A boolean indicating the link is local to the current directory. This is defined to mean that os.path.isabs(link_target) == False and the link NEVER references the parent ...
[ ":", "param", "link_target", ":", "The", "target", "of", "a", "symbolic", "link", "as", "given", "by", "os", ".", "readlink", "()", ":", "type", "link_target", ":", "string", ":", "returns", ":", "A", "boolean", "indicating", "the", "link", "is", "local"...
python
train
Yelp/yelp-python
yelp/endpoint/business.py
https://github.com/Yelp/yelp-python/blob/12d611bc2344bbc1c93c83775aa71b7b01b36ad6/yelp/endpoint/business.py#L13-L29
def get_by_id(self, business_id, **url_params): """Make a request to the business details endpoint. More info at https://www.yelp.com/developers/documentation/v3/business Args: business_id (str): The business alias (i.e. yelp-san-francisco) or ID (i.e. 4kMBvIEWPxWkWK...
[ "def", "get_by_id", "(", "self", ",", "business_id", ",", "*", "*", "url_params", ")", ":", "business_path", "=", "BUSINESS_PATH", ".", "format", "(", "business_id", "=", "business_id", ")", "response", "=", "self", ".", "client", ".", "_make_request", "(", ...
Make a request to the business details endpoint. More info at https://www.yelp.com/developers/documentation/v3/business Args: business_id (str): The business alias (i.e. yelp-san-francisco) or ID (i.e. 4kMBvIEWPxWkWKFN__8SxQ. **url_params: Dict corresponding to b...
[ "Make", "a", "request", "to", "the", "business", "details", "endpoint", ".", "More", "info", "at", "https", ":", "//", "www", ".", "yelp", ".", "com", "/", "developers", "/", "documentation", "/", "v3", "/", "business" ]
python
train
pandas-dev/pandas
pandas/core/frame.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L3084-L3187
def eval(self, expr, inplace=False, **kwargs): """ Evaluate a string describing operations on DataFrame columns. Operates on columns only, not specific rows or elements. This allows `eval` to run arbitrary code, which can make you vulnerable to code injection if you pass user i...
[ "def", "eval", "(", "self", ",", "expr", ",", "inplace", "=", "False", ",", "*", "*", "kwargs", ")", ":", "from", "pandas", ".", "core", ".", "computation", ".", "eval", "import", "eval", "as", "_eval", "inplace", "=", "validate_bool_kwarg", "(", "inpl...
Evaluate a string describing operations on DataFrame columns. Operates on columns only, not specific rows or elements. This allows `eval` to run arbitrary code, which can make you vulnerable to code injection if you pass user input to this function. Parameters ---------- ...
[ "Evaluate", "a", "string", "describing", "operations", "on", "DataFrame", "columns", "." ]
python
train
zhmcclient/python-zhmcclient
zhmcclient_mock/_urihandler.py
https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient_mock/_urihandler.py#L1110-L1121
def post(method, hmc, uri, uri_parms, body, logon_required, wait_for_completion): """Operation: Stop CPC (requires DPM mode).""" assert wait_for_completion is True # async not supported yet cpc_oid = uri_parms[0] try: cpc = hmc.cpcs.lookup_by_oid(cpc_oid) ...
[ "def", "post", "(", "method", ",", "hmc", ",", "uri", ",", "uri_parms", ",", "body", ",", "logon_required", ",", "wait_for_completion", ")", ":", "assert", "wait_for_completion", "is", "True", "# async not supported yet", "cpc_oid", "=", "uri_parms", "[", "0", ...
Operation: Stop CPC (requires DPM mode).
[ "Operation", ":", "Stop", "CPC", "(", "requires", "DPM", "mode", ")", "." ]
python
train
joelfrederico/SciSalt
scisalt/facettools/logbookForm.py
https://github.com/joelfrederico/SciSalt/blob/7bf57c49c7dde0a8b0aa337fbd2fbd527ce7a67f/scisalt/facettools/logbookForm.py#L359-L390
def submitEntry(self): """Process user inputs and subit logbook entry when user clicks Submit button""" # logType = self.logui.logType.currentText() mcclogs, physlogs = self.selectedLogs() success = True if mcclogs != []: if not self.acceptedUser("MC...
[ "def", "submitEntry", "(", "self", ")", ":", "# logType = self.logui.logType.currentText()", "mcclogs", ",", "physlogs", "=", "self", ".", "selectedLogs", "(", ")", "success", "=", "True", "if", "mcclogs", "!=", "[", "]", ":", "if", "not", "self", ".", "acce...
Process user inputs and subit logbook entry when user clicks Submit button
[ "Process", "user", "inputs", "and", "subit", "logbook", "entry", "when", "user", "clicks", "Submit", "button" ]
python
valid
pantsbuild/pants
src/python/pants/reporting/json_reporter.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/reporting/json_reporter.py#L83-L86
def handle_output(self, workunit, label, stream): """Implementation of Reporter callback.""" self._root_id_to_workunit_stack[str(workunit.root().id)][-1]['outputs'][label] += stream
[ "def", "handle_output", "(", "self", ",", "workunit", ",", "label", ",", "stream", ")", ":", "self", ".", "_root_id_to_workunit_stack", "[", "str", "(", "workunit", ".", "root", "(", ")", ".", "id", ")", "]", "[", "-", "1", "]", "[", "'outputs'", "]"...
Implementation of Reporter callback.
[ "Implementation", "of", "Reporter", "callback", "." ]
python
train
dshean/pygeotools
pygeotools/lib/geolib.py
https://github.com/dshean/pygeotools/blob/5ac745717c0098d01eb293ff1fe32fd7358c76ab/pygeotools/lib/geolib.py#L746-L795
def shp2array(shp_fn, r_ds=None, res=None, extent=None, t_srs=None): """Rasterize input shapefile to match existing raster Dataset (or specified res/extent/t_srs) """ shp_ds = ogr.Open(shp_fn) lyr = shp_ds.GetLayer() #This returns xmin, ymin, xmax, ymax shp_extent = lyr_extent(lyr) shp_srs =...
[ "def", "shp2array", "(", "shp_fn", ",", "r_ds", "=", "None", ",", "res", "=", "None", ",", "extent", "=", "None", ",", "t_srs", "=", "None", ")", ":", "shp_ds", "=", "ogr", ".", "Open", "(", "shp_fn", ")", "lyr", "=", "shp_ds", ".", "GetLayer", "...
Rasterize input shapefile to match existing raster Dataset (or specified res/extent/t_srs)
[ "Rasterize", "input", "shapefile", "to", "match", "existing", "raster", "Dataset", "(", "or", "specified", "res", "/", "extent", "/", "t_srs", ")" ]
python
train
mitsei/dlkit
dlkit/services/assessment.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/services/assessment.py#L3806-L3814
def use_comparative_sequence_rule_view(self): """Pass through to provider SequenceRuleLookupSession.use_comparative_sequence_rule_view""" self._object_views['sequence_rule'] = COMPARATIVE # self._get_provider_session('sequence_rule_lookup_session') # To make sure the session is tracked f...
[ "def", "use_comparative_sequence_rule_view", "(", "self", ")", ":", "self", ".", "_object_views", "[", "'sequence_rule'", "]", "=", "COMPARATIVE", "# self._get_provider_session('sequence_rule_lookup_session') # To make sure the session is tracked", "for", "session", "in", "self",...
Pass through to provider SequenceRuleLookupSession.use_comparative_sequence_rule_view
[ "Pass", "through", "to", "provider", "SequenceRuleLookupSession", ".", "use_comparative_sequence_rule_view" ]
python
train
quantopian/zipline
zipline/data/bundles/quandl.py
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/bundles/quandl.py#L183-L250
def quandl_bundle(environ, asset_db_writer, minute_bar_writer, daily_bar_writer, adjustment_writer, calendar, start_session, end_session, cache, show_progress...
[ "def", "quandl_bundle", "(", "environ", ",", "asset_db_writer", ",", "minute_bar_writer", ",", "daily_bar_writer", ",", "adjustment_writer", ",", "calendar", ",", "start_session", ",", "end_session", ",", "cache", ",", "show_progress", ",", "output_dir", ")", ":", ...
quandl_bundle builds a daily dataset using Quandl's WIKI Prices dataset. For more information on Quandl's API and how to obtain an API key, please visit https://docs.quandl.com/docs#section-authentication
[ "quandl_bundle", "builds", "a", "daily", "dataset", "using", "Quandl", "s", "WIKI", "Prices", "dataset", "." ]
python
train
LettError/MutatorMath
Lib/mutatorMath/ufo/instance.py
https://github.com/LettError/MutatorMath/blob/10318fc4e7c9cee9df6130826829baea3054a42b/Lib/mutatorMath/ufo/instance.py#L390-L418
def save(self): """ Save the UFO.""" # handle glyphs that were muted for name in self.mutedGlyphsNames: if name not in self.font: continue if self.logger: self.logger.info("removing muted glyph %s", name) del self.font[name] # XXX ...
[ "def", "save", "(", "self", ")", ":", "# handle glyphs that were muted", "for", "name", "in", "self", ".", "mutedGlyphsNames", ":", "if", "name", "not", "in", "self", ".", "font", ":", "continue", "if", "self", ".", "logger", ":", "self", ".", "logger", ...
Save the UFO.
[ "Save", "the", "UFO", "." ]
python
train
ArduPilot/MAVProxy
MAVProxy/modules/lib/mp_util.py
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/lib/mp_util.py#L237-L246
def dot_mavproxy(name=None): '''return a path to store mavproxy data''' if 'HOME' not in os.environ: dir = os.path.join(os.environ['LOCALAPPDATA'], '.mavproxy') else: dir = os.path.join(os.environ['HOME'], '.mavproxy') mkdir_p(dir) if name is None: return dir return os.pa...
[ "def", "dot_mavproxy", "(", "name", "=", "None", ")", ":", "if", "'HOME'", "not", "in", "os", ".", "environ", ":", "dir", "=", "os", ".", "path", ".", "join", "(", "os", ".", "environ", "[", "'LOCALAPPDATA'", "]", ",", "'.mavproxy'", ")", "else", "...
return a path to store mavproxy data
[ "return", "a", "path", "to", "store", "mavproxy", "data" ]
python
train
osrg/ryu
ryu/services/protocols/bgp/speaker.py
https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/services/protocols/bgp/speaker.py#L359-L379
def send_notification(self, code, subcode): """Utility to send notification message. Closes the socket after sending the message. :Parameters: - `socket`: (socket) - socket over which to send notification message. - `code`: (int) - BGP Notification code ...
[ "def", "send_notification", "(", "self", ",", "code", ",", "subcode", ")", ":", "notification", "=", "BGPNotification", "(", "code", ",", "subcode", ")", "reason", "=", "notification", ".", "reason", "self", ".", "_send_with_lock", "(", "notification", ")", ...
Utility to send notification message. Closes the socket after sending the message. :Parameters: - `socket`: (socket) - socket over which to send notification message. - `code`: (int) - BGP Notification code - `subcode`: (int) - BGP Notification sub-code ...
[ "Utility", "to", "send", "notification", "message", "." ]
python
train
dakrauth/django-swingtime
swingtime/views.py
https://github.com/dakrauth/django-swingtime/blob/d1cdd449bd5c6895c3ff182fd890c4d3452943fe/swingtime/views.py#L43-L88
def event_view( request, pk, template='swingtime/event_detail.html', event_form_class=forms.EventForm, recurrence_form_class=forms.MultipleOccurrenceForm ): ''' View an ``Event`` instance and optionally update either the event or its occurrences. Context parameters: ``event`` ...
[ "def", "event_view", "(", "request", ",", "pk", ",", "template", "=", "'swingtime/event_detail.html'", ",", "event_form_class", "=", "forms", ".", "EventForm", ",", "recurrence_form_class", "=", "forms", ".", "MultipleOccurrenceForm", ")", ":", "event", "=", "get_...
View an ``Event`` instance and optionally update either the event or its occurrences. Context parameters: ``event`` the event keyed by ``pk`` ``event_form`` a form object for updating the event ``recurrence_form`` a form object for adding occurrences
[ "View", "an", "Event", "instance", "and", "optionally", "update", "either", "the", "event", "or", "its", "occurrences", "." ]
python
train
python-rope/rope
rope/base/pycore.py
https://github.com/python-rope/rope/blob/1c9f9cd5964b099a99a9111e998f0dc728860688/rope/base/pycore.py#L169-L185
def run_module(self, resource, args=None, stdin=None, stdout=None): """Run `resource` module Returns a `rope.base.oi.doa.PythonFileRunner` object for controlling the process. """ perform_doa = self.project.prefs.get('perform_doi', True) perform_doa = self.project.prefs....
[ "def", "run_module", "(", "self", ",", "resource", ",", "args", "=", "None", ",", "stdin", "=", "None", ",", "stdout", "=", "None", ")", ":", "perform_doa", "=", "self", ".", "project", ".", "prefs", ".", "get", "(", "'perform_doi'", ",", "True", ")"...
Run `resource` module Returns a `rope.base.oi.doa.PythonFileRunner` object for controlling the process.
[ "Run", "resource", "module" ]
python
train
googleapis/google-cloud-python
storage/google/cloud/storage/_signing.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/storage/google/cloud/storage/_signing.py#L399-L591
def generate_signed_url_v4( credentials, resource, expiration, api_access_endpoint=DEFAULT_ENDPOINT, method="GET", content_md5=None, content_type=None, response_type=None, response_disposition=None, generation=None, headers=None, query_parameters=None, _request_timest...
[ "def", "generate_signed_url_v4", "(", "credentials", ",", "resource", ",", "expiration", ",", "api_access_endpoint", "=", "DEFAULT_ENDPOINT", ",", "method", "=", "\"GET\"", ",", "content_md5", "=", "None", ",", "content_type", "=", "None", ",", "response_type", "=...
Generate a V4 signed URL to provide query-string auth'n to a resource. .. note:: Assumes ``credentials`` implements the :class:`google.auth.credentials.Signing` interface. Also assumes ``credentials`` has a ``service_account_email`` property which identifies the credentials. ....
[ "Generate", "a", "V4", "signed", "URL", "to", "provide", "query", "-", "string", "auth", "n", "to", "a", "resource", "." ]
python
train
Devoxin/Lavalink.py
lavalink/PlayerManager.py
https://github.com/Devoxin/Lavalink.py/blob/63f55c3d726d24c4cfd3674d3cd6aab6f5be110d/lavalink/PlayerManager.py#L153-L156
async def set_pause(self, pause: bool): """ Sets the player's paused state. """ await self._lavalink.ws.send(op='pause', guildId=self.guild_id, pause=pause) self.paused = pause
[ "async", "def", "set_pause", "(", "self", ",", "pause", ":", "bool", ")", ":", "await", "self", ".", "_lavalink", ".", "ws", ".", "send", "(", "op", "=", "'pause'", ",", "guildId", "=", "self", ".", "guild_id", ",", "pause", "=", "pause", ")", "sel...
Sets the player's paused state.
[ "Sets", "the", "player", "s", "paused", "state", "." ]
python
valid
wickerwaka/russound_rio
russound_rio/rio.py
https://github.com/wickerwaka/russound_rio/blob/e331985fd1544abec6a1da3637090550d6f93f76/russound_rio/rio.py#L360-L369
def get_cached_source_variable(self, source_id, variable, default=None): """ Get the cached value of a source variable. If the variable is not cached return the default value. """ source_id = int(source_id) try: return self._retrieve_cached_source_variable( ...
[ "def", "get_cached_source_variable", "(", "self", ",", "source_id", ",", "variable", ",", "default", "=", "None", ")", ":", "source_id", "=", "int", "(", "source_id", ")", "try", ":", "return", "self", ".", "_retrieve_cached_source_variable", "(", "source_id", ...
Get the cached value of a source variable. If the variable is not cached return the default value.
[ "Get", "the", "cached", "value", "of", "a", "source", "variable", ".", "If", "the", "variable", "is", "not", "cached", "return", "the", "default", "value", "." ]
python
train
tanghaibao/jcvi
jcvi/utils/taxonomy.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/utils/taxonomy.py#L179-L196
def newick(args): """ %prog newick idslist Query a list of IDs to retrieve phylogeny. """ p = OptionParser(newick.__doc__) opts, args = p.parse_args(args) if len(args) != 1: sys.exit(not p.print_help()) idsfile, = args mylist = [x.strip() for x in open(idsfile) if x.strip(...
[ "def", "newick", "(", "args", ")", ":", "p", "=", "OptionParser", "(", "newick", ".", "__doc__", ")", "opts", ",", "args", "=", "p", ".", "parse_args", "(", "args", ")", "if", "len", "(", "args", ")", "!=", "1", ":", "sys", ".", "exit", "(", "n...
%prog newick idslist Query a list of IDs to retrieve phylogeny.
[ "%prog", "newick", "idslist" ]
python
train
aws/sagemaker-containers
src/sagemaker_containers/_files.py
https://github.com/aws/sagemaker-containers/blob/0030f07abbaf22a55d986d97274d7a8d1aa1f10c/src/sagemaker_containers/_files.py#L140-L157
def s3_download(url, dst): # type: (str, str) -> None """Download a file from S3. Args: url (str): the s3 url of the file. dst (str): the destination where the file will be saved. """ url = parse.urlparse(url) if url.scheme != 's3': raise ValueError("Expecting 's3' scheme,...
[ "def", "s3_download", "(", "url", ",", "dst", ")", ":", "# type: (str, str) -> None", "url", "=", "parse", ".", "urlparse", "(", "url", ")", "if", "url", ".", "scheme", "!=", "'s3'", ":", "raise", "ValueError", "(", "\"Expecting 's3' scheme, got: %s in %s\"", ...
Download a file from S3. Args: url (str): the s3 url of the file. dst (str): the destination where the file will be saved.
[ "Download", "a", "file", "from", "S3", "." ]
python
train
dedupeio/dedupe
dedupe/core.py
https://github.com/dedupeio/dedupe/blob/9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b/dedupe/core.py#L37-L62
def randomPairs(n_records, sample_size): """ Return random combinations of indices for a square matrix of size n records. For a discussion of how this works see http://stackoverflow.com/a/14839010/98080 """ n = int(n_records * (n_records - 1) / 2) if sample_size >= n: random_pairs ...
[ "def", "randomPairs", "(", "n_records", ",", "sample_size", ")", ":", "n", "=", "int", "(", "n_records", "*", "(", "n_records", "-", "1", ")", "/", "2", ")", "if", "sample_size", ">=", "n", ":", "random_pairs", "=", "numpy", ".", "arange", "(", "n", ...
Return random combinations of indices for a square matrix of size n records. For a discussion of how this works see http://stackoverflow.com/a/14839010/98080
[ "Return", "random", "combinations", "of", "indices", "for", "a", "square", "matrix", "of", "size", "n", "records", ".", "For", "a", "discussion", "of", "how", "this", "works", "see", "http", ":", "//", "stackoverflow", ".", "com", "/", "a", "/", "1483901...
python
train
celiao/tmdbsimple
tmdbsimple/tv.py
https://github.com/celiao/tmdbsimple/blob/ff17893110c99771d6398a62c35d36dd9735f4b9/tmdbsimple/tv.py#L481-L492
def credits(self, **kwargs): """ Get the TV episode credits by combination of season and episode number. Returns: A dict respresentation of the JSON returned from the API. """ path = self._get_series_id_season_number_episode_number_path('credits') response =...
[ "def", "credits", "(", "self", ",", "*", "*", "kwargs", ")", ":", "path", "=", "self", ".", "_get_series_id_season_number_episode_number_path", "(", "'credits'", ")", "response", "=", "self", ".", "_GET", "(", "path", ",", "kwargs", ")", "self", ".", "_set...
Get the TV episode credits by combination of season and episode number. Returns: A dict respresentation of the JSON returned from the API.
[ "Get", "the", "TV", "episode", "credits", "by", "combination", "of", "season", "and", "episode", "number", "." ]
python
test
log2timeline/dfvfs
dfvfs/vfs/apfs_container_file_entry.py
https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/vfs/apfs_container_file_entry.py#L16-L40
def _EntriesGenerator(self): """Retrieves directory entries. Since a directory can contain a vast number of entries using a generator is more memory efficient. Yields: APFSContainerPathSpec: a path specification. """ # Only the virtual root file has directory entries. volume_index = ...
[ "def", "_EntriesGenerator", "(", "self", ")", ":", "# Only the virtual root file has directory entries.", "volume_index", "=", "apfs_helper", ".", "APFSContainerPathSpecGetVolumeIndex", "(", "self", ".", "path_spec", ")", "if", "volume_index", "is", "not", "None", ":", ...
Retrieves directory entries. Since a directory can contain a vast number of entries using a generator is more memory efficient. Yields: APFSContainerPathSpec: a path specification.
[ "Retrieves", "directory", "entries", "." ]
python
train
synw/dataswim
dataswim/charts/seaborn.py
https://github.com/synw/dataswim/blob/4a4a53f80daa7cd8e8409d76a19ce07296269da2/dataswim/charts/seaborn.py#L153-L176
def _get_ticks(self, opts): """ Check if xticks and yticks are set """ opts, _ = self._get_opts(opts, None) if "xticks" not in opts: if "xticks" not in self.chart_opts: self.err(self.dlinear_, "Please set the xticks option for ...
[ "def", "_get_ticks", "(", "self", ",", "opts", ")", ":", "opts", ",", "_", "=", "self", ".", "_get_opts", "(", "opts", ",", "None", ")", "if", "\"xticks\"", "not", "in", "opts", ":", "if", "\"xticks\"", "not", "in", "self", ".", "chart_opts", ":", ...
Check if xticks and yticks are set
[ "Check", "if", "xticks", "and", "yticks", "are", "set" ]
python
train
openid/python-openid
openid/extensions/draft/pape5.py
https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/extensions/draft/pape5.py#L172-L184
def fromOpenIDRequest(cls, request): """Instantiate a Request object from the arguments in a C{checkid_*} OpenID message """ self = cls() args = request.message.getArgs(self.ns_uri) is_openid1 = request.message.isOpenID1() if args == {}: return None ...
[ "def", "fromOpenIDRequest", "(", "cls", ",", "request", ")", ":", "self", "=", "cls", "(", ")", "args", "=", "request", ".", "message", ".", "getArgs", "(", "self", ".", "ns_uri", ")", "is_openid1", "=", "request", ".", "message", ".", "isOpenID1", "("...
Instantiate a Request object from the arguments in a C{checkid_*} OpenID message
[ "Instantiate", "a", "Request", "object", "from", "the", "arguments", "in", "a", "C", "{", "checkid_", "*", "}", "OpenID", "message" ]
python
train
DBuildService/dockerfile-parse
dockerfile_parse/parser.py
https://github.com/DBuildService/dockerfile-parse/blob/3d7b514d8b8eded1b33529cf0f6a0770a573aee0/dockerfile_parse/parser.py#L578-L592
def _add_instruction(self, instruction, value): """ :param instruction: instruction name to be added :param value: instruction value """ if (instruction == 'LABEL' or instruction == 'ENV') and len(value) == 2: new_line = instruction + ' ' + '='.join(map(quote, value))...
[ "def", "_add_instruction", "(", "self", ",", "instruction", ",", "value", ")", ":", "if", "(", "instruction", "==", "'LABEL'", "or", "instruction", "==", "'ENV'", ")", "and", "len", "(", "value", ")", "==", "2", ":", "new_line", "=", "instruction", "+", ...
:param instruction: instruction name to be added :param value: instruction value
[ ":", "param", "instruction", ":", "instruction", "name", "to", "be", "added", ":", "param", "value", ":", "instruction", "value" ]
python
train
saltstack/salt
salt/modules/xapi_virt.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xapi_virt.py#L76-L102
def _get_xapi_session(): ''' Get a session to XenAPI. By default, use the local UNIX socket. ''' _xenapi = _check_xenapi() xapi_uri = __salt__['config.option']('xapi.uri') xapi_login = __salt__['config.option']('xapi.login') xapi_password = __salt__['config.option']('xapi.password') if...
[ "def", "_get_xapi_session", "(", ")", ":", "_xenapi", "=", "_check_xenapi", "(", ")", "xapi_uri", "=", "__salt__", "[", "'config.option'", "]", "(", "'xapi.uri'", ")", "xapi_login", "=", "__salt__", "[", "'config.option'", "]", "(", "'xapi.login'", ")", "xapi_...
Get a session to XenAPI. By default, use the local UNIX socket.
[ "Get", "a", "session", "to", "XenAPI", ".", "By", "default", "use", "the", "local", "UNIX", "socket", "." ]
python
train
guaix-ucm/numina
numina/core/tagexpr.py
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/core/tagexpr.py#L44-L47
def map_tree(visitor, tree): """Apply function to nodes""" newn = [map_tree(visitor, node) for node in tree.nodes] return visitor(tree, newn)
[ "def", "map_tree", "(", "visitor", ",", "tree", ")", ":", "newn", "=", "[", "map_tree", "(", "visitor", ",", "node", ")", "for", "node", "in", "tree", ".", "nodes", "]", "return", "visitor", "(", "tree", ",", "newn", ")" ]
Apply function to nodes
[ "Apply", "function", "to", "nodes" ]
python
train
limpyd/redis-limpyd-jobs
limpyd_jobs/models.py
https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/models.py#L276-L283
def get_from_ident(self, ident): """ Take a string as returned by get_ident and return a job, based on the class representation and the job's pk from the ident """ model_repr, job_pk = ident.split(':', 1) klass = import_class(model_repr) return klass.get(job_pk)
[ "def", "get_from_ident", "(", "self", ",", "ident", ")", ":", "model_repr", ",", "job_pk", "=", "ident", ".", "split", "(", "':'", ",", "1", ")", "klass", "=", "import_class", "(", "model_repr", ")", "return", "klass", ".", "get", "(", "job_pk", ")" ]
Take a string as returned by get_ident and return a job, based on the class representation and the job's pk from the ident
[ "Take", "a", "string", "as", "returned", "by", "get_ident", "and", "return", "a", "job", "based", "on", "the", "class", "representation", "and", "the", "job", "s", "pk", "from", "the", "ident" ]
python
train
mandiant/ioc_writer
ioc_writer/ioc_common.py
https://github.com/mandiant/ioc_writer/blob/712247f3a10bdc2584fa18ac909fc763f71df21a/ioc_writer/ioc_common.py#L919-L931
def make_serviceitem_servicedllsignatureexists(dll_sig_exists, condition='is', negate=False): """ Create a node for ServiceItem/serviceDLLSignatureExists :return: A IndicatorItem represented as an Element node """ document = 'ServiceItem' search = 'ServiceItem/serviceDLLSignatureExists' ...
[ "def", "make_serviceitem_servicedllsignatureexists", "(", "dll_sig_exists", ",", "condition", "=", "'is'", ",", "negate", "=", "False", ")", ":", "document", "=", "'ServiceItem'", "search", "=", "'ServiceItem/serviceDLLSignatureExists'", "content_type", "=", "'bool'", "...
Create a node for ServiceItem/serviceDLLSignatureExists :return: A IndicatorItem represented as an Element node
[ "Create", "a", "node", "for", "ServiceItem", "/", "serviceDLLSignatureExists", ":", "return", ":", "A", "IndicatorItem", "represented", "as", "an", "Element", "node" ]
python
train
django-admin-tools/django-admin-tools
admin_tools/utils.py
https://github.com/django-admin-tools/django-admin-tools/blob/ba6f46f51ebd84fcf84f2f79ec9487f45452d79b/admin_tools/utils.py#L166-L173
def _get_admin_change_url(self, model, context): """ Returns the admin change url. """ app_label = model._meta.app_label return reverse('%s:%s_%s_changelist' % (get_admin_site_name(context), app_label, ...
[ "def", "_get_admin_change_url", "(", "self", ",", "model", ",", "context", ")", ":", "app_label", "=", "model", ".", "_meta", ".", "app_label", "return", "reverse", "(", "'%s:%s_%s_changelist'", "%", "(", "get_admin_site_name", "(", "context", ")", ",", "app_l...
Returns the admin change url.
[ "Returns", "the", "admin", "change", "url", "." ]
python
train
google/brotli
research/brotlidump.py
https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1578-L1615
def processStream(self): """Process a brotli stream. """ print('addr hex{:{}s}binary context explanation'.format( '', self.width-10)) print('Stream header'.center(60, '-')) self.windowSize = self.verboseRead(WindowSizeAlphabet()) print('Metablock header'.cent...
[ "def", "processStream", "(", "self", ")", ":", "print", "(", "'addr hex{:{}s}binary context explanation'", ".", "format", "(", "''", ",", "self", ".", "width", "-", "10", ")", ")", "print", "(", "'Stream header'", ".", "center", "(", "60", ",", "'-'", ")"...
Process a brotli stream.
[ "Process", "a", "brotli", "stream", "." ]
python
test
brocade/pynos
pynos/device.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/device.py#L251-L269
def firmware_version(self): """ Returns firmware version. Args: None Returns: Dictionary Raises: None """ namespace = "urn:brocade.com:mgmt:brocade-firmware-ext" request_ver = ET.Element("show-firmware-version", xmln...
[ "def", "firmware_version", "(", "self", ")", ":", "namespace", "=", "\"urn:brocade.com:mgmt:brocade-firmware-ext\"", "request_ver", "=", "ET", ".", "Element", "(", "\"show-firmware-version\"", ",", "xmlns", "=", "namespace", ")", "ver", "=", "self", ".", "_callback"...
Returns firmware version. Args: None Returns: Dictionary Raises: None
[ "Returns", "firmware", "version", "." ]
python
train
sveetch/boussole
boussole/inspector.py
https://github.com/sveetch/boussole/blob/22cc644e9d633f41ebfc167d427a71c1726cee21/boussole/inspector.py#L181-L200
def children(self, sourcepath, recursive=True): """ Recursively find all children that are imported from the given source path. Args: sourcepath (str): Source file path to search for. Keyword Arguments: recursive (bool): Switch to enabled recursive findi...
[ "def", "children", "(", "self", ",", "sourcepath", ",", "recursive", "=", "True", ")", ":", "return", "self", ".", "_get_recursive_dependancies", "(", "self", ".", "_CHILDREN_MAP", ",", "sourcepath", ",", "recursive", "=", "True", ")" ]
Recursively find all children that are imported from the given source path. Args: sourcepath (str): Source file path to search for. Keyword Arguments: recursive (bool): Switch to enabled recursive finding (if True). Default to True. Returns: ...
[ "Recursively", "find", "all", "children", "that", "are", "imported", "from", "the", "given", "source", "path", "." ]
python
train
licenses/lice
lice/core.py
https://github.com/licenses/lice/blob/71635c2544d5edf9e93af4141467763916a86624/lice/core.py#L93-L100
def clean_path(p): """ Clean a path by expanding user and environment variables and ensuring absolute path. """ p = os.path.expanduser(p) p = os.path.expandvars(p) p = os.path.abspath(p) return p
[ "def", "clean_path", "(", "p", ")", ":", "p", "=", "os", ".", "path", ".", "expanduser", "(", "p", ")", "p", "=", "os", ".", "path", ".", "expandvars", "(", "p", ")", "p", "=", "os", ".", "path", ".", "abspath", "(", "p", ")", "return", "p" ]
Clean a path by expanding user and environment variables and ensuring absolute path.
[ "Clean", "a", "path", "by", "expanding", "user", "and", "environment", "variables", "and", "ensuring", "absolute", "path", "." ]
python
train
openstax/cnx-archive
cnxarchive/views/sitemap.py
https://github.com/openstax/cnx-archive/blob/d31d34aa8bbc8a9fde6cd4227a0df92726e8daf4/cnxarchive/views/sitemap.py#L39-L47
def notblocked(page): """Determine if given url is a page that should be in sitemap.""" for blocked in PAGES_TO_BLOCK: if blocked[0] != '*': blocked = '*' + blocked rx = re.compile(blocked.replace('*', '[^$]*')) if rx.match(page): return False return True
[ "def", "notblocked", "(", "page", ")", ":", "for", "blocked", "in", "PAGES_TO_BLOCK", ":", "if", "blocked", "[", "0", "]", "!=", "'*'", ":", "blocked", "=", "'*'", "+", "blocked", "rx", "=", "re", ".", "compile", "(", "blocked", ".", "replace", "(", ...
Determine if given url is a page that should be in sitemap.
[ "Determine", "if", "given", "url", "is", "a", "page", "that", "should", "be", "in", "sitemap", "." ]
python
train
airspeed-velocity/asv
asv/extern/asizeof.py
https://github.com/airspeed-velocity/asv/blob/d23bb8b74e8adacbfa3cf5724bda55fb39d56ba6/asv/extern/asizeof.py#L1468-L1478
def update(self, obj, size): '''Update this profile. ''' self.number += 1 self.total += size if self.high < size: # largest self.high = size try: # prefer using weak ref self.objref, self.weak = Weakref.ref(obj), True except Type...
[ "def", "update", "(", "self", ",", "obj", ",", "size", ")", ":", "self", ".", "number", "+=", "1", "self", ".", "total", "+=", "size", "if", "self", ".", "high", "<", "size", ":", "# largest", "self", ".", "high", "=", "size", "try", ":", "# pref...
Update this profile.
[ "Update", "this", "profile", "." ]
python
train
dade-ai/snipy
snipy/io/fileutil.py
https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/io/fileutil.py#L348-L359
def walkfolder(toppath, pred): """ walk folder if pred(foldername) is True :type toppath: str :type pred: function(str) => bool """ for entry in scandir.scandir(toppath): if not entry.is_dir() or not pred(entry.name): continue yield entry.path for p in walkfol...
[ "def", "walkfolder", "(", "toppath", ",", "pred", ")", ":", "for", "entry", "in", "scandir", ".", "scandir", "(", "toppath", ")", ":", "if", "not", "entry", ".", "is_dir", "(", ")", "or", "not", "pred", "(", "entry", ".", "name", ")", ":", "continu...
walk folder if pred(foldername) is True :type toppath: str :type pred: function(str) => bool
[ "walk", "folder", "if", "pred", "(", "foldername", ")", "is", "True", ":", "type", "toppath", ":", "str", ":", "type", "pred", ":", "function", "(", "str", ")", "=", ">", "bool" ]
python
valid
samuelcolvin/arq
arq/worker.py
https://github.com/samuelcolvin/arq/blob/1434646b48c45bd27e392f0162976404e4d8021d/arq/worker.py#L213-L225
async def run_check(self) -> int: """ Run :func:`arq.worker.Worker.async_run`, check for failed jobs and raise :class:`arq.worker.FailedJobs` if any jobs have failed. :return: number of completed jobs """ await self.async_run() if self.jobs_failed: fa...
[ "async", "def", "run_check", "(", "self", ")", "->", "int", ":", "await", "self", ".", "async_run", "(", ")", "if", "self", ".", "jobs_failed", ":", "failed_job_results", "=", "[", "r", "for", "r", "in", "await", "self", ".", "pool", ".", "all_job_resu...
Run :func:`arq.worker.Worker.async_run`, check for failed jobs and raise :class:`arq.worker.FailedJobs` if any jobs have failed. :return: number of completed jobs
[ "Run", ":", "func", ":", "arq", ".", "worker", ".", "Worker", ".", "async_run", "check", "for", "failed", "jobs", "and", "raise", ":", "class", ":", "arq", ".", "worker", ".", "FailedJobs", "if", "any", "jobs", "have", "failed", "." ]
python
train
captin411/ofxclient
ofxclient/institution.py
https://github.com/captin411/ofxclient/blob/4da2719f0ecbbf5eee62fb82c1b3b34ec955ee5e/ofxclient/institution.py#L134-L151
def accounts(self): """Ask the bank for the known :py:class:`ofxclient.Account` list. :rtype: list of :py:class:`ofxclient.Account` objects """ from ofxclient.account import Account client = self.client() query = client.account_list_query() resp = client.post(que...
[ "def", "accounts", "(", "self", ")", ":", "from", "ofxclient", ".", "account", "import", "Account", "client", "=", "self", ".", "client", "(", ")", "query", "=", "client", ".", "account_list_query", "(", ")", "resp", "=", "client", ".", "post", "(", "q...
Ask the bank for the known :py:class:`ofxclient.Account` list. :rtype: list of :py:class:`ofxclient.Account` objects
[ "Ask", "the", "bank", "for", "the", "known", ":", "py", ":", "class", ":", "ofxclient", ".", "Account", "list", "." ]
python
train
tensorpack/tensorpack
examples/basics/export-model.py
https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/examples/basics/export-model.py#L106-L113
def export_serving(model_path): """Export trained model to use it in TensorFlow Serving or cloudML. """ pred_config = PredictConfig( session_init=get_model_loader(model_path), model=InferenceOnlyModel(), input_names=['input_img_bytes'], output_names=['prediction_img_bytes']) ...
[ "def", "export_serving", "(", "model_path", ")", ":", "pred_config", "=", "PredictConfig", "(", "session_init", "=", "get_model_loader", "(", "model_path", ")", ",", "model", "=", "InferenceOnlyModel", "(", ")", ",", "input_names", "=", "[", "'input_img_bytes'", ...
Export trained model to use it in TensorFlow Serving or cloudML.
[ "Export", "trained", "model", "to", "use", "it", "in", "TensorFlow", "Serving", "or", "cloudML", "." ]
python
train
tornadoweb/tornado
tornado/auth.py
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/auth.py#L468-L490
async def _oauth_get_user_future( self, access_token: Dict[str, Any] ) -> Dict[str, Any]: """Subclasses must override this to get basic information about the user. Should be a coroutine whose result is a dictionary containing information about the user, which may have been ...
[ "async", "def", "_oauth_get_user_future", "(", "self", ",", "access_token", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "raise", "NotImplementedError", "(", ")" ]
Subclasses must override this to get basic information about the user. Should be a coroutine whose result is a dictionary containing information about the user, which may have been retrieved by using ``access_token`` to make a request to the service. The access token wi...
[ "Subclasses", "must", "override", "this", "to", "get", "basic", "information", "about", "the", "user", "." ]
python
train
Alignak-monitoring/alignak
alignak/downtime.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/downtime.py#L379-L394
def get_raise_brok(self, host_name, service_name=''): """Get a start downtime brok :param host_name: host concerned by the downtime :type host_name :param service_name: service concerned by the downtime :type service_name :return: brok with wanted data :rtype: al...
[ "def", "get_raise_brok", "(", "self", ",", "host_name", ",", "service_name", "=", "''", ")", ":", "data", "=", "self", ".", "serialize", "(", ")", "data", "[", "'host'", "]", "=", "host_name", "if", "service_name", "!=", "''", ":", "data", "[", "'servi...
Get a start downtime brok :param host_name: host concerned by the downtime :type host_name :param service_name: service concerned by the downtime :type service_name :return: brok with wanted data :rtype: alignak.brok.Brok
[ "Get", "a", "start", "downtime", "brok" ]
python
train
dwavesystems/dwave_networkx
dwave_networkx/drawing/chimera_layout.py
https://github.com/dwavesystems/dwave_networkx/blob/9ea1223ddbc7e86db2f90b8b23e250e6642c3d68/dwave_networkx/drawing/chimera_layout.py#L295-L336
def draw_chimera_yield(G, **kwargs): """Draws the given graph G with highlighted faults, according to layout. Parameters ---------- G : NetworkX graph The graph to be parsed for faults unused_color : tuple or color string (optional, default (0.9,0.9,0.9,1.0)) The color to use for n...
[ "def", "draw_chimera_yield", "(", "G", ",", "*", "*", "kwargs", ")", ":", "try", ":", "assert", "(", "G", ".", "graph", "[", "\"family\"", "]", "==", "\"chimera\"", ")", "m", "=", "G", ".", "graph", "[", "\"columns\"", "]", "n", "=", "G", ".", "g...
Draws the given graph G with highlighted faults, according to layout. Parameters ---------- G : NetworkX graph The graph to be parsed for faults unused_color : tuple or color string (optional, default (0.9,0.9,0.9,1.0)) The color to use for nodes and edges of G which are not faults. ...
[ "Draws", "the", "given", "graph", "G", "with", "highlighted", "faults", "according", "to", "layout", "." ]
python
train
log2timeline/plaso
plaso/formatters/manager.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/formatters/manager.py#L37-L64
def GetFormatterObject(cls, data_type): """Retrieves the formatter object for a specific data type. Args: data_type (str): data type. Returns: EventFormatter: corresponding formatter or the default formatter if not available. """ data_type = data_type.lower() if data_type...
[ "def", "GetFormatterObject", "(", "cls", ",", "data_type", ")", ":", "data_type", "=", "data_type", ".", "lower", "(", ")", "if", "data_type", "not", "in", "cls", ".", "_formatter_objects", ":", "formatter_object", "=", "None", "if", "data_type", "in", "cls"...
Retrieves the formatter object for a specific data type. Args: data_type (str): data type. Returns: EventFormatter: corresponding formatter or the default formatter if not available.
[ "Retrieves", "the", "formatter", "object", "for", "a", "specific", "data", "type", "." ]
python
train
singularityhub/sregistry-cli
sregistry/main/s3/__init__.py
https://github.com/singularityhub/sregistry-cli/blob/abc96140a1d15b5e96d83432e1e0e1f4f8f36331/sregistry/main/s3/__init__.py#L118-L141
def _update_secrets(self, base=None): '''update secrets will update/get the base for the server, along with the bucket name, defaulting to sregistry. ''' # We are required to have a base, either from environment or terminal self.base = self._get_and_update_setting('SREGISTRY_S...
[ "def", "_update_secrets", "(", "self", ",", "base", "=", "None", ")", ":", "# We are required to have a base, either from environment or terminal", "self", ".", "base", "=", "self", ".", "_get_and_update_setting", "(", "'SREGISTRY_S3_BASE'", ",", "self", ".", "base", ...
update secrets will update/get the base for the server, along with the bucket name, defaulting to sregistry.
[ "update", "secrets", "will", "update", "/", "get", "the", "base", "for", "the", "server", "along", "with", "the", "bucket", "name", "defaulting", "to", "sregistry", "." ]
python
test
muckamuck/stackility
stackility/command.py
https://github.com/muckamuck/stackility/blob/b1696f02661134d31b99b4dea7c0d21d09482d33/stackility/command.py#L81-L102
def delete(stack, region, profile): """ Delete the given CloudFormation stack. """ ini_data = {} environment = {} environment['stack_name'] = stack if region: environment['region'] = region else: environment['region'] = find_myself() if profile: environment[...
[ "def", "delete", "(", "stack", ",", "region", ",", "profile", ")", ":", "ini_data", "=", "{", "}", "environment", "=", "{", "}", "environment", "[", "'stack_name'", "]", "=", "stack", "if", "region", ":", "environment", "[", "'region'", "]", "=", "regi...
Delete the given CloudFormation stack.
[ "Delete", "the", "given", "CloudFormation", "stack", "." ]
python
train
Dentosal/python-sc2
sc2/game_data.py
https://github.com/Dentosal/python-sc2/blob/608bd25f04e89d39cef68b40101d8e9a8a7f1634/sc2/game_data.py#L222-L234
def cost_zerg_corrected(self) -> "Cost": """ This returns 25 for extractor and 200 for spawning pool instead of 75 and 250 respectively """ if self.race == Race.Zerg and Attribute.Structure.value in self.attributes: # a = self._game_data.units(UnitTypeId.ZERGLING) # print(a) ...
[ "def", "cost_zerg_corrected", "(", "self", ")", "->", "\"Cost\"", ":", "if", "self", ".", "race", "==", "Race", ".", "Zerg", "and", "Attribute", ".", "Structure", ".", "value", "in", "self", ".", "attributes", ":", "# a = self._game_data.units(UnitTypeId.ZERGLIN...
This returns 25 for extractor and 200 for spawning pool instead of 75 and 250 respectively
[ "This", "returns", "25", "for", "extractor", "and", "200", "for", "spawning", "pool", "instead", "of", "75", "and", "250", "respectively" ]
python
train
Bogdanp/anom-py
anom/conditions.py
https://github.com/Bogdanp/anom-py/blob/519078b6d1570fa63c5f17cf98817c7bb5588136/anom/conditions.py#L36-L38
def is_false(entity, prop, name): "bool: True if the value of a property is False." return is_not_empty(entity, prop, name) and name in entity._data and not bool(getattr(entity, name))
[ "def", "is_false", "(", "entity", ",", "prop", ",", "name", ")", ":", "return", "is_not_empty", "(", "entity", ",", "prop", ",", "name", ")", "and", "name", "in", "entity", ".", "_data", "and", "not", "bool", "(", "getattr", "(", "entity", ",", "name...
bool: True if the value of a property is False.
[ "bool", ":", "True", "if", "the", "value", "of", "a", "property", "is", "False", "." ]
python
train
swimlane/swimlane-python
swimlane/core/cache.py
https://github.com/swimlane/swimlane-python/blob/588fc503a76799bcdb5aecdf2f64a6ee05e3922d/swimlane/core/cache.py#L96-L103
def clear(self, *resource_types): """Clear cache for each provided APIResource class, or all resources if no classes are provided""" resource_types = resource_types or tuple(self.__caches.keys()) for cls in resource_types: # Clear and delete cache instances to guarantee no lingering...
[ "def", "clear", "(", "self", ",", "*", "resource_types", ")", ":", "resource_types", "=", "resource_types", "or", "tuple", "(", "self", ".", "__caches", ".", "keys", "(", ")", ")", "for", "cls", "in", "resource_types", ":", "# Clear and delete cache instances ...
Clear cache for each provided APIResource class, or all resources if no classes are provided
[ "Clear", "cache", "for", "each", "provided", "APIResource", "class", "or", "all", "resources", "if", "no", "classes", "are", "provided" ]
python
train
quantmind/dynts
dynts/api/timeseries.py
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L150-L155
def dates(self, desc=None): '''Returns an iterable over ``datetime.date`` instances in the timeseries.''' c = self.dateinverse for key in self.keys(desc=desc): yield c(key)
[ "def", "dates", "(", "self", ",", "desc", "=", "None", ")", ":", "c", "=", "self", ".", "dateinverse", "for", "key", "in", "self", ".", "keys", "(", "desc", "=", "desc", ")", ":", "yield", "c", "(", "key", ")" ]
Returns an iterable over ``datetime.date`` instances in the timeseries.
[ "Returns", "an", "iterable", "over", "datetime", ".", "date", "instances", "in", "the", "timeseries", "." ]
python
train
MolSSI-BSE/basis_set_exchange
basis_set_exchange/printing.py
https://github.com/MolSSI-BSE/basis_set_exchange/blob/e79110aaeb65f392ed5032420322dee3336948f7/basis_set_exchange/printing.py#L90-L105
def ecp_pot_str(pot): '''Return a string representing the data for an ECP potential ''' am = pot['angular_momentum'] amchar = lut.amint_to_char(am) rexponents = pot['r_exponents'] gexponents = pot['gaussian_exponents'] coefficients = pot['coefficients'] point_places = [0, 10, 33] ...
[ "def", "ecp_pot_str", "(", "pot", ")", ":", "am", "=", "pot", "[", "'angular_momentum'", "]", "amchar", "=", "lut", ".", "amint_to_char", "(", "am", ")", "rexponents", "=", "pot", "[", "'r_exponents'", "]", "gexponents", "=", "pot", "[", "'gaussian_exponen...
Return a string representing the data for an ECP potential
[ "Return", "a", "string", "representing", "the", "data", "for", "an", "ECP", "potential" ]
python
train
HEPData/hepdata-converter
hepdata_converter/parsers/oldhepdata_parser.py
https://github.com/HEPData/hepdata-converter/blob/354271448980efba86f2f3d27b99d818e75fd90d/hepdata_converter/parsers/oldhepdata_parser.py#L204-L406
def _parse_table_data(self, data): """Parse dataset data of the original HEPData format :param data: header of the table to be parsed :raise ValueError: """ header = data.split(':') self.current_table.data_header = header for i, h in enumerate(header): ...
[ "def", "_parse_table_data", "(", "self", ",", "data", ")", ":", "header", "=", "data", ".", "split", "(", "':'", ")", "self", ".", "current_table", ".", "data_header", "=", "header", "for", "i", ",", "h", "in", "enumerate", "(", "header", ")", ":", "...
Parse dataset data of the original HEPData format :param data: header of the table to be parsed :raise ValueError:
[ "Parse", "dataset", "data", "of", "the", "original", "HEPData", "format" ]
python
train
johntfoster/bspline
bspline/bspline.py
https://github.com/johntfoster/bspline/blob/366085a665da6fe907258eafcc8032c58a0601e0/bspline/bspline.py#L131-L133
def d(self, xi): """Convenience function to compute first derivative of basis functions. 'Memoized' for speed.""" return self.__basis(xi, self.p, compute_derivatives=True)
[ "def", "d", "(", "self", ",", "xi", ")", ":", "return", "self", ".", "__basis", "(", "xi", ",", "self", ".", "p", ",", "compute_derivatives", "=", "True", ")" ]
Convenience function to compute first derivative of basis functions. 'Memoized' for speed.
[ "Convenience", "function", "to", "compute", "first", "derivative", "of", "basis", "functions", ".", "Memoized", "for", "speed", "." ]
python
train
mehmetg/streak_client
streak_client/streak_client.py
https://github.com/mehmetg/streak_client/blob/46575510b4e4163a4a3cc06f7283a1ae377cdce6/streak_client/streak_client.py#L1050-L1062
def get_box_files(self, box_key): '''Gets to file infos in a single box. Args: box_key key for the file return (status code, list of file info dicts) ''' uri = '/'.join([self.api_uri, self.boxes_suffix, box_key, self.files_suffix ]) return self._req('get', uri)
[ "def", "get_box_files", "(", "self", ",", "box_key", ")", ":", "uri", "=", "'/'", ".", "join", "(", "[", "self", ".", "api_uri", ",", "self", ".", "boxes_suffix", ",", "box_key", ",", "self", ".", "files_suffix", "]", ")", "return", "self", ".", "_re...
Gets to file infos in a single box. Args: box_key key for the file return (status code, list of file info dicts)
[ "Gets", "to", "file", "infos", "in", "a", "single", "box", ".", "Args", ":", "box_key", "key", "for", "the", "file", "return", "(", "status", "code", "list", "of", "file", "info", "dicts", ")" ]
python
train
theosysbio/means
src/means/inference/inference.py
https://github.com/theosysbio/means/blob/fe164916a1d84ab2a4fa039871d38ccdf638b1db/src/means/inference/inference.py#L221-L241
def infer(self, number_of_processes=1, *args, **kwargs): """ :param number_of_processes: If set to more than 1, the inference routines will be paralellised using ``multiprocessing`` module :param args: arguments to pass to :meth:`Inference.infer` :para...
[ "def", "infer", "(", "self", ",", "number_of_processes", "=", "1", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "number_of_processes", "==", "1", ":", "results", "=", "map", "(", "lambda", "x", ":", "x", ".", "infer", "(", "*", "args"...
:param number_of_processes: If set to more than 1, the inference routines will be paralellised using ``multiprocessing`` module :param args: arguments to pass to :meth:`Inference.infer` :param kwargs: keyword arguments to pass to :meth:`Inference.infer` :retur...
[ ":", "param", "number_of_processes", ":", "If", "set", "to", "more", "than", "1", "the", "inference", "routines", "will", "be", "paralellised", "using", "multiprocessing", "module", ":", "param", "args", ":", "arguments", "to", "pass", "to", ":", "meth", ":"...
python
train
basho/riak-python-client
riak/transports/tcp/connection.py
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/tcp/connection.py#L82-L91
def _init_security(self): """ Initialize a secure connection to the server. """ if not self._starttls(): raise SecurityError("Could not start TLS connection") # _ssh_handshake() will throw an exception upon failure self._ssl_handshake() if not self._au...
[ "def", "_init_security", "(", "self", ")", ":", "if", "not", "self", ".", "_starttls", "(", ")", ":", "raise", "SecurityError", "(", "\"Could not start TLS connection\"", ")", "# _ssh_handshake() will throw an exception upon failure", "self", ".", "_ssl_handshake", "(",...
Initialize a secure connection to the server.
[ "Initialize", "a", "secure", "connection", "to", "the", "server", "." ]
python
train
twisted/axiom
axiom/scheduler.py
https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/scheduler.py#L217-L224
def scheduledTimes(self, runnable): """ Return an iterable of the times at which the given item is scheduled to run. """ events = self.store.query( TimedEvent, TimedEvent.runnable == runnable) return (event.time for event in events if not event.running)
[ "def", "scheduledTimes", "(", "self", ",", "runnable", ")", ":", "events", "=", "self", ".", "store", ".", "query", "(", "TimedEvent", ",", "TimedEvent", ".", "runnable", "==", "runnable", ")", "return", "(", "event", ".", "time", "for", "event", "in", ...
Return an iterable of the times at which the given item is scheduled to run.
[ "Return", "an", "iterable", "of", "the", "times", "at", "which", "the", "given", "item", "is", "scheduled", "to", "run", "." ]
python
train
saltstack/salt
salt/states/junos.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/junos.py#L157-L188
def rollback(name, **kwargs): ''' Rollbacks the committed changes. .. code-block:: yaml rollback the changes: junos: - rollback - id: 5 Parameters: Optional * id: The rollback id value [0-49]. (default = 0) * kw...
[ "def", "rollback", "(", "name", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "True", ",", "'comment'", ":", "''", "}", "ret", "[", "'changes'", "]", "=", "__salt...
Rollbacks the committed changes. .. code-block:: yaml rollback the changes: junos: - rollback - id: 5 Parameters: Optional * id: The rollback id value [0-49]. (default = 0) * kwargs: Keyworded arguments which can be pro...
[ "Rollbacks", "the", "committed", "changes", "." ]
python
train
spacetelescope/stsci.tools
lib/stsci/tools/basicpar.py
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/basicpar.py#L489-L526
def save(self, dolist=0): """Return .par format string for this parameter If dolist is set, returns fields as a list of strings. Default is to return a single string appropriate for writing to a file. """ quoted = not dolist fields = 7*[""] fields[0] = self.name...
[ "def", "save", "(", "self", ",", "dolist", "=", "0", ")", ":", "quoted", "=", "not", "dolist", "fields", "=", "7", "*", "[", "\"\"", "]", "fields", "[", "0", "]", "=", "self", ".", "name", "fields", "[", "1", "]", "=", "self", ".", "type", "f...
Return .par format string for this parameter If dolist is set, returns fields as a list of strings. Default is to return a single string appropriate for writing to a file.
[ "Return", ".", "par", "format", "string", "for", "this", "parameter" ]
python
train
saltstack/salt
salt/modules/infoblox.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/infoblox.py#L351-L382
def get_host_hostname(name, domains=None, **api_opts): ''' Get hostname If no domains are passed, the hostname is checked for a zone in infoblox, if no zone split on first dot. If domains are provided, the best match out of the list is truncated from the fqdn leaving the hostname. If no m...
[ "def", "get_host_hostname", "(", "name", ",", "domains", "=", "None", ",", "*", "*", "api_opts", ")", ":", "name", "=", "name", ".", "lower", "(", ")", ".", "rstrip", "(", "'.'", ")", "if", "not", "domains", ":", "return", "name", ".", "split", "("...
Get hostname If no domains are passed, the hostname is checked for a zone in infoblox, if no zone split on first dot. If domains are provided, the best match out of the list is truncated from the fqdn leaving the hostname. If no matching domains are found the fqdn is returned. dots at end of...
[ "Get", "hostname" ]
python
train
fstab50/metal
metal/script_utils.py
https://github.com/fstab50/metal/blob/0488bbdd516a508909267cc44191f632e21156ba/metal/script_utils.py#L391-L412
def read_local_config(cfg): """ Parses local config file for override values Args: :local_file (str): filename of local config file Returns: dict object of values contained in local config file """ try: if os.path.exists(cfg): config = import_file_object(cfg) ...
[ "def", "read_local_config", "(", "cfg", ")", ":", "try", ":", "if", "os", ".", "path", ".", "exists", "(", "cfg", ")", ":", "config", "=", "import_file_object", "(", "cfg", ")", "return", "config", "else", ":", "logger", ".", "warning", "(", "'%s: loca...
Parses local config file for override values Args: :local_file (str): filename of local config file Returns: dict object of values contained in local config file
[ "Parses", "local", "config", "file", "for", "override", "values" ]
python
train
kstaniek/condoor
condoor/fsm.py
https://github.com/kstaniek/condoor/blob/77c054b29d4e286c1d7aca2c74dff86b805e1fae/condoor/fsm.py#L152-L218
def run(self): """Start the FSM. Returns: boolean: True if FSM reaches the last state or false if the exception or error message was raised """ ctx = FSM.Context(self.name, self.device) transition_counter = 0 timeout = self.timeout self.log("{} Start...
[ "def", "run", "(", "self", ")", ":", "ctx", "=", "FSM", ".", "Context", "(", "self", ".", "name", ",", "self", ".", "device", ")", "transition_counter", "=", "0", "timeout", "=", "self", ".", "timeout", "self", ".", "log", "(", "\"{} Start\"", ".", ...
Start the FSM. Returns: boolean: True if FSM reaches the last state or false if the exception or error message was raised
[ "Start", "the", "FSM", "." ]
python
train
CityOfZion/neo-python
neo/Network/Payloads/InvPayload.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Network/Payloads/InvPayload.py#L26-L36
def Size(self): """ Get the total size in bytes of the object. Returns: int: size. """ if len(self.Hashes) > 0: if not isinstance(self.Hashes[0], UInt256): corrected_hashes = list(map(lambda i: UInt256(data=binascii.unhexlify(i)), self.Has...
[ "def", "Size", "(", "self", ")", ":", "if", "len", "(", "self", ".", "Hashes", ")", ">", "0", ":", "if", "not", "isinstance", "(", "self", ".", "Hashes", "[", "0", "]", ",", "UInt256", ")", ":", "corrected_hashes", "=", "list", "(", "map", "(", ...
Get the total size in bytes of the object. Returns: int: size.
[ "Get", "the", "total", "size", "in", "bytes", "of", "the", "object", "." ]
python
train
jantman/pypi-download-stats
pypi_download_stats/projectstats.py
https://github.com/jantman/pypi-download-stats/blob/44a7a6bbcd61a9e7f02bd02c52584a98183f80c5/pypi_download_stats/projectstats.py#L290-L307
def per_system_data(self): """ Return download data by system. :return: dict of cache data; keys are datetime objects, values are dict of system (str) to count (int) :rtype: dict """ ret = {} for cache_date in self.cache_dates: data = self._...
[ "def", "per_system_data", "(", "self", ")", ":", "ret", "=", "{", "}", "for", "cache_date", "in", "self", ".", "cache_dates", ":", "data", "=", "self", ".", "_cache_get", "(", "cache_date", ")", "ret", "[", "cache_date", "]", "=", "{", "self", ".", "...
Return download data by system. :return: dict of cache data; keys are datetime objects, values are dict of system (str) to count (int) :rtype: dict
[ "Return", "download", "data", "by", "system", "." ]
python
train
eddiejessup/fealty
fealty/lattice.py
https://github.com/eddiejessup/fealty/blob/03745eb98d85bc2a5d08920773ab9c4515462d30/fealty/lattice.py#L78-L105
def pad_length(x, d): """Return a vector appropriate to a dimensional space, using an input vector as a prompt depending on its type: - If the input is a vector, return that vector. - If the input is a scalar, return a vector filled with that value. Useful when a function expects an array ...
[ "def", "pad_length", "(", "x", ",", "d", ")", ":", "try", ":", "x", "[", "0", "]", "except", "TypeError", ":", "x", "=", "d", "*", "[", "x", "]", "return", "np", ".", "array", "(", "x", ")" ]
Return a vector appropriate to a dimensional space, using an input vector as a prompt depending on its type: - If the input is a vector, return that vector. - If the input is a scalar, return a vector filled with that value. Useful when a function expects an array specifying values along each ...
[ "Return", "a", "vector", "appropriate", "to", "a", "dimensional", "space", "using", "an", "input", "vector", "as", "a", "prompt", "depending", "on", "its", "type", ":" ]
python
train
zero-os/zerotier_client
zerotier/client_support.py
https://github.com/zero-os/zerotier_client/blob/03993da11e69d837a0308a2f41ae7b378692fd82/zerotier/client_support.py#L75-L90
def val_factory(val, datatypes): """ return an instance of `val` that is of type `datatype`. keep track of exceptions so we can produce meaningful error messages. """ exceptions = [] for dt in datatypes: try: if isinstance(val, dt): return val retu...
[ "def", "val_factory", "(", "val", ",", "datatypes", ")", ":", "exceptions", "=", "[", "]", "for", "dt", "in", "datatypes", ":", "try", ":", "if", "isinstance", "(", "val", ",", "dt", ")", ":", "return", "val", "return", "type_handler_object", "(", "val...
return an instance of `val` that is of type `datatype`. keep track of exceptions so we can produce meaningful error messages.
[ "return", "an", "instance", "of", "val", "that", "is", "of", "type", "datatype", ".", "keep", "track", "of", "exceptions", "so", "we", "can", "produce", "meaningful", "error", "messages", "." ]
python
train
PGower/PyCanvas
pycanvas/apis/users.py
https://github.com/PGower/PyCanvas/blob/68520005382b440a1e462f9df369f54d364e21e8/pycanvas/apis/users.py#L668-L694
def update_user_settings(self, id, collapse_global_nav=None, manual_mark_as_read=None): """ Update user settings. Update an existing user's settings. """ path = {} data = {} params = {} # REQUIRED - PATH - id """ID""" path["id...
[ "def", "update_user_settings", "(", "self", ",", "id", ",", "collapse_global_nav", "=", "None", ",", "manual_mark_as_read", "=", "None", ")", ":", "path", "=", "{", "}", "data", "=", "{", "}", "params", "=", "{", "}", "# REQUIRED - PATH - id\r", "\"\"\"ID\"\...
Update user settings. Update an existing user's settings.
[ "Update", "user", "settings", ".", "Update", "an", "existing", "user", "s", "settings", "." ]
python
train