repo
stringlengths
7
55
path
stringlengths
4
223
url
stringlengths
87
315
code
stringlengths
75
104k
code_tokens
list
docstring
stringlengths
1
46.9k
docstring_tokens
list
language
stringclasses
1 value
partition
stringclasses
3 values
avg_line_len
float64
7.91
980
bitesofcode/projexui
projexui/widgets/xchart/xchart.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchart/xchart.py#L217-L225
def addDataset(self, dataset): """ Adds the given data set to this chart widget. :param dataSet | <XChartDataset> """ self._datasets.append(dataset) self._dataChanged = True self._addDatasetAction(dataset)
[ "def", "addDataset", "(", "self", ",", "dataset", ")", ":", "self", ".", "_datasets", ".", "append", "(", "dataset", ")", "self", ".", "_dataChanged", "=", "True", "self", ".", "_addDatasetAction", "(", "dataset", ")" ]
Adds the given data set to this chart widget. :param dataSet | <XChartDataset>
[ "Adds", "the", "given", "data", "set", "to", "this", "chart", "widget", ".", ":", "param", "dataSet", "|", "<XChartDataset", ">" ]
python
train
30.555556
log2timeline/plaso
plaso/parsers/winreg_plugins/appcompatcache.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/winreg_plugins/appcompatcache.py#L170-L222
def _GetCachedEntryDataTypeMap( self, format_type, value_data, cached_entry_offset): """Determines the cached entry data type map. Args: format_type (int): format type. value_data (bytes): value data. cached_entry_offset (int): offset of the first cached entry data relative to...
[ "def", "_GetCachedEntryDataTypeMap", "(", "self", ",", "format_type", ",", "value_data", ",", "cached_entry_offset", ")", ":", "if", "format_type", "not", "in", "self", ".", "_SUPPORTED_FORMAT_TYPES", ":", "raise", "errors", ".", "ParseError", "(", "'Unsupported for...
Determines the cached entry data type map. Args: format_type (int): format type. value_data (bytes): value data. cached_entry_offset (int): offset of the first cached entry data relative to the start of the value data. Returns: dtfabric.DataTypeMap: data type map which contai...
[ "Determines", "the", "cached", "entry", "data", "type", "map", "." ]
python
train
36.90566
gem/oq-engine
openquake/commonlib/oqvalidation.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/oqvalidation.py#L316-L344
def check_gsims(self, gsims): """ :param gsims: a sequence of GSIM instances """ imts = set(from_string(imt).name for imt in self.imtls) for gsim in gsims: restrict_imts = gsim.DEFINED_FOR_INTENSITY_MEASURE_TYPES if restrict_imts: names = s...
[ "def", "check_gsims", "(", "self", ",", "gsims", ")", ":", "imts", "=", "set", "(", "from_string", "(", "imt", ")", ".", "name", "for", "imt", "in", "self", ".", "imtls", ")", "for", "gsim", "in", "gsims", ":", "restrict_imts", "=", "gsim", ".", "D...
:param gsims: a sequence of GSIM instances
[ ":", "param", "gsims", ":", "a", "sequence", "of", "GSIM", "instances" ]
python
train
48.206897
graphql-python/graphql-core
graphql/validation/rules/overlapping_fields_can_be_merged.py
https://github.com/graphql-python/graphql-core/blob/d8e9d3abe7c209eb2f51cf001402783bfd480596/graphql/validation/rules/overlapping_fields_can_be_merged.py#L504-L583
def _find_conflict( context, # type: ValidationContext cached_fields_and_fragment_names, # type: Dict[SelectionSet, Tuple[Dict[str, List[Tuple[Union[GraphQLInterfaceType, GraphQLObjectType, None], Field, GraphQLField]]], List[str]]] compared_fragments, # type: PairSet parent_fields_are_mutually_exclu...
[ "def", "_find_conflict", "(", "context", ",", "# type: ValidationContext", "cached_fields_and_fragment_names", ",", "# type: Dict[SelectionSet, Tuple[Dict[str, List[Tuple[Union[GraphQLInterfaceType, GraphQLObjectType, None], Field, GraphQLField]]], List[str]]]", "compared_fragments", ",", "# t...
Determines if there is a conflict between two particular fields.
[ "Determines", "if", "there", "is", "a", "conflict", "between", "two", "particular", "fields", "." ]
python
train
39.7625
keon/algorithms
algorithms/stack/longest_abs_path.py
https://github.com/keon/algorithms/blob/4d6569464a62a75c1357acc97e2dd32ee2f9f4a3/algorithms/stack/longest_abs_path.py#L36-L58
def length_longest_path(input): """ :type input: str :rtype: int """ curr_len, max_len = 0, 0 # running length and max length stack = [] # keep track of the name length for s in input.split('\n'): print("---------") print("<path>:", s) depth = s.count('\t') #...
[ "def", "length_longest_path", "(", "input", ")", ":", "curr_len", ",", "max_len", "=", "0", ",", "0", "# running length and max length", "stack", "=", "[", "]", "# keep track of the name length", "for", "s", "in", "input", ".", "split", "(", "'\\n'", ")", ":",...
:type input: str :rtype: int
[ ":", "type", "input", ":", "str", ":", "rtype", ":", "int" ]
python
train
38.652174
lorien/grab
grab/proxylist.py
https://github.com/lorien/grab/blob/8b301db2a08c830245b61c589e58af6234f4db79/grab/proxylist.py#L156-L159
def load(self): """Load proxy list from configured proxy source""" self._list = self._source.load() self._list_iter = itertools.cycle(self._list)
[ "def", "load", "(", "self", ")", ":", "self", ".", "_list", "=", "self", ".", "_source", ".", "load", "(", ")", "self", ".", "_list_iter", "=", "itertools", ".", "cycle", "(", "self", ".", "_list", ")" ]
Load proxy list from configured proxy source
[ "Load", "proxy", "list", "from", "configured", "proxy", "source" ]
python
train
41.5
cloudera/cm_api
python/src/cm_api/endpoints/services.py
https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/services.py#L1603-L1615
def trigger_replication_schedule(self, schedule_id, dry_run=False): """ Trigger replication immediately. Start and end dates on the schedule will be ignored. @param schedule_id: The id of the schedule to trigger. @param dry_run: Whether to execute a dry run. @return: The command corresponding t...
[ "def", "trigger_replication_schedule", "(", "self", ",", "schedule_id", ",", "dry_run", "=", "False", ")", ":", "return", "self", ".", "_post", "(", "\"replications/%s/run\"", "%", "schedule_id", ",", "ApiCommand", ",", "params", "=", "dict", "(", "dryRun", "=...
Trigger replication immediately. Start and end dates on the schedule will be ignored. @param schedule_id: The id of the schedule to trigger. @param dry_run: Whether to execute a dry run. @return: The command corresponding to the replication job. @since: API v3
[ "Trigger", "replication", "immediately", ".", "Start", "and", "end", "dates", "on", "the", "schedule", "will", "be", "ignored", "." ]
python
train
37.538462
NetEaseGame/ATX
atx/patch.py
https://github.com/NetEaseGame/ATX/blob/f4415c57b45cb0730e08899cbc92a2af1c047ffb/atx/patch.py#L36-L58
def attachmethod(target): ''' Reference: https://blog.tonyseek.com/post/open-class-in-python/ class Spam(object): pass @attach_method(Spam) def egg1(self, name): print((self, name)) spam1 = Spam() # OpenClass 加入的方法 egg1 可用 spam1.egg1("Test1") # 输出Test1 ''' ...
[ "def", "attachmethod", "(", "target", ")", ":", "if", "isinstance", "(", "target", ",", "type", ")", ":", "def", "decorator", "(", "func", ")", ":", "setattr", "(", "target", ",", "func", ".", "__name__", ",", "func", ")", "else", ":", "def", "decora...
Reference: https://blog.tonyseek.com/post/open-class-in-python/ class Spam(object): pass @attach_method(Spam) def egg1(self, name): print((self, name)) spam1 = Spam() # OpenClass 加入的方法 egg1 可用 spam1.egg1("Test1") # 输出Test1
[ "Reference", ":", "https", ":", "//", "blog", ".", "tonyseek", ".", "com", "/", "post", "/", "open", "-", "class", "-", "in", "-", "python", "/" ]
python
train
23.043478
Yelp/kafka-utils
kafka_utils/kafka_rolling_restart/main.py
https://github.com/Yelp/kafka-utils/blob/cdb4d64308f3079ee0873250bf7b34d0d94eca50/kafka_utils/kafka_rolling_restart/main.py#L360-L440
def execute_rolling_restart( brokers, jolokia_port, jolokia_prefix, check_interval, check_count, unhealthy_time_limit, skip, verbose, pre_stop_task, post_stop_task, start_command, stop_command, ssh_password=None ): """Execute the rolling restart on the specified b...
[ "def", "execute_rolling_restart", "(", "brokers", ",", "jolokia_port", ",", "jolokia_prefix", ",", "check_interval", ",", "check_count", ",", "unhealthy_time_limit", ",", "skip", ",", "verbose", ",", "pre_stop_task", ",", "post_stop_task", ",", "start_command", ",", ...
Execute the rolling restart on the specified brokers. It checks the number of under replicated partitions on each broker, using Jolokia. The check is performed at constant intervals, and a broker will be restarted when all the brokers are answering and are reporting zero under replicated partitions. ...
[ "Execute", "the", "rolling", "restart", "on", "the", "specified", "brokers", ".", "It", "checks", "the", "number", "of", "under", "replicated", "partitions", "on", "each", "broker", "using", "Jolokia", "." ]
python
train
39.580247
StackStorm/pybind
pybind/nos/v6_0_2f/rbridge_id/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/rbridge_id/__init__.py#L1176-L1199
def _set_filter_change_update_delay(self, v, load=False): """ Setter method for filter_change_update_delay, mapped from YANG variable /rbridge_id/filter_change_update_delay (list) If this variable is read-only (config: false) in the source YANG file, then _set_filter_change_update_delay is considered as...
[ "def", "_set_filter_change_update_delay", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v...
Setter method for filter_change_update_delay, mapped from YANG variable /rbridge_id/filter_change_update_delay (list) If this variable is read-only (config: false) in the source YANG file, then _set_filter_change_update_delay is considered as a private method. Backends looking to populate this variable shou...
[ "Setter", "method", "for", "filter_change_update_delay", "mapped", "from", "YANG", "variable", "/", "rbridge_id", "/", "filter_change_update_delay", "(", "list", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in", ...
python
train
132.125
worldcompany/djangoembed
oembed/providers.py
https://github.com/worldcompany/djangoembed/blob/f3f2be283441d91d1f89db780444dc75f7b51902/oembed/providers.py#L342-L376
def get_params(self, url): """ Extract the named parameters from a url regex. If the url regex does not contain named parameters, they will be keyed _0, _1, ... * Named parameters Regex: /photos/^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{1,2})/(?P<object_id>\d...
[ "def", "get_params", "(", "self", ",", "url", ")", ":", "match", "=", "re", ".", "match", "(", "self", ".", "regex", ",", "url", ")", "if", "match", "is", "not", "None", ":", "params", "=", "match", ".", "groupdict", "(", ")", "if", "not", "param...
Extract the named parameters from a url regex. If the url regex does not contain named parameters, they will be keyed _0, _1, ... * Named parameters Regex: /photos/^(?P<year>\d{4})/(?P<month>\w{3})/(?P<day>\d{1,2})/(?P<object_id>\d+)/ URL: http://www2.l...
[ "Extract", "the", "named", "parameters", "from", "a", "url", "regex", ".", "If", "the", "url", "regex", "does", "not", "contain", "named", "parameters", "they", "will", "be", "keyed", "_0", "_1", "...", "*", "Named", "parameters", "Regex", ":", "/", "pho...
python
valid
31.228571
SALib/SALib
src/SALib/sample/morris/__init__.py
https://github.com/SALib/SALib/blob/9744d73bb17cfcffc8282c7dc4a727efdc4bea3f/src/SALib/sample/morris/__init__.py#L53-L103
def sample(problem, N, num_levels=4, optimal_trajectories=None, local_optimization=True): """Generate model inputs using the Method of Morris Returns a NumPy matrix containing the model inputs required for Method of Morris. The resulting matrix has :math:`(G+1)*T` rows and :math:`D` columns...
[ "def", "sample", "(", "problem", ",", "N", ",", "num_levels", "=", "4", ",", "optimal_trajectories", "=", "None", ",", "local_optimization", "=", "True", ")", ":", "if", "problem", ".", "get", "(", "'groups'", ")", ":", "sample", "=", "_sample_groups", "...
Generate model inputs using the Method of Morris Returns a NumPy matrix containing the model inputs required for Method of Morris. The resulting matrix has :math:`(G+1)*T` rows and :math:`D` columns, where :math:`D` is the number of parameters, :math:`G` is the number of groups (if no groups are selec...
[ "Generate", "model", "inputs", "using", "the", "Method", "of", "Morris" ]
python
train
39.980392
phaethon/kamene
kamene/contrib/gsm_um.py
https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L750-L766
def immediateAssignmentExtended(StartingTime_presence=0): """IMMEDIATE ASSIGNMENT EXTENDED Section 9.1.19""" a = L2PseudoLength() b = TpPd(pd=0x6) c = MessageType(mesType=0x39) # 00111001 d = PageModeAndSpareHalfOctets() f = ChannelDescription() g = RequestReference() h = TimingAdvance(...
[ "def", "immediateAssignmentExtended", "(", "StartingTime_presence", "=", "0", ")", ":", "a", "=", "L2PseudoLength", "(", ")", "b", "=", "TpPd", "(", "pd", "=", "0x6", ")", "c", "=", "MessageType", "(", "mesType", "=", "0x39", ")", "# 00111001", "d", "=",...
IMMEDIATE ASSIGNMENT EXTENDED Section 9.1.19
[ "IMMEDIATE", "ASSIGNMENT", "EXTENDED", "Section", "9", ".", "1", ".", "19" ]
python
train
32.941176
nickfrostatx/flask-hookserver
flask_hookserver.py
https://github.com/nickfrostatx/flask-hookserver/blob/fb5c226473f54e3469234403ec56a354374d2c41/flask_hookserver.py#L132-L156
def _load_github_hooks(github_url='https://api.github.com'): """Request GitHub's IP block from their API. Return the IP network. If we detect a rate-limit error, raise an error message stating when the rate limit will reset. If something else goes wrong, raise a generic 503. """ try: ...
[ "def", "_load_github_hooks", "(", "github_url", "=", "'https://api.github.com'", ")", ":", "try", ":", "resp", "=", "requests", ".", "get", "(", "github_url", "+", "'/meta'", ")", "if", "resp", ".", "status_code", "==", "200", ":", "return", "resp", ".", "...
Request GitHub's IP block from their API. Return the IP network. If we detect a rate-limit error, raise an error message stating when the rate limit will reset. If something else goes wrong, raise a generic 503.
[ "Request", "GitHub", "s", "IP", "block", "from", "their", "API", "." ]
python
train
42
ael-code/pyFsdb
fsdb/hashtools.py
https://github.com/ael-code/pyFsdb/blob/de33a0d41373307cb32cdd7ba1991b85ff495ee3/fsdb/hashtools.py#L17-L35
def calc_digest(origin, algorithm="sha1", block_size=None): """Calculate digest of a readable object Args: origin -- a readable object for which calculate digest algorithn -- the algorithm to use. See ``hashlib.algorithms_available`` for supported algorithms. block_size -- the size of ...
[ "def", "calc_digest", "(", "origin", ",", "algorithm", "=", "\"sha1\"", ",", "block_size", "=", "None", ")", ":", "try", ":", "hashM", "=", "hashlib", ".", "new", "(", "algorithm", ")", "except", "ValueError", ":", "raise", "ValueError", "(", "'hash algori...
Calculate digest of a readable object Args: origin -- a readable object for which calculate digest algorithn -- the algorithm to use. See ``hashlib.algorithms_available`` for supported algorithms. block_size -- the size of the block to read at each iteration
[ "Calculate", "digest", "of", "a", "readable", "object" ]
python
train
37.473684
chrisjsewell/jsonextended
jsonextended/edict.py
https://github.com/chrisjsewell/jsonextended/blob/c3a7a880cc09789b3c61204265dcbb127be76c8a/jsonextended/edict.py#L1452-L1508
def apply(d, leaf_key, func, new_name=None, remove_lkey=True, list_of_dicts=False, unflatten_level=0, deepcopy=True, **kwargs): """ apply a function to all values with a certain leaf (terminal) key Parameters ---------- d : dict leaf_key : str name of leaf key func : callable ...
[ "def", "apply", "(", "d", ",", "leaf_key", ",", "func", ",", "new_name", "=", "None", ",", "remove_lkey", "=", "True", ",", "list_of_dicts", "=", "False", ",", "unflatten_level", "=", "0", ",", "deepcopy", "=", "True", ",", "*", "*", "kwargs", ")", "...
apply a function to all values with a certain leaf (terminal) key Parameters ---------- d : dict leaf_key : str name of leaf key func : callable function to apply new_name : str if not None, rename leaf_key remove_lkey: bool whether to remove original leaf_ke...
[ "apply", "a", "function", "to", "all", "values", "with", "a", "certain", "leaf", "(", "terminal", ")", "key" ]
python
train
35.403509
peerplays-network/python-peerplays
peerplays/peerplays.py
https://github.com/peerplays-network/python-peerplays/blob/188f04238e7e21d5f73e9b01099eea44289ef6b7/peerplays/peerplays.py#L439-L520
def disallow( self, foreign, permission="active", account=None, threshold=None, **kwargs ): """ Remove additional access to an account by some other public key or account. :param str foreign: The foreign account that will obtain access :param str permission: (opt...
[ "def", "disallow", "(", "self", ",", "foreign", ",", "permission", "=", "\"active\"", ",", "account", "=", "None", ",", "threshold", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "account", ":", "if", "\"default_account\"", "in", "self", ...
Remove additional access to an account by some other public key or account. :param str foreign: The foreign account that will obtain access :param str permission: (optional) The actual permission to modify (defaults to ``active``) :param str account: (opt...
[ "Remove", "additional", "access", "to", "an", "account", "by", "some", "other", "public", "key", "or", "account", "." ]
python
train
38.146341
koalalorenzo/python-digitalocean
digitalocean/Droplet.py
https://github.com/koalalorenzo/python-digitalocean/blob/d0221b57856fb1e131cafecf99d826f7b07a947c/digitalocean/Droplet.py#L204-L230
def _perform_action(self, params, return_dict=True): """ Perform a droplet action. Args: params (dict): parameters of the action Optional Args: return_dict (bool): Return a dict when True (default), otherwise return an Act...
[ "def", "_perform_action", "(", "self", ",", "params", ",", "return_dict", "=", "True", ")", ":", "action", "=", "self", ".", "get_data", "(", "\"droplets/%s/actions/\"", "%", "self", ".", "id", ",", "type", "=", "POST", ",", "params", "=", "params", ")",...
Perform a droplet action. Args: params (dict): parameters of the action Optional Args: return_dict (bool): Return a dict when True (default), otherwise return an Action. Returns dict or Action
[ "Perform", "a", "droplet", "action", "." ]
python
valid
29.740741
pyviz/holoviews
holoviews/plotting/util.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/plotting/util.py#L909-L955
def color_intervals(colors, levels, clip=None, N=255): """ Maps the supplied colors into bins defined by the supplied levels. If a clip tuple is defined the bins are clipped to the defined range otherwise the range is computed from the levels and returned. Arguments --------- colors: list ...
[ "def", "color_intervals", "(", "colors", ",", "levels", ",", "clip", "=", "None", ",", "N", "=", "255", ")", ":", "if", "len", "(", "colors", ")", "!=", "len", "(", "levels", ")", "-", "1", ":", "raise", "ValueError", "(", "'The number of colors in the...
Maps the supplied colors into bins defined by the supplied levels. If a clip tuple is defined the bins are clipped to the defined range otherwise the range is computed from the levels and returned. Arguments --------- colors: list List of colors (usually hex string or named colors) levels...
[ "Maps", "the", "supplied", "colors", "into", "bins", "defined", "by", "the", "supplied", "levels", ".", "If", "a", "clip", "tuple", "is", "defined", "the", "bins", "are", "clipped", "to", "the", "defined", "range", "otherwise", "the", "range", "is", "compu...
python
train
34.851064
readbeyond/aeneas
aeneas/audiofilemfcc.py
https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofilemfcc.py#L452-L460
def middle_begin(self, index): """ Set the index where MIDDLE starts. :param int index: the new index for MIDDLE begin """ if (index < 0) or (index > self.all_length): raise ValueError(u"The given index is not valid") self.__middle_begin = index
[ "def", "middle_begin", "(", "self", ",", "index", ")", ":", "if", "(", "index", "<", "0", ")", "or", "(", "index", ">", "self", ".", "all_length", ")", ":", "raise", "ValueError", "(", "u\"The given index is not valid\"", ")", "self", ".", "__middle_begin"...
Set the index where MIDDLE starts. :param int index: the new index for MIDDLE begin
[ "Set", "the", "index", "where", "MIDDLE", "starts", "." ]
python
train
33.111111
usc-isi-i2/etk
etk/data_extractors/htiExtractors/misc.py
https://github.com/usc-isi-i2/etk/blob/aab077c984ea20f5e8ae33af622fe11d3c4df866/etk/data_extractors/htiExtractors/misc.py#L26-L89
def phone_text_subs(): """ Gets a dictionary of dictionaries that each contain alphabetic number manifestations mapped to their actual Number value. Returns: dictionary of dictionaries containing Strings mapped to Numbers """ Small = { 'zero': 0, 'zer0': 0, 'one': 1, 'two': 2, 'th...
[ "def", "phone_text_subs", "(", ")", ":", "Small", "=", "{", "'zero'", ":", "0", ",", "'zer0'", ":", "0", ",", "'one'", ":", "1", ",", "'two'", ":", "2", ",", "'three'", ":", "3", ",", "'four'", ":", "4", ",", "'fuor'", ":", "4", ",", "'five'", ...
Gets a dictionary of dictionaries that each contain alphabetic number manifestations mapped to their actual Number value. Returns: dictionary of dictionaries containing Strings mapped to Numbers
[ "Gets", "a", "dictionary", "of", "dictionaries", "that", "each", "contain", "alphabetic", "number", "manifestations", "mapped", "to", "their", "actual", "Number", "value", "." ]
python
train
15.609375
googleapis/google-cloud-python
core/google/cloud/operation.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/core/google/cloud/operation.py#L169-L188
def from_dict(cls, operation, client, **caller_metadata): """Factory: construct an instance from a dictionary. :type operation: dict :param operation: Operation as a JSON object. :type client: :class:`~google.cloud.client.Client` :param client: The client used to poll for the s...
[ "def", "from_dict", "(", "cls", ",", "operation", ",", "client", ",", "*", "*", "caller_metadata", ")", ":", "operation_pb", "=", "json_format", ".", "ParseDict", "(", "operation", ",", "operations_pb2", ".", "Operation", "(", ")", ")", "result", "=", "cls...
Factory: construct an instance from a dictionary. :type operation: dict :param operation: Operation as a JSON object. :type client: :class:`~google.cloud.client.Client` :param client: The client used to poll for the status of the operation. :type caller_metadata: dict ...
[ "Factory", ":", "construct", "an", "instance", "from", "a", "dictionary", "." ]
python
train
40.35
sternoru/goscalecms
goscale/models.py
https://github.com/sternoru/goscalecms/blob/7eee50357c47ebdfe3e573a8b4be3b67892d229e/goscale/models.py#L211-L235
def update(self): """This method should be called to update associated Posts It will call content-specific methods: _get_data() to obtain list of entries _store_post() to store obtained entry object _get_data_source_url() to get an URL to identify Posts from this D...
[ "def", "update", "(", "self", ")", ":", "#get the raw data", "# self.posts.all().delete() # TODO: handle in update_posts if source changes without deleting every time", "data", "=", "self", ".", "_get_data", "(", ")", "#iterate through them and for each item", "msg", "=", ...
This method should be called to update associated Posts It will call content-specific methods: _get_data() to obtain list of entries _store_post() to store obtained entry object _get_data_source_url() to get an URL to identify Posts from this Data Source
[ "This", "method", "should", "be", "called", "to", "update", "associated", "Posts", "It", "will", "call", "content", "-", "specific", "methods", ":", "_get_data", "()", "to", "obtain", "list", "of", "entries", "_store_post", "()", "to", "store", "obtained", "...
python
train
46.72
mozillazg/baidu-pcs-python-sdk
baidupcs/api.py
https://github.com/mozillazg/baidu-pcs-python-sdk/blob/12fe3f13b2ecda8f8bdcc5334c876e934776a5cc/baidupcs/api.py#L769-L789
def query_download_tasks(self, task_ids, operate_type=1, expires=None, **kwargs): """根据任务ID号,查询离线下载任务信息及进度信息。 :param task_ids: 要查询的任务ID列表 :type task_ids: list or tuple :param operate_type: * 0:查任务信息 * 1...
[ "def", "query_download_tasks", "(", "self", ",", "task_ids", ",", "operate_type", "=", "1", ",", "expires", "=", "None", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "'task_ids'", ":", "','", ".", "join", "(", "map", "(", "str", ",", "task_...
根据任务ID号,查询离线下载任务信息及进度信息。 :param task_ids: 要查询的任务ID列表 :type task_ids: list or tuple :param operate_type: * 0:查任务信息 * 1:查进度信息,默认为1 :param expires: 请求失效时间,如果有,则会校验。 :type expires: int :return: Response 对象
[ "根据任务ID号,查询离线下载任务信息及进度信息。" ]
python
train
33.190476
openeemeter/eemeter
eemeter/caltrack/usage_per_day.py
https://github.com/openeemeter/eemeter/blob/e03b1cc5f4906e8f4f7fd16183bc037107d1dfa0/eemeter/caltrack/usage_per_day.py#L718-L771
def get_too_few_non_zero_degree_day_warning( model_type, balance_point, degree_day_type, degree_days, minimum_non_zero ): """ Return an empty list or a single warning wrapped in a list regarding non-zero degree days for a set of degree days. Parameters ---------- model_type : :any:`str` ...
[ "def", "get_too_few_non_zero_degree_day_warning", "(", "model_type", ",", "balance_point", ",", "degree_day_type", ",", "degree_days", ",", "minimum_non_zero", ")", ":", "warnings", "=", "[", "]", "n_non_zero", "=", "int", "(", "(", "degree_days", ">", "0", ")", ...
Return an empty list or a single warning wrapped in a list regarding non-zero degree days for a set of degree days. Parameters ---------- model_type : :any:`str` Model type (e.g., ``'cdd_hdd'``). balance_point : :any:`float` The balance point in question. degree_day_type : :any:...
[ "Return", "an", "empty", "list", "or", "a", "single", "warning", "wrapped", "in", "a", "list", "regarding", "non", "-", "zero", "degree", "days", "for", "a", "set", "of", "degree", "days", "." ]
python
train
37.648148
HonzaKral/django-threadedcomments
threadedcomments/util.py
https://github.com/HonzaKral/django-threadedcomments/blob/7b36d9e0813fcbb634052990d1cf01bba8ef220f/threadedcomments/util.py#L37-L83
def annotate_tree_properties(comments): """ iterate through nodes and adds some magic properties to each of them representing opening list of children and closing it """ if not comments: return it = iter(comments) # get the first item, this will fail if no items ! old = next(it...
[ "def", "annotate_tree_properties", "(", "comments", ")", ":", "if", "not", "comments", ":", "return", "it", "=", "iter", "(", "comments", ")", "# get the first item, this will fail if no items !", "old", "=", "next", "(", "it", ")", "# first item starts a new thread",...
iterate through nodes and adds some magic properties to each of them representing opening list of children and closing it
[ "iterate", "through", "nodes", "and", "adds", "some", "magic", "properties", "to", "each", "of", "them", "representing", "opening", "list", "of", "children", "and", "closing", "it" ]
python
train
26.06383
google/grumpy
compiler/stmt.py
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/compiler/stmt.py#L496-L566
def visit_function_inline(self, node): """Returns an GeneratedExpr for a function with the given body.""" # First pass collects the names of locals used in this function. Do this in # a separate pass so that we know whether to resolve a name as a local or a # global during the second pass. func_visi...
[ "def", "visit_function_inline", "(", "self", ",", "node", ")", ":", "# First pass collects the names of locals used in this function. Do this in", "# a separate pass so that we know whether to resolve a name as a local or a", "# global during the second pass.", "func_visitor", "=", "block"...
Returns an GeneratedExpr for a function with the given body.
[ "Returns", "an", "GeneratedExpr", "for", "a", "function", "with", "the", "given", "body", "." ]
python
valid
48.887324
pandas-dev/pandas
pandas/core/dtypes/common.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/dtypes/common.py#L1600-L1663
def is_bool_dtype(arr_or_dtype): """ Check whether the provided array or dtype is of a boolean dtype. Parameters ---------- arr_or_dtype : array-like The array or dtype to check. Returns ------- boolean Whether or not the array or dtype is of a boolean dtype. Notes...
[ "def", "is_bool_dtype", "(", "arr_or_dtype", ")", ":", "if", "arr_or_dtype", "is", "None", ":", "return", "False", "try", ":", "dtype", "=", "_get_dtype", "(", "arr_or_dtype", ")", "except", "TypeError", ":", "return", "False", "if", "isinstance", "(", "arr_...
Check whether the provided array or dtype is of a boolean dtype. Parameters ---------- arr_or_dtype : array-like The array or dtype to check. Returns ------- boolean Whether or not the array or dtype is of a boolean dtype. Notes ----- An ExtensionArray is considere...
[ "Check", "whether", "the", "provided", "array", "or", "dtype", "is", "of", "a", "boolean", "dtype", "." ]
python
train
25.109375
zhmcclient/python-zhmcclient
zhmcclient/_partition.py
https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient/_partition.py#L254-L270
def hbas(self): """ :class:`~zhmcclient.HbaManager`: Access to the :term:`HBAs <HBA>` in this Partition. If the "dpm-storage-management" feature is enabled, this property is `None`. """ # We do here some lazy loading. if not self._hbas: try: ...
[ "def", "hbas", "(", "self", ")", ":", "# We do here some lazy loading.", "if", "not", "self", ".", "_hbas", ":", "try", ":", "dpm_sm", "=", "self", ".", "feature_enabled", "(", "'dpm-storage-management'", ")", "except", "ValueError", ":", "dpm_sm", "=", "False...
:class:`~zhmcclient.HbaManager`: Access to the :term:`HBAs <HBA>` in this Partition. If the "dpm-storage-management" feature is enabled, this property is `None`.
[ ":", "class", ":", "~zhmcclient", ".", "HbaManager", ":", "Access", "to", "the", ":", "term", ":", "HBAs", "<HBA", ">", "in", "this", "Partition", "." ]
python
train
31.470588
proycon/pynlpl
pynlpl/formats/folia.py
https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3052-L3078
def annotation(self, type, set=None): """Obtain a single annotation element. A further restriction can be made based on set. Arguments: Class (class): The class to select; any python class (not instance) subclassed off :class:`AbstractElement` Set (str): The set to matc...
[ "def", "annotation", "(", "self", ",", "type", ",", "set", "=", "None", ")", ":", "\"\"\"Will return a **single** annotation (even if there are multiple). Raises a ``NoSuchAnnotation`` exception if none was found\"\"\"", "for", "e", "in", "self", ".", "select", "(", "type", ...
Obtain a single annotation element. A further restriction can be made based on set. Arguments: Class (class): The class to select; any python class (not instance) subclassed off :class:`AbstractElement` Set (str): The set to match against, only elements pertaining to this set w...
[ "Obtain", "a", "single", "annotation", "element", "." ]
python
train
40.777778
happyleavesaoc/python-limitlessled
limitlessled/group/commands/legacy.py
https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/group/commands/legacy.py#L210-L217
def brightness(self, brightness): """ Build command for setting the brightness of the led. :param brightness: Value to set (0.0-1.0). :return: The command. """ return self._build_command(0x4E, self.convert_brightness(brightness), select=...
[ "def", "brightness", "(", "self", ",", "brightness", ")", ":", "return", "self", ".", "_build_command", "(", "0x4E", ",", "self", ".", "convert_brightness", "(", "brightness", ")", ",", "select", "=", "True", ",", "select_command", "=", "self", ".", "on", ...
Build command for setting the brightness of the led. :param brightness: Value to set (0.0-1.0). :return: The command.
[ "Build", "command", "for", "setting", "the", "brightness", "of", "the", "led", ".", ":", "param", "brightness", ":", "Value", "to", "set", "(", "0", ".", "0", "-", "1", ".", "0", ")", ".", ":", "return", ":", "The", "command", "." ]
python
train
43
IdentityPython/SATOSA
src/satosa/plugin_loader.py
https://github.com/IdentityPython/SATOSA/blob/49da5d4c0ac1a5ebf1a71b4f7aaf04f0e52d8fdb/src/satosa/plugin_loader.py#L30-L47
def load_backends(config, callback, internal_attributes): """ Load all backend modules specified in the config :type config: satosa.satosa_config.SATOSAConfig :type callback: (satosa.context.Context, satosa.internal.InternalData) -> satosa.response.Response :type internal_attributes: dict[strin...
[ "def", "load_backends", "(", "config", ",", "callback", ",", "internal_attributes", ")", ":", "backend_modules", "=", "_load_plugins", "(", "config", ".", "get", "(", "\"CUSTOM_PLUGIN_MODULE_PATHS\"", ")", ",", "config", "[", "\"BACKEND_MODULES\"", "]", ",", "back...
Load all backend modules specified in the config :type config: satosa.satosa_config.SATOSAConfig :type callback: (satosa.context.Context, satosa.internal.InternalData) -> satosa.response.Response :type internal_attributes: dict[string, dict[str, str | list[str]]] :rtype: Sequence[satosa.backends.ba...
[ "Load", "all", "backend", "modules", "specified", "in", "the", "config" ]
python
train
50.611111
aio-libs/aioredis
aioredis/commands/hash.py
https://github.com/aio-libs/aioredis/blob/e8c33e39558d4cc91cf70dde490d8b330c97dc2e/aioredis/commands/hash.py#L40-L43
def hincrbyfloat(self, key, field, increment=1.0): """Increment the float value of a hash field by the given number.""" fut = self.execute(b'HINCRBYFLOAT', key, field, increment) return wait_convert(fut, float)
[ "def", "hincrbyfloat", "(", "self", ",", "key", ",", "field", ",", "increment", "=", "1.0", ")", ":", "fut", "=", "self", ".", "execute", "(", "b'HINCRBYFLOAT'", ",", "key", ",", "field", ",", "increment", ")", "return", "wait_convert", "(", "fut", ","...
Increment the float value of a hash field by the given number.
[ "Increment", "the", "float", "value", "of", "a", "hash", "field", "by", "the", "given", "number", "." ]
python
train
57.75
florianpaquet/mease
mease/server.py
https://github.com/florianpaquet/mease/blob/b9fbd08bbe162c8890c2a2124674371170c319ef/mease/server.py#L129-L140
def run_server(self): """ Runs the WebSocket server """ self.protocol = MeaseWebSocketServerProtocol reactor.listenTCP(port=self.port, factory=self, interface=self.host) logger.info("Websocket server listening on {address}".format( address=self.address)) ...
[ "def", "run_server", "(", "self", ")", ":", "self", ".", "protocol", "=", "MeaseWebSocketServerProtocol", "reactor", ".", "listenTCP", "(", "port", "=", "self", ".", "port", ",", "factory", "=", "self", ",", "interface", "=", "self", ".", "host", ")", "l...
Runs the WebSocket server
[ "Runs", "the", "WebSocket", "server" ]
python
train
27.333333
avihad/twistes
twistes/parser.py
https://github.com/avihad/twistes/blob/9ab8f5aa088b8886aefe3dec85a400e5035e034a/twistes/parser.py#L70-L91
def _parse_string_host(host_str): """ Parse host string into a dictionary host :param host_str: :return: """ host_str = EsParser._fix_host_prefix(host_str) parsed_url = urlparse(host_str) host = {HostParsing.HOST: parsed_url.hostname} if parsed_url...
[ "def", "_parse_string_host", "(", "host_str", ")", ":", "host_str", "=", "EsParser", ".", "_fix_host_prefix", "(", "host_str", ")", "parsed_url", "=", "urlparse", "(", "host_str", ")", "host", "=", "{", "HostParsing", ".", "HOST", ":", "parsed_url", ".", "ho...
Parse host string into a dictionary host :param host_str: :return:
[ "Parse", "host", "string", "into", "a", "dictionary", "host", ":", "param", "host_str", ":", ":", "return", ":" ]
python
train
43.909091
tensorflow/datasets
tensorflow_datasets/core/features/text/text_encoder.py
https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/features/text/text_encoder.py#L463-L470
def _make_reserved_tokens_re(reserved_tokens): """Constructs compiled regex to parse out reserved tokens.""" if not reserved_tokens: return None escaped_tokens = [_re_escape(rt) for rt in reserved_tokens] pattern = "(%s)" % "|".join(escaped_tokens) reserved_tokens_re = _re_compile(pattern) return reserv...
[ "def", "_make_reserved_tokens_re", "(", "reserved_tokens", ")", ":", "if", "not", "reserved_tokens", ":", "return", "None", "escaped_tokens", "=", "[", "_re_escape", "(", "rt", ")", "for", "rt", "in", "reserved_tokens", "]", "pattern", "=", "\"(%s)\"", "%", "\...
Constructs compiled regex to parse out reserved tokens.
[ "Constructs", "compiled", "regex", "to", "parse", "out", "reserved", "tokens", "." ]
python
train
40.625
sibirrer/lenstronomy
lenstronomy/ImSim/image_model.py
https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/ImSim/image_model.py#L296-L304
def reduced_chi2(self, model, error_map=0): """ returns reduced chi2 :param model: :param error_map: :return: """ chi2 = self.reduced_residuals(model, error_map) return np.sum(chi2**2) / self.num_data_evaluate()
[ "def", "reduced_chi2", "(", "self", ",", "model", ",", "error_map", "=", "0", ")", ":", "chi2", "=", "self", ".", "reduced_residuals", "(", "model", ",", "error_map", ")", "return", "np", ".", "sum", "(", "chi2", "**", "2", ")", "/", "self", ".", "...
returns reduced chi2 :param model: :param error_map: :return:
[ "returns", "reduced", "chi2", ":", "param", "model", ":", ":", "param", "error_map", ":", ":", "return", ":" ]
python
train
29.666667
Locu/chronology
kronos/kronos/core/validator.py
https://github.com/Locu/chronology/blob/0edf3ee3286c76e242cbf92436ffa9c836b428e2/kronos/kronos/core/validator.py#L18-L43
def _validate_and_get_value(options, options_name, key, _type): """ Check that `options` has a value for `key` with type `_type`. Return that value. `options_name` is a string representing a human-readable name for `options` to be used when printing errors. """ if isinstance(options, dict): has = lambda...
[ "def", "_validate_and_get_value", "(", "options", ",", "options_name", ",", "key", ",", "_type", ")", ":", "if", "isinstance", "(", "options", ",", "dict", ")", ":", "has", "=", "lambda", "k", ":", "k", "in", "options", "get", "=", "lambda", "k", ":", ...
Check that `options` has a value for `key` with type `_type`. Return that value. `options_name` is a string representing a human-readable name for `options` to be used when printing errors.
[ "Check", "that", "options", "has", "a", "value", "for", "key", "with", "type", "_type", ".", "Return", "that", "value", ".", "options_name", "is", "a", "string", "representing", "a", "human", "-", "readable", "name", "for", "options", "to", "be", "used", ...
python
train
33.384615
tzutalin/labelImg
libs/canvas.py
https://github.com/tzutalin/labelImg/blob/6afd15aa88f89f41254e0004ed219b3965eb2c0d/libs/canvas.py#L104-L208
def mouseMoveEvent(self, ev): """Update line with last point and current coordinates.""" pos = self.transformPos(ev.pos()) # Update coordinates in status bar if image is opened window = self.parent().window() if window.filePath is not None: self.parent().window().lab...
[ "def", "mouseMoveEvent", "(", "self", ",", "ev", ")", ":", "pos", "=", "self", ".", "transformPos", "(", "ev", ".", "pos", "(", ")", ")", "# Update coordinates in status bar if image is opened", "window", "=", "self", ".", "parent", "(", ")", ".", "window", ...
Update line with last point and current coordinates.
[ "Update", "line", "with", "last", "point", "and", "current", "coordinates", "." ]
python
train
42.428571
jtambasco/modesolverpy
modesolverpy/design.py
https://github.com/jtambasco/modesolverpy/blob/85254a13b5aed2404187c52ac93b9b3ce99ee3a3/modesolverpy/design.py#L29-L60
def grating_coupler_period(wavelength, n_eff, n_clad, incidence_angle_deg, diffration_order=1): ''' Calculate the period needed for a grating coupler. Args: wavelength (float): The target wav...
[ "def", "grating_coupler_period", "(", "wavelength", ",", "n_eff", ",", "n_clad", ",", "incidence_angle_deg", ",", "diffration_order", "=", "1", ")", ":", "k0", "=", "2.", "*", "np", ".", "pi", "/", "wavelength", "beta", "=", "n_eff", ".", "real", "*", "k...
Calculate the period needed for a grating coupler. Args: wavelength (float): The target wavelength for the grating coupler. n_eff (float): The effective index of the mode of a waveguide with the width of the grating coupler. n_clad (float): The refractive...
[ "Calculate", "the", "period", "needed", "for", "a", "grating", "coupler", "." ]
python
train
35.1875
semente/django-smuggler
smuggler/views.py
https://github.com/semente/django-smuggler/blob/3be76f4e94e50e927a55a60741fac1a793df83de/smuggler/views.py#L63-L71
def dump_data(request): """Exports data from whole project. """ # Try to grab app_label data app_label = request.GET.get('app_label', []) if app_label: app_label = app_label.split(',') return dump_to_response(request, app_label=app_label, exclude=settings.SMUG...
[ "def", "dump_data", "(", "request", ")", ":", "# Try to grab app_label data", "app_label", "=", "request", ".", "GET", ".", "get", "(", "'app_label'", ",", "[", "]", ")", "if", "app_label", ":", "app_label", "=", "app_label", ".", "split", "(", "','", ")",...
Exports data from whole project.
[ "Exports", "data", "from", "whole", "project", "." ]
python
train
36.666667
python-hyper/h11
h11/_connection.py
https://github.com/python-hyper/h11/blob/836d95d1c2af2f9153c86dbc8d9784341d73c6a6/h11/_connection.py#L443-L468
def send(self, event): """Convert a high-level event into bytes that can be sent to the peer, while updating our internal state machine. Args: event: The :ref:`event <events>` to send. Returns: If ``type(event) is ConnectionClosed``, then returns ``N...
[ "def", "send", "(", "self", ",", "event", ")", ":", "data_list", "=", "self", ".", "send_with_data_passthrough", "(", "event", ")", "if", "data_list", "is", "None", ":", "return", "None", "else", ":", "return", "b\"\"", ".", "join", "(", "data_list", ")"...
Convert a high-level event into bytes that can be sent to the peer, while updating our internal state machine. Args: event: The :ref:`event <events>` to send. Returns: If ``type(event) is ConnectionClosed``, then returns ``None``. Otherwise, returns a :term:...
[ "Convert", "a", "high", "-", "level", "event", "into", "bytes", "that", "can", "be", "sent", "to", "the", "peer", "while", "updating", "our", "internal", "state", "machine", "." ]
python
train
33.423077
hyperledger/indy-plenum
plenum/server/node.py
https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L1455-L1510
def onConnsChanged(self, joined: Set[str], left: Set[str]): """ A series of operations to perform once a connection count has changed. - Set f to max number of failures this system can handle. - Set status to one of started, started_hungry or starting depending on the number...
[ "def", "onConnsChanged", "(", "self", ",", "joined", ":", "Set", "[", "str", "]", ",", "left", ":", "Set", "[", "str", "]", ")", ":", "_prev_status", "=", "self", ".", "status", "if", "self", ".", "isGoing", "(", ")", ":", "if", "self", ".", "con...
A series of operations to perform once a connection count has changed. - Set f to max number of failures this system can handle. - Set status to one of started, started_hungry or starting depending on the number of protocol instances. - Check protocol instances. See `checkInstances(...
[ "A", "series", "of", "operations", "to", "perform", "once", "a", "connection", "count", "has", "changed", "." ]
python
train
45.875
CodyKochmann/generators
generators/Generator.py
https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/Generator.py#L145-L151
def add_methods(methods_to_add): ''' use this to bulk add new methods to Generator ''' for i in methods_to_add: try: Generator.add_method(*i) except Exception as ex: raise Exception('issue adding {} - {}'.format(repr(i), ex))
[ "def", "add_methods", "(", "methods_to_add", ")", ":", "for", "i", "in", "methods_to_add", ":", "try", ":", "Generator", ".", "add_method", "(", "*", "i", ")", "except", "Exception", "as", "ex", ":", "raise", "Exception", "(", "'issue adding {} - {}'", ".", ...
use this to bulk add new methods to Generator
[ "use", "this", "to", "bulk", "add", "new", "methods", "to", "Generator" ]
python
train
41.571429
ff0000/scarlet
scarlet/cms/actions.py
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/actions.py#L315-L348
def process_action(self, request, queryset): """ Publishes the selected objects by passing the value of \ 'when' to the object's publish method. The object's \ `purge_archives` method is also called to limit the number \ of old items that we keep around. The action is logged as \...
[ "def", "process_action", "(", "self", ",", "request", ",", "queryset", ")", ":", "form", "=", "self", ".", "form", "(", "request", ".", "POST", ")", "if", "form", ".", "is_valid", "(", ")", ":", "when", "=", "form", ".", "cleaned_data", ".", "get", ...
Publishes the selected objects by passing the value of \ 'when' to the object's publish method. The object's \ `purge_archives` method is also called to limit the number \ of old items that we keep around. The action is logged as \ either 'published' or 'scheduled' depending on the value...
[ "Publishes", "the", "selected", "objects", "by", "passing", "the", "value", "of", "\\", "when", "to", "the", "object", "s", "publish", "method", ".", "The", "object", "s", "\\", "purge_archives", "method", "is", "also", "called", "to", "limit", "the", "num...
python
train
44.323529
aliyun/aliyun-odps-python-sdk
odps/ml/expr/mixin.py
https://github.com/aliyun/aliyun-odps-python-sdk/blob/4b0de18f5864386df6068f26f026e62f932c41e4/odps/ml/expr/mixin.py#L389-L405
def discrete(self): """ Set sequence to be discrete. :rtype: Column :Example: >>> # Table schema is create table test(f1 double, f2 string) >>> # Original continuity: f1=CONTINUOUS, f2=CONTINUOUS >>> # Now we want to set ``f1`` and ``f2`` into continuous ...
[ "def", "discrete", "(", "self", ")", ":", "field_name", "=", "self", ".", "name", "new_df", "=", "copy_df", "(", "self", ")", "new_df", ".", "_perform_operation", "(", "op", ".", "FieldContinuityOperation", "(", "{", "field_name", ":", "False", "}", ")", ...
Set sequence to be discrete. :rtype: Column :Example: >>> # Table schema is create table test(f1 double, f2 string) >>> # Original continuity: f1=CONTINUOUS, f2=CONTINUOUS >>> # Now we want to set ``f1`` and ``f2`` into continuous >>> new_ds = df.discrete('f1 f2')
[ "Set", "sequence", "to", "be", "discrete", "." ]
python
train
30.529412
twilio/twilio-python
twilio/rest/preview/bulk_exports/export_configuration.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/preview/bulk_exports/export_configuration.py#L215-L228
def _proxy(self): """ Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: ExportConfigurationContext for this ExportConfigurationInstance :rtype: twilio.rest.preview.bulk_...
[ "def", "_proxy", "(", "self", ")", ":", "if", "self", ".", "_context", "is", "None", ":", "self", ".", "_context", "=", "ExportConfigurationContext", "(", "self", ".", "_version", ",", "resource_type", "=", "self", ".", "_solution", "[", "'resource_type'", ...
Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context :returns: ExportConfigurationContext for this ExportConfigurationInstance :rtype: twilio.rest.preview.bulk_exports.export_configuration.ExportCon...
[ "Generate", "an", "instance", "context", "for", "the", "instance", "the", "context", "is", "capable", "of", "performing", "various", "actions", ".", "All", "instance", "actions", "are", "proxied", "to", "the", "context" ]
python
train
42.928571
kata198/AdvancedHTMLParser
AdvancedHTMLParser/Tags.py
https://github.com/kata198/AdvancedHTMLParser/blob/06aeea5d8e2ea86e155aae0fc237623d3e9b7f9d/AdvancedHTMLParser/Tags.py#L1951-L1964
def getPeersWithAttrValues(self, attrName, attrValues): ''' getPeersWithAttrValues - Gets peers (elements on same level) whose attribute given by #attrName are in the list of possible vaues #attrValues @param attrName - Name of attribute @param attrValues - ...
[ "def", "getPeersWithAttrValues", "(", "self", ",", "attrName", ",", "attrValues", ")", ":", "peers", "=", "self", ".", "peers", "if", "peers", "is", "None", ":", "return", "None", "return", "TagCollection", "(", "[", "peer", "for", "peer", "in", "peers", ...
getPeersWithAttrValues - Gets peers (elements on same level) whose attribute given by #attrName are in the list of possible vaues #attrValues @param attrName - Name of attribute @param attrValues - List of possible values which will match @return - None if no paren...
[ "getPeersWithAttrValues", "-", "Gets", "peers", "(", "elements", "on", "same", "level", ")", "whose", "attribute", "given", "by", "#attrName", "are", "in", "the", "list", "of", "possible", "vaues", "#attrValues" ]
python
train
46.642857
tonybaloney/wily
wily/archivers/git.py
https://github.com/tonybaloney/wily/blob/bae259354a91b57d56603f0ca7403186f086a84c/wily/archivers/git.py#L87-L98
def checkout(self, revision, options): """ Checkout a specific revision. :param revision: The revision identifier. :type revision: :class:`Revision` :param options: Any additional options. :type options: ``dict`` """ rev = revision.key self.rep...
[ "def", "checkout", "(", "self", ",", "revision", ",", "options", ")", ":", "rev", "=", "revision", ".", "key", "self", ".", "repo", ".", "git", ".", "checkout", "(", "rev", ")" ]
Checkout a specific revision. :param revision: The revision identifier. :type revision: :class:`Revision` :param options: Any additional options. :type options: ``dict``
[ "Checkout", "a", "specific", "revision", "." ]
python
train
27.333333
jkawamoto/dsargparse
dsargparse.py
https://github.com/jkawamoto/dsargparse/blob/dbbcea11ff1ae7b84bdfccb9f97d1947574e4126/dsargparse.py#L183-L208
def add_argument(self, *args, **kwargs): """Add an argument. This method adds a new argument to the current parser. The function is same as ``argparse.ArgumentParser.add_argument``. However, this method tries to determine help messages for the adding argument from some docstring...
[ "def", "add_argument", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "_HELP", "not", "in", "kwargs", ":", "for", "name", "in", "args", ":", "name", "=", "name", ".", "replace", "(", "\"-\"", ",", "\"\"", ")", "if", "name...
Add an argument. This method adds a new argument to the current parser. The function is same as ``argparse.ArgumentParser.add_argument``. However, this method tries to determine help messages for the adding argument from some docstrings. If the new arguments belong to some sub ...
[ "Add", "an", "argument", "." ]
python
train
41.346154
eqcorrscan/EQcorrscan
eqcorrscan/utils/mag_calc.py
https://github.com/eqcorrscan/EQcorrscan/blob/3121b4aca801ee5d38f56ca297ce1c0f9515d9ff/eqcorrscan/utils/mag_calc.py#L825-L1027
def svd_moments(u, s, v, stachans, event_list, n_svs=2): """ Calculate relative moments/amplitudes using singular-value decomposition. Convert basis vectors calculated by singular value \ decomposition (see the SVD functions in clustering) into relative \ moments. For more information see the ...
[ "def", "svd_moments", "(", "u", ",", "s", ",", "v", ",", "stachans", ",", "event_list", ",", "n_svs", "=", "2", ")", ":", "# Define maximum number of events, will be the width of K", "K_width", "=", "max", "(", "[", "max", "(", "ev_list", ")", "for", "ev_lis...
Calculate relative moments/amplitudes using singular-value decomposition. Convert basis vectors calculated by singular value \ decomposition (see the SVD functions in clustering) into relative \ moments. For more information see the paper by \ `Rubinstein & Ellsworth (2010). <http://www.bssaon...
[ "Calculate", "relative", "moments", "/", "amplitudes", "using", "singular", "-", "value", "decomposition", "." ]
python
train
43.91133
xtream1101/web-wrapper
web_wrapper/selenium_utils.py
https://github.com/xtream1101/web-wrapper/blob/2bfc63caa7d316564088951f01a490db493ea240/web_wrapper/selenium_utils.py#L63-L101
def _get_site(self, url, headers, cookies, timeout, driver_args, driver_kwargs): """ Try and return page content in the requested format using selenium """ try: # **TODO**: Find what exception this will throw and catch it and call # self.driver.execute_script("w...
[ "def", "_get_site", "(", "self", ",", "url", ",", "headers", ",", "cookies", ",", "timeout", ",", "driver_args", ",", "driver_kwargs", ")", ":", "try", ":", "# **TODO**: Find what exception this will throw and catch it and call", "# self.driver.execute_script(\"window.sto...
Try and return page content in the requested format using selenium
[ "Try", "and", "return", "page", "content", "in", "the", "requested", "format", "using", "selenium" ]
python
train
41.025641
LuminosoInsight/luminoso-api-client-python
luminoso_api/v4_json_stream.py
https://github.com/LuminosoInsight/luminoso-api-client-python/blob/3bedf2a454aee39214c11fbf556ead3eecc27881/luminoso_api/v4_json_stream.py#L289-L306
def main(): """ Handle command line arguments to convert a file to a JSON stream as a script. """ logging.basicConfig(level=logging.INFO) import argparse parser = argparse.ArgumentParser( description="Translate CSV or JSON input to a JSON stream, or verify " "some...
[ "def", "main", "(", ")", ":", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "INFO", ")", "import", "argparse", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "\"Translate CSV or JSON input to a JSON stream, or verify \...
Handle command line arguments to convert a file to a JSON stream as a script.
[ "Handle", "command", "line", "arguments", "to", "convert", "a", "file", "to", "a", "JSON", "stream", "as", "a", "script", "." ]
python
test
38.388889
SUNCAT-Center/CatHub
cathub/reaction_networks.py
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/reaction_networks.py#L689-L721
def set_intermediates(self, intermediates, betas=None, transition_states=None): """Sets up intermediates and specifies whether it's an electrochemical step. Either provide individual contributions or net contributions. If both are given, only the net contributions are used. intermediate...
[ "def", "set_intermediates", "(", "self", ",", "intermediates", ",", "betas", "=", "None", ",", "transition_states", "=", "None", ")", ":", "self", ".", "intermediates", "=", "intermediates", "self", ".", "betas", "=", "betas", "self", ".", "transition_states",...
Sets up intermediates and specifies whether it's an electrochemical step. Either provide individual contributions or net contributions. If both are given, only the net contributions are used. intermediate_list: list of basestrings transition_states: list of True and False electr...
[ "Sets", "up", "intermediates", "and", "specifies", "whether", "it", "s", "an", "electrochemical", "step", ".", "Either", "provide", "individual", "contributions", "or", "net", "contributions", ".", "If", "both", "are", "given", "only", "the", "net", "contributio...
python
train
42.242424
inasafe/inasafe
safe/plugin.py
https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/plugin.py#L338-L347
def _create_geonode_uploader_action(self): """Create action for Geonode uploader dialog.""" icon = resources_path('img', 'icons', 'geonode.png') label = tr('Geonode Uploader') self.action_geonode = QAction( QIcon(icon), label, self.iface.mainWindow()) self.action_geon...
[ "def", "_create_geonode_uploader_action", "(", "self", ")", ":", "icon", "=", "resources_path", "(", "'img'", ",", "'icons'", ",", "'geonode.png'", ")", "label", "=", "tr", "(", "'Geonode Uploader'", ")", "self", ".", "action_geonode", "=", "QAction", "(", "QI...
Create action for Geonode uploader dialog.
[ "Create", "action", "for", "Geonode", "uploader", "dialog", "." ]
python
train
52.3
saltstack/salt
salt/modules/state.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/state.py#L527-L576
def template(tem, queue=False, **kwargs): ''' Execute the information stored in a template file on the minion. This function does not ask a master for a SLS file to render but instead directly processes the file at the provided path on the minion. CLI Example: .. code-block:: bash sa...
[ "def", "template", "(", "tem", ",", "queue", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "'env'", "in", "kwargs", ":", "# \"env\" is not supported; Use \"saltenv\".", "kwargs", ".", "pop", "(", "'env'", ")", "conflict", "=", "_check_queue", "(", ...
Execute the information stored in a template file on the minion. This function does not ask a master for a SLS file to render but instead directly processes the file at the provided path on the minion. CLI Example: .. code-block:: bash salt '*' state.template '<Path to template on the minion...
[ "Execute", "the", "information", "stored", "in", "a", "template", "file", "on", "the", "minion", "." ]
python
train
36.34
saltstack/salt
salt/modules/osquery.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/osquery.py#L209-L221
def shared_memory(attrs=None, where=None): ''' Return shared_memory information from osquery CLI Example: .. code-block:: bash salt '*' osquery.shared_memory ''' if __grains__['os_family'] in ['RedHat', 'Debian']: return _osquery_cmd(table='shared_memory', attrs=attrs, where=w...
[ "def", "shared_memory", "(", "attrs", "=", "None", ",", "where", "=", "None", ")", ":", "if", "__grains__", "[", "'os_family'", "]", "in", "[", "'RedHat'", ",", "'Debian'", "]", ":", "return", "_osquery_cmd", "(", "table", "=", "'shared_memory'", ",", "a...
Return shared_memory information from osquery CLI Example: .. code-block:: bash salt '*' osquery.shared_memory
[ "Return", "shared_memory", "information", "from", "osquery" ]
python
train
31.307692
tanghaibao/jcvi
jcvi/assembly/allmaps.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/assembly/allmaps.py#L203-L221
def prepare_ec(self, scaffolds, tour, weights): """ Prepare Evolutionary Computation. This converts scaffold names into indices (integer) in the scaffolds array. """ scaffolds_ii = dict((s, i) for i, s in enumerate(scaffolds)) scfs = [] ww = [] for mlg in ...
[ "def", "prepare_ec", "(", "self", ",", "scaffolds", ",", "tour", ",", "weights", ")", ":", "scaffolds_ii", "=", "dict", "(", "(", "s", ",", "i", ")", "for", "i", ",", "s", "in", "enumerate", "(", "scaffolds", ")", ")", "scfs", "=", "[", "]", "ww"...
Prepare Evolutionary Computation. This converts scaffold names into indices (integer) in the scaffolds array.
[ "Prepare", "Evolutionary", "Computation", ".", "This", "converts", "scaffold", "names", "into", "indices", "(", "integer", ")", "in", "the", "scaffolds", "array", "." ]
python
train
34.578947
BernardFW/bernard
src/bernard/server/views.py
https://github.com/BernardFW/bernard/blob/9c55703e5ffe5717c9fa39793df59dbfa5b4c5ab/src/bernard/server/views.py#L99-L108
async def postback_send(msg: BaseMessage, platform: Platform) -> Response: """ Injects the POST body into the FSM as a Postback message. """ await platform.inject_message(msg) return json_response({ 'status': 'ok', })
[ "async", "def", "postback_send", "(", "msg", ":", "BaseMessage", ",", "platform", ":", "Platform", ")", "->", "Response", ":", "await", "platform", ".", "inject_message", "(", "msg", ")", "return", "json_response", "(", "{", "'status'", ":", "'ok'", ",", "...
Injects the POST body into the FSM as a Postback message.
[ "Injects", "the", "POST", "body", "into", "the", "FSM", "as", "a", "Postback", "message", "." ]
python
train
24.2
gem/oq-engine
openquake/hazardlib/gsim/bindi_2011.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/bindi_2011.py#L135-L148
def _compute_magnitude(self, rup, C): """ Compute the third term of the equation 1: e1 + b1 * (M-Mh) + b2 * (M-Mh)**2 for M<=Mh e1 + b3 * (M-Mh) otherwise """ m_h = 6.75 b_3 = 0.0 if rup.mag <= m_h: return C["e1"] + (C['b1'] * (rup.mag - m_h))...
[ "def", "_compute_magnitude", "(", "self", ",", "rup", ",", "C", ")", ":", "m_h", "=", "6.75", "b_3", "=", "0.0", "if", "rup", ".", "mag", "<=", "m_h", ":", "return", "C", "[", "\"e1\"", "]", "+", "(", "C", "[", "'b1'", "]", "*", "(", "rup", "...
Compute the third term of the equation 1: e1 + b1 * (M-Mh) + b2 * (M-Mh)**2 for M<=Mh e1 + b3 * (M-Mh) otherwise
[ "Compute", "the", "third", "term", "of", "the", "equation", "1", ":" ]
python
train
30.428571
Alignak-monitoring/alignak
alignak/external_command.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/external_command.py#L3507-L3537
def schedule_hostgroup_host_downtime(self, hostgroup, start_time, end_time, fixed, trigger_id, duration, author, comment): """Schedule a downtime for each host of a hostgroup Format of the line that triggers function call:: SCHEDULE_HOSTGROUP_HOST_DOWNTI...
[ "def", "schedule_hostgroup_host_downtime", "(", "self", ",", "hostgroup", ",", "start_time", ",", "end_time", ",", "fixed", ",", "trigger_id", ",", "duration", ",", "author", ",", "comment", ")", ":", "for", "host_id", "in", "hostgroup", ".", "get_hosts", "(",...
Schedule a downtime for each host of a hostgroup Format of the line that triggers function call:: SCHEDULE_HOSTGROUP_HOST_DOWNTIME;<hostgroup_name>;<start_time>;<end_time>; <fixed>;<trigger_id>;<duration>;<author>;<comment> :param hostgroup: hostgroup to schedule :type hostgrou...
[ "Schedule", "a", "downtime", "for", "each", "host", "of", "a", "hostgroup", "Format", "of", "the", "line", "that", "triggers", "function", "call", "::" ]
python
train
43.16129
dropbox/stone
stone/frontend/ir_generator.py
https://github.com/dropbox/stone/blob/2e95cbcd1c48e05cca68c919fd8d24adec6b0f58/stone/frontend/ir_generator.py#L1056-L1136
def _resolve_type(self, env, type_ref, enforce_fully_defined=False): """ Resolves the data type referenced by type_ref. If `enforce_fully_defined` is True, then the referenced type must be fully populated (fields, parent_type, ...), and not simply a forward reference. ""...
[ "def", "_resolve_type", "(", "self", ",", "env", ",", "type_ref", ",", "enforce_fully_defined", "=", "False", ")", ":", "loc", "=", "type_ref", ".", "lineno", ",", "type_ref", ".", "path", "orig_namespace_name", "=", "env", ".", "namespace_name", "if", "type...
Resolves the data type referenced by type_ref. If `enforce_fully_defined` is True, then the referenced type must be fully populated (fields, parent_type, ...), and not simply a forward reference.
[ "Resolves", "the", "data", "type", "referenced", "by", "type_ref", "." ]
python
train
45.345679
juju/charm-helpers
charmhelpers/contrib/openstack/utils.py
https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/utils.py#L1077-L1090
def _check_running_services(services): """Check that the services dict provided is actually running and provide a list of (service, boolean) tuples for each service. Returns both a zipped list of (service, boolean) and a list of booleans in the same order as the services. @param services: OrderedD...
[ "def", "_check_running_services", "(", "services", ")", ":", "services_running", "=", "[", "service_running", "(", "s", ")", "for", "s", "in", "services", "]", "return", "list", "(", "zip", "(", "services", ",", "services_running", ")", ")", ",", "services_r...
Check that the services dict provided is actually running and provide a list of (service, boolean) tuples for each service. Returns both a zipped list of (service, boolean) and a list of booleans in the same order as the services. @param services: OrderedDict of strings: [ports], one for each service ...
[ "Check", "that", "the", "services", "dict", "provided", "is", "actually", "running", "and", "provide", "a", "list", "of", "(", "service", "boolean", ")", "tuples", "for", "each", "service", "." ]
python
train
47.214286
apache/spark
python/pyspark/util.py
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/util.py#L70-L89
def majorMinorVersion(sparkVersion): """ Given a Spark version string, return the (major version number, minor version number). E.g., for 2.0.1-SNAPSHOT, return (2, 0). >>> sparkVersion = "2.4.0" >>> VersionUtils.majorMinorVersion(sparkVersion) (2, 4) >>> sparkVe...
[ "def", "majorMinorVersion", "(", "sparkVersion", ")", ":", "m", "=", "re", ".", "search", "(", "r'^(\\d+)\\.(\\d+)(\\..*)?$'", ",", "sparkVersion", ")", "if", "m", "is", "not", "None", ":", "return", "(", "int", "(", "m", ".", "group", "(", "1", ")", "...
Given a Spark version string, return the (major version number, minor version number). E.g., for 2.0.1-SNAPSHOT, return (2, 0). >>> sparkVersion = "2.4.0" >>> VersionUtils.majorMinorVersion(sparkVersion) (2, 4) >>> sparkVersion = "2.3.0-SNAPSHOT" >>> VersionUtils.majorMi...
[ "Given", "a", "Spark", "version", "string", "return", "the", "(", "major", "version", "number", "minor", "version", "number", ")", ".", "E", ".", "g", ".", "for", "2", ".", "0", ".", "1", "-", "SNAPSHOT", "return", "(", "2", "0", ")", "." ]
python
train
39.65
SetBased/py-stratum
pystratum/application/PyStratumApplication.py
https://github.com/SetBased/py-stratum/blob/7c5ffaa2fdd03f865832a5190b5897ff2c0e3155/pystratum/application/PyStratumApplication.py#L25-L38
def get_default_commands(self): """ Returns the default commands of this application. :rtype: list[cleo.Command] """ commands = Application.get_default_commands(self) self.add(ConstantsCommand()) self.add(LoaderCommand()) self.add(PyStratumCommand()) ...
[ "def", "get_default_commands", "(", "self", ")", ":", "commands", "=", "Application", ".", "get_default_commands", "(", "self", ")", "self", ".", "add", "(", "ConstantsCommand", "(", ")", ")", "self", ".", "add", "(", "LoaderCommand", "(", ")", ")", "self"...
Returns the default commands of this application. :rtype: list[cleo.Command]
[ "Returns", "the", "default", "commands", "of", "this", "application", "." ]
python
train
25.928571
horazont/aioxmpp
aioxmpp/structs.py
https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/structs.py#L792-L815
def fromstr(cls, s, *, strict=True): """ Construct a JID out of a string containing it. :param s: The string to parse. :type s: :class:`str` :param strict: Whether to enable strict parsing. :type strict: :class:`bool` :raises: See :class:`JID` :return: Th...
[ "def", "fromstr", "(", "cls", ",", "s", ",", "*", ",", "strict", "=", "True", ")", ":", "nodedomain", ",", "sep", ",", "resource", "=", "s", ".", "partition", "(", "\"/\"", ")", "if", "not", "sep", ":", "resource", "=", "None", "localpart", ",", ...
Construct a JID out of a string containing it. :param s: The string to parse. :type s: :class:`str` :param strict: Whether to enable strict parsing. :type strict: :class:`bool` :raises: See :class:`JID` :return: The parsed JID :rtype: :class:`JID` See th...
[ "Construct", "a", "JID", "out", "of", "a", "string", "containing", "it", "." ]
python
train
31.208333
mrcagney/make_gtfs
make_gtfs/protofeed.py
https://github.com/mrcagney/make_gtfs/blob/37b6f88e03bac708c2e85d6f4b6d48a0c92e4a59/make_gtfs/protofeed.py#L73-L86
def copy(self): """ Return a copy of this ProtoFeed, that is, a feed with all the same attributes. """ other = ProtoFeed() for key in cs.PROTOFEED_ATTRS: value = getattr(self, key) if isinstance(value, pd.DataFrame): # Pandas copy D...
[ "def", "copy", "(", "self", ")", ":", "other", "=", "ProtoFeed", "(", ")", "for", "key", "in", "cs", ".", "PROTOFEED_ATTRS", ":", "value", "=", "getattr", "(", "self", ",", "key", ")", "if", "isinstance", "(", "value", ",", "pd", ".", "DataFrame", ...
Return a copy of this ProtoFeed, that is, a feed with all the same attributes.
[ "Return", "a", "copy", "of", "this", "ProtoFeed", "that", "is", "a", "feed", "with", "all", "the", "same", "attributes", "." ]
python
train
29.5
timothydmorton/VESPA
vespa/stars/populations.py
https://github.com/timothydmorton/VESPA/blob/0446b54d48009f3655cfd1a3957ceea21d3adcaa/vespa/stars/populations.py#L297-L305
def bands(self): """ Bandpasses for which StarPopulation has magnitude data """ bands = [] for c in self.stars.columns: if re.search('_mag',c): bands.append(c) return bands
[ "def", "bands", "(", "self", ")", ":", "bands", "=", "[", "]", "for", "c", "in", "self", ".", "stars", ".", "columns", ":", "if", "re", ".", "search", "(", "'_mag'", ",", "c", ")", ":", "bands", ".", "append", "(", "c", ")", "return", "bands" ]
Bandpasses for which StarPopulation has magnitude data
[ "Bandpasses", "for", "which", "StarPopulation", "has", "magnitude", "data" ]
python
train
26.666667
orb-framework/orb
orb/core/model.py
https://github.com/orb-framework/orb/blob/575be2689cb269e65a0a2678232ff940acc19e5a/orb/core/model.py#L387-L419
def changes(self, columns=None, recurse=True, flags=0, inflated=False): """ Returns a dictionary of changes that have been made to the data from this record. :return { <orb.Column>: ( <variant> old, <variant> new), .. } """ output = {} is_record = self.isReco...
[ "def", "changes", "(", "self", ",", "columns", "=", "None", ",", "recurse", "=", "True", ",", "flags", "=", "0", ",", "inflated", "=", "False", ")", ":", "output", "=", "{", "}", "is_record", "=", "self", ".", "isRecord", "(", ")", "schema", "=", ...
Returns a dictionary of changes that have been made to the data from this record. :return { <orb.Column>: ( <variant> old, <variant> new), .. }
[ "Returns", "a", "dictionary", "of", "changes", "that", "have", "been", "made", "to", "the", "data", "from", "this", "record", "." ]
python
train
36.030303
jadolg/rocketchat_API
rocketchat_API/rocketchat.py
https://github.com/jadolg/rocketchat_API/blob/f220d094434991cb9892418245f054ea06f28aad/rocketchat_API/rocketchat.py#L596-L598
def im_set_topic(self, room_id, topic, **kwargs): """Sets the topic for the direct message""" return self.__call_api_post('im.setTopic', roomId=room_id, topic=topic, kwargs=kwargs)
[ "def", "im_set_topic", "(", "self", ",", "room_id", ",", "topic", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "__call_api_post", "(", "'im.setTopic'", ",", "roomId", "=", "room_id", ",", "topic", "=", "topic", ",", "kwargs", "=", "kwargs", ...
Sets the topic for the direct message
[ "Sets", "the", "topic", "for", "the", "direct", "message" ]
python
train
64.666667
nuagenetworks/monolithe
monolithe/generators/lang/javascript/writers/apiversionwriter.py
https://github.com/nuagenetworks/monolithe/blob/626011af3ff43f73b7bd8aa5e1f93fb5f1f0e181/monolithe/generators/lang/javascript/writers/apiversionwriter.py#L242-L257
def _write_enums(self, entity_name, attributes): """ This method writes the ouput for a particular specification. """ self.enum_attrs_for_locale[entity_name] = attributes; for attribute in attributes: enum_name = "%s%sEnum" % (entity_name, attribute.name[0].upper() ...
[ "def", "_write_enums", "(", "self", ",", "entity_name", ",", "attributes", ")", ":", "self", ".", "enum_attrs_for_locale", "[", "entity_name", "]", "=", "attributes", "for", "attribute", "in", "attributes", ":", "enum_name", "=", "\"%s%sEnum\"", "%", "(", "ent...
This method writes the ouput for a particular specification.
[ "This", "method", "writes", "the", "ouput", "for", "a", "particular", "specification", "." ]
python
train
48.25
draperjames/qtpandas
qtpandas/models/DataFrameModel.py
https://github.com/draperjames/qtpandas/blob/64294fb69f1839e53dee5ea453337266bfaf24f4/qtpandas/models/DataFrameModel.py#L50-L72
def read_sql(sql, con, filePath, index_col=None, coerce_float=True, params=None, parse_dates=None, columns=None, chunksize=None): """ Read SQL query or database table into a DataFrameModel. Provide a filePath argument in addition to the *args/**kwargs from pandas.read_sql and get a DataFram...
[ "def", "read_sql", "(", "sql", ",", "con", ",", "filePath", ",", "index_col", "=", "None", ",", "coerce_float", "=", "True", ",", "params", "=", "None", ",", "parse_dates", "=", "None", ",", "columns", "=", "None", ",", "chunksize", "=", "None", ")", ...
Read SQL query or database table into a DataFrameModel. Provide a filePath argument in addition to the *args/**kwargs from pandas.read_sql and get a DataFrameModel. NOTE: The chunksize option is overridden to None always (for now). Reference: http://pandas.pydata.org/pandas-docs/version/0.18.1/gen...
[ "Read", "SQL", "query", "or", "database", "table", "into", "a", "DataFrameModel", ".", "Provide", "a", "filePath", "argument", "in", "addition", "to", "the", "*", "args", "/", "**", "kwargs", "from", "pandas", ".", "read_sql", "and", "get", "a", "DataFrame...
python
train
39.521739
SiLab-Bonn/pyBAR
pybar/analysis/analysis_utils.py
https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/analysis/analysis_utils.py#L1615-L1632
def print_raw_data_file(input_file, start_index=0, limit=200, flavor='fei4b', select=None, tdc_trig_dist=False, trigger_data_mode=0, meta_data_v2=True): """Printing FEI4 data from raw data file for debugging. """ with tb.open_file(input_file + '.h5', mode="r") as file_h5: if meta_data_v2: ...
[ "def", "print_raw_data_file", "(", "input_file", ",", "start_index", "=", "0", ",", "limit", "=", "200", ",", "flavor", "=", "'fei4b'", ",", "select", "=", "None", ",", "tdc_trig_dist", "=", "False", ",", "trigger_data_mode", "=", "0", ",", "meta_data_v2", ...
Printing FEI4 data from raw data file for debugging.
[ "Printing", "FEI4", "data", "from", "raw", "data", "file", "for", "debugging", "." ]
python
train
74.555556
fozzle/python-brotherprint
brotherprint/brotherprint.py
https://github.com/fozzle/python-brotherprint/blob/5fb92df11b599c30a7da3d6ac7ed60acff230044/brotherprint/brotherprint.py#L989-L1004
def select_delim(self, delim): '''Select desired delimeter Args: delim: The delimeter character you want. Returns: None Raises: RuntimeError: Delimeter too long. ''' size = len(delim) if size > 20: raise Run...
[ "def", "select_delim", "(", "self", ",", "delim", ")", ":", "size", "=", "len", "(", "delim", ")", "if", "size", ">", "20", ":", "raise", "RuntimeError", "(", "'Delimeter too long'", ")", "n1", "=", "size", "/", "10", "n2", "=", "size", "%", "10", ...
Select desired delimeter Args: delim: The delimeter character you want. Returns: None Raises: RuntimeError: Delimeter too long.
[ "Select", "desired", "delimeter", "Args", ":", "delim", ":", "The", "delimeter", "character", "you", "want", ".", "Returns", ":", "None", "Raises", ":", "RuntimeError", ":", "Delimeter", "too", "long", "." ]
python
train
26.1875
joke2k/faker
faker/providers/ssn/it_IT/__init__.py
https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/ssn/it_IT/__init__.py#L18-L24
def checksum(value): """ Calculates the checksum char used for the 16th char. Author: Vincenzo Palazzo """ return chr(65 + sum(CHECKSUM_TABLE[index % 2][ALPHANUMERICS_DICT[char]] for index, char in enumerate(value)) % 26)
[ "def", "checksum", "(", "value", ")", ":", "return", "chr", "(", "65", "+", "sum", "(", "CHECKSUM_TABLE", "[", "index", "%", "2", "]", "[", "ALPHANUMERICS_DICT", "[", "char", "]", "]", "for", "index", ",", "char", "in", "enumerate", "(", "value", ")"...
Calculates the checksum char used for the 16th char. Author: Vincenzo Palazzo
[ "Calculates", "the", "checksum", "char", "used", "for", "the", "16th", "char", ".", "Author", ":", "Vincenzo", "Palazzo" ]
python
train
37
resonai/ybt
yabt/dot.py
https://github.com/resonai/ybt/blob/5b40df0922ef3383eb85f2b04a26a2db4b81b3fd/yabt/dot.py#L62-L79
def write_dot(build_context, conf: Config, out_f): """Write build graph in dot format to `out_f` file-like object.""" not_buildenv_targets = get_not_buildenv_targets(build_context) prebuilt_targets = get_prebuilt_targets(build_context) out_f.write('strict digraph {\n') for node in build_context.tar...
[ "def", "write_dot", "(", "build_context", ",", "conf", ":", "Config", ",", "out_f", ")", ":", "not_buildenv_targets", "=", "get_not_buildenv_targets", "(", "build_context", ")", "prebuilt_targets", "=", "get_prebuilt_targets", "(", "build_context", ")", "out_f", "."...
Write build graph in dot format to `out_f` file-like object.
[ "Write", "build", "graph", "in", "dot", "format", "to", "out_f", "file", "-", "like", "object", "." ]
python
train
57.388889
tek/proteome
proteome/project.py
https://github.com/tek/proteome/blob/b4fea6ca633a5b9ff56eaaf2507028fc6ff078b9/proteome/project.py#L305-L323
def from_json(self, json: Map) -> Maybe[Project]: ''' Try to instantiate a Project from the given json object. Convert the **type** key to **tpe** and its value to Maybe. Make sure **root** is a directory, fall back to resolution by **tpe/name**. Reinsert the root dir int...
[ "def", "from_json", "(", "self", ",", "json", ":", "Map", ")", "->", "Maybe", "[", "Project", "]", ":", "root", "=", "json", ".", "get", "(", "'root'", ")", ".", "map", "(", "mkpath", ")", ".", "or_else", "(", "json", ".", "get_all", "(", "'type'...
Try to instantiate a Project from the given json object. Convert the **type** key to **tpe** and its value to Maybe. Make sure **root** is a directory, fall back to resolution by **tpe/name**. Reinsert the root dir into the json dict, filter out all keys that aren't conta...
[ "Try", "to", "instantiate", "a", "Project", "from", "the", "given", "json", "object", ".", "Convert", "the", "**", "type", "**", "key", "to", "**", "tpe", "**", "and", "its", "value", "to", "Maybe", ".", "Make", "sure", "**", "root", "**", "is", "a",...
python
train
44.578947
jab/bidict
bidict/_orderedbidict.py
https://github.com/jab/bidict/blob/1a1ba9758651aed9c4f58384eff006d2e2ad6835/bidict/_orderedbidict.py#L47-L59
def popitem(self, last=True): # pylint: disable=arguments-differ u"""*x.popitem() → (k, v)* Remove and return the most recently added item as a (key, value) pair if *last* is True, else the least recently added item. :raises KeyError: if *x* is empty. """ if not self: ...
[ "def", "popitem", "(", "self", ",", "last", "=", "True", ")", ":", "# pylint: disable=arguments-differ", "if", "not", "self", ":", "raise", "KeyError", "(", "'mapping is empty'", ")", "key", "=", "next", "(", "(", "reversed", "if", "last", "else", "iter", ...
u"""*x.popitem() → (k, v)* Remove and return the most recently added item as a (key, value) pair if *last* is True, else the least recently added item. :raises KeyError: if *x* is empty.
[ "u", "*", "x", ".", "popitem", "()", "→", "(", "k", "v", ")", "*" ]
python
test
35.538462
yatiml/yatiml
yatiml/helpers.py
https://github.com/yatiml/yatiml/blob/4f55c058b72388350f0af3076ac3ea9bc1c142b0/yatiml/helpers.py#L427-L525
def map_attribute_to_seq(self, attribute: str, key_attribute: str, value_attribute: Optional[str] = None) -> None: """Converts a mapping attribute to a sequence. This function takes an attribute of this Node whose va...
[ "def", "map_attribute_to_seq", "(", "self", ",", "attribute", ":", "str", ",", "key_attribute", ":", "str", ",", "value_attribute", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "None", ":", "if", "not", "self", ".", "has_attribute", "(", "at...
Converts a mapping attribute to a sequence. This function takes an attribute of this Node whose value \ is a mapping or a mapping of mappings and turns it into a \ sequence of mappings. Each entry in the original mapping is \ converted to an entry in the list. If only a key attribute is...
[ "Converts", "a", "mapping", "attribute", "to", "a", "sequence", "." ]
python
train
38.454545
learningequality/le-utils
le_utils/constants/languages.py
https://github.com/learningequality/le-utils/blob/07a776e3d5c288818764a25170de2e9ec5850c0d/le_utils/constants/languages.py#L200-L231
def getlang_by_alpha2(code): """ Lookup a Language object for language code `code` based on these strategies: - Special case rules for Hebrew and Chinese Hans/Hant scripts - Using `alpha_2` lookup in `pycountry.languages` followed by lookup for a language with the same `name` in the internal...
[ "def", "getlang_by_alpha2", "(", "code", ")", ":", "# Handle special cases for language codes returned by YouTube API", "if", "code", "==", "'iw'", ":", "# handle old Hebrew code 'iw' and return modern code 'he'", "return", "getlang", "(", "'he'", ")", "elif", "'zh-Hans'", "i...
Lookup a Language object for language code `code` based on these strategies: - Special case rules for Hebrew and Chinese Hans/Hant scripts - Using `alpha_2` lookup in `pycountry.languages` followed by lookup for a language with the same `name` in the internal representaion Returns `None` if no m...
[ "Lookup", "a", "Language", "object", "for", "language", "code", "code", "based", "on", "these", "strategies", ":", "-", "Special", "case", "rules", "for", "Hebrew", "and", "Chinese", "Hans", "/", "Hant", "scripts", "-", "Using", "alpha_2", "lookup", "in", ...
python
train
41.5625
Arubacloud/pyArubaCloud
ArubaCloud/PyArubaAPI.py
https://github.com/Arubacloud/pyArubaCloud/blob/ec4aecd8ca342b1e1a4f16b7cc87cb5e697cfcd4/ArubaCloud/PyArubaAPI.py#L309-L323
def get_package_id(self, name): """ Retrieve the smart package id given is English name @param (str) name: the Aruba Smart package size name, ie: "small", "medium", "large", "extra large". @return: The package id that depends on the Data center and the size choosen. """ j...
[ "def", "get_package_id", "(", "self", ",", "name", ")", ":", "json_scheme", "=", "self", ".", "gen_def_json_scheme", "(", "'GetPreConfiguredPackages'", ",", "dict", "(", "HypervisorType", "=", "4", ")", ")", "json_obj", "=", "self", ".", "call_method_post", "(...
Retrieve the smart package id given is English name @param (str) name: the Aruba Smart package size name, ie: "small", "medium", "large", "extra large". @return: The package id that depends on the Data center and the size choosen.
[ "Retrieve", "the", "smart", "package", "id", "given", "is", "English", "name" ]
python
train
57.266667
pahaz/sshtunnel
sshtunnel.py
https://github.com/pahaz/sshtunnel/blob/66a923e4c6c8e41b8348420523fbf5ddfd53176c/sshtunnel.py#L1061-L1097
def _consolidate_auth(ssh_password=None, ssh_pkey=None, ssh_pkey_password=None, allow_agent=True, host_pkey_directories=None, logger=None): """ Get sure authentication inform...
[ "def", "_consolidate_auth", "(", "ssh_password", "=", "None", ",", "ssh_pkey", "=", "None", ",", "ssh_pkey_password", "=", "None", ",", "allow_agent", "=", "True", ",", "host_pkey_directories", "=", "None", ",", "logger", "=", "None", ")", ":", "ssh_loaded_pke...
Get sure authentication information is in place. ``ssh_pkey`` may be of classes: - ``str`` - in this case it represents a private key file; public key will be obtained from it - ``paramiko.Pkey`` - it will be transparently added to loaded keys
[ "Get", "sure", "authentication", "information", "is", "in", "place", ".", "ssh_pkey", "may", "be", "of", "classes", ":", "-", "str", "-", "in", "this", "case", "it", "represents", "a", "private", "key", "file", ";", "public", "key", "will", "be", "obtain...
python
train
41.945946
jilljenn/tryalgo
tryalgo/range_minimum_query.py
https://github.com/jilljenn/tryalgo/blob/89a4dd9655e7b6b0a176f72b4c60d0196420dfe1/tryalgo/range_minimum_query.py#L126-L150
def _clear(self, node, left, right): """propagates the lazy updates for this node to the subtrees. as a result the maxval, minval, sumval values for the node are up to date. """ if self.lazyset[node] is not None: # first do the pending set val = self.lazyset[node] ...
[ "def", "_clear", "(", "self", ",", "node", ",", "left", ",", "right", ")", ":", "if", "self", ".", "lazyset", "[", "node", "]", "is", "not", "None", ":", "# first do the pending set", "val", "=", "self", ".", "lazyset", "[", "node", "]", "self", ".",...
propagates the lazy updates for this node to the subtrees. as a result the maxval, minval, sumval values for the node are up to date.
[ "propagates", "the", "lazy", "updates", "for", "this", "node", "to", "the", "subtrees", ".", "as", "a", "result", "the", "maxval", "minval", "sumval", "values", "for", "the", "node", "are", "up", "to", "date", "." ]
python
train
47.88
decryptus/sonicprobe
sonicprobe/libs/anysql.py
https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/anysql.py#L538-L549
def c14n_uri(sqluri): """ Ask the backend to c14n the uri. See register_uri_backend() for details. If no backend is found for this uri method, a NotImplementedError will be raised. """ uri_c14n_method = _get_methods_by_uri(sqluri)[METHOD_C14N_URI] if not uri_c14n_method: return ...
[ "def", "c14n_uri", "(", "sqluri", ")", ":", "uri_c14n_method", "=", "_get_methods_by_uri", "(", "sqluri", ")", "[", "METHOD_C14N_URI", "]", "if", "not", "uri_c14n_method", ":", "return", "sqluri", "return", "uri_c14n_method", "(", "sqluri", ")" ]
Ask the backend to c14n the uri. See register_uri_backend() for details. If no backend is found for this uri method, a NotImplementedError will be raised.
[ "Ask", "the", "backend", "to", "c14n", "the", "uri", ".", "See", "register_uri_backend", "()", "for", "details", "." ]
python
train
29.166667
telminov/sw-python-utils
swutils/date.py
https://github.com/telminov/sw-python-utils/blob/68f976122dd26a581b8d833c023f7f06542ca85c/swutils/date.py#L112-L118
def age_to_date(age): """ преобразует возраст в год рождения. (Для фильтрации по дате рождения) """ today = datetime.date.today() date = datetime.date(today.year - age - 1, today.month, today.day) + datetime.timedelta(days=1) return date
[ "def", "age_to_date", "(", "age", ")", ":", "today", "=", "datetime", ".", "date", ".", "today", "(", ")", "date", "=", "datetime", ".", "date", "(", "today", ".", "year", "-", "age", "-", "1", ",", "today", ".", "month", ",", "today", ".", "day"...
преобразует возраст в год рождения. (Для фильтрации по дате рождения)
[ "преобразует", "возраст", "в", "год", "рождения", ".", "(", "Для", "фильтрации", "по", "дате", "рождения", ")" ]
python
train
37
tcalmant/ipopo
pelix/misc/log.py
https://github.com/tcalmant/ipopo/blob/2f9ae0c44cd9c34ef1a9d50837b3254e75678eb1/pelix/misc/log.py#L241-L270
def _store_entry(self, entry): """ Stores a new log entry and notifies listeners :param entry: A LogEntry object """ # Get the logger and log the message self.__logs.append(entry) # Notify listeners for listener in self.__listeners.copy(): tr...
[ "def", "_store_entry", "(", "self", ",", "entry", ")", ":", "# Get the logger and log the message", "self", ".", "__logs", ".", "append", "(", "entry", ")", "# Notify listeners", "for", "listener", "in", "self", ".", "__listeners", ".", "copy", "(", ")", ":", ...
Stores a new log entry and notifies listeners :param entry: A LogEntry object
[ "Stores", "a", "new", "log", "entry", "and", "notifies", "listeners" ]
python
train
33.766667
binux/pyspider
pyspider/fetcher/tornado_fetcher.py
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/fetcher/tornado_fetcher.py#L431-L529
def phantomjs_fetch(self, url, task): '''Fetch with phantomjs proxy''' start_time = time.time() self.on_fetch('phantomjs', task) handle_error = lambda x: self.handle_error('phantomjs', url, task, start_time, x) # check phantomjs proxy is enabled if not self.phantomjs_pro...
[ "def", "phantomjs_fetch", "(", "self", ",", "url", ",", "task", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "self", ".", "on_fetch", "(", "'phantomjs'", ",", "task", ")", "handle_error", "=", "lambda", "x", ":", "self", ".", "handle_err...
Fetch with phantomjs proxy
[ "Fetch", "with", "phantomjs", "proxy" ]
python
train
38.383838
clalancette/pycdlib
pycdlib/rockridge.py
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/rockridge.py#L218-L231
def record(self): # type: () -> bytes ''' Generate a string representing the Rock Ridge Rock Ridge record. Parameters: None. Returns: String containing the Rock Ridge record. ''' if not self._initialized: raise pycdlibexception.PyCdl...
[ "def", "record", "(", "self", ")", ":", "# type: () -> bytes", "if", "not", "self", ".", "_initialized", ":", "raise", "pycdlibexception", ".", "PyCdlibInternalError", "(", "'RR record not yet initialized!'", ")", "return", "b'RR'", "+", "struct", ".", "pack", "("...
Generate a string representing the Rock Ridge Rock Ridge record. Parameters: None. Returns: String containing the Rock Ridge record.
[ "Generate", "a", "string", "representing", "the", "Rock", "Ridge", "Rock", "Ridge", "record", "." ]
python
train
32.428571
Yubico/yubikey-manager
ykman/cli/oath.py
https://github.com/Yubico/yubikey-manager/blob/3ac27bc59ae76a59db9d09a530494add2edbbabf/ykman/cli/oath.py#L307-L326
def list(ctx, show_hidden, oath_type, period): """ List all credentials. List all credentials stored on your YubiKey. """ ensure_validated(ctx) controller = ctx.obj['controller'] creds = [cred for cred in controller.list() if show_hidden or not cred.is_hidden ...
[ "def", "list", "(", "ctx", ",", "show_hidden", ",", "oath_type", ",", "period", ")", ":", "ensure_validated", "(", "ctx", ")", "controller", "=", "ctx", ".", "obj", "[", "'controller'", "]", "creds", "=", "[", "cred", "for", "cred", "in", "controller", ...
List all credentials. List all credentials stored on your YubiKey.
[ "List", "all", "credentials", "." ]
python
train
29.6
tjvr/kurt
kurt/scratch14/objtable.py
https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/scratch14/objtable.py#L60-L69
def _encode(self, obj, context): """Encodes a class to a lower-level object using the class' own to_construct function. If no such function is defined, returns the object unchanged. """ func = getattr(obj, 'to_construct', None) if callable(func): return func(c...
[ "def", "_encode", "(", "self", ",", "obj", ",", "context", ")", ":", "func", "=", "getattr", "(", "obj", ",", "'to_construct'", ",", "None", ")", "if", "callable", "(", "func", ")", ":", "return", "func", "(", "context", ")", "else", ":", "return", ...
Encodes a class to a lower-level object using the class' own to_construct function. If no such function is defined, returns the object unchanged.
[ "Encodes", "a", "class", "to", "a", "lower", "-", "level", "object", "using", "the", "class", "own", "to_construct", "function", ".", "If", "no", "such", "function", "is", "defined", "returns", "the", "object", "unchanged", "." ]
python
train
35.5
intiocean/pyinter
pyinter/examples/daterange.py
https://github.com/intiocean/pyinter/blob/fb6e904307477fa43123cc9ab326680aa1a8cd62/pyinter/examples/daterange.py#L5-L11
def daterange(start, end, delta=timedelta(days=1), lower=Interval.CLOSED, upper=Interval.OPEN): """Returns a generator which creates the next value in the range on demand""" date_interval = Interval(lower=lower, lower_value=start, upper_value=end, upper=upper) current = start if start in date_interval else ...
[ "def", "daterange", "(", "start", ",", "end", ",", "delta", "=", "timedelta", "(", "days", "=", "1", ")", ",", "lower", "=", "Interval", ".", "CLOSED", ",", "upper", "=", "Interval", ".", "OPEN", ")", ":", "date_interval", "=", "Interval", "(", "lowe...
Returns a generator which creates the next value in the range on demand
[ "Returns", "a", "generator", "which", "creates", "the", "next", "value", "in", "the", "range", "on", "demand" ]
python
train
59.857143
kennethreitz/clint
clint/resources.py
https://github.com/kennethreitz/clint/blob/9d3693d644b8587d985972b6075d970096f6439e/clint/resources.py#L67-L73
def open(self, filename, mode='r'): """Returns file object from given filename.""" self._raise_if_none() fn = path_join(self.path, filename) return open(fn, mode)
[ "def", "open", "(", "self", ",", "filename", ",", "mode", "=", "'r'", ")", ":", "self", ".", "_raise_if_none", "(", ")", "fn", "=", "path_join", "(", "self", ".", "path", ",", "filename", ")", "return", "open", "(", "fn", ",", "mode", ")" ]
Returns file object from given filename.
[ "Returns", "file", "object", "from", "given", "filename", "." ]
python
train
27.142857
jxtech/wechatpy
wechatpy/client/api/wxa.py
https://github.com/jxtech/wechatpy/blob/4df0da795618c0895a10f1c2cde9e9d5c0a93aaa/wechatpy/client/api/wxa.py#L145-L164
def commit(self, template_id, ext_json, version, description): """ 为授权的小程序账号上传小程序代码 详情请参考 https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1489140610_Uavc4 :param template_id: 代码库中的代码模板 ID :param ext_json: 第三方自定义的配置 :param version: 代码版本号,开发者...
[ "def", "commit", "(", "self", ",", "template_id", ",", "ext_json", ",", "version", ",", "description", ")", ":", "return", "self", ".", "_post", "(", "'wxa/commit'", ",", "data", "=", "{", "'template_id'", ":", "template_id", ",", "'ext_json'", ":", "ext_j...
为授权的小程序账号上传小程序代码 详情请参考 https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&id=open1489140610_Uavc4 :param template_id: 代码库中的代码模板 ID :param ext_json: 第三方自定义的配置 :param version: 代码版本号,开发者可自定义 :param description: 代码描述,开发者可自定义
[ "为授权的小程序账号上传小程序代码", "详情请参考", "https", ":", "//", "open", ".", "weixin", ".", "qq", ".", "com", "/", "cgi", "-", "bin", "/", "showdocument?action", "=", "dir_list&id", "=", "open1489140610_Uavc4" ]
python
train
31
materialsproject/custodian
custodian/ansible/actions.py
https://github.com/materialsproject/custodian/blob/b33b01574fc899f959acb3c495398fd3d0fc41d0/custodian/ansible/actions.py#L154-L168
def file_create(filename, settings): """ Creates a file. Args: filename (str): Filename. settings (dict): Must be {"content": actual_content} """ if len(settings) != 1: raise ValueError("Settings must only contain one item with key " ...
[ "def", "file_create", "(", "filename", ",", "settings", ")", ":", "if", "len", "(", "settings", ")", "!=", "1", ":", "raise", "ValueError", "(", "\"Settings must only contain one item with key \"", "\"'content'.\"", ")", "for", "k", ",", "v", "in", "settings", ...
Creates a file. Args: filename (str): Filename. settings (dict): Must be {"content": actual_content}
[ "Creates", "a", "file", "." ]
python
train
32.4
galaxyproject/pulsar
tools/install_venv.py
https://github.com/galaxyproject/pulsar/blob/9ab6683802884324652da0a9f0808c7eb59d3ab4/tools/install_venv.py#L92-L105
def create_virtualenv(venv=VENV): """Creates the virtual environment and installs PIP only into the virtual environment """ print 'Creating venv...', run_command(['virtualenv', '-q', '--no-site-packages', VENV]) print 'done.' print 'Installing pip in virtualenv...', if not run_command([W...
[ "def", "create_virtualenv", "(", "venv", "=", "VENV", ")", ":", "print", "'Creating venv...'", ",", "run_command", "(", "[", "'virtualenv'", ",", "'-q'", ",", "'--no-site-packages'", ",", "VENV", "]", ")", "print", "'done.'", "print", "'Installing pip in virtualen...
Creates the virtual environment and installs PIP only into the virtual environment
[ "Creates", "the", "virtual", "environment", "and", "installs", "PIP", "only", "into", "the", "virtual", "environment" ]
python
train
36.571429
saltstack/salt
salt/modules/zfs.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zfs.py#L575-L639
def diff(name_a, name_b=None, **kwargs): ''' Display the difference between a snapshot of a given filesystem and another snapshot of that filesystem from a later time or the current contents of the filesystem. name_a : string name of snapshot name_b : string (optional) name of s...
[ "def", "diff", "(", "name_a", ",", "name_b", "=", "None", ",", "*", "*", "kwargs", ")", ":", "## Configure command", "# NOTE: initialize the defaults", "flags", "=", "[", "'-H'", "]", "target", "=", "[", "]", "# NOTE: set extra config from kwargs", "if", "kwargs...
Display the difference between a snapshot of a given filesystem and another snapshot of that filesystem from a later time or the current contents of the filesystem. name_a : string name of snapshot name_b : string (optional) name of snapshot or filesystem show_changetime : boolean ...
[ "Display", "the", "difference", "between", "a", "snapshot", "of", "a", "given", "filesystem", "and", "another", "snapshot", "of", "that", "filesystem", "from", "a", "later", "time", "or", "the", "current", "contents", "of", "the", "filesystem", "." ]
python
train
30.138462
instaloader/instaloader
instaloader/instaloadercontext.py
https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L286-L301
def _graphql_query_waittime(self, query_hash: str, current_time: float, untracked_queries: bool = False) -> int: """Calculate time needed to wait before GraphQL query can be executed.""" sliding_window = 660 if query_hash not in self._graphql_query_timestamps: self._graphql_query_tim...
[ "def", "_graphql_query_waittime", "(", "self", ",", "query_hash", ":", "str", ",", "current_time", ":", "float", ",", "untracked_queries", ":", "bool", "=", "False", ")", "->", "int", ":", "sliding_window", "=", "660", "if", "query_hash", "not", "in", "self"...
Calculate time needed to wait before GraphQL query can be executed.
[ "Calculate", "time", "needed", "to", "wait", "before", "GraphQL", "query", "can", "be", "executed", "." ]
python
train
79.625
melizalab/libtfr
examples/tfr_tm.py
https://github.com/melizalab/libtfr/blob/9f7e7705793d258a0b205f185b20e3bbcda473da/examples/tfr_tm.py#L14-L56
def fmsin(N, fnormin=0.05, fnormax=0.45, period=None, t0=None, fnorm0=0.25, pm1=1): """ Signal with sinusoidal frequency modulation. generates a frequency modulation with a sinusoidal frequency. This sinusoidal modulation is designed such that the instantaneous frequency at time T0 is equal to FNOR...
[ "def", "fmsin", "(", "N", ",", "fnormin", "=", "0.05", ",", "fnormax", "=", "0.45", ",", "period", "=", "None", ",", "t0", "=", "None", ",", "fnorm0", "=", "0.25", ",", "pm1", "=", "1", ")", ":", "if", "period", "==", "None", ":", "period", "="...
Signal with sinusoidal frequency modulation. generates a frequency modulation with a sinusoidal frequency. This sinusoidal modulation is designed such that the instantaneous frequency at time T0 is equal to FNORM0, and the ambiguity between increasing or decreasing frequency is solved by PM1. N ...
[ "Signal", "with", "sinusoidal", "frequency", "modulation", "." ]
python
train
34.953488
matthieugouel/gibica
gibica/interpreter.py
https://github.com/matthieugouel/gibica/blob/65f937f7a6255078cc22eb7691a2897466032909/gibica/interpreter.py#L73-L85
def visit_FunctionBody(self, node): """Visitor for `FunctionBody` AST node.""" for child in node.children: return_value = self.visit(child) if isinstance(child, ReturnStatement): return return_value if isinstance(child, (IfStatement, WhileStatement))...
[ "def", "visit_FunctionBody", "(", "self", ",", "node", ")", ":", "for", "child", "in", "node", ".", "children", ":", "return_value", "=", "self", ".", "visit", "(", "child", ")", "if", "isinstance", "(", "child", ",", "ReturnStatement", ")", ":", "return...
Visitor for `FunctionBody` AST node.
[ "Visitor", "for", "FunctionBody", "AST", "node", "." ]
python
train
32.384615
casacore/python-casacore
casacore/images/image.py
https://github.com/casacore/python-casacore/blob/975510861ea005f7919dd9e438b5f98a1682eebe/casacore/images/image.py#L354-L375
def putmask(self, value, blc=(), trc=(), inc=()): """Put image mask. Using the arguments blc (bottom left corner), trc (top right corner), and inc (stride) it is possible to put a data slice. Not all axes need to be specified. Missing values default to begin, end, and 1. The da...
[ "def", "putmask", "(", "self", ",", "value", ",", "blc", "=", "(", ")", ",", "trc", "=", "(", ")", ",", "inc", "=", "(", ")", ")", ":", "# casa and numpy have opposite flags", "return", "self", ".", "_putmask", "(", "~", "value", ",", "self", ".", ...
Put image mask. Using the arguments blc (bottom left corner), trc (top right corner), and inc (stride) it is possible to put a data slice. Not all axes need to be specified. Missing values default to begin, end, and 1. The data should be a numpy array. Its dimensionality must be the sa...
[ "Put", "image", "mask", "." ]
python
train
46.545455