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
openspending/babbage
babbage/cube.py
https://github.com/openspending/babbage/blob/9e03efe62e0be0cceabafd4de2a09cb8ec794b92/babbage/cube.py#L182-L188
def compute_cardinalities(self): """ This will count the number of distinct values for each dimension in the dataset and add that count to the model so that it can be used as a hint by UI components. """ for dimension in self.model.dimensions: result = self.members(dimension....
[ "def", "compute_cardinalities", "(", "self", ")", ":", "for", "dimension", "in", "self", ".", "model", ".", "dimensions", ":", "result", "=", "self", ".", "members", "(", "dimension", ".", "ref", ",", "page_size", "=", "0", ")", "dimension", ".", "spec",...
This will count the number of distinct values for each dimension in the dataset and add that count to the model so that it can be used as a hint by UI components.
[ "This", "will", "count", "the", "number", "of", "distinct", "values", "for", "each", "dimension", "in", "the", "dataset", "and", "add", "that", "count", "to", "the", "model", "so", "that", "it", "can", "be", "used", "as", "a", "hint", "by", "UI", "comp...
python
train
linkedin/naarad
src/naarad/__init__.py
https://github.com/linkedin/naarad/blob/261e2c0760fd6a6b0ee59064180bd8e3674311fe/src/naarad/__init__.py#L224-L266
def analyze(self, input_directory, output_directory, **kwargs): """ Run all the analysis saved in self._analyses, sorted by test_id. This is useful when Naarad() is used by other programs and multiple analyses are run In naarad CLI mode, len(_analyses) == 1 :param: input_directory: location of log f...
[ "def", "analyze", "(", "self", ",", "input_directory", ",", "output_directory", ",", "*", "*", "kwargs", ")", ":", "is_api_call", "=", "True", "if", "len", "(", "self", ".", "_analyses", ")", "==", "0", ":", "if", "'config'", "not", "in", "kwargs", "."...
Run all the analysis saved in self._analyses, sorted by test_id. This is useful when Naarad() is used by other programs and multiple analyses are run In naarad CLI mode, len(_analyses) == 1 :param: input_directory: location of log files :param: output_directory: root directory for analysis output :p...
[ "Run", "all", "the", "analysis", "saved", "in", "self", ".", "_analyses", "sorted", "by", "test_id", ".", "This", "is", "useful", "when", "Naarad", "()", "is", "used", "by", "other", "programs", "and", "multiple", "analyses", "are", "run", "In", "naarad", ...
python
valid
spyder-ide/spyder
spyder/app/mainwindow.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L2874-L2902
def edit_preferences(self): """Edit Spyder preferences""" from spyder.preferences.configdialog import ConfigDialog dlg = ConfigDialog(self) dlg.size_change.connect(self.set_prefs_size) if self.prefs_dialog_size is not None: dlg.resize(self.prefs_dialog_size) ...
[ "def", "edit_preferences", "(", "self", ")", ":", "from", "spyder", ".", "preferences", ".", "configdialog", "import", "ConfigDialog", "dlg", "=", "ConfigDialog", "(", "self", ")", "dlg", ".", "size_change", ".", "connect", "(", "self", ".", "set_prefs_size", ...
Edit Spyder preferences
[ "Edit", "Spyder", "preferences" ]
python
train
Unidata/siphon
siphon/ncss.py
https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/ncss.py#L334-L345
def combine_xml_points(l, units, handle_units): """Combine multiple Point tags into an array.""" ret = {} for item in l: for key, value in item.items(): ret.setdefault(key, []).append(value) for key, value in ret.items(): if key != 'date': ret[key] = handle_units...
[ "def", "combine_xml_points", "(", "l", ",", "units", ",", "handle_units", ")", ":", "ret", "=", "{", "}", "for", "item", "in", "l", ":", "for", "key", ",", "value", "in", "item", ".", "items", "(", ")", ":", "ret", ".", "setdefault", "(", "key", ...
Combine multiple Point tags into an array.
[ "Combine", "multiple", "Point", "tags", "into", "an", "array", "." ]
python
train
dev-pipeline/dev-pipeline-core
lib/devpipeline_core/env.py
https://github.com/dev-pipeline/dev-pipeline-core/blob/fa40c050a56202485070b0300bb8695e9388c34f/lib/devpipeline_core/env.py#L41-L55
def create_environment(component_config): """ Create a modified environment. Arguments component_config - The configuration for a component. """ ret = os.environ.copy() for env in component_config.get_list("dp.env_list"): real_env = env.upper() value = os.environ.get(real_en...
[ "def", "create_environment", "(", "component_config", ")", ":", "ret", "=", "os", ".", "environ", ".", "copy", "(", ")", "for", "env", "in", "component_config", ".", "get_list", "(", "\"dp.env_list\"", ")", ":", "real_env", "=", "env", ".", "upper", "(", ...
Create a modified environment. Arguments component_config - The configuration for a component.
[ "Create", "a", "modified", "environment", "." ]
python
train
appknox/google-chartwrapper
GChartWrapper/GChart.py
https://github.com/appknox/google-chartwrapper/blob/3769aecbef6c83b6cd93ee72ece478ffe433ac57/GChartWrapper/GChart.py#L396-L406
def label(self, *args): """ Add a simple label to your chart call each time for each dataset APIPARAM: chl """ if self['cht'] == 'qr': self['chl'] = ''.join(map(str,args)) else: self['chl'] = '|'.join(map(str,args)) return self
[ "def", "label", "(", "self", ",", "*", "args", ")", ":", "if", "self", "[", "'cht'", "]", "==", "'qr'", ":", "self", "[", "'chl'", "]", "=", "''", ".", "join", "(", "map", "(", "str", ",", "args", ")", ")", "else", ":", "self", "[", "'chl'", ...
Add a simple label to your chart call each time for each dataset APIPARAM: chl
[ "Add", "a", "simple", "label", "to", "your", "chart", "call", "each", "time", "for", "each", "dataset", "APIPARAM", ":", "chl" ]
python
test
rstoneback/pysat
pysat/instruments/nasa_cdaweb_methods.py
https://github.com/rstoneback/pysat/blob/4ae1afd80e15e4449397d39dce8c3e969c32c422/pysat/instruments/nasa_cdaweb_methods.py#L15-L85
def list_files(tag=None, sat_id=None, data_path=None, format_str=None, supported_tags=None, fake_daily_files_from_monthly=False, two_digit_year_break=None): """Return a Pandas Series of every file for chosen satellite data. This routine is intended to be used by pysat instrume...
[ "def", "list_files", "(", "tag", "=", "None", ",", "sat_id", "=", "None", ",", "data_path", "=", "None", ",", "format_str", "=", "None", ",", "supported_tags", "=", "None", ",", "fake_daily_files_from_monthly", "=", "False", ",", "two_digit_year_break", "=", ...
Return a Pandas Series of every file for chosen satellite data. This routine is intended to be used by pysat instrument modules supporting a particular NASA CDAWeb dataset. Parameters ----------- tag : (string or NoneType) Denotes type of file to load. Accepted types are <tag strings>...
[ "Return", "a", "Pandas", "Series", "of", "every", "file", "for", "chosen", "satellite", "data", ".", "This", "routine", "is", "intended", "to", "be", "used", "by", "pysat", "instrument", "modules", "supporting", "a", "particular", "NASA", "CDAWeb", "dataset", ...
python
train
saltstack/salt
salt/utils/aggregation.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/aggregation.py#L188-L199
def mark(obj, map_class=Map, sequence_class=Sequence): ''' Convert obj into an Aggregate instance ''' if isinstance(obj, Aggregate): return obj if isinstance(obj, dict): return map_class(obj) if isinstance(obj, (list, tuple, set)): return sequence_class(obj) else: ...
[ "def", "mark", "(", "obj", ",", "map_class", "=", "Map", ",", "sequence_class", "=", "Sequence", ")", ":", "if", "isinstance", "(", "obj", ",", "Aggregate", ")", ":", "return", "obj", "if", "isinstance", "(", "obj", ",", "dict", ")", ":", "return", "...
Convert obj into an Aggregate instance
[ "Convert", "obj", "into", "an", "Aggregate", "instance" ]
python
train
djgagne/hagelslag
hagelslag/evaluation/ProbabilityMetrics.py
https://github.com/djgagne/hagelslag/blob/6fb6c3df90bf4867e13a97d3460b14471d107df1/hagelslag/evaluation/ProbabilityMetrics.py#L148-L153
def auc(self): """ Calculate the Area Under the ROC Curve (AUC). """ roc_curve = self.roc_curve() return np.abs(np.trapz(roc_curve['POD'], x=roc_curve['POFD']))
[ "def", "auc", "(", "self", ")", ":", "roc_curve", "=", "self", ".", "roc_curve", "(", ")", "return", "np", ".", "abs", "(", "np", ".", "trapz", "(", "roc_curve", "[", "'POD'", "]", ",", "x", "=", "roc_curve", "[", "'POFD'", "]", ")", ")" ]
Calculate the Area Under the ROC Curve (AUC).
[ "Calculate", "the", "Area", "Under", "the", "ROC", "Curve", "(", "AUC", ")", "." ]
python
train
artefactual-labs/mets-reader-writer
metsrw/fsentry.py
https://github.com/artefactual-labs/mets-reader-writer/blob/d95939cabdfdc25cb1bf67df0c84bd0d6e6a73ff/metsrw/fsentry.py#L210-L220
def group_id(self): """ Returns the @GROUPID. If derived_from is set, returns that group_id. """ if self.derived_from is not None: return self.derived_from.group_id() if self.file_uuid is None: return None return utils.GROUP_ID_PREFIX + se...
[ "def", "group_id", "(", "self", ")", ":", "if", "self", ".", "derived_from", "is", "not", "None", ":", "return", "self", ".", "derived_from", ".", "group_id", "(", ")", "if", "self", ".", "file_uuid", "is", "None", ":", "return", "None", "return", "uti...
Returns the @GROUPID. If derived_from is set, returns that group_id.
[ "Returns", "the", "@GROUPID", "." ]
python
train
apache/incubator-mxnet
python/mxnet/gluon/trainer.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/trainer.py#L272-L286
def _row_sparse_pull(self, parameter, out, row_id, full_idx=False): """Internal method to invoke pull operations on KVStore. If `full_idx` is set to True, `kv.pull` is preferred instead of `kv.row_sparse_pull`. """ # initialize kv and params if not already if not self._kv_initial...
[ "def", "_row_sparse_pull", "(", "self", ",", "parameter", ",", "out", ",", "row_id", ",", "full_idx", "=", "False", ")", ":", "# initialize kv and params if not already", "if", "not", "self", ".", "_kv_initialized", ":", "self", ".", "_init_kvstore", "(", ")", ...
Internal method to invoke pull operations on KVStore. If `full_idx` is set to True, `kv.pull` is preferred instead of `kv.row_sparse_pull`.
[ "Internal", "method", "to", "invoke", "pull", "operations", "on", "KVStore", ".", "If", "full_idx", "is", "set", "to", "True", "kv", ".", "pull", "is", "preferred", "instead", "of", "kv", ".", "row_sparse_pull", "." ]
python
train
pdkit/pdkit
pdkit/utils.py
https://github.com/pdkit/pdkit/blob/c7120263da2071bb139815fbdb56ca77b544f340/pdkit/utils.py#L26-L66
def load_cloudupdrs_data(filename, convert_times=1000000000.0): """ This method loads data in the cloudupdrs format Usually the data will be saved in a csv file and it should look like this: .. code-block:: json timestamp_0, x_0, y_0, z_0 timestamp_1, x_1...
[ "def", "load_cloudupdrs_data", "(", "filename", ",", "convert_times", "=", "1000000000.0", ")", ":", "# data_m = pd.read_table(filename, sep=',', header=None)", "try", ":", "data_m", "=", "np", ".", "genfromtxt", "(", "filename", ",", "delimiter", "=", "','", ",", "...
This method loads data in the cloudupdrs format Usually the data will be saved in a csv file and it should look like this: .. code-block:: json timestamp_0, x_0, y_0, z_0 timestamp_1, x_1, y_1, z_1 timestamp_2, x_2, y_2, z_2 . . ....
[ "This", "method", "loads", "data", "in", "the", "cloudupdrs", "format", "Usually", "the", "data", "will", "be", "saved", "in", "a", "csv", "file", "and", "it", "should", "look", "like", "this", ":", "..", "code", "-", "block", "::", "json", "timestamp_0"...
python
train
user-cont/colin
colin/core/result.py
https://github.com/user-cont/colin/blob/00bb80e6e91522e15361935f813e8cf13d7e76dc/colin/core/result.py#L133-L171
def generate_pretty_output(self, stat, verbose, output_function, logs=True): """ Send the formated to the provided function :param stat: if True print stat instead of full output :param verbose: bool :param output_function: function to send output to """ has_che...
[ "def", "generate_pretty_output", "(", "self", ",", "stat", ",", "verbose", ",", "output_function", ",", "logs", "=", "True", ")", ":", "has_check", "=", "False", "for", "r", "in", "self", ".", "results", ":", "has_check", "=", "True", "if", "stat", ":", ...
Send the formated to the provided function :param stat: if True print stat instead of full output :param verbose: bool :param output_function: function to send output to
[ "Send", "the", "formated", "to", "the", "provided", "function" ]
python
train
Ouranosinc/xclim
xclim/indices.py
https://github.com/Ouranosinc/xclim/blob/2080d139188bd8de2aeca097a025c2d89d6e0e09/xclim/indices.py#L2113-L2159
def warm_spell_duration_index(tasmax, tx90, window=6, freq='YS'): r"""Warm spell duration index Number of days with at least six consecutive days where the daily maximum temperature is above the 90th percentile. The 90th percentile should be computed for a 5-day window centred on each calendar day in the ...
[ "def", "warm_spell_duration_index", "(", "tasmax", ",", "tx90", ",", "window", "=", "6", ",", "freq", "=", "'YS'", ")", ":", "if", "'dayofyear'", "not", "in", "tx90", ".", "coords", ".", "keys", "(", ")", ":", "raise", "AttributeError", "(", "\"tx90 shou...
r"""Warm spell duration index Number of days with at least six consecutive days where the daily maximum temperature is above the 90th percentile. The 90th percentile should be computed for a 5-day window centred on each calendar day in the 1961-1990 period. Parameters ---------- tasmax : xarra...
[ "r", "Warm", "spell", "duration", "index" ]
python
train
raamana/hiwenet
hiwenet/pairwise_dist.py
https://github.com/raamana/hiwenet/blob/b12699b3722fd0a6a835e7d7ca4baf58fb181809/hiwenet/pairwise_dist.py#L498-L554
def check_weight_method(weight_method_spec, use_orig_distr=False, allow_non_symmetric=False): "Check if weight_method is recognized and implemented, or ensure it is callable." if not isinstance(use_orig_distr, bool): raise TypeError('use_original_distribu...
[ "def", "check_weight_method", "(", "weight_method_spec", ",", "use_orig_distr", "=", "False", ",", "allow_non_symmetric", "=", "False", ")", ":", "if", "not", "isinstance", "(", "use_orig_distr", ",", "bool", ")", ":", "raise", "TypeError", "(", "'use_original_dis...
Check if weight_method is recognized and implemented, or ensure it is callable.
[ "Check", "if", "weight_method", "is", "recognized", "and", "implemented", "or", "ensure", "it", "is", "callable", "." ]
python
train
adafruit/Adafruit_Python_BluefruitLE
Adafruit_BluefruitLE/corebluetooth/provider.py
https://github.com/adafruit/Adafruit_Python_BluefruitLE/blob/34fc6f596371b961628369d78ce836950514062f/Adafruit_BluefruitLE/corebluetooth/provider.py#L179-L188
def peripheral_didUpdateValueForCharacteristic_error_(self, peripheral, characteristic, error): """Called when characteristic value was read or updated.""" logger.debug('peripheral_didUpdateValueForCharacteristic_error called') # Stop if there was some kind of error. if error is not None...
[ "def", "peripheral_didUpdateValueForCharacteristic_error_", "(", "self", ",", "peripheral", ",", "characteristic", ",", "error", ")", ":", "logger", ".", "debug", "(", "'peripheral_didUpdateValueForCharacteristic_error called'", ")", "# Stop if there was some kind of error.", "...
Called when characteristic value was read or updated.
[ "Called", "when", "characteristic", "value", "was", "read", "or", "updated", "." ]
python
valid
BerkeleyAutomation/perception
perception/image.py
https://github.com/BerkeleyAutomation/perception/blob/03d9b37dd6b66896cdfe173905c9413c8c3c5df6/perception/image.py#L2902-L2924
def transform(self, translation, theta, method='opencv'): """Create a new image by translating and rotating the current image. Parameters ---------- translation : :obj:`numpy.ndarray` of float The XY translation vector. theta : float Rotation angle in rad...
[ "def", "transform", "(", "self", ",", "translation", ",", "theta", ",", "method", "=", "'opencv'", ")", ":", "# transform channels separately", "color_im_tf", "=", "self", ".", "color", ".", "transform", "(", "translation", ",", "theta", ",", "method", "=", ...
Create a new image by translating and rotating the current image. Parameters ---------- translation : :obj:`numpy.ndarray` of float The XY translation vector. theta : float Rotation angle in radians, with positive meaning counter-clockwise. method : :obj:...
[ "Create", "a", "new", "image", "by", "translating", "and", "rotating", "the", "current", "image", "." ]
python
train
fermiPy/fermipy
fermipy/roi_model.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L398-L401
def is_free(self): """ returns True if any of the spectral model parameters is set to free, else False """ return bool(np.array([int(value.get("free", False)) for key, value in self.spectral_pars.items()]).sum())
[ "def", "is_free", "(", "self", ")", ":", "return", "bool", "(", "np", ".", "array", "(", "[", "int", "(", "value", ".", "get", "(", "\"free\"", ",", "False", ")", ")", "for", "key", ",", "value", "in", "self", ".", "spectral_pars", ".", "items", ...
returns True if any of the spectral model parameters is set to free, else False
[ "returns", "True", "if", "any", "of", "the", "spectral", "model", "parameters", "is", "set", "to", "free", "else", "False" ]
python
train
Asana/python-asana
asana/resources/gen/projects.py
https://github.com/Asana/python-asana/blob/6deb7a34495db23f44858e53b6bb2c9eccff7872/asana/resources/gen/projects.py#L136-L147
def find_by_team(self, team, params={}, **options): """Returns the compact project records for all projects in the team. Parameters ---------- team : {Id} The team to find projects in. [params] : {Object} Parameters for the request - [archived] : {Boolean} Only return...
[ "def", "find_by_team", "(", "self", ",", "team", ",", "params", "=", "{", "}", ",", "*", "*", "options", ")", ":", "path", "=", "\"/teams/%s/projects\"", "%", "(", "team", ")", "return", "self", ".", "client", ".", "get_collection", "(", "path", ",", ...
Returns the compact project records for all projects in the team. Parameters ---------- team : {Id} The team to find projects in. [params] : {Object} Parameters for the request - [archived] : {Boolean} Only return projects whose `archived` field takes on the value of ...
[ "Returns", "the", "compact", "project", "records", "for", "all", "projects", "in", "the", "team", "." ]
python
train
kennydo/nyaalib
nyaalib/__init__.py
https://github.com/kennydo/nyaalib/blob/ab787b7ba141ed53d2ad978bf13eb7b8bcdd4b0d/nyaalib/__init__.py#L38-L65
def _get_page_content(self, response): """Given a :class:`requests.Response`, return the :class:`xml.etree.Element` of the content `div`. :param response: a :class:`requests.Response` to parse :returns: the :class:`Element` of the first content `div` or `None` """ docume...
[ "def", "_get_page_content", "(", "self", ",", "response", ")", ":", "document", "=", "html5lib", ".", "parse", "(", "response", ".", "content", ",", "encoding", "=", "response", ".", "encoding", ",", "treebuilder", "=", "'etree'", ",", "namespaceHTMLElements",...
Given a :class:`requests.Response`, return the :class:`xml.etree.Element` of the content `div`. :param response: a :class:`requests.Response` to parse :returns: the :class:`Element` of the first content `div` or `None`
[ "Given", "a", ":", "class", ":", "requests", ".", "Response", "return", "the", ":", "class", ":", "xml", ".", "etree", ".", "Element", "of", "the", "content", "div", "." ]
python
train
metagriffin/asset
asset/resource.py
https://github.com/metagriffin/asset/blob/f2c5e599cd4688f82216d4b5cfa87aab96d8bb8c/asset/resource.py#L244-L276
def load(pattern, *args, **kw): ''' Given a package asset-spec glob-pattern `pattern`, returns an :class:`AssetGroup` object, which in turn can act as a generator of :class:`Asset` objects that match the pattern. Example: .. code-block:: python import asset # concatenate all 'css' files into one...
[ "def", "load", "(", "pattern", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "spec", "=", "pattern", "if", "':'", "not", "in", "pattern", ":", "raise", "ValueError", "(", "'`pattern` must be in the format \"PACKAGE:GLOB\"'", ")", "pkgname", ",", "pkgpat",...
Given a package asset-spec glob-pattern `pattern`, returns an :class:`AssetGroup` object, which in turn can act as a generator of :class:`Asset` objects that match the pattern. Example: .. code-block:: python import asset # concatenate all 'css' files into one string: css = asset.load('mypackage...
[ "Given", "a", "package", "asset", "-", "spec", "glob", "-", "pattern", "pattern", "returns", "an", ":", "class", ":", "AssetGroup", "object", "which", "in", "turn", "can", "act", "as", "a", "generator", "of", ":", "class", ":", "Asset", "objects", "that"...
python
train
open-mmlab/mmcv
mmcv/image/transforms/colorspace.py
https://github.com/open-mmlab/mmcv/blob/0d77f61450aab4dde8b8585a577cc496acb95d7f/mmcv/image/transforms/colorspace.py#L33-L44
def gray2bgr(img): """Convert a grayscale image to BGR image. Args: img (ndarray or str): The input image. Returns: ndarray: The converted BGR image. """ img = img[..., None] if img.ndim == 2 else img out_img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR) return out_img
[ "def", "gray2bgr", "(", "img", ")", ":", "img", "=", "img", "[", "...", ",", "None", "]", "if", "img", ".", "ndim", "==", "2", "else", "img", "out_img", "=", "cv2", ".", "cvtColor", "(", "img", ",", "cv2", ".", "COLOR_GRAY2BGR", ")", "return", "o...
Convert a grayscale image to BGR image. Args: img (ndarray or str): The input image. Returns: ndarray: The converted BGR image.
[ "Convert", "a", "grayscale", "image", "to", "BGR", "image", "." ]
python
test
misli/django-cms-articles
cms_articles/models/managers.py
https://github.com/misli/django-cms-articles/blob/d96ac77e049022deb4c70d268e4eab74d175145c/cms_articles/models/managers.py#L19-L60
def search(self, q, language=None, current_site_only=True): """Simple search function Plugins can define a 'search_fields' tuple similar to ModelAdmin classes """ from cms.plugin_pool import plugin_pool qs = self.get_queryset() qs = qs.public() if current_site_...
[ "def", "search", "(", "self", ",", "q", ",", "language", "=", "None", ",", "current_site_only", "=", "True", ")", ":", "from", "cms", ".", "plugin_pool", "import", "plugin_pool", "qs", "=", "self", ".", "get_queryset", "(", ")", "qs", "=", "qs", ".", ...
Simple search function Plugins can define a 'search_fields' tuple similar to ModelAdmin classes
[ "Simple", "search", "function" ]
python
train
tensorflow/hub
examples/text_embeddings/export.py
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/examples/text_embeddings/export.py#L62-L90
def load(file_path, parse_line_fn): """Loads a text embedding into memory as a numpy matrix. Args: file_path: Path to the text embedding file. parse_line_fn: callback function to parse each file line. Returns: A tuple of (list of vocabulary tokens, numpy matrix of embedding vectors). Raises: ...
[ "def", "load", "(", "file_path", ",", "parse_line_fn", ")", ":", "vocabulary", "=", "[", "]", "embeddings", "=", "[", "]", "embeddings_dim", "=", "None", "for", "line", "in", "tf", ".", "gfile", ".", "GFile", "(", "file_path", ")", ":", "token", ",", ...
Loads a text embedding into memory as a numpy matrix. Args: file_path: Path to the text embedding file. parse_line_fn: callback function to parse each file line. Returns: A tuple of (list of vocabulary tokens, numpy matrix of embedding vectors). Raises: ValueError: if the data in the sstable is...
[ "Loads", "a", "text", "embedding", "into", "memory", "as", "a", "numpy", "matrix", "." ]
python
train
lepture/flask-oauthlib
flask_oauthlib/provider/oauth1.py
https://github.com/lepture/flask-oauthlib/blob/9e6f152a5bb360e7496210da21561c3e6d41b0e1/flask_oauthlib/provider/oauth1.py#L657-L671
def get_access_token_secret(self, client_key, token, request): """Get access token secret. The access token object should a ``secret`` attribute. """ log.debug('Get access token secret of %r for %r', token, client_key) tok = request.access_token or self._tokeng...
[ "def", "get_access_token_secret", "(", "self", ",", "client_key", ",", "token", ",", "request", ")", ":", "log", ".", "debug", "(", "'Get access token secret of %r for %r'", ",", "token", ",", "client_key", ")", "tok", "=", "request", ".", "access_token", "or", ...
Get access token secret. The access token object should a ``secret`` attribute.
[ "Get", "access", "token", "secret", "." ]
python
test
mzucker/noteshrink
noteshrink.py
https://github.com/mzucker/noteshrink/blob/7d876e5b43923c6bf8d64b7ef18f6855bfb30ce3/noteshrink.py#L371-L396
def get_palette(samples, options, return_mask=False, kmeans_iter=40): '''Extract the palette for the set of sampled RGB values. The first palette entry is always the background color; the rest are determined from foreground pixels by running K-means clustering. Returns the palette, as well as a mask corresponding ...
[ "def", "get_palette", "(", "samples", ",", "options", ",", "return_mask", "=", "False", ",", "kmeans_iter", "=", "40", ")", ":", "if", "not", "options", ".", "quiet", ":", "print", "(", "' getting palette...'", ")", "bg_color", "=", "get_bg_color", "(", "...
Extract the palette for the set of sampled RGB values. The first palette entry is always the background color; the rest are determined from foreground pixels by running K-means clustering. Returns the palette, as well as a mask corresponding to the foreground pixels.
[ "Extract", "the", "palette", "for", "the", "set", "of", "sampled", "RGB", "values", ".", "The", "first", "palette", "entry", "is", "always", "the", "background", "color", ";", "the", "rest", "are", "determined", "from", "foreground", "pixels", "by", "running...
python
train
yunojuno/elasticsearch-django
elasticsearch_django/models.py
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/models.py#L59-L80
def in_search_queryset(self, instance_id, index="_all"): """ Return True if an object is part of the search index queryset. Sometimes it's useful to know if an object _should_ be indexed. If an object is saved, how do you know if you should push that change to the search index? ...
[ "def", "in_search_queryset", "(", "self", ",", "instance_id", ",", "index", "=", "\"_all\"", ")", ":", "return", "self", ".", "get_search_queryset", "(", "index", "=", "index", ")", ".", "filter", "(", "pk", "=", "instance_id", ")", ".", "exists", "(", "...
Return True if an object is part of the search index queryset. Sometimes it's useful to know if an object _should_ be indexed. If an object is saved, how do you know if you should push that change to the search index? The simplest (albeit not most efficient) way is to check if it appear...
[ "Return", "True", "if", "an", "object", "is", "part", "of", "the", "search", "index", "queryset", "." ]
python
train
joeblackwaslike/pricing
pricing/metaconfigure.py
https://github.com/joeblackwaslike/pricing/blob/be988b0851b4313af81f1db475bc33248700e39c/pricing/metaconfigure.py#L37-L46
def currencyFormat(_context, code, symbol, format, currency_digits=True, decimal_quantization=True, name=''): """Handle currencyFormat subdirectives.""" _context.action( discriminator=('currency', name, code), callable=_register_curre...
[ "def", "currencyFormat", "(", "_context", ",", "code", ",", "symbol", ",", "format", ",", "currency_digits", "=", "True", ",", "decimal_quantization", "=", "True", ",", "name", "=", "''", ")", ":", "_context", ".", "action", "(", "discriminator", "=", "(",...
Handle currencyFormat subdirectives.
[ "Handle", "currencyFormat", "subdirectives", "." ]
python
test
latchset/jwcrypto
jwcrypto/jws.py
https://github.com/latchset/jwcrypto/blob/961df898dc08f63fe3d900f2002618740bc66b4a/jwcrypto/jws.py#L419-L510
def add_signature(self, key, alg=None, protected=None, header=None): """Adds a new signature to the object. :param key: A (:class:`jwcrypto.jwk.JWK`) key of appropriate for the "alg" provided. :param alg: An optional algorithm name. If already provided as an element of the pro...
[ "def", "add_signature", "(", "self", ",", "key", ",", "alg", "=", "None", ",", "protected", "=", "None", ",", "header", "=", "None", ")", ":", "if", "not", "self", ".", "objects", ".", "get", "(", "'payload'", ",", "None", ")", ":", "raise", "Inval...
Adds a new signature to the object. :param key: A (:class:`jwcrypto.jwk.JWK`) key of appropriate for the "alg" provided. :param alg: An optional algorithm name. If already provided as an element of the protected or unprotected header it can be safely omitted. :param p...
[ "Adds", "a", "new", "signature", "to", "the", "object", "." ]
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/zmq/kernelmanager.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/zmq/kernelmanager.py#L195-L206
def run(self): """The thread's main activity. Call start() instead.""" self.socket = self.context.socket(zmq.DEALER) self.socket.setsockopt(zmq.IDENTITY, self.session.bsession) self.socket.connect('tcp://%s:%i' % self.address) self.stream = zmqstream.ZMQStream(self.socket, self....
[ "def", "run", "(", "self", ")", ":", "self", ".", "socket", "=", "self", ".", "context", ".", "socket", "(", "zmq", ".", "DEALER", ")", "self", ".", "socket", ".", "setsockopt", "(", "zmq", ".", "IDENTITY", ",", "self", ".", "session", ".", "bsessi...
The thread's main activity. Call start() instead.
[ "The", "thread", "s", "main", "activity", ".", "Call", "start", "()", "instead", "." ]
python
test
OnroerendErfgoed/oe_utils
oe_utils/views/atom.py
https://github.com/OnroerendErfgoed/oe_utils/blob/7b2014bda8ac6bb71b7138eaa06ac17ef3ff4a6d/oe_utils/views/atom.py#L147-L157
def _generate_atom_feed(self, feed): """ A function returning a feed like `feedgen.feed.FeedGenerator`. The function can be overwritten when used in other applications. :param feed: a feed object :return: an atom feed `feedgen.feed.FeedGenerator` """ atom_feed = ...
[ "def", "_generate_atom_feed", "(", "self", ",", "feed", ")", ":", "atom_feed", "=", "self", ".", "init_atom_feed", "(", "feed", ")", "atom_feed", ".", "title", "(", "\"Feed\"", ")", "return", "atom_feed" ]
A function returning a feed like `feedgen.feed.FeedGenerator`. The function can be overwritten when used in other applications. :param feed: a feed object :return: an atom feed `feedgen.feed.FeedGenerator`
[ "A", "function", "returning", "a", "feed", "like", "feedgen", ".", "feed", ".", "FeedGenerator", ".", "The", "function", "can", "be", "overwritten", "when", "used", "in", "other", "applications", "." ]
python
train
codeghar/brokerlso
brokerlso/qmfv2.py
https://github.com/codeghar/brokerlso/blob/e110e12502b090e12b06c7615dd0a96a14a92585/brokerlso/qmfv2.py#L157-L166
def list_queues(self): """Create message content and properties to list all queues with QMFv2 :returns: Tuple containing content and query properties """ content = {"_what": "OBJECT", "_schema_id": {"_class_name": "queue"}} logger.debug("Message content -> {0}...
[ "def", "list_queues", "(", "self", ")", ":", "content", "=", "{", "\"_what\"", ":", "\"OBJECT\"", ",", "\"_schema_id\"", ":", "{", "\"_class_name\"", ":", "\"queue\"", "}", "}", "logger", ".", "debug", "(", "\"Message content -> {0}\"", ".", "format", "(", "...
Create message content and properties to list all queues with QMFv2 :returns: Tuple containing content and query properties
[ "Create", "message", "content", "and", "properties", "to", "list", "all", "queues", "with", "QMFv2" ]
python
test
Netflix-Skunkworks/cloudaux
cloudaux/orchestration/aws/iam/group.py
https://github.com/Netflix-Skunkworks/cloudaux/blob/c4b0870c3ac68b1c69e71d33cf78b6a8bdf437ea/cloudaux/orchestration/aws/iam/group.py#L74-L103
def get_group(group, flags=FLAGS.BASE | FLAGS.INLINE_POLICIES | FLAGS.MANAGED_POLICIES, **conn): """ Orchestrates all the calls required to fully build out an IAM Group in the following format: { "Arn": ..., "GroupName": ..., "Path": ..., "GroupId": ..., "CreateDate"...
[ "def", "get_group", "(", "group", ",", "flags", "=", "FLAGS", ".", "BASE", "|", "FLAGS", ".", "INLINE_POLICIES", "|", "FLAGS", ".", "MANAGED_POLICIES", ",", "*", "*", "conn", ")", ":", "if", "not", "group", ".", "get", "(", "'GroupName'", ")", ":", "...
Orchestrates all the calls required to fully build out an IAM Group in the following format: { "Arn": ..., "GroupName": ..., "Path": ..., "GroupId": ..., "CreateDate": ..., # str "InlinePolicies": ..., "ManagedPolicies": ..., # These are just the names of t...
[ "Orchestrates", "all", "the", "calls", "required", "to", "fully", "build", "out", "an", "IAM", "Group", "in", "the", "following", "format", ":" ]
python
valid
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/generator/mavparse.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/generator/mavparse.py#L396-L427
def merge_enums(xml): '''merge enums between XML files''' emap = {} for x in xml: newenums = [] for enum in x.enum: if enum.name in emap: emapitem = emap[enum.name] # check for possible conflicting auto-assigned values after merge i...
[ "def", "merge_enums", "(", "xml", ")", ":", "emap", "=", "{", "}", "for", "x", "in", "xml", ":", "newenums", "=", "[", "]", "for", "enum", "in", "x", ".", "enum", ":", "if", "enum", ".", "name", "in", "emap", ":", "emapitem", "=", "emap", "[", ...
merge enums between XML files
[ "merge", "enums", "between", "XML", "files" ]
python
train
supercoderz/pyflightdata
pyflightdata/flightdata.py
https://github.com/supercoderz/pyflightdata/blob/2caf9f429288f9a171893d1b8377d0c6244541cc/pyflightdata/flightdata.py#L556-L577
def decode_metar(self, metar): """ Simple method that decodes a given metar string. Args: metar (str): The metar data Returns: The metar data in readable format Example:: from pyflightdata import FlightData f=FlightData() ...
[ "def", "decode_metar", "(", "self", ",", "metar", ")", ":", "try", ":", "from", "metar", "import", "Metar", "except", ":", "return", "\"Unable to parse metars. Please install parser from https://github.com/tomp/python-metar.\"", "m", "=", "Metar", ".", "Metar", "(", "...
Simple method that decodes a given metar string. Args: metar (str): The metar data Returns: The metar data in readable format Example:: from pyflightdata import FlightData f=FlightData() f.decode_metar('WSSS 181030Z 04009KT 010V080 ...
[ "Simple", "method", "that", "decodes", "a", "given", "metar", "string", "." ]
python
train
SBRG/ssbio
ssbio/biopython/Bio/Struct/WWW/WHATIFXML.py
https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/biopython/Bio/Struct/WWW/WHATIFXML.py#L81-L182
def _parse(self): """ Parse atomic data of the XML file. """ atom_counter = 0 structure_build = self.structure_builder residues = self._extract_residues() cur_model = None cur_chain = None structure_build.init_se...
[ "def", "_parse", "(", "self", ")", ":", "atom_counter", "=", "0", "structure_build", "=", "self", ".", "structure_builder", "residues", "=", "self", ".", "_extract_residues", "(", ")", "cur_model", "=", "None", "cur_chain", "=", "None", "structure_build", ".",...
Parse atomic data of the XML file.
[ "Parse", "atomic", "data", "of", "the", "XML", "file", "." ]
python
train
sunlightlabs/django-locksmith
locksmith/hub/views.py
https://github.com/sunlightlabs/django-locksmith/blob/eef5b7c25404560aaad50b6e622594f89239b74b/locksmith/hub/views.py#L180-L208
def profile(request): ''' Viewing of signup details and editing of password ''' context = {} if request.method == 'POST': form = PasswordChangeForm(request.user, request.POST) if form.is_valid(): form.save() messages.info(request, 'Password Changed.') ...
[ "def", "profile", "(", "request", ")", ":", "context", "=", "{", "}", "if", "request", ".", "method", "==", "'POST'", ":", "form", "=", "PasswordChangeForm", "(", "request", ".", "user", ",", "request", ".", "POST", ")", "if", "form", ".", "is_valid", ...
Viewing of signup details and editing of password
[ "Viewing", "of", "signup", "details", "and", "editing", "of", "password" ]
python
train
dnanexus/dx-toolkit
src/python/dxpy/bindings/search.py
https://github.com/dnanexus/dx-toolkit/blob/74befb53ad90fcf902d8983ae6d74580f402d619/src/python/dxpy/bindings/search.py#L73-L108
def _find(api_method, query, limit, return_handler, first_page_size, **kwargs): ''' Takes an API method handler (dxpy.api.find*) and calls it with *query*, and then wraps a generator around its output. Used by the methods below. Note that this function may only be used for /system/find* methods. ''' ...
[ "def", "_find", "(", "api_method", ",", "query", ",", "limit", ",", "return_handler", ",", "first_page_size", ",", "*", "*", "kwargs", ")", ":", "num_results", "=", "0", "if", "\"limit\"", "not", "in", "query", ":", "query", "[", "\"limit\"", "]", "=", ...
Takes an API method handler (dxpy.api.find*) and calls it with *query*, and then wraps a generator around its output. Used by the methods below. Note that this function may only be used for /system/find* methods.
[ "Takes", "an", "API", "method", "handler", "(", "dxpy", ".", "api", ".", "find", "*", ")", "and", "calls", "it", "with", "*", "query", "*", "and", "then", "wraps", "a", "generator", "around", "its", "output", ".", "Used", "by", "the", "methods", "bel...
python
train
cloudendpoints/endpoints-management-python
endpoints_management/control/vendor/py3/sched.py
https://github.com/cloudendpoints/endpoints-management-python/blob/ec3c4a330ae9d65738861ce6df4dd6c3cb9f7731/endpoints_management/control/vendor/py3/sched.py#L94-L103
def cancel(self, event): """Remove an event from the queue. This must be presented the ID as returned by enter(). If the event is not in the queue, this raises ValueError. """ with self._lock: self._queue.remove(event) heapq.heapify(self._queue)
[ "def", "cancel", "(", "self", ",", "event", ")", ":", "with", "self", ".", "_lock", ":", "self", ".", "_queue", ".", "remove", "(", "event", ")", "heapq", ".", "heapify", "(", "self", ".", "_queue", ")" ]
Remove an event from the queue. This must be presented the ID as returned by enter(). If the event is not in the queue, this raises ValueError.
[ "Remove", "an", "event", "from", "the", "queue", "." ]
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/frontend/html/notebook/notebookmanager.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/frontend/html/notebook/notebookmanager.py#L268-L276
def new_notebook(self): """Create a new notebook and return its notebook_id.""" path, name = self.increment_filename('Untitled') notebook_id = self.new_notebook_id(name) metadata = current.new_metadata(name=name) nb = current.new_notebook(metadata=metadata) with open(path...
[ "def", "new_notebook", "(", "self", ")", ":", "path", ",", "name", "=", "self", ".", "increment_filename", "(", "'Untitled'", ")", "notebook_id", "=", "self", ".", "new_notebook_id", "(", "name", ")", "metadata", "=", "current", ".", "new_metadata", "(", "...
Create a new notebook and return its notebook_id.
[ "Create", "a", "new", "notebook", "and", "return", "its", "notebook_id", "." ]
python
test
shoebot/shoebot
shoebot/grammar/nodebox.py
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/nodebox.py#L432-L439
def transform(self, mode=None): ''' Set the current transform mode. :param mode: CENTER or CORNER''' if mode: self._canvas.mode = mode return self._canvas.mode
[ "def", "transform", "(", "self", ",", "mode", "=", "None", ")", ":", "if", "mode", ":", "self", ".", "_canvas", ".", "mode", "=", "mode", "return", "self", ".", "_canvas", ".", "mode" ]
Set the current transform mode. :param mode: CENTER or CORNER
[ "Set", "the", "current", "transform", "mode", "." ]
python
valid
spacetelescope/stsci.tools
lib/stsci/tools/vtor_checks.py
https://github.com/spacetelescope/stsci.tools/blob/9a022503ad24ca54ce83331482dfa3ff6de9f403/lib/stsci/tools/vtor_checks.py#L18-L40
def sigStrToKwArgsDict(checkFuncSig): """ Take a check function signature (string), and parse it to get a dict of the keyword args and their values. """ p1 = checkFuncSig.find('(') p2 = checkFuncSig.rfind(')') assert p1 > 0 and p2 > 0 and p2 > p1, "Invalid signature: "+checkFuncSig argParts ...
[ "def", "sigStrToKwArgsDict", "(", "checkFuncSig", ")", ":", "p1", "=", "checkFuncSig", ".", "find", "(", "'('", ")", "p2", "=", "checkFuncSig", ".", "rfind", "(", "')'", ")", "assert", "p1", ">", "0", "and", "p2", ">", "0", "and", "p2", ">", "p1", ...
Take a check function signature (string), and parse it to get a dict of the keyword args and their values.
[ "Take", "a", "check", "function", "signature", "(", "string", ")", "and", "parse", "it", "to", "get", "a", "dict", "of", "the", "keyword", "args", "and", "their", "values", "." ]
python
train
cocagne/txdbus
txdbus/marshal.py
https://github.com/cocagne/txdbus/blob/eb424918764b7b93eecd2a4e2e5c2d0b2944407b/txdbus/marshal.py#L221-L240
def validateMemberName(n): """ Verifies that the supplied name is a valid DBus member name. Throws an L{error.MarshallingError} if the format is invalid @type n: C{string} @param n: A DBus member name """ try: if len(n) < 1: raise Exception('Name must be at least one byt...
[ "def", "validateMemberName", "(", "n", ")", ":", "try", ":", "if", "len", "(", "n", ")", "<", "1", ":", "raise", "Exception", "(", "'Name must be at least one byte in length'", ")", "if", "len", "(", "n", ")", ">", "255", ":", "raise", "Exception", "(", ...
Verifies that the supplied name is a valid DBus member name. Throws an L{error.MarshallingError} if the format is invalid @type n: C{string} @param n: A DBus member name
[ "Verifies", "that", "the", "supplied", "name", "is", "a", "valid", "DBus", "member", "name", ".", "Throws", "an", "L", "{", "error", ".", "MarshallingError", "}", "if", "the", "format", "is", "invalid" ]
python
train
pytroll/satpy
satpy/readers/eps_l1b.py
https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/readers/eps_l1b.py#L291-L394
def get_dataset(self, key, info): """Get calibrated channel data.""" if self.mdrs is None: self._read_all(self.filename) if key.name in ['longitude', 'latitude']: lons, lats = self.get_full_lonlats() if key.name == 'longitude': dataset = creat...
[ "def", "get_dataset", "(", "self", ",", "key", ",", "info", ")", ":", "if", "self", ".", "mdrs", "is", "None", ":", "self", ".", "_read_all", "(", "self", ".", "filename", ")", "if", "key", ".", "name", "in", "[", "'longitude'", ",", "'latitude'", ...
Get calibrated channel data.
[ "Get", "calibrated", "channel", "data", "." ]
python
train
saltstack/salt
salt/states/win_iis.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_iis.py#L783-L871
def set_app(name, site, settings=None): # pylint: disable=anomalous-backslash-in-string ''' .. versionadded:: 2017.7.0 Set the value of the setting for an IIS web application. .. note:: This function only configures existing app. Params are case sensitive. :param str name: The IIS app...
[ "def", "set_app", "(", "name", ",", "site", ",", "settings", "=", "None", ")", ":", "# pylint: disable=anomalous-backslash-in-string", "# pylint: enable=anomalous-backslash-in-string", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "...
.. versionadded:: 2017.7.0 Set the value of the setting for an IIS web application. .. note:: This function only configures existing app. Params are case sensitive. :param str name: The IIS application. :param str site: The IIS site name. :param str settings: A dictionary of the setting n...
[ "..", "versionadded", "::", "2017", ".", "7", ".", "0" ]
python
train
authomatic/authomatic
authomatic/providers/oauth2.py
https://github.com/authomatic/authomatic/blob/90a9ce60cc405ae8a2bf5c3713acd5d78579a04e/authomatic/providers/oauth2.py#L115-L215
def create_request_elements( cls, request_type, credentials, url, method='GET', params=None, headers=None, body='', secret=None, redirect_uri='', scope='', csrf='', user_state='' ): """ Creates |oauth2| request elements. """ headers = headers or {...
[ "def", "create_request_elements", "(", "cls", ",", "request_type", ",", "credentials", ",", "url", ",", "method", "=", "'GET'", ",", "params", "=", "None", ",", "headers", "=", "None", ",", "body", "=", "''", ",", "secret", "=", "None", ",", "redirect_ur...
Creates |oauth2| request elements.
[ "Creates", "|oauth2|", "request", "elements", "." ]
python
test
bitesofcode/projexui
projexui/widgets/xviewwidget/xview.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xviewwidget/xview.py#L492-L502
def setMaximumWidth(self, width): """ Sets the maximum width value to the inputed width and emits the \ sizeConstraintChanged signal. :param width | <int> """ super(XView, self).setMaximumWidth(width) if ( not self.signalsBlocked() ): ...
[ "def", "setMaximumWidth", "(", "self", ",", "width", ")", ":", "super", "(", "XView", ",", "self", ")", ".", "setMaximumWidth", "(", "width", ")", "if", "(", "not", "self", ".", "signalsBlocked", "(", ")", ")", ":", "self", ".", "sizeConstraintChanged", ...
Sets the maximum width value to the inputed width and emits the \ sizeConstraintChanged signal. :param width | <int>
[ "Sets", "the", "maximum", "width", "value", "to", "the", "inputed", "width", "and", "emits", "the", "\\", "sizeConstraintChanged", "signal", ".", ":", "param", "width", "|", "<int", ">" ]
python
train
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/parallel/controller/scheduler.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/parallel/controller/scheduler.py#L477-L531
def maybe_run(self, job): """check location dependencies, and run if they are met.""" msg_id = job.msg_id self.log.debug("Attempting to assign task %s", msg_id) if not self.targets: # no engines, definitely can't run return False if job.follow or ...
[ "def", "maybe_run", "(", "self", ",", "job", ")", ":", "msg_id", "=", "job", ".", "msg_id", "self", ".", "log", ".", "debug", "(", "\"Attempting to assign task %s\"", ",", "msg_id", ")", "if", "not", "self", ".", "targets", ":", "# no engines, definitely can...
check location dependencies, and run if they are met.
[ "check", "location", "dependencies", "and", "run", "if", "they", "are", "met", "." ]
python
test
wmayner/pyphi
pyphi/actual.py
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/actual.py#L366-L383
def potential_purviews(self, direction, mechanism, purviews=False): """Return all purviews that could belong to the |MIC|/|MIE|. Filters out trivially-reducible purviews. Args: direction (str): Either |CAUSE| or |EFFECT|. mechanism (tuple[int]): The mechanism of interes...
[ "def", "potential_purviews", "(", "self", ",", "direction", ",", "mechanism", ",", "purviews", "=", "False", ")", ":", "system", "=", "self", ".", "system", "[", "direction", "]", "return", "[", "purview", "for", "purview", "in", "system", ".", "potential_...
Return all purviews that could belong to the |MIC|/|MIE|. Filters out trivially-reducible purviews. Args: direction (str): Either |CAUSE| or |EFFECT|. mechanism (tuple[int]): The mechanism of interest. Keyword Args: purviews (tuple[int]): Optional subset of...
[ "Return", "all", "purviews", "that", "could", "belong", "to", "the", "|MIC|", "/", "|MIE|", "." ]
python
train
saltstack/salt
salt/modules/win_file.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/win_file.py#L1110-L1161
def symlink(src, link): ''' Create a symbolic link to a file This is only supported with Windows Vista or later and must be executed by a user with the SeCreateSymbolicLink privilege. The behavior of this function matches the Unix equivalent, with one exception - invalid symlinks cannot be cre...
[ "def", "symlink", "(", "src", ",", "link", ")", ":", "# When Python 3.2 or later becomes the minimum version, this function can be", "# replaced with the built-in os.symlink function, which supports Windows.", "if", "sys", ".", "getwindowsversion", "(", ")", ".", "major", "<", ...
Create a symbolic link to a file This is only supported with Windows Vista or later and must be executed by a user with the SeCreateSymbolicLink privilege. The behavior of this function matches the Unix equivalent, with one exception - invalid symlinks cannot be created. The source path must exist. ...
[ "Create", "a", "symbolic", "link", "to", "a", "file" ]
python
train
Chilipp/docrep
docrep/__init__.py
https://github.com/Chilipp/docrep/blob/637971f76e1a6e1c70e36dcd1b02bbc37ba02487/docrep/__init__.py#L641-L727
def keep_params(self, base_key, *params): """ Method to keep only specific parameters from a parameter documentation. This method extracts the given `param` from the `base_key` item in the :attr:`params` dictionary and creates a new item with the original documentation with only...
[ "def", "keep_params", "(", "self", ",", "base_key", ",", "*", "params", ")", ":", "self", ".", "params", "[", "base_key", "+", "'.'", "+", "'|'", ".", "join", "(", "params", ")", "]", "=", "self", ".", "keep_params_s", "(", "self", ".", "params", "...
Method to keep only specific parameters from a parameter documentation. This method extracts the given `param` from the `base_key` item in the :attr:`params` dictionary and creates a new item with the original documentation with only the description of the param. This method works for `...
[ "Method", "to", "keep", "only", "specific", "parameters", "from", "a", "parameter", "documentation", "." ]
python
train
MagicStack/asyncpg
asyncpg/connresource.py
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connresource.py#L14-L22
def guarded(meth): """A decorator to add a sanity check to ConnectionResource methods.""" @functools.wraps(meth) def _check(self, *args, **kwargs): self._check_conn_validity(meth.__name__) return meth(self, *args, **kwargs) return _check
[ "def", "guarded", "(", "meth", ")", ":", "@", "functools", ".", "wraps", "(", "meth", ")", "def", "_check", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_check_conn_validity", "(", "meth", ".", "__name__", ")", "r...
A decorator to add a sanity check to ConnectionResource methods.
[ "A", "decorator", "to", "add", "a", "sanity", "check", "to", "ConnectionResource", "methods", "." ]
python
train
pylp/pylp
pylp/utils/paths.py
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/utils/paths.py#L13-L19
def make_readable_path(path): """Make a path more "readable""" home = os.path.expanduser("~") if path.startswith(home): path = "~" + path[len(home):] return path
[ "def", "make_readable_path", "(", "path", ")", ":", "home", "=", "os", ".", "path", ".", "expanduser", "(", "\"~\"", ")", "if", "path", ".", "startswith", "(", "home", ")", ":", "path", "=", "\"~\"", "+", "path", "[", "len", "(", "home", ")", ":", ...
Make a path more "readable
[ "Make", "a", "path", "more", "readable" ]
python
train
genialis/resolwe
resolwe/flow/models/utils.py
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/models/utils.py#L235-L292
def _hydrate_values(output, output_schema, data): """Hydrate basic:file and basic:json values. Find fields with basic:file type and assign a full path to the file. Find fields with basic:json type and assign a JSON object from storage. """ def hydrate_path(file_name): """Hydrate file paths...
[ "def", "_hydrate_values", "(", "output", ",", "output_schema", ",", "data", ")", ":", "def", "hydrate_path", "(", "file_name", ")", ":", "\"\"\"Hydrate file paths.\"\"\"", "from", "resolwe", ".", "flow", ".", "managers", "import", "manager", "class", "HydratedPath...
Hydrate basic:file and basic:json values. Find fields with basic:file type and assign a full path to the file. Find fields with basic:json type and assign a JSON object from storage.
[ "Hydrate", "basic", ":", "file", "and", "basic", ":", "json", "values", "." ]
python
train
mitsei/dlkit
dlkit/json_/resource/objects.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/resource/objects.py#L192-L202
def get_group_metadata(self): """Gets the metadata for a group. return: (osid.Metadata) - metadata for the group *compliance: mandatory -- This method must be implemented.* """ # Implemented from template for osid.resource.ResourceForm.get_group_metadata_template metada...
[ "def", "get_group_metadata", "(", "self", ")", ":", "# Implemented from template for osid.resource.ResourceForm.get_group_metadata_template", "metadata", "=", "dict", "(", "self", ".", "_mdata", "[", "'group'", "]", ")", "metadata", ".", "update", "(", "{", "'existing_b...
Gets the metadata for a group. return: (osid.Metadata) - metadata for the group *compliance: mandatory -- This method must be implemented.*
[ "Gets", "the", "metadata", "for", "a", "group", "." ]
python
train
jobovy/galpy
galpy/potential/MovingObjectPotential.py
https://github.com/jobovy/galpy/blob/9c5b9fe65d58835624dffe432be282060918ee08/galpy/potential/MovingObjectPotential.py#L63-L83
def _evaluate(self,R,z,phi=0.,t=0.): """ NAME: _evaluate PURPOSE: evaluate the potential at R,z, phi INPUT: R - Galactocentric cylindrical radius z - vertical height phi - azimuth t - time OUTPUT: Phi(R,...
[ "def", "_evaluate", "(", "self", ",", "R", ",", "z", ",", "phi", "=", "0.", ",", "t", "=", "0.", ")", ":", "#Cylindrical distance", "Rdist", "=", "_cylR", "(", "R", ",", "phi", ",", "self", ".", "_orb", ".", "R", "(", "t", ")", ",", "self", "...
NAME: _evaluate PURPOSE: evaluate the potential at R,z, phi INPUT: R - Galactocentric cylindrical radius z - vertical height phi - azimuth t - time OUTPUT: Phi(R,z,phi) HISTORY: 2011-04-10 - Started -...
[ "NAME", ":", "_evaluate", "PURPOSE", ":", "evaluate", "the", "potential", "at", "R", "z", "phi", "INPUT", ":", "R", "-", "Galactocentric", "cylindrical", "radius", "z", "-", "vertical", "height", "phi", "-", "azimuth", "t", "-", "time", "OUTPUT", ":", "P...
python
train
aaugustin/websockets
src/websockets/http.py
https://github.com/aaugustin/websockets/blob/17b3f47549b6f752a1be07fa1ba3037cb59c7d56/src/websockets/http.py#L187-L204
async def read_line(stream: asyncio.StreamReader) -> bytes: """ Read a single line from ``stream``. ``stream`` is an :class:`~asyncio.StreamReader`. Return :class:`bytes` without CRLF. """ # Security: this is bounded by the StreamReader's limit (default = 32 KiB). line = await stream.read...
[ "async", "def", "read_line", "(", "stream", ":", "asyncio", ".", "StreamReader", ")", "->", "bytes", ":", "# Security: this is bounded by the StreamReader's limit (default = 32 KiB).", "line", "=", "await", "stream", ".", "readline", "(", ")", "# Security: this guarantees...
Read a single line from ``stream``. ``stream`` is an :class:`~asyncio.StreamReader`. Return :class:`bytes` without CRLF.
[ "Read", "a", "single", "line", "from", "stream", "." ]
python
train
MolSSI-BSE/basis_set_exchange
basis_set_exchange/cli/bse_handlers.py
https://github.com/MolSSI-BSE/basis_set_exchange/blob/e79110aaeb65f392ed5032420322dee3336948f7/basis_set_exchange/cli/bse_handlers.py#L52-L61
def _bse_cli_list_roles(args): '''Handles the list-roles subcommand''' all_roles = api.get_roles() if args.no_description: liststr = all_roles.keys() else: liststr = format_columns(all_roles.items()) return '\n'.join(liststr)
[ "def", "_bse_cli_list_roles", "(", "args", ")", ":", "all_roles", "=", "api", ".", "get_roles", "(", ")", "if", "args", ".", "no_description", ":", "liststr", "=", "all_roles", ".", "keys", "(", ")", "else", ":", "liststr", "=", "format_columns", "(", "a...
Handles the list-roles subcommand
[ "Handles", "the", "list", "-", "roles", "subcommand" ]
python
train
IdentityPython/pysaml2
src/saml2/mcache.py
https://github.com/IdentityPython/pysaml2/blob/d3aa78eeb7d37c12688f783cb4db1c7263a14ad6/src/saml2/mcache.py#L153-L174
def active(self, subject_id, entity_id): """ Returns the status of assertions from a specific entity_id. :param subject_id: The ID of the subject :param entity_id: The entity ID of the entity_id of the assertion :return: True or False depending on if the assertion is still v...
[ "def", "active", "(", "self", ",", "subject_id", ",", "entity_id", ")", ":", "try", ":", "(", "timestamp", ",", "info", ")", "=", "self", ".", "_cache", ".", "get", "(", "_key", "(", "subject_id", ",", "entity_id", ")", ")", "except", "ValueError", "...
Returns the status of assertions from a specific entity_id. :param subject_id: The ID of the subject :param entity_id: The entity ID of the entity_id of the assertion :return: True or False depending on if the assertion is still valid or not.
[ "Returns", "the", "status", "of", "assertions", "from", "a", "specific", "entity_id", "." ]
python
train
nion-software/nionswift
nion/swift/model/Symbolic.py
https://github.com/nion-software/nionswift/blob/d43693eaf057b8683b9638e575000f055fede452/nion/swift/model/Symbolic.py#L886-L891
def unbind(self): """Unlisten and close each bound item.""" for variable in self.variables: self.__unbind_variable(variable) for result in self.results: self.__unbind_result(result)
[ "def", "unbind", "(", "self", ")", ":", "for", "variable", "in", "self", ".", "variables", ":", "self", ".", "__unbind_variable", "(", "variable", ")", "for", "result", "in", "self", ".", "results", ":", "self", ".", "__unbind_result", "(", "result", ")"...
Unlisten and close each bound item.
[ "Unlisten", "and", "close", "each", "bound", "item", "." ]
python
train
swift-nav/libsbp
python/sbp/client/drivers/cdc_driver.py
https://github.com/swift-nav/libsbp/blob/5a950608506b23e31b73ef7065da905b646055c1/python/sbp/client/drivers/cdc_driver.py#L27-L48
def read(self, size): """ Read wrapper. Parameters ---------- size : int Number of bytes to read. """ try: return_val = self.handle.read(size) if return_val == '': print() print("Piksi disconnected...
[ "def", "read", "(", "self", ",", "size", ")", ":", "try", ":", "return_val", "=", "self", ".", "handle", ".", "read", "(", "size", ")", "if", "return_val", "==", "''", ":", "print", "(", ")", "print", "(", "\"Piksi disconnected\"", ")", "print", "(",...
Read wrapper. Parameters ---------- size : int Number of bytes to read.
[ "Read", "wrapper", "." ]
python
train
stephrdev/django-formwizard
formwizard/views.py
https://github.com/stephrdev/django-formwizard/blob/7b35165f0340aae4e8302d5b05b0cb443f6c9904/formwizard/views.py#L303-L325
def render_done(self, form, **kwargs): """ This method gets called when all forms passed. The method should also re-validate all steps to prevent manipulation. If any form don't validate, `render_revalidation_failure` should get called. If everything is fine call `done`. ...
[ "def", "render_done", "(", "self", ",", "form", ",", "*", "*", "kwargs", ")", ":", "final_form_list", "=", "[", "]", "# walk through the form list and try to validate the data again.", "for", "form_key", "in", "self", ".", "get_form_list", "(", ")", ":", "form_obj...
This method gets called when all forms passed. The method should also re-validate all steps to prevent manipulation. If any form don't validate, `render_revalidation_failure` should get called. If everything is fine call `done`.
[ "This", "method", "gets", "called", "when", "all", "forms", "passed", ".", "The", "method", "should", "also", "re", "-", "validate", "all", "steps", "to", "prevent", "manipulation", ".", "If", "any", "form", "don", "t", "validate", "render_revalidation_failure...
python
train
Azure/azure-cli-extensions
src/storage-preview/azext_storage_preview/_validators.py
https://github.com/Azure/azure-cli-extensions/blob/3d4854205b0f0d882f688cfa12383d14506c2e35/src/storage-preview/azext_storage_preview/_validators.py#L388-L398
def resource_type_type(loader): """ Returns a function which validates that resource types string contains only a combination of service, container, and object. Their shorthand representations are s, c, and o. """ def impl(string): t_resources = loader.get_models('common.models#ResourceTypes') ...
[ "def", "resource_type_type", "(", "loader", ")", ":", "def", "impl", "(", "string", ")", ":", "t_resources", "=", "loader", ".", "get_models", "(", "'common.models#ResourceTypes'", ")", "if", "set", "(", "string", ")", "-", "set", "(", "\"sco\"", ")", ":",...
Returns a function which validates that resource types string contains only a combination of service, container, and object. Their shorthand representations are s, c, and o.
[ "Returns", "a", "function", "which", "validates", "that", "resource", "types", "string", "contains", "only", "a", "combination", "of", "service", "container", "and", "object", ".", "Their", "shorthand", "representations", "are", "s", "c", "and", "o", "." ]
python
train
softlayer/softlayer-python
SoftLayer/CLI/block/lun.py
https://github.com/softlayer/softlayer-python/blob/9f181be08cc3668353b05a6de0cb324f52cff6fa/SoftLayer/CLI/block/lun.py#L14-L36
def cli(env, volume_id, lun_id): """Set the LUN ID on an existing block storage volume. The LUN ID only takes effect during the Host Authorization process. It is recommended (but not necessary) to de-authorize all hosts before using this method. See `block access-revoke`. VOLUME_ID - the volume ID...
[ "def", "cli", "(", "env", ",", "volume_id", ",", "lun_id", ")", ":", "block_storage_manager", "=", "SoftLayer", ".", "BlockStorageManager", "(", "env", ".", "client", ")", "res", "=", "block_storage_manager", ".", "create_or_update_lun_id", "(", "volume_id", ","...
Set the LUN ID on an existing block storage volume. The LUN ID only takes effect during the Host Authorization process. It is recommended (but not necessary) to de-authorize all hosts before using this method. See `block access-revoke`. VOLUME_ID - the volume ID on which to set the LUN ID. LUN_ID...
[ "Set", "the", "LUN", "ID", "on", "an", "existing", "block", "storage", "volume", "." ]
python
train
zenodo/zenodo-accessrequests
zenodo_accessrequests/models.py
https://github.com/zenodo/zenodo-accessrequests/blob/ce2cf3f1425d02ba4f3ad3202cfca43a1892558a/zenodo_accessrequests/models.py#L360-L369
def create_secret_link(self, title, description=None, expires_at=None): """Create a secret link from request.""" self.link = SecretLink.create( title, self.receiver, extra_data=dict(recid=self.recid), description=description, expires_at=expires...
[ "def", "create_secret_link", "(", "self", ",", "title", ",", "description", "=", "None", ",", "expires_at", "=", "None", ")", ":", "self", ".", "link", "=", "SecretLink", ".", "create", "(", "title", ",", "self", ".", "receiver", ",", "extra_data", "=", ...
Create a secret link from request.
[ "Create", "a", "secret", "link", "from", "request", "." ]
python
test
yunojuno/elasticsearch-django
elasticsearch_django/settings.py
https://github.com/yunojuno/elasticsearch-django/blob/e8d98d32bcd77f1bedb8f1a22b6523ca44ffd489/elasticsearch_django/settings.py#L29-L34
def get_setting(key, *default): """Return specific search setting from Django conf.""" if default: return get_settings().get(key, default[0]) else: return get_settings()[key]
[ "def", "get_setting", "(", "key", ",", "*", "default", ")", ":", "if", "default", ":", "return", "get_settings", "(", ")", ".", "get", "(", "key", ",", "default", "[", "0", "]", ")", "else", ":", "return", "get_settings", "(", ")", "[", "key", "]" ...
Return specific search setting from Django conf.
[ "Return", "specific", "search", "setting", "from", "Django", "conf", "." ]
python
train
ask/carrot
carrot/backends/queue.py
https://github.com/ask/carrot/blob/5889a25cd2e274642071c9bba39772f4b3e3d9da/carrot/backends/queue.py#L33-L45
def get(self, *args, **kwargs): """Get the next waiting message from the queue. :returns: A :class:`Message` instance, or ``None`` if there is no messages waiting. """ if not mqueue.qsize(): return None message_data, content_type, content_encoding = mque...
[ "def", "get", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "mqueue", ".", "qsize", "(", ")", ":", "return", "None", "message_data", ",", "content_type", ",", "content_encoding", "=", "mqueue", ".", "get", "(", ")", ...
Get the next waiting message from the queue. :returns: A :class:`Message` instance, or ``None`` if there is no messages waiting.
[ "Get", "the", "next", "waiting", "message", "from", "the", "queue", "." ]
python
train
swharden/PyOriginTools
PyOriginTools/highlevel.py
https://github.com/swharden/PyOriginTools/blob/536fb8e11234ffdc27e26b1800e0358179ca7d26/PyOriginTools/highlevel.py#L227-L254
def getSheet(book=None,sheet=None): """returns the pyorigin object for a sheet.""" # figure out what book to use if book and not book.lower() in [x.lower() for x in bookNames()]: print("book %s doesn't exist"%book) return if book is None: book=activeBook().lower() if book is...
[ "def", "getSheet", "(", "book", "=", "None", ",", "sheet", "=", "None", ")", ":", "# figure out what book to use", "if", "book", "and", "not", "book", ".", "lower", "(", ")", "in", "[", "x", ".", "lower", "(", ")", "for", "x", "in", "bookNames", "(",...
returns the pyorigin object for a sheet.
[ "returns", "the", "pyorigin", "object", "for", "a", "sheet", "." ]
python
train
PmagPy/PmagPy
pmagpy/contribution_builder.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/contribution_builder.py#L1689-L1712
def drop_stub_rows(self, ignore_cols=('specimen', 'sample', 'software_packages', 'num')): """ Drop self.df rows that have only null values, ignoring certain columns. ...
[ "def", "drop_stub_rows", "(", "self", ",", "ignore_cols", "=", "(", "'specimen'", ",", "'sample'", ",", "'software_packages'", ",", "'num'", ")", ")", ":", "# ignore citations if they just say 'This study'", "if", "'citations'", "in", "self", ".", "df", ".", "colu...
Drop self.df rows that have only null values, ignoring certain columns. Parameters ---------- ignore_cols : list-like list of column names to ignore for Returns --------- self.df : pandas DataFrame
[ "Drop", "self", ".", "df", "rows", "that", "have", "only", "null", "values", "ignoring", "certain", "columns", "." ]
python
train
econ-ark/HARK
HARK/utilities.py
https://github.com/econ-ark/HARK/blob/3d184153a189e618a87c9540df1cd12044039cc5/HARK/utilities.py#L259-L279
def CRRAutility_invP(u, gam): ''' Evaluates the derivative of the inverse of the CRRA utility function (with risk aversion parameter gam) at a given utility level u. Parameters ---------- u : float Utility value gam : float Risk aversion Returns ------- (unnamed...
[ "def", "CRRAutility_invP", "(", "u", ",", "gam", ")", ":", "if", "gam", "==", "1", ":", "return", "np", ".", "exp", "(", "u", ")", "else", ":", "return", "(", "(", "(", "1.0", "-", "gam", ")", "*", "u", ")", "**", "(", "gam", "/", "(", "1.0...
Evaluates the derivative of the inverse of the CRRA utility function (with risk aversion parameter gam) at a given utility level u. Parameters ---------- u : float Utility value gam : float Risk aversion Returns ------- (unnamed) : float Marginal consumption cor...
[ "Evaluates", "the", "derivative", "of", "the", "inverse", "of", "the", "CRRA", "utility", "function", "(", "with", "risk", "aversion", "parameter", "gam", ")", "at", "a", "given", "utility", "level", "u", "." ]
python
train
AkihikoITOH/capybara
capybara/virtualenv/lib/python2.7/site-packages/lxml/html/diff.py
https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/lxml/html/diff.py#L100-L113
def compress_tokens(tokens): """ Combine adjacent tokens when there is no HTML between the tokens, and they share an annotation """ result = [tokens[0]] for tok in tokens[1:]: if (not result[-1].post_tags and not tok.pre_tags and result[-1].annotation == tok....
[ "def", "compress_tokens", "(", "tokens", ")", ":", "result", "=", "[", "tokens", "[", "0", "]", "]", "for", "tok", "in", "tokens", "[", "1", ":", "]", ":", "if", "(", "not", "result", "[", "-", "1", "]", ".", "post_tags", "and", "not", "tok", "...
Combine adjacent tokens when there is no HTML between the tokens, and they share an annotation
[ "Combine", "adjacent", "tokens", "when", "there", "is", "no", "HTML", "between", "the", "tokens", "and", "they", "share", "an", "annotation" ]
python
test
SeattleTestbed/seash
seash_modules.py
https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/seash_modules.py#L598-L608
def _ensure_module_folder_exists(): """ Checks to see if the module folder exists. If it does not, create it. If there is an existing file with the same name, we raise a RuntimeError. """ if not os.path.isdir(MODULES_FOLDER_PATH): try: os.mkdir(MODULES_FOLDER_PATH) except OSError, e: if "...
[ "def", "_ensure_module_folder_exists", "(", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "MODULES_FOLDER_PATH", ")", ":", "try", ":", "os", ".", "mkdir", "(", "MODULES_FOLDER_PATH", ")", "except", "OSError", ",", "e", ":", "if", "\"file alr...
Checks to see if the module folder exists. If it does not, create it. If there is an existing file with the same name, we raise a RuntimeError.
[ "Checks", "to", "see", "if", "the", "module", "folder", "exists", ".", "If", "it", "does", "not", "create", "it", ".", "If", "there", "is", "an", "existing", "file", "with", "the", "same", "name", "we", "raise", "a", "RuntimeError", "." ]
python
train
TheHive-Project/Cortex-Analyzers
analyzers/Malpedia/malpedia_analyzer.py
https://github.com/TheHive-Project/Cortex-Analyzers/blob/8dae6a8c4cf9af5554ae8c844985c4b44d4bd4bf/analyzers/Malpedia/malpedia_analyzer.py#L58-L92
def check(self, file): """ Checks a given file against all available yara rules :param file: Path to file :type file:str :returns: Python list with matched rules info :rtype: list """ result = [] all_matches = [] for filerules in os.listdir...
[ "def", "check", "(", "self", ",", "file", ")", ":", "result", "=", "[", "]", "all_matches", "=", "[", "]", "for", "filerules", "in", "os", ".", "listdir", "(", "self", ".", "rulepaths", ")", ":", "try", ":", "rule", "=", "yara", ".", "compile", "...
Checks a given file against all available yara rules :param file: Path to file :type file:str :returns: Python list with matched rules info :rtype: list
[ "Checks", "a", "given", "file", "against", "all", "available", "yara", "rules", ":", "param", "file", ":", "Path", "to", "file", ":", "type", "file", ":", "str", ":", "returns", ":", "Python", "list", "with", "matched", "rules", "info", ":", "rtype", "...
python
train
wummel/patool
patoolib/programs/rzip.py
https://github.com/wummel/patool/blob/d7e64d9fd60faaa4b3f824bd97c43ce59b185c40/patoolib/programs/rzip.py#L19-L26
def extract_rzip (archive, compression, cmd, verbosity, interactive, outdir): """Extract an RZIP archive.""" cmdlist = [cmd, '-d', '-k'] if verbosity > 1: cmdlist.append('-v') outfile = util.get_single_outfile(outdir, archive) cmdlist.extend(["-o", outfile, archive]) return cmdlist
[ "def", "extract_rzip", "(", "archive", ",", "compression", ",", "cmd", ",", "verbosity", ",", "interactive", ",", "outdir", ")", ":", "cmdlist", "=", "[", "cmd", ",", "'-d'", ",", "'-k'", "]", "if", "verbosity", ">", "1", ":", "cmdlist", ".", "append",...
Extract an RZIP archive.
[ "Extract", "an", "RZIP", "archive", "." ]
python
train
aboSamoor/polyglot
polyglot/__main__.py
https://github.com/aboSamoor/polyglot/blob/d0d2aa8d06cec4e03bd96618ae960030f7069a17/polyglot/__main__.py#L68-L76
def transliterate(args): """Transliterate words according to the target language.""" t = Transliterator(source_lang=args.lang, target_lang=args.target) for l in args.input: words = l.strip().split() line_annotations = [u"{:<16}{:<16}".format(w, t.transliterate(w)) for w in words] ...
[ "def", "transliterate", "(", "args", ")", ":", "t", "=", "Transliterator", "(", "source_lang", "=", "args", ".", "lang", ",", "target_lang", "=", "args", ".", "target", ")", "for", "l", "in", "args", ".", "input", ":", "words", "=", "l", ".", "strip"...
Transliterate words according to the target language.
[ "Transliterate", "words", "according", "to", "the", "target", "language", "." ]
python
train
ArchiveTeam/wpull
wpull/network/pool.py
https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/network/pool.py#L251-L272
def session(self, host: str, port: int, use_ssl: bool=False): '''Return a context manager that returns a connection. Usage:: session = yield from connection_pool.session('example.com', 80) with session as connection: connection.write(b'blah') con...
[ "def", "session", "(", "self", ",", "host", ":", "str", ",", "port", ":", "int", ",", "use_ssl", ":", "bool", "=", "False", ")", ":", "connection", "=", "yield", "from", "self", ".", "acquire", "(", "host", ",", "port", ",", "use_ssl", ")", "@", ...
Return a context manager that returns a connection. Usage:: session = yield from connection_pool.session('example.com', 80) with session as connection: connection.write(b'blah') connection.close() Coroutine.
[ "Return", "a", "context", "manager", "that", "returns", "a", "connection", "." ]
python
train
gholt/swiftly
swiftly/cli/cli.py
https://github.com/gholt/swiftly/blob/5bcc1c65323b1caf1f85adbefd9fc4988c072149/swiftly/cli/cli.py#L433-L458
def _resolve_option(self, options, option_name, section_name): """Resolves an option value into options. Sets options.<option_name> to a resolved value. Any value already in options overrides a value in os.environ which overrides self.context.conf. :param options: The options i...
[ "def", "_resolve_option", "(", "self", ",", "options", ",", "option_name", ",", "section_name", ")", ":", "if", "getattr", "(", "options", ",", "option_name", ",", "None", ")", "is", "not", "None", ":", "return", "if", "option_name", ".", "startswith", "("...
Resolves an option value into options. Sets options.<option_name> to a resolved value. Any value already in options overrides a value in os.environ which overrides self.context.conf. :param options: The options instance as returned by optparse. :param option_name: The name of t...
[ "Resolves", "an", "option", "value", "into", "options", "." ]
python
test
campbellr/smashrun-client
smashrun/client.py
https://github.com/campbellr/smashrun-client/blob/2522cb4d0545cf482a49a9533f12aac94c5aecdc/smashrun/client.py#L129-L138
def get_splits(self, id_num, unit='mi'): """Return the splits of the activity with the given id. :param unit: The unit to use for splits. May be one of 'mi' or 'km'. """ url = self._build_url('my', 'activities', id_num, 'splits', unit) return self._json(u...
[ "def", "get_splits", "(", "self", ",", "id_num", ",", "unit", "=", "'mi'", ")", ":", "url", "=", "self", ".", "_build_url", "(", "'my'", ",", "'activities'", ",", "id_num", ",", "'splits'", ",", "unit", ")", "return", "self", ".", "_json", "(", "url"...
Return the splits of the activity with the given id. :param unit: The unit to use for splits. May be one of 'mi' or 'km'.
[ "Return", "the", "splits", "of", "the", "activity", "with", "the", "given", "id", "." ]
python
train
vvangelovski/django-audit-log
audit_log/models/managers.py
https://github.com/vvangelovski/django-audit-log/blob/f1bee75360a67390fbef67c110e9a245b41ebb92/audit_log/models/managers.py#L128-L186
def copy_fields(self, model): """ Creates copies of the fields we are keeping track of for the provided model, returning a dictionary mapping field name to a copied field object. """ fields = {'__module__' : model.__module__} for field in model._meta.fields: ...
[ "def", "copy_fields", "(", "self", ",", "model", ")", ":", "fields", "=", "{", "'__module__'", ":", "model", ".", "__module__", "}", "for", "field", "in", "model", ".", "_meta", ".", "fields", ":", "if", "not", "field", ".", "name", "in", "self", "."...
Creates copies of the fields we are keeping track of for the provided model, returning a dictionary mapping field name to a copied field object.
[ "Creates", "copies", "of", "the", "fields", "we", "are", "keeping", "track", "of", "for", "the", "provided", "model", "returning", "a", "dictionary", "mapping", "field", "name", "to", "a", "copied", "field", "object", "." ]
python
train
skyfielders/python-skyfield
skyfield/precessionlib.py
https://github.com/skyfielders/python-skyfield/blob/51d9e042e06457f6b1f2415296d50a38cb3a300f/skyfield/precessionlib.py#L5-L69
def compute_precession(jd_tdb): """Return the rotation matrices for precessing to an array of epochs. `jd_tdb` - array of TDB Julian dates The array returned has the shape `(3, 3, n)` where `n` is the number of dates that have been provided as input. """ eps0 = 84381.406 # 't' is time in...
[ "def", "compute_precession", "(", "jd_tdb", ")", ":", "eps0", "=", "84381.406", "# 't' is time in TDB centuries.", "t", "=", "(", "jd_tdb", "-", "T0", ")", "/", "36525.0", "# Numerical coefficients of psi_a, omega_a, and chi_a, along with", "# epsilon_0, the obliquity at J200...
Return the rotation matrices for precessing to an array of epochs. `jd_tdb` - array of TDB Julian dates The array returned has the shape `(3, 3, n)` where `n` is the number of dates that have been provided as input.
[ "Return", "the", "rotation", "matrices", "for", "precessing", "to", "an", "array", "of", "epochs", "." ]
python
train
frictionlessdata/datapackage-py
datapackage/package.py
https://github.com/frictionlessdata/datapackage-py/blob/aca085ea54541b087140b58a81332f8728baeeb2/datapackage/package.py#L396-L405
def iter_errors(self): """"Lazily yields each ValidationError for the received data dict. """ # Deprecate warnings.warn( 'Property "package.iter_errors" is deprecated.', UserWarning) return self.profile.iter_errors(self.to_dict())
[ "def", "iter_errors", "(", "self", ")", ":", "# Deprecate", "warnings", ".", "warn", "(", "'Property \"package.iter_errors\" is deprecated.'", ",", "UserWarning", ")", "return", "self", ".", "profile", ".", "iter_errors", "(", "self", ".", "to_dict", "(", ")", "...
Lazily yields each ValidationError for the received data dict.
[ "Lazily", "yields", "each", "ValidationError", "for", "the", "received", "data", "dict", "." ]
python
valid
fprimex/zdesk
zdesk/zdesk_api.py
https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L2403-L2407
def nps_survey_show(self, id, **kwargs): "https://developer.zendesk.com/rest_api/docs/nps-api/surveys#show-survey" api_path = "/api/v2/nps/surveys/{id}" api_path = api_path.format(id=id) return self.call(api_path, **kwargs)
[ "def", "nps_survey_show", "(", "self", ",", "id", ",", "*", "*", "kwargs", ")", ":", "api_path", "=", "\"/api/v2/nps/surveys/{id}\"", "api_path", "=", "api_path", ".", "format", "(", "id", "=", "id", ")", "return", "self", ".", "call", "(", "api_path", "...
https://developer.zendesk.com/rest_api/docs/nps-api/surveys#show-survey
[ "https", ":", "//", "developer", ".", "zendesk", ".", "com", "/", "rest_api", "/", "docs", "/", "nps", "-", "api", "/", "surveys#show", "-", "survey" ]
python
train
portfoliome/postpy
postpy/admin.py
https://github.com/portfoliome/postpy/blob/fe26199131b15295fc5f669a0ad2a7f47bf490ee/postpy/admin.py#L24-L44
def get_primary_keys(conn, table: str, schema='public'): """Returns primary key columns for a specific table.""" query = """\ SELECT c.constraint_name AS pkey_constraint_name, c.column_name AS column_name FROM information_schema.key_column_usage AS c JOIN information_schema.table_constraints AS t ...
[ "def", "get_primary_keys", "(", "conn", ",", "table", ":", "str", ",", "schema", "=", "'public'", ")", ":", "query", "=", "\"\"\"\\\nSELECT\n c.constraint_name AS pkey_constraint_name,\n c.column_name AS column_name\nFROM\n information_schema.key_column_usage AS c\n JOIN info...
Returns primary key columns for a specific table.
[ "Returns", "primary", "key", "columns", "for", "a", "specific", "table", "." ]
python
train
vanheeringen-lab/gimmemotifs
gimmemotifs/scanner.py
https://github.com/vanheeringen-lab/gimmemotifs/blob/1dc0572179e5d0c8f96958060133c1f8d92c6675/gimmemotifs/scanner.py#L515-L522
def count(self, seqs, nreport=100, scan_rc=True): """ count the number of matches above the cutoff returns an iterator of lists containing integer counts """ for matches in self.scan(seqs, nreport, scan_rc): counts = [len(m) for m in matches] yield counts
[ "def", "count", "(", "self", ",", "seqs", ",", "nreport", "=", "100", ",", "scan_rc", "=", "True", ")", ":", "for", "matches", "in", "self", ".", "scan", "(", "seqs", ",", "nreport", ",", "scan_rc", ")", ":", "counts", "=", "[", "len", "(", "m", ...
count the number of matches above the cutoff returns an iterator of lists containing integer counts
[ "count", "the", "number", "of", "matches", "above", "the", "cutoff", "returns", "an", "iterator", "of", "lists", "containing", "integer", "counts" ]
python
train
zmathew/django-backbone
backbone/views.py
https://github.com/zmathew/django-backbone/blob/53505a247fb058e64a103c4f11da66993037bd6b/backbone/views.py#L90-L101
def post(self, request, id=None, **kwargs): """ Handles post requests. """ if id: # No posting to an object detail page return HttpResponseForbidden() else: if not self.has_add_permission(request): return HttpResponseForbidden(_...
[ "def", "post", "(", "self", ",", "request", ",", "id", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "id", ":", "# No posting to an object detail page", "return", "HttpResponseForbidden", "(", ")", "else", ":", "if", "not", "self", ".", "has_add_pe...
Handles post requests.
[ "Handles", "post", "requests", "." ]
python
train
juju/theblues
theblues/charmstore.py
https://github.com/juju/theblues/blob/f4431f29e43d04fc32f38f4f86cea45cd4e6ae98/theblues/charmstore.py#L66-L106
def _get(self, url): """Make a get request against the charmstore. This method is used by other API methods to standardize querying. @param url The full url to query (e.g. https://api.jujucharms.com/charmstore/v4/macaroon) """ try: response = requests.get...
[ "def", "_get", "(", "self", ",", "url", ")", ":", "try", ":", "response", "=", "requests", ".", "get", "(", "url", ",", "verify", "=", "self", ".", "verify", ",", "cookies", "=", "self", ".", "cookies", ",", "timeout", "=", "self", ".", "timeout", ...
Make a get request against the charmstore. This method is used by other API methods to standardize querying. @param url The full url to query (e.g. https://api.jujucharms.com/charmstore/v4/macaroon)
[ "Make", "a", "get", "request", "against", "the", "charmstore", "." ]
python
train
craffel/mir_eval
mir_eval/chord.py
https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/chord.py#L1238-L1290
def sevenths(reference_labels, estimated_labels): """Compare chords along MIREX 'sevenths' rules. Chords with qualities outside [maj, maj7, 7, min, min7, N] are ignored. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals...
[ "def", "sevenths", "(", "reference_labels", ",", "estimated_labels", ")", ":", "validate", "(", "reference_labels", ",", "estimated_labels", ")", "seventh_qualities", "=", "[", "'maj'", ",", "'min'", ",", "'maj7'", ",", "'7'", ",", "'min7'", ",", "''", "]", ...
Compare chords along MIREX 'sevenths' rules. Chords with qualities outside [maj, maj7, 7, min, min7, N] are ignored. Examples -------- >>> (ref_intervals, ... ref_labels) = mir_eval.io.load_labeled_intervals('ref.lab') >>> (est_intervals, ... est_labels) = mir_eval.io.load_labeled_interva...
[ "Compare", "chords", "along", "MIREX", "sevenths", "rules", ".", "Chords", "with", "qualities", "outside", "[", "maj", "maj7", "7", "min", "min7", "N", "]", "are", "ignored", "." ]
python
train
pjuren/pyokit
src/pyokit/datastruct/read.py
https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/datastruct/read.py#L232-L256
def merge(self, other, forceMerge=False): """ Merge two reads by concatenating their sequence data and their quality data (<self> first, then <other>); <self> and <other> must have the same sequence name. A new merged FastqSequence object is returned; <Self> and <other> are left unaltered. ...
[ "def", "merge", "(", "self", ",", "other", ",", "forceMerge", "=", "False", ")", ":", "if", "self", ".", "sequenceName", "!=", "other", ".", "sequenceName", "and", "not", "forceMerge", ":", "raise", "NGSReadError", "(", "\"cannot merge \"", "+", "self", "....
Merge two reads by concatenating their sequence data and their quality data (<self> first, then <other>); <self> and <other> must have the same sequence name. A new merged FastqSequence object is returned; <Self> and <other> are left unaltered. :param other: the other sequence to merge with sel...
[ "Merge", "two", "reads", "by", "concatenating", "their", "sequence", "data", "and", "their", "quality", "data", "(", "<self", ">", "first", "then", "<other", ">", ")", ";", "<self", ">", "and", "<other", ">", "must", "have", "the", "same", "sequence", "n...
python
train
reingart/pyafipws
utils.py
https://github.com/reingart/pyafipws/blob/ee87cfe4ac12285ab431df5fec257f103042d1ab/utils.py#L566-L614
def leer(linea, formato, expandir_fechas=False): "Analiza una linea de texto dado un formato, devuelve un diccionario" dic = {} comienzo = 1 for fmt in formato: clave, longitud, tipo = fmt[0:3] dec = (len(fmt)>3 and isinstance(fmt[3], int)) and fmt[3] or 2 valor = linea[comie...
[ "def", "leer", "(", "linea", ",", "formato", ",", "expandir_fechas", "=", "False", ")", ":", "dic", "=", "{", "}", "comienzo", "=", "1", "for", "fmt", "in", "formato", ":", "clave", ",", "longitud", ",", "tipo", "=", "fmt", "[", "0", ":", "3", "]...
Analiza una linea de texto dado un formato, devuelve un diccionario
[ "Analiza", "una", "linea", "de", "texto", "dado", "un", "formato", "devuelve", "un", "diccionario" ]
python
train
vertexproject/synapse
synapse/lib/syntax.py
https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/lib/syntax.py#L328-L347
def parse_cmd_kwlist(text, off=0): ''' Parse a foo:bar=<valu>[,...] kwarg list into (prop,valu),off ''' kwlist = [] _, off = nom(text, off, whites) while off < len(text): (p, v), off = parse_cmd_kwarg(text, off=off) kwlist.append((p, v)) _, off = nom(text, off, white...
[ "def", "parse_cmd_kwlist", "(", "text", ",", "off", "=", "0", ")", ":", "kwlist", "=", "[", "]", "_", ",", "off", "=", "nom", "(", "text", ",", "off", ",", "whites", ")", "while", "off", "<", "len", "(", "text", ")", ":", "(", "p", ",", "v", ...
Parse a foo:bar=<valu>[,...] kwarg list into (prop,valu),off
[ "Parse", "a", "foo", ":", "bar", "=", "<valu", ">", "[", "...", "]", "kwarg", "list", "into", "(", "prop", "valu", ")", "off" ]
python
train
anjishnu/ask-alexa-pykit
examples/twitter/lambda_function.py
https://github.com/anjishnu/ask-alexa-pykit/blob/a47c278ca7a60532bbe1a9b789f6c37e609fea8b/examples/twitter/lambda_function.py#L322-L337
def next_intent_handler(request): """ Takes care of things whenver the user says 'next' """ message = "Sorry, couldn't find anything in your next queue" end_session = True if True: user_queue = twitter_cache.user_queue(request.access_token()) if not user_queue.is_finished(): ...
[ "def", "next_intent_handler", "(", "request", ")", ":", "message", "=", "\"Sorry, couldn't find anything in your next queue\"", "end_session", "=", "True", "if", "True", ":", "user_queue", "=", "twitter_cache", ".", "user_queue", "(", "request", ".", "access_token", "...
Takes care of things whenver the user says 'next'
[ "Takes", "care", "of", "things", "whenver", "the", "user", "says", "next" ]
python
train
saltstack/salt
salt/returners/influxdb_return.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/influxdb_return.py#L313-L326
def get_minions(): ''' Return a list of minions ''' serv = _get_serv(ret=None) sql = "select distinct(id) from returns" data = serv.query(sql) ret = [] if data: for jid in data[0]['points']: ret.append(jid[1]) return ret
[ "def", "get_minions", "(", ")", ":", "serv", "=", "_get_serv", "(", "ret", "=", "None", ")", "sql", "=", "\"select distinct(id) from returns\"", "data", "=", "serv", ".", "query", "(", "sql", ")", "ret", "=", "[", "]", "if", "data", ":", "for", "jid", ...
Return a list of minions
[ "Return", "a", "list", "of", "minions" ]
python
train
scanny/python-pptx
pptx/chart/data.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/chart/data.py#L711-L719
def add_series(self, name, number_format=None): """ Return a |BubbleSeriesData| object newly created and added at the end of this sequence, and having series named *name* and values formatted with *number_format*. """ series_data = BubbleSeriesData(self, name, number_form...
[ "def", "add_series", "(", "self", ",", "name", ",", "number_format", "=", "None", ")", ":", "series_data", "=", "BubbleSeriesData", "(", "self", ",", "name", ",", "number_format", ")", "self", ".", "append", "(", "series_data", ")", "return", "series_data" ]
Return a |BubbleSeriesData| object newly created and added at the end of this sequence, and having series named *name* and values formatted with *number_format*.
[ "Return", "a", "|BubbleSeriesData|", "object", "newly", "created", "and", "added", "at", "the", "end", "of", "this", "sequence", "and", "having", "series", "named", "*", "name", "*", "and", "values", "formatted", "with", "*", "number_format", "*", "." ]
python
train
lemieuxl/pyplink
pyplink/pyplink.py
https://github.com/lemieuxl/pyplink/blob/31d47c86f589064bda98206314a2d0b20e7fd2f0/pyplink/pyplink.py#L410-L414
def _write_bed_header(self): """Writes the BED first 3 bytes.""" # Writing the first three bytes final_byte = 1 if self._bed_format == "SNP-major" else 0 self._bed.write(bytearray((108, 27, final_byte)))
[ "def", "_write_bed_header", "(", "self", ")", ":", "# Writing the first three bytes", "final_byte", "=", "1", "if", "self", ".", "_bed_format", "==", "\"SNP-major\"", "else", "0", "self", ".", "_bed", ".", "write", "(", "bytearray", "(", "(", "108", ",", "27...
Writes the BED first 3 bytes.
[ "Writes", "the", "BED", "first", "3", "bytes", "." ]
python
train
aetros/aetros-cli
aetros/client.py
https://github.com/aetros/aetros-cli/blob/a2a1f38d6af1660e1e2680c7d413ec2aef45faab/aetros/client.py#L496-L537
def wait_until_queue_empty(self, channels, report=True, clear_end=True): """ Waits until all queues of channels are empty. """ state = {'message': ''} self.logger.debug("wait_until_queue_empty: report=%s %s" % (str(report), str([channel+':'+str(len(self...
[ "def", "wait_until_queue_empty", "(", "self", ",", "channels", ",", "report", "=", "True", ",", "clear_end", "=", "True", ")", ":", "state", "=", "{", "'message'", ":", "''", "}", "self", ".", "logger", ".", "debug", "(", "\"wait_until_queue_empty: report=%s...
Waits until all queues of channels are empty.
[ "Waits", "until", "all", "queues", "of", "channels", "are", "empty", "." ]
python
train
portfoliome/foil
foil/deserializers.py
https://github.com/portfoliome/foil/blob/b66d8cf4ab048a387d8c7a033b47e922ed6917d6/foil/deserializers.py#L45-L65
def json_decoder_hook(dct, str_decoders=STRING_DECODERS, converters=MappingProxyType(dict())) -> dict: """Decoder for parsing typical objects like uuid's and dates.""" for k, v in dct.items(): if k in converters: parse_func = converters[k] dct[k] = parse_fu...
[ "def", "json_decoder_hook", "(", "dct", ",", "str_decoders", "=", "STRING_DECODERS", ",", "converters", "=", "MappingProxyType", "(", "dict", "(", ")", ")", ")", "->", "dict", ":", "for", "k", ",", "v", "in", "dct", ".", "items", "(", ")", ":", "if", ...
Decoder for parsing typical objects like uuid's and dates.
[ "Decoder", "for", "parsing", "typical", "objects", "like", "uuid", "s", "and", "dates", "." ]
python
train
tanghaibao/jcvi
jcvi/formats/fasta.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/formats/fasta.py#L2209-L2257
def tidy(args): """ %prog tidy fastafile Trim terminal Ns, normalize gap sizes and remove small components. """ p = OptionParser(tidy.__doc__) p.add_option("--gapsize", dest="gapsize", default=0, type="int", help="Set all gaps to the same size [default: %default]") p.add_option(...
[ "def", "tidy", "(", "args", ")", ":", "p", "=", "OptionParser", "(", "tidy", ".", "__doc__", ")", "p", ".", "add_option", "(", "\"--gapsize\"", ",", "dest", "=", "\"gapsize\"", ",", "default", "=", "0", ",", "type", "=", "\"int\"", ",", "help", "=", ...
%prog tidy fastafile Trim terminal Ns, normalize gap sizes and remove small components.
[ "%prog", "tidy", "fastafile" ]
python
train
carpedm20/fbchat
fbchat/_client.py
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L2319-L2332
def deleteMessages(self, message_ids): """ Deletes specifed messages :param message_ids: Message IDs to delete :return: Whether the request was successful :raises: FBchatException if request failed """ message_ids = require_list(message_ids) data = dict()...
[ "def", "deleteMessages", "(", "self", ",", "message_ids", ")", ":", "message_ids", "=", "require_list", "(", "message_ids", ")", "data", "=", "dict", "(", ")", "for", "i", ",", "message_id", "in", "enumerate", "(", "message_ids", ")", ":", "data", "[", "...
Deletes specifed messages :param message_ids: Message IDs to delete :return: Whether the request was successful :raises: FBchatException if request failed
[ "Deletes", "specifed", "messages" ]
python
train
szairis/sakmapper
sakmapper/network.py
https://github.com/szairis/sakmapper/blob/ac462fd2674e6aa1aa3b209222d8ac4e9268a790/sakmapper/network.py#L173-L220
def mapper_graph(df, lens_data=None, lens='pca', resolution=10, gain=0.5, equalize=True, clust='kmeans', stat='db', max_K=5): """ input: N x n_dim image of of raw data under lens function, as a dataframe output: (undirected graph, list of node contents, dictionary of patches) """ if...
[ "def", "mapper_graph", "(", "df", ",", "lens_data", "=", "None", ",", "lens", "=", "'pca'", ",", "resolution", "=", "10", ",", "gain", "=", "0.5", ",", "equalize", "=", "True", ",", "clust", "=", "'kmeans'", ",", "stat", "=", "'db'", ",", "max_K", ...
input: N x n_dim image of of raw data under lens function, as a dataframe output: (undirected graph, list of node contents, dictionary of patches)
[ "input", ":", "N", "x", "n_dim", "image", "of", "of", "raw", "data", "under", "lens", "function", "as", "a", "dataframe", "output", ":", "(", "undirected", "graph", "list", "of", "node", "contents", "dictionary", "of", "patches", ")" ]
python
train
KnowledgeLinks/rdfframework
rdfframework/search/esmappings.py
https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esmappings.py#L71-L88
def list_indexes(cls): """ Returns a dictionary with the key as the es_index name and the object is a list of rdfclasses for that index args: None """ cls_list = cls.list_mapped_classes() rtn_obj = {} for key, value in cls_list.ite...
[ "def", "list_indexes", "(", "cls", ")", ":", "cls_list", "=", "cls", ".", "list_mapped_classes", "(", ")", "rtn_obj", "=", "{", "}", "for", "key", ",", "value", "in", "cls_list", ".", "items", "(", ")", ":", "idx", "=", "value", ".", "es_defs", ".", ...
Returns a dictionary with the key as the es_index name and the object is a list of rdfclasses for that index args: None
[ "Returns", "a", "dictionary", "with", "the", "key", "as", "the", "es_index", "name", "and", "the", "object", "is", "a", "list", "of", "rdfclasses", "for", "that", "index", "args", ":", "None" ]
python
train