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
thelabnyc/wagtail_blog
blog/utils.py
https://github.com/thelabnyc/wagtail_blog/blob/7e092c02d10ec427c9a2c4b5dcbe910d88c628cf/blog/utils.py#L6-L48
def unique_slugify(instance, value, slug_field_name='slug', queryset=None, slug_separator='-'): """ Calculates and stores a unique slug of ``value`` for an instance. ``slug_field_name`` should be a string matching the name of the field to store the slug in (and the field to check aga...
[ "def", "unique_slugify", "(", "instance", ",", "value", ",", "slug_field_name", "=", "'slug'", ",", "queryset", "=", "None", ",", "slug_separator", "=", "'-'", ")", ":", "slug_field", "=", "instance", ".", "_meta", ".", "get_field", "(", "slug_field_name", "...
Calculates and stores a unique slug of ``value`` for an instance. ``slug_field_name`` should be a string matching the name of the field to store the slug in (and the field to check against for uniqueness). ``queryset`` usually doesn't need to be explicitly provided - it'll default to using the ``.all(...
[ "Calculates", "and", "stores", "a", "unique", "slug", "of", "value", "for", "an", "instance", "." ]
python
train
37.325581
square/pylink
setup.py
https://github.com/square/pylink/blob/81dda0a191d923a8b2627c52cb778aba24d279d7/setup.py#L70-L89
def run(self): """Runs the command. Args: self (CleanCommand): the ``CleanCommand`` instance Returns: ``None`` """ for build_dir in self.build_dirs: if os.path.isdir(build_dir): sys.stdout.write('Removing %s%s' % (build_dir, os.li...
[ "def", "run", "(", "self", ")", ":", "for", "build_dir", "in", "self", ".", "build_dirs", ":", "if", "os", ".", "path", ".", "isdir", "(", "build_dir", ")", ":", "sys", ".", "stdout", ".", "write", "(", "'Removing %s%s'", "%", "(", "build_dir", ",", ...
Runs the command. Args: self (CleanCommand): the ``CleanCommand`` instance Returns: ``None``
[ "Runs", "the", "command", "." ]
python
train
34.3
klen/python-scss
scss/tool.py
https://github.com/klen/python-scss/blob/34fe985e6b43caa9f9b9bcd0dc433be4b2a1fdec/scss/tool.py#L16-L23
def complete(text, state): """ Auto complete scss constructions in interactive mode. """ for cmd in COMMANDS: if cmd.startswith(text): if not state: return cmd else: state -= 1
[ "def", "complete", "(", "text", ",", "state", ")", ":", "for", "cmd", "in", "COMMANDS", ":", "if", "cmd", ".", "startswith", "(", "text", ")", ":", "if", "not", "state", ":", "return", "cmd", "else", ":", "state", "-=", "1" ]
Auto complete scss constructions in interactive mode.
[ "Auto", "complete", "scss", "constructions", "in", "interactive", "mode", "." ]
python
train
30.125
bitesofcode/projexui
projexui/widgets/xnodewidget/xnode.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xnodewidget/xnode.py#L345-L357
def clearConnections( self, cls ): """ Clears all the connections for this node. :param cls | <subclass of XNodeConnection> || None :return <int> | number of connections removed """ count = 0 for connection in self.connections(cls): ...
[ "def", "clearConnections", "(", "self", ",", "cls", ")", ":", "count", "=", "0", "for", "connection", "in", "self", ".", "connections", "(", "cls", ")", ":", "connection", ".", "remove", "(", ")", "count", "+=", "1", "return", "count" ]
Clears all the connections for this node. :param cls | <subclass of XNodeConnection> || None :return <int> | number of connections removed
[ "Clears", "all", "the", "connections", "for", "this", "node", ".", ":", "param", "cls", "|", "<subclass", "of", "XNodeConnection", ">", "||", "None", ":", "return", "<int", ">", "|", "number", "of", "connections", "removed" ]
python
train
29.153846
mitsei/dlkit
dlkit/json_/learning/sessions.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/learning/sessions.py#L3570-L3591
def get_objective_bank_ids_by_activity(self, activity_id): """Gets the list of ``ObjectiveBank Ids`` mapped to a ``Activity``. arg: activity_id (osid.id.Id): ``Id`` of a ``Activity`` return: (osid.id.IdList) - list of objective bank ``Ids`` raise: NotFound - ``activity_id`` is not f...
[ "def", "get_objective_bank_ids_by_activity", "(", "self", ",", "activity_id", ")", ":", "# Implemented from template for", "# osid.resource.ResourceBinSession.get_bin_ids_by_resource", "mgr", "=", "self", ".", "_get_provider_manager", "(", "'LEARNING'", ",", "local", "=", "Tr...
Gets the list of ``ObjectiveBank Ids`` mapped to a ``Activity``. arg: activity_id (osid.id.Id): ``Id`` of a ``Activity`` return: (osid.id.IdList) - list of objective bank ``Ids`` raise: NotFound - ``activity_id`` is not found raise: NullArgument - ``activity_id`` is ``null`` ...
[ "Gets", "the", "list", "of", "ObjectiveBank", "Ids", "mapped", "to", "a", "Activity", "." ]
python
train
49.318182
totalgood/twip
docs/notebooks/shakescorpus.py
https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/docs/notebooks/shakescorpus.py#L65-L123
def segment_shakespeare_works(input_file=PATH_SHAKESPEARE, verbose=False): """Find start and end of each volume within _Complete Works of William Shakespeare_ """ works = [{}] meta = {} j = 0 for i, line in enumerate(generate_lines(input_file=input_file)): if 'title' not in meta: ...
[ "def", "segment_shakespeare_works", "(", "input_file", "=", "PATH_SHAKESPEARE", ",", "verbose", "=", "False", ")", ":", "works", "=", "[", "{", "}", "]", "meta", "=", "{", "}", "j", "=", "0", "for", "i", ",", "line", "in", "enumerate", "(", "generate_l...
Find start and end of each volume within _Complete Works of William Shakespeare_
[ "Find", "start", "and", "end", "of", "each", "volume", "within", "_Complete", "Works", "of", "William", "Shakespeare_" ]
python
train
39.542373
EntilZha/PyFunctional
functional/util.py
https://github.com/EntilZha/PyFunctional/blob/ac04e4a8552b0c464a7f492f7c9862424867b63e/functional/util.py#L179-L191
def compute_partition_size(result, processes): """ Attempts to compute the partition size to evenly distribute work across processes. Defaults to 1 if the length of result cannot be determined. :param result: Result to compute on :param processes: Number of processes to use :return: Best partit...
[ "def", "compute_partition_size", "(", "result", ",", "processes", ")", ":", "try", ":", "return", "max", "(", "math", ".", "ceil", "(", "len", "(", "result", ")", "/", "processes", ")", ",", "1", ")", "except", "TypeError", ":", "return", "1" ]
Attempts to compute the partition size to evenly distribute work across processes. Defaults to 1 if the length of result cannot be determined. :param result: Result to compute on :param processes: Number of processes to use :return: Best partition size
[ "Attempts", "to", "compute", "the", "partition", "size", "to", "evenly", "distribute", "work", "across", "processes", ".", "Defaults", "to", "1", "if", "the", "length", "of", "result", "cannot", "be", "determined", "." ]
python
train
33.076923
evhub/coconut
coconut/compiler/matching.py
https://github.com/evhub/coconut/blob/ff97177344e7604e89a0a98a977a87ed2a56fc6d/coconut/compiler/matching.py#L478-L495
def match_msequence(self, tokens, item): """Matches a middle sequence.""" series_type, head_matches, middle, _, last_matches = tokens self.add_check("_coconut.isinstance(" + item + ", _coconut.abc.Sequence)") self.add_check("_coconut.len(" + item + ") >= " + str(len(head_matches) + len(l...
[ "def", "match_msequence", "(", "self", ",", "tokens", ",", "item", ")", ":", "series_type", ",", "head_matches", ",", "middle", ",", "_", ",", "last_matches", "=", "tokens", "self", ".", "add_check", "(", "\"_coconut.isinstance(\"", "+", "item", "+", "\", _c...
Matches a middle sequence.
[ "Matches", "a", "middle", "sequence", "." ]
python
train
54.388889
vpelletier/python-functionfs
functionfs/__init__.py
https://github.com/vpelletier/python-functionfs/blob/e19f729bb47a7d1edd2488531af24551bb86726f/functionfs/__init__.py#L800-L807
def close(self): """ Close all endpoint file descriptors. """ ep_list = self._ep_list while ep_list: ep_list.pop().close() self._closed = True
[ "def", "close", "(", "self", ")", ":", "ep_list", "=", "self", ".", "_ep_list", "while", "ep_list", ":", "ep_list", ".", "pop", "(", ")", ".", "close", "(", ")", "self", ".", "_closed", "=", "True" ]
Close all endpoint file descriptors.
[ "Close", "all", "endpoint", "file", "descriptors", "." ]
python
train
24.375
joeblackwaslike/pricing
pricing/price.py
https://github.com/joeblackwaslike/pricing/blob/be988b0851b4313af81f1db475bc33248700e39c/pricing/price.py#L36-L43
def amount_converter(obj): """Converts amount value from several types into Decimal.""" if isinstance(obj, Decimal): return obj elif isinstance(obj, (str, int, float)): return Decimal(str(obj)) else: raise ValueError('do not know how to convert: {}'.format(type(obj)))
[ "def", "amount_converter", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "Decimal", ")", ":", "return", "obj", "elif", "isinstance", "(", "obj", ",", "(", "str", ",", "int", ",", "float", ")", ")", ":", "return", "Decimal", "(", "str", ...
Converts amount value from several types into Decimal.
[ "Converts", "amount", "value", "from", "several", "types", "into", "Decimal", "." ]
python
test
37.625
axialmarket/fsq
fsq/install.py
https://github.com/axialmarket/fsq/blob/43b84c292cb8a187599d86753b947cf73248f989/fsq/install.py#L173-L232
def install_host(trg_queue, *hosts, **kwargs): ''' Atomically install host queues ''' user = kwargs.pop('user', None) group = kwargs.pop('group', None) mode = kwargs.pop('mode', None) item_user = kwargs.pop('item_user', None) item_group = kwargs.pop('item_group', None) item_mode = kwargs.pop...
[ "def", "install_host", "(", "trg_queue", ",", "*", "hosts", ",", "*", "*", "kwargs", ")", ":", "user", "=", "kwargs", ".", "pop", "(", "'user'", ",", "None", ")", "group", "=", "kwargs", ".", "pop", "(", "'group'", ",", "None", ")", "mode", "=", ...
Atomically install host queues
[ "Atomically", "install", "host", "queues" ]
python
train
43.866667
turbidsoul/tsutil
tsutil/util.py
https://github.com/turbidsoul/tsutil/blob/2c86d872791edc0f17f2c48b6f15d5c79b4551f7/tsutil/util.py#L89-L95
def get_week_start_end_day(): """ Get the week start date and end date """ t = date.today() wd = t.weekday() return (t - timedelta(wd), t + timedelta(6 - wd))
[ "def", "get_week_start_end_day", "(", ")", ":", "t", "=", "date", ".", "today", "(", ")", "wd", "=", "t", ".", "weekday", "(", ")", "return", "(", "t", "-", "timedelta", "(", "wd", ")", ",", "t", "+", "timedelta", "(", "6", "-", "wd", ")", ")" ...
Get the week start date and end date
[ "Get", "the", "week", "start", "date", "and", "end", "date" ]
python
train
25.142857
mopidy/mopidy-spotify
mopidy_spotify/translator.py
https://github.com/mopidy/mopidy-spotify/blob/77a293088e63a7b4b77bf9409ce57cb14048d18c/mopidy_spotify/translator.py#L205-L225
def sp_search_query(query): """Translate a Mopidy search query to a Spotify search query""" result = [] for (field, values) in query.items(): field = SEARCH_FIELD_MAP.get(field, field) if field is None: continue for value in values: if field == 'year': ...
[ "def", "sp_search_query", "(", "query", ")", ":", "result", "=", "[", "]", "for", "(", "field", ",", "values", ")", "in", "query", ".", "items", "(", ")", ":", "field", "=", "SEARCH_FIELD_MAP", ".", "get", "(", "field", ",", "field", ")", "if", "fi...
Translate a Mopidy search query to a Spotify search query
[ "Translate", "a", "Mopidy", "search", "query", "to", "a", "Spotify", "search", "query" ]
python
test
29.714286
gofed/gofedlib
gofedlib/providers/upstreamprovider.py
https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/providers/upstreamprovider.py#L147-L194
def parseGopkgImportPath(self, path): """ Definition: gopkg.in/<v>/<repo> || gopkg.in/<repo>.<v> || gopkg.in/<project>/<repo> """ parts = path.split('/') if re.match('v[0-9]+', parts[1]): if len(parts) < 3: raise ValueError("Import path %s is not in gopkg.in/<v>/<repo> form" % path) project = "" ...
[ "def", "parseGopkgImportPath", "(", "self", ",", "path", ")", ":", "parts", "=", "path", ".", "split", "(", "'/'", ")", "if", "re", ".", "match", "(", "'v[0-9]+'", ",", "parts", "[", "1", "]", ")", ":", "if", "len", "(", "parts", ")", "<", "3", ...
Definition: gopkg.in/<v>/<repo> || gopkg.in/<repo>.<v> || gopkg.in/<project>/<repo>
[ "Definition", ":", "gopkg", ".", "in", "/", "<v", ">", "/", "<repo", ">", "||", "gopkg", ".", "in", "/", "<repo", ">", ".", "<v", ">", "||", "gopkg", ".", "in", "/", "<project", ">", "/", "<repo", ">" ]
python
train
30.0625
CiscoDevNet/webexteamssdk
webexteamssdk/restsession.py
https://github.com/CiscoDevNet/webexteamssdk/blob/6fc2cc3557e080ba4b2a380664cb2a0532ae45cd/webexteamssdk/restsession.py#L217-L262
def request(self, method, url, erc, **kwargs): """Abstract base method for making requests to the Webex Teams APIs. This base method: * Expands the API endpoint URL to an absolute URL * Makes the actual HTTP request to the API endpoint * Provides support for Webex Te...
[ "def", "request", "(", "self", ",", "method", ",", "url", ",", "erc", ",", "*", "*", "kwargs", ")", ":", "# Ensure the url is an absolute URL", "abs_url", "=", "self", ".", "abs_url", "(", "url", ")", "# Update request kwargs with session defaults", "kwargs", "....
Abstract base method for making requests to the Webex Teams APIs. This base method: * Expands the API endpoint URL to an absolute URL * Makes the actual HTTP request to the API endpoint * Provides support for Webex Teams rate-limiting * Inspects response codes an...
[ "Abstract", "base", "method", "for", "making", "requests", "to", "the", "Webex", "Teams", "APIs", "." ]
python
test
40.608696
pip-services3-python/pip-services3-commons-python
pip_services3_commons/commands/CommandSet.py
https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/commands/CommandSet.py#L273-L286
def notify(self, correlation_id, event, value): """ Fires event specified by its name and notifies all registered IEventListener listeners :param correlation_id: (optional) transaction id to trace execution through call chain. :param event: the name of the event that is to be f...
[ "def", "notify", "(", "self", ",", "correlation_id", ",", "event", ",", "value", ")", ":", "e", "=", "self", ".", "find_event", "(", "event", ")", "if", "e", "!=", "None", ":", "e", ".", "notify", "(", "correlation_id", ",", "value", ")" ]
Fires event specified by its name and notifies all registered IEventListener listeners :param correlation_id: (optional) transaction id to trace execution through call chain. :param event: the name of the event that is to be fired. :param value: the event arguments (parameters).
[ "Fires", "event", "specified", "by", "its", "name", "and", "notifies", "all", "registered", "IEventListener", "listeners" ]
python
train
34.428571
ga4gh/ga4gh-server
ga4gh/server/backend.py
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/backend.py#L568-L575
def runGetRequest(self, obj): """ Runs a get request by converting the specified datamodel object into its protocol representation. """ protocolElement = obj.toProtocolElement() jsonString = protocol.toJson(protocolElement) return jsonString
[ "def", "runGetRequest", "(", "self", ",", "obj", ")", ":", "protocolElement", "=", "obj", ".", "toProtocolElement", "(", ")", "jsonString", "=", "protocol", ".", "toJson", "(", "protocolElement", ")", "return", "jsonString" ]
Runs a get request by converting the specified datamodel object into its protocol representation.
[ "Runs", "a", "get", "request", "by", "converting", "the", "specified", "datamodel", "object", "into", "its", "protocol", "representation", "." ]
python
train
36.25
influxdata/influxdb-python
examples/tutorial_pandas.py
https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/examples/tutorial_pandas.py#L10-L38
def main(host='localhost', port=8086): """Instantiate the connection to the InfluxDB client.""" user = 'root' password = 'root' dbname = 'demo' protocol = 'json' client = DataFrameClient(host, port, user, password, dbname) print("Create pandas DataFrame") df = pd.DataFrame(data=list(ra...
[ "def", "main", "(", "host", "=", "'localhost'", ",", "port", "=", "8086", ")", ":", "user", "=", "'root'", "password", "=", "'root'", "dbname", "=", "'demo'", "protocol", "=", "'json'", "client", "=", "DataFrameClient", "(", "host", ",", "port", ",", "...
Instantiate the connection to the InfluxDB client.
[ "Instantiate", "the", "connection", "to", "the", "InfluxDB", "client", "." ]
python
train
30.724138
openvax/mhcnames
mhcnames/class2.py
https://github.com/openvax/mhcnames/blob/71694b9d620db68ceee44da1b8422ff436f15bd3/mhcnames/class2.py#L42-L83
def parse_classi_or_classii_allele_name(name, infer_pair=True): """ Handle different forms of both single and alpha-beta allele names. Alpha-beta alleles may look like: DPA10105-DPB110001 HLA-DPA1*01:05-DPB1*100:01 hla-dpa1*0105-dpb1*10001 dpa1*0105-dpb1*10001 HLA-DPA1*01:05/DPB1*100:01...
[ "def", "parse_classi_or_classii_allele_name", "(", "name", ",", "infer_pair", "=", "True", ")", ":", "species", ",", "name", "=", "split_species_prefix", "(", "name", ")", "# Handle the case where alpha/beta pairs are separated with a /.", "name", "=", "name", ".", "rep...
Handle different forms of both single and alpha-beta allele names. Alpha-beta alleles may look like: DPA10105-DPB110001 HLA-DPA1*01:05-DPB1*100:01 hla-dpa1*0105-dpb1*10001 dpa1*0105-dpb1*10001 HLA-DPA1*01:05/DPB1*100:01 Other class II alleles may look like: DRB1_0102 DRB101:02 ...
[ "Handle", "different", "forms", "of", "both", "single", "and", "alpha", "-", "beta", "allele", "names", ".", "Alpha", "-", "beta", "alleles", "may", "look", "like", ":" ]
python
train
28.5
onnx/onnxmltools
onnxmltools/convert/coreml/shape_calculators/FeatureVectorizer.py
https://github.com/onnx/onnxmltools/blob/d4e4c31990fc2d9fd1f92139f497d360914c9df2/onnxmltools/convert/coreml/shape_calculators/FeatureVectorizer.py#L12-L46
def calculate_feature_vectorizer_output_shapes(operator): ''' Allowed input/output patterns are 1. [N, C_1], ..., [N, C_n] ---> [N, C_1 + ... + C_n] Feature vectorizer concatenates all input tensors along the C-axis, so the output dimension along C-axis is simply a sum of all input features. ...
[ "def", "calculate_feature_vectorizer_output_shapes", "(", "operator", ")", ":", "check_input_and_output_numbers", "(", "operator", ",", "input_count_range", "=", "[", "1", ",", "None", "]", ",", "output_count_range", "=", "1", ")", "check_input_and_output_types", "(", ...
Allowed input/output patterns are 1. [N, C_1], ..., [N, C_n] ---> [N, C_1 + ... + C_n] Feature vectorizer concatenates all input tensors along the C-axis, so the output dimension along C-axis is simply a sum of all input features.
[ "Allowed", "input", "/", "output", "patterns", "are", "1", ".", "[", "N", "C_1", "]", "...", "[", "N", "C_n", "]", "---", ">", "[", "N", "C_1", "+", "...", "+", "C_n", "]" ]
python
train
53.085714
andymccurdy/redis-py
redis/connection.py
https://github.com/andymccurdy/redis-py/blob/cdfe2befbe00db4a3c48c9ddd6d64dea15f6f0db/redis/connection.py#L1019-L1024
def make_connection(self): "Create a new connection" if self._created_connections >= self.max_connections: raise ConnectionError("Too many connections") self._created_connections += 1 return self.connection_class(**self.connection_kwargs)
[ "def", "make_connection", "(", "self", ")", ":", "if", "self", ".", "_created_connections", ">=", "self", ".", "max_connections", ":", "raise", "ConnectionError", "(", "\"Too many connections\"", ")", "self", ".", "_created_connections", "+=", "1", "return", "self...
Create a new connection
[ "Create", "a", "new", "connection" ]
python
train
46.166667
PonteIneptique/collatinus-python
pycollatinus/lemme.py
https://github.com/PonteIneptique/collatinus-python/blob/fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5/pycollatinus/lemme.py#L177-L196
def genre(self): """ Cette routine convertit les indications morphologiques, données dans le fichier lemmes.la, pour exprimer le genre du mot dans la langue courante. :return: Genre :rtype: str """ _genre = "" if " m." in self._indMorph: _genre += "m" ...
[ "def", "genre", "(", "self", ")", ":", "_genre", "=", "\"\"", "if", "\" m.\"", "in", "self", ".", "_indMorph", ":", "_genre", "+=", "\"m\"", "if", "\" f.\"", "in", "self", ".", "_indMorph", ":", "_genre", "+=", "\"f\"", "if", "\" n.\"", "in", "self", ...
Cette routine convertit les indications morphologiques, données dans le fichier lemmes.la, pour exprimer le genre du mot dans la langue courante. :return: Genre :rtype: str
[ "Cette", "routine", "convertit", "les", "indications", "morphologiques", "données", "dans", "le", "fichier", "lemmes", ".", "la", "pour", "exprimer", "le", "genre", "du", "mot", "dans", "la", "langue", "courante", "." ]
python
train
31
materialsproject/pymatgen
pymatgen/alchemy/materials.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/alchemy/materials.py#L204-L221
def write_vasp_input(self, vasp_input_set=MPRelaxSet, output_dir=".", create_directory=True, **kwargs): """ Writes VASP input to an output_dir. Args: vasp_input_set: pymatgen.io.vaspio_set.VaspInputSet like object that creates ...
[ "def", "write_vasp_input", "(", "self", ",", "vasp_input_set", "=", "MPRelaxSet", ",", "output_dir", "=", "\".\"", ",", "create_directory", "=", "True", ",", "*", "*", "kwargs", ")", ":", "vasp_input_set", "(", "self", ".", "final_structure", ",", "*", "*", ...
Writes VASP input to an output_dir. Args: vasp_input_set: pymatgen.io.vaspio_set.VaspInputSet like object that creates vasp input files from structures output_dir: Directory to output files create_directory: Create the directory if not present...
[ "Writes", "VASP", "input", "to", "an", "output_dir", "." ]
python
train
46.166667
chrippa/ds4drv
ds4drv/device.py
https://github.com/chrippa/ds4drv/blob/be7327fc3f5abb8717815f2a1a2ad3d335535d8a/ds4drv/device.py#L95-L98
def set_led(self, red=0, green=0, blue=0): """Sets the LED color. Values are RGB between 0-255.""" self._led = (red, green, blue) self._control()
[ "def", "set_led", "(", "self", ",", "red", "=", "0", ",", "green", "=", "0", ",", "blue", "=", "0", ")", ":", "self", ".", "_led", "=", "(", "red", ",", "green", ",", "blue", ")", "self", ".", "_control", "(", ")" ]
Sets the LED color. Values are RGB between 0-255.
[ "Sets", "the", "LED", "color", ".", "Values", "are", "RGB", "between", "0", "-", "255", "." ]
python
train
41.5
KelSolaar/Foundations
foundations/environment.py
https://github.com/KelSolaar/Foundations/blob/5c141330faf09dad70a12bc321f4c564917d0a91/foundations/environment.py#L90-L105
def variables(self, value): """ Setter for **self.__variables** attribute. :param value: Attribute value. :type value: dict """ if value is not None: assert type(value) is dict, "'{0}' attribute: '{1}' type is not 'dict'!".format("variables", value) ...
[ "def", "variables", "(", "self", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "assert", "type", "(", "value", ")", "is", "dict", ",", "\"'{0}' attribute: '{1}' type is not 'dict'!\"", ".", "format", "(", "\"variables\"", ",", "value", ")"...
Setter for **self.__variables** attribute. :param value: Attribute value. :type value: dict
[ "Setter", "for", "**", "self", ".", "__variables", "**", "attribute", "." ]
python
train
41.625
niklasf/python-chess
chess/gaviota.py
https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/gaviota.py#L1641-L1674
def probe_wdl(self, board: chess.Board) -> int: """ Probes for win/draw/loss-information. Returns ``1`` if the side to move is winning, ``0`` if it is a draw, and ``-1`` if the side to move is losing. >>> import chess >>> import chess.gaviota >>> >>> wit...
[ "def", "probe_wdl", "(", "self", ",", "board", ":", "chess", ".", "Board", ")", "->", "int", ":", "dtm", "=", "self", ".", "probe_dtm", "(", "board", ")", "if", "dtm", "==", "0", ":", "if", "board", ".", "is_checkmate", "(", ")", ":", "return", "...
Probes for win/draw/loss-information. Returns ``1`` if the side to move is winning, ``0`` if it is a draw, and ``-1`` if the side to move is losing. >>> import chess >>> import chess.gaviota >>> >>> with chess.gaviota.open_tablebase("data/gaviota") as tablebase: ...
[ "Probes", "for", "win", "/", "draw", "/", "loss", "-", "information", "." ]
python
train
31.647059
limodou/uliweb
uliweb/lib/werkzeug/wrappers.py
https://github.com/limodou/uliweb/blob/34472f25e4bc0b954a35346672f94e84ef18b076/uliweb/lib/werkzeug/wrappers.py#L836-L853
def get_data(self, as_text=False): """The string representation of the request body. Whenever you call this property the request iterable is encoded and flattened. This can lead to unwanted behavior if you stream big data. This behavior can be disabled by setting :attr:`implic...
[ "def", "get_data", "(", "self", ",", "as_text", "=", "False", ")", ":", "self", ".", "_ensure_sequence", "(", ")", "rv", "=", "b''", ".", "join", "(", "self", ".", "iter_encoded", "(", ")", ")", "if", "as_text", ":", "rv", "=", "rv", ".", "decode",...
The string representation of the request body. Whenever you call this property the request iterable is encoded and flattened. This can lead to unwanted behavior if you stream big data. This behavior can be disabled by setting :attr:`implicit_sequence_conversion` to `False`. I...
[ "The", "string", "representation", "of", "the", "request", "body", ".", "Whenever", "you", "call", "this", "property", "the", "request", "iterable", "is", "encoded", "and", "flattened", ".", "This", "can", "lead", "to", "unwanted", "behavior", "if", "you", "...
python
train
35.166667
vertexproject/synapse
synapse/cortex.py
https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/cortex.py#L1570-L1580
async def eval(self, text, opts=None, user=None): ''' Evaluate a storm query and yield Nodes only. ''' if user is None: user = self.auth.getUserByName('root') await self.boss.promote('storm', user=user, info={'query': text}) async with await self.snap(user=us...
[ "async", "def", "eval", "(", "self", ",", "text", ",", "opts", "=", "None", ",", "user", "=", "None", ")", ":", "if", "user", "is", "None", ":", "user", "=", "self", ".", "auth", ".", "getUserByName", "(", "'root'", ")", "await", "self", ".", "bo...
Evaluate a storm query and yield Nodes only.
[ "Evaluate", "a", "storm", "query", "and", "yield", "Nodes", "only", "." ]
python
train
38
thombashi/pytablereader
pytablereader/spreadsheet/excelloader.py
https://github.com/thombashi/pytablereader/blob/bc3c057a2cc775bcce690e0e9019c2907b638101/pytablereader/spreadsheet/excelloader.py#L59-L122
def load(self): """ Extract tabular data as |TableData| instances from an Excel file. |spreadsheet_load_desc| :return: Loaded |TableData| iterator. |TableData| created for each sheet in the workbook. |load_table_name_desc| ===============...
[ "def", "load", "(", "self", ")", ":", "import", "xlrd", "self", ".", "_validate", "(", ")", "self", ".", "_logger", ".", "logging_load", "(", ")", "try", ":", "workbook", "=", "xlrd", ".", "open_workbook", "(", "self", ".", "source", ")", "except", "...
Extract tabular data as |TableData| instances from an Excel file. |spreadsheet_load_desc| :return: Loaded |TableData| iterator. |TableData| created for each sheet in the workbook. |load_table_name_desc| =================== ==============================...
[ "Extract", "tabular", "data", "as", "|TableData|", "instances", "from", "an", "Excel", "file", ".", "|spreadsheet_load_desc|" ]
python
train
31.71875
lrq3000/pyFileFixity
pyFileFixity/lib/profilers/visual/memory_profiler.py
https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/memory_profiler.py#L177-L190
def add_function(self, func): """ Record line profiling information for the given Python function. """ try: # func_code does not exist in Python3 code = func.__code__ except AttributeError: import warnings warnings.warn("Could not extract a...
[ "def", "add_function", "(", "self", ",", "func", ")", ":", "try", ":", "# func_code does not exist in Python3", "code", "=", "func", ".", "__code__", "except", "AttributeError", ":", "import", "warnings", "warnings", ".", "warn", "(", "\"Could not extract a code obj...
Record line profiling information for the given Python function.
[ "Record", "line", "profiling", "information", "for", "the", "given", "Python", "function", "." ]
python
train
36.357143
bcbio/bcbio-nextgen
bcbio/upload/__init__.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/upload/__init__.py#L408-L420
def _flatten_file_with_secondary(input, out_dir): """Flatten file representation with secondary indices (CWL-like) """ out = [] orig_dir = os.path.dirname(input["base"]) for finfo in [input["base"]] + input.get("secondary", []): cur_dir = os.path.dirname(finfo) if cur_dir != orig_dir...
[ "def", "_flatten_file_with_secondary", "(", "input", ",", "out_dir", ")", ":", "out", "=", "[", "]", "orig_dir", "=", "os", ".", "path", ".", "dirname", "(", "input", "[", "\"base\"", "]", ")", "for", "finfo", "in", "[", "input", "[", "\"base\"", "]", ...
Flatten file representation with secondary indices (CWL-like)
[ "Flatten", "file", "representation", "with", "secondary", "indices", "(", "CWL", "-", "like", ")" ]
python
train
42
maas/python-libmaas
maas/client/flesh/machines.py
https://github.com/maas/python-libmaas/blob/4092c68ef7fb1753efc843569848e2bcc3415002/maas/client/flesh/machines.py#L353-L373
def get_machines(self, origin, hostnames): """Return a set of machines based on `hostnames`. Any hostname that is not found will result in an error. """ hostnames = { hostname: True for hostname in hostnames } machines = origin.Machines.read(hostn...
[ "def", "get_machines", "(", "self", ",", "origin", ",", "hostnames", ")", ":", "hostnames", "=", "{", "hostname", ":", "True", "for", "hostname", "in", "hostnames", "}", "machines", "=", "origin", ".", "Machines", ".", "read", "(", "hostnames", "=", "hos...
Return a set of machines based on `hostnames`. Any hostname that is not found will result in an error.
[ "Return", "a", "set", "of", "machines", "based", "on", "hostnames", "." ]
python
train
33.238095
librosa/librosa
librosa/sequence.py
https://github.com/librosa/librosa/blob/180e8e6eb8f958fa6b20b8cba389f7945d508247/librosa/sequence.py#L238-L302
def __dtw_calc_accu_cost(C, D, D_steps, step_sizes_sigma, weights_mul, weights_add, max_0, max_1): # pragma: no cover '''Calculate the accumulated cost matrix D. Use dynamic programming to calculate the accumulated costs. Parameters ---------- C : np.ndarray [shape=(N, M)...
[ "def", "__dtw_calc_accu_cost", "(", "C", ",", "D", ",", "D_steps", ",", "step_sizes_sigma", ",", "weights_mul", ",", "weights_add", ",", "max_0", ",", "max_1", ")", ":", "# pragma: no cover", "for", "cur_n", "in", "range", "(", "max_0", ",", "D", ".", "sha...
Calculate the accumulated cost matrix D. Use dynamic programming to calculate the accumulated costs. Parameters ---------- C : np.ndarray [shape=(N, M)] pre-computed cost matrix D : np.ndarray [shape=(N, M)] accumulated cost matrix D_steps : np.ndarray [shape=(N, M)] ...
[ "Calculate", "the", "accumulated", "cost", "matrix", "D", "." ]
python
test
32.707692
google/apitools
apitools/base/py/transfer.py
https://github.com/google/apitools/blob/f3745a7ea535aa0e88b0650c16479b696d6fd446/apitools/base/py/transfer.py#L744-L787
def ConfigureRequest(self, upload_config, http_request, url_builder): """Configure the request and url for this upload.""" # Validate total_size vs. max_size if (self.total_size and upload_config.max_size and self.total_size > upload_config.max_size): raise exceptions...
[ "def", "ConfigureRequest", "(", "self", ",", "upload_config", ",", "http_request", ",", "url_builder", ")", ":", "# Validate total_size vs. max_size", "if", "(", "self", ".", "total_size", "and", "upload_config", ".", "max_size", "and", "self", ".", "total_size", ...
Configure the request and url for this upload.
[ "Configure", "the", "request", "and", "url", "for", "this", "upload", "." ]
python
train
57.113636
lesscpy/lesscpy
lesscpy/lessc/scope.py
https://github.com/lesscpy/lesscpy/blob/51e392fb4a3cd4ccfb6175e0e42ce7d2f6b78126/lesscpy/lessc/scope.py#L141-L159
def _blocks(self, name): """Inner wrapper to search for blocks by name. """ i = len(self) while i >= 0: i -= 1 if name in self[i]['__names__']: for b in self[i]['__blocks__']: r = b.raw() if r and r == name: ...
[ "def", "_blocks", "(", "self", ",", "name", ")", ":", "i", "=", "len", "(", "self", ")", "while", "i", ">=", "0", ":", "i", "-=", "1", "if", "name", "in", "self", "[", "i", "]", "[", "'__names__'", "]", ":", "for", "b", "in", "self", "[", "...
Inner wrapper to search for blocks by name.
[ "Inner", "wrapper", "to", "search", "for", "blocks", "by", "name", "." ]
python
valid
32.947368
MoseleyBioinformaticsLab/mwtab
mwtab/validator.py
https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/validator.py#L19-L44
def _validate_samples_factors(mwtabfile, validate_samples=True, validate_factors=True): """Validate ``Samples`` and ``Factors`` identifiers across the file. :param mwtabfile: Instance of :class:`~mwtab.mwtab.MWTabFile`. :type mwtabfile: :class:`~mwtab.mwtab.MWTabFile` :return: None :rtype: :py:obj:...
[ "def", "_validate_samples_factors", "(", "mwtabfile", ",", "validate_samples", "=", "True", ",", "validate_factors", "=", "True", ")", ":", "from_subject_samples", "=", "{", "i", "[", "\"local_sample_id\"", "]", "for", "i", "in", "mwtabfile", "[", "\"SUBJECT_SAMPL...
Validate ``Samples`` and ``Factors`` identifiers across the file. :param mwtabfile: Instance of :class:`~mwtab.mwtab.MWTabFile`. :type mwtabfile: :class:`~mwtab.mwtab.MWTabFile` :return: None :rtype: :py:obj:`None`
[ "Validate", "Samples", "and", "Factors", "identifiers", "across", "the", "file", "." ]
python
train
50.115385
IdentityPython/pyop
src/pyop/request_validator.py
https://github.com/IdentityPython/pyop/blob/7b1385964f079c39752fce5f2dbcf458b8a92e56/src/pyop/request_validator.py#L106-L115
def registration_request_verify(registration_request): """ Verifies that all required parameters and correct values are included in the client registration request. :param registration_request: the authentication request to verify :raise InvalidClientRegistrationRequest: if the registration is incorrect...
[ "def", "registration_request_verify", "(", "registration_request", ")", ":", "try", ":", "registration_request", ".", "verify", "(", ")", "except", "MessageException", "as", "e", ":", "raise", "InvalidClientRegistrationRequest", "(", "str", "(", "e", ")", ",", "re...
Verifies that all required parameters and correct values are included in the client registration request. :param registration_request: the authentication request to verify :raise InvalidClientRegistrationRequest: if the registration is incorrect
[ "Verifies", "that", "all", "required", "parameters", "and", "correct", "values", "are", "included", "in", "the", "client", "registration", "request", ".", ":", "param", "registration_request", ":", "the", "authentication", "request", "to", "verify", ":", "raise", ...
python
train
51.5
venthur/python-debianbts
debianbts/debianbts.py
https://github.com/venthur/python-debianbts/blob/72cf11ae3458a8544142e9f365aaafe25634dd4f/debianbts/debianbts.py#L524-L535
def _build_int_array_el(el_name, parent, list_): """build a soapenc:Array made of ints called `el_name` as a child of `parent`""" el = parent.add_child(el_name) el.add_attribute('xmlns:soapenc', 'http://schemas.xmlsoap.org/soap/encoding/') el.add_attribute('xsi:type', 'soapenc:A...
[ "def", "_build_int_array_el", "(", "el_name", ",", "parent", ",", "list_", ")", ":", "el", "=", "parent", ".", "add_child", "(", "el_name", ")", "el", ".", "add_attribute", "(", "'xmlns:soapenc'", ",", "'http://schemas.xmlsoap.org/soap/encoding/'", ")", "el", "....
build a soapenc:Array made of ints called `el_name` as a child of `parent`
[ "build", "a", "soapenc", ":", "Array", "made", "of", "ints", "called", "el_name", "as", "a", "child", "of", "parent" ]
python
train
44.416667
incuna/django-wkhtmltopdf
wkhtmltopdf/utils.py
https://github.com/incuna/django-wkhtmltopdf/blob/4e73f604c48f7f449c916c4257a72af59517322c/wkhtmltopdf/utils.py#L278-L308
def make_absolute_paths(content): """Convert all MEDIA files into a file://URL paths in order to correctly get it displayed in PDFs.""" overrides = [ { 'root': settings.MEDIA_ROOT, 'url': settings.MEDIA_URL, }, { 'root': settings.STATIC_ROOT, ...
[ "def", "make_absolute_paths", "(", "content", ")", ":", "overrides", "=", "[", "{", "'root'", ":", "settings", ".", "MEDIA_ROOT", ",", "'url'", ":", "settings", ".", "MEDIA_URL", ",", "}", ",", "{", "'root'", ":", "settings", ".", "STATIC_ROOT", ",", "'u...
Convert all MEDIA files into a file://URL paths in order to correctly get it displayed in PDFs.
[ "Convert", "all", "MEDIA", "files", "into", "a", "file", ":", "//", "URL", "paths", "in", "order", "to", "correctly", "get", "it", "displayed", "in", "PDFs", "." ]
python
test
31.032258
python-gitlab/python-gitlab
gitlab/v4/objects.py
https://github.com/python-gitlab/python-gitlab/blob/16de1b03fde3dbbe8f851614dd1d8c09de102fe5/gitlab/v4/objects.py#L1609-L1620
def stop(self, **kwargs): """Stop the environment. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabStopError: If the operation failed """ path = '%s/%s/...
[ "def", "stop", "(", "self", ",", "*", "*", "kwargs", ")", ":", "path", "=", "'%s/%s/stop'", "%", "(", "self", ".", "manager", ".", "path", ",", "self", ".", "get_id", "(", ")", ")", "self", ".", "manager", ".", "gitlab", ".", "http_post", "(", "p...
Stop the environment. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabStopError: If the operation failed
[ "Stop", "the", "environment", "." ]
python
train
33.75
kubernetes-client/python
kubernetes/client/models/v1alpha1_webhook_client_config.py
https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/models/v1alpha1_webhook_client_config.py#L74-L85
def ca_bundle(self, ca_bundle): """ Sets the ca_bundle of this V1alpha1WebhookClientConfig. `caBundle` is a PEM encoded CA bundle which will be used to validate the webhook's server certificate. If unspecified, system trust roots on the apiserver are used. :param ca_bundle: The ca_bundl...
[ "def", "ca_bundle", "(", "self", ",", "ca_bundle", ")", ":", "if", "ca_bundle", "is", "not", "None", "and", "not", "re", ".", "search", "(", "'^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\\/]{3}=)?$'", ",", "ca_bundle", ")", ":", "raise", "ValueError"...
Sets the ca_bundle of this V1alpha1WebhookClientConfig. `caBundle` is a PEM encoded CA bundle which will be used to validate the webhook's server certificate. If unspecified, system trust roots on the apiserver are used. :param ca_bundle: The ca_bundle of this V1alpha1WebhookClientConfig. :type...
[ "Sets", "the", "ca_bundle", "of", "this", "V1alpha1WebhookClientConfig", ".", "caBundle", "is", "a", "PEM", "encoded", "CA", "bundle", "which", "will", "be", "used", "to", "validate", "the", "webhook", "s", "server", "certificate", ".", "If", "unspecified", "s...
python
train
60.083333
openstax/cnx-epub
cnxepub/models.py
https://github.com/openstax/cnx-epub/blob/f648a309eff551b0a68a115a98ddf7858149a2ea/cnxepub/models.py#L204-L211
def _parse_references(xml): """Parse the references to ``Reference`` instances.""" references = [] ref_finder = HTMLReferenceFinder(xml) for elm, uri_attr in ref_finder: type_ = _discover_uri_type(elm.get(uri_attr)) references.append(Reference(elm, type_, uri_attr)) return references
[ "def", "_parse_references", "(", "xml", ")", ":", "references", "=", "[", "]", "ref_finder", "=", "HTMLReferenceFinder", "(", "xml", ")", "for", "elm", ",", "uri_attr", "in", "ref_finder", ":", "type_", "=", "_discover_uri_type", "(", "elm", ".", "get", "(...
Parse the references to ``Reference`` instances.
[ "Parse", "the", "references", "to", "Reference", "instances", "." ]
python
train
39.125
tanghaibao/goatools
goatools/gosubdag/rpt/wr_xlsx.py
https://github.com/tanghaibao/goatools/blob/407682e573a108864a79031f8ca19ee3bf377626/goatools/gosubdag/rpt/wr_xlsx.py#L51-L55
def get_nts_sections(self, sections, sortby=None): """Given a list of sections containing GO IDs, get a list of sections w/GO nts.""" goids = self.get_goids_sections(sections) gosubdag = GoSubDag(goids, self.go2obj) return [(sec, gosubdag.get_nts(gos, sortby)) for sec, gos in sections]
[ "def", "get_nts_sections", "(", "self", ",", "sections", ",", "sortby", "=", "None", ")", ":", "goids", "=", "self", ".", "get_goids_sections", "(", "sections", ")", "gosubdag", "=", "GoSubDag", "(", "goids", ",", "self", ".", "go2obj", ")", "return", "[...
Given a list of sections containing GO IDs, get a list of sections w/GO nts.
[ "Given", "a", "list", "of", "sections", "containing", "GO", "IDs", "get", "a", "list", "of", "sections", "w", "/", "GO", "nts", "." ]
python
train
62.8
edeposit/edeposit.amqp.aleph
src/edeposit/amqp/aleph/export.py
https://github.com/edeposit/edeposit.amqp.aleph/blob/360342c0504d5daa2344e864762cdf938d4149c7/src/edeposit/amqp/aleph/export.py#L162-L198
def _import_epublication(self, epub): """ Fill internal property ._POST dictionary with data from EPublication. """ # mrs. Svobodová requires that annotation exported by us have this # prefix prefixed_annotation = ANNOTATION_PREFIX + epub.anotace self._POST["P050...
[ "def", "_import_epublication", "(", "self", ",", "epub", ")", ":", "# mrs. Svobodová requires that annotation exported by us have this", "# prefix", "prefixed_annotation", "=", "ANNOTATION_PREFIX", "+", "epub", ".", "anotace", "self", ".", "_POST", "[", "\"P0501010__a\"", ...
Fill internal property ._POST dictionary with data from EPublication.
[ "Fill", "internal", "property", ".", "_POST", "dictionary", "with", "data", "from", "EPublication", "." ]
python
train
45.621622
devassistant/devassistant
devassistant/gui/path_window.py
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/path_window.py#L383-L391
def dir_name_changed(self, widget, data=None): """ Function is used for controlling label Full Directory project name and storing current project directory in configuration manager """ config_manager.set_config_value("da.project_dir", self.dir_name.get_text()) ...
[ "def", "dir_name_changed", "(", "self", ",", "widget", ",", "data", "=", "None", ")", ":", "config_manager", ".", "set_config_value", "(", "\"da.project_dir\"", ",", "self", ".", "dir_name", ".", "get_text", "(", ")", ")", "self", ".", "update_full_label", "...
Function is used for controlling label Full Directory project name and storing current project directory in configuration manager
[ "Function", "is", "used", "for", "controlling", "label", "Full", "Directory", "project", "name", "and", "storing", "current", "project", "directory", "in", "configuration", "manager" ]
python
train
37.888889
pyQode/pyqode.core
pyqode/core/managers/backend.py
https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/managers/backend.py#L161-L194
def send_request(self, worker_class_or_function, args, on_receive=None): """ Requests some work to be done by the backend. You can get notified of the work results by passing a callback (on_receive). :param worker_class_or_function: Worker class or function :param args: worker a...
[ "def", "send_request", "(", "self", ",", "worker_class_or_function", ",", "args", ",", "on_receive", "=", "None", ")", ":", "if", "not", "self", ".", "running", ":", "try", ":", "# try to restart the backend if it crashed.", "self", ".", "start", "(", "self", ...
Requests some work to be done by the backend. You can get notified of the work results by passing a callback (on_receive). :param worker_class_or_function: Worker class or function :param args: worker args, any Json serializable objects :param on_receive: an optional callback executed w...
[ "Requests", "some", "work", "to", "be", "done", "by", "the", "backend", ".", "You", "can", "get", "notified", "of", "the", "work", "results", "by", "passing", "a", "callback", "(", "on_receive", ")", "." ]
python
train
45.058824
Gandi/gandi.cli
gandi/cli/modules/network.py
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/modules/network.py#L77-L89
def attach(cls, ip, vm, background=False, force=False): """ Attach """ vm_ = Iaas.info(vm) ip_ = cls.info(ip) if not cls._check_and_detach(ip_, vm_): return # then we should attach the ip to the vm attach = Iface._attach(ip_['iface_id'], vm_['id']) if...
[ "def", "attach", "(", "cls", ",", "ip", ",", "vm", ",", "background", "=", "False", ",", "force", "=", "False", ")", ":", "vm_", "=", "Iaas", ".", "info", "(", "vm", ")", "ip_", "=", "cls", ".", "info", "(", "ip", ")", "if", "not", "cls", "."...
Attach
[ "Attach" ]
python
train
29.846154
log2timeline/plaso
plaso/parsers/cookie_plugins/ganalytics.py
https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/parsers/cookie_plugins/ganalytics.py#L286-L323
def GetEntries( self, parser_mediator, cookie_data=None, url=None, **kwargs): """Extracts event objects from the cookie. Args: parser_mediator (ParserMediator): parser mediator. cookie_data (bytes): cookie data. url (str): URL or path where the cookie got set. """ fields = cooki...
[ "def", "GetEntries", "(", "self", ",", "parser_mediator", ",", "cookie_data", "=", "None", ",", "url", "=", "None", ",", "*", "*", "kwargs", ")", ":", "fields", "=", "cookie_data", ".", "split", "(", "'.'", ")", "number_of_fields", "=", "len", "(", "fi...
Extracts event objects from the cookie. Args: parser_mediator (ParserMediator): parser mediator. cookie_data (bytes): cookie data. url (str): URL or path where the cookie got set.
[ "Extracts", "event", "objects", "from", "the", "cookie", "." ]
python
train
36
globality-corp/microcosm-flask
microcosm_flask/formatting/base.py
https://github.com/globality-corp/microcosm-flask/blob/c2eaf57f03e7d041eea343751a4a90fcc80df418/microcosm_flask/formatting/base.py#L50-L74
def build_etag(self, response, include_etag=True, **kwargs): """ Add an etag to the response body. Uses spooky where possible because it is empirically fast and well-regarded. See: http://blog.reverberate.org/2012/01/state-of-hash-functions-2012.html """ if not include...
[ "def", "build_etag", "(", "self", ",", "response", ",", "include_etag", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "not", "include_etag", ":", "return", "if", "not", "spooky", ":", "# use built-in md5", "response", ".", "add_etag", "(", ")", "...
Add an etag to the response body. Uses spooky where possible because it is empirically fast and well-regarded. See: http://blog.reverberate.org/2012/01/state-of-hash-functions-2012.html
[ "Add", "an", "etag", "to", "the", "response", "body", "." ]
python
train
26.92
sampsyo/confuse
confuse.py
https://github.com/sampsyo/confuse/blob/9ff0992e30470f6822824711950e6dd906e253fb/confuse.py#L846-L875
def restore_yaml_comments(data, default_data): """Scan default_data for comments (we include empty lines in our definition of comments) and place them before the same keys in data. Only works with comments that are on one or more own lines, i.e. not next to a yaml mapping. """ comment_map = dict...
[ "def", "restore_yaml_comments", "(", "data", ",", "default_data", ")", ":", "comment_map", "=", "dict", "(", ")", "default_lines", "=", "iter", "(", "default_data", ".", "splitlines", "(", ")", ")", "for", "line", "in", "default_lines", ":", "if", "not", "...
Scan default_data for comments (we include empty lines in our definition of comments) and place them before the same keys in data. Only works with comments that are on one or more own lines, i.e. not next to a yaml mapping.
[ "Scan", "default_data", "for", "comments", "(", "we", "include", "empty", "lines", "in", "our", "definition", "of", "comments", ")", "and", "place", "them", "before", "the", "same", "keys", "in", "data", ".", "Only", "works", "with", "comments", "that", "a...
python
train
34.9
lesscpy/lesscpy
lesscpy/plib/expression.py
https://github.com/lesscpy/lesscpy/blob/51e392fb4a3cd4ccfb6175e0e42ce7d2f6b78126/lesscpy/plib/expression.py#L56-L83
def with_units(self, val, ua, ub): """Return value with unit. args: val (mixed): result ua (str): 1st unit ub (str): 2nd unit raises: SyntaxError returns: str """ if not val: return str(val) i...
[ "def", "with_units", "(", "self", ",", "val", ",", "ua", ",", "ub", ")", ":", "if", "not", "val", ":", "return", "str", "(", "val", ")", "if", "ua", "or", "ub", ":", "if", "ua", "and", "ub", ":", "if", "ua", "==", "ub", ":", "return", "str", ...
Return value with unit. args: val (mixed): result ua (str): 1st unit ub (str): 2nd unit raises: SyntaxError returns: str
[ "Return", "value", "with", "unit", ".", "args", ":", "val", "(", "mixed", ")", ":", "result", "ua", "(", "str", ")", ":", "1st", "unit", "ub", "(", "str", ")", ":", "2nd", "unit", "raises", ":", "SyntaxError", "returns", ":", "str" ]
python
valid
30.75
firecat53/urlscan
urlscan/urlchoose.py
https://github.com/firecat53/urlscan/blob/2d10807d01167873733da3b478c784f8fa21bbc0/urlscan/urlchoose.py#L507-L515
def _footer_start_thread(self, text, time): """Display given text in the footer. Clears after <time> seconds """ footerwid = urwid.AttrMap(urwid.Text(text), 'footer') self.top.footer = footerwid load_thread = Thread(target=self._loading_thread, args=(time,)) load_thread....
[ "def", "_footer_start_thread", "(", "self", ",", "text", ",", "time", ")", ":", "footerwid", "=", "urwid", ".", "AttrMap", "(", "urwid", ".", "Text", "(", "text", ")", ",", "'footer'", ")", "self", ".", "top", ".", "footer", "=", "footerwid", "load_thr...
Display given text in the footer. Clears after <time> seconds
[ "Display", "given", "text", "in", "the", "footer", ".", "Clears", "after", "<time", ">", "seconds" ]
python
train
39.222222
michael-lazar/rtv
rtv/packages/praw/internal.py
https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/internal.py#L149-L206
def _prepare_request(reddit_session, url, params, data, auth, files, method=None): """Return a requests Request object that can be "prepared".""" # Requests using OAuth for authorization must switch to using the oauth # domain. if getattr(reddit_session, '_use_oauth', False): ...
[ "def", "_prepare_request", "(", "reddit_session", ",", "url", ",", "params", ",", "data", ",", "auth", ",", "files", ",", "method", "=", "None", ")", ":", "# Requests using OAuth for authorization must switch to using the oauth", "# domain.", "if", "getattr", "(", "...
Return a requests Request object that can be "prepared".
[ "Return", "a", "requests", "Request", "object", "that", "can", "be", "prepared", "." ]
python
train
36.086207
jonfaustman/django-frontend
djfrontend/templatetags/djfrontend.py
https://github.com/jonfaustman/django-frontend/blob/897934d593fade0eb1998f8fadd18c91a89e5b9a/djfrontend/templatetags/djfrontend.py#L60-L70
def djfrontend_fontawesome(version=None): """ Returns Font Awesome CSS file. TEMPLATE_DEBUG returns full file, otherwise returns minified file. """ if version is None: version = getattr(settings, 'DJFRONTEND_FONTAWESOME', DJFRONTEND_FONTAWESOME_DEFAULT) return format_html( '<lin...
[ "def", "djfrontend_fontawesome", "(", "version", "=", "None", ")", ":", "if", "version", "is", "None", ":", "version", "=", "getattr", "(", "settings", ",", "'DJFRONTEND_FONTAWESOME'", ",", "DJFRONTEND_FONTAWESOME_DEFAULT", ")", "return", "format_html", "(", "'<li...
Returns Font Awesome CSS file. TEMPLATE_DEBUG returns full file, otherwise returns minified file.
[ "Returns", "Font", "Awesome", "CSS", "file", ".", "TEMPLATE_DEBUG", "returns", "full", "file", "otherwise", "returns", "minified", "file", "." ]
python
test
38.909091
projectshift/shift-schema
shiftschema/property.py
https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/property.py#L56-L73
def filter(self, value=None, model=None, context=None): """ Sequentially applies all the filters to provided value :param value: a value to filter :param model: parent entity :param context: filtering context, usually parent entity :return: filtered value """ ...
[ "def", "filter", "(", "self", ",", "value", "=", "None", ",", "model", "=", "None", ",", "context", "=", "None", ")", ":", "if", "value", "is", "None", ":", "return", "value", "for", "filter_obj", "in", "self", ".", "filters", ":", "value", "=", "f...
Sequentially applies all the filters to provided value :param value: a value to filter :param model: parent entity :param context: filtering context, usually parent entity :return: filtered value
[ "Sequentially", "applies", "all", "the", "filters", "to", "provided", "value" ]
python
train
32.444444
CityOfZion/neo-python
neo/Network/Payloads/GetBlocksPayload.py
https://github.com/CityOfZion/neo-python/blob/fe90f62e123d720d4281c79af0598d9df9e776fb/neo/Network/Payloads/GetBlocksPayload.py#L33-L41
def Deserialize(self, reader): """ Deserialize full object. Args: reader (neo.IO.BinaryReader): """ self.HashStart = reader.ReadSerializableArray('neocore.UInt256.UInt256') self.HashStop = reader.ReadUInt256()
[ "def", "Deserialize", "(", "self", ",", "reader", ")", ":", "self", ".", "HashStart", "=", "reader", ".", "ReadSerializableArray", "(", "'neocore.UInt256.UInt256'", ")", "self", ".", "HashStop", "=", "reader", ".", "ReadUInt256", "(", ")" ]
Deserialize full object. Args: reader (neo.IO.BinaryReader):
[ "Deserialize", "full", "object", "." ]
python
train
29.111111
quiltdata/quilt
compiler/quilt/tools/command.py
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L1196-L1210
def rm(package, force=False): """ Remove a package (all instances) from the local store. """ team, owner, pkg = parse_package(package) if not force: confirmed = input("Remove {0}? (y/n) ".format(package)) if confirmed.lower() != 'y': return store = PackageStore() ...
[ "def", "rm", "(", "package", ",", "force", "=", "False", ")", ":", "team", ",", "owner", ",", "pkg", "=", "parse_package", "(", "package", ")", "if", "not", "force", ":", "confirmed", "=", "input", "(", "\"Remove {0}? (y/n) \"", ".", "format", "(", "pa...
Remove a package (all instances) from the local store.
[ "Remove", "a", "package", "(", "all", "instances", ")", "from", "the", "local", "store", "." ]
python
train
28.133333
tensorlayer/tensorlayer
tensorlayer/layers/core.py
https://github.com/tensorlayer/tensorlayer/blob/aa9e52e36c7058a7e6fd81d36563ca6850b21956/tensorlayer/layers/core.py#L215-L223
def get_all_params(self, session=None): """Return the parameters in a list of array.""" _params = [] for p in self.all_params: if session is None: _params.append(p.eval()) else: _params.append(session.run(p)) return _params
[ "def", "get_all_params", "(", "self", ",", "session", "=", "None", ")", ":", "_params", "=", "[", "]", "for", "p", "in", "self", ".", "all_params", ":", "if", "session", "is", "None", ":", "_params", ".", "append", "(", "p", ".", "eval", "(", ")", ...
Return the parameters in a list of array.
[ "Return", "the", "parameters", "in", "a", "list", "of", "array", "." ]
python
valid
33.666667
ARMmbed/icetea
icetea_lib/ResultList.py
https://github.com/ARMmbed/icetea/blob/b2b97ac607429830cf7d62dae2e3903692c7c778/icetea_lib/ResultList.py#L325-L338
def next(self): """ Implementation of next method from Iterator. :return: Result :raises: StopIteration if IndexError occurs. """ try: result = self.data[self.index] except IndexError: self.index = 0 raise StopIteration ...
[ "def", "next", "(", "self", ")", ":", "try", ":", "result", "=", "self", ".", "data", "[", "self", ".", "index", "]", "except", "IndexError", ":", "self", ".", "index", "=", "0", "raise", "StopIteration", "self", ".", "index", "+=", "1", "return", ...
Implementation of next method from Iterator. :return: Result :raises: StopIteration if IndexError occurs.
[ "Implementation", "of", "next", "method", "from", "Iterator", "." ]
python
train
24.642857
scanny/python-pptx
pptx/shapes/shapetree.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/shapes/shapetree.py#L237-L253
def add_chart(self, chart_type, x, y, cx, cy, chart_data): """Add a new chart of *chart_type* to the slide. The chart is positioned at (*x*, *y*), has size (*cx*, *cy*), and depicts *chart_data*. *chart_type* is one of the :ref:`XlChartType` enumeration values. *chart_data* is a |ChartD...
[ "def", "add_chart", "(", "self", ",", "chart_type", ",", "x", ",", "y", ",", "cx", ",", "cy", ",", "chart_data", ")", ":", "rId", "=", "self", ".", "part", ".", "add_chart_part", "(", "chart_type", ",", "chart_data", ")", "graphicFrame", "=", "self", ...
Add a new chart of *chart_type* to the slide. The chart is positioned at (*x*, *y*), has size (*cx*, *cy*), and depicts *chart_data*. *chart_type* is one of the :ref:`XlChartType` enumeration values. *chart_data* is a |ChartData| object populated with the categories and series values fo...
[ "Add", "a", "new", "chart", "of", "*", "chart_type", "*", "to", "the", "slide", "." ]
python
train
51.176471
Equitable/trump
trump/orm.py
https://github.com/Equitable/trump/blob/a2802692bc642fa32096374159eea7ceca2947b4/trump/orm.py#L1205-L1257
def check_validity(self, checks=None, report=True): """ Runs a Symbol's validity checks. Parameters ---------- checks : str, [str,], optional Only run certain checks. report : bool, optional If set to False, the method will return only t...
[ "def", "check_validity", "(", "self", ",", "checks", "=", "None", ",", "report", "=", "True", ")", ":", "if", "report", ":", "reportpoints", "=", "[", "]", "allchecks", "=", "[", "]", "checks_specified", "=", "False", "if", "isinstance", "(", "checks", ...
Runs a Symbol's validity checks. Parameters ---------- checks : str, [str,], optional Only run certain checks. report : bool, optional If set to False, the method will return only the result of the check checks (True/False). Set to ...
[ "Runs", "a", "Symbol", "s", "validity", "checks", ".", "Parameters", "----------", "checks", ":", "str", "[", "str", "]", "optional", "Only", "run", "certain", "checks", ".", "report", ":", "bool", "optional", "If", "set", "to", "False", "the", "method", ...
python
train
32.981132
project-rig/rig
rig/utils/contexts.py
https://github.com/project-rig/rig/blob/3a3e053d3214899b6d68758685835de0afd5542b/rig/utils/contexts.py#L83-L88
def get_context_arguments(self): """Return a dictionary containing the current context arguments.""" cargs = {} for context in self.__context_stack: cargs.update(context.context_arguments) return cargs
[ "def", "get_context_arguments", "(", "self", ")", ":", "cargs", "=", "{", "}", "for", "context", "in", "self", ".", "__context_stack", ":", "cargs", ".", "update", "(", "context", ".", "context_arguments", ")", "return", "cargs" ]
Return a dictionary containing the current context arguments.
[ "Return", "a", "dictionary", "containing", "the", "current", "context", "arguments", "." ]
python
train
40
spyder-ide/qtawesome
qtawesome/iconic_font.py
https://github.com/spyder-ide/qtawesome/blob/c88122aac5b7000eab9d2ae98d27fb3ade88d0f3/qtawesome/iconic_font.py#L84-L138
def _paint_icon(self, iconic, painter, rect, mode, state, options): """Paint a single icon.""" painter.save() color = options['color'] char = options['char'] color_options = { QIcon.On: { QIcon.Normal: (options['color_on'], options['on']), ...
[ "def", "_paint_icon", "(", "self", ",", "iconic", ",", "painter", ",", "rect", ",", "mode", ",", "state", ",", "options", ")", ":", "painter", ".", "save", "(", ")", "color", "=", "options", "[", "'color'", "]", "char", "=", "options", "[", "'char'",...
Paint a single icon.
[ "Paint", "a", "single", "icon", "." ]
python
train
38.290909
huggingface/pytorch-pretrained-BERT
pytorch_pretrained_bert/tokenization.py
https://github.com/huggingface/pytorch-pretrained-BERT/blob/b832d5bb8a6dfc5965015b828e577677eace601e/pytorch_pretrained_bert/tokenization.py#L236-L245
def _run_strip_accents(self, text): """Strips accents from a piece of text.""" text = unicodedata.normalize("NFD", text) output = [] for char in text: cat = unicodedata.category(char) if cat == "Mn": continue output.append(char) ...
[ "def", "_run_strip_accents", "(", "self", ",", "text", ")", ":", "text", "=", "unicodedata", ".", "normalize", "(", "\"NFD\"", ",", "text", ")", "output", "=", "[", "]", "for", "char", "in", "text", ":", "cat", "=", "unicodedata", ".", "category", "(",...
Strips accents from a piece of text.
[ "Strips", "accents", "from", "a", "piece", "of", "text", "." ]
python
train
33.4
caktus/django-timepiece
timepiece/reports/utils.py
https://github.com/caktus/django-timepiece/blob/52515dec027664890efbc535429e1ba1ee152f40/timepiece/reports/utils.py#L12-L31
def date_totals(entries, by): """Yield a user's name and a dictionary of their hours""" date_dict = {} for date, date_entries in groupby(entries, lambda x: x['date']): if isinstance(date, datetime.datetime): date = date.date() d_entries = list(date_entries) if by == 'use...
[ "def", "date_totals", "(", "entries", ",", "by", ")", ":", "date_dict", "=", "{", "}", "for", "date", ",", "date_entries", "in", "groupby", "(", "entries", ",", "lambda", "x", ":", "x", "[", "'date'", "]", ")", ":", "if", "isinstance", "(", "date", ...
Yield a user's name and a dictionary of their hours
[ "Yield", "a", "user", "s", "name", "and", "a", "dictionary", "of", "their", "hours" ]
python
train
34.9
ska-sa/katcp-python
katcp/core.py
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/core.py#L101-L127
def log_future_exceptions(logger, f, ignore=()): """Log any exceptions set to a future Parameters ---------- logger : logging.Logger instance logger.exception(...) is called if the future resolves with an exception f : Future object Future to be monitored for exceptions ignore :...
[ "def", "log_future_exceptions", "(", "logger", ",", "f", ",", "ignore", "=", "(", ")", ")", ":", "def", "log_cb", "(", "f", ")", ":", "try", ":", "f", ".", "result", "(", ")", "except", "ignore", ":", "pass", "except", "Exception", ":", "logger", "...
Log any exceptions set to a future Parameters ---------- logger : logging.Logger instance logger.exception(...) is called if the future resolves with an exception f : Future object Future to be monitored for exceptions ignore : Exception or tuple of Exception Exptected excep...
[ "Log", "any", "exceptions", "set", "to", "a", "future" ]
python
train
33.518519
dswah/pyGAM
pygam/utils.py
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/utils.py#L489-L515
def space_row(left, right, filler=' ', total_width=-1): """space the data in a row with optional filling Arguments --------- left : str, to be aligned left right : str, to be aligned right filler : str, default ' '. must be of length 1 total_width : int, width of line. if ne...
[ "def", "space_row", "(", "left", ",", "right", ",", "filler", "=", "' '", ",", "total_width", "=", "-", "1", ")", ":", "left", "=", "str", "(", "left", ")", "right", "=", "str", "(", "right", ")", "filler", "=", "str", "(", "filler", ")", "[", ...
space the data in a row with optional filling Arguments --------- left : str, to be aligned left right : str, to be aligned right filler : str, default ' '. must be of length 1 total_width : int, width of line. if negative number is specified, then that number of spaces ...
[ "space", "the", "data", "in", "a", "row", "with", "optional", "filling" ]
python
train
25.037037
contentful/contentful-management.py
contentful_management/content_type_field_types.py
https://github.com/contentful/contentful-management.py/blob/707dd30883b98a10c7ff0f7f5bdb8edbdc1d8df0/contentful_management/content_type_field_types.py#L167-L175
def coerce(self, value): """ Coerces value to location hash. """ return { 'lat': float(value.get('lat', value.get('latitude'))), 'lon': float(value.get('lon', value.get('longitude'))) }
[ "def", "coerce", "(", "self", ",", "value", ")", ":", "return", "{", "'lat'", ":", "float", "(", "value", ".", "get", "(", "'lat'", ",", "value", ".", "get", "(", "'latitude'", ")", ")", ")", ",", "'lon'", ":", "float", "(", "value", ".", "get", ...
Coerces value to location hash.
[ "Coerces", "value", "to", "location", "hash", "." ]
python
train
26.888889
tundish/turberfield-dialogue
turberfield/dialogue/player.py
https://github.com/tundish/turberfield-dialogue/blob/e7ccf7c19ae162e2f315ddf2642394e858529b4a/turberfield/dialogue/player.py#L27-L43
def run_through(script, ensemble, roles=1, strict=False): """ :py:class:`turberfield.dialogue.model.SceneScript`. """ with script as dialogue: selection = dialogue.select(ensemble, roles=roles) if not any(selection.values()) or strict and not all(selection.values()): return ...
[ "def", "run_through", "(", "script", ",", "ensemble", ",", "roles", "=", "1", ",", "strict", "=", "False", ")", ":", "with", "script", "as", "dialogue", ":", "selection", "=", "dialogue", ".", "select", "(", "ensemble", ",", "roles", "=", "roles", ")",...
:py:class:`turberfield.dialogue.model.SceneScript`.
[ ":", "py", ":", "class", ":", "turberfield", ".", "dialogue", ".", "model", ".", "SceneScript", "." ]
python
train
36.529412
GoogleCloudPlatform/cloud-debug-python
src/googleclouddebugger/module_explorer.py
https://github.com/GoogleCloudPlatform/cloud-debug-python/blob/89ce3782c98b814838a3ecb5479ed3882368cbee/src/googleclouddebugger/module_explorer.py#L100-L134
def _GetModuleCodeObjects(module): """Gets all code objects defined in the specified module. There are two BFS traversals involved. One in this function and the other in _FindCodeObjectsReferents. Only the BFS in _FindCodeObjectsReferents has a depth limit. This function does not. The motivation is that this f...
[ "def", "_GetModuleCodeObjects", "(", "module", ")", ":", "visit_recorder", "=", "_VisitRecorder", "(", ")", "current", "=", "[", "module", "]", "code_objects", "=", "set", "(", ")", "while", "current", ":", "current", "=", "_FindCodeObjectsReferents", "(", "mo...
Gets all code objects defined in the specified module. There are two BFS traversals involved. One in this function and the other in _FindCodeObjectsReferents. Only the BFS in _FindCodeObjectsReferents has a depth limit. This function does not. The motivation is that this function explores code object of the mo...
[ "Gets", "all", "code", "objects", "defined", "in", "the", "specified", "module", "." ]
python
train
37.285714
shawnsilva/steamwebapi
steamwebapi/api.py
https://github.com/shawnsilva/steamwebapi/blob/dc16538ebe985cc7ea170f660169ebc2366efbf2/steamwebapi/api.py#L316-L330
def get_recently_played_games(self, steamID, count=0, format=None): """Request a list of recently played games by a given steam id. steamID: The users ID count: Number of games to return. (0 is all recent games.) format: Return format. None defaults to json. (json, xml, vdf) ""...
[ "def", "get_recently_played_games", "(", "self", ",", "steamID", ",", "count", "=", "0", ",", "format", "=", "None", ")", ":", "parameters", "=", "{", "'steamid'", ":", "steamID", ",", "'count'", ":", "count", "}", "if", "format", "is", "not", "None", ...
Request a list of recently played games by a given steam id. steamID: The users ID count: Number of games to return. (0 is all recent games.) format: Return format. None defaults to json. (json, xml, vdf)
[ "Request", "a", "list", "of", "recently", "played", "games", "by", "a", "given", "steam", "id", "." ]
python
train
42.8
santoshphilip/eppy
eppy/bunch_subclass.py
https://github.com/santoshphilip/eppy/blob/55410ff7c11722f35bc4331ff5e00a0b86f787e1/eppy/bunch_subclass.py#L235-L237
def getreferingobjs(self, iddgroups=None, fields=None): """Get a list of objects that refer to this object""" return getreferingobjs(self, iddgroups=iddgroups, fields=fields)
[ "def", "getreferingobjs", "(", "self", ",", "iddgroups", "=", "None", ",", "fields", "=", "None", ")", ":", "return", "getreferingobjs", "(", "self", ",", "iddgroups", "=", "iddgroups", ",", "fields", "=", "fields", ")" ]
Get a list of objects that refer to this object
[ "Get", "a", "list", "of", "objects", "that", "refer", "to", "this", "object" ]
python
train
62.666667
jaraco/tempora
tempora/schedule.py
https://github.com/jaraco/tempora/blob/f0a9ab636103fe829aa9b495c93f5249aac5f2b8/tempora/schedule.py#L144-L153
def daily_at(cls, at, target): """ Schedule a command to run at a specific time each day. """ daily = datetime.timedelta(days=1) # convert when to the next datetime matching this time when = datetime.datetime.combine(datetime.date.today(), at) if when < now(): ...
[ "def", "daily_at", "(", "cls", ",", "at", ",", "target", ")", ":", "daily", "=", "datetime", ".", "timedelta", "(", "days", "=", "1", ")", "# convert when to the next datetime matching this time", "when", "=", "datetime", ".", "datetime", ".", "combine", "(", ...
Schedule a command to run at a specific time each day.
[ "Schedule", "a", "command", "to", "run", "at", "a", "specific", "time", "each", "day", "." ]
python
valid
39.6
quantopian/zipline
zipline/algorithm.py
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/algorithm.py#L482-L526
def _create_clock(self): """ If the clock property is not set, then create one based on frequency. """ trading_o_and_c = self.trading_calendar.schedule.ix[ self.sim_params.sessions] market_closes = trading_o_and_c['market_close'] minutely_emission = False ...
[ "def", "_create_clock", "(", "self", ")", ":", "trading_o_and_c", "=", "self", ".", "trading_calendar", ".", "schedule", ".", "ix", "[", "self", ".", "sim_params", ".", "sessions", "]", "market_closes", "=", "trading_o_and_c", "[", "'market_close'", "]", "minu...
If the clock property is not set, then create one based on frequency.
[ "If", "the", "clock", "property", "is", "not", "set", "then", "create", "one", "based", "on", "frequency", "." ]
python
train
42.288889
arista-eosplus/pyeapi
docs/generate_modules.py
https://github.com/arista-eosplus/pyeapi/blob/96a74faef1fe3bd79c4e900aed29c9956a0587d6/docs/generate_modules.py#L64-L80
def write_module_file(name, path, package): '''Creates an RST file for the module name passed in. It places it in the path defined ''' file_path = join(path, '%s.rst' % name) mod_file = open(file_path, 'w') mod_file.write('%s\n' % AUTOGEN) mod_file.write('%s\n' % name.title()) mod_file....
[ "def", "write_module_file", "(", "name", ",", "path", ",", "package", ")", ":", "file_path", "=", "join", "(", "path", ",", "'%s.rst'", "%", "name", ")", "mod_file", "=", "open", "(", "file_path", ",", "'w'", ")", "mod_file", ".", "write", "(", "'%s\\n...
Creates an RST file for the module name passed in. It places it in the path defined
[ "Creates", "an", "RST", "file", "for", "the", "module", "name", "passed", "in", ".", "It", "places", "it", "in", "the", "path", "defined" ]
python
train
36.588235
pyQode/pyqode.core
pyqode/core/widgets/output_window.py
https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/output_window.py#L1236-L1244
def _draw_chars(self, data, to_draw): """ Draw the specified charachters using the specified format. """ i = 0 while not self._cursor.atBlockEnd() and i < len(to_draw) and len(to_draw) > 1: self._cursor.deleteChar() i += 1 self._cursor.insertText(t...
[ "def", "_draw_chars", "(", "self", ",", "data", ",", "to_draw", ")", ":", "i", "=", "0", "while", "not", "self", ".", "_cursor", ".", "atBlockEnd", "(", ")", "and", "i", "<", "len", "(", "to_draw", ")", "and", "len", "(", "to_draw", ")", ">", "1"...
Draw the specified charachters using the specified format.
[ "Draw", "the", "specified", "charachters", "using", "the", "specified", "format", "." ]
python
train
36.555556
digidotcom/python-devicecloud
devicecloud/__init__.py
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L394-L398
def streams(self): """Property providing access to the :class:`.StreamsAPI`""" if self._streams_api is None: self._streams_api = self.get_streams_api() return self._streams_api
[ "def", "streams", "(", "self", ")", ":", "if", "self", ".", "_streams_api", "is", "None", ":", "self", ".", "_streams_api", "=", "self", ".", "get_streams_api", "(", ")", "return", "self", ".", "_streams_api" ]
Property providing access to the :class:`.StreamsAPI`
[ "Property", "providing", "access", "to", "the", ":", "class", ":", ".", "StreamsAPI" ]
python
train
41.6
mpg-age-bioinformatics/AGEpy
AGEpy/fasta.py
https://github.com/mpg-age-bioinformatics/AGEpy/blob/887808a7a2c1504f39ce8d8cb36c15c1721cd29f/AGEpy/fasta.py#L2-L34
def getFasta(opened_file, sequence_name): """ Retrieves a sequence from an opened multifasta file :param opened_file: an opened multifasta file eg. opened_file=open("/path/to/file.fa",'r+') :param sequence_name: the name of the sequence to be retrieved eg. for '>2 dna:chromosome chromosome:GRCm38:2:1:1...
[ "def", "getFasta", "(", "opened_file", ",", "sequence_name", ")", ":", "lines", "=", "opened_file", ".", "readlines", "(", ")", "seq", "=", "str", "(", "\"\"", ")", "for", "i", "in", "range", "(", "0", ",", "len", "(", "lines", ")", ")", ":", "line...
Retrieves a sequence from an opened multifasta file :param opened_file: an opened multifasta file eg. opened_file=open("/path/to/file.fa",'r+') :param sequence_name: the name of the sequence to be retrieved eg. for '>2 dna:chromosome chromosome:GRCm38:2:1:182113224:1 REF' use: sequence_name=str(2) returns...
[ "Retrieves", "a", "sequence", "from", "an", "opened", "multifasta", "file" ]
python
train
30.727273
python-bonobo/bonobo
bonobo/registry.py
https://github.com/python-bonobo/bonobo/blob/70c8e62c4a88576976e5b52e58d380d6e3227ab4/bonobo/registry.py#L80-L88
def get_writer_factory_for(self, name, *, format=None): """ Returns a callable to build a writer for the provided filename, eventually forcing a format. :param name: filename :param format: format :return: type """ return self.get_factory_for(WRITER, name, format...
[ "def", "get_writer_factory_for", "(", "self", ",", "name", ",", "*", ",", "format", "=", "None", ")", ":", "return", "self", ".", "get_factory_for", "(", "WRITER", ",", "name", ",", "format", "=", "format", ")" ]
Returns a callable to build a writer for the provided filename, eventually forcing a format. :param name: filename :param format: format :return: type
[ "Returns", "a", "callable", "to", "build", "a", "writer", "for", "the", "provided", "filename", "eventually", "forcing", "a", "format", "." ]
python
train
35.555556
tensorflow/hub
tensorflow_hub/module_v2.py
https://github.com/tensorflow/hub/blob/09f45963f6787322967b6fec61459f3ac56fbb27/tensorflow_hub/module_v2.py#L43-L83
def load(handle): """Loads a module from a handle. Currently this method only works with Tensorflow 2.x and can only load modules created by calling tensorflow.saved_model.save(). The method works in both eager and graph modes. Depending on the type of handle used, the call may involve downloading a Tenso...
[ "def", "load", "(", "handle", ")", ":", "if", "hasattr", "(", "tf_v1", ".", "saved_model", ",", "\"load_v2\"", ")", ":", "module_handle", "=", "resolve", "(", "handle", ")", "if", "tf_v1", ".", "gfile", ".", "Exists", "(", "native_module", ".", "get_modu...
Loads a module from a handle. Currently this method only works with Tensorflow 2.x and can only load modules created by calling tensorflow.saved_model.save(). The method works in both eager and graph modes. Depending on the type of handle used, the call may involve downloading a Tensorflow Hub module to a l...
[ "Loads", "a", "module", "from", "a", "handle", "." ]
python
train
44.439024
pyQode/pyqode.core
pyqode/core/modes/checker.py
https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/modes/checker.py#L255-L272
def remove_message(self, message): """ Removes a message. :param message: Message to remove """ import time _logger(self.__class__).log(5, 'removing message %s' % message) t = time.time() usd = message.block.userData() if usd: try: ...
[ "def", "remove_message", "(", "self", ",", "message", ")", ":", "import", "time", "_logger", "(", "self", ".", "__class__", ")", ".", "log", "(", "5", ",", "'removing message %s'", "%", "message", ")", "t", "=", "time", ".", "time", "(", ")", "usd", ...
Removes a message. :param message: Message to remove
[ "Removes", "a", "message", "." ]
python
train
30.388889
xmartlabs/benderthon
benderthon/caffe_freeze.py
https://github.com/xmartlabs/benderthon/blob/810b6fb90f56136257e7ed12e5a30d17ad7ce6ba/benderthon/caffe_freeze.py#L48-L62
def freeze(caffe_def_path, caffemodel_path, inputs, output_file_path, output_node_names, graph_name='Graph', conversion_out_dir_path=None, checkpoint_out_path=None, use_padding_same=False): """Freeze and shrink the graph based on a Caffe model, the input tensors and the output node names.""" with caf...
[ "def", "freeze", "(", "caffe_def_path", ",", "caffemodel_path", ",", "inputs", ",", "output_file_path", ",", "output_node_names", ",", "graph_name", "=", "'Graph'", ",", "conversion_out_dir_path", "=", "None", ",", "checkpoint_out_path", "=", "None", ",", "use_paddi...
Freeze and shrink the graph based on a Caffe model, the input tensors and the output node names.
[ "Freeze", "and", "shrink", "the", "graph", "based", "on", "a", "Caffe", "model", "the", "input", "tensors", "and", "the", "output", "node", "names", "." ]
python
test
68.4
JoelBender/bacpypes
py34/bacpypes/primitivedata.py
https://github.com/JoelBender/bacpypes/blob/4111b8604a16fa2b7f80d8104a43b9f3e28dfc78/py34/bacpypes/primitivedata.py#L1135-L1148
def keylist(self): """Return a list of names in order by value.""" items = self.enumerations.items() items.sort(lambda a, b: self.cmp(a[1], b[1])) # last item has highest value rslt = [None] * (items[-1][1] + 1) # map the values for key, value in items: ...
[ "def", "keylist", "(", "self", ")", ":", "items", "=", "self", ".", "enumerations", ".", "items", "(", ")", "items", ".", "sort", "(", "lambda", "a", ",", "b", ":", "self", ".", "cmp", "(", "a", "[", "1", "]", ",", "b", "[", "1", "]", ")", ...
Return a list of names in order by value.
[ "Return", "a", "list", "of", "names", "in", "order", "by", "value", "." ]
python
train
26.928571
datastax/python-driver
setup.py
https://github.com/datastax/python-driver/blob/30a80d0b798b1f45f8cb77163b1fa791f3e3ca29/setup.py#L325-L377
def pre_build_check(): """ Try to verify build tools """ if os.environ.get('CASS_DRIVER_NO_PRE_BUILD_CHECK'): return True try: from distutils.ccompiler import new_compiler from distutils.sysconfig import customize_compiler from distutils.dist import Distribution ...
[ "def", "pre_build_check", "(", ")", ":", "if", "os", ".", "environ", ".", "get", "(", "'CASS_DRIVER_NO_PRE_BUILD_CHECK'", ")", ":", "return", "True", "try", ":", "from", "distutils", ".", "ccompiler", "import", "new_compiler", "from", "distutils", ".", "syscon...
Try to verify build tools
[ "Try", "to", "verify", "build", "tools" ]
python
train
37.339623
orbingol/NURBS-Python
geomdl/helpers.py
https://github.com/orbingol/NURBS-Python/blob/b1c6a8b51cf143ff58761438e93ba6baef470627/geomdl/helpers.py#L193-L214
def basis_function_all(degree, knot_vector, span, knot): """ Computes all non-zero basis functions of all degrees from 0 up to the input degree for a single parameter. A slightly modified version of Algorithm A2.2 from The NURBS Book by Piegl & Tiller. :param degree: degree, :math:`p` :type degree: in...
[ "def", "basis_function_all", "(", "degree", ",", "knot_vector", ",", "span", ",", "knot", ")", ":", "N", "=", "[", "[", "None", "for", "_", "in", "range", "(", "degree", "+", "1", ")", "]", "for", "_", "in", "range", "(", "degree", "+", "1", ")",...
Computes all non-zero basis functions of all degrees from 0 up to the input degree for a single parameter. A slightly modified version of Algorithm A2.2 from The NURBS Book by Piegl & Tiller. :param degree: degree, :math:`p` :type degree: int :param knot_vector: knot vector, :math:`U` :type knot_...
[ "Computes", "all", "non", "-", "zero", "basis", "functions", "of", "all", "degrees", "from", "0", "up", "to", "the", "input", "degree", "for", "a", "single", "parameter", "." ]
python
train
36.636364
juju/python-libjuju
juju/client/_client2.py
https://github.com/juju/python-libjuju/blob/58f0011f4c57cd68830258952fa952eaadca6b38/juju/client/_client2.py#L5258-L5271
async def BlockUntilLeadershipReleased(self, name): ''' name : str Returns -> Error ''' # map input types to rpc msg _params = dict() msg = dict(type='LeadershipService', request='BlockUntilLeadershipReleased', version=2, ...
[ "async", "def", "BlockUntilLeadershipReleased", "(", "self", ",", "name", ")", ":", "# map input types to rpc msg", "_params", "=", "dict", "(", ")", "msg", "=", "dict", "(", "type", "=", "'LeadershipService'", ",", "request", "=", "'BlockUntilLeadershipReleased'", ...
name : str Returns -> Error
[ "name", ":", "str", "Returns", "-", ">", "Error" ]
python
train
30.357143
qubole/qds-sdk-py
qds_sdk/commands.py
https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/commands.py#L1415-L1489
def _download_to_local(boto_conn, s3_path, fp, num_result_dir, delim=None): ''' Downloads the contents of all objects in s3_path into fp Args: `boto_conn`: S3 connection object `s3_path`: S3 path to be downloaded `fp`: The file object where data is to be downloaded ''' #Pr...
[ "def", "_download_to_local", "(", "boto_conn", ",", "s3_path", ",", "fp", ",", "num_result_dir", ",", "delim", "=", "None", ")", ":", "#Progress bar to display download progress", "def", "_callback", "(", "downloaded", ",", "total", ")", ":", "'''\n Call func...
Downloads the contents of all objects in s3_path into fp Args: `boto_conn`: S3 connection object `s3_path`: S3 path to be downloaded `fp`: The file object where data is to be downloaded
[ "Downloads", "the", "contents", "of", "all", "objects", "in", "s3_path", "into", "fp" ]
python
train
38.12
Stranger6667/postmarker
postmarker/models/emails.py
https://github.com/Stranger6667/postmarker/blob/013224ab1761e95c488c7d2701e6fa83f3108d94/postmarker/models/emails.py#L411-L449
def Email( self, From, To, Cc=None, Bcc=None, Subject=None, Tag=None, HtmlBody=None, TextBody=None, Metadata=None, ReplyTo=None, Headers=None, TrackOpens=None, TrackLinks="None", Attachments=None, ...
[ "def", "Email", "(", "self", ",", "From", ",", "To", ",", "Cc", "=", "None", ",", "Bcc", "=", "None", ",", "Subject", "=", "None", ",", "Tag", "=", "None", ",", "HtmlBody", "=", "None", ",", "TextBody", "=", "None", ",", "Metadata", "=", "None", ...
Constructs :py:class:`Email` instance. :return: :py:class:`Email`
[ "Constructs", ":", "py", ":", "class", ":", "Email", "instance", "." ]
python
train
21.538462
waqasbhatti/astrobase
astrobase/awsutils.py
https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/awsutils.py#L657-L714
def sqs_delete_item(queue_url, receipt_handle, client=None, raiseonfail=False): """This deletes a message from the queue, effectively acknowledging its receipt. Call this only when all messages retrieved from the queue have been processed, sin...
[ "def", "sqs_delete_item", "(", "queue_url", ",", "receipt_handle", ",", "client", "=", "None", ",", "raiseonfail", "=", "False", ")", ":", "if", "not", "client", ":", "client", "=", "boto3", ".", "client", "(", "'sqs'", ")", "try", ":", "client", ".", ...
This deletes a message from the queue, effectively acknowledging its receipt. Call this only when all messages retrieved from the queue have been processed, since this will prevent redelivery of these messages to other queue workers pulling fromn the same queue channel. Parameters ---------- ...
[ "This", "deletes", "a", "message", "from", "the", "queue", "effectively", "acknowledging", "its", "receipt", "." ]
python
valid
28.017241
cloudendpoints/endpoints-python
endpoints/apiserving.py
https://github.com/cloudendpoints/endpoints-python/blob/00dd7c7a52a9ee39d5923191c2604b8eafdb3f24/endpoints/apiserving.py#L434-L447
def __is_json_error(self, status, headers): """Determine if response is an error. Args: status: HTTP status code. headers: Dictionary of (lowercase) header name to value. Returns: True if the response was an error, else False. """ content_header = headers.get('content-type', '') ...
[ "def", "__is_json_error", "(", "self", ",", "status", ",", "headers", ")", ":", "content_header", "=", "headers", ".", "get", "(", "'content-type'", ",", "''", ")", "content_type", ",", "unused_params", "=", "cgi", ".", "parse_header", "(", "content_header", ...
Determine if response is an error. Args: status: HTTP status code. headers: Dictionary of (lowercase) header name to value. Returns: True if the response was an error, else False.
[ "Determine", "if", "response", "is", "an", "error", "." ]
python
train
33.928571
JdeRobot/base
src/drivers/MAVLinkServer/MAVProxy/pymavlink/quaternion.py
https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/pymavlink/quaternion.py#L348-L382
def _dcm_to_q(self, dcm): """ Create q from dcm Reference: - Shoemake, Quaternions, http://www.cs.ucr.edu/~vbz/resources/quatut.pdf :param dcm: 3x3 dcm array returns: quaternion array """ assert(dcm.shape == (3, 3)) q = np.zeros(4)...
[ "def", "_dcm_to_q", "(", "self", ",", "dcm", ")", ":", "assert", "(", "dcm", ".", "shape", "==", "(", "3", ",", "3", ")", ")", "q", "=", "np", ".", "zeros", "(", "4", ")", "tr", "=", "np", ".", "trace", "(", "dcm", ")", "if", "tr", ">", "...
Create q from dcm Reference: - Shoemake, Quaternions, http://www.cs.ucr.edu/~vbz/resources/quatut.pdf :param dcm: 3x3 dcm array returns: quaternion array
[ "Create", "q", "from", "dcm", "Reference", ":", "-", "Shoemake", "Quaternions", "http", ":", "//", "www", ".", "cs", ".", "ucr", ".", "edu", "/", "~vbz", "/", "resources", "/", "quatut", ".", "pdf" ]
python
train
31.085714
datosgobar/pydatajson
pydatajson/indicators.py
https://github.com/datosgobar/pydatajson/blob/3141082ffbaa295e2deaf6ffbbc5a59f5859960e/pydatajson/indicators.py#L509-L562
def _count_fields_recursive(dataset, fields): """Cuenta la información de campos optativos/recomendados/requeridos desde 'fields', y cuenta la ocurrencia de los mismos en 'dataset'. Args: dataset (dict): diccionario con claves a ser verificadas. fields (dict): diccionario con los campos a v...
[ "def", "_count_fields_recursive", "(", "dataset", ",", "fields", ")", ":", "key_count", "=", "{", "'recomendado'", ":", "0", ",", "'optativo'", ":", "0", ",", "'requerido'", ":", "0", ",", "'total_optativo'", ":", "0", ",", "'total_recomendado'", ":", "0", ...
Cuenta la información de campos optativos/recomendados/requeridos desde 'fields', y cuenta la ocurrencia de los mismos en 'dataset'. Args: dataset (dict): diccionario con claves a ser verificadas. fields (dict): diccionario con los campos a verificar en dataset como claves, y 'optat...
[ "Cuenta", "la", "información", "de", "campos", "optativos", "/", "recomendados", "/", "requeridos", "desde", "fields", "y", "cuenta", "la", "ocurrencia", "de", "los", "mismos", "en", "dataset", "." ]
python
train
38.425926
gem/oq-engine
openquake/hazardlib/geo/utils.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/utils.py#L134-L174
def assoc2(self, assets_by_site, assoc_dist, mode, asset_refs): """ Associated a list of assets by site to the site collection used to instantiate GeographicObjects. :param assets_by_sites: a list of lists of assets :param assoc_dist: the maximum distance for association ...
[ "def", "assoc2", "(", "self", ",", "assets_by_site", ",", "assoc_dist", ",", "mode", ",", "asset_refs", ")", ":", "assert", "mode", "in", "'strict filter'", ",", "mode", "self", ".", "objects", ".", "filtered", "# self.objects must be a SiteCollection", "asset_dt"...
Associated a list of assets by site to the site collection used to instantiate GeographicObjects. :param assets_by_sites: a list of lists of assets :param assoc_dist: the maximum distance for association :param mode: 'strict', 'warn' or 'filter' :param asset_ref: ID of the asset...
[ "Associated", "a", "list", "of", "assets", "by", "site", "to", "the", "site", "collection", "used", "to", "instantiate", "GeographicObjects", "." ]
python
train
46.365854
casacore/python-casacore
casacore/tables/tablecolumn.py
https://github.com/casacore/python-casacore/blob/975510861ea005f7919dd9e438b5f98a1682eebe/casacore/tables/tablecolumn.py#L159-L162
def putcol(self, value, startrow=0, nrow=-1, rowincr=1): """Put an entire column or part of it. (see :func:`table.putcol`)""" return self._table.putcol(self._column, value, startrow, nrow, rowincr)
[ "def", "putcol", "(", "self", ",", "value", ",", "startrow", "=", "0", ",", "nrow", "=", "-", "1", ",", "rowincr", "=", "1", ")", ":", "return", "self", ".", "_table", ".", "putcol", "(", "self", ".", "_column", ",", "value", ",", "startrow", ","...
Put an entire column or part of it. (see :func:`table.putcol`)
[ "Put", "an", "entire", "column", "or", "part", "of", "it", ".", "(", "see", ":", "func", ":", "table", ".", "putcol", ")" ]
python
train
54.5
podio/podio-py
pypodio2/areas.py
https://github.com/podio/podio-py/blob/5ce956034a06c98b0ef18fcd940b36da0908ad6c/pypodio2/areas.py#L557-L568
def get(self, app_id, view_specifier): """ Retrieve the definition of a given view, provided the app_id and the view_id :param app_id: the app id :param view_specifier: Can be one of the following: 1. The view ID 2. The view's name 3. "las...
[ "def", "get", "(", "self", ",", "app_id", ",", "view_specifier", ")", ":", "return", "self", ".", "transport", ".", "GET", "(", "url", "=", "'/view/app/{}/{}'", ".", "format", "(", "app_id", ",", "view_specifier", ")", ")" ]
Retrieve the definition of a given view, provided the app_id and the view_id :param app_id: the app id :param view_specifier: Can be one of the following: 1. The view ID 2. The view's name 3. "last" to look up the last view used
[ "Retrieve", "the", "definition", "of", "a", "given", "view", "provided", "the", "app_id", "and", "the", "view_id" ]
python
train
36.75
fermiPy/fermipy
fermipy/roi_model.py
https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/roi_model.py#L137-L188
def get_skydir_distance_mask(src_skydir, skydir, dist, min_dist=None, square=False, coordsys='CEL'): """Retrieve sources within a certain angular distance of an (ra,dec) coordinate. This function supports two types of geometric selections: circular (square=False) and square ...
[ "def", "get_skydir_distance_mask", "(", "src_skydir", ",", "skydir", ",", "dist", ",", "min_dist", "=", "None", ",", "square", "=", "False", ",", "coordsys", "=", "'CEL'", ")", ":", "if", "dist", "is", "None", ":", "dist", "=", "180.", "if", "not", "sq...
Retrieve sources within a certain angular distance of an (ra,dec) coordinate. This function supports two types of geometric selections: circular (square=False) and square (square=True). The circular selection finds all sources with a given angular distance of the target position. The square selection...
[ "Retrieve", "sources", "within", "a", "certain", "angular", "distance", "of", "an", "(", "ra", "dec", ")", "coordinate", ".", "This", "function", "supports", "two", "types", "of", "geometric", "selections", ":", "circular", "(", "square", "=", "False", ")", ...
python
train
34.153846
ivankorobkov/python-inject
src/inject.py
https://github.com/ivankorobkov/python-inject/blob/e2f04f91fbcfd0b38e628cbeda97bd8449038d36/src/inject.py#L271-L294
def get_instance(self, cls): """Return an instance for a class.""" binding = self._bindings.get(cls) if binding: return binding() # Try to create a runtime binding. with _BINDING_LOCK: binding = self._bindings.get(cls) if binding: ...
[ "def", "get_instance", "(", "self", ",", "cls", ")", ":", "binding", "=", "self", ".", "_bindings", ".", "get", "(", "cls", ")", "if", "binding", ":", "return", "binding", "(", ")", "# Try to create a runtime binding.", "with", "_BINDING_LOCK", ":", "binding...
Return an instance for a class.
[ "Return", "an", "instance", "for", "a", "class", "." ]
python
train
33.916667
Alignak-monitoring/alignak
alignak/objects/schedulingitem.py
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L846-L884
def no_more_a_problem(self, hosts, services, timeperiods, bi_modulations): """Remove this objects as an impact for other schedulingitem. :param hosts: hosts objects, used to get impacts :type hosts: alignak.objects.host.Hosts :param services: services objects, used to get impacts ...
[ "def", "no_more_a_problem", "(", "self", ",", "hosts", ",", "services", ",", "timeperiods", ",", "bi_modulations", ")", ":", "was_pb", "=", "self", ".", "is_problem", "if", "self", ".", "is_problem", ":", "self", ".", "is_problem", "=", "False", "# we warn i...
Remove this objects as an impact for other schedulingitem. :param hosts: hosts objects, used to get impacts :type hosts: alignak.objects.host.Hosts :param services: services objects, used to get impacts :type services: alignak.objects.service.Services :param timeperiods: Timeper...
[ "Remove", "this", "objects", "as", "an", "impact", "for", "other", "schedulingitem", "." ]
python
train
45.666667
razorpay/razorpay-python
razorpay/client.py
https://github.com/razorpay/razorpay-python/blob/5bc63fd8452165a4b54556888492e555222c8afe/razorpay/client.py#L171-L176
def put(self, path, data, **options): """ Parses PUT request options and dispatches a request """ data, options = self._update_request(data, options) return self.request('put', path, data=data, **options)
[ "def", "put", "(", "self", ",", "path", ",", "data", ",", "*", "*", "options", ")", ":", "data", ",", "options", "=", "self", ".", "_update_request", "(", "data", ",", "options", ")", "return", "self", ".", "request", "(", "'put'", ",", "path", ","...
Parses PUT request options and dispatches a request
[ "Parses", "PUT", "request", "options", "and", "dispatches", "a", "request" ]
python
train
39.833333
cjdrake/pyeda
pyeda/boolalg/bdd.py
https://github.com/cjdrake/pyeda/blob/554ee53aa678f4b61bcd7e07ba2c74ddc749d665/pyeda/boolalg/bdd.py#L524-L535
def _iter_all_paths(start, end, rand=False, path=tuple()): """Iterate through all paths from start to end.""" path = path + (start, ) if start is end: yield path else: nodes = [start.lo, start.hi] if rand: # pragma: no cover random.shuffle(nodes) for node in n...
[ "def", "_iter_all_paths", "(", "start", ",", "end", ",", "rand", "=", "False", ",", "path", "=", "tuple", "(", ")", ")", ":", "path", "=", "path", "+", "(", "start", ",", ")", "if", "start", "is", "end", ":", "yield", "path", "else", ":", "nodes"...
Iterate through all paths from start to end.
[ "Iterate", "through", "all", "paths", "from", "start", "to", "end", "." ]
python
train
34.416667