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
Fantomas42/django-blog-zinnia
zinnia/context.py
https://github.com/Fantomas42/django-blog-zinnia/blob/b4949304b104a8e1a7a7a0773cbfd024313c3a15/zinnia/context.py#L25-L40
def get_context_loop_positions(context): """ Return the paginated current position within a loop, and the non-paginated position. """ try: loop_counter = context['forloop']['counter'] except KeyError: return 0, 0 try: page = context['page_obj'] except KeyError: ...
[ "def", "get_context_loop_positions", "(", "context", ")", ":", "try", ":", "loop_counter", "=", "context", "[", "'forloop'", "]", "[", "'counter'", "]", "except", "KeyError", ":", "return", "0", ",", "0", "try", ":", "page", "=", "context", "[", "'page_obj...
Return the paginated current position within a loop, and the non-paginated position.
[ "Return", "the", "paginated", "current", "position", "within", "a", "loop", "and", "the", "non", "-", "paginated", "position", "." ]
python
train
pandas-dev/pandas
pandas/core/frame.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L2057-L2069
def to_feather(self, fname): """ Write out the binary feather-format for DataFrames. .. versionadded:: 0.20.0 Parameters ---------- fname : str string file path """ from pandas.io.feather_format import to_feather to_feather(self, fnam...
[ "def", "to_feather", "(", "self", ",", "fname", ")", ":", "from", "pandas", ".", "io", ".", "feather_format", "import", "to_feather", "to_feather", "(", "self", ",", "fname", ")" ]
Write out the binary feather-format for DataFrames. .. versionadded:: 0.20.0 Parameters ---------- fname : str string file path
[ "Write", "out", "the", "binary", "feather", "-", "format", "for", "DataFrames", "." ]
python
train
projectshift/shift-schema
shiftschema/result.py
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/result.py#L352-L359
def format_error(self, error, args=None): """ Format error with positional or named arguments (if any) """ if type(args) is dict: return error.format(**args) if type(args) is list or type(args) is tuple: return error.format(*args) return error
[ "def", "format_error", "(", "self", ",", "error", ",", "args", "=", "None", ")", ":", "if", "type", "(", "args", ")", "is", "dict", ":", "return", "error", ".", "format", "(", "*", "*", "args", ")", "if", "type", "(", "args", ")", "is", "list", ...
Format error with positional or named arguments (if any)
[ "Format", "error", "with", "positional", "or", "named", "arguments", "(", "if", "any", ")" ]
python
train
4degrees/riffle
source/riffle/browser.py
https://github.com/4degrees/riffle/blob/e5a0d908df8c93ff1ee7abdda8875fd1667df53d/source/riffle/browser.py#L146-L151
def _onNavigate(self, index): '''Handle selection of path segment.''' if index > 0: self.setLocation( self._locationWidget.itemData(index), interactive=True )
[ "def", "_onNavigate", "(", "self", ",", "index", ")", ":", "if", "index", ">", "0", ":", "self", ".", "setLocation", "(", "self", ".", "_locationWidget", ".", "itemData", "(", "index", ")", ",", "interactive", "=", "True", ")" ]
Handle selection of path segment.
[ "Handle", "selection", "of", "path", "segment", "." ]
python
test
chaoss/grimoirelab-kingarthur
arthur/server.py
https://github.com/chaoss/grimoirelab-kingarthur/blob/9d6a638bee68d5e5c511f045eeebf06340fd3252/arthur/server.py#L73-L82
def write_items(cls, writer, items_generator): """Write items to the queue :param writer: the writer object :param items_generator: items to be written in the queue """ while True: items = items_generator() writer.write(items) time.sleep(1)
[ "def", "write_items", "(", "cls", ",", "writer", ",", "items_generator", ")", ":", "while", "True", ":", "items", "=", "items_generator", "(", ")", "writer", ".", "write", "(", "items", ")", "time", ".", "sleep", "(", "1", ")" ]
Write items to the queue :param writer: the writer object :param items_generator: items to be written in the queue
[ "Write", "items", "to", "the", "queue" ]
python
test
SheffieldML/GPy
GPy/kern/src/ODE_UYC.py
https://github.com/SheffieldML/GPy/blob/54c32d79d289d622fb18b898aee65a2a431d90cf/GPy/kern/src/ODE_UYC.py#L96-L121
def Kdiag(self, X): """Compute the diagonal of the covariance matrix associated to X.""" Kdiag = np.zeros(X.shape[0]) ly=1/self.lengthscale_Y lu=np.sqrt(3)/self.lengthscale_U Vu = self.variance_U Vy=self.variance_Y k1 = (2*lu+ly)/(lu+ly)**2 k2 = (ly-2*lu...
[ "def", "Kdiag", "(", "self", ",", "X", ")", ":", "Kdiag", "=", "np", ".", "zeros", "(", "X", ".", "shape", "[", "0", "]", ")", "ly", "=", "1", "/", "self", ".", "lengthscale_Y", "lu", "=", "np", ".", "sqrt", "(", "3", ")", "/", "self", ".",...
Compute the diagonal of the covariance matrix associated to X.
[ "Compute", "the", "diagonal", "of", "the", "covariance", "matrix", "associated", "to", "X", "." ]
python
train
SchroterQuentin/django-search-listview
search_listview/list.py
https://github.com/SchroterQuentin/django-search-listview/blob/8b027a6908dc30c6ebc613bb4fde6b1ba40124a3/search_listview/list.py#L184-L190
def alias_field(model, field): """ Return the prefix name of a field """ for part in field.split(LOOKUP_SEP)[:-1]: model = associate_model(model,part) return model.__name__ + "-" + field.split(LOOKUP_SEP)[-1]
[ "def", "alias_field", "(", "model", ",", "field", ")", ":", "for", "part", "in", "field", ".", "split", "(", "LOOKUP_SEP", ")", "[", ":", "-", "1", "]", ":", "model", "=", "associate_model", "(", "model", ",", "part", ")", "return", "model", ".", "...
Return the prefix name of a field
[ "Return", "the", "prefix", "name", "of", "a", "field" ]
python
train
OSSOS/MOP
src/ossos/plotting/scripts/rose_topdown.py
https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/plotting/scripts/rose_topdown.py#L165-L205
def plot_ossos_discoveries(ax, discoveries, plot_discoveries, plot_colossos=False, split_plutinos=False): """ plotted at their discovery locations, provided by the Version Releases in decimal degrees. """ fc = ['b', '#E47833', 'k'] alpha = [0.85, 0.6, 1.] marker = ['o'...
[ "def", "plot_ossos_discoveries", "(", "ax", ",", "discoveries", ",", "plot_discoveries", ",", "plot_colossos", "=", "False", ",", "split_plutinos", "=", "False", ")", ":", "fc", "=", "[", "'b'", ",", "'#E47833'", ",", "'k'", "]", "alpha", "=", "[", "0.85",...
plotted at their discovery locations, provided by the Version Releases in decimal degrees.
[ "plotted", "at", "their", "discovery", "locations", "provided", "by", "the", "Version", "Releases", "in", "decimal", "degrees", "." ]
python
train
vinci1it2000/schedula
examples/processing_chain/utils/plot.py
https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/examples/processing_chain/utils/plot.py#L39-L52
def plot_lines(it): """ Plotting lines. :param it: Data to plot where key value is the name of the series. :type it: list[dict] :return: The plot. :rtype: plotly.plotly.iplot """ data = [go.Scatter(mode='lines', **d) for d in it] return py.iplot(data, filename='scat...
[ "def", "plot_lines", "(", "it", ")", ":", "data", "=", "[", "go", ".", "Scatter", "(", "mode", "=", "'lines'", ",", "*", "*", "d", ")", "for", "d", "in", "it", "]", "return", "py", ".", "iplot", "(", "data", ",", "filename", "=", "'scatter-mode'"...
Plotting lines. :param it: Data to plot where key value is the name of the series. :type it: list[dict] :return: The plot. :rtype: plotly.plotly.iplot
[ "Plotting", "lines", "." ]
python
train
androguard/androguard
androguard/core/bytecodes/axml/__init__.py
https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/core/bytecodes/axml/__init__.py#L833-L847
def getAttributeValue(self, index): """ This function is only used to look up strings All other work is done by :func:`~androguard.core.bytecodes.axml.format_value` # FIXME should unite those functions :param index: index of the attribute :return: """ ...
[ "def", "getAttributeValue", "(", "self", ",", "index", ")", ":", "offset", "=", "self", ".", "_get_attribute_offset", "(", "index", ")", "valueType", "=", "self", ".", "m_attributes", "[", "offset", "+", "ATTRIBUTE_IX_VALUE_TYPE", "]", "if", "valueType", "==",...
This function is only used to look up strings All other work is done by :func:`~androguard.core.bytecodes.axml.format_value` # FIXME should unite those functions :param index: index of the attribute :return:
[ "This", "function", "is", "only", "used", "to", "look", "up", "strings", "All", "other", "work", "is", "done", "by", ":", "func", ":", "~androguard", ".", "core", ".", "bytecodes", ".", "axml", ".", "format_value", "#", "FIXME", "should", "unite", "those...
python
train
nhfruchter/pgh-bustime
pghbustime/interface.py
https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/interface.py#L327-L360
def bulletins(self, rt="", rtdir="", stpid=""): """ Return list of service alerts ('bulletins') for a route or stop. Arguments: `rt`: route designator or `stpid`: bus stop number or (`rt` and `rtdir`) or (`rt` and `rtdir` and `stpid`) ...
[ "def", "bulletins", "(", "self", ",", "rt", "=", "\"\"", ",", "rtdir", "=", "\"\"", ",", "stpid", "=", "\"\"", ")", ":", "if", "not", "(", "rt", "or", "stpid", ")", "or", "(", "rtdir", "and", "not", "(", "rt", "or", "stpid", ")", ")", ":", "r...
Return list of service alerts ('bulletins') for a route or stop. Arguments: `rt`: route designator or `stpid`: bus stop number or (`rt` and `rtdir`) or (`rt` and `rtdir` and `stpid`) Response: `sb`: (bulletin container) conta...
[ "Return", "list", "of", "service", "alerts", "(", "bulletins", ")", "for", "a", "route", "or", "stop", ".", "Arguments", ":", "rt", ":", "route", "designator", "or", "stpid", ":", "bus", "stop", "number", "or", "(", "rt", "and", "rtdir", ")", "or", "...
python
train
mbj4668/pyang
pyang/translators/dsdl.py
https://github.com/mbj4668/pyang/blob/f2a5cc3142162e5b9ee4e18d154568d939ff63dd/pyang/translators/dsdl.py#L564-L575
def get_default(self, stmt, refd): """Return default value for `stmt` node. `refd` is a dictionary of applicable refinements that is constructed in the `process_patches` method. """ if refd["default"]: return refd["default"] defst = stmt.search_one("defau...
[ "def", "get_default", "(", "self", ",", "stmt", ",", "refd", ")", ":", "if", "refd", "[", "\"default\"", "]", ":", "return", "refd", "[", "\"default\"", "]", "defst", "=", "stmt", ".", "search_one", "(", "\"default\"", ")", "if", "defst", ":", "return"...
Return default value for `stmt` node. `refd` is a dictionary of applicable refinements that is constructed in the `process_patches` method.
[ "Return", "default", "value", "for", "stmt", "node", "." ]
python
train
jay-johnson/network-pipeline
network_pipeline/record_packets_to_csv.py
https://github.com/jay-johnson/network-pipeline/blob/4e53ae13fe12085e0cf2e5e1aff947368f4f1ffa/network_pipeline/record_packets_to_csv.py#L432-L467
def process_raw_frame(self, id=None, msg=None): """process_raw_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :pa...
[ "def", "process_raw_frame", "(", "self", ",", "id", "=", "None", ",", "msg", "=", "None", ")", ":", "# normalize into a dataframe", "df", "=", "json_normalize", "(", "msg", ")", "# convert to a flattened dictionary", "dt", "=", "json", ".", "loads", "(", "df",...
process_raw_frame Convert a complex nested json dictionary to a flattened dictionary and capture all unique keys for table construction :param id: key for this msg :param msg: raw frame for packet
[ "process_raw_frame" ]
python
train
rbarrois/mpdlcd
mpdlcd/utils.py
https://github.com/rbarrois/mpdlcd/blob/85f16c8cc0883f8abb4c2cc7f69729c3e2f857da/mpdlcd/utils.py#L50-L81
def auto_retry(fun): """Decorator for retrying method calls, based on instance parameters.""" @functools.wraps(fun) def decorated(instance, *args, **kwargs): """Wrapper around a decorated function.""" cfg = instance._retry_config remaining_tries = cfg.retry_attempts current_...
[ "def", "auto_retry", "(", "fun", ")", ":", "@", "functools", ".", "wraps", "(", "fun", ")", "def", "decorated", "(", "instance", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Wrapper around a decorated function.\"\"\"", "cfg", "=", "instance", ...
Decorator for retrying method calls, based on instance parameters.
[ "Decorator", "for", "retrying", "method", "calls", "based", "on", "instance", "parameters", "." ]
python
train
gem/oq-engine
openquake/hazardlib/probability_map.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/probability_map.py#L96-L106
def convert(self, imtls, idx=0): """ Convert a probability curve into a record of dtype `imtls.dt`. :param imtls: DictArray instance :param idx: extract the data corresponding to the given inner index """ curve = numpy.zeros(1, imtls.dt) for imt in imtls: ...
[ "def", "convert", "(", "self", ",", "imtls", ",", "idx", "=", "0", ")", ":", "curve", "=", "numpy", ".", "zeros", "(", "1", ",", "imtls", ".", "dt", ")", "for", "imt", "in", "imtls", ":", "curve", "[", "imt", "]", "=", "self", ".", "array", "...
Convert a probability curve into a record of dtype `imtls.dt`. :param imtls: DictArray instance :param idx: extract the data corresponding to the given inner index
[ "Convert", "a", "probability", "curve", "into", "a", "record", "of", "dtype", "imtls", ".", "dt", "." ]
python
train
StackStorm/pybind
pybind/nos/v6_0_2f/brocade_ntp_rpc/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/brocade_ntp_rpc/__init__.py#L96-L119
def _set_show_ntp(self, v, load=False): """ Setter method for show_ntp, mapped from YANG variable /brocade_ntp_rpc/show_ntp (rpc) If this variable is read-only (config: false) in the source YANG file, then _set_show_ntp is considered as a private method. Backends looking to populate this variable sh...
[ "def", "_set_show_ntp", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "base"...
Setter method for show_ntp, mapped from YANG variable /brocade_ntp_rpc/show_ntp (rpc) If this variable is read-only (config: false) in the source YANG file, then _set_show_ntp is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_show_ntp() d...
[ "Setter", "method", "for", "show_ntp", "mapped", "from", "YANG", "variable", "/", "brocade_ntp_rpc", "/", "show_ntp", "(", "rpc", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in", "the", "source", "YANG", "...
python
train
eleme/meepo
meepo/apps/eventsourcing/pub.py
https://github.com/eleme/meepo/blob/8212f0fe9b1d44be0c5de72d221a31c1d24bfe7a/meepo/apps/eventsourcing/pub.py#L119-L133
def session_rollback(self, session): """Send session_rollback signal in sqlalchemy ``after_rollback``. This marks the failure of session so the session may enter commit phase. """ # this may happen when there's nothing to rollback if not hasattr(session, 'meepo_unique_id...
[ "def", "session_rollback", "(", "self", ",", "session", ")", ":", "# this may happen when there's nothing to rollback", "if", "not", "hasattr", "(", "session", ",", "'meepo_unique_id'", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"skipped - session_rollback\...
Send session_rollback signal in sqlalchemy ``after_rollback``. This marks the failure of session so the session may enter commit phase.
[ "Send", "session_rollback", "signal", "in", "sqlalchemy", "after_rollback", "." ]
python
train
minio/minio-py
minio/api.py
https://github.com/minio/minio-py/blob/7107c84183cf5fb4deff68c0a16ab9f1c0b4c37e/minio/api.py#L1686-L1710
def _new_multipart_upload(self, bucket_name, object_name, metadata=None, sse=None): """ Initialize new multipart upload request. :param bucket_name: Bucket name of the new multipart request. :param object_name: Object name of the new multipart request. ...
[ "def", "_new_multipart_upload", "(", "self", ",", "bucket_name", ",", "object_name", ",", "metadata", "=", "None", ",", "sse", "=", "None", ")", ":", "is_valid_bucket_name", "(", "bucket_name", ")", "is_non_empty_string", "(", "object_name", ")", "headers", "=",...
Initialize new multipart upload request. :param bucket_name: Bucket name of the new multipart request. :param object_name: Object name of the new multipart request. :param metadata: Additional new metadata for the new object. :return: Returns an upload id.
[ "Initialize", "new", "multipart", "upload", "request", "." ]
python
train
edx/edx-enterprise
setup.py
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/setup.py#L28-L68
def get_requirements(requirements_file): """ Get the contents of a file listing the requirements """ lines = open(requirements_file).readlines() dependencies = [] dependency_links = [] for line in lines: package = line.strip() if package.startswith('#'): # Skip p...
[ "def", "get_requirements", "(", "requirements_file", ")", ":", "lines", "=", "open", "(", "requirements_file", ")", ".", "readlines", "(", ")", "dependencies", "=", "[", "]", "dependency_links", "=", "[", "]", "for", "line", "in", "lines", ":", "package", ...
Get the contents of a file listing the requirements
[ "Get", "the", "contents", "of", "a", "file", "listing", "the", "requirements" ]
python
valid
ray-project/ray
python/ray/tune/trial.py
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial.py#L486-L495
def should_recover(self): """Returns whether the trial qualifies for restoring. This is if a checkpoint frequency is set and has not failed more than max_failures. This may return true even when there may not yet be a checkpoint. """ return (self.checkpoint_freq > 0 ...
[ "def", "should_recover", "(", "self", ")", ":", "return", "(", "self", ".", "checkpoint_freq", ">", "0", "and", "(", "self", ".", "num_failures", "<", "self", ".", "max_failures", "or", "self", ".", "max_failures", "<", "0", ")", ")" ]
Returns whether the trial qualifies for restoring. This is if a checkpoint frequency is set and has not failed more than max_failures. This may return true even when there may not yet be a checkpoint.
[ "Returns", "whether", "the", "trial", "qualifies", "for", "restoring", "." ]
python
train
gristlabs/asttokens
asttokens/util.py
https://github.com/gristlabs/asttokens/blob/c8697dcf799a63d432727abb1d972adb3e85970a/asttokens/util.py#L214-L230
def replace(text, replacements): """ Replaces multiple slices of text with new values. This is a convenience method for making code modifications of ranges e.g. as identified by ``ASTTokens.get_text_range(node)``. Replacements is an iterable of ``(start, end, new_text)`` tuples. For example, ``replace("this ...
[ "def", "replace", "(", "text", ",", "replacements", ")", ":", "p", "=", "0", "parts", "=", "[", "]", "for", "(", "start", ",", "end", ",", "new_text", ")", "in", "sorted", "(", "replacements", ")", ":", "parts", ".", "append", "(", "text", "[", "...
Replaces multiple slices of text with new values. This is a convenience method for making code modifications of ranges e.g. as identified by ``ASTTokens.get_text_range(node)``. Replacements is an iterable of ``(start, end, new_text)`` tuples. For example, ``replace("this is a test", [(0, 4, "X"), (8, 1, "THE")])...
[ "Replaces", "multiple", "slices", "of", "text", "with", "new", "values", ".", "This", "is", "a", "convenience", "method", "for", "making", "code", "modifications", "of", "ranges", "e", ".", "g", ".", "as", "identified", "by", "ASTTokens", ".", "get_text_rang...
python
train
openatx/facebook-wda
wda/__init__.py
https://github.com/openatx/facebook-wda/blob/aa644204620c6d5c7705a9c7452d8c0cc39330d5/wda/__init__.py#L394-L407
def set_alert_callback(self, callback): """ Args: callback (func): called when alert popup Example of callback: def callback(session): session.alert.accept() """ if callable(callable): self.http.alert_callback = functo...
[ "def", "set_alert_callback", "(", "self", ",", "callback", ")", ":", "if", "callable", "(", "callable", ")", ":", "self", ".", "http", ".", "alert_callback", "=", "functools", ".", "partial", "(", "callback", ",", "self", ")", "else", ":", "self", ".", ...
Args: callback (func): called when alert popup Example of callback: def callback(session): session.alert.accept()
[ "Args", ":", "callback", "(", "func", ")", ":", "called", "when", "alert", "popup", "Example", "of", "callback", ":" ]
python
train
SAP/PyHDB
pyhdb/lib/stringlib.py
https://github.com/SAP/PyHDB/blob/826539d06b8bcef74fe755e7489b8a8255628f12/pyhdb/lib/stringlib.py#L19-L27
def allhexlify(data): """Hexlify given data into a string representation with hex values for all chars Input like 'ab\x04ce' becomes '\x61\x62\x04\x63\x65' """ hx = binascii.hexlify(data) return b''.join([b'\\x' + o for o in re.findall(b'..', hx)])
[ "def", "allhexlify", "(", "data", ")", ":", "hx", "=", "binascii", ".", "hexlify", "(", "data", ")", "return", "b''", ".", "join", "(", "[", "b'\\\\x'", "+", "o", "for", "o", "in", "re", ".", "findall", "(", "b'..'", ",", "hx", ")", "]", ")" ]
Hexlify given data into a string representation with hex values for all chars Input like 'ab\x04ce' becomes '\x61\x62\x04\x63\x65'
[ "Hexlify", "given", "data", "into", "a", "string", "representation", "with", "hex", "values", "for", "all", "chars", "Input", "like", "ab", "\\", "x04ce", "becomes", "\\", "x61", "\\", "x62", "\\", "x04", "\\", "x63", "\\", "x65" ]
python
train
saimn/sigal
sigal/gallery.py
https://github.com/saimn/sigal/blob/912ca39991355d358dc85fd55c7aeabdd7acc386/sigal/gallery.py#L103-L118
def big(self): """Path to the original image, if ``keep_orig`` is set (relative to the album directory). Copy the file if needed. """ if self.settings['keep_orig']: s = self.settings if s['use_orig']: # The image *is* the original, just use it ...
[ "def", "big", "(", "self", ")", ":", "if", "self", ".", "settings", "[", "'keep_orig'", "]", ":", "s", "=", "self", ".", "settings", "if", "s", "[", "'use_orig'", "]", ":", "# The image *is* the original, just use it", "return", "self", ".", "filename", "o...
Path to the original image, if ``keep_orig`` is set (relative to the album directory). Copy the file if needed.
[ "Path", "to", "the", "original", "image", "if", "keep_orig", "is", "set", "(", "relative", "to", "the", "album", "directory", ")", ".", "Copy", "the", "file", "if", "needed", "." ]
python
valid
jeremyschulman/halutz
halutz/client.py
https://github.com/jeremyschulman/halutz/blob/6bb398dc99bf723daabd9eda02494a11252ee109/halutz/client.py#L89-L96
def save_swagger_spec(self, filepath=None): """ Saves a copy of the origin_spec to a local file in JSON format """ if filepath is True or filepath is None: filepath = self.file_spec.format(server=self.server) json.dump(self.origin_spec, open(filepath, 'w+'), indent=3...
[ "def", "save_swagger_spec", "(", "self", ",", "filepath", "=", "None", ")", ":", "if", "filepath", "is", "True", "or", "filepath", "is", "None", ":", "filepath", "=", "self", ".", "file_spec", ".", "format", "(", "server", "=", "self", ".", "server", "...
Saves a copy of the origin_spec to a local file in JSON format
[ "Saves", "a", "copy", "of", "the", "origin_spec", "to", "a", "local", "file", "in", "JSON", "format" ]
python
train
michaelliao/sinaweibopy
snspy.py
https://github.com/michaelliao/sinaweibopy/blob/0f19dd71c1fbd16ee539620c7e9e986887f5c665/snspy.py#L324-L333
def refresh_access_token(self, refresh_token, redirect_uri=None): ''' Refresh access token. ''' redirect = redirect_uri or self._redirect_uri resp_text = _http('POST', 'https://graph.qq.com/oauth2.0/token', refresh_token=refresh_token, ...
[ "def", "refresh_access_token", "(", "self", ",", "refresh_token", ",", "redirect_uri", "=", "None", ")", ":", "redirect", "=", "redirect_uri", "or", "self", ".", "_redirect_uri", "resp_text", "=", "_http", "(", "'POST'", ",", "'https://graph.qq.com/oauth2.0/token'",...
Refresh access token.
[ "Refresh", "access", "token", "." ]
python
train
SmokinCaterpillar/pypet
pypet/trajectory.py
https://github.com/SmokinCaterpillar/pypet/blob/97ad3e80d46dbdea02deeb98ea41f05a19565826/pypet/trajectory.py#L2180-L2218
def _merge_single_runs(self, other_trajectory, used_runs): """ Updates the `run_information` of the current trajectory.""" count = len(self) # Variable to count the increasing new run indices and create # new run names run_indices = range(len(other_trajectory)) run_name_dict ...
[ "def", "_merge_single_runs", "(", "self", ",", "other_trajectory", ",", "used_runs", ")", ":", "count", "=", "len", "(", "self", ")", "# Variable to count the increasing new run indices and create", "# new run names", "run_indices", "=", "range", "(", "len", "(", "oth...
Updates the `run_information` of the current trajectory.
[ "Updates", "the", "run_information", "of", "the", "current", "trajectory", "." ]
python
test
mitsei/dlkit
dlkit/json_/grading/objects.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/grading/objects.py#L1732-L1738
def _get_entry_scores(self): """Takes entries from self._entries and returns a list of scores (or output scores, if based on grades)""" if self.get_gradebook_column().get_grade_system().is_based_on_grades(): return [e.get_grade().get_output_score() for e in self._entries if e.is_grad...
[ "def", "_get_entry_scores", "(", "self", ")", ":", "if", "self", ".", "get_gradebook_column", "(", ")", ".", "get_grade_system", "(", ")", ".", "is_based_on_grades", "(", ")", ":", "return", "[", "e", ".", "get_grade", "(", ")", ".", "get_output_score", "(...
Takes entries from self._entries and returns a list of scores (or output scores, if based on grades)
[ "Takes", "entries", "from", "self", ".", "_entries", "and", "returns", "a", "list", "of", "scores", "(", "or", "output", "scores", "if", "based", "on", "grades", ")" ]
python
train
plivo/plivohelper-python
plivohelper.py
https://github.com/plivo/plivohelper-python/blob/a2f706d69e2138fbb973f792041341f662072d26/plivohelper.py#L195-L200
def schedule_hangup(self, call_params): """REST Schedule Hangup Helper """ path = '/' + self.api_version + '/ScheduleHangup/' method = 'POST' return self.request(path, method, call_params)
[ "def", "schedule_hangup", "(", "self", ",", "call_params", ")", ":", "path", "=", "'/'", "+", "self", ".", "api_version", "+", "'/ScheduleHangup/'", "method", "=", "'POST'", "return", "self", ".", "request", "(", "path", ",", "method", ",", "call_params", ...
REST Schedule Hangup Helper
[ "REST", "Schedule", "Hangup", "Helper" ]
python
valid
hyperledger/sawtooth-core
validator/sawtooth_validator/execution/execution_context.py
https://github.com/hyperledger/sawtooth-core/blob/8cf473bc2207e51f02bd182d825158a57d72b098/validator/sawtooth_validator/execution/execution_context.py#L214-L228
def get_all_if_deleted(self): """Return all the addresses deleted in the context. Useful in the squash method. Returns: (dict of str to bytes): The addresses and bytes that have been deleted in the context. """ with self._lock: results = ...
[ "def", "get_all_if_deleted", "(", "self", ")", ":", "with", "self", ".", "_lock", ":", "results", "=", "{", "}", "for", "add", ",", "fut", "in", "self", ".", "_state", ".", "items", "(", ")", ":", "if", "self", ".", "_contains_and_deleted", "(", "add...
Return all the addresses deleted in the context. Useful in the squash method. Returns: (dict of str to bytes): The addresses and bytes that have been deleted in the context.
[ "Return", "all", "the", "addresses", "deleted", "in", "the", "context", ".", "Useful", "in", "the", "squash", "method", "." ]
python
train
NASA-AMMOS/AIT-Core
ait/core/tlm.py
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/tlm.py#L793-L803
def eval(self, packet): """Returns the result of evaluating this PacketExpression in the context of the given Packet. """ try: context = createPacketContext(packet) result = eval(self._code, packet._defn.globals, context) except ZeroDivisionError: ...
[ "def", "eval", "(", "self", ",", "packet", ")", ":", "try", ":", "context", "=", "createPacketContext", "(", "packet", ")", "result", "=", "eval", "(", "self", ".", "_code", ",", "packet", ".", "_defn", ".", "globals", ",", "context", ")", "except", ...
Returns the result of evaluating this PacketExpression in the context of the given Packet.
[ "Returns", "the", "result", "of", "evaluating", "this", "PacketExpression", "in", "the", "context", "of", "the", "given", "Packet", "." ]
python
train
pymc-devs/pymc
pymc/distributions.py
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L2296-L2313
def truncated_pareto_like(x, alpha, m, b): R""" Truncated Pareto log-likelihood. The Pareto is a continuous, positive probability distribution with two parameters. It is often used to characterize wealth distribution, or other examples of the 80/20 rule. .. math:: f(x \mid \alpha, m, b)...
[ "def", "truncated_pareto_like", "(", "x", ",", "alpha", ",", "m", ",", "b", ")", ":", "return", "flib", ".", "truncated_pareto", "(", "x", ",", "alpha", ",", "m", ",", "b", ")" ]
R""" Truncated Pareto log-likelihood. The Pareto is a continuous, positive probability distribution with two parameters. It is often used to characterize wealth distribution, or other examples of the 80/20 rule. .. math:: f(x \mid \alpha, m, b) = \frac{\alpha m^{\alpha} x^{-\alpha}}{1-(m/b)...
[ "R", "Truncated", "Pareto", "log", "-", "likelihood", ".", "The", "Pareto", "is", "a", "continuous", "positive", "probability", "distribution", "with", "two", "parameters", ".", "It", "is", "often", "used", "to", "characterize", "wealth", "distribution", "or", ...
python
train
fake-name/ChromeController
ChromeController/Generator/Generated.py
https://github.com/fake-name/ChromeController/blob/914dd136184e8f1165c7aa6ef30418aaf10c61f0/ChromeController/Generator/Generated.py#L6990-L7008
def Debugger_setSkipAllPauses(self, skip): """ Function path: Debugger.setSkipAllPauses Domain: Debugger Method name: setSkipAllPauses Parameters: Required arguments: 'skip' (type: boolean) -> New value for skip pauses state. No return value. Description: Makes page not interrupt on an...
[ "def", "Debugger_setSkipAllPauses", "(", "self", ",", "skip", ")", ":", "assert", "isinstance", "(", "skip", ",", "(", "bool", ",", ")", ")", ",", "\"Argument 'skip' must be of type '['bool']'. Received type: '%s'\"", "%", "type", "(", "skip", ")", "subdom_funcs", ...
Function path: Debugger.setSkipAllPauses Domain: Debugger Method name: setSkipAllPauses Parameters: Required arguments: 'skip' (type: boolean) -> New value for skip pauses state. No return value. Description: Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc)...
[ "Function", "path", ":", "Debugger", ".", "setSkipAllPauses", "Domain", ":", "Debugger", "Method", "name", ":", "setSkipAllPauses", "Parameters", ":", "Required", "arguments", ":", "skip", "(", "type", ":", "boolean", ")", "-", ">", "New", "value", "for", "s...
python
train
rigetti/pyquil
pyquil/noise.py
https://github.com/rigetti/pyquil/blob/ec98e453084b0037d69d8c3245f6822a5422593d/pyquil/noise.py#L639-L652
def estimate_bitstring_probs(results): """ Given an array of single shot results estimate the probability distribution over all bitstrings. :param np.array results: A 2d array where the outer axis iterates over shots and the inner axis over bits. :return: An array with as many axes as there are...
[ "def", "estimate_bitstring_probs", "(", "results", ")", ":", "nshots", ",", "nq", "=", "np", ".", "shape", "(", "results", ")", "outcomes", "=", "np", ".", "array", "(", "[", "int", "(", "\"\"", ".", "join", "(", "map", "(", "str", ",", "r", ")", ...
Given an array of single shot results estimate the probability distribution over all bitstrings. :param np.array results: A 2d array where the outer axis iterates over shots and the inner axis over bits. :return: An array with as many axes as there are qubit and normalized such that it sums to one. ...
[ "Given", "an", "array", "of", "single", "shot", "results", "estimate", "the", "probability", "distribution", "over", "all", "bitstrings", "." ]
python
train
WojciechMula/canvas2svg
canvasvg.py
https://github.com/WojciechMula/canvas2svg/blob/c05d73d88499e5c565386a1765f79d9417a14dac/canvasvg.py#L403-L412
def polyline(document, coords): "polyline with more then 2 vertices" points = [] for i in range(0, len(coords), 2): points.append("%s,%s" % (coords[i], coords[i+1])) return setattribs( document.createElement('polyline'), points = ' '.join(points), )
[ "def", "polyline", "(", "document", ",", "coords", ")", ":", "points", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "len", "(", "coords", ")", ",", "2", ")", ":", "points", ".", "append", "(", "\"%s,%s\"", "%", "(", "coords", "[", "...
polyline with more then 2 vertices
[ "polyline", "with", "more", "then", "2", "vertices" ]
python
train
osrg/ryu
ryu/lib/igmplib.py
https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/lib/igmplib.py#L522-L552
def packet_in_handler(self, req_pkt, req_igmp, msg): """the process when the snooper received IGMP.""" dpid = msg.datapath.id ofproto = msg.datapath.ofproto if ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION: in_port = msg.in_port else: in_port = msg.match...
[ "def", "packet_in_handler", "(", "self", ",", "req_pkt", ",", "req_igmp", ",", "msg", ")", ":", "dpid", "=", "msg", ".", "datapath", ".", "id", "ofproto", "=", "msg", ".", "datapath", ".", "ofproto", "if", "ofproto", ".", "OFP_VERSION", "==", "ofproto_v1...
the process when the snooper received IGMP.
[ "the", "process", "when", "the", "snooper", "received", "IGMP", "." ]
python
train
bskinn/opan
opan/vpt2/base.py
https://github.com/bskinn/opan/blob/0b1b21662df6abc971407a9386db21a8796fbfe5/opan/vpt2/base.py#L54-L144
def new_from_files(self, basepath, basename, repo, \ bohrs=False, \ software=_E_SW.ORCA, \ repo_clobber=False, **kwargs): """ Initialize with data from files. """ # Imports import os from os import path as osp ...
[ "def", "new_from_files", "(", "self", ",", "basepath", ",", "basename", ",", "repo", ",", "bohrs", "=", "False", ",", "software", "=", "_E_SW", ".", "ORCA", ",", "repo_clobber", "=", "False", ",", "*", "*", "kwargs", ")", ":", "# Imports", "import", "o...
Initialize with data from files.
[ "Initialize", "with", "data", "from", "files", "." ]
python
train
wummel/linkchecker
third_party/miniboa-r42/handler_demo.py
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/third_party/miniboa-r42/handler_demo.py#L25-L36
def my_on_connect(client): """ Example on_connect handler. """ client.send('You connected from %s\n' % client.addrport()) if CLIENTS: client.send('Also connected are:\n') for neighbor in CLIENTS: client.send('%s\n' % neighbor.addrport()) else: client.send('Sad...
[ "def", "my_on_connect", "(", "client", ")", ":", "client", ".", "send", "(", "'You connected from %s\\n'", "%", "client", ".", "addrport", "(", ")", ")", "if", "CLIENTS", ":", "client", ".", "send", "(", "'Also connected are:\\n'", ")", "for", "neighbor", "i...
Example on_connect handler.
[ "Example", "on_connect", "handler", "." ]
python
train
chaoss/grimoirelab-sortinghat
sortinghat/cmd/show.py
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/show.py#L83-L118
def show(self, uuid=None, term=None): """Show the information related to unique identities. This method prints information related to unique identities such as identities or enrollments. When <uuid> is given, it will only show information about the unique identity related to <u...
[ "def", "show", "(", "self", ",", "uuid", "=", "None", ",", "term", "=", "None", ")", ":", "try", ":", "if", "uuid", ":", "uidentities", "=", "api", ".", "unique_identities", "(", "self", ".", "db", ",", "uuid", ")", "elif", "term", ":", "uidentitie...
Show the information related to unique identities. This method prints information related to unique identities such as identities or enrollments. When <uuid> is given, it will only show information about the unique identity related to <uuid>. When <term> is set, it will only s...
[ "Show", "the", "information", "related", "to", "unique", "identities", "." ]
python
train
cloudify-cosmo/repex
repex.py
https://github.com/cloudify-cosmo/repex/blob/589e442857fa4a99fa88670d7df1a72f983bbd28/repex.py#L302-L315
def _expand_var(self, in_string, available_variables): """Expand variable to its corresponding value in_string :param string variable: variable name :param value: value to replace with :param string in_string: the string to replace in """ instances = self._get_instances(...
[ "def", "_expand_var", "(", "self", ",", "in_string", ",", "available_variables", ")", ":", "instances", "=", "self", ".", "_get_instances", "(", "in_string", ")", "for", "instance", "in", "instances", ":", "for", "name", ",", "value", "in", "available_variable...
Expand variable to its corresponding value in_string :param string variable: variable name :param value: value to replace with :param string in_string: the string to replace in
[ "Expand", "variable", "to", "its", "corresponding", "value", "in_string" ]
python
train
mitsei/dlkit
dlkit/services/assessment.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/services/assessment.py#L3229-L3237
def use_comparative_assessment_taken_view(self): """Pass through to provider AssessmentTakenLookupSession.use_comparative_assessment_taken_view""" self._object_views['assessment_taken'] = COMPARATIVE # self._get_provider_session('assessment_taken_lookup_session') # To make sure the session is tr...
[ "def", "use_comparative_assessment_taken_view", "(", "self", ")", ":", "self", ".", "_object_views", "[", "'assessment_taken'", "]", "=", "COMPARATIVE", "# self._get_provider_session('assessment_taken_lookup_session') # To make sure the session is tracked", "for", "session", "in", ...
Pass through to provider AssessmentTakenLookupSession.use_comparative_assessment_taken_view
[ "Pass", "through", "to", "provider", "AssessmentTakenLookupSession", ".", "use_comparative_assessment_taken_view" ]
python
train
chrisspen/dtree
dtree.py
https://github.com/chrisspen/dtree/blob/9e9c9992b22ad9a7e296af7e6837666b05db43ef/dtree.py#L1293-L1314
def build(cls, data, *args, **kwargs): """ Constructs a classification or regression tree in a single batch by analyzing the given data. """ assert isinstance(data, Data) if data.is_continuous_class: fitness_func = gain_variance else: fitne...
[ "def", "build", "(", "cls", ",", "data", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "assert", "isinstance", "(", "data", ",", "Data", ")", "if", "data", ".", "is_continuous_class", ":", "fitness_func", "=", "gain_variance", "else", ":", "fitn...
Constructs a classification or regression tree in a single batch by analyzing the given data.
[ "Constructs", "a", "classification", "or", "regression", "tree", "in", "a", "single", "batch", "by", "analyzing", "the", "given", "data", "." ]
python
train
elemoine/papyrus
papyrus/xsd.py
https://github.com/elemoine/papyrus/blob/764fb2326105df74fbd3dbcd7e58f4cb21956005/papyrus/xsd.py#L146-L160
def add_column_property_xsd(self, tb, column_property): """ Add the XSD for a column property to the ``TreeBuilder``. """ if len(column_property.columns) != 1: raise NotImplementedError # pragma: no cover column = column_property.columns[0] if column.primary_key and not self...
[ "def", "add_column_property_xsd", "(", "self", ",", "tb", ",", "column_property", ")", ":", "if", "len", "(", "column_property", ".", "columns", ")", "!=", "1", ":", "raise", "NotImplementedError", "# pragma: no cover", "column", "=", "column_property", ".", "co...
Add the XSD for a column property to the ``TreeBuilder``.
[ "Add", "the", "XSD", "for", "a", "column", "property", "to", "the", "TreeBuilder", "." ]
python
train
aio-libs/aiohttp-cors
aiohttp_cors/urldispatcher_router_adapter.py
https://github.com/aio-libs/aiohttp-cors/blob/14affbd95c88c675eb513c1d295ede1897930f94/aiohttp_cors/urldispatcher_router_adapter.py#L226-L271
def set_config_for_routing_entity( self, routing_entity: Union[web.Resource, web.StaticResource, web.ResourceRoute], config): """Record configuration for resource or it's route.""" if isinstance(routing_entity, (web.Resource, web.Sta...
[ "def", "set_config_for_routing_entity", "(", "self", ",", "routing_entity", ":", "Union", "[", "web", ".", "Resource", ",", "web", ".", "StaticResource", ",", "web", ".", "ResourceRoute", "]", ",", "config", ")", ":", "if", "isinstance", "(", "routing_entity",...
Record configuration for resource or it's route.
[ "Record", "configuration", "for", "resource", "or", "it", "s", "route", "." ]
python
train
palantir/python-language-server
pyls/workspace.py
https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/workspace.py#L63-L68
def get_document(self, doc_uri): """Return a managed document if-present, else create one pointing at disk. See https://github.com/Microsoft/language-server-protocol/issues/177 """ return self._docs.get(doc_uri) or self._create_document(doc_uri)
[ "def", "get_document", "(", "self", ",", "doc_uri", ")", ":", "return", "self", ".", "_docs", ".", "get", "(", "doc_uri", ")", "or", "self", ".", "_create_document", "(", "doc_uri", ")" ]
Return a managed document if-present, else create one pointing at disk. See https://github.com/Microsoft/language-server-protocol/issues/177
[ "Return", "a", "managed", "document", "if", "-", "present", "else", "create", "one", "pointing", "at", "disk", "." ]
python
train
un33k/django-toolware
toolware/utils/query.py
https://github.com/un33k/django-toolware/blob/973f3e003dc38b812897dab88455bee37dcaf931/toolware/utils/query.py#L12-L20
def get_unique_or_none(klass, *args, **kwargs): """ Returns a unique instance of `klass` or None """ try: return klass.objects.get(*args, **kwargs) except klass.DoesNotExist: return None except klass.MultipleObjectsReturned: return None return None
[ "def", "get_unique_or_none", "(", "klass", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "return", "klass", ".", "objects", ".", "get", "(", "*", "args", ",", "*", "*", "kwargs", ")", "except", "klass", ".", "DoesNotExist", ":", ...
Returns a unique instance of `klass` or None
[ "Returns", "a", "unique", "instance", "of", "klass", "or", "None" ]
python
test
CityOfZion/neo-python
neo/Core/State/AccountState.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Core/State/AccountState.py#L200-L214
def AddToBalance(self, assetId, fixed8_val): """ Add amount to the specified balance. Args: assetId (UInt256): fixed8_val (Fixed8): amount to add. """ found = False for key, balance in self.Balances.items(): if key == assetId: ...
[ "def", "AddToBalance", "(", "self", ",", "assetId", ",", "fixed8_val", ")", ":", "found", "=", "False", "for", "key", ",", "balance", "in", "self", ".", "Balances", ".", "items", "(", ")", ":", "if", "key", "==", "assetId", ":", "self", ".", "Balance...
Add amount to the specified balance. Args: assetId (UInt256): fixed8_val (Fixed8): amount to add.
[ "Add", "amount", "to", "the", "specified", "balance", "." ]
python
train
apple/turicreate
deps/src/cmake-3.13.4/Source/cmConvertMSBuildXMLToJSON.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/cmake-3.13.4/Source/cmConvertMSBuildXMLToJSON.py#L292-L296
def __convert_string(node): """Converts a StringProperty node to JSON format.""" converted = __convert_node(node, default_flags=vsflags(VSFlags.UserValue)) return __check_for_flag(converted)
[ "def", "__convert_string", "(", "node", ")", ":", "converted", "=", "__convert_node", "(", "node", ",", "default_flags", "=", "vsflags", "(", "VSFlags", ".", "UserValue", ")", ")", "return", "__check_for_flag", "(", "converted", ")" ]
Converts a StringProperty node to JSON format.
[ "Converts", "a", "StringProperty", "node", "to", "JSON", "format", "." ]
python
train
delfick/gitmit
gitmit/cache.py
https://github.com/delfick/gitmit/blob/ae0aef14a06b25ad2811f8f47cc97e68a0910eae/gitmit/cache.py#L20-L42
def get_all_cached_commit_times(root_folder): """ Find the gitmit cached commit_times and return them if they are the right shape. This means the file is a list of dictionaries. If they aren't, issue a warning and return an empty list, it is just a cache after all! """ result = [] loca...
[ "def", "get_all_cached_commit_times", "(", "root_folder", ")", ":", "result", "=", "[", "]", "location", "=", "cache_location", "(", "root_folder", ")", "if", "os", ".", "path", ".", "exists", "(", "location", ")", ":", "try", ":", "result", "=", "json", ...
Find the gitmit cached commit_times and return them if they are the right shape. This means the file is a list of dictionaries. If they aren't, issue a warning and return an empty list, it is just a cache after all!
[ "Find", "the", "gitmit", "cached", "commit_times", "and", "return", "them", "if", "they", "are", "the", "right", "shape", "." ]
python
train
materialsproject/pymatgen
pymatgen/io/abinit/tasks.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/tasks.py#L2222-L2235
def get_results(self, **kwargs): """ Returns :class:`NodeResults` instance. Subclasses should extend this method (if needed) by adding specialized code that performs some kind of post-processing. """ # Check whether the process completed. if self.returncode is Non...
[ "def", "get_results", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# Check whether the process completed.", "if", "self", ".", "returncode", "is", "None", ":", "raise", "self", ".", "Error", "(", "\"return code is None, you should call wait, communicate or poll\"", ...
Returns :class:`NodeResults` instance. Subclasses should extend this method (if needed) by adding specialized code that performs some kind of post-processing.
[ "Returns", ":", "class", ":", "NodeResults", "instance", ".", "Subclasses", "should", "extend", "this", "method", "(", "if", "needed", ")", "by", "adding", "specialized", "code", "that", "performs", "some", "kind", "of", "post", "-", "processing", "." ]
python
train
sibirrer/lenstronomy
lenstronomy/LensModel/lens_model.py
https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/LensModel/lens_model.py#L57-L71
def fermat_potential(self, x_image, y_image, x_source, y_source, kwargs_lens): """ fermat potential (negative sign means earlier arrival time) :param x_image: image position :param y_image: image position :param x_source: source position :param y_source: source position ...
[ "def", "fermat_potential", "(", "self", ",", "x_image", ",", "y_image", ",", "x_source", ",", "y_source", ",", "kwargs_lens", ")", ":", "if", "hasattr", "(", "self", ".", "lens_model", ",", "'fermat_potential'", ")", ":", "return", "self", ".", "lens_model",...
fermat potential (negative sign means earlier arrival time) :param x_image: image position :param y_image: image position :param x_source: source position :param y_source: source position :param kwargs_lens: list of keyword arguments of lens model parameters matching the lens mo...
[ "fermat", "potential", "(", "negative", "sign", "means", "earlier", "arrival", "time", ")" ]
python
train
ToucanToco/toucan-data-sdk
toucan_data_sdk/utils/generic/compute_ffill_by_group.py
https://github.com/ToucanToco/toucan-data-sdk/blob/c3ca874e1b64f4bdcc2edda750a72d45d1561d8a/toucan_data_sdk/utils/generic/compute_ffill_by_group.py#L6-L67
def compute_ffill_by_group( df, id_cols: List[str], reference_cols: List[str], value_col: str ): """ Compute `ffill` with `groupby` Dedicated method as there is a performance issue with a simple groupby/fillna (2017/07) The method `ffill` propagates last valid value forwa...
[ "def", "compute_ffill_by_group", "(", "df", ",", "id_cols", ":", "List", "[", "str", "]", ",", "reference_cols", ":", "List", "[", "str", "]", ",", "value_col", ":", "str", ")", ":", "check_params_columns_duplicate", "(", "id_cols", "+", "reference_cols", "+...
Compute `ffill` with `groupby` Dedicated method as there is a performance issue with a simple groupby/fillna (2017/07) The method `ffill` propagates last valid value forward to next values. --- ### Parameters *mandatory :* - `id_cols` (*list of str*): names of columns used to create each grou...
[ "Compute", "ffill", "with", "groupby", "Dedicated", "method", "as", "there", "is", "a", "performance", "issue", "with", "a", "simple", "groupby", "/", "fillna", "(", "2017", "/", "07", ")", "The", "method", "ffill", "propagates", "last", "valid", "value", ...
python
test
CEA-COSMIC/ModOpt
modopt/opt/linear.py
https://github.com/CEA-COSMIC/ModOpt/blob/019b189cb897cbb4d210c44a100daaa08468830c/modopt/opt/linear.py#L154-L184
def _check_type(self, input_val): """ Check Input Type This method checks if the input is a list, tuple or a numpy array and converts the input to a numpy array Parameters ---------- input_val : list, tuple or np.ndarray Returns ------- np.ndarr...
[ "def", "_check_type", "(", "self", ",", "input_val", ")", ":", "if", "not", "isinstance", "(", "input_val", ",", "(", "list", ",", "tuple", ",", "np", ".", "ndarray", ")", ")", ":", "raise", "TypeError", "(", "'Invalid input type, input must be a list, tuple '...
Check Input Type This method checks if the input is a list, tuple or a numpy array and converts the input to a numpy array Parameters ---------- input_val : list, tuple or np.ndarray Returns ------- np.ndarray of input Raises ------ ...
[ "Check", "Input", "Type" ]
python
train
markuskiller/textblob-de
textblob_de/ext/_pattern/text/__init__.py
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/__init__.py#L2152-L2172
def suggest(self, w): """ Return a list of (word, confidence) spelling corrections for the given word, based on the probability of known words with edit distance 1-2 from the given word. """ if len(self) == 0: self.load() if len(w) == 1: return [(w, 1....
[ "def", "suggest", "(", "self", ",", "w", ")", ":", "if", "len", "(", "self", ")", "==", "0", ":", "self", ".", "load", "(", ")", "if", "len", "(", "w", ")", "==", "1", ":", "return", "[", "(", "w", ",", "1.0", ")", "]", "# I", "if", "w", ...
Return a list of (word, confidence) spelling corrections for the given word, based on the probability of known words with edit distance 1-2 from the given word.
[ "Return", "a", "list", "of", "(", "word", "confidence", ")", "spelling", "corrections", "for", "the", "given", "word", "based", "on", "the", "probability", "of", "known", "words", "with", "edit", "distance", "1", "-", "2", "from", "the", "given", "word", ...
python
train
estnltk/estnltk
estnltk/text.py
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/text.py#L758-L798
def syntax_trees( self, layer=None ): """ Builds syntactic trees (estnltk.syntax.utils.Tree objects) from syntactic annotations and returns as a list. If the input argument *layer* is not specified, the type of the syntactic parser is used to decide, which synt...
[ "def", "syntax_trees", "(", "self", ",", "layer", "=", "None", ")", ":", "# If no layer specified, decide the layer based on the type of syntactic", "# analyzer used:", "if", "not", "layer", "and", "self", ".", "__syntactic_parser", ":", "if", "isinstance", "(", "self",...
Builds syntactic trees (estnltk.syntax.utils.Tree objects) from syntactic annotations and returns as a list. If the input argument *layer* is not specified, the type of the syntactic parser is used to decide, which syntactic analysis layer should be produc...
[ "Builds", "syntactic", "trees", "(", "estnltk", ".", "syntax", ".", "utils", ".", "Tree", "objects", ")", "from", "syntactic", "annotations", "and", "returns", "as", "a", "list", ".", "If", "the", "input", "argument", "*", "layer", "*", "is", "not", "spe...
python
train
saltstack/salt
salt/modules/win_network.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_network.py#L349-L389
def ip_addrs(interface=None, include_loopback=False, cidr=None, type=None): ''' Returns a list of IPv4 addresses assigned to the host. interface Only IP addresses from that interface will be returned. include_loopback : False Include loopback 127.0.0.1 IPv4 address. cidr D...
[ "def", "ip_addrs", "(", "interface", "=", "None", ",", "include_loopback", "=", "False", ",", "cidr", "=", "None", ",", "type", "=", "None", ")", ":", "addrs", "=", "salt", ".", "utils", ".", "network", ".", "ip_addrs", "(", "interface", "=", "interfac...
Returns a list of IPv4 addresses assigned to the host. interface Only IP addresses from that interface will be returned. include_loopback : False Include loopback 127.0.0.1 IPv4 address. cidr Describes subnet using CIDR notation and only IPv4 addresses that belong to this ...
[ "Returns", "a", "list", "of", "IPv4", "addresses", "assigned", "to", "the", "host", "." ]
python
train
DeVilhena-Paulo/KdQuery
kdquery.py
https://github.com/DeVilhena-Paulo/KdQuery/blob/76e3791e25b2db2168c1007fe1b92c3f8ec20005/kdquery.py#L100-L156
def insert(self, point, data=None): """Insert a new node in the tree. Args: point (:obj:`tuple` of float or int): Stores the position of the node. data (:obj, optional): The information stored by the node. Returns: int: The identifier of the ...
[ "def", "insert", "(", "self", ",", "point", ",", "data", "=", "None", ")", ":", "assert", "len", "(", "point", ")", "==", "self", ".", "k", "if", "self", ".", "size", "==", "0", ":", "if", "self", ".", "region", "is", "None", ":", "self", ".", ...
Insert a new node in the tree. Args: point (:obj:`tuple` of float or int): Stores the position of the node. data (:obj, optional): The information stored by the node. Returns: int: The identifier of the new node. Example: >>> tre...
[ "Insert", "a", "new", "node", "in", "the", "tree", "." ]
python
train
beregond/jsonmodels
jsonmodels/fields.py
https://github.com/beregond/jsonmodels/blob/97a1a6b90a49490fc5a6078f49027055d2e13541/jsonmodels/fields.py#L418-L424
def parse_value(self, value): """Parse string into instance of `time`.""" if value is None: return value if isinstance(value, datetime.time): return value return parse(value).timetz()
[ "def", "parse_value", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "return", "value", "if", "isinstance", "(", "value", ",", "datetime", ".", "time", ")", ":", "return", "value", "return", "parse", "(", "value", ")", ".", "t...
Parse string into instance of `time`.
[ "Parse", "string", "into", "instance", "of", "time", "." ]
python
train
mikedh/trimesh
trimesh/poses.py
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/poses.py#L13-L155
def compute_stable_poses(mesh, center_mass=None, sigma=0.0, n_samples=1, threshold=0.0): """ Computes stable orientations of a mesh and their quasi-static probabilites. This method samples the location of th...
[ "def", "compute_stable_poses", "(", "mesh", ",", "center_mass", "=", "None", ",", "sigma", "=", "0.0", ",", "n_samples", "=", "1", ",", "threshold", "=", "0.0", ")", ":", "# save convex hull mesh to avoid a cache check", "cvh", "=", "mesh", ".", "convex_hull", ...
Computes stable orientations of a mesh and their quasi-static probabilites. This method samples the location of the center of mass from a multivariate gaussian with the mean at the center of mass, and a covariance equal to and identity matrix times sigma, over n_samples. For each sample, it computes t...
[ "Computes", "stable", "orientations", "of", "a", "mesh", "and", "their", "quasi", "-", "static", "probabilites", "." ]
python
train
jupyter-widgets/ipywidgets
ipywidgets/widgets/widget.py
https://github.com/jupyter-widgets/ipywidgets/blob/36fe37594cd5a268def228709ca27e37b99ac606/ipywidgets/widgets/widget.py#L732-L735
def _send(self, msg, buffers=None): """Sends a message to the model in the front-end.""" if self.comm is not None and self.comm.kernel is not None: self.comm.send(data=msg, buffers=buffers)
[ "def", "_send", "(", "self", ",", "msg", ",", "buffers", "=", "None", ")", ":", "if", "self", ".", "comm", "is", "not", "None", "and", "self", ".", "comm", ".", "kernel", "is", "not", "None", ":", "self", ".", "comm", ".", "send", "(", "data", ...
Sends a message to the model in the front-end.
[ "Sends", "a", "message", "to", "the", "model", "in", "the", "front", "-", "end", "." ]
python
train
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_interface_ext.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_interface_ext.py#L1276-L1292
def get_interface_detail_output_interface_ifHCOutBroadcastPkts(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_interface_detail = ET.Element("get_interface_detail") config = get_interface_detail output = ET.SubElement(get_interface_detail, "o...
[ "def", "get_interface_detail_output_interface_ifHCOutBroadcastPkts", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "get_interface_detail", "=", "ET", ".", "Element", "(", "\"get_interface_detail\"", ")",...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
wbond/asn1crypto
asn1crypto/_iri.py
https://github.com/wbond/asn1crypto/blob/ecda20176f55d37021cbca1f6da9083a8e491197/asn1crypto/_iri.py#L120-L169
def uri_to_iri(value): """ Converts an ASCII URI byte string into a unicode IRI :param value: An ASCII-encoded byte string of the URI :return: A unicode string of the IRI """ if not isinstance(value, byte_cls): raise TypeError(unwrap( ''' value ...
[ "def", "uri_to_iri", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "byte_cls", ")", ":", "raise", "TypeError", "(", "unwrap", "(", "'''\n value must be a byte string, not %s\n '''", ",", "type_name", "(", "value", ")", ...
Converts an ASCII URI byte string into a unicode IRI :param value: An ASCII-encoded byte string of the URI :return: A unicode string of the IRI
[ "Converts", "an", "ASCII", "URI", "byte", "string", "into", "a", "unicode", "IRI" ]
python
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Variables/PackageVariable.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Variables/PackageVariable.py#L86-L100
def PackageVariable(key, help, default, searchfunc=None): # NB: searchfunc is currently undocumented and unsupported """ The input parameters describe a 'package list' option, thus they are returned with the correct converter and validator appended. The result is usable for input to opts.Add() . ...
[ "def", "PackageVariable", "(", "key", ",", "help", ",", "default", ",", "searchfunc", "=", "None", ")", ":", "# NB: searchfunc is currently undocumented and unsupported", "help", "=", "'\\n '", ".", "join", "(", "(", "help", ",", "'( yes | no | /path/to/%s )'", "...
The input parameters describe a 'package list' option, thus they are returned with the correct converter and validator appended. The result is usable for input to opts.Add() . A 'package list' option may either be 'all', 'none' or a list of package names (separated by space).
[ "The", "input", "parameters", "describe", "a", "package", "list", "option", "thus", "they", "are", "returned", "with", "the", "correct", "converter", "and", "validator", "appended", ".", "The", "result", "is", "usable", "for", "input", "to", "opts", ".", "Ad...
python
train
gem/oq-engine
openquake/hazardlib/sourceconverter.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/sourceconverter.py#L614-L627
def convert_hpdist(self, node): """ Convert the given node into a probability mass function for the hypo depth distribution. :param node: a hypoDepthDist node :returns: a :class:`openquake.hazardlib.pmf.PMF` instance """ with context(self.fname, node): ...
[ "def", "convert_hpdist", "(", "self", ",", "node", ")", ":", "with", "context", "(", "self", ".", "fname", ",", "node", ")", ":", "hcdist", "=", "[", "(", "hd", "[", "'probability'", "]", ",", "hd", "[", "'depth'", "]", ")", "for", "hd", "in", "n...
Convert the given node into a probability mass function for the hypo depth distribution. :param node: a hypoDepthDist node :returns: a :class:`openquake.hazardlib.pmf.PMF` instance
[ "Convert", "the", "given", "node", "into", "a", "probability", "mass", "function", "for", "the", "hypo", "depth", "distribution", "." ]
python
train
Jarn/jarn.mkrelease
jarn/mkrelease/utils.py
https://github.com/Jarn/jarn.mkrelease/blob/844377f37a3cdc0a154148790a926f991019ec4a/jarn/mkrelease/utils.py#L34-L44
def getinputencoding(stream=None): """Return preferred encoding for reading from ``stream``. ``stream`` defaults to sys.stdin. """ if stream is None: stream = sys.stdin encoding = stream.encoding if not encoding: encoding = getpreferredencoding() return encoding
[ "def", "getinputencoding", "(", "stream", "=", "None", ")", ":", "if", "stream", "is", "None", ":", "stream", "=", "sys", ".", "stdin", "encoding", "=", "stream", ".", "encoding", "if", "not", "encoding", ":", "encoding", "=", "getpreferredencoding", "(", ...
Return preferred encoding for reading from ``stream``. ``stream`` defaults to sys.stdin.
[ "Return", "preferred", "encoding", "for", "reading", "from", "stream", "." ]
python
train
pyQode/pyqode.core
examples/notepad/notepad/main_window.py
https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/examples/notepad/notepad/main_window.py#L76-L93
def setup_mimetypes(self): """ Setup additional mime types. """ # setup some specific mimetypes mimetypes.add_type('text/xml', '.ui') # qt designer forms forms mimetypes.add_type('text/x-rst', '.rst') # rst docs mimetypes.add_type('text/x-cython', '.pyx') # cython impl files ...
[ "def", "setup_mimetypes", "(", "self", ")", ":", "# setup some specific mimetypes", "mimetypes", ".", "add_type", "(", "'text/xml'", ",", "'.ui'", ")", "# qt designer forms forms", "mimetypes", ".", "add_type", "(", "'text/x-rst'", ",", "'.rst'", ")", "# rst docs", ...
Setup additional mime types.
[ "Setup", "additional", "mime", "types", "." ]
python
train
Microsoft/azure-devops-python-api
azure-devops/azure/devops/_file_cache.py
https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/_file_cache.py#L165-L176
def shell_safe_json_parse(json_or_dict_string, preserve_order=False): """ Allows the passing of JSON or Python dictionary strings. This is needed because certain JSON strings in CMD shell are not received in main's argv. This allows the user to specify the alternative notation, which does not have this prob...
[ "def", "shell_safe_json_parse", "(", "json_or_dict_string", ",", "preserve_order", "=", "False", ")", ":", "try", ":", "if", "not", "preserve_order", ":", "return", "json", ".", "loads", "(", "json_or_dict_string", ")", "from", "collections", "import", "OrderedDic...
Allows the passing of JSON or Python dictionary strings. This is needed because certain JSON strings in CMD shell are not received in main's argv. This allows the user to specify the alternative notation, which does not have this problem (but is technically not JSON).
[ "Allows", "the", "passing", "of", "JSON", "or", "Python", "dictionary", "strings", ".", "This", "is", "needed", "because", "certain", "JSON", "strings", "in", "CMD", "shell", "are", "not", "received", "in", "main", "s", "argv", ".", "This", "allows", "the"...
python
train
archman/beamline
beamline/lattice.py
https://github.com/archman/beamline/blob/417bc5dc13e754bc89d246427984590fced64d07/beamline/lattice.py#L367-L380
def makeElement(self, kw): """ return element object regarding the keyword configuration """ kw_name = kw kw_type = self.getKwType(kw_name) kw_config = {k.lower(): v for k, v in self.getKwConfig(kw_name).items()} objtype = 'Element' + kw_type.capitalize() retobj =...
[ "def", "makeElement", "(", "self", ",", "kw", ")", ":", "kw_name", "=", "kw", "kw_type", "=", "self", ".", "getKwType", "(", "kw_name", ")", "kw_config", "=", "{", "k", ".", "lower", "(", ")", ":", "v", "for", "k", ",", "v", "in", "self", ".", ...
return element object regarding the keyword configuration
[ "return", "element", "object", "regarding", "the", "keyword", "configuration" ]
python
train
saltstack/salt
salt/thorium/calc.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/calc.py#L226-L246
def median_high(name, num, minimum=0, maximum=0, ref=None): ''' Calculates the high mean of the ``num`` most recent values. Requires a list. USAGE: .. code-block:: yaml foo: calc.median_high: - name: myregentry - num: 5 ''' return calc( name=n...
[ "def", "median_high", "(", "name", ",", "num", ",", "minimum", "=", "0", ",", "maximum", "=", "0", ",", "ref", "=", "None", ")", ":", "return", "calc", "(", "name", "=", "name", ",", "num", "=", "num", ",", "oper", "=", "'median_high'", ",", "min...
Calculates the high mean of the ``num`` most recent values. Requires a list. USAGE: .. code-block:: yaml foo: calc.median_high: - name: myregentry - num: 5
[ "Calculates", "the", "high", "mean", "of", "the", "num", "most", "recent", "values", ".", "Requires", "a", "list", "." ]
python
train
wdm0006/git-pandas
gitpandas/project.py
https://github.com/wdm0006/git-pandas/blob/e56b817b1d66b8296d1d5e703d5db0e181d25899/gitpandas/project.py#L140-L178
def file_change_rates(self, branch='master', limit=None, coverage=False, days=None, ignore_globs=None, include_globs=None): """ This function will return a DataFrame containing some basic aggregations of the file change history data, and optionally test coverage data from a coverage_data.py .cov...
[ "def", "file_change_rates", "(", "self", ",", "branch", "=", "'master'", ",", "limit", "=", "None", ",", "coverage", "=", "False", ",", "days", "=", "None", ",", "ignore_globs", "=", "None", ",", "include_globs", "=", "None", ")", ":", "columns", "=", ...
This function will return a DataFrame containing some basic aggregations of the file change history data, and optionally test coverage data from a coverage_data.py .coverage file. The aim here is to identify files in the project which have abnormal edit rates, or the rate of changes without growing the...
[ "This", "function", "will", "return", "a", "DataFrame", "containing", "some", "basic", "aggregations", "of", "the", "file", "change", "history", "data", "and", "optionally", "test", "coverage", "data", "from", "a", "coverage_data", ".", "py", ".", "coverage", ...
python
train
ASMfreaK/habitipy
habitipy/cli.py
https://github.com/ASMfreaK/habitipy/blob/555b8b20faf6d553353092614a8a0d612f0adbde/habitipy/cli.py#L126-L164
def get_content(api, rebuild_cache=False): """get content from server or cache""" if hasattr(get_content, 'cache') and not rebuild_cache: return get_content.cache if not os.path.exists(CONTENT_JSON) or rebuild_cache: import locale content_endpoint = api.content.get # pylint: ...
[ "def", "get_content", "(", "api", ",", "rebuild_cache", "=", "False", ")", ":", "if", "hasattr", "(", "get_content", ",", "'cache'", ")", "and", "not", "rebuild_cache", ":", "return", "get_content", ".", "cache", "if", "not", "os", ".", "path", ".", "exi...
get content from server or cache
[ "get", "content", "from", "server", "or", "cache" ]
python
train
limpyd/redis-limpyd
limpyd/collection.py
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/collection.py#L574-L583
def sort(self, **parameters): """ Parameters: `by`: pass either a field name or a wildcard string to sort on prefix with `-` to make a desc sort. `alpha`: set it to True to sort lexicographically instead of numerically. """ parameters = self._coerce_by_param...
[ "def", "sort", "(", "self", ",", "*", "*", "parameters", ")", ":", "parameters", "=", "self", ".", "_coerce_by_parameter", "(", "parameters", ")", "self", ".", "_sort", "=", "parameters", "return", "self" ]
Parameters: `by`: pass either a field name or a wildcard string to sort on prefix with `-` to make a desc sort. `alpha`: set it to True to sort lexicographically instead of numerically.
[ "Parameters", ":", "by", ":", "pass", "either", "a", "field", "name", "or", "a", "wildcard", "string", "to", "sort", "on", "prefix", "with", "-", "to", "make", "a", "desc", "sort", ".", "alpha", ":", "set", "it", "to", "True", "to", "sort", "lexicogr...
python
train
jleinonen/pytmatrix
pytmatrix/tmatrix.py
https://github.com/jleinonen/pytmatrix/blob/8803507fe5332786feab105fa74acf63e7121718/pytmatrix/tmatrix.py#L202-L219
def _init_tmatrix(self): """Initialize the T-matrix. """ if self.radius_type == Scatterer.RADIUS_MAXIMUM: # Maximum radius is not directly supported in the original # so we convert it to equal volume radius radius_type = Scatterer.RADIUS_EQUAL_VOLUME ...
[ "def", "_init_tmatrix", "(", "self", ")", ":", "if", "self", ".", "radius_type", "==", "Scatterer", ".", "RADIUS_MAXIMUM", ":", "# Maximum radius is not directly supported in the original", "# so we convert it to equal volume radius", "radius_type", "=", "Scatterer", ".", "...
Initialize the T-matrix.
[ "Initialize", "the", "T", "-", "matrix", "." ]
python
train
MisterWil/abodepy
abodepy/devices/camera.py
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/camera.py#L40-L48
def refresh_image(self): """Get the most recent camera image.""" url = str.replace(CONST.TIMELINE_IMAGES_ID_URL, '$DEVID$', self.device_id) response = self._abode.send_request("get", url) _LOGGER.debug("Get image response: %s", response.text) return se...
[ "def", "refresh_image", "(", "self", ")", ":", "url", "=", "str", ".", "replace", "(", "CONST", ".", "TIMELINE_IMAGES_ID_URL", ",", "'$DEVID$'", ",", "self", ".", "device_id", ")", "response", "=", "self", ".", "_abode", ".", "send_request", "(", "\"get\""...
Get the most recent camera image.
[ "Get", "the", "most", "recent", "camera", "image", "." ]
python
train
pybel/pybel
src/pybel/struct/summary/node_summary.py
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/summary/node_summary.py#L170-L183
def count_names_by_namespace(graph, namespace): """Get the set of all of the names in a given namespace that are in the graph. :param pybel.BELGraph graph: A BEL graph :param str namespace: A namespace keyword :return: A counter from {name: frequency} :rtype: collections.Counter :raises IndexE...
[ "def", "count_names_by_namespace", "(", "graph", ",", "namespace", ")", ":", "if", "namespace", "not", "in", "graph", ".", "defined_namespace_keywords", ":", "raise", "IndexError", "(", "'{} is not defined in {}'", ".", "format", "(", "namespace", ",", "graph", ")...
Get the set of all of the names in a given namespace that are in the graph. :param pybel.BELGraph graph: A BEL graph :param str namespace: A namespace keyword :return: A counter from {name: frequency} :rtype: collections.Counter :raises IndexError: if the namespace is not defined in the graph.
[ "Get", "the", "set", "of", "all", "of", "the", "names", "in", "a", "given", "namespace", "that", "are", "in", "the", "graph", "." ]
python
train
cariad/py-wpconfigr
wpconfigr/wp_config_string.py
https://github.com/cariad/py-wpconfigr/blob/8f25bb849b72ce95957566544a2be8445316c818/wpconfigr/wp_config_string.py#L29-L41
def _get_match(self, key): """ Gets a MatchObject for the given key. Args: key (str): Key of the property to look-up. Return: MatchObject: The discovered match. """ return self._get_string_match(key=key) or \ self._get_non_string_mat...
[ "def", "_get_match", "(", "self", ",", "key", ")", ":", "return", "self", ".", "_get_string_match", "(", "key", "=", "key", ")", "or", "self", ".", "_get_non_string_match", "(", "key", "=", "key", ")" ]
Gets a MatchObject for the given key. Args: key (str): Key of the property to look-up. Return: MatchObject: The discovered match.
[ "Gets", "a", "MatchObject", "for", "the", "given", "key", "." ]
python
train
ET-CS/dry
dry/__init__.py
https://github.com/ET-CS/dry/blob/e8e73903dab372122ebb89a11d2168dd239faf51/dry/__init__.py#L382-L394
def init_current_directory(): """Initialize and create dry config file(s) inside current directory""" settings_directory=project_path+'/.dry' settings_file=settings_directory+'/config.py' if os.path.isdir(settings_directory): # already initialized print("directory already initialized.") return # ...
[ "def", "init_current_directory", "(", ")", ":", "settings_directory", "=", "project_path", "+", "'/.dry'", "settings_file", "=", "settings_directory", "+", "'/config.py'", "if", "os", ".", "path", ".", "isdir", "(", "settings_directory", ")", ":", "# already initial...
Initialize and create dry config file(s) inside current directory
[ "Initialize", "and", "create", "dry", "config", "file", "(", "s", ")", "inside", "current", "directory" ]
python
train
echinopsii/net.echinopsii.ariane.community.cli.python3
ariane_clip3/mapping.py
https://github.com/echinopsii/net.echinopsii.ariane.community.cli.python3/blob/0a7feddebf66fee4bef38d64f456d93a7e9fcd68/ariane_clip3/mapping.py#L2176-L2215
def get_gates(): """ get all gates known on the Ariane server :return: """ LOGGER.debug("GateService.get_gates") params = SessionService.complete_transactional_req(None) if params is None: if MappingService.driver_type != DriverFactory.DRIVER_REST: ...
[ "def", "get_gates", "(", ")", ":", "LOGGER", ".", "debug", "(", "\"GateService.get_gates\"", ")", "params", "=", "SessionService", ".", "complete_transactional_req", "(", "None", ")", "if", "params", "is", "None", ":", "if", "MappingService", ".", "driver_type",...
get all gates known on the Ariane server :return:
[ "get", "all", "gates", "known", "on", "the", "Ariane", "server", ":", "return", ":" ]
python
train
snare/voltron
setup.py
https://github.com/snare/voltron/blob/4ee3cbe6f7c1e38303f5dc6114c48b60217253c3/setup.py#L10-L51
def check_install(): """ Try to detect the two most common installation errors: 1. Installing on macOS using a Homebrew version of Python 2. Installing on Linux using Python 2 when GDB is linked with Python 3 """ if platform.system() == 'Darwin' and sys.executable != '/usr/bin/python': ...
[ "def", "check_install", "(", ")", ":", "if", "platform", ".", "system", "(", ")", "==", "'Darwin'", "and", "sys", ".", "executable", "!=", "'/usr/bin/python'", ":", "print", "(", "\"*\"", "*", "79", ")", "print", "(", "textwrap", ".", "fill", "(", "\"W...
Try to detect the two most common installation errors: 1. Installing on macOS using a Homebrew version of Python 2. Installing on Linux using Python 2 when GDB is linked with Python 3
[ "Try", "to", "detect", "the", "two", "most", "common", "installation", "errors", ":" ]
python
train
Erotemic/utool
utool/util_str.py
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_str.py#L1885-L1910
def str_between(str_, startstr, endstr): r""" gets substring between two sentianl strings Example: >>> # DISABLE_DOCTEST >>> from utool.util_str import * # NOQA >>> import utool as ut >>> str_ = '\n INSERT INTO vsone(\n' >>> startstr = 'INSERT' >>> en...
[ "def", "str_between", "(", "str_", ",", "startstr", ",", "endstr", ")", ":", "if", "startstr", "is", "None", ":", "startpos", "=", "0", "else", ":", "startpos", "=", "str_", ".", "find", "(", "startstr", ")", "+", "len", "(", "startstr", ")", "if", ...
r""" gets substring between two sentianl strings Example: >>> # DISABLE_DOCTEST >>> from utool.util_str import * # NOQA >>> import utool as ut >>> str_ = '\n INSERT INTO vsone(\n' >>> startstr = 'INSERT' >>> endstr = '(' >>> result = str_between(s...
[ "r", "gets", "substring", "between", "two", "sentianl", "strings" ]
python
train
pr-omethe-us/PyKED
pyked/chemked.py
https://github.com/pr-omethe-us/PyKED/blob/d9341a068c1099049a3f1de41c512591f342bf64/pyked/chemked.py#L853-L889
def get_cantera_mass_fraction(self, species_conversion=None): """Get the mass fractions in a string format suitable for input to Cantera. Arguments: species_conversion (`dict`, optional): Mapping of species identifier to a species name. This argument should be supplied when ...
[ "def", "get_cantera_mass_fraction", "(", "self", ",", "species_conversion", "=", "None", ")", ":", "if", "self", ".", "composition_type", "in", "[", "'mole fraction'", ",", "'mole percent'", "]", ":", "raise", "ValueError", "(", "'Cannot get mass fractions from the gi...
Get the mass fractions in a string format suitable for input to Cantera. Arguments: species_conversion (`dict`, optional): Mapping of species identifier to a species name. This argument should be supplied when the name of the species in the ChemKED YAML file does not...
[ "Get", "the", "mass", "fractions", "in", "a", "string", "format", "suitable", "for", "input", "to", "Cantera", "." ]
python
train
biolink/biolink-model
metamodel/generators/markdowngen.py
https://github.com/biolink/biolink-model/blob/f379e28d5d4085e1115798c6cb28e5acc4dba8b4/metamodel/generators/markdowngen.py#L262-L277
def desc_for(self, obj: Element, doing_descs: bool) -> str: """ Return a description for object if it is unique (different than its parent) @param obj: object to be described @param doing_descs: If false, always return an empty string @return: text or empty string """ if...
[ "def", "desc_for", "(", "self", ",", "obj", ":", "Element", ",", "doing_descs", ":", "bool", ")", "->", "str", ":", "if", "obj", ".", "description", "and", "doing_descs", ":", "if", "isinstance", "(", "obj", ",", "SlotDefinition", ")", "and", "obj", "....
Return a description for object if it is unique (different than its parent) @param obj: object to be described @param doing_descs: If false, always return an empty string @return: text or empty string
[ "Return", "a", "description", "for", "object", "if", "it", "is", "unique", "(", "different", "than", "its", "parent", ")" ]
python
train
dwkim78/upsilon
upsilon/extract_features/extract_features.py
https://github.com/dwkim78/upsilon/blob/5f381453f26582ef56e62fb8fed7317ce67861af/upsilon/extract_features/extract_features.py#L451-L486
def half_mag_amplitude_ratio2(self, mag, avg): """ Return ratio of amplitude of higher and lower magnitudes. A ratio of amplitude of higher and lower magnitudes than average, considering weights. This ratio, by definition, should be higher for EB than for others. Param...
[ "def", "half_mag_amplitude_ratio2", "(", "self", ",", "mag", ",", "avg", ")", ":", "# For lower (fainter) magnitude than average.", "index", "=", "np", ".", "where", "(", "mag", ">", "avg", ")", "fainter_mag", "=", "mag", "[", "index", "]", "lower_sum", "=", ...
Return ratio of amplitude of higher and lower magnitudes. A ratio of amplitude of higher and lower magnitudes than average, considering weights. This ratio, by definition, should be higher for EB than for others. Parameters ---------- mag : array_like An ar...
[ "Return", "ratio", "of", "amplitude", "of", "higher", "and", "lower", "magnitudes", "." ]
python
train
Opentrons/opentrons
api/src/opentrons/deck_calibration/endpoints.py
https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/deck_calibration/endpoints.py#L438-L467
async def save_z(data): """ Save the current Z height value for the calibration data :param data: Information obtained from a POST request. The content type is application/json. The correct packet form should be as follows: { 'token': UUID token from current session start 'command':...
[ "async", "def", "save_z", "(", "data", ")", ":", "if", "not", "session", ".", "tip_length", ":", "message", "=", "\"Tip length must be set before calibrating\"", "status", "=", "400", "else", ":", "if", "not", "feature_flags", ".", "use_protocol_api_v2", "(", ")...
Save the current Z height value for the calibration data :param data: Information obtained from a POST request. The content type is application/json. The correct packet form should be as follows: { 'token': UUID token from current session start 'command': 'save z' }
[ "Save", "the", "current", "Z", "height", "value", "for", "the", "calibration", "data" ]
python
train
Yubico/python-yubico
setup.py
https://github.com/Yubico/python-yubico/blob/a72e8eddb90da6ee96e29f60912ca1f2872c9aea/setup.py#L10-L15
def get_version(): """Return the current version as defined by yubico/yubico_version.py.""" with open('yubico/yubico_version.py', 'r') as f: match = VERSION_PATTERN.search(f.read()) return match.group(1)
[ "def", "get_version", "(", ")", ":", "with", "open", "(", "'yubico/yubico_version.py'", ",", "'r'", ")", "as", "f", ":", "match", "=", "VERSION_PATTERN", ".", "search", "(", "f", ".", "read", "(", ")", ")", "return", "match", ".", "group", "(", "1", ...
Return the current version as defined by yubico/yubico_version.py.
[ "Return", "the", "current", "version", "as", "defined", "by", "yubico", "/", "yubico_version", ".", "py", "." ]
python
train
saltstack/salt
salt/modules/aptpkg.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/aptpkg.py#L2399-L2452
def expand_repo_def(**kwargs): ''' Take a repository definition and expand it to the full pkg repository dict that can be used for comparison. This is a helper function to make the Debian/Ubuntu apt sources sane for comparison in the pkgrepo states. This is designed to be called from pkgrepo state...
[ "def", "expand_repo_def", "(", "*", "*", "kwargs", ")", ":", "if", "'repo'", "not", "in", "kwargs", ":", "raise", "SaltInvocationError", "(", "'missing \\'repo\\' argument'", ")", "_check_apt", "(", ")", "sanitized", "=", "{", "}", "repo", "=", "salt", ".", ...
Take a repository definition and expand it to the full pkg repository dict that can be used for comparison. This is a helper function to make the Debian/Ubuntu apt sources sane for comparison in the pkgrepo states. This is designed to be called from pkgrepo states and will have little use being called...
[ "Take", "a", "repository", "definition", "and", "expand", "it", "to", "the", "full", "pkg", "repository", "dict", "that", "can", "be", "used", "for", "comparison", ".", "This", "is", "a", "helper", "function", "to", "make", "the", "Debian", "/", "Ubuntu", ...
python
train
chatfirst/chatfirst
chatfirst/client.py
https://github.com/chatfirst/chatfirst/blob/11e023fc372e034dfd3417b61b67759ef8c37ad6/chatfirst/client.py#L38-L48
def bots_get(self, bot): """ Fetch and fill Bot object :param bot: empty bot object with name to search :type bot: Bot :rtype: Bot :return: filled bot object """ data = self.client.bots.__getattr__(bot.name).__call__() return Bot(data)
[ "def", "bots_get", "(", "self", ",", "bot", ")", ":", "data", "=", "self", ".", "client", ".", "bots", ".", "__getattr__", "(", "bot", ".", "name", ")", ".", "__call__", "(", ")", "return", "Bot", "(", "data", ")" ]
Fetch and fill Bot object :param bot: empty bot object with name to search :type bot: Bot :rtype: Bot :return: filled bot object
[ "Fetch", "and", "fill", "Bot", "object" ]
python
train
acrazing/dbapi
dbapi/base.py
https://github.com/acrazing/dbapi/blob/8c1f85cb1a051daf7be1fc97a62c4499983e9898/dbapi/base.py#L106-L127
def json(self, url, method='get', params=None, data=None): """ 请求并返回json :type url: str :param url: API :type method: str :param method: HTTP METHOD :type params: dict :param params: query :type data: di...
[ "def", "json", "(", "self", ",", "url", ",", "method", "=", "'get'", ",", "params", "=", "None", ",", "data", "=", "None", ")", ":", "r", "=", "self", ".", "req", "(", "url", ",", "method", ",", "params", ",", "data", ")", "return", "r", ".", ...
请求并返回json :type url: str :param url: API :type method: str :param method: HTTP METHOD :type params: dict :param params: query :type data: dict :param data: body :rtype: dict :return:
[ "请求并返回json", ":", "type", "url", ":", "str", ":", "param", "url", ":", "API", ":", "type", "method", ":", "str", ":", "param", "method", ":", "HTTP", "METHOD", ":", "type", "params", ":", "dict", ":", "param", "params", ":", "query", ":", "type", "...
python
train
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L687-L689
def subscriptions_unread(self, room_id, **kwargs): """Mark messages as unread by roomId or from a message""" return self.__call_api_post('subscriptions.unread', roomId=room_id, kwargs=kwargs)
[ "def", "subscriptions_unread", "(", "self", ",", "room_id", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'subscriptions.unread'", ",", "roomId", "=", "room_id", ",", "kwargs", "=", "kwargs", ")" ]
Mark messages as unread by roomId or from a message
[ "Mark", "messages", "as", "unread", "by", "roomId", "or", "from", "a", "message" ]
python
train
orb-framework/orb
orb/core/model.py
https://github.com/orb-framework/orb/blob/575be2689cb269e65a0a2678232ff940acc19e5a/orb/core/model.py#L428-L437
def context(self, **context): """ Returns the lookup options for this record. This will track the options that were used when looking this record up from the database. :return <orb.LookupOptions> """ output = orb.Context(context=self.__context) if self.__context is ...
[ "def", "context", "(", "self", ",", "*", "*", "context", ")", ":", "output", "=", "orb", ".", "Context", "(", "context", "=", "self", ".", "__context", ")", "if", "self", ".", "__context", "is", "not", "None", "else", "orb", ".", "Context", "(", ")...
Returns the lookup options for this record. This will track the options that were used when looking this record up from the database. :return <orb.LookupOptions>
[ "Returns", "the", "lookup", "options", "for", "this", "record", ".", "This", "will", "track", "the", "options", "that", "were", "used", "when", "looking", "this", "record", "up", "from", "the", "database", "." ]
python
train
spyder-ide/spyder
spyder/plugins/editor/widgets/editor.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/editor.py#L1545-L1551
def sorted(self): """Utility function for sort_file_tabs_alphabetically().""" for i in range(0, self.tabs.tabBar().count() - 1): if (self.tabs.tabBar().tabText(i) > self.tabs.tabBar().tabText(i + 1)): return False return True
[ "def", "sorted", "(", "self", ")", ":", "for", "i", "in", "range", "(", "0", ",", "self", ".", "tabs", ".", "tabBar", "(", ")", ".", "count", "(", ")", "-", "1", ")", ":", "if", "(", "self", ".", "tabs", ".", "tabBar", "(", ")", ".", "tabTe...
Utility function for sort_file_tabs_alphabetically().
[ "Utility", "function", "for", "sort_file_tabs_alphabetically", "()", "." ]
python
train
koordinates/python-client
koordinates/metadata.py
https://github.com/koordinates/python-client/blob/f3dc7cd164f5a9499b2454cd1d4516e9d4b3c252/koordinates/metadata.py#L47-L61
def get_xml(self, fp, format=FORMAT_NATIVE): """ Returns the XML metadata for this source, converted to the requested format. Converted metadata may not contain all the same information as the native format. :param file fp: A path, or an open file-like object which the content should be...
[ "def", "get_xml", "(", "self", ",", "fp", ",", "format", "=", "FORMAT_NATIVE", ")", ":", "r", "=", "self", ".", "_client", ".", "request", "(", "'GET'", ",", "getattr", "(", "self", ",", "format", ")", ",", "stream", "=", "True", ")", "filename", "...
Returns the XML metadata for this source, converted to the requested format. Converted metadata may not contain all the same information as the native format. :param file fp: A path, or an open file-like object which the content should be written to. :param str format: desired format for the ou...
[ "Returns", "the", "XML", "metadata", "for", "this", "source", "converted", "to", "the", "requested", "format", ".", "Converted", "metadata", "may", "not", "contain", "all", "the", "same", "information", "as", "the", "native", "format", "." ]
python
train
moble/quaternion
__init__.py
https://github.com/moble/quaternion/blob/7a323e81b391d6892e2874073e495e0beb057e85/__init__.py#L190-L326
def from_rotation_matrix(rot, nonorthogonal=True): """Convert input 3x3 rotation matrix to unit quaternion By default, if scipy.linalg is available, this function uses Bar-Itzhack's algorithm to allow for non-orthogonal matrices. [J. Guidance, Vol. 23, No. 6, p. 1085 <http://dx.doi.org/10.2514/2.4654>]...
[ "def", "from_rotation_matrix", "(", "rot", ",", "nonorthogonal", "=", "True", ")", ":", "try", ":", "from", "scipy", "import", "linalg", "except", "ImportError", ":", "linalg", "=", "False", "rot", "=", "np", ".", "array", "(", "rot", ",", "copy", "=", ...
Convert input 3x3 rotation matrix to unit quaternion By default, if scipy.linalg is available, this function uses Bar-Itzhack's algorithm to allow for non-orthogonal matrices. [J. Guidance, Vol. 23, No. 6, p. 1085 <http://dx.doi.org/10.2514/2.4654>] This will almost certainly be quite a bit slower than...
[ "Convert", "input", "3x3", "rotation", "matrix", "to", "unit", "quaternion" ]
python
train
HPCC-Cloud-Computing/CAL
calplus/utils.py
https://github.com/HPCC-Cloud-Computing/CAL/blob/7134b3dfe9ee3a383506a592765c7a12fa4ca1e9/calplus/utils.py#L50-L56
def _sanitizer(self, obj): """Sanitizer method that will be passed to json.dumps.""" if isinstance(obj, datetime.datetime): return obj.isoformat() if hasattr(obj, "to_dict"): return obj.to_dict() return obj
[ "def", "_sanitizer", "(", "self", ",", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "datetime", ".", "datetime", ")", ":", "return", "obj", ".", "isoformat", "(", ")", "if", "hasattr", "(", "obj", ",", "\"to_dict\"", ")", ":", "return", "obj...
Sanitizer method that will be passed to json.dumps.
[ "Sanitizer", "method", "that", "will", "be", "passed", "to", "json", ".", "dumps", "." ]
python
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Script/SConscript.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Script/SConscript.py#L92-L111
def compute_exports(exports): """Compute a dictionary of exports given one of the parameters to the Export() function or the exports argument to SConscript().""" loc, glob = get_calling_namespaces() retval = {} try: for export in exports: if SCons.Util.is_Dict(export): ...
[ "def", "compute_exports", "(", "exports", ")", ":", "loc", ",", "glob", "=", "get_calling_namespaces", "(", ")", "retval", "=", "{", "}", "try", ":", "for", "export", "in", "exports", ":", "if", "SCons", ".", "Util", ".", "is_Dict", "(", "export", ")",...
Compute a dictionary of exports given one of the parameters to the Export() function or the exports argument to SConscript().
[ "Compute", "a", "dictionary", "of", "exports", "given", "one", "of", "the", "parameters", "to", "the", "Export", "()", "function", "or", "the", "exports", "argument", "to", "SConscript", "()", "." ]
python
train
saltstack/salt
salt/utils/dns.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L1128-L1224
def parse_resolv(src='/etc/resolv.conf'): ''' Parse a resolver configuration file (traditionally /etc/resolv.conf) ''' nameservers = [] ip4_nameservers = [] ip6_nameservers = [] search = [] sortlist = [] domain = '' options = [] try: with salt.utils.files.fopen(src)...
[ "def", "parse_resolv", "(", "src", "=", "'/etc/resolv.conf'", ")", ":", "nameservers", "=", "[", "]", "ip4_nameservers", "=", "[", "]", "ip6_nameservers", "=", "[", "]", "search", "=", "[", "]", "sortlist", "=", "[", "]", "domain", "=", "''", "options", ...
Parse a resolver configuration file (traditionally /etc/resolv.conf)
[ "Parse", "a", "resolver", "configuration", "file", "(", "traditionally", "/", "etc", "/", "resolv", ".", "conf", ")" ]
python
train
vinitkumar/pycrawler
crawler.py
https://github.com/vinitkumar/pycrawler/blob/d3fe6d2da1469fc701c4fe04df88cee9cc8cd9c3/crawler.py#L50-L75
async def main(): """ Main class.""" opts, args = option_parser() url = args[0] if opts.links: getlinks(url) raise SystemExit(0) depth = opts.depth sTime = time.time() webcrawler = Webcrawler(url, depth) webcrawler.crawl() eTime = time.time() tTime = eTime - sT...
[ "async", "def", "main", "(", ")", ":", "opts", ",", "args", "=", "option_parser", "(", ")", "url", "=", "args", "[", "0", "]", "if", "opts", ".", "links", ":", "getlinks", "(", "url", ")", "raise", "SystemExit", "(", "0", ")", "depth", "=", "opts...
Main class.
[ "Main", "class", "." ]
python
train
thebigmunch/audio-metadata
src/audio_metadata/api.py
https://github.com/thebigmunch/audio-metadata/blob/d17bdbdb71db79c1568d54438d42dcd940b76074/src/audio_metadata/api.py#L85-L103
def loads(b): """Load audio metadata from a bytes-like object. Parameters: b (bytes-like object): A bytes-like object of an audio file. Returns: Format: An audio format object. Raises: UnsupportedFormat: If file is not of a supported format. """ parser_cls = determine_format(b) if parser_cls is None: ...
[ "def", "loads", "(", "b", ")", ":", "parser_cls", "=", "determine_format", "(", "b", ")", "if", "parser_cls", "is", "None", ":", "raise", "UnsupportedFormat", "(", "\"Supported format signature not found.\"", ")", "return", "parser_cls", ".", "load", "(", "b", ...
Load audio metadata from a bytes-like object. Parameters: b (bytes-like object): A bytes-like object of an audio file. Returns: Format: An audio format object. Raises: UnsupportedFormat: If file is not of a supported format.
[ "Load", "audio", "metadata", "from", "a", "bytes", "-", "like", "object", "." ]
python
train
tradenity/python-sdk
tradenity/resources/tax_rate.py
https://github.com/tradenity/python-sdk/blob/d13fbe23f4d6ff22554c6d8d2deaf209371adaf1/tradenity/resources/tax_rate.py#L539-L559
def delete_tax_rate_by_id(cls, tax_rate_id, **kwargs): """Delete TaxRate Delete an instance of TaxRate by its ID. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.delete_tax_rate_by_id(tax_rate...
[ "def", "delete_tax_rate_by_id", "(", "cls", ",", "tax_rate_id", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async'", ")", ":", "return", "cls", ".", "_delete_tax_rate_by_i...
Delete TaxRate Delete an instance of TaxRate by its ID. This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async=True >>> thread = api.delete_tax_rate_by_id(tax_rate_id, async=True) >>> result = thread.get() :param...
[ "Delete", "TaxRate" ]
python
train
futurecolors/django-geoip
django_geoip/management/ipgeobase.py
https://github.com/futurecolors/django-geoip/blob/f9eee4bcad40508089b184434b79826f842d7bd0/django_geoip/management/ipgeobase.py#L128-L147
def _update_geography(self, countries, regions, cities, city_country_mapping): """ Update database with new countries, regions and cities """ existing = { 'cities': list(City.objects.values_list('id', flat=True)), 'regions': list(Region.objects.values('name', 'country__code')), ...
[ "def", "_update_geography", "(", "self", ",", "countries", ",", "regions", ",", "cities", ",", "city_country_mapping", ")", ":", "existing", "=", "{", "'cities'", ":", "list", "(", "City", ".", "objects", ".", "values_list", "(", "'id'", ",", "flat", "=", ...
Update database with new countries, regions and cities
[ "Update", "database", "with", "new", "countries", "regions", "and", "cities" ]
python
train