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
fhamborg/news-please
newsplease/pipeline/extractor/cleaner.py
https://github.com/fhamborg/news-please/blob/731837c2a6c223cfb3e1d7f5fdc4f4eced2310f9/newsplease/pipeline/extractor/cleaner.py#L35-L51
def delete_whitespaces(self, arg): """Removes newlines, tabs and whitespaces at the beginning, the end and if there is more than one. :param arg: A string, the string which shell be cleaned :return: A string, the cleaned string """ # Deletes whitespaces after a newline a...
[ "def", "delete_whitespaces", "(", "self", ",", "arg", ")", ":", "# Deletes whitespaces after a newline", "arg", "=", "re", ".", "sub", "(", "re_newline_spc", ",", "''", ",", "arg", ")", "# Deletes every whitespace, tabulator, newline at the beginning of the string", "arg"...
Removes newlines, tabs and whitespaces at the beginning, the end and if there is more than one. :param arg: A string, the string which shell be cleaned :return: A string, the cleaned string
[ "Removes", "newlines", "tabs", "and", "whitespaces", "at", "the", "beginning", "the", "end", "and", "if", "there", "is", "more", "than", "one", "." ]
python
train
ricequant/rqalpha
rqalpha/api/api_base.py
https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/api/api_base.py#L224-L291
def submit_order(id_or_ins, amount, side, price=None, position_effect=None): """ 通用下单函数,策略可以通过该函数自由选择参数下单。 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` :param float amount: 下单量,需为正数 :param side: 多空方向,多(SIDE.BUY)或空(SIDE.SELL) :type side: :class:`~SIDE` enum ...
[ "def", "submit_order", "(", "id_or_ins", ",", "amount", ",", "side", ",", "price", "=", "None", ",", "position_effect", "=", "None", ")", ":", "order_book_id", "=", "assure_order_book_id", "(", "id_or_ins", ")", "env", "=", "Environment", ".", "get_instance", ...
通用下单函数,策略可以通过该函数自由选择参数下单。 :param id_or_ins: 下单标的物 :type id_or_ins: :class:`~Instrument` object | `str` :param float amount: 下单量,需为正数 :param side: 多空方向,多(SIDE.BUY)或空(SIDE.SELL) :type side: :class:`~SIDE` enum :param float price: 下单价格,默认为None,表示市价单 :param position_effect: 开平方向,开仓(POSITION...
[ "通用下单函数,策略可以通过该函数自由选择参数下单。" ]
python
train
callowayproject/Transmogrify
transmogrify/utils.py
https://github.com/callowayproject/Transmogrify/blob/f1f891b8b923b3a1ede5eac7f60531c1c472379e/transmogrify/utils.py#L252-L264
def get_cached_files(url, server_name="", document_root=None): """ Given a URL, return a list of paths of all cached variations of that file. Doesn't include the original file. """ import glob url_info = process_url(url, server_name, document_root, check_security=False) # get path to cache...
[ "def", "get_cached_files", "(", "url", ",", "server_name", "=", "\"\"", ",", "document_root", "=", "None", ")", ":", "import", "glob", "url_info", "=", "process_url", "(", "url", ",", "server_name", ",", "document_root", ",", "check_security", "=", "False", ...
Given a URL, return a list of paths of all cached variations of that file. Doesn't include the original file.
[ "Given", "a", "URL", "return", "a", "list", "of", "paths", "of", "all", "cached", "variations", "of", "that", "file", "." ]
python
train
xflr6/features
features/__init__.py
https://github.com/xflr6/features/blob/f985304dd642da6ecdc66d85167d00daa4efe5f4/features/__init__.py#L31-L50
def make_features(context, frmat='table', str_maximal=False): """Return a new feature system from context string in the given format. Args: context (str): Formal context table as plain-text string. frmat: Format of the context string (``'table'``, ``'cxt'``, ``'csv'``). str_maximal (boo...
[ "def", "make_features", "(", "context", ",", "frmat", "=", "'table'", ",", "str_maximal", "=", "False", ")", ":", "config", "=", "Config", ".", "create", "(", "context", "=", "context", ",", "format", "=", "frmat", ",", "str_maximal", "=", "str_maximal", ...
Return a new feature system from context string in the given format. Args: context (str): Formal context table as plain-text string. frmat: Format of the context string (``'table'``, ``'cxt'``, ``'csv'``). str_maximal (bool): Example: >>> make_features(''' ... |+ma...
[ "Return", "a", "new", "feature", "system", "from", "context", "string", "in", "the", "given", "format", "." ]
python
train
markovmodel/msmtools
msmtools/flux/api.py
https://github.com/markovmodel/msmtools/blob/54dc76dd2113a0e8f3d15d5316abab41402941be/msmtools/flux/api.py#L334-L367
def coarsegrain(F, sets): r"""Coarse-grains the flux to the given sets. Parameters ---------- F : (n, n) ndarray or scipy.sparse matrix Matrix of flux values between pairs of states. sets : list of array-like of ints The sets of states onto which the flux is coarse-grained. Not...
[ "def", "coarsegrain", "(", "F", ",", "sets", ")", ":", "if", "issparse", "(", "F", ")", ":", "return", "sparse", ".", "tpt", ".", "coarsegrain", "(", "F", ",", "sets", ")", "elif", "isdense", "(", "F", ")", ":", "return", "dense", ".", "tpt", "."...
r"""Coarse-grains the flux to the given sets. Parameters ---------- F : (n, n) ndarray or scipy.sparse matrix Matrix of flux values between pairs of states. sets : list of array-like of ints The sets of states onto which the flux is coarse-grained. Notes ----- The coarse gr...
[ "r", "Coarse", "-", "grains", "the", "flux", "to", "the", "given", "sets", "." ]
python
train
Duke-GCB/DukeDSClient
ddsc/cmdparser.py
https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/cmdparser.py#L309-L317
def _add_message_file(arg_parser, help_text): """ Add mesage file argument with help_text to arg_parser. :param arg_parser: ArgumentParser parser to add this argument to. :param help_text: str: help text for this argument """ arg_parser.add_argument('--msg-file', type...
[ "def", "_add_message_file", "(", "arg_parser", ",", "help_text", ")", ":", "arg_parser", ".", "add_argument", "(", "'--msg-file'", ",", "type", "=", "argparse", ".", "FileType", "(", "'r'", ")", ",", "help", "=", "help_text", ")" ]
Add mesage file argument with help_text to arg_parser. :param arg_parser: ArgumentParser parser to add this argument to. :param help_text: str: help text for this argument
[ "Add", "mesage", "file", "argument", "with", "help_text", "to", "arg_parser", ".", ":", "param", "arg_parser", ":", "ArgumentParser", "parser", "to", "add", "this", "argument", "to", ".", ":", "param", "help_text", ":", "str", ":", "help", "text", "for", "...
python
train
pudo/jsonmapping
jsonmapping/transforms.py
https://github.com/pudo/jsonmapping/blob/4cf0a20a393ba82e00651c6fd39522a67a0155de/jsonmapping/transforms.py#L26-L32
def slugify(mapping, bind, values): """ Transform all values into URL-capable slugs. """ for value in values: if isinstance(value, six.string_types): value = transliterate(value) value = normality.slugify(value) yield value
[ "def", "slugify", "(", "mapping", ",", "bind", ",", "values", ")", ":", "for", "value", "in", "values", ":", "if", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", ":", "value", "=", "transliterate", "(", "value", ")", "value", "=", ...
Transform all values into URL-capable slugs.
[ "Transform", "all", "values", "into", "URL", "-", "capable", "slugs", "." ]
python
train
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/memory_profiler.py
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/memory_profiler.py#L192-L203
def wrap_function(self, func): """ Wrap a function to profile it. """ def f(*args, **kwds): self.enable_by_count() try: result = func(*args, **kwds) finally: self.disable_by_count() return result return f
[ "def", "wrap_function", "(", "self", ",", "func", ")", ":", "def", "f", "(", "*", "args", ",", "*", "*", "kwds", ")", ":", "self", ".", "enable_by_count", "(", ")", "try", ":", "result", "=", "func", "(", "*", "args", ",", "*", "*", "kwds", ")"...
Wrap a function to profile it.
[ "Wrap", "a", "function", "to", "profile", "it", "." ]
python
train
webrecorder/pywb
pywb/utils/loaders.py
https://github.com/webrecorder/pywb/blob/77f8bb647639dd66f6b92b7a9174c28810e4b1d9/pywb/utils/loaders.py#L48-L52
def to_file_url(filename): """ Convert a filename to a file:// url """ url = 'file://' + os.path.abspath(filename).replace(os.path.sep, '/') return url
[ "def", "to_file_url", "(", "filename", ")", ":", "url", "=", "'file://'", "+", "os", ".", "path", ".", "abspath", "(", "filename", ")", ".", "replace", "(", "os", ".", "path", ".", "sep", ",", "'/'", ")", "return", "url" ]
Convert a filename to a file:// url
[ "Convert", "a", "filename", "to", "a", "file", ":", "//", "url" ]
python
train
pandas-dev/pandas
pandas/core/frame.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L2679-L2701
def get_value(self, index, col, takeable=False): """ Quickly retrieve single value at passed column and index. .. deprecated:: 0.21.0 Use .at[] or .iat[] accessors instead. Parameters ---------- index : row label col : column label takeable :...
[ "def", "get_value", "(", "self", ",", "index", ",", "col", ",", "takeable", "=", "False", ")", ":", "warnings", ".", "warn", "(", "\"get_value is deprecated and will be removed \"", "\"in a future release. Please use \"", "\".at[] or .iat[] accessors instead\"", ",", "Fut...
Quickly retrieve single value at passed column and index. .. deprecated:: 0.21.0 Use .at[] or .iat[] accessors instead. Parameters ---------- index : row label col : column label takeable : interpret the index/col as indexers, default False Returns ...
[ "Quickly", "retrieve", "single", "value", "at", "passed", "column", "and", "index", "." ]
python
train
log2timeline/plaso
plaso/output/dynamic.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/output/dynamic.py#L138-L157
def _FormatMessage(self, event): """Formats the message. Args: event (EventObject): event. Returns: str: message field. Raises: NoFormatterFound: if no event formatter can be found to match the data type in the event. """ message, _ = self._output_mediator.GetForma...
[ "def", "_FormatMessage", "(", "self", ",", "event", ")", ":", "message", ",", "_", "=", "self", ".", "_output_mediator", ".", "GetFormattedMessages", "(", "event", ")", "if", "message", "is", "None", ":", "data_type", "=", "getattr", "(", "event", ",", "...
Formats the message. Args: event (EventObject): event. Returns: str: message field. Raises: NoFormatterFound: if no event formatter can be found to match the data type in the event.
[ "Formats", "the", "message", "." ]
python
train
adafruit/Adafruit_CircuitPython_BME280
adafruit_bme280.py
https://github.com/adafruit/Adafruit_CircuitPython_BME280/blob/febcd51983dc2bc3cd006bacaada505251c39af1/adafruit_bme280.py#L366-L399
def humidity(self): """ The relative humidity in RH % returns None if humidity measurement is disabled """ self._read_temperature() hum = self._read_register(_BME280_REGISTER_HUMIDDATA, 2) #print("Humidity data: ", hum) adc = float(hum[0] << 8 | hum[1]) ...
[ "def", "humidity", "(", "self", ")", ":", "self", ".", "_read_temperature", "(", ")", "hum", "=", "self", ".", "_read_register", "(", "_BME280_REGISTER_HUMIDDATA", ",", "2", ")", "#print(\"Humidity data: \", hum)", "adc", "=", "float", "(", "hum", "[", "0", ...
The relative humidity in RH % returns None if humidity measurement is disabled
[ "The", "relative", "humidity", "in", "RH", "%", "returns", "None", "if", "humidity", "measurement", "is", "disabled" ]
python
train
saltstack/salt
salt/utils/stringutils.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/stringutils.py#L364-L389
def expr_match(line, expr): ''' Checks whether or not the passed value matches the specified expression. Tries to match expr first as a glob using fnmatch.fnmatch(), and then tries to match expr as a regular expression. Originally designed to match minion IDs for whitelists/blacklists. Note tha...
[ "def", "expr_match", "(", "line", ",", "expr", ")", ":", "try", ":", "if", "fnmatch", ".", "fnmatch", "(", "line", ",", "expr", ")", ":", "return", "True", "try", ":", "if", "re", ".", "match", "(", "r'\\A{0}\\Z'", ".", "format", "(", "expr", ")", ...
Checks whether or not the passed value matches the specified expression. Tries to match expr first as a glob using fnmatch.fnmatch(), and then tries to match expr as a regular expression. Originally designed to match minion IDs for whitelists/blacklists. Note that this also does exact matches, as fnmat...
[ "Checks", "whether", "or", "not", "the", "passed", "value", "matches", "the", "specified", "expression", ".", "Tries", "to", "match", "expr", "first", "as", "a", "glob", "using", "fnmatch", ".", "fnmatch", "()", "and", "then", "tries", "to", "match", "expr...
python
train
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/_backends/external_ca/apis/certificate_issuers_api.py
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/_backends/external_ca/apis/certificate_issuers_api.py#L331-L349
def get_certificate_issuers(self, **kwargs): # noqa: E501 """Get certificate issuers list. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass asynchronous=True >>> thread = api.get_certificate_issuers(asynchronous=Tr...
[ "def", "get_certificate_issuers", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "if", "kwargs", ".", "get", "(", "'asynchronous'", ")", ":", "return", "self", ".", "get_certificate_...
Get certificate issuers list. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass asynchronous=True >>> thread = api.get_certificate_issuers(asynchronous=True) >>> result = thread.get() :param asynchronous boo...
[ "Get", "certificate", "issuers", "list", ".", "#", "noqa", ":", "E501" ]
python
train
pantsbuild/pex
pex/util.py
https://github.com/pantsbuild/pex/blob/87b2129d860250d3b9edce75b9cb62f9789ee521/pex/util.py#L38-L46
def zipsafe(dist): """Returns whether or not we determine a distribution is zip-safe.""" # zip-safety is only an attribute of eggs. wheels are considered never # zip safe per implications of PEP 427. if hasattr(dist, 'egg_info') and dist.egg_info.endswith('EGG-INFO'): egg_metadata = dist.metadata...
[ "def", "zipsafe", "(", "dist", ")", ":", "# zip-safety is only an attribute of eggs. wheels are considered never", "# zip safe per implications of PEP 427.", "if", "hasattr", "(", "dist", ",", "'egg_info'", ")", "and", "dist", ".", "egg_info", ".", "endswith", "(", "'EGG...
Returns whether or not we determine a distribution is zip-safe.
[ "Returns", "whether", "or", "not", "we", "determine", "a", "distribution", "is", "zip", "-", "safe", "." ]
python
train
tylerbutler/engineer
engineer/commands/core.py
https://github.com/tylerbutler/engineer/blob/8884f587297f37646c40e5553174852b444a4024/engineer/commands/core.py#L165-L178
def parser(self): """Returns the appropriate parser to use for adding arguments to your command.""" if self._command_parser is None: parents = [] if self.need_verbose: parents.append(_verbose_parser) if self.need_settings: parents.appen...
[ "def", "parser", "(", "self", ")", ":", "if", "self", ".", "_command_parser", "is", "None", ":", "parents", "=", "[", "]", "if", "self", ".", "need_verbose", ":", "parents", ".", "append", "(", "_verbose_parser", ")", "if", "self", ".", "need_settings", ...
Returns the appropriate parser to use for adding arguments to your command.
[ "Returns", "the", "appropriate", "parser", "to", "use", "for", "adding", "arguments", "to", "your", "command", "." ]
python
train
UCL-INGI/INGInious
inginious/frontend/arch_helper.py
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/arch_helper.py#L58-L115
def create_arch(configuration, tasks_fs, context, course_factory): """ Helper that can start a simple complete INGInious arch locally if needed, or a client to a remote backend. Intended to be used on command line, makes uses of exit() and the logger inginious.frontend. :param configuration: configurati...
[ "def", "create_arch", "(", "configuration", ",", "tasks_fs", ",", "context", ",", "course_factory", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "\"inginious.frontend\"", ")", "backend_link", "=", "configuration", ".", "get", "(", "\"backend\"", ",...
Helper that can start a simple complete INGInious arch locally if needed, or a client to a remote backend. Intended to be used on command line, makes uses of exit() and the logger inginious.frontend. :param configuration: configuration dict :param tasks_fs: FileSystemProvider to the courses/tasks folder...
[ "Helper", "that", "can", "start", "a", "simple", "complete", "INGInious", "arch", "locally", "if", "needed", "or", "a", "client", "to", "a", "remote", "backend", ".", "Intended", "to", "be", "used", "on", "command", "line", "makes", "uses", "of", "exit", ...
python
train
broadinstitute/fiss
firecloud/workspace.py
https://github.com/broadinstitute/fiss/blob/dddf91547479506dbbafb69ec84d44dcc4a94ab4/firecloud/workspace.py#L42-L54
def new(namespace, name, protected=False, attributes=dict(), api_url=fapi.PROD_API_ROOT): """Create a new FireCloud workspace. Returns: Workspace: A new FireCloud workspace Raises: FireCloudServerError: API call failed. """ r = fapi.create_wo...
[ "def", "new", "(", "namespace", ",", "name", ",", "protected", "=", "False", ",", "attributes", "=", "dict", "(", ")", ",", "api_url", "=", "fapi", ".", "PROD_API_ROOT", ")", ":", "r", "=", "fapi", ".", "create_workspace", "(", "namespace", ",", "name"...
Create a new FireCloud workspace. Returns: Workspace: A new FireCloud workspace Raises: FireCloudServerError: API call failed.
[ "Create", "a", "new", "FireCloud", "workspace", "." ]
python
train
abarto/pandas-drf-tools
pandas_drf_tools/generics.py
https://github.com/abarto/pandas-drf-tools/blob/ec754ac75327e6ee5a1efd256a572a9a531e4d28/pandas_drf_tools/generics.py#L55-L59
def index_row(self, dataframe): """ Indexes the row based on the request parameters. """ return dataframe.loc[self.kwargs[self.lookup_url_kwarg]].to_frame().T
[ "def", "index_row", "(", "self", ",", "dataframe", ")", ":", "return", "dataframe", ".", "loc", "[", "self", ".", "kwargs", "[", "self", ".", "lookup_url_kwarg", "]", "]", ".", "to_frame", "(", ")", ".", "T" ]
Indexes the row based on the request parameters.
[ "Indexes", "the", "row", "based", "on", "the", "request", "parameters", "." ]
python
valid
arne-cl/discoursegraphs
src/discoursegraphs/discoursegraph.py
https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/discoursegraph.py#L159-L181
def _get_all_offsets(self, offset_ns=None): """ returns all token offsets of this document as a generator of (token node ID str, character onset int, character offset int) tuples. Parameters ---------- offset_ns : str or None The namespace from which the offs...
[ "def", "_get_all_offsets", "(", "self", ",", "offset_ns", "=", "None", ")", ":", "for", "token_id", ",", "_token_str", "in", "self", ".", "get_tokens", "(", ")", ":", "onset", "=", "self", ".", "node", "[", "token_id", "]", "[", "'{0}:{1}'", ".", "form...
returns all token offsets of this document as a generator of (token node ID str, character onset int, character offset int) tuples. Parameters ---------- offset_ns : str or None The namespace from which the offsets will be retrieved. If no namespace is given, the...
[ "returns", "all", "token", "offsets", "of", "this", "document", "as", "a", "generator", "of", "(", "token", "node", "ID", "str", "character", "onset", "int", "character", "offset", "int", ")", "tuples", "." ]
python
train
dunovank/jupyter-themes
jupyterthemes/jtplot.py
https://github.com/dunovank/jupyter-themes/blob/421016c2e4fed75fa1830d664c10478d9bd25ed1/jupyterthemes/jtplot.py#L276-L287
def reset(): """ full reset of matplotlib default style and colors """ colors = [(0., 0., 1.), (0., .5, 0.), (1., 0., 0.), (.75, .75, 0.), (.75, .75, 0.), (0., .75, .75), (0., 0., 0.)] for code, color in zip("bgrmyck", colors): rgb = mpl.colors.colorConverter.to_rgb(color) mp...
[ "def", "reset", "(", ")", ":", "colors", "=", "[", "(", "0.", ",", "0.", ",", "1.", ")", ",", "(", "0.", ",", ".5", ",", "0.", ")", ",", "(", "1.", ",", "0.", ",", "0.", ")", ",", "(", ".75", ",", ".75", ",", "0.", ")", ",", "(", ".75...
full reset of matplotlib default style and colors
[ "full", "reset", "of", "matplotlib", "default", "style", "and", "colors" ]
python
train
projectshift/shift-boiler
boiler/user/role_service.py
https://github.com/projectshift/shift-boiler/blob/8e6f3a3e4b9493fb6c8bd16bed160ede153bfb0b/boiler/user/role_service.py#L14-L28
def save(self, role, commit=True): """ Persist role model """ self.is_instance(role) schema = RoleSchema() valid = schema.process(role) if not valid: return valid db.session.add(role) if commit: db.session.commit() events.role_sa...
[ "def", "save", "(", "self", ",", "role", ",", "commit", "=", "True", ")", ":", "self", ".", "is_instance", "(", "role", ")", "schema", "=", "RoleSchema", "(", ")", "valid", "=", "schema", ".", "process", "(", "role", ")", "if", "not", "valid", ":",...
Persist role model
[ "Persist", "role", "model" ]
python
train
PMEAL/OpenPNM
openpnm/network/GenericNetwork.py
https://github.com/PMEAL/OpenPNM/blob/0547b5724ffedc0a593aae48639d36fe10e0baed/openpnm/network/GenericNetwork.py#L630-L700
def find_neighbor_throats(self, pores, mode='union', flatten=True): r""" Returns a list of throats neighboring the given pore(s) Parameters ---------- pores : array_like Indices of pores whose neighbors are sought flatten : boolean, optional If `...
[ "def", "find_neighbor_throats", "(", "self", ",", "pores", ",", "mode", "=", "'union'", ",", "flatten", "=", "True", ")", ":", "pores", "=", "self", ".", "_parse_indices", "(", "pores", ")", "if", "sp", ".", "size", "(", "pores", ")", "==", "0", ":",...
r""" Returns a list of throats neighboring the given pore(s) Parameters ---------- pores : array_like Indices of pores whose neighbors are sought flatten : boolean, optional If ``True`` (default) a 1D array of unique throat indices is returne...
[ "r", "Returns", "a", "list", "of", "throats", "neighboring", "the", "given", "pore", "(", "s", ")" ]
python
train
googleapis/google-cloud-python
bigtable/google/cloud/bigtable/instance.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/bigtable/google/cloud/bigtable/instance.py#L453-L477
def set_iam_policy(self, policy): """Sets the access control policy on an instance resource. Replaces any existing policy. For more information about policy, please see documentation of class `google.cloud.bigtable.policy.Policy` For example: .. literalinclude:: snippe...
[ "def", "set_iam_policy", "(", "self", ",", "policy", ")", ":", "instance_admin_client", "=", "self", ".", "_client", ".", "instance_admin_client", "resp", "=", "instance_admin_client", ".", "set_iam_policy", "(", "resource", "=", "self", ".", "name", ",", "polic...
Sets the access control policy on an instance resource. Replaces any existing policy. For more information about policy, please see documentation of class `google.cloud.bigtable.policy.Policy` For example: .. literalinclude:: snippets.py :start-after: [START bigtab...
[ "Sets", "the", "access", "control", "policy", "on", "an", "instance", "resource", ".", "Replaces", "any", "existing", "policy", "." ]
python
train
mromanello/hucitlib
knowledge_base/surfext/__init__.py
https://github.com/mromanello/hucitlib/blob/6587d1b04eb7e5b48ad7359be845e5d3b444d6fa/knowledge_base/surfext/__init__.py#L81-L107
def add_name(self, name, lang=None): """ Adds a new name variant to an author. :param name: the name to be added :param lang: the language of the name variant :return: `True` if the name is added, `False` otherwise (the name is a duplicate) """ try: a...
[ "def", "add_name", "(", "self", ",", "name", ",", "lang", "=", "None", ")", ":", "try", ":", "assert", "(", "lang", ",", "name", ")", "not", "in", "self", ".", "get_names", "(", ")", "except", "Exception", "as", "e", ":", "# TODO: raise a custom except...
Adds a new name variant to an author. :param name: the name to be added :param lang: the language of the name variant :return: `True` if the name is added, `False` otherwise (the name is a duplicate)
[ "Adds", "a", "new", "name", "variant", "to", "an", "author", "." ]
python
train
calston/tensor
tensor/outputs/elasticsearch.py
https://github.com/calston/tensor/blob/7c0c99708b5dbff97f3895f705e11996b608549d/tensor/outputs/elasticsearch.py#L61-L71
def createClient(self): """Sets up HTTP connector and starts queue timer """ server = self.config.get('server', 'localhost') port = int(self.config.get('port', 9200)) self.client = elasticsearch.ElasticSearch(self.url, self.user, self.password, self.index) ...
[ "def", "createClient", "(", "self", ")", ":", "server", "=", "self", ".", "config", ".", "get", "(", "'server'", ",", "'localhost'", ")", "port", "=", "int", "(", "self", ".", "config", ".", "get", "(", "'port'", ",", "9200", ")", ")", "self", ".",...
Sets up HTTP connector and starts queue timer
[ "Sets", "up", "HTTP", "connector", "and", "starts", "queue", "timer" ]
python
test
f3at/feat
src/feat/models/model.py
https://github.com/f3at/feat/blob/15da93fc9d6ec8154f52a9172824e25821195ef8/src/feat/models/model.py#L633-L668
def initiate(self, aspect=None, view=None, parent=None, officer=None): """Do not keep any reference to its parent, this way it can be garbage-collected.""" def got_view(view): if view is None: return None return init(view) def init(view): ...
[ "def", "initiate", "(", "self", ",", "aspect", "=", "None", ",", "view", "=", "None", ",", "parent", "=", "None", ",", "officer", "=", "None", ")", ":", "def", "got_view", "(", "view", ")", ":", "if", "view", "is", "None", ":", "return", "None", ...
Do not keep any reference to its parent, this way it can be garbage-collected.
[ "Do", "not", "keep", "any", "reference", "to", "its", "parent", "this", "way", "it", "can", "be", "garbage", "-", "collected", "." ]
python
train
Vagrants/blackbird
blackbird/plugins/base.py
https://github.com/Vagrants/blackbird/blob/3b38cd5650caae362e0668dbd38bf8f88233e079/blackbird/plugins/base.py#L89-L95
def _generate(self): u"""overrided in each modules.""" self._data['key'] = self.key self._data['value'] = self.value self._data['host'] = self.host self._data['clock'] = self.clock
[ "def", "_generate", "(", "self", ")", ":", "self", ".", "_data", "[", "'key'", "]", "=", "self", ".", "key", "self", ".", "_data", "[", "'value'", "]", "=", "self", ".", "value", "self", ".", "_data", "[", "'host'", "]", "=", "self", ".", "host",...
u"""overrided in each modules.
[ "u", "overrided", "in", "each", "modules", "." ]
python
train
saltstack/salt
salt/modules/git.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/git.py#L5269-L5380
def worktree_prune(cwd, dry_run=False, verbose=True, expire=None, opts='', git_opts='', user=None, password=None, ignore_retcode=False, output_encodi...
[ "def", "worktree_prune", "(", "cwd", ",", "dry_run", "=", "False", ",", "verbose", "=", "True", ",", "expire", "=", "None", ",", "opts", "=", "''", ",", "git_opts", "=", "''", ",", "user", "=", "None", ",", "password", "=", "None", ",", "ignore_retco...
.. versionadded:: 2015.8.0 Interface to `git-worktree(1)`_, prunes stale worktree administrative data from the gitdir cwd The path to the main git checkout or a linked worktree dry_run : False If ``True``, then this function will report what would have been pruned, but no chan...
[ "..", "versionadded", "::", "2015", ".", "8", ".", "0" ]
python
train
CityOfZion/neo-python-rpc
neorpc/Client.py
https://github.com/CityOfZion/neo-python-rpc/blob/89d22c4043654b2941bf26b15a1c09082901d9ef/neorpc/Client.py#L103-L114
def get_block_hash(self, height, id=None, endpoint=None): """ Get hash of a block by its height Args: height: (int) height of the block to lookup id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use ...
[ "def", "get_block_hash", "(", "self", ",", "height", ",", "id", "=", "None", ",", "endpoint", "=", "None", ")", ":", "return", "self", ".", "_call_endpoint", "(", "GET_BLOCK_HASH", ",", "params", "=", "[", "height", "]", ",", "id", "=", "id", ",", "e...
Get hash of a block by its height Args: height: (int) height of the block to lookup id: (int, optional) id to use for response tracking endpoint: (RPCEndpoint, optional) endpoint to specify to use Returns: json object of the result or the error encountere...
[ "Get", "hash", "of", "a", "block", "by", "its", "height", "Args", ":", "height", ":", "(", "int", ")", "height", "of", "the", "block", "to", "lookup", "id", ":", "(", "int", "optional", ")", "id", "to", "use", "for", "response", "tracking", "endpoint...
python
train
StackStorm/pybind
pybind/nos/v7_2_0/rbridge_id/ip/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v7_2_0/rbridge_id/ip/__init__.py#L246-L267
def _set_as_path(self, v, load=False): """ Setter method for as_path, mapped from YANG variable /rbridge_id/ip/as_path (container) If this variable is read-only (config: false) in the source YANG file, then _set_as_path is considered as a private method. Backends looking to populate this variable sh...
[ "def", "_set_as_path", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "base",...
Setter method for as_path, mapped from YANG variable /rbridge_id/ip/as_path (container) If this variable is read-only (config: false) in the source YANG file, then _set_as_path is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_as_path() d...
[ "Setter", "method", "for", "as_path", "mapped", "from", "YANG", "variable", "/", "rbridge_id", "/", "ip", "/", "as_path", "(", "container", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in", "the", "source",...
python
train
ray-project/ray
python/ray/tune/automl/genetic_searcher.py
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automl/genetic_searcher.py#L140-L178
def _selection(candidate): """Perform selection action to candidates. For example, new gene = sample_1 + the 5th bit of sample2. Args: candidate: List of candidate genes (encodings). Examples: >>> # Genes that represent 3 parameters >>> gene1 = np.a...
[ "def", "_selection", "(", "candidate", ")", ":", "sample_index1", "=", "np", ".", "random", ".", "choice", "(", "len", "(", "candidate", ")", ")", "sample_index2", "=", "np", ".", "random", ".", "choice", "(", "len", "(", "candidate", ")", ")", "sample...
Perform selection action to candidates. For example, new gene = sample_1 + the 5th bit of sample2. Args: candidate: List of candidate genes (encodings). Examples: >>> # Genes that represent 3 parameters >>> gene1 = np.array([[0, 0, 1], [0, 1], [1, 0]]) ...
[ "Perform", "selection", "action", "to", "candidates", "." ]
python
train
pydata/xarray
xarray/plot/utils.py
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/plot/utils.py#L412-L422
def _interval_to_bound_points(array): """ Helper function which returns an array with the Intervals' boundaries. """ array_boundaries = np.array([x.left for x in array]) array_boundaries = np.concatenate( (array_boundaries, np.array([array[-1].right]))) return array_boundaries
[ "def", "_interval_to_bound_points", "(", "array", ")", ":", "array_boundaries", "=", "np", ".", "array", "(", "[", "x", ".", "left", "for", "x", "in", "array", "]", ")", "array_boundaries", "=", "np", ".", "concatenate", "(", "(", "array_boundaries", ",", ...
Helper function which returns an array with the Intervals' boundaries.
[ "Helper", "function", "which", "returns", "an", "array", "with", "the", "Intervals", "boundaries", "." ]
python
train
LEMS/pylems
lems/model/model.py
https://github.com/LEMS/pylems/blob/4eeb719d2f23650fe16c38626663b69b5c83818b/lems/model/model.py#L728-L799
def resolve_simulation(self, fc, ct): """ Resolve simulation specifications. """ for run in ct.simulation.runs: try: run2 = Run(fc.component_references[run.component].referenced_component, run.variable, fc...
[ "def", "resolve_simulation", "(", "self", ",", "fc", ",", "ct", ")", ":", "for", "run", "in", "ct", ".", "simulation", ".", "runs", ":", "try", ":", "run2", "=", "Run", "(", "fc", ".", "component_references", "[", "run", ".", "component", "]", ".", ...
Resolve simulation specifications.
[ "Resolve", "simulation", "specifications", "." ]
python
train
GNS3/gns3-server
gns3server/compute/iou/iou_vm.py
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/iou/iou_vm.py#L687-L704
def _create_netmap_config(self): """ Creates the NETMAP file. """ netmap_path = os.path.join(self.working_dir, "NETMAP") try: with open(netmap_path, "w", encoding="utf-8") as f: for bay in range(0, 16): for unit in range(0, 4): ...
[ "def", "_create_netmap_config", "(", "self", ")", ":", "netmap_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "working_dir", ",", "\"NETMAP\"", ")", "try", ":", "with", "open", "(", "netmap_path", ",", "\"w\"", ",", "encoding", "=", "\"utf...
Creates the NETMAP file.
[ "Creates", "the", "NETMAP", "file", "." ]
python
train
twilio/twilio-python
twilio/twiml/voice_response.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/twiml/voice_response.py#L35-L78
def dial(self, number=None, action=None, method=None, timeout=None, hangup_on_star=None, time_limit=None, caller_id=None, record=None, trim=None, recording_status_callback=None, recording_status_callback_method=None, recording_status_callback_event=None, answer_on_bri...
[ "def", "dial", "(", "self", ",", "number", "=", "None", ",", "action", "=", "None", ",", "method", "=", "None", ",", "timeout", "=", "None", ",", "hangup_on_star", "=", "None", ",", "time_limit", "=", "None", ",", "caller_id", "=", "None", ",", "reco...
Create a <Dial> element :param number: Phone number to dial :param action: Action URL :param method: Action URL method :param timeout: Time to wait for answer :param hangup_on_star: Hangup call on star press :param time_limit: Max time length :param caller_id: Ca...
[ "Create", "a", "<Dial", ">", "element" ]
python
train
SCIP-Interfaces/PySCIPOpt
examples/finished/read_tsplib.py
https://github.com/SCIP-Interfaces/PySCIPOpt/blob/9c960b40d94a48b0304d73dbe28b467b9c065abe/examples/finished/read_tsplib.py#L27-L35
def distL1(x1,y1,x2,y2): """Compute the L1-norm (Manhattan) distance between two points. The distance is rounded to the closest integer, for compatibility with the TSPLIB convention. The two points are located on coordinates (x1,y1) and (x2,y2), sent as parameters""" return int(abs(x2-x1) + ab...
[ "def", "distL1", "(", "x1", ",", "y1", ",", "x2", ",", "y2", ")", ":", "return", "int", "(", "abs", "(", "x2", "-", "x1", ")", "+", "abs", "(", "y2", "-", "y1", ")", "+", ".5", ")" ]
Compute the L1-norm (Manhattan) distance between two points. The distance is rounded to the closest integer, for compatibility with the TSPLIB convention. The two points are located on coordinates (x1,y1) and (x2,y2), sent as parameters
[ "Compute", "the", "L1", "-", "norm", "(", "Manhattan", ")", "distance", "between", "two", "points", "." ]
python
train
edaniszewski/bison
bison/bison.py
https://github.com/edaniszewski/bison/blob/0b889196bb314a0803c4089fe102eacacabb118b/bison/bison.py#L138-L147
def parse(self, requires_cfg=True): """Parse the configuration sources into `Bison`. Args: requires_cfg (bool): Specify whether or not parsing should fail if a config file is not found. (default: True) """ self._parse_default() self._parse_config(requ...
[ "def", "parse", "(", "self", ",", "requires_cfg", "=", "True", ")", ":", "self", ".", "_parse_default", "(", ")", "self", ".", "_parse_config", "(", "requires_cfg", ")", "self", ".", "_parse_env", "(", ")" ]
Parse the configuration sources into `Bison`. Args: requires_cfg (bool): Specify whether or not parsing should fail if a config file is not found. (default: True)
[ "Parse", "the", "configuration", "sources", "into", "Bison", "." ]
python
train
materials-data-facility/toolbox
mdf_toolbox/toolbox.py
https://github.com/materials-data-facility/toolbox/blob/2a4ac2b6a892238263008efa6a5f3923d9a83505/mdf_toolbox/toolbox.py#L65-L254
def login(credentials=None, app_name=None, services=None, client_id=None, make_clients=True, clear_old_tokens=False, token_dir=DEFAULT_CRED_PATH, **kwargs): """Log in to Globus services Arguments: credentials (str or dict): A string filename, string JSON, or dictionary with cr...
[ "def", "login", "(", "credentials", "=", "None", ",", "app_name", "=", "None", ",", "services", "=", "None", ",", "client_id", "=", "None", ",", "make_clients", "=", "True", ",", "clear_old_tokens", "=", "False", ",", "token_dir", "=", "DEFAULT_CRED_PATH", ...
Log in to Globus services Arguments: credentials (str or dict): A string filename, string JSON, or dictionary with credential and config information. By default, looks in ``~/mdf/credentials/globus_login.json``. Contains ``app_name``, ``services``, and ``clie...
[ "Log", "in", "to", "Globus", "services" ]
python
train
timgabets/pynblock
pynblock/tools.py
https://github.com/timgabets/pynblock/blob/dbdb6d06bd7741e1138bed09d874b47b23d8d200/pynblock/tools.py#L218-L234
def modify_key_parity(key): """ The prior use of the function is to return the parity-validated key. The incoming key is expected to be hex data binary representation, e.g. b'E7A3C8B1' """ validated_key = b'' for byte in key: if parityOf(int(byte)) == -1: byte_candidate = in...
[ "def", "modify_key_parity", "(", "key", ")", ":", "validated_key", "=", "b''", "for", "byte", "in", "key", ":", "if", "parityOf", "(", "int", "(", "byte", ")", ")", "==", "-", "1", ":", "byte_candidate", "=", "int", "(", "byte", ")", "+", "1", "whi...
The prior use of the function is to return the parity-validated key. The incoming key is expected to be hex data binary representation, e.g. b'E7A3C8B1'
[ "The", "prior", "use", "of", "the", "function", "is", "to", "return", "the", "parity", "-", "validated", "key", "." ]
python
train
DheerendraRathor/django-auth-ldap-ng
django_auth_ldap/backend.py
https://github.com/DheerendraRathor/django-auth-ldap-ng/blob/4d2458bd90c4539353c5bfd5ea793c1e59780ee8/django_auth_ldap/backend.py#L211-L225
def get_or_create_user(self, username, ldap_user): """ This must return a (User, created) 2-tuple for the given LDAP user. username is the Django-friendly username of the user. ldap_user.dn is the user's DN and ldap_user.attrs contains all of their LDAP attributes. """ mo...
[ "def", "get_or_create_user", "(", "self", ",", "username", ",", "ldap_user", ")", ":", "model", "=", "self", ".", "get_user_model", "(", ")", "username_field", "=", "getattr", "(", "model", ",", "'USERNAME_FIELD'", ",", "'username'", ")", "kwargs", "=", "{",...
This must return a (User, created) 2-tuple for the given LDAP user. username is the Django-friendly username of the user. ldap_user.dn is the user's DN and ldap_user.attrs contains all of their LDAP attributes.
[ "This", "must", "return", "a", "(", "User", "created", ")", "2", "-", "tuple", "for", "the", "given", "LDAP", "user", ".", "username", "is", "the", "Django", "-", "friendly", "username", "of", "the", "user", ".", "ldap_user", ".", "dn", "is", "the", ...
python
train
HydrelioxGitHub/pybbox
pybbox/__init__.py
https://github.com/HydrelioxGitHub/pybbox/blob/bedcdccab5d18d36890ef8bf414845f2dec18b5c/pybbox/__init__.py#L83-L96
def get_token(self): """ Return a string which is a token, needed for some API calls :return: Token (can be used with some API call :rtype: str .. todo:: make a token class to be able to store date of expiration """ self.bbox_auth.set_access(BboxConstant.AUTHENTI...
[ "def", "get_token", "(", "self", ")", ":", "self", ".", "bbox_auth", ".", "set_access", "(", "BboxConstant", ".", "AUTHENTICATION_LEVEL_PRIVATE", ",", "BboxConstant", ".", "AUTHENTICATION_LEVEL_PRIVATE", ")", "self", ".", "bbox_url", ".", "set_api_name", "(", "Bbo...
Return a string which is a token, needed for some API calls :return: Token (can be used with some API call :rtype: str .. todo:: make a token class to be able to store date of expiration
[ "Return", "a", "string", "which", "is", "a", "token", "needed", "for", "some", "API", "calls", ":", "return", ":", "Token", "(", "can", "be", "used", "with", "some", "API", "call", ":", "rtype", ":", "str" ]
python
train
arista-eosplus/pyeapi
pyeapi/api/abstract.py
https://github.com/arista-eosplus/pyeapi/blob/96a74faef1fe3bd79c4e900aed29c9956a0587d6/pyeapi/api/abstract.py#L162-L174
def configure_interface(self, name, commands): """Configures the specified interface with the commands Args: name (str): The interface name to configure commands: The commands to configure in the interface Returns: True if the commands completed successfully...
[ "def", "configure_interface", "(", "self", ",", "name", ",", "commands", ")", ":", "commands", "=", "make_iterable", "(", "commands", ")", "commands", ".", "insert", "(", "0", ",", "'interface %s'", "%", "name", ")", "return", "self", ".", "configure", "("...
Configures the specified interface with the commands Args: name (str): The interface name to configure commands: The commands to configure in the interface Returns: True if the commands completed successfully
[ "Configures", "the", "specified", "interface", "with", "the", "commands" ]
python
train
dmckeone/frosty
frosty/freezers.py
https://github.com/dmckeone/frosty/blob/868d81e72b6c8e354af3697531c20f116cd1fc9a/frosty/freezers.py#L44-L82
def build_includes(cls, include_packages): """ The default include strategy is to add a star (*) wild card after all sub-packages (but not the main package). This strategy is compatible with py2app and bbfreeze. Example (From SaltStack 2014.7): salt salt.fileser...
[ "def", "build_includes", "(", "cls", ",", "include_packages", ")", ":", "includes", ",", "package_root_paths", "=", "cls", ".", "_split_packages", "(", "include_packages", ")", "for", "package_path", ",", "package_name", "in", "six", ".", "iteritems", "(", "pack...
The default include strategy is to add a star (*) wild card after all sub-packages (but not the main package). This strategy is compatible with py2app and bbfreeze. Example (From SaltStack 2014.7): salt salt.fileserver.* salt.modules.* etc... :p...
[ "The", "default", "include", "strategy", "is", "to", "add", "a", "star", "(", "*", ")", "wild", "card", "after", "all", "sub", "-", "packages", "(", "but", "not", "the", "main", "package", ")", ".", "This", "strategy", "is", "compatible", "with", "py2a...
python
train
selectel/pyte
pyte/screens.py
https://github.com/selectel/pyte/blob/8adad489f86da1788a7995720c344a2fa44f244e/pyte/screens.py#L582-L589
def linefeed(self): """Perform an index and, if :data:`~pyte.modes.LNM` is set, a carriage return. """ self.index() if mo.LNM in self.mode: self.carriage_return()
[ "def", "linefeed", "(", "self", ")", ":", "self", ".", "index", "(", ")", "if", "mo", ".", "LNM", "in", "self", ".", "mode", ":", "self", ".", "carriage_return", "(", ")" ]
Perform an index and, if :data:`~pyte.modes.LNM` is set, a carriage return.
[ "Perform", "an", "index", "and", "if", ":", "data", ":", "~pyte", ".", "modes", ".", "LNM", "is", "set", "a", "carriage", "return", "." ]
python
train
googlefonts/ufo2ft
Lib/ufo2ft/__init__.py
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/__init__.py#L393-L470
def compileInterpolatableOTFsFromDS( designSpaceDoc, preProcessorClass=OTFPreProcessor, outlineCompilerClass=OutlineOTFCompiler, featureCompilerClass=None, featureWriters=None, glyphOrder=None, useProductionNames=None, roundTolerance=None, inplace=False, ): """Create FontTools CF...
[ "def", "compileInterpolatableOTFsFromDS", "(", "designSpaceDoc", ",", "preProcessorClass", "=", "OTFPreProcessor", ",", "outlineCompilerClass", "=", "OutlineOTFCompiler", ",", "featureCompilerClass", "=", "None", ",", "featureWriters", "=", "None", ",", "glyphOrder", "=",...
Create FontTools CFF fonts from the DesignSpaceDocument UFO sources with interpolatable outlines. Interpolatable means without subroutinization and specializer optimizations and no removal of overlaps. If the Designspace contains a "public.skipExportGlyphs" lib key, these glyphs will not be export...
[ "Create", "FontTools", "CFF", "fonts", "from", "the", "DesignSpaceDocument", "UFO", "sources", "with", "interpolatable", "outlines", "." ]
python
train
etingof/pysnmp
pysnmp/smi/mibs/SNMPv2-SMI.py
https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L2552-L2608
def valueToOid(self, value, impliedFlag=False, parentIndices=None): """Turn value object into SMI table instance identifier. SNMP SMI table objects are identified by OIDs composed of columnar object ID and instance index. The index part can be composed from the values of one or more tab...
[ "def", "valueToOid", "(", "self", ",", "value", ",", "impliedFlag", "=", "False", ",", "parentIndices", "=", "None", ")", ":", "if", "hasattr", "(", "value", ",", "'cloneAsName'", ")", ":", "return", "value", ".", "cloneAsName", "(", "impliedFlag", ",", ...
Turn value object into SMI table instance identifier. SNMP SMI table objects are identified by OIDs composed of columnar object ID and instance index. The index part can be composed from the values of one or more tabular objects. This method takes an arbitrary value object and turns it...
[ "Turn", "value", "object", "into", "SMI", "table", "instance", "identifier", "." ]
python
train
GiulioRossetti/dynetx
dynetx/classes/function.py
https://github.com/GiulioRossetti/dynetx/blob/634e2b38f8950885aebfa079dad7d5e8d7563f1d/dynetx/classes/function.py#L503-L535
def set_node_attributes(G, values, name=None): """Set node attributes from dictionary of nodes and values Parameters ---------- G : DyNetx Graph name : string Attribute name values: dict Dictionary of attribute values keyed by node. If `values` is not...
[ "def", "set_node_attributes", "(", "G", ",", "values", ",", "name", "=", "None", ")", ":", "# Set node attributes based on type of `values`", "if", "name", "is", "not", "None", ":", "# `values` must not be a dict of dict", "try", ":", "# `values` is a dict", "for", "n...
Set node attributes from dictionary of nodes and values Parameters ---------- G : DyNetx Graph name : string Attribute name values: dict Dictionary of attribute values keyed by node. If `values` is not a dictionary, then it is treated as a sing...
[ "Set", "node", "attributes", "from", "dictionary", "of", "nodes", "and", "values" ]
python
train
exa-analytics/exa
exa/core/editor.py
https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/editor.py#L108-L119
def append(self, lines): """ Args: lines (list): List of line strings to append to the end of the editor """ if isinstance(lines, list): self._lines = self._lines + lines elif isinstance(lines, str): lines = lines.split('\n') self._...
[ "def", "append", "(", "self", ",", "lines", ")", ":", "if", "isinstance", "(", "lines", ",", "list", ")", ":", "self", ".", "_lines", "=", "self", ".", "_lines", "+", "lines", "elif", "isinstance", "(", "lines", ",", "str", ")", ":", "lines", "=", ...
Args: lines (list): List of line strings to append to the end of the editor
[ "Args", ":", "lines", "(", "list", ")", ":", "List", "of", "line", "strings", "to", "append", "to", "the", "end", "of", "the", "editor" ]
python
train
jgillick/LendingClub
lendingclub/filters.py
https://github.com/jgillick/LendingClub/blob/4495f99fd869810f39c00e02b0f4112c6b210384/lendingclub/filters.py#L431-L455
def all_filters(lc): """ Get a list of all your saved filters Parameters ---------- lc : :py:class:`lendingclub.LendingClub` An instance of the authenticated LendingClub class Returns ------- list A list of lendingclub.filters.Sav...
[ "def", "all_filters", "(", "lc", ")", ":", "filters", "=", "[", "]", "response", "=", "lc", ".", "session", ".", "get", "(", "'/browse/getSavedFiltersAj.action'", ")", "json_response", "=", "response", ".", "json", "(", ")", "# Load all filters", "if", "lc",...
Get a list of all your saved filters Parameters ---------- lc : :py:class:`lendingclub.LendingClub` An instance of the authenticated LendingClub class Returns ------- list A list of lendingclub.filters.SavedFilter objects
[ "Get", "a", "list", "of", "all", "your", "saved", "filters" ]
python
train
SavinaRoja/OpenAccess_EPUB
src/openaccess_epub/utils/__init__.py
https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/__init__.py#L179-L243
def get_output_directory(args): """ Determination of the directory for output placement involves possibilities for explicit user instruction (absolute path or relative to execution) and implicit default configuration (absolute path or relative to input) from the system global configuration file. Thi...
[ "def", "get_output_directory", "(", "args", ")", ":", "#Import the global config file as a module", "import", "imp", "config_path", "=", "os", ".", "path", ".", "join", "(", "cache_location", "(", ")", ",", "'config.py'", ")", "try", ":", "config", "=", "imp", ...
Determination of the directory for output placement involves possibilities for explicit user instruction (absolute path or relative to execution) and implicit default configuration (absolute path or relative to input) from the system global configuration file. This function is responsible for reliably r...
[ "Determination", "of", "the", "directory", "for", "output", "placement", "involves", "possibilities", "for", "explicit", "user", "instruction", "(", "absolute", "path", "or", "relative", "to", "execution", ")", "and", "implicit", "default", "configuration", "(", "...
python
train
apriha/lineage
src/lineage/resources.py
https://github.com/apriha/lineage/blob/13106a62a959a80ac26c68d1566422de08aa877b/src/lineage/resources.py#L262-L309
def _load_genetic_map(filename): """ Load genetic map (e.g. HapMapII). Parameters ---------- filename : str path to compressed archive with genetic map data Returns ------- genetic_map : dict dict of pandas.DataFrame genetic maps if loadi...
[ "def", "_load_genetic_map", "(", "filename", ")", ":", "try", ":", "genetic_map", "=", "{", "}", "with", "tarfile", ".", "open", "(", "filename", ",", "\"r\"", ")", "as", "tar", ":", "# http://stackoverflow.com/a/2018576", "for", "member", "in", "tar", ".", ...
Load genetic map (e.g. HapMapII). Parameters ---------- filename : str path to compressed archive with genetic map data Returns ------- genetic_map : dict dict of pandas.DataFrame genetic maps if loading was successful, else None Notes ...
[ "Load", "genetic", "map", "(", "e", ".", "g", ".", "HapMapII", ")", "." ]
python
train
grundprinzip/pyxplorer
pyxplorer/types.py
https://github.com/grundprinzip/pyxplorer/blob/34c1d166cfef4a94aeb6d5fcb3cbb726d48146e2/pyxplorer/types.py#L215-L224
def columns(self): """ :return: the list of column in this table """ c = self._connection.cursor() c.execute("describe `%s`.`%s`" % (self._db, self._name)) self._cols = [] for col in c.fetchall(): self._cols.append(Column.build(col, table=self, con=sel...
[ "def", "columns", "(", "self", ")", ":", "c", "=", "self", ".", "_connection", ".", "cursor", "(", ")", "c", ".", "execute", "(", "\"describe `%s`.`%s`\"", "%", "(", "self", ".", "_db", ",", "self", ".", "_name", ")", ")", "self", ".", "_cols", "="...
:return: the list of column in this table
[ ":", "return", ":", "the", "list", "of", "column", "in", "this", "table" ]
python
train
aws/aws-xray-sdk-python
aws_xray_sdk/core/sampling/connector.py
https://github.com/aws/aws-xray-sdk-python/blob/707358cd3a516d51f2ebf71cf34f00e8d906a667/aws_xray_sdk/core/sampling/connector.py#L136-L149
def _dt_to_epoch(self, dt): """ Convert a offset-aware datetime to POSIX time. """ if PY2: # The input datetime is from botocore unmarshalling and it is # offset-aware so the timedelta of subtracting this time # to 01/01/1970 using the same tzinfo give...
[ "def", "_dt_to_epoch", "(", "self", ",", "dt", ")", ":", "if", "PY2", ":", "# The input datetime is from botocore unmarshalling and it is", "# offset-aware so the timedelta of subtracting this time", "# to 01/01/1970 using the same tzinfo gives us", "# Unix Time (also known as POSIX Time...
Convert a offset-aware datetime to POSIX time.
[ "Convert", "a", "offset", "-", "aware", "datetime", "to", "POSIX", "time", "." ]
python
train
roboogle/gtkmvc3
gtkmvco/gtkmvc3/support/metaclasses.py
https://github.com/roboogle/gtkmvc3/blob/63405fd8d2056be26af49103b13a8d5e57fe4dff/gtkmvco/gtkmvc3/support/metaclasses.py#L225-L342
def __create_log_props(cls, log_props, _getdict, _setdict): # @NoSelf """Creates all the logical property. The list of names of properties to be created is passed with frozenset log_props. The getter/setter information is taken from _{get,set}dict. This method resolves also wi...
[ "def", "__create_log_props", "(", "cls", ",", "log_props", ",", "_getdict", ",", "_setdict", ")", ":", "# @NoSelf", "real_log_props", "=", "set", "(", ")", "resolved_getdict", "=", "{", "}", "resolved_setdict", "=", "{", "}", "for", "_dict_name", ",", "_dict...
Creates all the logical property. The list of names of properties to be created is passed with frozenset log_props. The getter/setter information is taken from _{get,set}dict. This method resolves also wildcards in names, and performs all checks to ensure correctness. ...
[ "Creates", "all", "the", "logical", "property", "." ]
python
train
vinci1it2000/schedula
schedula/utils/alg.py
https://github.com/vinci1it2000/schedula/blob/addb9fd685be81544b796c51383ac00a31543ce9/schedula/utils/alg.py#L202-L227
def _get_node(nodes, node_id, fuzzy=True): """ Returns a dispatcher node that match the given node id. :param nodes: Dispatcher nodes. :type nodes: dict :param node_id: Node id. :type node_id: str :return: The dispatcher node and its id. :rtype: (str, dict) ...
[ "def", "_get_node", "(", "nodes", ",", "node_id", ",", "fuzzy", "=", "True", ")", ":", "try", ":", "return", "node_id", ",", "nodes", "[", "node_id", "]", "# Return dispatcher node and its id.", "except", "KeyError", "as", "ex", ":", "if", "fuzzy", ":", "i...
Returns a dispatcher node that match the given node id. :param nodes: Dispatcher nodes. :type nodes: dict :param node_id: Node id. :type node_id: str :return: The dispatcher node and its id. :rtype: (str, dict)
[ "Returns", "a", "dispatcher", "node", "that", "match", "the", "given", "node", "id", "." ]
python
train
kentik/kentikapi-py
kentikapi/v5/tagging.py
https://github.com/kentik/kentikapi-py/blob/aa94c0b7eaf88409818b97967d7293e309e11bab/kentikapi/v5/tagging.py#L124-L130
def build_json(self, guid): """Build JSON with the input guid""" upserts = [] for value in self.upserts: upserts.append({"value": value, "criteria": self.upserts[value]}) return json.dumps({'replace_all': self.replace_all, 'guid': guid, 'complete': ...
[ "def", "build_json", "(", "self", ",", "guid", ")", ":", "upserts", "=", "[", "]", "for", "value", "in", "self", ".", "upserts", ":", "upserts", ".", "append", "(", "{", "\"value\"", ":", "value", ",", "\"criteria\"", ":", "self", ".", "upserts", "["...
Build JSON with the input guid
[ "Build", "JSON", "with", "the", "input", "guid" ]
python
train
noahbenson/pimms
pimms/calculation.py
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/calculation.py#L357-L362
def discard(self, *args): ''' cplan.discard(...) yields a new calculation plan identical to cplan except without any of the calculation steps listed in the arguments. ''' return Plan(reduce(lambda m,k: m.discard(k), args, self.nodes))
[ "def", "discard", "(", "self", ",", "*", "args", ")", ":", "return", "Plan", "(", "reduce", "(", "lambda", "m", ",", "k", ":", "m", ".", "discard", "(", "k", ")", ",", "args", ",", "self", ".", "nodes", ")", ")" ]
cplan.discard(...) yields a new calculation plan identical to cplan except without any of the calculation steps listed in the arguments.
[ "cplan", ".", "discard", "(", "...", ")", "yields", "a", "new", "calculation", "plan", "identical", "to", "cplan", "except", "without", "any", "of", "the", "calculation", "steps", "listed", "in", "the", "arguments", "." ]
python
train
ianmiell/shutit
shutit_class.py
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L1673-L1707
def get_file(self, target_path, host_path, note=None, loglevel=logging.DEBUG): """Copy a file from the target machine to the host machine @param target_path: path to file in the target @param host_path: path to file on the host machine (e.g. copy test) ...
[ "def", "get_file", "(", "self", ",", "target_path", ",", "host_path", ",", "note", "=", "None", ",", "loglevel", "=", "logging", ".", "DEBUG", ")", ":", "shutit_global", ".", "shutit_global_object", ".", "yield_to_draw", "(", ")", "self", ".", "handle_note",...
Copy a file from the target machine to the host machine @param target_path: path to file in the target @param host_path: path to file on the host machine (e.g. copy test) @param note: See send() @type target_path: string @type host_path: string @return: boolean @rtype: s...
[ "Copy", "a", "file", "from", "the", "target", "machine", "to", "the", "host", "machine" ]
python
train
RJT1990/pyflux
pyflux/ssm/nllm.py
https://github.com/RJT1990/pyflux/blob/297f2afc2095acd97c12e827dd500e8ea5da0c0f/pyflux/ssm/nllm.py#L300-L308
def _create_latent_variables(self): """ Creates model latent variables Returns ---------- None (changes model attributes) """ self.latent_variables.add_z('Sigma^2 level', fam.Flat(transform='exp'), fam.Normal(0,3))
[ "def", "_create_latent_variables", "(", "self", ")", ":", "self", ".", "latent_variables", ".", "add_z", "(", "'Sigma^2 level'", ",", "fam", ".", "Flat", "(", "transform", "=", "'exp'", ")", ",", "fam", ".", "Normal", "(", "0", ",", "3", ")", ")" ]
Creates model latent variables Returns ---------- None (changes model attributes)
[ "Creates", "model", "latent", "variables" ]
python
train
vicenteneto/python-cartolafc
cartolafc/api.py
https://github.com/vicenteneto/python-cartolafc/blob/15b2a192d7745f454d69a55ac9b7ef7c7abb53b9/cartolafc/api.py#L91-L110
def set_credentials(self, email, password): """ Realiza a autenticação no sistema do CartolaFC utilizando o email e password informados. Args: email (str): O email do usuário password (str): A senha do usuário Raises: cartolafc.CartolaFCError: Se o conjunto ...
[ "def", "set_credentials", "(", "self", ",", "email", ",", "password", ")", ":", "self", ".", "_email", "=", "email", "self", ".", "_password", "=", "password", "response", "=", "requests", ".", "post", "(", "self", ".", "_auth_url", ",", "json", "=", "...
Realiza a autenticação no sistema do CartolaFC utilizando o email e password informados. Args: email (str): O email do usuário password (str): A senha do usuário Raises: cartolafc.CartolaFCError: Se o conjunto (email, password) não conseguiu realizar a autenticação ...
[ "Realiza", "a", "autenticação", "no", "sistema", "do", "CartolaFC", "utilizando", "o", "email", "e", "password", "informados", "." ]
python
train
internetarchive/warc
warc/arc.py
https://github.com/internetarchive/warc/blob/8f05a000a23bbd6501217e37cfd862ffdf19da7f/warc/arc.py#L307-L335
def _read_file_header(self): """Reads out the file header for the arc file. If version was not provided, this will autopopulate it.""" header = self.fileobj.readline() payload1 = self.fileobj.readline() payload2 = self.fileobj.readline() version, reserved, organisation = ...
[ "def", "_read_file_header", "(", "self", ")", ":", "header", "=", "self", ".", "fileobj", ".", "readline", "(", ")", "payload1", "=", "self", ".", "fileobj", ".", "readline", "(", ")", "payload2", "=", "self", ".", "fileobj", ".", "readline", "(", ")",...
Reads out the file header for the arc file. If version was not provided, this will autopopulate it.
[ "Reads", "out", "the", "file", "header", "for", "the", "arc", "file", ".", "If", "version", "was", "not", "provided", "this", "will", "autopopulate", "it", "." ]
python
train
saltstack/salt
salt/states/heat.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/heat.py#L80-L99
def _parse_template(tmpl_str): ''' Parsing template ''' tmpl_str = tmpl_str.strip() if tmpl_str.startswith('{'): tpl = salt.utils.json.loads(tmpl_str) else: try: tpl = salt.utils.yaml.safe_load(tmpl_str) except salt.utils.yaml.YAMLError as exc: rai...
[ "def", "_parse_template", "(", "tmpl_str", ")", ":", "tmpl_str", "=", "tmpl_str", ".", "strip", "(", ")", "if", "tmpl_str", ".", "startswith", "(", "'{'", ")", ":", "tpl", "=", "salt", ".", "utils", ".", "json", ".", "loads", "(", "tmpl_str", ")", "e...
Parsing template
[ "Parsing", "template" ]
python
train
pyviz/holoviews
holoviews/core/boundingregion.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/core/boundingregion.py#L298-L300
def lbrt(self): """Return (left,bottom,right,top) as a tuple.""" return self._left, self._bottom, self._right, self._top
[ "def", "lbrt", "(", "self", ")", ":", "return", "self", ".", "_left", ",", "self", ".", "_bottom", ",", "self", ".", "_right", ",", "self", ".", "_top" ]
Return (left,bottom,right,top) as a tuple.
[ "Return", "(", "left", "bottom", "right", "top", ")", "as", "a", "tuple", "." ]
python
train
miyakogi/wdom
wdom/document.py
https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/document.py#L315-L317
def add_cssfile(self, src: str) -> None: """Add CSS file to load at this document's header.""" self.head.appendChild(Link(rel='stylesheet', href=src))
[ "def", "add_cssfile", "(", "self", ",", "src", ":", "str", ")", "->", "None", ":", "self", ".", "head", ".", "appendChild", "(", "Link", "(", "rel", "=", "'stylesheet'", ",", "href", "=", "src", ")", ")" ]
Add CSS file to load at this document's header.
[ "Add", "CSS", "file", "to", "load", "at", "this", "document", "s", "header", "." ]
python
train
amcat/nlpipe
nlpipe/modules/frog.py
https://github.com/amcat/nlpipe/blob/e9dcf0214d5dc6ba3900b8d7359909e1e33f1ce7/nlpipe/modules/frog.py#L48-L63
def call_frog(text): """ Call frog on the text and return (sent, offset, word, lemma, pos, morphofeat) tuples """ host, port = os.environ.get('FROG_HOST', 'localhost:9887').split(":") frogclient = FrogClient(host, port, returnall=True) sent = 1 offset = 0 for word, lemma, morph, mor...
[ "def", "call_frog", "(", "text", ")", ":", "host", ",", "port", "=", "os", ".", "environ", ".", "get", "(", "'FROG_HOST'", ",", "'localhost:9887'", ")", ".", "split", "(", "\":\"", ")", "frogclient", "=", "FrogClient", "(", "host", ",", "port", ",", ...
Call frog on the text and return (sent, offset, word, lemma, pos, morphofeat) tuples
[ "Call", "frog", "on", "the", "text", "and", "return", "(", "sent", "offset", "word", "lemma", "pos", "morphofeat", ")", "tuples" ]
python
train
chop-dbhi/varify-data-warehouse
vdw/pipeline/checks.py
https://github.com/chop-dbhi/varify-data-warehouse/blob/1600ee1bc5fae6c68fd03b23624467298570cca8/vdw/pipeline/checks.py#L4-L16
def record_is_valid(record): "Checks if a record is valid for processing." # No random contigs if record.CHROM.startswith('GL'): return False # Skip results with a read depth < 5. If no read depth is specified then # we have no choice but to consider this record as being valid. if 'DP'...
[ "def", "record_is_valid", "(", "record", ")", ":", "# No random contigs", "if", "record", ".", "CHROM", ".", "startswith", "(", "'GL'", ")", ":", "return", "False", "# Skip results with a read depth < 5. If no read depth is specified then", "# we have no choice but to conside...
Checks if a record is valid for processing.
[ "Checks", "if", "a", "record", "is", "valid", "for", "processing", "." ]
python
train
chrisspen/burlap
burlap/dj.py
https://github.com/chrisspen/burlap/blob/a92b0a8e5206850bb777c74af8421ea8b33779bd/burlap/dj.py#L258-L365
def install_sql(self, site=None, database='default', apps=None, stop_on_error=0, fn=None): """ Installs all custom SQL. """ #from burlap.db import load_db_set stop_on_error = int(stop_on_error) site = site or ALL name = database r = self.local_renderer...
[ "def", "install_sql", "(", "self", ",", "site", "=", "None", ",", "database", "=", "'default'", ",", "apps", "=", "None", ",", "stop_on_error", "=", "0", ",", "fn", "=", "None", ")", ":", "#from burlap.db import load_db_set", "stop_on_error", "=", "int", "...
Installs all custom SQL.
[ "Installs", "all", "custom", "SQL", "." ]
python
valid
contentful/contentful.py
contentful/client.py
https://github.com/contentful/contentful.py/blob/73fe01d6ae5a1f8818880da65199107b584681dd/contentful/client.py#L259-L279
def asset(self, asset_id, query=None): """Fetches an Asset by ID. API Reference: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/assets/asset/get-a-single-asset :param asset_id: The ID of the target Asset. :param query: (optional) Dict with API op...
[ "def", "asset", "(", "self", ",", "asset_id", ",", "query", "=", "None", ")", ":", "return", "self", ".", "_get", "(", "self", ".", "environment_url", "(", "'/assets/{0}'", ".", "format", "(", "asset_id", ")", ")", ",", "query", ")" ]
Fetches an Asset by ID. API Reference: https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/assets/asset/get-a-single-asset :param asset_id: The ID of the target Asset. :param query: (optional) Dict with API options. :return: :class:`Asset <Asset>` obj...
[ "Fetches", "an", "Asset", "by", "ID", "." ]
python
train
JarryShaw/PyPCAPKit
src/protocols/internet/hip.py
https://github.com/JarryShaw/PyPCAPKit/blob/c7f0da9aebc2cf210bf8f8b912f7d3cbb98ca10e/src/protocols/internet/hip.py#L1600-L1645
def _read_para_esp_transform(self, code, cbit, clen, *, desc, length, version): """Read HIP ESP_TRANSFORM parameter. Structure of HIP ESP_TRANSFORM parameter [RFC 7402]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2...
[ "def", "_read_para_esp_transform", "(", "self", ",", "code", ",", "cbit", ",", "clen", ",", "*", ",", "desc", ",", "length", ",", "version", ")", ":", "if", "clen", "%", "2", "!=", "0", ":", "raise", "ProtocolError", "(", "f'HIPv{version}: [Parano {code}] ...
Read HIP ESP_TRANSFORM parameter. Structure of HIP ESP_TRANSFORM parameter [RFC 7402]: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-...
[ "Read", "HIP", "ESP_TRANSFORM", "parameter", "." ]
python
train
quantopian/zipline
zipline/finance/metrics/tracker.py
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/metrics/tracker.py#L277-L328
def handle_market_close(self, dt, data_portal): """Handles the close of the given day. Parameters ---------- dt : Timestamp The most recently completed simulation datetime. data_portal : DataPortal The current data portal. Returns -------...
[ "def", "handle_market_close", "(", "self", ",", "dt", ",", "data_portal", ")", ":", "completed_session", "=", "self", ".", "_current_session", "if", "self", ".", "emission_rate", "==", "'daily'", ":", "# this method is called for both minutely and daily emissions, but", ...
Handles the close of the given day. Parameters ---------- dt : Timestamp The most recently completed simulation datetime. data_portal : DataPortal The current data portal. Returns ------- A daily perf packet.
[ "Handles", "the", "close", "of", "the", "given", "day", "." ]
python
train
ArangoDB-Community/pyArango
pyArango/collection.py
https://github.com/ArangoDB-Community/pyArango/blob/dd72e5f6c540e5e148943d615ddf7553bb78ce0b/pyArango/collection.py#L664-L675
def validateField(cls, fieldName, value) : """checks if 'value' is valid for field 'fieldName'. If the validation is unsuccessful, raises a SchemaViolation or a ValidationError. for nested dicts ex: {address : { street: xxx} }, fieldName can take the form address.street """ try : ...
[ "def", "validateField", "(", "cls", ",", "fieldName", ",", "value", ")", ":", "try", ":", "valValue", "=", "Collection", ".", "validateField", "(", "fieldName", ",", "value", ")", "except", "SchemaViolation", "as", "e", ":", "if", "fieldName", "==", "\"_fr...
checks if 'value' is valid for field 'fieldName'. If the validation is unsuccessful, raises a SchemaViolation or a ValidationError. for nested dicts ex: {address : { street: xxx} }, fieldName can take the form address.street
[ "checks", "if", "value", "is", "valid", "for", "field", "fieldName", ".", "If", "the", "validation", "is", "unsuccessful", "raises", "a", "SchemaViolation", "or", "a", "ValidationError", ".", "for", "nested", "dicts", "ex", ":", "{", "address", ":", "{", "...
python
train
numenta/nupic
src/nupic/engine/__init__.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/engine/__init__.py#L541-L549
def setParameter(self, paramName, value): """Set parameter value""" (setter, getter) = self._getParameterMethods(paramName) if setter is None: import exceptions raise exceptions.Exception( "setParameter -- parameter name '%s' does not exist in region %s of type %s" % (paramNa...
[ "def", "setParameter", "(", "self", ",", "paramName", ",", "value", ")", ":", "(", "setter", ",", "getter", ")", "=", "self", ".", "_getParameterMethods", "(", "paramName", ")", "if", "setter", "is", "None", ":", "import", "exceptions", "raise", "exception...
Set parameter value
[ "Set", "parameter", "value" ]
python
valid
msuozzo/Aduro
aduro/events.py
https://github.com/msuozzo/Aduro/blob/338eeb1deeff30c198e721b660ae4daca3660911/aduro/events.py#L69-L76
def from_str(string): """Generate a `AddEvent` object from a string """ match = re.match(r'^ADD (\w+)$', string) if match: return AddEvent(match.group(1)) else: raise EventParseError
[ "def", "from_str", "(", "string", ")", ":", "match", "=", "re", ".", "match", "(", "r'^ADD (\\w+)$'", ",", "string", ")", "if", "match", ":", "return", "AddEvent", "(", "match", ".", "group", "(", "1", ")", ")", "else", ":", "raise", "EventParseError" ...
Generate a `AddEvent` object from a string
[ "Generate", "a", "AddEvent", "object", "from", "a", "string" ]
python
train
andrewda/frc-livescore
livescore/simpleocr_utils/processor.py
https://github.com/andrewda/frc-livescore/blob/71594cd6d2c8b6c5feb3889bb05552d09b8128b1/livescore/simpleocr_utils/processor.py#L66-L71
def get_parameters(self): """returns a dictionary with the processor's stored parameters""" parameter_names = self.PARAMETERS.keys() # TODO: Unresolved reference for processor parameter_values = [getattr(processor, n) for n in parameter_names] return dict(zip(parameter_names, par...
[ "def", "get_parameters", "(", "self", ")", ":", "parameter_names", "=", "self", ".", "PARAMETERS", ".", "keys", "(", ")", "# TODO: Unresolved reference for processor", "parameter_values", "=", "[", "getattr", "(", "processor", ",", "n", ")", "for", "n", "in", ...
returns a dictionary with the processor's stored parameters
[ "returns", "a", "dictionary", "with", "the", "processor", "s", "stored", "parameters" ]
python
train
jorgenschaefer/elpy
elpy/server.py
https://github.com/jorgenschaefer/elpy/blob/ffd982f829b11e53f2be187c7b770423341f29bc/elpy/server.py#L109-L114
def rpc_get_definition(self, filename, source, offset): """Get the location of the definition for the symbol at the offset. """ return self._call_backend("rpc_get_definition", None, filename, get_source(source), offset)
[ "def", "rpc_get_definition", "(", "self", ",", "filename", ",", "source", ",", "offset", ")", ":", "return", "self", ".", "_call_backend", "(", "\"rpc_get_definition\"", ",", "None", ",", "filename", ",", "get_source", "(", "source", ")", ",", "offset", ")" ...
Get the location of the definition for the symbol at the offset.
[ "Get", "the", "location", "of", "the", "definition", "for", "the", "symbol", "at", "the", "offset", "." ]
python
train
DataDog/integrations-core
spark/datadog_checks/spark/spark.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/spark/datadog_checks/spark/spark.py#L693-L711
def _rest_request_to_json(self, address, object_path, service_name, requests_config, tags, *args, **kwargs): """ Query the given URL and return the JSON response """ response = self._rest_request(address, object_path, service_name, requests_config, tags, *args, **kwargs) try: ...
[ "def", "_rest_request_to_json", "(", "self", ",", "address", ",", "object_path", ",", "service_name", ",", "requests_config", ",", "tags", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "response", "=", "self", ".", "_rest_request", "(", "address", "...
Query the given URL and return the JSON response
[ "Query", "the", "given", "URL", "and", "return", "the", "JSON", "response" ]
python
train
HttpRunner/HttpRunner
httprunner/report.py
https://github.com/HttpRunner/HttpRunner/blob/f259551bf9c8ba905eae5c1afcf2efea20ae0871/httprunner/report.py#L218-L245
def __expand_meta_datas(meta_datas, meta_datas_expanded): """ expand meta_datas to one level Args: meta_datas (dict/list): maybe in nested format Returns: list: expanded list in one level Examples: >>> meta_datas = [ [ dict1, ...
[ "def", "__expand_meta_datas", "(", "meta_datas", ",", "meta_datas_expanded", ")", ":", "if", "isinstance", "(", "meta_datas", ",", "dict", ")", ":", "meta_datas_expanded", ".", "append", "(", "meta_datas", ")", "elif", "isinstance", "(", "meta_datas", ",", "list...
expand meta_datas to one level Args: meta_datas (dict/list): maybe in nested format Returns: list: expanded list in one level Examples: >>> meta_datas = [ [ dict1, dict2 ], dict3 ] ...
[ "expand", "meta_datas", "to", "one", "level" ]
python
train
siznax/wptools
wptools/page.py
https://github.com/siznax/wptools/blob/100eaea585c34aa9ad87a9eda8982bb4898f6ec9/wptools/page.py#L491-L540
def get(self, show=True, proxy=None, timeout=0): """ Make Mediawiki, RESTBase, and Wikidata requests for page data some sequence of: - get_parse() - get_query() - get_restbase() - get_wikidata() """ wikibase = self.params.get('wikibase') i...
[ "def", "get", "(", "self", ",", "show", "=", "True", ",", "proxy", "=", "None", ",", "timeout", "=", "0", ")", ":", "wikibase", "=", "self", ".", "params", ".", "get", "(", "'wikibase'", ")", "if", "wikibase", ":", "self", ".", "flags", "[", "'de...
Make Mediawiki, RESTBase, and Wikidata requests for page data some sequence of: - get_parse() - get_query() - get_restbase() - get_wikidata()
[ "Make", "Mediawiki", "RESTBase", "and", "Wikidata", "requests", "for", "page", "data", "some", "sequence", "of", ":", "-", "get_parse", "()", "-", "get_query", "()", "-", "get_restbase", "()", "-", "get_wikidata", "()" ]
python
train
openstack/horizon
openstack_auth/user.py
https://github.com/openstack/horizon/blob/5601ea9477323e599d9b766fcac1f8be742935b2/openstack_auth/user.py#L344-L357
def has_a_matching_perm(self, perm_list, obj=None): """Returns True if the user has one of the specified permissions. If object is passed, it checks if the user has any of the required perms for this object. """ # If there are no permissions to check, just return true if...
[ "def", "has_a_matching_perm", "(", "self", ",", "perm_list", ",", "obj", "=", "None", ")", ":", "# If there are no permissions to check, just return true", "if", "not", "perm_list", ":", "return", "True", "# Check that user has at least one of the required permissions.", "for...
Returns True if the user has one of the specified permissions. If object is passed, it checks if the user has any of the required perms for this object.
[ "Returns", "True", "if", "the", "user", "has", "one", "of", "the", "specified", "permissions", "." ]
python
train
mdorn/pyinstapaper
pyinstapaper/instapaper.py
https://github.com/mdorn/pyinstapaper/blob/94f5f61ccd07079ba3967f788c555aea1a81cca5/pyinstapaper/instapaper.py#L34-L52
def login(self, username, password): '''Authenticate using XAuth variant of OAuth. :param str username: Username or email address for the relevant account :param str password: Password for the account ''' response = self.request( ACCESS_TOKEN, { ...
[ "def", "login", "(", "self", ",", "username", ",", "password", ")", ":", "response", "=", "self", ".", "request", "(", "ACCESS_TOKEN", ",", "{", "'x_auth_mode'", ":", "'client_auth'", ",", "'x_auth_username'", ":", "username", ",", "'x_auth_password'", ":", ...
Authenticate using XAuth variant of OAuth. :param str username: Username or email address for the relevant account :param str password: Password for the account
[ "Authenticate", "using", "XAuth", "variant", "of", "OAuth", "." ]
python
train
planetlabs/planet-client-python
planet/api/client.py
https://github.com/planetlabs/planet-client-python/blob/1c62ce7d416819951dddee0c22068fef6d40b027/planet/api/client.py#L283-L292
def get_mosaic_by_name(self, name): '''Get the API representation of a mosaic by name. :param name str: The name of the mosaic :returns: :py:Class:`planet.api.models.Mosaics` :raises planet.api.exceptions.APIException: On API error. ''' params = {'name__is': name} ...
[ "def", "get_mosaic_by_name", "(", "self", ",", "name", ")", ":", "params", "=", "{", "'name__is'", ":", "name", "}", "url", "=", "self", ".", "_url", "(", "'basemaps/v1/mosaics'", ")", "return", "self", ".", "_get", "(", "url", ",", "models", ".", "Mos...
Get the API representation of a mosaic by name. :param name str: The name of the mosaic :returns: :py:Class:`planet.api.models.Mosaics` :raises planet.api.exceptions.APIException: On API error.
[ "Get", "the", "API", "representation", "of", "a", "mosaic", "by", "name", "." ]
python
train
rbuffat/pyepw
pyepw/epw.py
https://github.com/rbuffat/pyepw/blob/373d4d3c8386c8d35789f086ac5f6018c2711745/pyepw/epw.py#L2791-L2811
def ws050(self, value=None): """ Corresponds to IDD Field `ws050` Wind speed corresponding 5.0% annual cumulative frequency of occurrence Args: value (float): value for IDD Field `ws050` Unit: m/s if `value` is None it will not be checked against the...
[ "def", "ws050", "(", "self", ",", "value", "=", "None", ")", ":", "if", "value", "is", "not", "None", ":", "try", ":", "value", "=", "float", "(", "value", ")", "except", "ValueError", ":", "raise", "ValueError", "(", "'value {} need to be of type float '"...
Corresponds to IDD Field `ws050` Wind speed corresponding 5.0% annual cumulative frequency of occurrence Args: value (float): value for IDD Field `ws050` Unit: m/s if `value` is None it will not be checked against the specification and is assu...
[ "Corresponds", "to", "IDD", "Field", "ws050", "Wind", "speed", "corresponding", "5", ".", "0%", "annual", "cumulative", "frequency", "of", "occurrence" ]
python
train
NYUCCL/psiTurk
psiturk/experiment.py
https://github.com/NYUCCL/psiTurk/blob/7170b992a0b5f56c165929cf87b3d3a1f3336c36/psiturk/experiment.py#L128-L176
def get_random_condcount(mode): """ HITs can be in one of three states: - jobs that are finished - jobs that are started but not finished - jobs that are never going to finish (user decided not to do it) Our count should be based on the first two, so we count any tasks finished o...
[ "def", "get_random_condcount", "(", "mode", ")", ":", "cutofftime", "=", "datetime", ".", "timedelta", "(", "minutes", "=", "-", "CONFIG", ".", "getint", "(", "'Server Parameters'", ",", "'cutoff_time'", ")", ")", "starttime", "=", "datetime", ".", "datetime",...
HITs can be in one of three states: - jobs that are finished - jobs that are started but not finished - jobs that are never going to finish (user decided not to do it) Our count should be based on the first two, so we count any tasks finished or any tasks not finished that were started i...
[ "HITs", "can", "be", "in", "one", "of", "three", "states", ":", "-", "jobs", "that", "are", "finished", "-", "jobs", "that", "are", "started", "but", "not", "finished", "-", "jobs", "that", "are", "never", "going", "to", "finish", "(", "user", "decided...
python
train
nicolargo/glances
glances/amps/glances_amp.py
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/amps/glances_amp.py#L179-L186
def set_result(self, result, separator=''): """Store the result (string) into the result key of the AMP if one_line is true then replace \n by separator """ if self.one_line(): self.configs['result'] = str(result).replace('\n', separator) else: self.config...
[ "def", "set_result", "(", "self", ",", "result", ",", "separator", "=", "''", ")", ":", "if", "self", ".", "one_line", "(", ")", ":", "self", ".", "configs", "[", "'result'", "]", "=", "str", "(", "result", ")", ".", "replace", "(", "'\\n'", ",", ...
Store the result (string) into the result key of the AMP if one_line is true then replace \n by separator
[ "Store", "the", "result", "(", "string", ")", "into", "the", "result", "key", "of", "the", "AMP", "if", "one_line", "is", "true", "then", "replace", "\\", "n", "by", "separator" ]
python
train
ARMmbed/autoversion
src/auto_version/auto_version_tool.py
https://github.com/ARMmbed/autoversion/blob/c5b127d2059c8219f5637fe45bf9e1be3a0af2aa/src/auto_version/auto_version_tool.py#L98-L108
def detect_file_triggers(trigger_patterns): """The existence of files matching configured globs will trigger a version bump""" triggers = set() for trigger, pattern in trigger_patterns.items(): matches = glob.glob(pattern) if matches: _LOG.debug("trigger: %s bump from %r\n\t%s", ...
[ "def", "detect_file_triggers", "(", "trigger_patterns", ")", ":", "triggers", "=", "set", "(", ")", "for", "trigger", ",", "pattern", "in", "trigger_patterns", ".", "items", "(", ")", ":", "matches", "=", "glob", ".", "glob", "(", "pattern", ")", "if", "...
The existence of files matching configured globs will trigger a version bump
[ "The", "existence", "of", "files", "matching", "configured", "globs", "will", "trigger", "a", "version", "bump" ]
python
train
ValvePython/steam
steam/client/user.py
https://github.com/ValvePython/steam/blob/2de1364c47598410b572114e6129eab8fff71d5b/steam/client/user.py#L85-L107
def get_avatar_url(self, size=2): """Get URL to avatar picture :param size: possible values are ``0``, ``1``, or ``2`` corresponding to small, medium, large :type size: :class:`int` :return: url to avatar :rtype: :class:`str` """ hashbytes = self.get_ps('avatar_h...
[ "def", "get_avatar_url", "(", "self", ",", "size", "=", "2", ")", ":", "hashbytes", "=", "self", ".", "get_ps", "(", "'avatar_hash'", ")", "if", "hashbytes", "!=", "\"\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\\000\"", ...
Get URL to avatar picture :param size: possible values are ``0``, ``1``, or ``2`` corresponding to small, medium, large :type size: :class:`int` :return: url to avatar :rtype: :class:`str`
[ "Get", "URL", "to", "avatar", "picture" ]
python
train
Contraz/demosys-py
demosys/loaders/data/text.py
https://github.com/Contraz/demosys-py/blob/6466128a3029c4d09631420ccce73024025bd5b6/demosys/loaders/data/text.py#L8-L18
def load(self): """Load a file in text mode""" self.meta.resolved_path = self.find_data(self.meta.path) if not self.meta.resolved_path: raise ImproperlyConfigured("Data file '{}' not found".format(self.meta.path)) print("Loading:", self.meta.path) with ope...
[ "def", "load", "(", "self", ")", ":", "self", ".", "meta", ".", "resolved_path", "=", "self", ".", "find_data", "(", "self", ".", "meta", ".", "path", ")", "if", "not", "self", ".", "meta", ".", "resolved_path", ":", "raise", "ImproperlyConfigured", "(...
Load a file in text mode
[ "Load", "a", "file", "in", "text", "mode" ]
python
valid
ejeschke/ginga
ginga/misc/Bunch.py
https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/misc/Bunch.py#L497-L506
def get(self, key, alt=None): """If dictionary contains _key_ return the associated value, otherwise return _alt_. """ with self.lock: if key in self: return self.getitem(key) else: return alt
[ "def", "get", "(", "self", ",", "key", ",", "alt", "=", "None", ")", ":", "with", "self", ".", "lock", ":", "if", "key", "in", "self", ":", "return", "self", ".", "getitem", "(", "key", ")", "else", ":", "return", "alt" ]
If dictionary contains _key_ return the associated value, otherwise return _alt_.
[ "If", "dictionary", "contains", "_key_", "return", "the", "associated", "value", "otherwise", "return", "_alt_", "." ]
python
train
spyder-ide/conda-manager
conda_manager/api/conda_api.py
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/conda_api.py#L440-L448
def info(self, abspath=True): """ Return a dictionary with configuration information. No guarantee is made about which keys exist. Therefore this function should only be used for testing and debugging. """ logger.debug(str('')) return self._call_and_parse(['info...
[ "def", "info", "(", "self", ",", "abspath", "=", "True", ")", ":", "logger", ".", "debug", "(", "str", "(", "''", ")", ")", "return", "self", ".", "_call_and_parse", "(", "[", "'info'", ",", "'--json'", "]", ",", "abspath", "=", "abspath", ")" ]
Return a dictionary with configuration information. No guarantee is made about which keys exist. Therefore this function should only be used for testing and debugging.
[ "Return", "a", "dictionary", "with", "configuration", "information", "." ]
python
train
nicolargo/glances
glances/password.py
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/password.py#L49-L51
def get_hash(self, salt, plain_password): """Return the hashed password, salt + SHA-256.""" return hashlib.sha256(salt.encode() + plain_password.encode()).hexdigest()
[ "def", "get_hash", "(", "self", ",", "salt", ",", "plain_password", ")", ":", "return", "hashlib", ".", "sha256", "(", "salt", ".", "encode", "(", ")", "+", "plain_password", ".", "encode", "(", ")", ")", ".", "hexdigest", "(", ")" ]
Return the hashed password, salt + SHA-256.
[ "Return", "the", "hashed", "password", "salt", "+", "SHA", "-", "256", "." ]
python
train
SavinaRoja/OpenAccess_EPUB
src/openaccess_epub/utils/images.py
https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/images.py#L19-L34
def move_images_to_cache(source, destination): """ Handles the movement of images to the cache. Must be helpful if it finds that the folder for this article already exists. """ if os.path.isdir(destination): log.debug('Cached images for this article already exist') return else: ...
[ "def", "move_images_to_cache", "(", "source", ",", "destination", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "destination", ")", ":", "log", ".", "debug", "(", "'Cached images for this article already exist'", ")", "return", "else", ":", "log", ".",...
Handles the movement of images to the cache. Must be helpful if it finds that the folder for this article already exists.
[ "Handles", "the", "movement", "of", "images", "to", "the", "cache", ".", "Must", "be", "helpful", "if", "it", "finds", "that", "the", "folder", "for", "this", "article", "already", "exists", "." ]
python
train
josiah-wolf-oberholtzer/uqbar
uqbar/cli/CLIAggregator.py
https://github.com/josiah-wolf-oberholtzer/uqbar/blob/eca7fefebbbee1e2ae13bf5d6baa838be66b1db6/uqbar/cli/CLIAggregator.py#L160-L213
def cli_aliases(self): r"""Developer script aliases. """ scripting_groups = [] aliases = {} for cli_class in self.cli_classes: instance = cli_class() if getattr(instance, "alias", None): scripting_group = getattr(instance, "scripting_group"...
[ "def", "cli_aliases", "(", "self", ")", ":", "scripting_groups", "=", "[", "]", "aliases", "=", "{", "}", "for", "cli_class", "in", "self", ".", "cli_classes", ":", "instance", "=", "cli_class", "(", ")", "if", "getattr", "(", "instance", ",", "\"alias\"...
r"""Developer script aliases.
[ "r", "Developer", "script", "aliases", "." ]
python
train
d0c-s4vage/pfp
pfp/interp.py
https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L1771-L1819
def _handle_assignment(self, node, scope, ctxt, stream): """Handle assignment nodes :node: TODO :scope: TODO :ctxt: TODO :stream: TODO :returns: TODO """ def add_op(x,y): x += y def sub_op(x,y): x -= y def div_op(x,y): x /= y def ...
[ "def", "_handle_assignment", "(", "self", ",", "node", ",", "scope", ",", "ctxt", ",", "stream", ")", ":", "def", "add_op", "(", "x", ",", "y", ")", ":", "x", "+=", "y", "def", "sub_op", "(", "x", ",", "y", ")", ":", "x", "-=", "y", "def", "d...
Handle assignment nodes :node: TODO :scope: TODO :ctxt: TODO :stream: TODO :returns: TODO
[ "Handle", "assignment", "nodes" ]
python
train
serkanyersen/underscore.py
src/underscore.py
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L300-L312
def invoke(self, method, *args): """ Invoke a method (with arguments) on every item in a collection. """ def inv(value, *ar): if ( _(method).isFunction() or _(method).isLambda() or _(method).isMethod() ): ret...
[ "def", "invoke", "(", "self", ",", "method", ",", "*", "args", ")", ":", "def", "inv", "(", "value", ",", "*", "ar", ")", ":", "if", "(", "_", "(", "method", ")", ".", "isFunction", "(", ")", "or", "_", "(", "method", ")", ".", "isLambda", "(...
Invoke a method (with arguments) on every item in a collection.
[ "Invoke", "a", "method", "(", "with", "arguments", ")", "on", "every", "item", "in", "a", "collection", "." ]
python
train
internetarchive/brozzler
brozzler/__init__.py
https://github.com/internetarchive/brozzler/blob/411b3f266a38b9bb942021c0121ebd8e5ca66447/brozzler/__init__.py#L174-L202
def thread_exception_gate(thread=None): ''' Returns a `ThreadExceptionGate` for `thread` (current thread by default). `ThreadExceptionGate` is a context manager which allows exceptions to be raised from threads other than the current one, by way of `thread_raise`. Example: try: ...
[ "def", "thread_exception_gate", "(", "thread", "=", "None", ")", ":", "if", "not", "thread", ":", "thread", "=", "threading", ".", "current_thread", "(", ")", "with", "_thread_exception_gates_lock", ":", "if", "not", "thread", "in", "_thread_exception_gates", ":...
Returns a `ThreadExceptionGate` for `thread` (current thread by default). `ThreadExceptionGate` is a context manager which allows exceptions to be raised from threads other than the current one, by way of `thread_raise`. Example: try: with thread_exception_gate(): # do...
[ "Returns", "a", "ThreadExceptionGate", "for", "thread", "(", "current", "thread", "by", "default", ")", "." ]
python
train
senaite/senaite.core
bika/lims/browser/reports/productivity_analysesperclient.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/reports/productivity_analysesperclient.py#L128-L137
def add_filter_by_date(self, query, out_params): """Applies the filter by Requested date to the search query """ date_query = formatDateQuery(self.context, 'Requested') if date_query: query['created'] = date_query requested = formatDateParms(self.context, 'Request...
[ "def", "add_filter_by_date", "(", "self", ",", "query", ",", "out_params", ")", ":", "date_query", "=", "formatDateQuery", "(", "self", ".", "context", ",", "'Requested'", ")", "if", "date_query", ":", "query", "[", "'created'", "]", "=", "date_query", "requ...
Applies the filter by Requested date to the search query
[ "Applies", "the", "filter", "by", "Requested", "date", "to", "the", "search", "query" ]
python
train
ngmarchant/oasis
oasis/kad.py
https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/kad.py#L105-L131
def _sample_item(self, **kwargs): """Sample an item from the pool according to the instrumental distribution """ t = self.t_ if 'fixed_stratum' in kwargs: stratum_idx = kwargs['fixed_stratum'] else: stratum_idx = None if stratum_idx is not ...
[ "def", "_sample_item", "(", "self", ",", "*", "*", "kwargs", ")", ":", "t", "=", "self", ".", "t_", "if", "'fixed_stratum'", "in", "kwargs", ":", "stratum_idx", "=", "kwargs", "[", "'fixed_stratum'", "]", "else", ":", "stratum_idx", "=", "None", "if", ...
Sample an item from the pool according to the instrumental distribution
[ "Sample", "an", "item", "from", "the", "pool", "according", "to", "the", "instrumental", "distribution" ]
python
train
mcieslik-mctp/papy
src/papy/core.py
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L925-L974
def start(self, stages=None): """ Makes the ``Piper`` ready to return results. This involves starting the the provided ``NuMap`` instance. If multiple ``Pipers`` share a ``NuMap`` instance the order in which these ``Pipers`` are started is important. The valid order is upstrea...
[ "def", "start", "(", "self", ",", "stages", "=", "None", ")", ":", "# defaults differ linear vs. parallel", "stages", "=", "stages", "or", "(", "(", "0", ",", ")", "if", "self", ".", "imap", "is", "imap", "else", "(", "0", ",", "1", ",", "2", ")", ...
Makes the ``Piper`` ready to return results. This involves starting the the provided ``NuMap`` instance. If multiple ``Pipers`` share a ``NuMap`` instance the order in which these ``Pipers`` are started is important. The valid order is upstream before downstream. The ``NuMap`` instan...
[ "Makes", "the", "Piper", "ready", "to", "return", "results", ".", "This", "involves", "starting", "the", "the", "provided", "NuMap", "instance", ".", "If", "multiple", "Pipers", "share", "a", "NuMap", "instance", "the", "order", "in", "which", "these", "Pipe...
python
train
avanwyk/cipy
cipy/algorithms/pso/functions.py
https://github.com/avanwyk/cipy/blob/98450dd01767b3615c113e50dc396f135e177b29/cipy/algorithms/pso/functions.py#L123-L138
def initialize_particle(rng, domain, fitness_function): """ Initializes a particle within a domain. Args: rng: numpy.random.RandomState: The random number generator. domain: cipy.problems.core.Domain: The domain of the problem. Returns: cipy.algorithms.pso.Particle: A new, fully ini...
[ "def", "initialize_particle", "(", "rng", ",", "domain", ",", "fitness_function", ")", ":", "position", "=", "rng", ".", "uniform", "(", "domain", ".", "lower", ",", "domain", ".", "upper", ",", "domain", ".", "dimension", ")", "fitness", "=", "fitness_fun...
Initializes a particle within a domain. Args: rng: numpy.random.RandomState: The random number generator. domain: cipy.problems.core.Domain: The domain of the problem. Returns: cipy.algorithms.pso.Particle: A new, fully initialized particle.
[ "Initializes", "a", "particle", "within", "a", "domain", ".", "Args", ":", "rng", ":", "numpy", ".", "random", ".", "RandomState", ":", "The", "random", "number", "generator", ".", "domain", ":", "cipy", ".", "problems", ".", "core", ".", "Domain", ":", ...
python
train