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
pandas-dev/pandas
pandas/tseries/offsets.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/tseries/offsets.py#L654-L666
def rollback(self, dt): """ Roll provided date backward to next offset only if not on offset. """ if not self.onOffset(dt): businesshours = self._get_business_hours_by_sec if self.n >= 0: dt = self._prev_opening_time( dt) + time...
[ "def", "rollback", "(", "self", ",", "dt", ")", ":", "if", "not", "self", ".", "onOffset", "(", "dt", ")", ":", "businesshours", "=", "self", ".", "_get_business_hours_by_sec", "if", "self", ".", "n", ">=", "0", ":", "dt", "=", "self", ".", "_prev_op...
Roll provided date backward to next offset only if not on offset.
[ "Roll", "provided", "date", "backward", "to", "next", "offset", "only", "if", "not", "on", "offset", "." ]
python
train
Alignak-monitoring/alignak
alignak/objects/host.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/host.py#L1095-L1104
def _tot_services_by_state(self, services, state): """Get the number of service in the specified state :param state: state to filter service :type state: :return: number of service with s.state_id == state :rtype: int """ return str(sum(1 for s in self.services ...
[ "def", "_tot_services_by_state", "(", "self", ",", "services", ",", "state", ")", ":", "return", "str", "(", "sum", "(", "1", "for", "s", "in", "self", ".", "services", "if", "services", "[", "s", "]", ".", "state_id", "==", "state", ")", ")" ]
Get the number of service in the specified state :param state: state to filter service :type state: :return: number of service with s.state_id == state :rtype: int
[ "Get", "the", "number", "of", "service", "in", "the", "specified", "state" ]
python
train
gatkin/declxml
declxml.py
https://github.com/gatkin/declxml/blob/3a2324b43aee943e82a04587fbb68932c6f392ba/declxml.py#L1547-L1559
def _parse_boolean(element_text, state): """Parse the raw XML string as a boolean value.""" value = None lowered_text = element_text.lower() if lowered_text == 'true': value = True elif lowered_text == 'false': value = False else: state.raise_error(InvalidPrimitiveValue,...
[ "def", "_parse_boolean", "(", "element_text", ",", "state", ")", ":", "value", "=", "None", "lowered_text", "=", "element_text", ".", "lower", "(", ")", "if", "lowered_text", "==", "'true'", ":", "value", "=", "True", "elif", "lowered_text", "==", "'false'",...
Parse the raw XML string as a boolean value.
[ "Parse", "the", "raw", "XML", "string", "as", "a", "boolean", "value", "." ]
python
train
Ex-Mente/auxi.0
auxi/tools/chemistry/thermochemistry.py
https://github.com/Ex-Mente/auxi.0/blob/2dcdae74154f136f8ca58289fe5b20772f215046/auxi/tools/chemistry/thermochemistry.py#L553-L653
def _read_compound_from_factsage_file_(file_name): """ Build a dictionary containing the factsage thermochemical data of a compound by reading the data from a file. :param file_name: Name of file to read the data from. :returns: Dictionary containing compound data. """ with open(file_name...
[ "def", "_read_compound_from_factsage_file_", "(", "file_name", ")", ":", "with", "open", "(", "file_name", ")", "as", "f", ":", "lines", "=", "f", ".", "readlines", "(", ")", "compound", "=", "{", "'Formula'", ":", "lines", "[", "0", "]", ".", "split", ...
Build a dictionary containing the factsage thermochemical data of a compound by reading the data from a file. :param file_name: Name of file to read the data from. :returns: Dictionary containing compound data.
[ "Build", "a", "dictionary", "containing", "the", "factsage", "thermochemical", "data", "of", "a", "compound", "by", "reading", "the", "data", "from", "a", "file", "." ]
python
valid
KelSolaar/Umbra
umbra/components/factory/script_editor/workers.py
https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/components/factory/script_editor/workers.py#L192-L203
def pattern(self, value): """ Setter for **self.__pattern** attribute. :param value: Attribute value. :type value: unicode """ if value is not None: assert type(value) in (unicode, QString), \ "'{0}' attribute: '{1}' type is not 'unicode' or ...
[ "def", "pattern", "(", "self", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "assert", "type", "(", "value", ")", "in", "(", "unicode", ",", "QString", ")", ",", "\"'{0}' attribute: '{1}' type is not 'unicode' or 'QString'!\"", ".", "format"...
Setter for **self.__pattern** attribute. :param value: Attribute value. :type value: unicode
[ "Setter", "for", "**", "self", ".", "__pattern", "**", "attribute", "." ]
python
train
GeoPyTool/GeoPyTool
geopytool/GLMultiDimension.py
https://github.com/GeoPyTool/GeoPyTool/blob/8c198aa42e4fbdf62fac05d40cbf4d1086328da3/geopytool/GLMultiDimension.py#L507-L727
def Magic(self): #self.view.setFixedSize(self.width(), self.width()) self.WholeData = [] self.x_scale = self.width_plot / self.width_load self.y_scale = self.height_plot / self.height_load self.z_scale = self.depth_plot / self.depth_load # print(self.x_scale,' and ...
[ "def", "Magic", "(", "self", ")", ":", "#self.view.setFixedSize(self.width(), self.width())", "self", ".", "WholeData", "=", "[", "]", "self", ".", "x_scale", "=", "self", ".", "width_plot", "/", "self", ".", "width_load", "self", ".", "y_scale", "=", "self", ...
xgrid.scale(12.8, 12.8, 12.8) ygrid.scale(12.8, 12.8, 12.8) zgrid.scale(12.8, 12.8, 12.8)
[ "xgrid", ".", "scale", "(", "12", ".", "8", "12", ".", "8", "12", ".", "8", ")", "ygrid", ".", "scale", "(", "12", ".", "8", "12", ".", "8", "12", ".", "8", ")", "zgrid", ".", "scale", "(", "12", ".", "8", "12", ".", "8", "12", ".", "8"...
python
train
KxSystems/pyq
src/pyq/magic.py
https://github.com/KxSystems/pyq/blob/ad7b807abde94615a7344aaa930bb01fb1552cc5/src/pyq/magic.py#L23-L38
def logical_lines(lines): """Merge lines into chunks according to q rules""" if isinstance(lines, string_types): lines = StringIO(lines) buf = [] for line in lines: if buf and not line.startswith(' '): chunk = ''.join(buf).strip() if chunk: yield c...
[ "def", "logical_lines", "(", "lines", ")", ":", "if", "isinstance", "(", "lines", ",", "string_types", ")", ":", "lines", "=", "StringIO", "(", "lines", ")", "buf", "=", "[", "]", "for", "line", "in", "lines", ":", "if", "buf", "and", "not", "line", ...
Merge lines into chunks according to q rules
[ "Merge", "lines", "into", "chunks", "according", "to", "q", "rules" ]
python
train
Qiskit/qiskit-terra
qiskit/validation/fields/custom.py
https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/validation/fields/custom.py#L113-L124
def check_type(self, value, attr, data): """Customize check_type for handling containers.""" # Check the type in the standard way first, in order to fail quickly # in case of invalid values. root_value = super(InstructionParameter, self).check_type( value, attr, data) ...
[ "def", "check_type", "(", "self", ",", "value", ",", "attr", ",", "data", ")", ":", "# Check the type in the standard way first, in order to fail quickly", "# in case of invalid values.", "root_value", "=", "super", "(", "InstructionParameter", ",", "self", ")", ".", "c...
Customize check_type for handling containers.
[ "Customize", "check_type", "for", "handling", "containers", "." ]
python
test
Dallinger/Dallinger
dallinger/heroku/tools.py
https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/heroku/tools.py#L190-L195
def destroy(self): """Destroy an app and all its add-ons""" result = self._result( ["heroku", "apps:destroy", "--app", self.name, "--confirm", self.name] ) return result
[ "def", "destroy", "(", "self", ")", ":", "result", "=", "self", ".", "_result", "(", "[", "\"heroku\"", ",", "\"apps:destroy\"", ",", "\"--app\"", ",", "self", ".", "name", ",", "\"--confirm\"", ",", "self", ".", "name", "]", ")", "return", "result" ]
Destroy an app and all its add-ons
[ "Destroy", "an", "app", "and", "all", "its", "add", "-", "ons" ]
python
train
glue-viz/glue-vispy-viewers
glue_vispy_viewers/extern/vispy/util/quaternion.py
https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/util/quaternion.py#L193-L210
def get_axis_angle(self): """ Get the axis-angle representation of the quaternion. (The angle is in radians) """ # Init angle = 2 * np.arccos(max(min(self.w, 1.), -1.)) scale = (self.x**2 + self.y**2 + self.z**2)**0.5 # Calc axis if scale: ...
[ "def", "get_axis_angle", "(", "self", ")", ":", "# Init", "angle", "=", "2", "*", "np", ".", "arccos", "(", "max", "(", "min", "(", "self", ".", "w", ",", "1.", ")", ",", "-", "1.", ")", ")", "scale", "=", "(", "self", ".", "x", "**", "2", ...
Get the axis-angle representation of the quaternion. (The angle is in radians)
[ "Get", "the", "axis", "-", "angle", "representation", "of", "the", "quaternion", ".", "(", "The", "angle", "is", "in", "radians", ")" ]
python
train
assamite/creamas
creamas/examples/spiro/spiro_agent_mp.py
https://github.com/assamite/creamas/blob/54dc3e31c97a3f938e58272f8ab80b6bcafeff58/creamas/examples/spiro/spiro_agent_mp.py#L651-L702
def plot_places(self): '''Plot places (in the parameter space) of all the generated artifacts and the artifacts accepted to the domain. ''' from matplotlib import pyplot as plt fig, ax = plt.subplots() title = "Agent places, artifacts and env artifacts ({} env artifacts)"...
[ "def", "plot_places", "(", "self", ")", ":", "from", "matplotlib", "import", "pyplot", "as", "plt", "fig", ",", "ax", "=", "plt", ".", "subplots", "(", ")", "title", "=", "\"Agent places, artifacts and env artifacts ({} env artifacts)\"", ".", "format", "(", "le...
Plot places (in the parameter space) of all the generated artifacts and the artifacts accepted to the domain.
[ "Plot", "places", "(", "in", "the", "parameter", "space", ")", "of", "all", "the", "generated", "artifacts", "and", "the", "artifacts", "accepted", "to", "the", "domain", "." ]
python
train
mattupstate/flask-security
flask_security/cli.py
https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/cli.py#L130-L139
def users_activate(user): """Activate a user.""" user_obj = _datastore.get_user(user) if user_obj is None: raise click.UsageError('ERROR: User not found.') if _datastore.activate_user(user_obj): click.secho('User "{0}" has been activated.'.format(user), fg='green') else: clic...
[ "def", "users_activate", "(", "user", ")", ":", "user_obj", "=", "_datastore", ".", "get_user", "(", "user", ")", "if", "user_obj", "is", "None", ":", "raise", "click", ".", "UsageError", "(", "'ERROR: User not found.'", ")", "if", "_datastore", ".", "activa...
Activate a user.
[ "Activate", "a", "user", "." ]
python
train
spotify/luigi
luigi/contrib/opener.py
https://github.com/spotify/luigi/blob/c5eca1c3c3ee2a7eb612486192a0da146710a1e9/luigi/contrib/opener.py#L115-L142
def open(self, target_uri, **kwargs): """Open target uri. :param target_uri: Uri to open :type target_uri: string :returns: Target object """ target = urlsplit(target_uri, scheme=self.default_opener) opener = self.get_opener(target.scheme) query = open...
[ "def", "open", "(", "self", ",", "target_uri", ",", "*", "*", "kwargs", ")", ":", "target", "=", "urlsplit", "(", "target_uri", ",", "scheme", "=", "self", ".", "default_opener", ")", "opener", "=", "self", ".", "get_opener", "(", "target", ".", "schem...
Open target uri. :param target_uri: Uri to open :type target_uri: string :returns: Target object
[ "Open", "target", "uri", "." ]
python
train
theelous3/multio
multio/__init__.py
https://github.com/theelous3/multio/blob/018e4a9f78d5f4e78608a1a1537000b5fd778bbe/multio/__init__.py#L112-L121
def wrap(cls, meth): ''' Wraps a connection opening method in this class. ''' async def inner(*args, **kwargs): sock = await meth(*args, **kwargs) return cls(sock) return inner
[ "def", "wrap", "(", "cls", ",", "meth", ")", ":", "async", "def", "inner", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "sock", "=", "await", "meth", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "cls", "(", "sock", ")", "...
Wraps a connection opening method in this class.
[ "Wraps", "a", "connection", "opening", "method", "in", "this", "class", "." ]
python
train
DataDog/integrations-core
vsphere/datadog_checks/vsphere/vsphere.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/vsphere/datadog_checks/vsphere/vsphere.py#L68-L80
def trace_method(method): """ Decorator to catch and print the exceptions that happen within async tasks. Note: this should be applied to methods of VSphereCheck only! """ def wrapper(*args, **kwargs): try: method(*args, **kwargs) except Exception: args[0].pr...
[ "def", "trace_method", "(", "method", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "method", "(", "*", "args", ",", "*", "*", "kwargs", ")", "except", "Exception", ":", "args", "[", "0", "]", ".", ...
Decorator to catch and print the exceptions that happen within async tasks. Note: this should be applied to methods of VSphereCheck only!
[ "Decorator", "to", "catch", "and", "print", "the", "exceptions", "that", "happen", "within", "async", "tasks", ".", "Note", ":", "this", "should", "be", "applied", "to", "methods", "of", "VSphereCheck", "only!" ]
python
train
QuantEcon/QuantEcon.py
quantecon/kalman.py
https://github.com/QuantEcon/QuantEcon.py/blob/26a66c552f2a73967d7efb6e1f4b4c4985a12643/quantecon/kalman.py#L279-L312
def stationary_coefficients(self, j, coeff_type='ma'): """ Wold representation moving average or VAR coefficients for the steady state Kalman filter. Parameters ---------- j : int The lag length coeff_type : string, either 'ma' or 'var' (default='ma')...
[ "def", "stationary_coefficients", "(", "self", ",", "j", ",", "coeff_type", "=", "'ma'", ")", ":", "# == simplify notation == #", "A", ",", "G", "=", "self", ".", "ss", ".", "A", ",", "self", ".", "ss", ".", "G", "K_infinity", "=", "self", ".", "K_infi...
Wold representation moving average or VAR coefficients for the steady state Kalman filter. Parameters ---------- j : int The lag length coeff_type : string, either 'ma' or 'var' (default='ma') The type of coefficent sequence to compute. Either 'ma' for ...
[ "Wold", "representation", "moving", "average", "or", "VAR", "coefficients", "for", "the", "steady", "state", "Kalman", "filter", "." ]
python
train
earlzo/hfut
hfut/shortcut.py
https://github.com/earlzo/hfut/blob/09270a9647fba79f26fd1a8a3c53c0678b5257a1/hfut/shortcut.py#L237-L265
def evaluate_course(self, kcdm, jxbh, r101=1, r102=1, r103=1, r104=1, r105=1, r106=1, r107=1, r108=1, r109=1, r201=3, r202=3, advice=''): """ 课程评价, 数值为 1-5, r1 类选项 1 为最好, 5 为最差, r2 类选项程度由深到浅, 3 为最好. 默认都是最好的选项 :param kcdm: 课程代码 :pa...
[ "def", "evaluate_course", "(", "self", ",", "kcdm", ",", "jxbh", ",", "r101", "=", "1", ",", "r102", "=", "1", ",", "r103", "=", "1", ",", "r104", "=", "1", ",", "r105", "=", "1", ",", "r106", "=", "1", ",", "r107", "=", "1", ",", "r108", "...
课程评价, 数值为 1-5, r1 类选项 1 为最好, 5 为最差, r2 类选项程度由深到浅, 3 为最好. 默认都是最好的选项 :param kcdm: 课程代码 :param jxbh: 教学班号 :param r101: 教学态度认真,课前准备充分 :param r102: 教授内容充实,要点重点突出 :param r103: 理论联系实际,反映最新成果 :param r104: 教学方法灵活,师生互动得当 :param r105: 运用现代技术,教学手段多样 :param r...
[ "课程评价", "数值为", "1", "-", "5", "r1", "类选项", "1", "为最好", "5", "为最差", "r2", "类选项程度由深到浅", "3", "为最好", "." ]
python
train
inveniosoftware/invenio-query-parser
invenio_query_parser/walkers/match_unit.py
https://github.com/inveniosoftware/invenio-query-parser/blob/21a2c36318003ff52d2e18e7196bb420db8ecb4b/invenio_query_parser/walkers/match_unit.py#L37-L54
def dottable_getitem(data, dottable_key, default=None): """Return item as ``dict.__getitem__` but using keys with dots. It does not address indexes in iterables. """ def getitem(value, *keys): if not keys: return default elif len(keys) == 1: key = keys[0] ...
[ "def", "dottable_getitem", "(", "data", ",", "dottable_key", ",", "default", "=", "None", ")", ":", "def", "getitem", "(", "value", ",", "*", "keys", ")", ":", "if", "not", "keys", ":", "return", "default", "elif", "len", "(", "keys", ")", "==", "1",...
Return item as ``dict.__getitem__` but using keys with dots. It does not address indexes in iterables.
[ "Return", "item", "as", "dict", ".", "__getitem__", "but", "using", "keys", "with", "dots", "." ]
python
train
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Defaults.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Defaults.py#L344-L358
def _concat(prefix, list, suffix, env, f=lambda x: x, target=None, source=None): """ Creates a new list from 'list' by first interpolating each element in the list using the 'env' dictionary and then calling f on the list, and finally calling _concat_ixes to concatenate 'prefix' and 'suffix' onto ea...
[ "def", "_concat", "(", "prefix", ",", "list", ",", "suffix", ",", "env", ",", "f", "=", "lambda", "x", ":", "x", ",", "target", "=", "None", ",", "source", "=", "None", ")", ":", "if", "not", "list", ":", "return", "list", "l", "=", "f", "(", ...
Creates a new list from 'list' by first interpolating each element in the list using the 'env' dictionary and then calling f on the list, and finally calling _concat_ixes to concatenate 'prefix' and 'suffix' onto each element of the list.
[ "Creates", "a", "new", "list", "from", "list", "by", "first", "interpolating", "each", "element", "in", "the", "list", "using", "the", "env", "dictionary", "and", "then", "calling", "f", "on", "the", "list", "and", "finally", "calling", "_concat_ixes", "to",...
python
train
VingtCinq/python-mailchimp
mailchimp3/entities/automationemailqueues.py
https://github.com/VingtCinq/python-mailchimp/blob/1b472f1b64fdde974732ac4b7ed48908bb707260/mailchimp3/entities/automationemailqueues.py#L31-L61
def create(self, workflow_id, email_id, data): """ Manually add a subscriber to a workflow, bypassing the default trigger settings. You can also use this endpoint to trigger a series of automated emails in an API 3.0 workflow type or add subscribers to an automated email queue th...
[ "def", "create", "(", "self", ",", "workflow_id", ",", "email_id", ",", "data", ")", ":", "self", ".", "workflow_id", "=", "workflow_id", "self", ".", "email_id", "=", "email_id", "if", "'email_address'", "not", "in", "data", ":", "raise", "KeyError", "(",...
Manually add a subscriber to a workflow, bypassing the default trigger settings. You can also use this endpoint to trigger a series of automated emails in an API 3.0 workflow type or add subscribers to an automated email queue that uses the API request delay type. :param workflow_id: Th...
[ "Manually", "add", "a", "subscriber", "to", "a", "workflow", "bypassing", "the", "default", "trigger", "settings", ".", "You", "can", "also", "use", "this", "endpoint", "to", "trigger", "a", "series", "of", "automated", "emails", "in", "an", "API", "3", "....
python
valid
dead-beef/markovchain
markovchain/cli/util.py
https://github.com/dead-beef/markovchain/blob/9bd10b2f01089341c4a875a0fa569d50caba22c7/markovchain/cli/util.py#L342-L360
def cmd_settings(args): """Print generator settings. Parameters ---------- args : `argparse.Namespace` Command arguments. """ if args.type == SQLITE: storage = SqliteStorage else: storage = JsonStorage storage = storage.load(args.state) data = storage.setting...
[ "def", "cmd_settings", "(", "args", ")", ":", "if", "args", ".", "type", "==", "SQLITE", ":", "storage", "=", "SqliteStorage", "else", ":", "storage", "=", "JsonStorage", "storage", "=", "storage", ".", "load", "(", "args", ".", "state", ")", "data", "...
Print generator settings. Parameters ---------- args : `argparse.Namespace` Command arguments.
[ "Print", "generator", "settings", "." ]
python
train
kajala/django-jutil
jutil/format.py
https://github.com/kajala/django-jutil/blob/2abd93ebad51042744eaeb1ee1074ed0eb55ad0c/jutil/format.py#L6-L47
def format_full_name(first_name: str, last_name: str, max_length: int = 20): """ Limits name length to specified length. Tries to keep name as human-readable an natural as possible. :param first_name: First name :param last_name: Last name :param max_length: Maximum length :return: Full name of ...
[ "def", "format_full_name", "(", "first_name", ":", "str", ",", "last_name", ":", "str", ",", "max_length", ":", "int", "=", "20", ")", ":", "# dont allow commas in limited names", "first_name", "=", "first_name", ".", "replace", "(", "','", ",", "' '", ")", ...
Limits name length to specified length. Tries to keep name as human-readable an natural as possible. :param first_name: First name :param last_name: Last name :param max_length: Maximum length :return: Full name of shortened version depending on length
[ "Limits", "name", "length", "to", "specified", "length", ".", "Tries", "to", "keep", "name", "as", "human", "-", "readable", "an", "natural", "as", "possible", ".", ":", "param", "first_name", ":", "First", "name", ":", "param", "last_name", ":", "Last", ...
python
train
apple/turicreate
deps/src/libxml2-2.9.1/python/libxml2.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libxml2-2.9.1/python/libxml2.py#L6331-L6338
def relaxNGValidatePushElement(self, doc, elem): """Push a new element start on the RelaxNG validation stack. """ if doc is None: doc__o = None else: doc__o = doc._o if elem is None: elem__o = None else: elem__o = elem._o ret = libxml2mod.xmlRelaxNGValidatePushElement(sel...
[ "def", "relaxNGValidatePushElement", "(", "self", ",", "doc", ",", "elem", ")", ":", "if", "doc", "is", "None", ":", "doc__o", "=", "None", "else", ":", "doc__o", "=", "doc", ".", "_o", "if", "elem", "is", "None", ":", "elem__o", "=", "None", "else",...
Push a new element start on the RelaxNG validation stack.
[ "Push", "a", "new", "element", "start", "on", "the", "RelaxNG", "validation", "stack", "." ]
python
train
humilis/humilis-lambdautils
lambdautils/state.py
https://github.com/humilis/humilis-lambdautils/blob/58f75eb5ace23523c283708d56a9193181ea7e8e/lambdautils/state.py#L409-L427
def arrival_delay_greater_than(item_id, delay, namespace="_expected_arrival"): """Check if an item arrival is delayed more than a given amount.""" expected = get_state(item_id, namespace=namespace) now = time.time() if expected and (now - expected) > delay: logger.error("Timeout: waited %s secon...
[ "def", "arrival_delay_greater_than", "(", "item_id", ",", "delay", ",", "namespace", "=", "\"_expected_arrival\"", ")", ":", "expected", "=", "get_state", "(", "item_id", ",", "namespace", "=", "namespace", ")", "now", "=", "time", ".", "time", "(", ")", "if...
Check if an item arrival is delayed more than a given amount.
[ "Check", "if", "an", "item", "arrival", "is", "delayed", "more", "than", "a", "given", "amount", "." ]
python
train
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L829-L833
def list_security_group_rules(self, retrieve_all=True, **_params): """Fetches a list of all security group rules for a project.""" return self.list('security_group_rules', self.security_group_rules_path, retrieve_all, **_params)
[ "def", "list_security_group_rules", "(", "self", ",", "retrieve_all", "=", "True", ",", "*", "*", "_params", ")", ":", "return", "self", ".", "list", "(", "'security_group_rules'", ",", "self", ".", "security_group_rules_path", ",", "retrieve_all", ",", "*", "...
Fetches a list of all security group rules for a project.
[ "Fetches", "a", "list", "of", "all", "security", "group", "rules", "for", "a", "project", "." ]
python
train
tensorflow/hub
tensorflow_hub/saved_model_lib.py
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/saved_model_lib.py#L391-L406
def export(self, path, variables_saver=None): """Exports to SavedModel directory. Args: path: path where to export the SavedModel to. variables_saver: lambda that receives a directory path where to export checkpoints of variables. """ # Operate on a copy of self._proto since it need...
[ "def", "export", "(", "self", ",", "path", ",", "variables_saver", "=", "None", ")", ":", "# Operate on a copy of self._proto since it needs to be modified.", "proto", "=", "saved_model_pb2", ".", "SavedModel", "(", ")", "proto", ".", "CopyFrom", "(", "self", ".", ...
Exports to SavedModel directory. Args: path: path where to export the SavedModel to. variables_saver: lambda that receives a directory path where to export checkpoints of variables.
[ "Exports", "to", "SavedModel", "directory", "." ]
python
train
bcbio/bcbio-nextgen
bcbio/variation/validate.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/validate.py#L671-L680
def _get_validate_plotdata_yaml(grading_file, data): """Retrieve validation plot data from grading YAML file (old style). """ with open(grading_file) as in_handle: grade_stats = yaml.safe_load(in_handle) for sample_stats in grade_stats: sample = sample_stats["sample"] for vtype, ...
[ "def", "_get_validate_plotdata_yaml", "(", "grading_file", ",", "data", ")", ":", "with", "open", "(", "grading_file", ")", "as", "in_handle", ":", "grade_stats", "=", "yaml", ".", "safe_load", "(", "in_handle", ")", "for", "sample_stats", "in", "grade_stats", ...
Retrieve validation plot data from grading YAML file (old style).
[ "Retrieve", "validation", "plot", "data", "from", "grading", "YAML", "file", "(", "old", "style", ")", "." ]
python
train
googleads/googleads-python-lib
examples/adwords/v201809/advanced_operations/add_shopping_dynamic_remarketing_campaign.py
https://github.com/googleads/googleads-python-lib/blob/aa3b1b474b0f9789ca55ca46f4b2b57aeae38874/examples/adwords/v201809/advanced_operations/add_shopping_dynamic_remarketing_campaign.py#L216-L246
def AttachUserList(client, ad_group_id, user_list_id): """Links the provided ad group and user list. Args: client: an AdWordsClient instance. ad_group_id: an int ad group ID. user_list_id: an int user list ID. Returns: The ad group criterion that was successfully created. """ ad_group_criter...
[ "def", "AttachUserList", "(", "client", ",", "ad_group_id", ",", "user_list_id", ")", ":", "ad_group_criterion_service", "=", "client", ".", "GetService", "(", "'AdGroupCriterionService'", ",", "'v201809'", ")", "user_list", "=", "{", "'xsi_type'", ":", "'CriterionU...
Links the provided ad group and user list. Args: client: an AdWordsClient instance. ad_group_id: an int ad group ID. user_list_id: an int user list ID. Returns: The ad group criterion that was successfully created.
[ "Links", "the", "provided", "ad", "group", "and", "user", "list", "." ]
python
train
timothyb0912/pylogit
pylogit/asym_logit.py
https://github.com/timothyb0912/pylogit/blob/f83b0fd6debaa7358d87c3828428f6d4ead71357/pylogit/asym_logit.py#L184-L225
def _calc_deriv_c_with_respect_to_eta(natural_shapes, ref_position, output_array=None): """ Parameters ---------- natural_shapes : 1D ndarray. Should have one element per available alternative in the dataset whose ...
[ "def", "_calc_deriv_c_with_respect_to_eta", "(", "natural_shapes", ",", "ref_position", ",", "output_array", "=", "None", ")", ":", "# Generate a list of the indices which indicate the columns to be", "# selected from a 2D numpy array of", "# np.diag(natural_shapes) - np.outer(natural_sh...
Parameters ---------- natural_shapes : 1D ndarray. Should have one element per available alternative in the dataset whose choice situations are being modeled. Should have at least `ref_position` elements in it. ref_position : int. Specifies the position in the array of natura...
[ "Parameters", "----------", "natural_shapes", ":", "1D", "ndarray", ".", "Should", "have", "one", "element", "per", "available", "alternative", "in", "the", "dataset", "whose", "choice", "situations", "are", "being", "modeled", ".", "Should", "have", "at", "leas...
python
train
andreafioraldi/angrdbg
angrdbg/page_7.py
https://github.com/andreafioraldi/angrdbg/blob/939b20fb9b341aee695d2db12142b1eddc5b555a/angrdbg/page_7.py#L247-L284
def load_objects(self, addr, num_bytes, ret_on_segv=False): """ Load memory objects from paged memory. :param addr: Address to start loading. :param num_bytes: Number of bytes to load. :param bool ret_on_segv: True if you want load_bytes to return directly when a SIGSEV is trigg...
[ "def", "load_objects", "(", "self", ",", "addr", ",", "num_bytes", ",", "ret_on_segv", "=", "False", ")", ":", "result", "=", "[", "]", "end", "=", "addr", "+", "num_bytes", "for", "page_addr", "in", "self", ".", "_containing_pages", "(", "addr", ",", ...
Load memory objects from paged memory. :param addr: Address to start loading. :param num_bytes: Number of bytes to load. :param bool ret_on_segv: True if you want load_bytes to return directly when a SIGSEV is triggered, otherwise a SimSegfaultError will be rais...
[ "Load", "memory", "objects", "from", "paged", "memory", "." ]
python
train
redvox/Eliza
eliza/config.py
https://github.com/redvox/Eliza/blob/8661222fe792fca92bc25546f8ac7b5dd673913d/eliza/config.py#L58-L100
def load_config(self, path, environments, fill_with_defaults=False): """Will load default.yaml and <environment>.yaml at given path. The environment config will override the default values. :param path: directory where to find your config files. If the last character is not a slash (/) it will ...
[ "def", "load_config", "(", "self", ",", "path", ",", "environments", ",", "fill_with_defaults", "=", "False", ")", ":", "yaml", ".", "add_implicit_resolver", "(", "\"!environ\"", ",", "self", ".", "__environ_pattern", ")", "yaml", ".", "add_constructor", "(", ...
Will load default.yaml and <environment>.yaml at given path. The environment config will override the default values. :param path: directory where to find your config files. If the last character is not a slash (/) it will be appended. Example: resources/ :param environments: list of environmen...
[ "Will", "load", "default", ".", "yaml", "and", "<environment", ">", ".", "yaml", "at", "given", "path", ".", "The", "environment", "config", "will", "override", "the", "default", "values", "." ]
python
train
tnkteja/myhelp
virtualEnvironment/lib/python2.7/site-packages/pkginfo/utils.py
https://github.com/tnkteja/myhelp/blob/fb3a4809d448ad14d5b2e6ddf2e7e89ad52b71cb/virtualEnvironment/lib/python2.7/site-packages/pkginfo/utils.py#L10-L57
def get_metadata(path_or_module, metadata_version=None): """ Try to create a Distribution 'path_or_module'. o 'path_or_module' may be a module object. o If a string, 'path_or_module' may point to an sdist file, a bdist file, an installed package, or a working checkout (if it contains PKG-I...
[ "def", "get_metadata", "(", "path_or_module", ",", "metadata_version", "=", "None", ")", ":", "if", "isinstance", "(", "path_or_module", ",", "ModuleType", ")", ":", "try", ":", "return", "Installed", "(", "path_or_module", ",", "metadata_version", ")", "except"...
Try to create a Distribution 'path_or_module'. o 'path_or_module' may be a module object. o If a string, 'path_or_module' may point to an sdist file, a bdist file, an installed package, or a working checkout (if it contains PKG-INFO). o Return None if 'path_or_module' can't be parsed.
[ "Try", "to", "create", "a", "Distribution", "path_or_module", ".", "o", "path_or_module", "may", "be", "a", "module", "object", "." ]
python
test
tnkteja/myhelp
virtualEnvironment/lib/python2.7/site-packages/coverage/control.py
https://github.com/tnkteja/myhelp/blob/fb3a4809d448ad14d5b2e6ddf2e7e89ad52b71cb/virtualEnvironment/lib/python2.7/site-packages/coverage/control.py#L222-L288
def _should_trace_with_reason(self, filename, frame): """Decide whether to trace execution in `filename`, with a reason. This function is called from the trace function. As each new file name is encountered, this function determines whether it is traced or not. Returns a pair of value...
[ "def", "_should_trace_with_reason", "(", "self", ",", "filename", ",", "frame", ")", ":", "if", "not", "filename", ":", "# Empty string is pretty useless", "return", "None", ",", "\"empty string isn't a filename\"", "if", "filename", ".", "startswith", "(", "'<'", "...
Decide whether to trace execution in `filename`, with a reason. This function is called from the trace function. As each new file name is encountered, this function determines whether it is traced or not. Returns a pair of values: the first indicates whether the file should be traced...
[ "Decide", "whether", "to", "trace", "execution", "in", "filename", "with", "a", "reason", "." ]
python
test
edeposit/edeposit.amqp.harvester
src/edeposit/amqp/harvester/scrappers/cpress_cz.py
https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/cpress_cz.py#L205-L227
def _parse_description(html_chunk): """ Parse description of the book. Args: html_chunk (obj): HTMLElement containing slice of the page with details. Returns: str/None: Description as string or None if not found. """ description_tag = html_chunk.match( ["div", {"class":...
[ "def", "_parse_description", "(", "html_chunk", ")", ":", "description_tag", "=", "html_chunk", ".", "match", "(", "[", "\"div\"", ",", "{", "\"class\"", ":", "\"kniha_detail_text\"", "}", "]", ",", "\"p\"", ")", "if", "not", "description_tag", ":", "return", ...
Parse description of the book. Args: html_chunk (obj): HTMLElement containing slice of the page with details. Returns: str/None: Description as string or None if not found.
[ "Parse", "description", "of", "the", "book", "." ]
python
train
ergoithz/browsepy
browsepy/manager.py
https://github.com/ergoithz/browsepy/blob/1612a930ef220fae507e1b152c531707e555bd92/browsepy/manager.py#L455-L494
def load_arguments(self, argv, base=None): ''' Process given argument list based on registered arguments and given optional base :class:`argparse.ArgumentParser` instance. This method saves processed arguments on itself, and this state won't be lost after :meth:`clean` calls. ...
[ "def", "load_arguments", "(", "self", ",", "argv", ",", "base", "=", "None", ")", ":", "plugin_parser", "=", "argparse", ".", "ArgumentParser", "(", "add_help", "=", "False", ")", "plugin_parser", ".", "add_argument", "(", "'--plugin'", ",", "action", "=", ...
Process given argument list based on registered arguments and given optional base :class:`argparse.ArgumentParser` instance. This method saves processed arguments on itself, and this state won't be lost after :meth:`clean` calls. Processed argument state will be available via :meth:`ge...
[ "Process", "given", "argument", "list", "based", "on", "registered", "arguments", "and", "given", "optional", "base", ":", "class", ":", "argparse", ".", "ArgumentParser", "instance", "." ]
python
train
GNS3/gns3-server
gns3server/compute/dynamips/nodes/ethernet_switch.py
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/dynamips/nodes/ethernet_switch.py#L262-L289
def remove_nio(self, port_number): """ Removes the specified NIO as member of this Ethernet switch. :param port_number: allocated port number :returns: the NIO that was bound to the port """ if port_number not in self._nios: raise DynamipsError("Port {} is ...
[ "def", "remove_nio", "(", "self", ",", "port_number", ")", ":", "if", "port_number", "not", "in", "self", ".", "_nios", ":", "raise", "DynamipsError", "(", "\"Port {} is not allocated\"", ".", "format", "(", "port_number", ")", ")", "nio", "=", "self", ".", ...
Removes the specified NIO as member of this Ethernet switch. :param port_number: allocated port number :returns: the NIO that was bound to the port
[ "Removes", "the", "specified", "NIO", "as", "member", "of", "this", "Ethernet", "switch", "." ]
python
train
mrstephenneal/mysql-toolkit
mysql/toolkit/components/connector.py
https://github.com/mrstephenneal/mysql-toolkit/blob/6964f718f4b72eb30f2259adfcfaf3090526c53d/mysql/toolkit/components/connector.py#L60-L72
def executemany(self, command, params=None, max_attempts=5): """Execute multiple SQL queries without returning a result.""" attempts = 0 while attempts < max_attempts: try: # Execute statement self._cursor.executemany(command, params) s...
[ "def", "executemany", "(", "self", ",", "command", ",", "params", "=", "None", ",", "max_attempts", "=", "5", ")", ":", "attempts", "=", "0", "while", "attempts", "<", "max_attempts", ":", "try", ":", "# Execute statement", "self", ".", "_cursor", ".", "...
Execute multiple SQL queries without returning a result.
[ "Execute", "multiple", "SQL", "queries", "without", "returning", "a", "result", "." ]
python
train
deontologician/restnavigator
restnavigator/halnav.py
https://github.com/deontologician/restnavigator/blob/453b9de4e70e602009d3e3ffafcf77d23c8b07c5/restnavigator/halnav.py#L396-L404
def _make_embedded_from(self, doc): '''Creates embedded navigators from a HAL response doc''' ld = utils.CurieDict(self._core.default_curie, {}) for rel, doc in doc.get('_embedded', {}).items(): if isinstance(doc, list): ld[rel] = [self._recursively_embed(d) for d in ...
[ "def", "_make_embedded_from", "(", "self", ",", "doc", ")", ":", "ld", "=", "utils", ".", "CurieDict", "(", "self", ".", "_core", ".", "default_curie", ",", "{", "}", ")", "for", "rel", ",", "doc", "in", "doc", ".", "get", "(", "'_embedded'", ",", ...
Creates embedded navigators from a HAL response doc
[ "Creates", "embedded", "navigators", "from", "a", "HAL", "response", "doc" ]
python
train
twisted/mantissa
xmantissa/website.py
https://github.com/twisted/mantissa/blob/53e5502aba23ce99be78b27f923a276593033fe8/xmantissa/website.py#L646-L659
def getKeyForAPI(cls, siteStore, apiName): """ Get the API key for the named API, if one exists. @param siteStore: The site store. @type siteStore: L{axiom.store.Store} @param apiName: The name of the API. @type apiName: C{unicode} (L{APIKey} constant) @rtype: ...
[ "def", "getKeyForAPI", "(", "cls", ",", "siteStore", ",", "apiName", ")", ":", "return", "siteStore", ".", "findUnique", "(", "cls", ",", "cls", ".", "apiName", "==", "apiName", ",", "default", "=", "None", ")" ]
Get the API key for the named API, if one exists. @param siteStore: The site store. @type siteStore: L{axiom.store.Store} @param apiName: The name of the API. @type apiName: C{unicode} (L{APIKey} constant) @rtype: L{APIKey} or C{NoneType}
[ "Get", "the", "API", "key", "for", "the", "named", "API", "if", "one", "exists", "." ]
python
train
DataONEorg/d1_python
gmn/src/d1_gmn/app/auth.py
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/auth.py#L164-L195
def is_allowed(request, level, pid): """Check if one or more subjects are allowed to perform action level on object. If a subject holds permissions for one action level on object, all lower action levels are also allowed. Any included subject that is unknown to this MN is treated as a subject without p...
[ "def", "is_allowed", "(", "request", ",", "level", ",", "pid", ")", ":", "if", "is_trusted_subject", "(", "request", ")", ":", "return", "True", "return", "d1_gmn", ".", "app", ".", "models", ".", "Permission", ".", "objects", ".", "filter", "(", "sciobj...
Check if one or more subjects are allowed to perform action level on object. If a subject holds permissions for one action level on object, all lower action levels are also allowed. Any included subject that is unknown to this MN is treated as a subject without permissions. Returns: bool ...
[ "Check", "if", "one", "or", "more", "subjects", "are", "allowed", "to", "perform", "action", "level", "on", "object", "." ]
python
train
jtwhite79/pyemu
pyemu/ev.py
https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/ev.py#L425-L471
def G(self, singular_value): """get the parameter solution Matrix at a singular value V_1 * S_1^(_1) * U_1^T Parameters ---------- singular_value : int singular value to calc R at Returns ------- G : pyemu.Matrix parameter sol...
[ "def", "G", "(", "self", ",", "singular_value", ")", ":", "if", "self", ".", "__G", "is", "not", "None", "and", "singular_value", "==", "self", ".", "__G_sv", ":", "return", "self", ".", "__G", "if", "singular_value", "==", "0", ":", "self", ".", "__...
get the parameter solution Matrix at a singular value V_1 * S_1^(_1) * U_1^T Parameters ---------- singular_value : int singular value to calc R at Returns ------- G : pyemu.Matrix parameter solution matrix at singular value
[ "get", "the", "parameter", "solution", "Matrix", "at", "a", "singular", "value", "V_1", "*", "S_1^", "(", "_1", ")", "*", "U_1^T" ]
python
train
econ-ark/HARK
HARK/ConsumptionSaving/ConsIndShockModel.py
https://github.com/econ-ark/HARK/blob/3d184153a189e618a87c9540df1cd12044039cc5/HARK/ConsumptionSaving/ConsIndShockModel.py#L1517-L1536
def unpackcFunc(self): ''' "Unpacks" the consumption functions into their own field for easier access. After the model has been solved, the consumption functions reside in the attribute cFunc of each element of ConsumerType.solution. This method creates a (time varying) attribut...
[ "def", "unpackcFunc", "(", "self", ")", ":", "self", ".", "cFunc", "=", "[", "]", "for", "solution_t", "in", "self", ".", "solution", ":", "self", ".", "cFunc", ".", "append", "(", "solution_t", ".", "cFunc", ")", "self", ".", "addToTimeVary", "(", "...
"Unpacks" the consumption functions into their own field for easier access. After the model has been solved, the consumption functions reside in the attribute cFunc of each element of ConsumerType.solution. This method creates a (time varying) attribute cFunc that contains a list of consumption...
[ "Unpacks", "the", "consumption", "functions", "into", "their", "own", "field", "for", "easier", "access", ".", "After", "the", "model", "has", "been", "solved", "the", "consumption", "functions", "reside", "in", "the", "attribute", "cFunc", "of", "each", "elem...
python
train
databio/pypiper
pypiper/pipeline.py
https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/pipeline.py#L216-L228
def list_flags(self, only_name=False): """ Determine the flag files associated with this pipeline. :param bool only_name: Whether to return only flag file name(s) (True), or full flag file paths (False); default False (paths) :return list[str]: flag files associated with thi...
[ "def", "list_flags", "(", "self", ",", "only_name", "=", "False", ")", ":", "paths", "=", "glob", ".", "glob", "(", "os", ".", "path", ".", "join", "(", "self", ".", "outfolder", ",", "flag_name", "(", "\"*\"", ")", ")", ")", "if", "only_name", ":"...
Determine the flag files associated with this pipeline. :param bool only_name: Whether to return only flag file name(s) (True), or full flag file paths (False); default False (paths) :return list[str]: flag files associated with this pipeline.
[ "Determine", "the", "flag", "files", "associated", "with", "this", "pipeline", "." ]
python
train
jazzband/django-ddp
dddp/migrations/__init__.py
https://github.com/jazzband/django-ddp/blob/1e1954b06fe140346acea43582515991685e4e01/dddp/migrations/__init__.py#L43-L49
def set_default_forwards(app_name, operation, apps, schema_editor): """Set default value for AleaIdField.""" model = apps.get_model(app_name, operation.model_name) for obj_pk in model.objects.values_list('pk', flat=True): model.objects.filter(pk=obj_pk).update(**{ operation.name: get_met...
[ "def", "set_default_forwards", "(", "app_name", ",", "operation", ",", "apps", ",", "schema_editor", ")", ":", "model", "=", "apps", ".", "get_model", "(", "app_name", ",", "operation", ".", "model_name", ")", "for", "obj_pk", "in", "model", ".", "objects", ...
Set default value for AleaIdField.
[ "Set", "default", "value", "for", "AleaIdField", "." ]
python
test
jhermann/rituals
src/rituals/acts/documentation.py
https://github.com/jhermann/rituals/blob/1534f50d81e19bbbe799e2eba0acdefbce047c06/src/rituals/acts/documentation.py#L313-L348
def _to_webdav(self, docs_base, release): """Upload to WebDAV store.""" try: git_path = subprocess.check_output('git remote get-url origin 2>/dev/null', shell=True) except subprocess.CalledProcessError: git_path = '' else: git_path = git_path.decode('a...
[ "def", "_to_webdav", "(", "self", ",", "docs_base", ",", "release", ")", ":", "try", ":", "git_path", "=", "subprocess", ".", "check_output", "(", "'git remote get-url origin 2>/dev/null'", ",", "shell", "=", "True", ")", "except", "subprocess", ".", "CalledProc...
Upload to WebDAV store.
[ "Upload", "to", "WebDAV", "store", "." ]
python
valid
bolt-project/bolt
bolt/utils.py
https://github.com/bolt-project/bolt/blob/9cd7104aa085498da3097b72696184b9d3651c51/bolt/utils.py#L25-L40
def argpack(args): """ Coerce a list of arguments to a tuple. Parameters ---------- args : tuple or nested tuple Pack arguments into a tuple, converting ((,...),) or (,) -> (,) """ if isinstance(args[0], (tuple, list, ndarray)): return tupleize(args[0]) elif isinstance(a...
[ "def", "argpack", "(", "args", ")", ":", "if", "isinstance", "(", "args", "[", "0", "]", ",", "(", "tuple", ",", "list", ",", "ndarray", ")", ")", ":", "return", "tupleize", "(", "args", "[", "0", "]", ")", "elif", "isinstance", "(", "args", "[",...
Coerce a list of arguments to a tuple. Parameters ---------- args : tuple or nested tuple Pack arguments into a tuple, converting ((,...),) or (,) -> (,)
[ "Coerce", "a", "list", "of", "arguments", "to", "a", "tuple", "." ]
python
test
saltstack/salt
salt/modules/win_task.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_task.py#L557-L675
def create_task_from_xml(name, location='\\', xml_text=None, xml_path=None, user_name='System', password=None): r''' Create a task based on XML. Source can be a file or a string of XML. ...
[ "def", "create_task_from_xml", "(", "name", ",", "location", "=", "'\\\\'", ",", "xml_text", "=", "None", ",", "xml_path", "=", "None", ",", "user_name", "=", "'System'", ",", "password", "=", "None", ")", ":", "# Check for existing task", "if", "name", "in"...
r''' Create a task based on XML. Source can be a file or a string of XML. :param str name: The name of the task. This will be displayed in the task scheduler. :param str location: A string value representing the location in which to create the task. Default is '\\' which is the root for th...
[ "r", "Create", "a", "task", "based", "on", "XML", ".", "Source", "can", "be", "a", "file", "or", "a", "string", "of", "XML", "." ]
python
train
proycon/flat
flat/comm.py
https://github.com/proycon/flat/blob/f14eea61edcae8656dadccd9a43481ff7e710ffb/flat/comm.py#L12-L22
def checkversion(version): """Checks foliadocserve version, returns 1 if the document is newer than the library, -1 if it is older, 0 if it is equal""" try: for refversion, responseversion in zip([int(x) for x in REQUIREFOLIADOCSERVE.split('.')], [int(x) for x in version.split('.')]): if res...
[ "def", "checkversion", "(", "version", ")", ":", "try", ":", "for", "refversion", ",", "responseversion", "in", "zip", "(", "[", "int", "(", "x", ")", "for", "x", "in", "REQUIREFOLIADOCSERVE", ".", "split", "(", "'.'", ")", "]", ",", "[", "int", "(",...
Checks foliadocserve version, returns 1 if the document is newer than the library, -1 if it is older, 0 if it is equal
[ "Checks", "foliadocserve", "version", "returns", "1", "if", "the", "document", "is", "newer", "than", "the", "library", "-", "1", "if", "it", "is", "older", "0", "if", "it", "is", "equal" ]
python
train
rmax/scrapy-redis
src/scrapy_redis/dupefilter.py
https://github.com/rmax/scrapy-redis/blob/31c022dd145654cb4ea1429f09852a82afa0a01c/src/scrapy_redis/dupefilter.py#L86-L101
def request_seen(self, request): """Returns True if request was already seen. Parameters ---------- request : scrapy.http.Request Returns ------- bool """ fp = self.request_fingerprint(request) # This returns the number of values added, ...
[ "def", "request_seen", "(", "self", ",", "request", ")", ":", "fp", "=", "self", ".", "request_fingerprint", "(", "request", ")", "# This returns the number of values added, zero if already exists.", "added", "=", "self", ".", "server", ".", "sadd", "(", "self", "...
Returns True if request was already seen. Parameters ---------- request : scrapy.http.Request Returns ------- bool
[ "Returns", "True", "if", "request", "was", "already", "seen", "." ]
python
train
MartinThoma/hwrt
hwrt/train.py
https://github.com/MartinThoma/hwrt/blob/725c21a3d0f5a30b8492cbc184b3688ceb364e1c/hwrt/train.py#L22-L61
def update_if_outdated(folder): """Check if the currently watched instance (model, feature or preprocessing) is outdated and update it eventually. """ folders = [] while os.path.isdir(folder): folders.append(folder) # Get info.yml with open(os.path.join(folder, "info.yml...
[ "def", "update_if_outdated", "(", "folder", ")", ":", "folders", "=", "[", "]", "while", "os", ".", "path", ".", "isdir", "(", "folder", ")", ":", "folders", ".", "append", "(", "folder", ")", "# Get info.yml", "with", "open", "(", "os", ".", "path", ...
Check if the currently watched instance (model, feature or preprocessing) is outdated and update it eventually.
[ "Check", "if", "the", "currently", "watched", "instance", "(", "model", "feature", "or", "preprocessing", ")", "is", "outdated", "and", "update", "it", "eventually", "." ]
python
train
sdss/tree
python/tree/tree.py
https://github.com/sdss/tree/blob/f61fe0876c138ccb61874912d4b8590dadfa835c/python/tree/tree.py#L75-L103
def set_roots(self, uproot_with=None): ''' Set the roots of the tree in the os environment Parameters: uproot_with (str): A new TREE_DIR path used to override an existing TREE_DIR environment variable ''' # Check for TREE_DIR self.treedir = os.envir...
[ "def", "set_roots", "(", "self", ",", "uproot_with", "=", "None", ")", ":", "# Check for TREE_DIR", "self", ".", "treedir", "=", "os", ".", "environ", ".", "get", "(", "'TREE_DIR'", ",", "None", ")", "if", "not", "uproot_with", "else", "uproot_with", "if",...
Set the roots of the tree in the os environment Parameters: uproot_with (str): A new TREE_DIR path used to override an existing TREE_DIR environment variable
[ "Set", "the", "roots", "of", "the", "tree", "in", "the", "os", "environment" ]
python
train
dixudx/rtcclient
rtcclient/client.py
https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/client.py#L332-L374
def getTeamArea(self, teamarea_name, projectarea_id=None, projectarea_name=None, archived=False, returned_properties=None): """Get :class:`rtcclient.models.TeamArea` object by its name If `projectarea_id` or `projectarea_name` is specified, then the match...
[ "def", "getTeamArea", "(", "self", ",", "teamarea_name", ",", "projectarea_id", "=", "None", ",", "projectarea_name", "=", "None", ",", "archived", "=", "False", ",", "returned_properties", "=", "None", ")", ":", "if", "not", "isinstance", "(", "teamarea_name"...
Get :class:`rtcclient.models.TeamArea` object by its name If `projectarea_id` or `projectarea_name` is specified, then the matched :class:`rtcclient.models.TeamArea` in that project area will be returned. Otherwise, only return the first found :class:`rtcclient.models.TeamArea` ...
[ "Get", ":", "class", ":", "rtcclient", ".", "models", ".", "TeamArea", "object", "by", "its", "name" ]
python
train
adaptive-learning/proso-apps
proso_user/views_classes.py
https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_user/views_classes.py#L26-L63
def create_class(request): """Create new class POST parameters (JSON): name: Human readable name of class code (optional): unique code of class used for joining to class """ if request.method == 'GET': return render(request, 'classes_create.html', {}, he...
[ "def", "create_class", "(", "request", ")", ":", "if", "request", ".", "method", "==", "'GET'", ":", "return", "render", "(", "request", ",", "'classes_create.html'", ",", "{", "}", ",", "help_text", "=", "create_class", ".", "__doc__", ")", "if", "request...
Create new class POST parameters (JSON): name: Human readable name of class code (optional): unique code of class used for joining to class
[ "Create", "new", "class" ]
python
train
secdev/scapy
scapy/modules/krack/automaton.py
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/modules/krack/automaton.py#L219-L232
def build_ap_info_pkt(self, layer_cls, dest): """Build a packet with info describing the current AP For beacon / proberesp use """ return RadioTap() \ / Dot11(addr1=dest, addr2=self.mac, addr3=self.mac) \ / layer_cls(timestamp=0, beacon_interval=100, ...
[ "def", "build_ap_info_pkt", "(", "self", ",", "layer_cls", ",", "dest", ")", ":", "return", "RadioTap", "(", ")", "/", "Dot11", "(", "addr1", "=", "dest", ",", "addr2", "=", "self", ".", "mac", ",", "addr3", "=", "self", ".", "mac", ")", "/", "laye...
Build a packet with info describing the current AP For beacon / proberesp use
[ "Build", "a", "packet", "with", "info", "describing", "the", "current", "AP", "For", "beacon", "/", "proberesp", "use" ]
python
train
tanghaibao/jcvi
jcvi/apps/align.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/apps/align.py#L44-L59
def run_vecscreen(infile=None, outfile=None, db="UniVec_Core", pctid=None, hitlen=None): """ BLASTN parameters reference: http://www.ncbi.nlm.nih.gov/VecScreen/VecScreen_docs.html """ db = get_abs_path(db) nin = db + ".nin" run_formatdb(infile=db, outfile=nin) cmd = "blastn" ...
[ "def", "run_vecscreen", "(", "infile", "=", "None", ",", "outfile", "=", "None", ",", "db", "=", "\"UniVec_Core\"", ",", "pctid", "=", "None", ",", "hitlen", "=", "None", ")", ":", "db", "=", "get_abs_path", "(", "db", ")", "nin", "=", "db", "+", "...
BLASTN parameters reference: http://www.ncbi.nlm.nih.gov/VecScreen/VecScreen_docs.html
[ "BLASTN", "parameters", "reference", ":", "http", ":", "//", "www", ".", "ncbi", ".", "nlm", ".", "nih", ".", "gov", "/", "VecScreen", "/", "VecScreen_docs", ".", "html" ]
python
train
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L806-L809
def list_security_groups(self, retrieve_all=True, **_params): """Fetches a list of all security groups for a project.""" return self.list('security_groups', self.security_groups_path, retrieve_all, **_params)
[ "def", "list_security_groups", "(", "self", ",", "retrieve_all", "=", "True", ",", "*", "*", "_params", ")", ":", "return", "self", ".", "list", "(", "'security_groups'", ",", "self", ".", "security_groups_path", ",", "retrieve_all", ",", "*", "*", "_params"...
Fetches a list of all security groups for a project.
[ "Fetches", "a", "list", "of", "all", "security", "groups", "for", "a", "project", "." ]
python
train
kblomqvist/yasha
yasha/cmsis.py
https://github.com/kblomqvist/yasha/blob/aebda08f45458611a59497fb7505f0881b73fbd5/yasha/cmsis.py#L240-L268
def fold(self): """Folds the Register in accordance with it's dimensions. If the register is dimensionless, the returned list just contains the register itself unchanged. In case the register name looks like a C array, the returned list contains the register itself, where nothin...
[ "def", "fold", "(", "self", ")", ":", "if", "self", ".", "dim", "is", "None", ":", "return", "[", "self", "]", "if", "self", ".", "name", ".", "endswith", "(", "\"[%s]\"", ")", ":", "# C array like", "self", ".", "name", "=", "self", ".", "name", ...
Folds the Register in accordance with it's dimensions. If the register is dimensionless, the returned list just contains the register itself unchanged. In case the register name looks like a C array, the returned list contains the register itself, where nothing else than the '%s' placeh...
[ "Folds", "the", "Register", "in", "accordance", "with", "it", "s", "dimensions", "." ]
python
train
blockstack/blockstack-core
blockstack/lib/nameset/virtualchain_hooks.py
https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/virtualchain_hooks.py#L143-L159
def get_db_state(working_dir): """ Callback to the virtual chain state engine. Get a *read-only* handle to our state engine implementation (i.e. our name database). Note that in this implementation, the database handle returned will only support read-only operations by default. Attempts to ...
[ "def", "get_db_state", "(", "working_dir", ")", ":", "impl", "=", "sys", ".", "modules", "[", "__name__", "]", "db_inst", "=", "BlockstackDB", ".", "get_readonly_instance", "(", "working_dir", ")", "assert", "db_inst", ",", "'Failed to instantiate database handle'",...
Callback to the virtual chain state engine. Get a *read-only* handle to our state engine implementation (i.e. our name database). Note that in this implementation, the database handle returned will only support read-only operations by default. Attempts to save state with the handle will lead to pro...
[ "Callback", "to", "the", "virtual", "chain", "state", "engine", ".", "Get", "a", "*", "read", "-", "only", "*", "handle", "to", "our", "state", "engine", "implementation", "(", "i", ".", "e", ".", "our", "name", "database", ")", "." ]
python
train
franciscogarate/pyliferisk
pyliferisk/__init__.py
https://github.com/franciscogarate/pyliferisk/blob/8d906bed04df1ba00fa1cacc6f31030ce5ab6233/pyliferisk/__init__.py#L229-L238
def ex(mt, x): """ ex : Returns the curtate expectation of life. Life expectancy """ sum1 = 0 for j in mt.lx[x + 1:-1]: sum1 += j #print sum1 try: return sum1 / mt.lx[x] + 0.5 except: return 0
[ "def", "ex", "(", "mt", ",", "x", ")", ":", "sum1", "=", "0", "for", "j", "in", "mt", ".", "lx", "[", "x", "+", "1", ":", "-", "1", "]", ":", "sum1", "+=", "j", "#print sum1", "try", ":", "return", "sum1", "/", "mt", ".", "lx", "[", "x", ...
ex : Returns the curtate expectation of life. Life expectancy
[ "ex", ":", "Returns", "the", "curtate", "expectation", "of", "life", ".", "Life", "expectancy" ]
python
train
Kane610/axis
axis/configuration.py
https://github.com/Kane610/axis/blob/b2b44ce595c7b722b5e13eabcab7b91f048e1808/axis/configuration.py#L28-L30
def url(self): """Represent device base url.""" return URL.format(http=self.web_proto, host=self.host, port=self.port)
[ "def", "url", "(", "self", ")", ":", "return", "URL", ".", "format", "(", "http", "=", "self", ".", "web_proto", ",", "host", "=", "self", ".", "host", ",", "port", "=", "self", ".", "port", ")" ]
Represent device base url.
[ "Represent", "device", "base", "url", "." ]
python
train
Diaoul/pywunderground
pywunderground/core.py
https://github.com/Diaoul/pywunderground/blob/d0fcb7c573e1c8285f6fc3930c6bddab820a9de7/pywunderground/core.py#L79-L88
def _unicode(string): """Try to convert a string to unicode using different encodings""" for encoding in ['utf-8', 'latin1']: try: result = unicode(string, encoding) return result except UnicodeDecodeError: pass result = unicode(string, 'utf-8', 'replace')...
[ "def", "_unicode", "(", "string", ")", ":", "for", "encoding", "in", "[", "'utf-8'", ",", "'latin1'", "]", ":", "try", ":", "result", "=", "unicode", "(", "string", ",", "encoding", ")", "return", "result", "except", "UnicodeDecodeError", ":", "pass", "r...
Try to convert a string to unicode using different encodings
[ "Try", "to", "convert", "a", "string", "to", "unicode", "using", "different", "encodings" ]
python
valid
bjodah/chempy
chempy/util/graph.py
https://github.com/bjodah/chempy/blob/bd62c3e1f7cb797782471203acd3bcf23b21c47e/chempy/util/graph.py#L92-L152
def rsys2graph(rsys, fname, output_dir=None, prog=None, save=False, **kwargs): """ Convenience function to call `rsys2dot` and write output to file and render the graph Parameters ---------- rsys : ReactionSystem fname : str filename output_dir : str (optional) path to d...
[ "def", "rsys2graph", "(", "rsys", ",", "fname", ",", "output_dir", "=", "None", ",", "prog", "=", "None", ",", "save", "=", "False", ",", "*", "*", "kwargs", ")", ":", "lines", "=", "rsys2dot", "(", "rsys", ",", "*", "*", "kwargs", ")", "created_te...
Convenience function to call `rsys2dot` and write output to file and render the graph Parameters ---------- rsys : ReactionSystem fname : str filename output_dir : str (optional) path to directory (default: temporary directory) prog : str (optional) default: 'dot' ...
[ "Convenience", "function", "to", "call", "rsys2dot", "and", "write", "output", "to", "file", "and", "render", "the", "graph" ]
python
train
ModisWorks/modis
modis/discord_modis/modules/music/_musicplayer.py
https://github.com/ModisWorks/modis/blob/1f1225c9841835ec1d1831fc196306527567db8b/modis/discord_modis/modules/music/_musicplayer.py#L1250-L1279
async def vafter(self): """Function that is called after a song finishes playing""" self.logger.debug("Finished playing a song") if self.state != 'ready': self.logger.debug("Returning because player is in state {}".format(self.state)) return self.pause_time = Non...
[ "async", "def", "vafter", "(", "self", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"Finished playing a song\"", ")", "if", "self", ".", "state", "!=", "'ready'", ":", "self", ".", "logger", ".", "debug", "(", "\"Returning because player is in state {...
Function that is called after a song finishes playing
[ "Function", "that", "is", "called", "after", "a", "song", "finishes", "playing" ]
python
train
shmuelamar/cbox
cbox/cli.py
https://github.com/shmuelamar/cbox/blob/2d0cda5b3f61a55e530251430bf3d460dcd3732e/cbox/cli.py#L11-L57
def stream(input_type='lines', output_type=None, worker_type='simple', max_workers=1, workers_window=100): """wrapper for processing data from input stream into output into output stream while passing each data piece into the function. function should take at least one argument (an input stream p...
[ "def", "stream", "(", "input_type", "=", "'lines'", ",", "output_type", "=", "None", ",", "worker_type", "=", "'simple'", ",", "max_workers", "=", "1", ",", "workers_window", "=", "100", ")", ":", "def", "inner", "(", "f", ")", ":", "@", "wraps", "(", ...
wrapper for processing data from input stream into output into output stream while passing each data piece into the function. function should take at least one argument (an input stream piece) and return an `str` to be written into the output stream. Example Usage: >>> import cbox >>> ...
[ "wrapper", "for", "processing", "data", "from", "input", "stream", "into", "output", "into", "output", "stream", "while", "passing", "each", "data", "piece", "into", "the", "function", ".", "function", "should", "take", "at", "least", "one", "argument", "(", ...
python
train
rdo-management/python-rdomanager-oscplugin
rdomanager_oscplugin/plugin.py
https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/plugin.py#L72-L93
def baremetal(self): """Returns an baremetal service client""" # TODO(d0ugal): When the ironicclient has it's own OSC plugin, the # following client handling code should be removed in favor of the # upstream version. if self._baremetal is not None: return self._bare...
[ "def", "baremetal", "(", "self", ")", ":", "# TODO(d0ugal): When the ironicclient has it's own OSC plugin, the", "# following client handling code should be removed in favor of the", "# upstream version.", "if", "self", ".", "_baremetal", "is", "not", "None", ":", "return", "self...
Returns an baremetal service client
[ "Returns", "an", "baremetal", "service", "client" ]
python
train
CogSciUOS/StudDP
studdp/model.py
https://github.com/CogSciUOS/StudDP/blob/e953aea51766438f2901c9e87f5b7b9e5bb892f5/studdp/model.py#L90-L100
def deep_documents(self): """ list of all documents find in subtrees of this node """ tree = [] for entry in self.contents: if isinstance(entry, Document): tree.append(entry) else: tree += entry.deep_documents return...
[ "def", "deep_documents", "(", "self", ")", ":", "tree", "=", "[", "]", "for", "entry", "in", "self", ".", "contents", ":", "if", "isinstance", "(", "entry", ",", "Document", ")", ":", "tree", ".", "append", "(", "entry", ")", "else", ":", "tree", "...
list of all documents find in subtrees of this node
[ "list", "of", "all", "documents", "find", "in", "subtrees", "of", "this", "node" ]
python
train
noahbenson/neuropythy
neuropythy/io/core.py
https://github.com/noahbenson/neuropythy/blob/b588889f6db36ddb9602ae4a72c1c0d3f41586b2/neuropythy/io/core.py#L134-L165
def guess_export_format(filename, data, **kwargs): ''' guess_export_format(filename, data) attempts to guess the export file format for the given filename and data (to be exported); it does this guessing by looking at the file extension and using registered sniff-tests from exporters. It will not a...
[ "def", "guess_export_format", "(", "filename", ",", "data", ",", "*", "*", "kwargs", ")", ":", "# First try file endings", "(", "_", ",", "filename", ")", "=", "os", ".", "path", ".", "split", "(", "filename", ")", "fnm", "=", "filename", ".", "lower", ...
guess_export_format(filename, data) attempts to guess the export file format for the given filename and data (to be exported); it does this guessing by looking at the file extension and using registered sniff-tests from exporters. It will not attempt to save the file, so if the extension of the filen...
[ "guess_export_format", "(", "filename", "data", ")", "attempts", "to", "guess", "the", "export", "file", "format", "for", "the", "given", "filename", "and", "data", "(", "to", "be", "exported", ")", ";", "it", "does", "this", "guessing", "by", "looking", "...
python
train
peterbrittain/asciimatics
asciimatics/paths.py
https://github.com/peterbrittain/asciimatics/blob/f471427d7786ce2d5f1eeb2dae0e67d19e46e085/asciimatics/paths.py#L113-L121
def _add_step(self, pos): """ Add a step to the end of the current recorded path. :param pos: The position tuple (x, y) to add to the list. """ self._steps.append(pos) self._rec_x = pos[0] self._rec_y = pos[1]
[ "def", "_add_step", "(", "self", ",", "pos", ")", ":", "self", ".", "_steps", ".", "append", "(", "pos", ")", "self", ".", "_rec_x", "=", "pos", "[", "0", "]", "self", ".", "_rec_y", "=", "pos", "[", "1", "]" ]
Add a step to the end of the current recorded path. :param pos: The position tuple (x, y) to add to the list.
[ "Add", "a", "step", "to", "the", "end", "of", "the", "current", "recorded", "path", "." ]
python
train
wavefrontHQ/python-client
wavefront_api_client/api/notificant_api.py
https://github.com/wavefrontHQ/python-client/blob/b0f1046a8f68c2c7d69e395f7167241f224c738a/wavefront_api_client/api/notificant_api.py#L511-L532
def update_notificant(self, id, **kwargs): # noqa: E501 """Update a specific notification target # noqa: E501 # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.update_notifi...
[ "def", "update_notificant", "(", "self", ",", "id", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'async_req'", ")", ":", "return", "self", ".", "update_not...
Update a specific notification target # noqa: E501 # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.update_notificant(id, async_req=True) >>> result = thread.get() ...
[ "Update", "a", "specific", "notification", "target", "#", "noqa", ":", "E501" ]
python
train
NarrativeScience/lsi
src/lsi/utils/stream.py
https://github.com/NarrativeScience/lsi/blob/7d901b03fdb1a34ef795e5412bfe9685d948e32d/src/lsi/utils/stream.py#L86-L108
def stream_command_dicts(commands, parallel=False): """ Takes a list of dictionaries with keys corresponding to ``stream_command`` arguments, and runs all concurrently. :param commands: A list of dictionaries, the keys of which should line up with the arguments to ``stream_command`...
[ "def", "stream_command_dicts", "(", "commands", ",", "parallel", "=", "False", ")", ":", "if", "parallel", "is", "True", ":", "threads", "=", "[", "]", "for", "command", "in", "commands", ":", "target", "=", "lambda", ":", "stream_command", "(", "*", "*"...
Takes a list of dictionaries with keys corresponding to ``stream_command`` arguments, and runs all concurrently. :param commands: A list of dictionaries, the keys of which should line up with the arguments to ``stream_command`` function. :type commands: ``list`` of ``dict`` :param ...
[ "Takes", "a", "list", "of", "dictionaries", "with", "keys", "corresponding", "to", "stream_command", "arguments", "and", "runs", "all", "concurrently", "." ]
python
test
Hironsan/HateSonar
hatesonar/crawler/twitter.py
https://github.com/Hironsan/HateSonar/blob/39ede274119bb128ac32ba3e6d7d58f6104d2354/hatesonar/crawler/twitter.py#L9-L20
def load_keys(): """Loads Twitter keys. Returns: tuple: consumer_key, consumer_secret, access_token, access_token_secret """ consumer_key = os.environ.get('CONSUMER_KEY') consumer_secret = os.environ.get('CONSUMER_SECRET') access_token = os.environ.get('ACCESS_TOKEN') access_token_s...
[ "def", "load_keys", "(", ")", ":", "consumer_key", "=", "os", ".", "environ", ".", "get", "(", "'CONSUMER_KEY'", ")", "consumer_secret", "=", "os", ".", "environ", ".", "get", "(", "'CONSUMER_SECRET'", ")", "access_token", "=", "os", ".", "environ", ".", ...
Loads Twitter keys. Returns: tuple: consumer_key, consumer_secret, access_token, access_token_secret
[ "Loads", "Twitter", "keys", "." ]
python
train
xaptum/xtt-python
xtt/certificates.py
https://github.com/xaptum/xtt-python/blob/23ee469488d710d730314bec1136c4dd7ac2cd5c/xtt/certificates.py#L35-L57
def generate_ecdsap256_server_certificate(server_id, server_pub_key, expiry, root_id, root_priv_key): """ Creates a new server certificate signed by the provided root. :param Identity server_id: the identity for the certificate :param ECDSAP256PublicKey server_pu...
[ "def", "generate_ecdsap256_server_certificate", "(", "server_id", ",", "server_pub_key", ",", "expiry", ",", "root_id", ",", "root_priv_key", ")", ":", "cert", "=", "ECDSAP256ServerCertificate", "(", ")", "rc", "=", "_lib", ".", "xtt_generate_server_certificate_ecdsap25...
Creates a new server certificate signed by the provided root. :param Identity server_id: the identity for the certificate :param ECDSAP256PublicKey server_pub_key: the public key for the certificate :param CertificateExpiry expiry: the expiry date for the certificate :param CertificateRootId root_id: t...
[ "Creates", "a", "new", "server", "certificate", "signed", "by", "the", "provided", "root", "." ]
python
train
sdispater/cachy
cachy/stores/file_store.py
https://github.com/sdispater/cachy/blob/ee4b044d6aafa80125730a00b1f679a7bd852b8a/cachy/stores/file_store.py#L114-L132
def increment(self, key, value=1): """ Increment the value of an item in the cache. :param key: The cache key :type key: str :param value: The increment value :type value: int :rtype: int or bool """ raw = self._get_payload(key) integer...
[ "def", "increment", "(", "self", ",", "key", ",", "value", "=", "1", ")", ":", "raw", "=", "self", ".", "_get_payload", "(", "key", ")", "integer", "=", "int", "(", "raw", "[", "'data'", "]", ")", "+", "value", "self", ".", "put", "(", "key", "...
Increment the value of an item in the cache. :param key: The cache key :type key: str :param value: The increment value :type value: int :rtype: int or bool
[ "Increment", "the", "value", "of", "an", "item", "in", "the", "cache", "." ]
python
train
tensorflow/datasets
tensorflow_datasets/core/download/resource.py
https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/download/resource.py#L273-L278
def exists_locally(cls, path): """Returns whether the resource exists locally, at `resource.path`.""" # If INFO file doesn't exist, consider resource does NOT exist, as it would # prevent guessing the `extract_method`. return (tf.io.gfile.exists(path) and tf.io.gfile.exists(_get_info_path(pa...
[ "def", "exists_locally", "(", "cls", ",", "path", ")", ":", "# If INFO file doesn't exist, consider resource does NOT exist, as it would", "# prevent guessing the `extract_method`.", "return", "(", "tf", ".", "io", ".", "gfile", ".", "exists", "(", "path", ")", "and", "...
Returns whether the resource exists locally, at `resource.path`.
[ "Returns", "whether", "the", "resource", "exists", "locally", "at", "resource", ".", "path", "." ]
python
train
DataDog/integrations-core
tokumx/datadog_checks/tokumx/vendor/pymongo/auth.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/auth.py#L190-L251
def _authenticate_scram_sha1(credentials, sock_info): """Authenticate using SCRAM-SHA-1.""" username = credentials.username password = credentials.password source = credentials.source # Make local _hmac = hmac.HMAC _sha1 = sha1 user = username.encode("utf-8").replace(b"=", b"=3D").repl...
[ "def", "_authenticate_scram_sha1", "(", "credentials", ",", "sock_info", ")", ":", "username", "=", "credentials", ".", "username", "password", "=", "credentials", ".", "password", "source", "=", "credentials", ".", "source", "# Make local", "_hmac", "=", "hmac", ...
Authenticate using SCRAM-SHA-1.
[ "Authenticate", "using", "SCRAM", "-", "SHA", "-", "1", "." ]
python
train
ANTsX/ANTsPy
ants/core/ants_image_io.py
https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/core/ants_image_io.py#L76-L106
def from_numpy(data, origin=None, spacing=None, direction=None, has_components=False, is_rgb=False): """ Create an ANTsImage object from a numpy array ANTsR function: `as.antsImage` Arguments --------- data : ndarray image data array origin : tuple/list image origin s...
[ "def", "from_numpy", "(", "data", ",", "origin", "=", "None", ",", "spacing", "=", "None", ",", "direction", "=", "None", ",", "has_components", "=", "False", ",", "is_rgb", "=", "False", ")", ":", "data", "=", "data", ".", "astype", "(", "'float32'", ...
Create an ANTsImage object from a numpy array ANTsR function: `as.antsImage` Arguments --------- data : ndarray image data array origin : tuple/list image origin spacing : tuple/list image spacing direction : list/ndarray image direction has_componen...
[ "Create", "an", "ANTsImage", "object", "from", "a", "numpy", "array" ]
python
train
saltstack/salt
salt/spm/pkgfiles/local.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/spm/pkgfiles/local.py#L103-L169
def install_file(package, formula_tar, member, formula_def, conn=None): ''' Install a single file to the file system ''' if member.name == package: return False if conn is None: conn = init() node_type = six.text_type(__opts__.get('spm_node_type')) out_path = conn['formula...
[ "def", "install_file", "(", "package", ",", "formula_tar", ",", "member", ",", "formula_def", ",", "conn", "=", "None", ")", ":", "if", "member", ".", "name", "==", "package", ":", "return", "False", "if", "conn", "is", "None", ":", "conn", "=", "init"...
Install a single file to the file system
[ "Install", "a", "single", "file", "to", "the", "file", "system" ]
python
train
krischer/mtspec
mtspec/multitaper.py
https://github.com/krischer/mtspec/blob/06561b6370f13fcb2e731470ba0f7314f4b2362d/mtspec/multitaper.py#L775-L784
def empty(self, shape, complex=False): """ A wrapper around np.empty which automatically sets the correct type and returns an empty array. :param shape: The shape of the array in np.empty format """ if complex: return np.empty(shape, dtype=self.complex, order...
[ "def", "empty", "(", "self", ",", "shape", ",", "complex", "=", "False", ")", ":", "if", "complex", ":", "return", "np", ".", "empty", "(", "shape", ",", "dtype", "=", "self", ".", "complex", ",", "order", "=", "self", ".", "order", ")", "return", ...
A wrapper around np.empty which automatically sets the correct type and returns an empty array. :param shape: The shape of the array in np.empty format
[ "A", "wrapper", "around", "np", ".", "empty", "which", "automatically", "sets", "the", "correct", "type", "and", "returns", "an", "empty", "array", "." ]
python
train
pycontribs/pyrax
pyrax/object_storage.py
https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/object_storage.py#L868-L879
def fetch_cdn_data(self, container): """ Returns a dict containing the CDN information for the specified container. If the container is not CDN-enabled, returns an empty dict. """ name = utils.get_name(container) uri = "/%s" % name try: resp, resp_body...
[ "def", "fetch_cdn_data", "(", "self", ",", "container", ")", ":", "name", "=", "utils", ".", "get_name", "(", "container", ")", "uri", "=", "\"/%s\"", "%", "name", "try", ":", "resp", ",", "resp_body", "=", "self", ".", "api", ".", "cdn_request", "(", ...
Returns a dict containing the CDN information for the specified container. If the container is not CDN-enabled, returns an empty dict.
[ "Returns", "a", "dict", "containing", "the", "CDN", "information", "for", "the", "specified", "container", ".", "If", "the", "container", "is", "not", "CDN", "-", "enabled", "returns", "an", "empty", "dict", "." ]
python
train
rosenbrockc/fortpy
fortpy/parsers/docstring.py
https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/parsers/docstring.py#L488-L531
def parsexml(self, xmlstring, modules, source=None): """Parses the docstrings out of the specified xml file. :arg source: the path to the file from which the XML string was extracted. """ result = {} from fortpy.utility import XML_fromstring xmlroot = XML_fromstring(xml...
[ "def", "parsexml", "(", "self", ",", "xmlstring", ",", "modules", ",", "source", "=", "None", ")", ":", "result", "=", "{", "}", "from", "fortpy", ".", "utility", "import", "XML_fromstring", "xmlroot", "=", "XML_fromstring", "(", "xmlstring", ",", "source"...
Parses the docstrings out of the specified xml file. :arg source: the path to the file from which the XML string was extracted.
[ "Parses", "the", "docstrings", "out", "of", "the", "specified", "xml", "file", "." ]
python
train
davenquinn/Attitude
attitude/stereonet.py
https://github.com/davenquinn/Attitude/blob/2ce97b9aba0aa5deedc6617c2315e07e6396d240/attitude/stereonet.py#L13-L23
def ellipse(n=1000, adaptive=False): """ Get a parameterized set of vectors defining ellipse for a major and minor axis length. Resulting vector bundle has major axes along axes given. """ u = N.linspace(0,2*N.pi,n) # Get a bundle of vectors defining # a full rotation around the unit...
[ "def", "ellipse", "(", "n", "=", "1000", ",", "adaptive", "=", "False", ")", ":", "u", "=", "N", ".", "linspace", "(", "0", ",", "2", "*", "N", ".", "pi", ",", "n", ")", "# Get a bundle of vectors defining", "# a full rotation around the unit circle", "ret...
Get a parameterized set of vectors defining ellipse for a major and minor axis length. Resulting vector bundle has major axes along axes given.
[ "Get", "a", "parameterized", "set", "of", "vectors", "defining", "ellipse", "for", "a", "major", "and", "minor", "axis", "length", ".", "Resulting", "vector", "bundle", "has", "major", "axes", "along", "axes", "given", "." ]
python
train
apple/turicreate
deps/src/boost_1_68_0/libs/predef/tools/ci/build_log.py
https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/libs/predef/tools/ci/build_log.py#L85-L103
def add_input(self, input): ''' Add a single build XML output file to our data. ''' events = xml.dom.pulldom.parse(input) context = [] for (event,node) in events: if event == xml.dom.pulldom.START_ELEMENT: context.append(node) i...
[ "def", "add_input", "(", "self", ",", "input", ")", ":", "events", "=", "xml", ".", "dom", ".", "pulldom", ".", "parse", "(", "input", ")", "context", "=", "[", "]", "for", "(", "event", ",", "node", ")", "in", "events", ":", "if", "event", "==",...
Add a single build XML output file to our data.
[ "Add", "a", "single", "build", "XML", "output", "file", "to", "our", "data", "." ]
python
train
ethereum/py-evm
eth/vm/logic/comparison.py
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/vm/logic/comparison.py#L39-L53
def slt(computation: BaseComputation) -> None: """ Signed Lesser Comparison """ left, right = map( unsigned_to_signed, computation.stack_pop(num_items=2, type_hint=constants.UINT256), ) if left < right: result = 1 else: result = 0 computation.stack_push(...
[ "def", "slt", "(", "computation", ":", "BaseComputation", ")", "->", "None", ":", "left", ",", "right", "=", "map", "(", "unsigned_to_signed", ",", "computation", ".", "stack_pop", "(", "num_items", "=", "2", ",", "type_hint", "=", "constants", ".", "UINT2...
Signed Lesser Comparison
[ "Signed", "Lesser", "Comparison" ]
python
train
liampauling/betfair
betfairlightweight/baseclient.py
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/baseclient.py#L126-L156
def cert(self): """ The betfair certificates, by default it looks for the certificates in /certs/. :return: Path of cert files :rtype: str """ if self.cert_files is not None: return self.cert_files certs = self.certs or '/certs/' ssl_...
[ "def", "cert", "(", "self", ")", ":", "if", "self", ".", "cert_files", "is", "not", "None", ":", "return", "self", ".", "cert_files", "certs", "=", "self", ".", "certs", "or", "'/certs/'", "ssl_path", "=", "os", ".", "path", ".", "join", "(", "os", ...
The betfair certificates, by default it looks for the certificates in /certs/. :return: Path of cert files :rtype: str
[ "The", "betfair", "certificates", "by", "default", "it", "looks", "for", "the", "certificates", "in", "/", "certs", "/", "." ]
python
train
HDI-Project/MLPrimitives
mlprimitives/custom/timeseries_anomalies.py
https://github.com/HDI-Project/MLPrimitives/blob/bf415f9f751724ff545a1156ddfd7524e320f469/mlprimitives/custom/timeseries_anomalies.py#L119-L140
def find_sequences(errors, epsilon): """Find sequences of values that are above epsilon. This is done following this steps: * create a boolean mask that indicates which value are above epsilon. * shift this mask by one place, filing the empty gap with a False * compare the shifted mask...
[ "def", "find_sequences", "(", "errors", ",", "epsilon", ")", ":", "above", "=", "pd", ".", "Series", "(", "errors", ">", "epsilon", ")", "shift", "=", "above", ".", "shift", "(", "1", ")", ".", "fillna", "(", "False", ")", "change", "=", "above", "...
Find sequences of values that are above epsilon. This is done following this steps: * create a boolean mask that indicates which value are above epsilon. * shift this mask by one place, filing the empty gap with a False * compare the shifted mask with the original one to see if there are c...
[ "Find", "sequences", "of", "values", "that", "are", "above", "epsilon", "." ]
python
train
edx/edx-enterprise
enterprise/management/commands/assign_enterprise_user_roles.py
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/management/commands/assign_enterprise_user_roles.py#L113-L118
def _get_enterprise_enrollment_api_admin_users_batch(self, start, end): # pylint: disable=invalid-name """ Returns a batched queryset of User objects. """ LOGGER.info('Fetching new batch of enterprise enrollment admin users from indexes: %s to %s', start, end) return User.obj...
[ "def", "_get_enterprise_enrollment_api_admin_users_batch", "(", "self", ",", "start", ",", "end", ")", ":", "# pylint: disable=invalid-name", "LOGGER", ".", "info", "(", "'Fetching new batch of enterprise enrollment admin users from indexes: %s to %s'", ",", "start", ",", "end"...
Returns a batched queryset of User objects.
[ "Returns", "a", "batched", "queryset", "of", "User", "objects", "." ]
python
valid
burnash/gspread
gspread/utils.py
https://github.com/burnash/gspread/blob/0e8debe208095aeed3e3e7136c2fa5cd74090946/gspread/utils.py#L135-L162
def a1_to_rowcol(label): """Translates a cell's address in A1 notation to a tuple of integers. :param label: A cell label in A1 notation, e.g. 'B1'. Letter case is ignored. :type label: str :returns: a tuple containing `row` and `column` numbers. Both indexed from 1 (on...
[ "def", "a1_to_rowcol", "(", "label", ")", ":", "m", "=", "CELL_ADDR_RE", ".", "match", "(", "label", ")", "if", "m", ":", "column_label", "=", "m", ".", "group", "(", "1", ")", ".", "upper", "(", ")", "row", "=", "int", "(", "m", ".", "group", ...
Translates a cell's address in A1 notation to a tuple of integers. :param label: A cell label in A1 notation, e.g. 'B1'. Letter case is ignored. :type label: str :returns: a tuple containing `row` and `column` numbers. Both indexed from 1 (one). Example: >>> a1_to...
[ "Translates", "a", "cell", "s", "address", "in", "A1", "notation", "to", "a", "tuple", "of", "integers", "." ]
python
train
common-workflow-language/cwltool
cwltool/factory.py
https://github.com/common-workflow-language/cwltool/blob/cb81b22abc52838823da9945f04d06739ab32fda/cwltool/factory.py#L56-L61
def make(self, cwl): """Instantiate a CWL object from a CWl document.""" load = load_tool.load_tool(cwl, self.loading_context) if isinstance(load, int): raise Exception("Error loading tool") return Callable(load, self)
[ "def", "make", "(", "self", ",", "cwl", ")", ":", "load", "=", "load_tool", ".", "load_tool", "(", "cwl", ",", "self", ".", "loading_context", ")", "if", "isinstance", "(", "load", ",", "int", ")", ":", "raise", "Exception", "(", "\"Error loading tool\""...
Instantiate a CWL object from a CWl document.
[ "Instantiate", "a", "CWL", "object", "from", "a", "CWl", "document", "." ]
python
train
jic-dtool/dtoolcore
dtoolcore/__init__.py
https://github.com/jic-dtool/dtoolcore/blob/eeb9a924dc8fcf543340653748a7877be1f98e0f/dtoolcore/__init__.py#L366-L371
def _manifest(self): """Return manifest content.""" if self._manifest_cache is None: self._manifest_cache = self._storage_broker.get_manifest() return self._manifest_cache
[ "def", "_manifest", "(", "self", ")", ":", "if", "self", ".", "_manifest_cache", "is", "None", ":", "self", ".", "_manifest_cache", "=", "self", ".", "_storage_broker", ".", "get_manifest", "(", ")", "return", "self", ".", "_manifest_cache" ]
Return manifest content.
[ "Return", "manifest", "content", "." ]
python
train
pavlin-policar/openTSNE
openTSNE/tsne.py
https://github.com/pavlin-policar/openTSNE/blob/28513a0d669f2f20e7b971c0c6373dc375f72771/openTSNE/tsne.py#L691-L751
def prepare_partial(self, X, initialization="median", k=25, **affinity_params): """Prepare a partial embedding which can be optimized. Parameters ---------- X: np.ndarray The data matrix to be added to the existing embedding. initialization: Union[np.ndarray, str] ...
[ "def", "prepare_partial", "(", "self", ",", "X", ",", "initialization", "=", "\"median\"", ",", "k", "=", "25", ",", "*", "*", "affinity_params", ")", ":", "P", ",", "neighbors", ",", "distances", "=", "self", ".", "affinities", ".", "to_new", "(", "X"...
Prepare a partial embedding which can be optimized. Parameters ---------- X: np.ndarray The data matrix to be added to the existing embedding. initialization: Union[np.ndarray, str] The initial point positions to be used in the embedding space. Can b...
[ "Prepare", "a", "partial", "embedding", "which", "can", "be", "optimized", "." ]
python
train
pyviz/holoviews
holoviews/plotting/plotly/util.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/plotting/plotly/util.py#L285-L379
def _offset_subplot_ids(fig, offsets): """ Apply offsets to the subplot id numbers in a figure. Note: This function mutates the input figure dict Note: This function assumes that the normalize_subplot_ids function has already been run on the figure, so that all layout subplot properties in use...
[ "def", "_offset_subplot_ids", "(", "fig", ",", "offsets", ")", ":", "# Offset traces", "for", "trace", "in", "fig", ".", "get", "(", "'data'", ",", "None", ")", ":", "trace_type", "=", "trace", ".", "get", "(", "'type'", ",", "'scatter'", ")", "subplot_t...
Apply offsets to the subplot id numbers in a figure. Note: This function mutates the input figure dict Note: This function assumes that the normalize_subplot_ids function has already been run on the figure, so that all layout subplot properties in use are explicitly present in the figure's layout. ...
[ "Apply", "offsets", "to", "the", "subplot", "id", "numbers", "in", "a", "figure", "." ]
python
train
python-openxml/python-docx
docx/opc/oxml.py
https://github.com/python-openxml/python-docx/blob/6756f6cd145511d3eb6d1d188beea391b1ddfd53/docx/opc/oxml.py#L109-L118
def new(ext, content_type): """ Return a new ``<Default>`` element with attributes set to parameter values. """ xml = '<Default xmlns="%s"/>' % nsmap['ct'] default = parse_xml(xml) default.set('Extension', ext) default.set('ContentType', content_type) ...
[ "def", "new", "(", "ext", ",", "content_type", ")", ":", "xml", "=", "'<Default xmlns=\"%s\"/>'", "%", "nsmap", "[", "'ct'", "]", "default", "=", "parse_xml", "(", "xml", ")", "default", ".", "set", "(", "'Extension'", ",", "ext", ")", "default", ".", ...
Return a new ``<Default>`` element with attributes set to parameter values.
[ "Return", "a", "new", "<Default", ">", "element", "with", "attributes", "set", "to", "parameter", "values", "." ]
python
train
alvinwan/TexSoup
TexSoup/data.py
https://github.com/alvinwan/TexSoup/blob/63323ed71510fd2351102b8c36660a3b7703cead/TexSoup/data.py#L137-L159
def children(self): r"""Immediate children of this TeX element that are valid TeX objects. This is equivalent to contents, excluding text elements and keeping only Tex expressions. :return: generator of all children :rtype: Iterator[TexExpr] >>> from TexSoup import Tex...
[ "def", "children", "(", "self", ")", ":", "for", "child", "in", "self", ".", "expr", ".", "children", ":", "node", "=", "TexNode", "(", "child", ")", "node", ".", "parent", "=", "self", "yield", "node" ]
r"""Immediate children of this TeX element that are valid TeX objects. This is equivalent to contents, excluding text elements and keeping only Tex expressions. :return: generator of all children :rtype: Iterator[TexExpr] >>> from TexSoup import TexSoup >>> soup = TexS...
[ "r", "Immediate", "children", "of", "this", "TeX", "element", "that", "are", "valid", "TeX", "objects", "." ]
python
train
archman/beamline
beamline/ui/pltutils.py
https://github.com/archman/beamline/blob/417bc5dc13e754bc89d246427984590fced64d07/beamline/ui/pltutils.py#L86-L96
def set_color(self, rgb_tuple): """ set figure and canvas with the same color. :param rgb_tuple: rgb color tuple, e.g. (255, 255, 255) for white color """ if rgb_tuple is None: rgb_tuple = wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE).Get() clr = [c / 255.0 for ...
[ "def", "set_color", "(", "self", ",", "rgb_tuple", ")", ":", "if", "rgb_tuple", "is", "None", ":", "rgb_tuple", "=", "wx", ".", "SystemSettings", ".", "GetColour", "(", "wx", ".", "SYS_COLOUR_BTNFACE", ")", ".", "Get", "(", ")", "clr", "=", "[", "c", ...
set figure and canvas with the same color. :param rgb_tuple: rgb color tuple, e.g. (255, 255, 255) for white color
[ "set", "figure", "and", "canvas", "with", "the", "same", "color", "." ]
python
train
JarryShaw/PyPCAPKit
src/foundation/extraction.py
https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/foundation/extraction.py#L566-L571
def _cleanup(self): """Cleanup after extraction & analysis.""" self._expkg = None self._extmp = None self._flag_e = True self._ifile.close()
[ "def", "_cleanup", "(", "self", ")", ":", "self", ".", "_expkg", "=", "None", "self", ".", "_extmp", "=", "None", "self", ".", "_flag_e", "=", "True", "self", ".", "_ifile", ".", "close", "(", ")" ]
Cleanup after extraction & analysis.
[ "Cleanup", "after", "extraction", "&", "analysis", "." ]
python
train
dnanexus/dx-toolkit
src/python/dxpy/bindings/dxrecord.py
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/dxrecord.py#L79-L105
def _new(self, dx_hash, close=False, **kwargs): """ :param dx_hash: Standard hash populated in :func:`dxpy.bindings.DXDataObject.new()` containing attributes common to all data object classes. :type dx_hash: dict :param init_from: Record from which to initialize the metadata :typ...
[ "def", "_new", "(", "self", ",", "dx_hash", ",", "close", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "\"init_from\"", "in", "kwargs", ":", "if", "kwargs", "[", "\"init_from\"", "]", "is", "not", "None", ":", "if", "not", "isinstance", "("...
:param dx_hash: Standard hash populated in :func:`dxpy.bindings.DXDataObject.new()` containing attributes common to all data object classes. :type dx_hash: dict :param init_from: Record from which to initialize the metadata :type init_from: :class:`DXRecord` :param close: Whether or not ...
[ ":", "param", "dx_hash", ":", "Standard", "hash", "populated", "in", ":", "func", ":", "dxpy", ".", "bindings", ".", "DXDataObject", ".", "new", "()", "containing", "attributes", "common", "to", "all", "data", "object", "classes", ".", ":", "type", "dx_has...
python
train
srsudar/eg
eg/config.py
https://github.com/srsudar/eg/blob/96142a74f4416b4a7000c85032c070df713b849e/eg/config.py#L393-L428
def get_custom_color_config_from_egrc(config): """ Get the ColorConfig from the egrc config object. Any colors not defined will be None. """ pound = _get_color_from_config(config, CONFIG_NAMES.pound) heading = _get_color_from_config(config, CONFIG_NAMES.heading) code = _get_color_from_config...
[ "def", "get_custom_color_config_from_egrc", "(", "config", ")", ":", "pound", "=", "_get_color_from_config", "(", "config", ",", "CONFIG_NAMES", ".", "pound", ")", "heading", "=", "_get_color_from_config", "(", "config", ",", "CONFIG_NAMES", ".", "heading", ")", "...
Get the ColorConfig from the egrc config object. Any colors not defined will be None.
[ "Get", "the", "ColorConfig", "from", "the", "egrc", "config", "object", ".", "Any", "colors", "not", "defined", "will", "be", "None", "." ]
python
train
laf/russound
russound/russound.py
https://github.com/laf/russound/blob/683af823f78ad02111f9966dc7b535dd66a1f083/russound/russound.py#L202-L224
def create_send_message(self, string_message, controller, zone=None, parameter=None): """ Creates a message from a string, substituting the necessary parameters, that is ready to send to the socket """ cc = hex(int(controller) - 1).replace('0x', '') # RNET requires controller value to be zero ...
[ "def", "create_send_message", "(", "self", ",", "string_message", ",", "controller", ",", "zone", "=", "None", ",", "parameter", "=", "None", ")", ":", "cc", "=", "hex", "(", "int", "(", "controller", ")", "-", "1", ")", ".", "replace", "(", "'0x'", ...
Creates a message from a string, substituting the necessary parameters, that is ready to send to the socket
[ "Creates", "a", "message", "from", "a", "string", "substituting", "the", "necessary", "parameters", "that", "is", "ready", "to", "send", "to", "the", "socket" ]
python
train
crytic/slither
slither/detectors/functions/complex_function.py
https://github.com/crytic/slither/blob/04c147f7e50223c6af458ca430befae747ccd259/slither/detectors/functions/complex_function.py#L36-L73
def detect_complex_func(func): """Detect the cyclomatic complexity of the contract functions shouldn't be greater than 7 """ result = [] code_complexity = compute_cyclomatic_complexity(func) if code_complexity > ComplexFunction.MAX_CYCLOMATIC_COMPLEXITY: r...
[ "def", "detect_complex_func", "(", "func", ")", ":", "result", "=", "[", "]", "code_complexity", "=", "compute_cyclomatic_complexity", "(", "func", ")", "if", "code_complexity", ">", "ComplexFunction", ".", "MAX_CYCLOMATIC_COMPLEXITY", ":", "result", ".", "append", ...
Detect the cyclomatic complexity of the contract functions shouldn't be greater than 7
[ "Detect", "the", "cyclomatic", "complexity", "of", "the", "contract", "functions", "shouldn", "t", "be", "greater", "than", "7" ]
python
train
jobovy/galpy
galpy/df/quasiisothermaldf.py
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/df/quasiisothermaldf.py#L1628-L1698
def sampleV(self,R,z,n=1,**kwargs): """ NAME: sampleV PURPOSE: sample a radial, azimuthal, and vertical velocity at R,z INPUT: R - Galactocentric distance (can be Quantity) z - height (can be Quantity) n= number of distances t...
[ "def", "sampleV", "(", "self", ",", "R", ",", "z", ",", "n", "=", "1", ",", "*", "*", "kwargs", ")", ":", "use_physical", "=", "kwargs", ".", "pop", "(", "'use_physical'", ",", "True", ")", "vo", "=", "kwargs", ".", "pop", "(", "'vo'", ",", "No...
NAME: sampleV PURPOSE: sample a radial, azimuthal, and vertical velocity at R,z INPUT: R - Galactocentric distance (can be Quantity) z - height (can be Quantity) n= number of distances to sample OUTPUT: list of samples ...
[ "NAME", ":" ]
python
train