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
CyberReboot/vent
vent/extras/rmq_es_connector/rmq_es_connector.py
https://github.com/CyberReboot/vent/blob/9956a09146b11a89a0eabab3bc7ce8906d124885/vent/extras/rmq_es_connector/rmq_es_connector.py#L104-L108
def consume(self): # pragma: no cover """ start consuming rabbitmq messages """ print(' [*] Waiting for logs. To exit press CTRL+C') self.channel.basic_consume(self.queue_name, self.callback) self.channel.start_consuming()
[ "def", "consume", "(", "self", ")", ":", "# pragma: no cover", "print", "(", "' [*] Waiting for logs. To exit press CTRL+C'", ")", "self", ".", "channel", ".", "basic_consume", "(", "self", ".", "queue_name", ",", "self", ".", "callback", ")", "self", ".", "chan...
start consuming rabbitmq messages
[ "start", "consuming", "rabbitmq", "messages" ]
python
train
50.2
common-workflow-language/schema_salad
schema_salad/schema.py
https://github.com/common-workflow-language/schema_salad/blob/608ba207b9058fe0a9c3db161058ab3782eef015/schema_salad/schema.py#L381-L426
def replace_type(items, spec, loader, found, find_embeds=True, deepen=True): # type: (Any, Dict[Text, Any], Loader, Set[Text], bool, bool) -> Any """ Go through and replace types in the 'spec' mapping""" if isinstance(items, MutableMapping): # recursively check these fields for types to replace ...
[ "def", "replace_type", "(", "items", ",", "spec", ",", "loader", ",", "found", ",", "find_embeds", "=", "True", ",", "deepen", "=", "True", ")", ":", "# type: (Any, Dict[Text, Any], Loader, Set[Text], bool, bool) -> Any", "if", "isinstance", "(", "items", ",", "Mu...
Go through and replace types in the 'spec' mapping
[ "Go", "through", "and", "replace", "types", "in", "the", "spec", "mapping" ]
python
train
39.130435
dourvaris/nano-python
src/nano/rpc.py
https://github.com/dourvaris/nano-python/blob/f26b8bc895b997067780f925049a70e82c0c2479/src/nano/rpc.py#L2238-L2266
def wallet_balance_total(self, wallet): """ Returns the sum of all accounts balances in **wallet** :param wallet: Wallet to return sum of balances for :type wallet: str :raises: :py:exc:`nano.rpc.RPCException` >>> rpc.wallet_balance_total( ... wallet="000D1...
[ "def", "wallet_balance_total", "(", "self", ",", "wallet", ")", ":", "wallet", "=", "self", ".", "_process_value", "(", "wallet", ",", "'wallet'", ")", "payload", "=", "{", "\"wallet\"", ":", "wallet", "}", "resp", "=", "self", ".", "call", "(", "'wallet...
Returns the sum of all accounts balances in **wallet** :param wallet: Wallet to return sum of balances for :type wallet: str :raises: :py:exc:`nano.rpc.RPCException` >>> rpc.wallet_balance_total( ... wallet="000D1BAEC8EC208142C99059B393051BAC8380F9B5A2E6B2489A277D81789F3F"...
[ "Returns", "the", "sum", "of", "all", "accounts", "balances", "in", "**", "wallet", "**" ]
python
train
23.862069
roboogle/gtkmvc3
gtkmvco/examples/custom_widget/htmltextview.py
https://github.com/roboogle/gtkmvc3/blob/63405fd8d2056be26af49103b13a8d5e57fe4dff/gtkmvco/examples/custom_widget/htmltextview.py#L42-L48
def _parse_css_color(color): '''_parse_css_color(css_color) -> gtk.gdk.Color''' if color.startswith("rgb(") and color.endswith(')'): r, g, b = [int(c)*257 for c in color[4:-1].split(',')] return gtk.gdk.Color(r, g, b) else: return gtk.gdk.color_parse(color)
[ "def", "_parse_css_color", "(", "color", ")", ":", "if", "color", ".", "startswith", "(", "\"rgb(\"", ")", "and", "color", ".", "endswith", "(", "')'", ")", ":", "r", ",", "g", ",", "b", "=", "[", "int", "(", "c", ")", "*", "257", "for", "c", "...
_parse_css_color(css_color) -> gtk.gdk.Color
[ "_parse_css_color", "(", "css_color", ")", "-", ">", "gtk", ".", "gdk", ".", "Color" ]
python
train
41
pyviz/holoviews
holoviews/core/spaces.py
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/core/spaces.py#L181-L225
def _dynamic_mul(self, dimensions, other, keys): """ Implements dynamic version of overlaying operation overlaying DynamicMaps and HoloMaps where the key dimensions of one is a strict superset of the other. """ # If either is a HoloMap compute Dimension values if ...
[ "def", "_dynamic_mul", "(", "self", ",", "dimensions", ",", "other", ",", "keys", ")", ":", "# If either is a HoloMap compute Dimension values", "if", "not", "isinstance", "(", "self", ",", "DynamicMap", ")", "or", "not", "isinstance", "(", "other", ",", "Dynami...
Implements dynamic version of overlaying operation overlaying DynamicMaps and HoloMaps where the key dimensions of one is a strict superset of the other.
[ "Implements", "dynamic", "version", "of", "overlaying", "operation", "overlaying", "DynamicMaps", "and", "HoloMaps", "where", "the", "key", "dimensions", "of", "one", "is", "a", "strict", "superset", "of", "the", "other", "." ]
python
train
44.422222
econ-ark/HARK
HARK/FashionVictim/FashionVictimModel.py
https://github.com/econ-ark/HARK/blob/3d184153a189e618a87c9540df1cd12044039cc5/HARK/FashionVictim/FashionVictimModel.py#L239-L263
def simOnePrd(self): ''' Simulate one period of the fashion victom model for this type. Each agent receives an idiosyncratic preference shock and chooses whether to change styles (using the optimal decision rule). Parameters ---------- none Returns ...
[ "def", "simOnePrd", "(", "self", ")", ":", "pNow", "=", "self", ".", "pNow", "sPrev", "=", "self", ".", "sNow", "J2Pprob", "=", "self", ".", "switchFuncJock", "(", "pNow", ")", "P2Jprob", "=", "self", ".", "switchFuncPunk", "(", "pNow", ")", "Shks", ...
Simulate one period of the fashion victom model for this type. Each agent receives an idiosyncratic preference shock and chooses whether to change styles (using the optimal decision rule). Parameters ---------- none Returns ------- none
[ "Simulate", "one", "period", "of", "the", "fashion", "victom", "model", "for", "this", "type", ".", "Each", "agent", "receives", "an", "idiosyncratic", "preference", "shock", "and", "chooses", "whether", "to", "change", "styles", "(", "using", "the", "optimal"...
python
train
29.68
esterhui/pypu
pypu/service_facebook.py
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L113-L132
def _update_config(self,directory,filename): """Manages FB config files""" basefilename=os.path.splitext(filename)[0] ext=os.path.splitext(filename)[1].lower() #if filename==LOCATION_FILE: #return self._update_config_location(directory) #FIXME #elif filename==...
[ "def", "_update_config", "(", "self", ",", "directory", ",", "filename", ")", ":", "basefilename", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "[", "0", "]", "ext", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "["...
Manages FB config files
[ "Manages", "FB", "config", "files" ]
python
train
45.3
openwisp/django-freeradius
django_freeradius/base/models.py
https://github.com/openwisp/django-freeradius/blob/a9dd0710327eb33b49dd01097fc3b76048894963/django_freeradius/base/models.py#L524-L531
def set_default(self): """ ensures there's only 1 default group (logic overridable via custom models) """ queryset = self.get_default_queryset() if queryset.exists(): queryset.update(default=False)
[ "def", "set_default", "(", "self", ")", ":", "queryset", "=", "self", ".", "get_default_queryset", "(", ")", "if", "queryset", ".", "exists", "(", ")", ":", "queryset", ".", "update", "(", "default", "=", "False", ")" ]
ensures there's only 1 default group (logic overridable via custom models)
[ "ensures", "there", "s", "only", "1", "default", "group", "(", "logic", "overridable", "via", "custom", "models", ")" ]
python
train
31.25
azogue/dataweb
dataweb/requestweb/__init__.py
https://github.com/azogue/dataweb/blob/085035855df7cef0fe7725bbe9a706832344d946/dataweb/requestweb/__init__.py#L99-L227
def get_data_en_intervalo(d0=None, df=None, date_fmt=DATE_FMT, usar_multithread=USAR_MULTITHREAD, max_threads_requests=MAX_THREADS_REQUESTS, timeout=TIMEOUT, num_retries=NUM_RETRIES, func_procesa_data_dia=None, func_url_data_dia=None, max_act...
[ "def", "get_data_en_intervalo", "(", "d0", "=", "None", ",", "df", "=", "None", ",", "date_fmt", "=", "DATE_FMT", ",", "usar_multithread", "=", "USAR_MULTITHREAD", ",", "max_threads_requests", "=", "MAX_THREADS_REQUESTS", ",", "timeout", "=", "TIMEOUT", ",", "nu...
Obtiene los datos en bruto de la red realizando múltiples requests al tiempo Procesa los datos en bruto obtenidos de la red convirtiendo a Pandas DataFrame
[ "Obtiene", "los", "datos", "en", "bruto", "de", "la", "red", "realizando", "múltiples", "requests", "al", "tiempo", "Procesa", "los", "datos", "en", "bruto", "obtenidos", "de", "la", "red", "convirtiendo", "a", "Pandas", "DataFrame" ]
python
train
54.674419
mcieslik-mctp/papy
src/papy/graph.py
https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/graph.py#L451-L467
def outgoing_edges(self, node): """ Returns a ``tuple`` of outgoing edges for a **node object**. Arguments: - node(``object``) **node object** present in the graph to be queried for outgoing edges. """ #TODO: pls make outgoig_ed...
[ "def", "outgoing_edges", "(", "self", ",", "node", ")", ":", "#TODO: pls make outgoig_edges less insane", "edges", "=", "self", ".", "edges", "(", ")", "out_edges", "=", "[", "]", "for", "out_node", ",", "in_node", "in", "edges", ":", "if", "node", "is", "...
Returns a ``tuple`` of outgoing edges for a **node object**. Arguments: - node(``object``) **node object** present in the graph to be queried for outgoing edges.
[ "Returns", "a", "tuple", "of", "outgoing", "edges", "for", "a", "**", "node", "object", "**", ".", "Arguments", ":", "-", "node", "(", "object", ")", "**", "node", "object", "**", "present", "in", "the", "graph", "to", "be", "queried", "for", "outgoing...
python
train
31.176471
atl/py-smartdc
smartdc/machine.py
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/machine.py#L462-L477
def delete_all_metadata(self): """ :: DELETE /:login/machines/:id/metadata :Returns: current metadata :rtype: empty :py:class:`dict` Deletes all the metadata stored for this machine. Also explicitly requests and returns the machine ...
[ "def", "delete_all_metadata", "(", "self", ")", ":", "j", ",", "r", "=", "self", ".", "datacenter", ".", "request", "(", "'DELETE'", ",", "self", ".", "path", "+", "'/metadata'", ")", "r", ".", "raise_for_status", "(", ")", "return", "self", ".", "get_...
:: DELETE /:login/machines/:id/metadata :Returns: current metadata :rtype: empty :py:class:`dict` Deletes all the metadata stored for this machine. Also explicitly requests and returns the machine metadata so that the local copy stays sync...
[ "::", "DELETE", "/", ":", "login", "/", "machines", "/", ":", "id", "/", "metadata", ":", "Returns", ":", "current", "metadata", ":", "rtype", ":", "empty", ":", "py", ":", "class", ":", "dict", "Deletes", "all", "the", "metadata", "stored", "for", "...
python
train
32.1875
iotile/coretools
iotileemulate/iotile/emulate/virtual/peripheral_tile.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotileemulate/iotile/emulate/virtual/peripheral_tile.py#L95-L107
def _handle_reset(self): """Reset this tile. This process needs to trigger the peripheral tile to reregister itself with the controller and get new configuration variables. It also needs to clear app_running. """ self._registered.clear() self._start_received.cl...
[ "def", "_handle_reset", "(", "self", ")", ":", "self", ".", "_registered", ".", "clear", "(", ")", "self", ".", "_start_received", ".", "clear", "(", ")", "self", ".", "_hosted_app_running", ".", "clear", "(", ")", "super", "(", "EmulatedPeripheralTile", "...
Reset this tile. This process needs to trigger the peripheral tile to reregister itself with the controller and get new configuration variables. It also needs to clear app_running.
[ "Reset", "this", "tile", "." ]
python
train
31.923077
emlazzarin/acrylic
acrylic/datatable.py
https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L815-L820
def wheregreater(self, fieldname, value): """ Returns a new DataTable with rows only where the value at `fieldname` > `value`. """ return self.mask([elem > value for elem in self[fieldname]])
[ "def", "wheregreater", "(", "self", ",", "fieldname", ",", "value", ")", ":", "return", "self", ".", "mask", "(", "[", "elem", ">", "value", "for", "elem", "in", "self", "[", "fieldname", "]", "]", ")" ]
Returns a new DataTable with rows only where the value at `fieldname` > `value`.
[ "Returns", "a", "new", "DataTable", "with", "rows", "only", "where", "the", "value", "at", "fieldname", ">", "value", "." ]
python
train
37.666667
saltstack/salt
salt/proxy/ssh_sample.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/ssh_sample.py#L150-L162
def package_install(name, **kwargs): ''' Install a "package" on the ssh server ''' cmd = 'pkg_install ' + name if kwargs.get('version', False): cmd += ' ' + kwargs['version'] # Send the command to execute out, err = DETAILS['server'].sendline(cmd) # "scrape" the output and retu...
[ "def", "package_install", "(", "name", ",", "*", "*", "kwargs", ")", ":", "cmd", "=", "'pkg_install '", "+", "name", "if", "kwargs", ".", "get", "(", "'version'", ",", "False", ")", ":", "cmd", "+=", "' '", "+", "kwargs", "[", "'version'", "]", "# Se...
Install a "package" on the ssh server
[ "Install", "a", "package", "on", "the", "ssh", "server" ]
python
train
27.615385
Garee/pytodoist
pytodoist/todoist.py
https://github.com/Garee/pytodoist/blob/3359cbff485ebdbbb4ffbd58d71e21a817874dd7/pytodoist/todoist.py#L377-L386
def _sync_notes(self, notes_json): """"Populate the user's notes from a JSON encoded list.""" for note_json in notes_json: note_id = note_json['id'] task_id = note_json['item_id'] if task_id not in self.tasks: # ignore orphan notes cont...
[ "def", "_sync_notes", "(", "self", ",", "notes_json", ")", ":", "for", "note_json", "in", "notes_json", ":", "note_id", "=", "note_json", "[", "'id'", "]", "task_id", "=", "note_json", "[", "'item_id'", "]", "if", "task_id", "not", "in", "self", ".", "ta...
Populate the user's notes from a JSON encoded list.
[ "Populate", "the", "user", "s", "notes", "from", "a", "JSON", "encoded", "list", "." ]
python
train
41
xtrementl/focus
focus/task.py
https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/task.py#L205-L248
def create(self, task_name, clone_task=None): """ Creates a new task directory. `task_name` Task name. `clone_task` Existing task name to use as a template for new task. Returns boolean. * Raises ``Value`` if task name is invalid...
[ "def", "create", "(", "self", ",", "task_name", ",", "clone_task", "=", "None", ")", ":", "if", "not", "task_name", "or", "task_name", ".", "startswith", "(", "'-'", ")", ":", "raise", "ValueError", "(", "'Invalid task name'", ")", "try", ":", "task_dir", ...
Creates a new task directory. `task_name` Task name. `clone_task` Existing task name to use as a template for new task. Returns boolean. * Raises ``Value`` if task name is invalid, ``TaskExists`` if task already exists, or ...
[ "Creates", "a", "new", "task", "directory", "." ]
python
train
29.295455
Kozea/pygal
pygal/svg.py
https://github.com/Kozea/pygal/blob/5e25c98a59a0642eecd9fcc5dbfeeb2190fbb5e7/pygal/svg.py#L87-L131
def add_styles(self): """Add the css to the svg""" colors = self.graph.style.get_colors(self.id, self.graph._order) strokes = self.get_strokes() all_css = [] auto_css = ['file://base.css'] if self.graph.style._google_fonts: auto_css.append( '/...
[ "def", "add_styles", "(", "self", ")", ":", "colors", "=", "self", ".", "graph", ".", "style", ".", "get_colors", "(", "self", ".", "id", ",", "self", ".", "graph", ".", "_order", ")", "strokes", "=", "self", ".", "get_strokes", "(", ")", "all_css", ...
Add the css to the svg
[ "Add", "the", "css", "to", "the", "svg" ]
python
train
37.511111
theislab/scanpy
scanpy/neighbors/__init__.py
https://github.com/theislab/scanpy/blob/9e4e5ee02e04cf618872d9b098e24f0542e8b227/scanpy/neighbors/__init__.py#L765-L818
def compute_eigen(self, n_comps=15, sym=None, sort='decrease'): """Compute eigen decomposition of transition matrix. Parameters ---------- n_comps : `int` Number of eigenvalues/vectors to be computed, set `n_comps = 0` if you need all eigenvectors. sym : ...
[ "def", "compute_eigen", "(", "self", ",", "n_comps", "=", "15", ",", "sym", "=", "None", ",", "sort", "=", "'decrease'", ")", ":", "np", ".", "set_printoptions", "(", "precision", "=", "10", ")", "if", "self", ".", "_transitions_sym", "is", "None", ":"...
Compute eigen decomposition of transition matrix. Parameters ---------- n_comps : `int` Number of eigenvalues/vectors to be computed, set `n_comps = 0` if you need all eigenvectors. sym : `bool` Instead of computing the eigendecomposition of the assym...
[ "Compute", "eigen", "decomposition", "of", "transition", "matrix", "." ]
python
train
45.351852
estnltk/estnltk
estnltk/wordnet/eurown.py
https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/wordnet/eurown.py#L1739-L1748
def addUsage_Label(self,usage_label): '''Appends one Usage_Label to usage_labels ''' if isinstance(usage_label, Usage_Label): self.usage_labels.append(usage_label) else: raise (Usage_LabelError, 'usage_label Type should be Usage_Label, not %s' %...
[ "def", "addUsage_Label", "(", "self", ",", "usage_label", ")", ":", "if", "isinstance", "(", "usage_label", ",", "Usage_Label", ")", ":", "self", ".", "usage_labels", ".", "append", "(", "usage_label", ")", "else", ":", "raise", "(", "Usage_LabelError", ",",...
Appends one Usage_Label to usage_labels
[ "Appends", "one", "Usage_Label", "to", "usage_labels" ]
python
train
37.1
benjamin-hodgson/asynqp
src/asynqp/__init__.py
https://github.com/benjamin-hodgson/asynqp/blob/ea8630d1803d10d4fd64b1a0e50f3097710b34d1/src/asynqp/__init__.py#L22-L86
def connect(host='localhost', port=5672, username='guest', password='guest', virtual_host='/', on_connection_close=None, *, loop=None, sock=None, **kwargs): """ Connect to an AMQP server on the given host and port. Log in to the given virtual host...
[ "def", "connect", "(", "host", "=", "'localhost'", ",", "port", "=", "5672", ",", "username", "=", "'guest'", ",", "password", "=", "'guest'", ",", "virtual_host", "=", "'/'", ",", "on_connection_close", "=", "None", ",", "*", ",", "loop", "=", "None", ...
Connect to an AMQP server on the given host and port. Log in to the given virtual host using the supplied credentials. This function is a :ref:`coroutine <coroutine>`. :param str host: the host server to connect to. :param int port: the port which the AMQP server is listening on. :param str userna...
[ "Connect", "to", "an", "AMQP", "server", "on", "the", "given", "host", "and", "port", "." ]
python
train
42.984615
hatemile/hatemile-for-python
hatemile/implementation/css.py
https://github.com/hatemile/hatemile-for-python/blob/1e914f9aa09f6f8d78282af131311546ecba9fb8/hatemile/implementation/css.py#L568-L587
def _create_aural_content_element(self, content, data_property_value): """ Create a element to show the content, only to aural displays. :param content: The text content of element. :type content: str :param data_property_value: The value of custom attribute used to ...
[ "def", "_create_aural_content_element", "(", "self", ",", "content", ",", "data_property_value", ")", ":", "content_element", "=", "self", ".", "_create_content_element", "(", "content", ",", "data_property_value", ")", "content_element", ".", "set_attribute", "(", "'...
Create a element to show the content, only to aural displays. :param content: The text content of element. :type content: str :param data_property_value: The value of custom attribute used to identify the fix. :type data_property_value: str :r...
[ "Create", "a", "element", "to", "show", "the", "content", "only", "to", "aural", "displays", "." ]
python
train
39.4
gwastro/pycbc-glue
pycbc_glue/ligolw/utils/ligolw_add.py
https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/ligolw/utils/ligolw_add.py#L111-L125
def merge_ligolws(elem): """ Merge all LIGO_LW elements that are immediate children of elem by appending their children to the first. """ ligolws = [child for child in elem.childNodes if child.tagName == ligolw.LIGO_LW.tagName] if ligolws: dest = ligolws.pop(0) for src in ligolws: # copy children; LIGO_LW...
[ "def", "merge_ligolws", "(", "elem", ")", ":", "ligolws", "=", "[", "child", "for", "child", "in", "elem", ".", "childNodes", "if", "child", ".", "tagName", "==", "ligolw", ".", "LIGO_LW", ".", "tagName", "]", "if", "ligolws", ":", "dest", "=", "ligolw...
Merge all LIGO_LW elements that are immediate children of elem by appending their children to the first.
[ "Merge", "all", "LIGO_LW", "elements", "that", "are", "immediate", "children", "of", "elem", "by", "appending", "their", "children", "to", "the", "first", "." ]
python
train
32.133333
pingali/dgit
dgitcore/datasets/history.py
https://github.com/pingali/dgit/blob/ecde01f40b98f0719dbcfb54452270ed2f86686d/dgitcore/datasets/history.py#L196-L278
def get_diffs(history): """ Look at files and compute the diffs intelligently """ # First get all possible representations mgr = plugins_get_mgr() keys = mgr.search('representation')['representation'] representations = [mgr.get_by_key('representation', k) for k in keys] for i in range...
[ "def", "get_diffs", "(", "history", ")", ":", "# First get all possible representations", "mgr", "=", "plugins_get_mgr", "(", ")", "keys", "=", "mgr", ".", "search", "(", "'representation'", ")", "[", "'representation'", "]", "representations", "=", "[", "mgr", ...
Look at files and compute the diffs intelligently
[ "Look", "at", "files", "and", "compute", "the", "diffs", "intelligently" ]
python
valid
33.578313
renatopp/liac-arff
arff.py
https://github.com/renatopp/liac-arff/blob/6771f4cdd13d0eca74d3ebbaa6290297dd0a381d/arff.py#L484-L512
def encode_data(self, data, attributes): '''(INTERNAL) Encodes a line of data. Data instances follow the csv format, i.e, attribute values are delimited by commas. After converted from csv. :param data: a list of values. :param attributes: a list of attributes. Used to check if...
[ "def", "encode_data", "(", "self", ",", "data", ",", "attributes", ")", ":", "current_row", "=", "0", "for", "inst", "in", "data", ":", "if", "len", "(", "inst", ")", "!=", "len", "(", "attributes", ")", ":", "raise", "BadObject", "(", "'Instance %d ha...
(INTERNAL) Encodes a line of data. Data instances follow the csv format, i.e, attribute values are delimited by commas. After converted from csv. :param data: a list of values. :param attributes: a list of attributes. Used to check if data is valid. :return: a string with the e...
[ "(", "INTERNAL", ")", "Encodes", "a", "line", "of", "data", "." ]
python
train
33.896552
DallasMorningNews/django-datafreezer
datafreezer/views.py
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views.py#L388-L414
def home(request): """Renders Datafreezer homepage. Includes recent uploads.""" recent_uploads = Dataset.objects.order_by('-date_uploaded')[:11] email_list = [upload.uploaded_by.strip() for upload in recent_uploads] # print all_staff emails_names = grab_names_from_emails(email_list) # print em...
[ "def", "home", "(", "request", ")", ":", "recent_uploads", "=", "Dataset", ".", "objects", ".", "order_by", "(", "'-date_uploaded'", ")", "[", ":", "11", "]", "email_list", "=", "[", "upload", ".", "uploaded_by", ".", "strip", "(", ")", "for", "upload", ...
Renders Datafreezer homepage. Includes recent uploads.
[ "Renders", "Datafreezer", "homepage", ".", "Includes", "recent", "uploads", "." ]
python
train
29.037037
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_genobstacles.py
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_genobstacles.py#L93-L98
def move(self, bearing, distance): '''move position by bearing and distance''' lat = self.pkt['I105']['Lat']['val'] lon = self.pkt['I105']['Lon']['val'] (lat, lon) = mp_util.gps_newpos(lat, lon, bearing, distance) self.setpos(lat, lon)
[ "def", "move", "(", "self", ",", "bearing", ",", "distance", ")", ":", "lat", "=", "self", ".", "pkt", "[", "'I105'", "]", "[", "'Lat'", "]", "[", "'val'", "]", "lon", "=", "self", ".", "pkt", "[", "'I105'", "]", "[", "'Lon'", "]", "[", "'val'"...
move position by bearing and distance
[ "move", "position", "by", "bearing", "and", "distance" ]
python
train
45
CalebBell/fluids
fluids/units.py
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/units.py#L51-L58
def func_args(func): '''Basic function which returns a tuple of arguments of a function or method. ''' try: return tuple(inspect.signature(func).parameters) except: return tuple(inspect.getargspec(func).args)
[ "def", "func_args", "(", "func", ")", ":", "try", ":", "return", "tuple", "(", "inspect", ".", "signature", "(", "func", ")", ".", "parameters", ")", "except", ":", "return", "tuple", "(", "inspect", ".", "getargspec", "(", "func", ")", ".", "args", ...
Basic function which returns a tuple of arguments of a function or method.
[ "Basic", "function", "which", "returns", "a", "tuple", "of", "arguments", "of", "a", "function", "or", "method", "." ]
python
train
29.625
junzis/pyModeS
pyModeS/decoder/bds/bds05.py
https://github.com/junzis/pyModeS/blob/8cd5655a04b08171a9ad5f1ffd232b7e0178ea53/pyModeS/decoder/bds/bds05.py#L132-L161
def altitude(msg): """Decode aircraft altitude Args: msg (string): 28 bytes hexadecimal message string Returns: int: altitude in feet """ tc = common.typecode(msg) if tc<9 or tc==19 or tc>22: raise RuntimeError("%s: Not a airborn position message" % msg) mb = com...
[ "def", "altitude", "(", "msg", ")", ":", "tc", "=", "common", ".", "typecode", "(", "msg", ")", "if", "tc", "<", "9", "or", "tc", "==", "19", "or", "tc", ">", "22", ":", "raise", "RuntimeError", "(", "\"%s: Not a airborn position message\"", "%", "msg"...
Decode aircraft altitude Args: msg (string): 28 bytes hexadecimal message string Returns: int: altitude in feet
[ "Decode", "aircraft", "altitude" ]
python
train
20.9
django-admin-tools/django-admin-tools
admin_tools/dashboard/modules.py
https://github.com/django-admin-tools/django-admin-tools/blob/ba6f46f51ebd84fcf84f2f79ec9487f45452d79b/admin_tools/dashboard/modules.py#L251-L275
def is_empty(self): """ A group of modules is considered empty if it has no children or if all its children are empty. >>> from admin_tools.dashboard.modules import DashboardModule, LinkList >>> mod = Group() >>> mod.is_empty() True >>> mod.children.appen...
[ "def", "is_empty", "(", "self", ")", ":", "if", "super", "(", "Group", ",", "self", ")", ".", "is_empty", "(", ")", ":", "return", "True", "for", "child", "in", "self", ".", "children", ":", "if", "not", "child", ".", "is_empty", "(", ")", ":", "...
A group of modules is considered empty if it has no children or if all its children are empty. >>> from admin_tools.dashboard.modules import DashboardModule, LinkList >>> mod = Group() >>> mod.is_empty() True >>> mod.children.append(DashboardModule()) >>> mod.is_...
[ "A", "group", "of", "modules", "is", "considered", "empty", "if", "it", "has", "no", "children", "or", "if", "all", "its", "children", "are", "empty", "." ]
python
train
32.32
materialsproject/pymatgen
pymatgen/analysis/defects/corrections.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/defects/corrections.py#L249-L283
def plot(self, axis, title=None, saved=False): """ Plots the planar average electrostatic potential against the Long range and short range models from Freysoldt """ x = self.metadata['pot_plot_data'][axis]['x'] v_R = self.metadata['pot_plot_data'][axis]['Vr'] dft_diff =...
[ "def", "plot", "(", "self", ",", "axis", ",", "title", "=", "None", ",", "saved", "=", "False", ")", ":", "x", "=", "self", ".", "metadata", "[", "'pot_plot_data'", "]", "[", "axis", "]", "[", "'x'", "]", "v_R", "=", "self", ".", "metadata", "[",...
Plots the planar average electrostatic potential against the Long range and short range models from Freysoldt
[ "Plots", "the", "planar", "average", "electrostatic", "potential", "against", "the", "Long", "range", "and", "short", "range", "models", "from", "Freysoldt" ]
python
train
42.628571
Nic30/hwt
hwt/hdl/frameTmplUtils.py
https://github.com/Nic30/hwt/blob/8cbb399e326da3b22c233b98188a9d08dec057e6/hwt/hdl/frameTmplUtils.py#L222-L247
def groupByWordIndex(self, transaction: 'TransTmpl', offset: int): """ Group transaction parts splited on words to words :param transaction: TransTmpl instance which parts should be grupped into words :return: generator of tuples (wordIndex, list of transaction parts ...
[ "def", "groupByWordIndex", "(", "self", ",", "transaction", ":", "'TransTmpl'", ",", "offset", ":", "int", ")", ":", "actualW", "=", "None", "partsInWord", "=", "[", "]", "wordWidth", "=", "self", ".", "wordWidth", "for", "item", "in", "self", ".", "spli...
Group transaction parts splited on words to words :param transaction: TransTmpl instance which parts should be grupped into words :return: generator of tuples (wordIndex, list of transaction parts in this word)
[ "Group", "transaction", "parts", "splited", "on", "words", "to", "words" ]
python
test
35
Asana/python-asana
asana/client.py
https://github.com/Asana/python-asana/blob/6deb7a34495db23f44858e53b6bb2c9eccff7872/asana/client.py#L187-L208
def _parse_api_options(self, options, query_string=False): """Select API options out of the provided options object. Selects API string options out of the provided options object and formats for either request body (default) or query string. """ api_options = self._select_optio...
[ "def", "_parse_api_options", "(", "self", ",", "options", ",", "query_string", "=", "False", ")", ":", "api_options", "=", "self", ".", "_select_options", "(", "options", ",", "self", ".", "API_OPTIONS", ")", "if", "query_string", ":", "# Prefix all options with...
Select API options out of the provided options object. Selects API string options out of the provided options object and formats for either request body (default) or query string.
[ "Select", "API", "options", "out", "of", "the", "provided", "options", "object", "." ]
python
train
41.136364
shoyer/h5netcdf
h5netcdf/_chainmap.py
https://github.com/shoyer/h5netcdf/blob/3ae35cd58297281a1dc69c46fb0b315a0007ac2b/h5netcdf/_chainmap.py#L131-L136
def pop(self, key, *args): 'Remove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].' try: return self.maps[0].pop(key, *args) except KeyError: raise KeyError('Key not found in the first mapping: {!r}'.format(key))
[ "def", "pop", "(", "self", ",", "key", ",", "*", "args", ")", ":", "try", ":", "return", "self", ".", "maps", "[", "0", "]", ".", "pop", "(", "key", ",", "*", "args", ")", "except", "KeyError", ":", "raise", "KeyError", "(", "'Key not found in the ...
Remove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].
[ "Remove", "*", "key", "*", "from", "maps", "[", "0", "]", "and", "return", "its", "value", ".", "Raise", "KeyError", "if", "*", "key", "*", "not", "in", "maps", "[", "0", "]", "." ]
python
train
48
bram85/topydo
topydo/ui/cli/CLI.py
https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/ui/cli/CLI.py#L45-L64
def run(self): """ Main entry function. """ args = self._process_flags() self.todofile = TodoFile.TodoFile(config().todotxt()) self.todolist = TodoList.TodoList(self.todofile.read()) try: (subcommand, args) = get_subcommand(args) except ConfigError as ce: ...
[ "def", "run", "(", "self", ")", ":", "args", "=", "self", ".", "_process_flags", "(", ")", "self", ".", "todofile", "=", "TodoFile", ".", "TodoFile", "(", "config", "(", ")", ".", "todotxt", "(", ")", ")", "self", ".", "todolist", "=", "TodoList", ...
Main entry function.
[ "Main", "entry", "function", "." ]
python
train
29.85
opereto/pyopereto
pyopereto/client.py
https://github.com/opereto/pyopereto/blob/16ca987738a7e1b82b52b0b099794a74ed557223/pyopereto/client.py#L802-L819
def modify_agent_properties(self, agent_id, key_value_map={}): ''' modify_agent_properties(self, agent_id, key_value_map={}) Modify properties of an agent. If properties do not exists, they will be created :Parameters: * *agent_id* (`string`) -- Identifier of an existing agent ...
[ "def", "modify_agent_properties", "(", "self", ",", "agent_id", ",", "key_value_map", "=", "{", "}", ")", ":", "return", "self", ".", "_call_rest_api", "(", "'post'", ",", "'/agents/'", "+", "agent_id", "+", "'/properties'", ",", "data", "=", "key_value_map", ...
modify_agent_properties(self, agent_id, key_value_map={}) Modify properties of an agent. If properties do not exists, they will be created :Parameters: * *agent_id* (`string`) -- Identifier of an existing agent * *key_value_map* (`object`) -- Key value map of properties to change ...
[ "modify_agent_properties", "(", "self", "agent_id", "key_value_map", "=", "{}", ")" ]
python
train
43.111111
tanghaibao/jcvi
jcvi/annotation/pasa.py
https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/annotation/pasa.py#L336-L507
def consolidate(args): """ %prog consolidate gffile1 gffile2 ... > consolidated.out Given 2 or more gff files generated by pasa annotation comparison, iterate through each locus (shared locus name or overlapping CDS) and identify same/different isoforms (shared splicing structure) across the in...
[ "def", "consolidate", "(", "args", ")", ":", "from", "jcvi", ".", "formats", ".", "base", "import", "longest_unique_prefix", "from", "jcvi", ".", "formats", ".", "gff", "import", "make_index", ",", "match_subfeats", "from", "jcvi", ".", "utils", ".", "cbook"...
%prog consolidate gffile1 gffile2 ... > consolidated.out Given 2 or more gff files generated by pasa annotation comparison, iterate through each locus (shared locus name or overlapping CDS) and identify same/different isoforms (shared splicing structure) across the input datasets. If `slop` is ena...
[ "%prog", "consolidate", "gffile1", "gffile2", "...", ">", "consolidated", ".", "out" ]
python
train
41.726744
rdussurget/py-altimetry
altimetry/tools/interp_tools.py
https://github.com/rdussurget/py-altimetry/blob/57ce7f2d63c6bbc4993821af0bbe46929e3a2d98/altimetry/tools/interp_tools.py#L88-L114
def interp1d(x,Z,xout,spline=False,kind='linear',fill_value=np.NaN,**kwargs): """ INTERP1D : Interpolate values from a 1D vector at given positions @param x: 1st dimension vector of size NX @author: Renaud DUSSURGET, LER/PAC, Ifremer La Seyne """ linear = not spline ...
[ "def", "interp1d", "(", "x", ",", "Z", ",", "xout", ",", "spline", "=", "False", ",", "kind", "=", "'linear'", ",", "fill_value", "=", "np", ".", "NaN", ",", "*", "*", "kwargs", ")", ":", "linear", "=", "not", "spline", "nx", "=", "len", "(", "...
INTERP1D : Interpolate values from a 1D vector at given positions @param x: 1st dimension vector of size NX @author: Renaud DUSSURGET, LER/PAC, Ifremer La Seyne
[ "INTERP1D", ":", "Interpolate", "values", "from", "a", "1D", "vector", "at", "given", "positions" ]
python
train
28.62963
seomoz/shovel
shovel/args.py
https://github.com/seomoz/shovel/blob/fc29232b2b8be33972f8fb498a91a67e334f057f/shovel/args.py#L69-L81
def explain(self, *args, **kwargs): '''Return a string that describes how these args are interpreted''' args = self.get(*args, **kwargs) results = ['%s = %s' % (name, value) for name, value in args.required] results.extend(['%s = %s (overridden)' % ( name, value) for name, va...
[ "def", "explain", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "args", "=", "self", ".", "get", "(", "*", "args", ",", "*", "*", "kwargs", ")", "results", "=", "[", "'%s = %s'", "%", "(", "name", ",", "value", ")", "for", ...
Return a string that describes how these args are interpreted
[ "Return", "a", "string", "that", "describes", "how", "these", "args", "are", "interpreted" ]
python
train
51.230769
wtsi-hgi/python-git-subrepo
gitsubrepo/subrepo.py
https://github.com/wtsi-hgi/python-git-subrepo/blob/bb2eb2bd9a7e51b862298ddb4168cc5b8633dad0/gitsubrepo/subrepo.py#L144-L159
def pull(directory: str) -> Commit: """ Pulls the subrepo that has been cloned into the given directory. :param directory: the directory containing the subrepo :return: the commit the subrepo is on """ if not os.path.exists(directory): raise ValueError(f"No subrepo found in \"{directory}...
[ "def", "pull", "(", "directory", ":", "str", ")", "->", "Commit", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "directory", ")", ":", "raise", "ValueError", "(", "f\"No subrepo found in \\\"{directory}\\\"\"", ")", "try", ":", "result", "=", "r...
Pulls the subrepo that has been cloned into the given directory. :param directory: the directory containing the subrepo :return: the commit the subrepo is on
[ "Pulls", "the", "subrepo", "that", "has", "been", "cloned", "into", "the", "given", "directory", ".", ":", "param", "directory", ":", "the", "directory", "containing", "the", "subrepo", ":", "return", ":", "the", "commit", "the", "subrepo", "is", "on" ]
python
train
47.4375
frictionlessdata/tableschema-sql-py
tableschema_sql/storage.py
https://github.com/frictionlessdata/tableschema-sql-py/blob/81ca4b564f6dac5fe3adc6553b353826190df6f8/tableschema_sql/storage.py#L144-L160
def describe(self, bucket, descriptor=None): """https://github.com/frictionlessdata/tableschema-sql-py#storage """ # Set descriptor if descriptor is not None: self.__descriptors[bucket] = descriptor # Get descriptor else: descriptor = self.__desc...
[ "def", "describe", "(", "self", ",", "bucket", ",", "descriptor", "=", "None", ")", ":", "# Set descriptor", "if", "descriptor", "is", "not", "None", ":", "self", ".", "__descriptors", "[", "bucket", "]", "=", "descriptor", "# Get descriptor", "else", ":", ...
https://github.com/frictionlessdata/tableschema-sql-py#storage
[ "https", ":", "//", "github", ".", "com", "/", "frictionlessdata", "/", "tableschema", "-", "sql", "-", "py#storage" ]
python
train
34.411765
gem/oq-engine
openquake/hazardlib/shakemap.py
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/shakemap.py#L278-L317
def to_gmfs(shakemap, spatialcorr, crosscorr, site_effects, trunclevel, num_gmfs, seed, imts=None): """ :returns: (IMT-strings, array of GMFs of shape (R, N, E, M) """ N = len(shakemap) # number of sites std = shakemap['std'] if imts is None or len(imts) == 0: imts = std.dty...
[ "def", "to_gmfs", "(", "shakemap", ",", "spatialcorr", ",", "crosscorr", ",", "site_effects", ",", "trunclevel", ",", "num_gmfs", ",", "seed", ",", "imts", "=", "None", ")", ":", "N", "=", "len", "(", "shakemap", ")", "# number of sites", "std", "=", "sh...
:returns: (IMT-strings, array of GMFs of shape (R, N, E, M)
[ ":", "returns", ":", "(", "IMT", "-", "strings", "array", "of", "GMFs", "of", "shape", "(", "R", "N", "E", "M", ")" ]
python
train
45.775
cozy/python_cozy_management
cozy_management/monitor.py
https://github.com/cozy/python_cozy_management/blob/820cea58458ae3e067fa8cc2da38edbda4681dac/cozy_management/monitor.py#L36-L69
def status(app_name=None, only_cozy=False, as_boolean=False): '''Get apps status :param app_name: If pass app name return this app status :return: dict with all apps status or str with one app status ''' apps = {} # Get all apps status & slip them apps_status = subprocess.Popen('cozy-monito...
[ "def", "status", "(", "app_name", "=", "None", ",", "only_cozy", "=", "False", ",", "as_boolean", "=", "False", ")", ":", "apps", "=", "{", "}", "# Get all apps status & slip them", "apps_status", "=", "subprocess", ".", "Popen", "(", "'cozy-monitor status'", ...
Get apps status :param app_name: If pass app name return this app status :return: dict with all apps status or str with one app status
[ "Get", "apps", "status" ]
python
train
37.529412
saltstack/salt
salt/grains/junos.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/grains/junos.py#L30-L41
def _remove_complex_types(dictionary): ''' Linode-python is now returning some complex types that are not serializable by msgpack. Kill those. ''' for k, v in six.iteritems(dictionary): if isinstance(v, dict): dictionary[k] = _remove_complex_types(v) elif hasattr(v, 'to_...
[ "def", "_remove_complex_types", "(", "dictionary", ")", ":", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "dictionary", ")", ":", "if", "isinstance", "(", "v", ",", "dict", ")", ":", "dictionary", "[", "k", "]", "=", "_remove_complex_types",...
Linode-python is now returning some complex types that are not serializable by msgpack. Kill those.
[ "Linode", "-", "python", "is", "now", "returning", "some", "complex", "types", "that", "are", "not", "serializable", "by", "msgpack", ".", "Kill", "those", "." ]
python
train
32.583333
bitesofcode/projexui
projexui/widgets/xchartwidget/xchartwidgetitem.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchartwidget/xchartwidgetitem.py#L640-L647
def setKeyColor( self, key, color ): """ Sets the color used when rendering pie charts. :param key | <str> color | <QColor> """ self._keyColors[nativestring(key)] = QColor(color)
[ "def", "setKeyColor", "(", "self", ",", "key", ",", "color", ")", ":", "self", ".", "_keyColors", "[", "nativestring", "(", "key", ")", "]", "=", "QColor", "(", "color", ")" ]
Sets the color used when rendering pie charts. :param key | <str> color | <QColor>
[ "Sets", "the", "color", "used", "when", "rendering", "pie", "charts", ".", ":", "param", "key", "|", "<str", ">", "color", "|", "<QColor", ">" ]
python
train
31.75
ARMmbed/mbed-connector-api-python
mbed_connector_api/mbed_connector_api.py
https://github.com/ARMmbed/mbed-connector-api-python/blob/a5024a01dc67cc192c8bf7a70b251fcf0a3f279b/mbed_connector_api/mbed_connector_api.py#L373-L390
def deleteAllSubscriptions(self): ''' Delete all subscriptions on the domain (all endpoints, all resources) :return: successful ``.status_code`` / ``.is_done``. Check the ``.error`` :rtype: asyncResult ''' result = asyncResult() data = self._deleteURL("/subscriptions/") if data.status_code == 204: #i...
[ "def", "deleteAllSubscriptions", "(", "self", ")", ":", "result", "=", "asyncResult", "(", ")", "data", "=", "self", ".", "_deleteURL", "(", "\"/subscriptions/\"", ")", "if", "data", ".", "status_code", "==", "204", ":", "#immediate success", "result", ".", ...
Delete all subscriptions on the domain (all endpoints, all resources) :return: successful ``.status_code`` / ``.is_done``. Check the ``.error`` :rtype: asyncResult
[ "Delete", "all", "subscriptions", "on", "the", "domain", "(", "all", "endpoints", "all", "resources", ")", ":", "return", ":", "successful", ".", "status_code", "/", ".", "is_done", ".", "Check", "the", ".", "error", ":", "rtype", ":", "asyncResult" ]
python
train
30.833333
Toilal/rebulk
rebulk/chain.py
https://github.com/Toilal/rebulk/blob/7511a4671f2fd9493e3df1e5177b7656789069e8/rebulk/chain.py#L139-L156
def string(self, *pattern, **kwargs): """ Add string pattern :param pattern: :type pattern: :param kwargs: :type kwargs: :return: :rtype: """ set_defaults(self._kwargs, kwargs) set_defaults(self._functional_defaults, kwargs) ...
[ "def", "string", "(", "self", ",", "*", "pattern", ",", "*", "*", "kwargs", ")", ":", "set_defaults", "(", "self", ".", "_kwargs", ",", "kwargs", ")", "set_defaults", "(", "self", ".", "_functional_defaults", ",", "kwargs", ")", "set_defaults", "(", "sel...
Add string pattern :param pattern: :type pattern: :param kwargs: :type kwargs: :return: :rtype:
[ "Add", "string", "pattern" ]
python
train
27.555556
google/dotty
efilter/parsers/dottysql/parser.py
https://github.com/google/dotty/blob/b145131499be0c4b755fc2e2ac19be11a50bce6a/efilter/parsers/dottysql/parser.py#L666-L695
def application(self, func): """Parse the function application subgrammar. Function application can, conceptually, be thought of as a mixfix operator, similar to the way array subscripting works. However, it is not clear at this point whether we want to allow it to work as such, ...
[ "def", "application", "(", "self", ",", "func", ")", ":", "start", "=", "self", ".", "tokens", ".", "matched", ".", "start", "if", "self", ".", "tokens", ".", "accept", "(", "common_grammar", ".", "rparen", ")", ":", "# That was easy.", "return", "ast", ...
Parse the function application subgrammar. Function application can, conceptually, be thought of as a mixfix operator, similar to the way array subscripting works. However, it is not clear at this point whether we want to allow it to work as such, because doing so would permit queries t...
[ "Parse", "the", "function", "application", "subgrammar", "." ]
python
train
48.466667
opencobra/memote
memote/support/consistency_helpers.py
https://github.com/opencobra/memote/blob/276630fcd4449fb7b914186edfd38c239e7052df/memote/support/consistency_helpers.py#L100-L144
def rank(matrix, atol=1e-13, rtol=0): """ Estimate the rank, i.e., the dimension of the column space, of a matrix. The algorithm used by this function is based on the singular value decomposition of `stoichiometry_matrix`. Parameters ---------- matrix : ndarray The matrix should be...
[ "def", "rank", "(", "matrix", ",", "atol", "=", "1e-13", ",", "rtol", "=", "0", ")", ":", "matrix", "=", "np", ".", "atleast_2d", "(", "matrix", ")", "sigma", "=", "svd", "(", "matrix", ",", "compute_uv", "=", "False", ")", "tol", "=", "max", "("...
Estimate the rank, i.e., the dimension of the column space, of a matrix. The algorithm used by this function is based on the singular value decomposition of `stoichiometry_matrix`. Parameters ---------- matrix : ndarray The matrix should be at most 2-D. A 1-D array with length k w...
[ "Estimate", "the", "rank", "i", ".", "e", ".", "the", "dimension", "of", "the", "column", "space", "of", "a", "matrix", "." ]
python
train
30.533333
spyder-ide/spyder
spyder/plugins/editor/extensions/closequotes.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/extensions/closequotes.py#L14-L38
def unmatched_quotes_in_line(text): """Return whether a string has open quotes. This simply counts whether the number of quote characters of either type in the string is odd. Take from the IPython project (in IPython/core/completer.py in v0.13) Spyder team: Add some changes to deal with escaped qu...
[ "def", "unmatched_quotes_in_line", "(", "text", ")", ":", "# We check \" first, then ', so complex cases with nested quotes will", "# get the \" to take precedence.", "text", "=", "text", ".", "replace", "(", "\"\\\\'\"", ",", "\"\"", ")", "text", "=", "text", ".", "repla...
Return whether a string has open quotes. This simply counts whether the number of quote characters of either type in the string is odd. Take from the IPython project (in IPython/core/completer.py in v0.13) Spyder team: Add some changes to deal with escaped quotes - Copyright (C) 2008-2011 IPython...
[ "Return", "whether", "a", "string", "has", "open", "quotes", "." ]
python
train
34.24
Kortemme-Lab/klab
klab/cloning/cloning.py
https://github.com/Kortemme-Lab/klab/blob/6d410ad08f1bd9f7cbbb28d7d946e94fbaaa2b6b/klab/cloning/cloning.py#L87-L134
def sanitize_codon_list(codon_list, forbidden_seqs=()): """ Make silent mutations to the given codon lists to remove any undesirable sequences that are present within it. Undesirable sequences include restriction sites, which may be optionally specified as a second argument, and homopolymers abo...
[ "def", "sanitize_codon_list", "(", "codon_list", ",", "forbidden_seqs", "=", "(", ")", ")", ":", "# Unit test missing for:", "# Homopolymer fixing", "for", "codon", "in", "codon_list", ":", "if", "len", "(", "codon", ")", "!=", "3", ":", "raise", "ValueError",...
Make silent mutations to the given codon lists to remove any undesirable sequences that are present within it. Undesirable sequences include restriction sites, which may be optionally specified as a second argument, and homopolymers above a pre-defined length. The return value is the number of cor...
[ "Make", "silent", "mutations", "to", "the", "given", "codon", "lists", "to", "remove", "any", "undesirable", "sequences", "that", "are", "present", "within", "it", ".", "Undesirable", "sequences", "include", "restriction", "sites", "which", "may", "be", "optiona...
python
train
31.5625
ElementAI/greensim
greensim/__init__.py
https://github.com/ElementAI/greensim/blob/f160e8b57d69f6ef469f2e991cc07b7721e08a91/greensim/__init__.py#L480-L500
def _bind_and_call_constructor(self, t: type, *args) -> None: """ Accesses the __init__ method of a type directly and calls it with *args This allows the constructors of both superclasses to be called, as described in get_binding.md This could be done using two calls to super() with a ...
[ "def", "_bind_and_call_constructor", "(", "self", ",", "t", ":", "type", ",", "*", "args", ")", "->", "None", ":", "t", ".", "__init__", ".", "__get__", "(", "self", ")", "(", "*", "args", ")" ]
Accesses the __init__ method of a type directly and calls it with *args This allows the constructors of both superclasses to be called, as described in get_binding.md This could be done using two calls to super() with a hack based on how Python searches __mro__: ``` super().__init__(r...
[ "Accesses", "the", "__init__", "method", "of", "a", "type", "directly", "and", "calls", "it", "with", "*", "args" ]
python
train
47.142857
heroku/heroku.py
heroku/structures.py
https://github.com/heroku/heroku.py/blob/cadc0a074896cf29c65a457c5c5bdb2069470af0/heroku/structures.py#L108-L116
def clear(self): """Removes all SSH keys from a user's system.""" r = self._h._http_resource( method='DELETE', resource=('user', 'keys'), ) return r.ok
[ "def", "clear", "(", "self", ")", ":", "r", "=", "self", ".", "_h", ".", "_http_resource", "(", "method", "=", "'DELETE'", ",", "resource", "=", "(", "'user'", ",", "'keys'", ")", ",", ")", "return", "r", ".", "ok" ]
Removes all SSH keys from a user's system.
[ "Removes", "all", "SSH", "keys", "from", "a", "user", "s", "system", "." ]
python
train
22.333333
galaxy-genome-annotation/python-apollo
arrow/commands/annotations/set_symbol.py
https://github.com/galaxy-genome-annotation/python-apollo/blob/2bc9991302abe4402ec2885dcaac35915475b387/arrow/commands/annotations/set_symbol.py#L22-L29
def cli(ctx, feature_id, symbol, organism="", sequence=""): """Set a feature's description Output: A standard apollo feature dictionary ({"features": [{...}]}) """ return ctx.gi.annotations.set_symbol(feature_id, symbol, organism=organism, sequence=sequence)
[ "def", "cli", "(", "ctx", ",", "feature_id", ",", "symbol", ",", "organism", "=", "\"\"", ",", "sequence", "=", "\"\"", ")", ":", "return", "ctx", ".", "gi", ".", "annotations", ".", "set_symbol", "(", "feature_id", ",", "symbol", ",", "organism", "=",...
Set a feature's description Output: A standard apollo feature dictionary ({"features": [{...}]})
[ "Set", "a", "feature", "s", "description" ]
python
train
33.625
mlavin/django-all-access
allaccess/clients.py
https://github.com/mlavin/django-all-access/blob/4b15b6c9dedf8080a7c477e0af1142c609ec5598/allaccess/clients.py#L99-L109
def get_redirect_args(self, request, callback): "Get request parameters for redirect url." callback = force_text(request.build_absolute_uri(callback)) raw_token = self.get_request_token(request, callback) token, secret = self.parse_raw_token(raw_token) if token is not None and se...
[ "def", "get_redirect_args", "(", "self", ",", "request", ",", "callback", ")", ":", "callback", "=", "force_text", "(", "request", ".", "build_absolute_uri", "(", "callback", ")", ")", "raw_token", "=", "self", ".", "get_request_token", "(", "request", ",", ...
Get request parameters for redirect url.
[ "Get", "request", "parameters", "for", "redirect", "url", "." ]
python
train
44.181818
PredixDev/predixpy
predix/security/acs.py
https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/security/acs.py#L241-L268
def add_subject(self, subject_id, attributes, parents=[], issuer='default'): """ Will add the given subject with a given identifier and attribute dictionary. example/ add_subject('/user/j12y', {'username': 'j12y'}) """ # MAINT: consider t...
[ "def", "add_subject", "(", "self", ",", "subject_id", ",", "attributes", ",", "parents", "=", "[", "]", ",", "issuer", "=", "'default'", ")", ":", "# MAINT: consider test to avoid adding duplicate subject id", "assert", "isinstance", "(", "attributes", ",", "(", "...
Will add the given subject with a given identifier and attribute dictionary. example/ add_subject('/user/j12y', {'username': 'j12y'})
[ "Will", "add", "the", "given", "subject", "with", "a", "given", "identifier", "and", "attribute", "dictionary", "." ]
python
train
28.964286
pypa/pipenv
pipenv/vendor/vistir/compat.py
https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/vistir/compat.py#L220-L236
def _get_path(path): """ Fetch the string value from a path-like object Returns **None** if there is no string value. """ if isinstance(path, (six.string_types, bytes)): return path path_type = type(path) try: path_repr = path_type.__fspath__(path) except AttributeError...
[ "def", "_get_path", "(", "path", ")", ":", "if", "isinstance", "(", "path", ",", "(", "six", ".", "string_types", ",", "bytes", ")", ")", ":", "return", "path", "path_type", "=", "type", "(", "path", ")", "try", ":", "path_repr", "=", "path_type", "....
Fetch the string value from a path-like object Returns **None** if there is no string value.
[ "Fetch", "the", "string", "value", "from", "a", "path", "-", "like", "object" ]
python
train
24.294118
javipalanca/spade
spade/presence.py
https://github.com/javipalanca/spade/blob/59942bd1a1edae4c807d06cabb178d5630cbf61b/spade/presence.py#L94-L103
def set_available(self, show=None): """ Sets the agent availability to True. Args: show (aioxmpp.PresenceShow, optional): the show state of the presence (Default value = None) """ show = self.state.show if show is None else show self.set_presence(PresenceState...
[ "def", "set_available", "(", "self", ",", "show", "=", "None", ")", ":", "show", "=", "self", ".", "state", ".", "show", "if", "show", "is", "None", "else", "show", "self", ".", "set_presence", "(", "PresenceState", "(", "available", "=", "True", ",", ...
Sets the agent availability to True. Args: show (aioxmpp.PresenceShow, optional): the show state of the presence (Default value = None)
[ "Sets", "the", "agent", "availability", "to", "True", "." ]
python
train
33.9
alvations/pywsd
pywsd/semeval.py
https://github.com/alvations/pywsd/blob/4c12394c8adbcfed71dd912bdbef2e36370821bf/pywsd/semeval.py#L55-L76
def get_answers(self): """ Returns a {(key,value), ...} dictionary of {(instance_id,Answer),...)} >>> coarse_wsd = SemEval2007_Coarse_WSD() >>> inst2ans = coarse_wsd.get_answers() >>> for inst in inst2ans: ... print inst, inst2ans[inst ... break """ ...
[ "def", "get_answers", "(", "self", ")", ":", "inst2ans", "=", "{", "}", "with", "io", ".", "open", "(", "self", ".", "test_ans", ",", "'r'", ")", "as", "fin", ":", "for", "line", "in", "fin", ":", "line", ",", "_", ",", "lemma", "=", "line", "....
Returns a {(key,value), ...} dictionary of {(instance_id,Answer),...)} >>> coarse_wsd = SemEval2007_Coarse_WSD() >>> inst2ans = coarse_wsd.get_answers() >>> for inst in inst2ans: ... print inst, inst2ans[inst ... break
[ "Returns", "a", "{", "(", "key", "value", ")", "...", "}", "dictionary", "of", "{", "(", "instance_id", "Answer", ")", "...", ")", "}", ">>>", "coarse_wsd", "=", "SemEval2007_Coarse_WSD", "()", ">>>", "inst2ans", "=", "coarse_wsd", ".", "get_answers", "()"...
python
train
40.363636
pymupdf/PyMuPDF
fitz/fitz.py
https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/fitz.py#L586-L588
def isInfinite(self): """Check if rectangle is infinite.""" return self.x0 > self.x1 or self.y0 > self.y1
[ "def", "isInfinite", "(", "self", ")", ":", "return", "self", ".", "x0", ">", "self", ".", "x1", "or", "self", ".", "y0", ">", "self", ".", "y1" ]
Check if rectangle is infinite.
[ "Check", "if", "rectangle", "is", "infinite", "." ]
python
train
39.666667
jashandeep-sohi/python-blowfish
blowfish.py
https://github.com/jashandeep-sohi/python-blowfish/blob/5ce7f6d54dcef7efd715b26f9a9ffee0d543047e/blowfish.py#L826-L900
def decrypt_cbc_cts(self, data, init_vector): """ Return an iterator that decrypts `data` using the Cipher-Block Chaining with Ciphertext Stealing (CBC-CTS) mode of operation. CBC-CTS mode can only operate on `data` that is greater than 8 bytes in length. Each iteration, except the las...
[ "def", "decrypt_cbc_cts", "(", "self", ",", "data", ",", "init_vector", ")", ":", "data_len", "=", "len", "(", "data", ")", "if", "data_len", "<=", "8", ":", "raise", "ValueError", "(", "\"data is not greater than 8 bytes in length\"", ")", "S1", ",", "S2", ...
Return an iterator that decrypts `data` using the Cipher-Block Chaining with Ciphertext Stealing (CBC-CTS) mode of operation. CBC-CTS mode can only operate on `data` that is greater than 8 bytes in length. Each iteration, except the last, always returns a block-sized :obj:`bytes` object (i...
[ "Return", "an", "iterator", "that", "decrypts", "data", "using", "the", "Cipher", "-", "Block", "Chaining", "with", "Ciphertext", "Stealing", "(", "CBC", "-", "CTS", ")", "mode", "of", "operation", ".", "CBC", "-", "CTS", "mode", "can", "only", "operate", ...
python
train
31.64
pantsbuild/pants
src/python/pants/pantsd/process_manager.py
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/pantsd/process_manager.py#L337-L340
def write_pid(self, pid=None): """Write the current processes PID to the pidfile location""" pid = pid or os.getpid() self.write_metadata_by_name(self._name, 'pid', str(pid))
[ "def", "write_pid", "(", "self", ",", "pid", "=", "None", ")", ":", "pid", "=", "pid", "or", "os", ".", "getpid", "(", ")", "self", ".", "write_metadata_by_name", "(", "self", ".", "_name", ",", "'pid'", ",", "str", "(", "pid", ")", ")" ]
Write the current processes PID to the pidfile location
[ "Write", "the", "current", "processes", "PID", "to", "the", "pidfile", "location" ]
python
train
45.75
cheind/tf-matplotlib
tfmpl/create.py
https://github.com/cheind/tf-matplotlib/blob/c6904d3d2d306d9a479c24fbcb1f674a57dafd0e/tfmpl/create.py#L9-L23
def create_figure(*fig_args, **fig_kwargs): '''Create a single figure. Args and Kwargs are passed to `matplotlib.figure.Figure`. This routine is provided in order to avoid usage of pyplot which is stateful and not thread safe. As drawing routines in tf-matplotlib are called from py-funcs in th...
[ "def", "create_figure", "(", "*", "fig_args", ",", "*", "*", "fig_kwargs", ")", ":", "fig", "=", "Figure", "(", "*", "fig_args", ",", "*", "*", "fig_kwargs", ")", "# Attach canvas", "FigureCanvas", "(", "fig", ")", "return", "fig" ]
Create a single figure. Args and Kwargs are passed to `matplotlib.figure.Figure`. This routine is provided in order to avoid usage of pyplot which is stateful and not thread safe. As drawing routines in tf-matplotlib are called from py-funcs in their respective thread, avoid usage of pyplot wh...
[ "Create", "a", "single", "figure", "." ]
python
train
31.866667
pybel/pybel-tools
src/pybel_tools/summary/edge_summary.py
https://github.com/pybel/pybel-tools/blob/3491adea0ac4ee60f57275ef72f9b73da6dbfe0c/src/pybel_tools/summary/edge_summary.py#L145-L152
def get_contradictory_pairs(graph: BELGraph) -> Iterable[Tuple[BaseEntity, BaseEntity]]: """Iterates over contradictory node pairs in the graph based on their causal relationships :return: An iterator over (source, target) node pairs that have contradictory causal edges """ for u, v in graph.edges(...
[ "def", "get_contradictory_pairs", "(", "graph", ":", "BELGraph", ")", "->", "Iterable", "[", "Tuple", "[", "BaseEntity", ",", "BaseEntity", "]", "]", ":", "for", "u", ",", "v", "in", "graph", ".", "edges", "(", ")", ":", "if", "pair_has_contradiction", "...
Iterates over contradictory node pairs in the graph based on their causal relationships :return: An iterator over (source, target) node pairs that have contradictory causal edges
[ "Iterates", "over", "contradictory", "node", "pairs", "in", "the", "graph", "based", "on", "their", "causal", "relationships", ":", "return", ":", "An", "iterator", "over", "(", "source", "target", ")", "node", "pairs", "that", "have", "contradictory", "causal...
python
valid
48.25
Esri/ArcREST
src/arcresthelper/common.py
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcresthelper/common.py#L309-L343
def online_time_to_string(value, timeFormat, utcOffset=0): """Converts AGOL timestamp to formatted string. Args: value (float): A UTC timestamp as reported by AGOL (time in ms since Unix epoch * 1000) timeFormat (str): Date/Time format string as parsed by :py:func:`datetime.strftime`. u...
[ "def", "online_time_to_string", "(", "value", ",", "timeFormat", ",", "utcOffset", "=", "0", ")", ":", "try", ":", "return", "datetime", ".", "datetime", ".", "fromtimestamp", "(", "value", "/", "1000", "+", "utcOffset", "*", "3600", ")", ".", "strftime", ...
Converts AGOL timestamp to formatted string. Args: value (float): A UTC timestamp as reported by AGOL (time in ms since Unix epoch * 1000) timeFormat (str): Date/Time format string as parsed by :py:func:`datetime.strftime`. utcOffset (int): Hours difference from UTC and desired output. Defa...
[ "Converts", "AGOL", "timestamp", "to", "formatted", "string", "." ]
python
train
38.228571
dcramer/django-ratings
djangoratings/__init__.py
https://github.com/dcramer/django-ratings/blob/4d00dedc920a4e32d650dc12d5f480c51fc6216c/djangoratings/__init__.py#L16-L26
def get_revision(): """ :returns: Revision number of this branch/checkout, if available. None if no revision number can be determined. """ package_dir = os.path.dirname(__file__) checkout_dir = os.path.normpath(os.path.join(package_dir, '..')) path = os.path.join(checkout_dir, '.git') ...
[ "def", "get_revision", "(", ")", ":", "package_dir", "=", "os", ".", "path", ".", "dirname", "(", "__file__", ")", "checkout_dir", "=", "os", ".", "path", ".", "normpath", "(", "os", ".", "path", ".", "join", "(", "package_dir", ",", "'..'", ")", ")"...
:returns: Revision number of this branch/checkout, if available. None if no revision number can be determined.
[ ":", "returns", ":", "Revision", "number", "of", "this", "branch", "/", "checkout", "if", "available", ".", "None", "if", "no", "revision", "number", "can", "be", "determined", "." ]
python
train
35.545455
mitsei/dlkit
dlkit/json_/grading/objects.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/grading/objects.py#L659-L677
def set_lowest_numeric_score(self, score): """Sets the lowest numeric score. arg: score (decimal): the lowest numeric score raise: InvalidArgument - ``score`` is invalid raise: NoAccess - ``score`` cannot be modified *compliance: mandatory -- This method must be implemented...
[ "def", "set_lowest_numeric_score", "(", "self", ",", "score", ")", ":", "# Implemented from template for osid.grading.GradeSystemForm.set_lowest_numeric_score", "if", "self", ".", "get_lowest_numeric_score_metadata", "(", ")", ".", "is_read_only", "(", ")", ":", "raise", "e...
Sets the lowest numeric score. arg: score (decimal): the lowest numeric score raise: InvalidArgument - ``score`` is invalid raise: NoAccess - ``score`` cannot be modified *compliance: mandatory -- This method must be implemented.*
[ "Sets", "the", "lowest", "numeric", "score", "." ]
python
train
42.789474
ltworf/typedload
typedload/dataloader.py
https://github.com/ltworf/typedload/blob/7fd130612963bfcec3242698463ef863ca4af927/typedload/dataloader.py#L436-L464
def _enumload(l: Loader, value, type_) -> Enum: """ This loads something into an Enum. It tries with basic types first. If that fails, it tries to look for type annotations inside the Enum, and tries to use those to load the value into something that is compatible with the Enum. Of course...
[ "def", "_enumload", "(", "l", ":", "Loader", ",", "value", ",", "type_", ")", "->", "Enum", ":", "try", ":", "# Try naïve conversion", "return", "type_", "(", "value", ")", "except", ":", "pass", "# Try with the typing hints", "for", "_", ",", "t", "in", ...
This loads something into an Enum. It tries with basic types first. If that fails, it tries to look for type annotations inside the Enum, and tries to use those to load the value into something that is compatible with the Enum. Of course if that fails too, a ValueError is raised.
[ "This", "loads", "something", "into", "an", "Enum", "." ]
python
train
25.37931
Robpol86/colorclass
colorclass/core.py
https://github.com/Robpol86/colorclass/blob/692e2d6f5ad470b6221c8cb9641970dc5563a572/colorclass/core.py#L10-L23
def apply_text(incoming, func): """Call `func` on text portions of incoming color string. :param iter incoming: Incoming string/ColorStr/string-like object to iterate. :param func: Function to call with string portion as first and only parameter. :return: Modified string, same class type as incoming s...
[ "def", "apply_text", "(", "incoming", ",", "func", ")", ":", "split", "=", "RE_SPLIT", ".", "split", "(", "incoming", ")", "for", "i", ",", "item", "in", "enumerate", "(", "split", ")", ":", "if", "not", "item", "or", "RE_SPLIT", ".", "match", "(", ...
Call `func` on text portions of incoming color string. :param iter incoming: Incoming string/ColorStr/string-like object to iterate. :param func: Function to call with string portion as first and only parameter. :return: Modified string, same class type as incoming string.
[ "Call", "func", "on", "text", "portions", "of", "incoming", "color", "string", "." ]
python
train
38.214286
Qiskit/qiskit-api-py
IBMQuantumExperience/IBMQuantumExperience.py
https://github.com/Qiskit/qiskit-api-py/blob/2ab240110fb7e653254e44c4833f3643e8ae7f0f/IBMQuantumExperience/IBMQuantumExperience.py#L771-L800
def get_jobs(self, limit=10, skip=0, backend=None, only_completed=False, filter=None, hub=None, group=None, project=None, access_token=None, user_id=None): """ Get the information about the user jobs """ if access_token: self.req.credential.set_token(access_token) if ...
[ "def", "get_jobs", "(", "self", ",", "limit", "=", "10", ",", "skip", "=", "0", ",", "backend", "=", "None", ",", "only_completed", "=", "False", ",", "filter", "=", "None", ",", "hub", "=", "None", ",", "group", "=", "None", ",", "project", "=", ...
Get the information about the user jobs
[ "Get", "the", "information", "about", "the", "user", "jobs" ]
python
train
34.9
denisenkom/pytds
src/pytds/tds.py
https://github.com/denisenkom/pytds/blob/7d875cab29134afdef719406831c1c6a0d7af48a/src/pytds/tds.py#L889-L906
def querying_context(self, packet_type): """ Context manager for querying. Sets state to TDS_QUERYING, and reverts it to TDS_IDLE if exception happens inside managed block, and to TDS_PENDING if managed block succeeds and flushes buffer. """ if self.set_state(tds_base.TDS_QUERYI...
[ "def", "querying_context", "(", "self", ",", "packet_type", ")", ":", "if", "self", ".", "set_state", "(", "tds_base", ".", "TDS_QUERYING", ")", "!=", "tds_base", ".", "TDS_QUERYING", ":", "raise", "tds_base", ".", "Error", "(", "\"Couldn't switch to state\"", ...
Context manager for querying. Sets state to TDS_QUERYING, and reverts it to TDS_IDLE if exception happens inside managed block, and to TDS_PENDING if managed block succeeds and flushes buffer.
[ "Context", "manager", "for", "querying", "." ]
python
train
38.833333
ArduPilot/MAVProxy
MAVProxy/modules/mavproxy_gimbal.py
https://github.com/ArduPilot/MAVProxy/blob/f50bdeff33064876f7dc8dc4683d278ff47f75d5/MAVProxy/modules/mavproxy_gimbal.py#L58-L74
def cmd_gimbal_mode(self, args): '''control gimbal mode''' if len(args) != 1: print("usage: gimbal mode <GPS|MAVLink>") return if args[0].upper() == 'GPS': mode = mavutil.mavlink.MAV_MOUNT_MODE_GPS_POINT elif args[0].upper() == 'MAVLINK': m...
[ "def", "cmd_gimbal_mode", "(", "self", ",", "args", ")", ":", "if", "len", "(", "args", ")", "!=", "1", ":", "print", "(", "\"usage: gimbal mode <GPS|MAVLink>\"", ")", "return", "if", "args", "[", "0", "]", ".", "upper", "(", ")", "==", "'GPS'", ":", ...
control gimbal mode
[ "control", "gimbal", "mode" ]
python
train
44.823529
Jaymon/prom
prom/interface/postgres.py
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/interface/postgres.py#L292-L314
def _set_index(self, schema, name, fields, **index_options): """ NOTE -- we set the index name using <table_name>_<name> format since indexes have to have a globally unique name in postgres http://www.postgresql.org/docs/9.1/static/sql-createindex.html """ index_fields =...
[ "def", "_set_index", "(", "self", ",", "schema", ",", "name", ",", "fields", ",", "*", "*", "index_options", ")", ":", "index_fields", "=", "[", "]", "for", "field_name", "in", "fields", ":", "field", "=", "schema", ".", "fields", "[", "field_name", "]...
NOTE -- we set the index name using <table_name>_<name> format since indexes have to have a globally unique name in postgres http://www.postgresql.org/docs/9.1/static/sql-createindex.html
[ "NOTE", "--", "we", "set", "the", "index", "name", "using", "<table_name", ">", "_<name", ">", "format", "since", "indexes", "have", "to", "have", "a", "globally", "unique", "name", "in", "postgres" ]
python
train
43.304348
dokterbob/django-multilingual-model
multilingual_model/models.py
https://github.com/dokterbob/django-multilingual-model/blob/2479b2c3d6f7b697e95aa1e082c8bc8699f1f638/multilingual_model/models.py#L44-L90
def _get_translation(self, field, code): """ Gets the translation of a specific field for a specific language code. This raises ObjectDoesNotExist if the lookup was unsuccesful. As of today, this stuff is cached. As the cache is rather aggressive it might cause rather strange ef...
[ "def", "_get_translation", "(", "self", ",", "field", ",", "code", ")", ":", "if", "not", "code", "in", "self", ".", "_translation_cache", ":", "translations", "=", "self", ".", "translations", ".", "select_related", "(", ")", "logger", ".", "debug", "(", ...
Gets the translation of a specific field for a specific language code. This raises ObjectDoesNotExist if the lookup was unsuccesful. As of today, this stuff is cached. As the cache is rather aggressive it might cause rather strange effects. However, we would see the same effects when an...
[ "Gets", "the", "translation", "of", "a", "specific", "field", "for", "a", "specific", "language", "code", "." ]
python
train
33.744681
flatangle/flatlib
flatlib/predictives/returns.py
https://github.com/flatangle/flatlib/blob/44e05b2991a296c678adbc17a1d51b6a21bc867c/flatlib/predictives/returns.py#L18-L26
def _computeChart(chart, date): """ Internal function to return a new chart for a specific date using properties from old chart. """ pos = chart.pos hsys = chart.hsys IDs = [obj.id for obj in chart.objects] return Chart(date, pos, IDs=IDs, hsys=hsys)
[ "def", "_computeChart", "(", "chart", ",", "date", ")", ":", "pos", "=", "chart", ".", "pos", "hsys", "=", "chart", ".", "hsys", "IDs", "=", "[", "obj", ".", "id", "for", "obj", "in", "chart", ".", "objects", "]", "return", "Chart", "(", "date", ...
Internal function to return a new chart for a specific date using properties from old chart.
[ "Internal", "function", "to", "return", "a", "new", "chart", "for", "a", "specific", "date", "using", "properties", "from", "old", "chart", "." ]
python
train
30.555556
tango-controls/pytango
tango/databaseds/database.py
https://github.com/tango-controls/pytango/blob/9cf78c517c9cdc1081ff6d080a9646a740cc1d36/tango/databaseds/database.py#L1096-L1104
def DbGetClassForDevice(self, argin): """ Get Tango class for the specified device. :param argin: Device name :type: tango.DevString :return: Device Tango class :rtype: tango.DevString """ self._log.debug("In DbGetClassForDevice()") return self.db.get_class_for_d...
[ "def", "DbGetClassForDevice", "(", "self", ",", "argin", ")", ":", "self", ".", "_log", ".", "debug", "(", "\"In DbGetClassForDevice()\"", ")", "return", "self", ".", "db", ".", "get_class_for_device", "(", "argin", ")" ]
Get Tango class for the specified device. :param argin: Device name :type: tango.DevString :return: Device Tango class :rtype: tango.DevString
[ "Get", "Tango", "class", "for", "the", "specified", "device", "." ]
python
train
36
numenta/htmresearch
htmresearch/frameworks/sp_paper/sp_metrics.py
https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/htmresearch/frameworks/sp_paper/sp_metrics.py#L621-L673
def inspectSpatialPoolerStats(sp, inputVectors, saveFigPrefix=None): """ Inspect the statistics of a spatial pooler given a set of input vectors @param sp: an spatial pooler instance @param inputVectors: a set of input vectors """ numInputVector, inputSize = inputVectors.shape numColumns = np.prod(sp.getC...
[ "def", "inspectSpatialPoolerStats", "(", "sp", ",", "inputVectors", ",", "saveFigPrefix", "=", "None", ")", ":", "numInputVector", ",", "inputSize", "=", "inputVectors", ".", "shape", "numColumns", "=", "np", ".", "prod", "(", "sp", ".", "getColumnDimensions", ...
Inspect the statistics of a spatial pooler given a set of input vectors @param sp: an spatial pooler instance @param inputVectors: a set of input vectors
[ "Inspect", "the", "statistics", "of", "a", "spatial", "pooler", "given", "a", "set", "of", "input", "vectors" ]
python
train
37.490566
twilio/twilio-python
twilio/rest/serverless/v1/service/environment/variable.py
https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/serverless/v1/service/environment/variable.py#L281-L305
def update(self, key=values.unset, value=values.unset): """ Update the VariableInstance :param unicode key: The key :param unicode value: The value :returns: Updated VariableInstance :rtype: twilio.rest.serverless.v1.service.environment.variable.VariableInstance ...
[ "def", "update", "(", "self", ",", "key", "=", "values", ".", "unset", ",", "value", "=", "values", ".", "unset", ")", ":", "data", "=", "values", ".", "of", "(", "{", "'Key'", ":", "key", ",", "'Value'", ":", "value", ",", "}", ")", "payload", ...
Update the VariableInstance :param unicode key: The key :param unicode value: The value :returns: Updated VariableInstance :rtype: twilio.rest.serverless.v1.service.environment.variable.VariableInstance
[ "Update", "the", "VariableInstance" ]
python
train
28.92
Robin8Put/pmes
balance/handler.py
https://github.com/Robin8Put/pmes/blob/338bec94162098f05b75bad035417317e1252fd2/balance/handler.py#L103-L178
async def freeze(self, *args, **kwargs): """ Freeze users balance Accepts: - uid [integer] (users id from main server) - coinid [string] (blockchain type in uppercase) - amount [integer] (amount for freezing) Returns: - uid [integer] (users id from main server) - coinid [string] (blockchain typ...
[ "async", "def", "freeze", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Get data from request", "uid", "=", "kwargs", ".", "get", "(", "\"uid\"", ",", "0", ")", "coinid", "=", "kwargs", ".", "get", "(", "\"coinid\"", ")", "amou...
Freeze users balance Accepts: - uid [integer] (users id from main server) - coinid [string] (blockchain type in uppercase) - amount [integer] (amount for freezing) Returns: - uid [integer] (users id from main server) - coinid [string] (blockchain type in uppercase) - amount_active [integer] (act...
[ "Freeze", "users", "balance" ]
python
train
27.657895
uw-it-aca/uw-restclients
restclients/trumba/calendar.py
https://github.com/uw-it-aca/uw-restclients/blob/e12dcd32bf5296b6ebdf71798031594afb7852cb/restclients/trumba/calendar.py#L268-L292
def _check_err(data): """ :param data: response json data object (must be not None). Check possible error code returned in the response body raise the coresponding exceptions """ if data['d'] is None: raise NoDataReturned() if data['d']['Messages'] is None: return msg = ...
[ "def", "_check_err", "(", "data", ")", ":", "if", "data", "[", "'d'", "]", "is", "None", ":", "raise", "NoDataReturned", "(", ")", "if", "data", "[", "'d'", "]", "[", "'Messages'", "]", "is", "None", ":", "return", "msg", "=", "data", "[", "'d'", ...
:param data: response json data object (must be not None). Check possible error code returned in the response body raise the coresponding exceptions
[ ":", "param", "data", ":", "response", "json", "data", "object", "(", "must", "be", "not", "None", ")", ".", "Check", "possible", "error", "code", "returned", "in", "the", "response", "body", "raise", "the", "coresponding", "exceptions" ]
python
train
28
ethereum/py-evm
eth/tools/fixtures/loading.py
https://github.com/ethereum/py-evm/blob/58346848f076116381d3274bbcea96b9e2cfcbdf/eth/tools/fixtures/loading.py#L54-L60
def load_json_fixture(fixture_path: str) -> Dict[str, Any]: """ Loads a fixture file, caching the most recent files it loaded. """ with open(fixture_path) as fixture_file: file_fixtures = json.load(fixture_file) return file_fixtures
[ "def", "load_json_fixture", "(", "fixture_path", ":", "str", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "with", "open", "(", "fixture_path", ")", "as", "fixture_file", ":", "file_fixtures", "=", "json", ".", "load", "(", "fixture_file", ")", "r...
Loads a fixture file, caching the most recent files it loaded.
[ "Loads", "a", "fixture", "file", "caching", "the", "most", "recent", "files", "it", "loaded", "." ]
python
train
36.285714
arviz-devs/arviz
arviz/stats/stats.py
https://github.com/arviz-devs/arviz/blob/d04d8da07f029fd2931f48d2f7f324cf393e5277/arviz/stats/stats.py#L331-L384
def _logsumexp(ary, *, b=None, b_inv=None, axis=None, keepdims=False, out=None, copy=True): """Stable logsumexp when b >= 0 and b is scalar. b_inv overwrites b unless b_inv is None. """ # check dimensions for result arrays ary = np.asarray(ary) if ary.dtype.kind == "i": ary = ary.astype...
[ "def", "_logsumexp", "(", "ary", ",", "*", ",", "b", "=", "None", ",", "b_inv", "=", "None", ",", "axis", "=", "None", ",", "keepdims", "=", "False", ",", "out", "=", "None", ",", "copy", "=", "True", ")", ":", "# check dimensions for result arrays", ...
Stable logsumexp when b >= 0 and b is scalar. b_inv overwrites b unless b_inv is None.
[ "Stable", "logsumexp", "when", "b", ">", "=", "0", "and", "b", "is", "scalar", "." ]
python
train
33.648148
lablup/backend.ai-client-py
src/ai/backend/client/cli/admin/sessions.py
https://github.com/lablup/backend.ai-client-py/blob/a063d774fea6f4350b89498c40d3c837ec3029a7/src/ai/backend/client/cli/admin/sessions.py#L24-L133
def sessions(status, access_key, id_only, all): ''' List and manage compute sessions. ''' fields = [ ('Session ID', 'sess_id'), ] with Session() as session: if is_admin(session): fields.append(('Owner', 'access_key')) if not id_only: fields.extend([ ...
[ "def", "sessions", "(", "status", ",", "access_key", ",", "id_only", ",", "all", ")", ":", "fields", "=", "[", "(", "'Session ID'", ",", "'sess_id'", ")", ",", "]", "with", "Session", "(", ")", "as", "session", ":", "if", "is_admin", "(", "session", ...
List and manage compute sessions.
[ "List", "and", "manage", "compute", "sessions", "." ]
python
train
34.790909
ampl/amplpy
amplpy/utils.py
https://github.com/ampl/amplpy/blob/39df6954049a11a8f666aed26853259b4687099a/amplpy/utils.py#L11-L45
def register_magics(store_name='_ampl_cells', ampl_object=None): """ Register jupyter notebook magics ``%%ampl`` and ``%%ampl_eval``. Args: store_name: Name of the store where ``%%ampl cells`` will be stored. ampl_object: Object used to evaluate ``%%ampl_eval`` cells. """ from IPyth...
[ "def", "register_magics", "(", "store_name", "=", "'_ampl_cells'", ",", "ampl_object", "=", "None", ")", ":", "from", "IPython", ".", "core", ".", "magic", "import", "(", "Magics", ",", "magics_class", ",", "cell_magic", ",", "line_magic", ")", "@", "magics_...
Register jupyter notebook magics ``%%ampl`` and ``%%ampl_eval``. Args: store_name: Name of the store where ``%%ampl cells`` will be stored. ampl_object: Object used to evaluate ``%%ampl_eval`` cells.
[ "Register", "jupyter", "notebook", "magics", "%%ampl", "and", "%%ampl_eval", "." ]
python
train
29.914286
pyGrowler/Growler
growler/http/response.py
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/response.py#L208-L226
def send_text(self, txt, status=200): """ Sends plaintext response to client. Automatically sets the content-type header to text/plain. If txt is not a string, it will be formatted as one. Parameters ---------- txt : str The plaintext string to be sen...
[ "def", "send_text", "(", "self", ",", "txt", ",", "status", "=", "200", ")", ":", "self", ".", "headers", ".", "setdefault", "(", "'content-type'", ",", "'text/plain'", ")", "if", "not", "isinstance", "(", "txt", ",", "bytes", ")", ":", "txt", "=", "...
Sends plaintext response to client. Automatically sets the content-type header to text/plain. If txt is not a string, it will be formatted as one. Parameters ---------- txt : str The plaintext string to be sent back to the client status : int, optional ...
[ "Sends", "plaintext", "response", "to", "client", ".", "Automatically", "sets", "the", "content", "-", "type", "header", "to", "text", "/", "plain", ".", "If", "txt", "is", "not", "a", "string", "it", "will", "be", "formatted", "as", "one", "." ]
python
train
33.526316
abau171/highfive
highfive/jobs.py
https://github.com/abau171/highfive/blob/07b3829331072035ab100d1d66deca3e8f3f372a/highfive/jobs.py#L466-L479
def close(self): """ Closes the job manager. No more jobs will be assigned, no more job sets will be added, and any queued or active job sets will be cancelled. """ if self._closed: return self._closed = True if self._active_js is not None: ...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_closed", ":", "return", "self", ".", "_closed", "=", "True", "if", "self", ".", "_active_js", "is", "not", "None", ":", "self", ".", "_active_js", ".", "cancel", "(", ")", "for", "js", "in...
Closes the job manager. No more jobs will be assigned, no more job sets will be added, and any queued or active job sets will be cancelled.
[ "Closes", "the", "job", "manager", ".", "No", "more", "jobs", "will", "be", "assigned", "no", "more", "job", "sets", "will", "be", "added", "and", "any", "queued", "or", "active", "job", "sets", "will", "be", "cancelled", "." ]
python
test
28
RacingTadpole/django-singleton-admin
django_singleton_admin/admin.py
https://github.com/RacingTadpole/django-singleton-admin/blob/0a81454be11fdcbaf95ca5018667a8dff3f45bf7/django_singleton_admin/admin.py#L44-L55
def add_view(self, *args, **kwargs): """ Redirect to the change view if the singleton instance exists. """ try: singleton = self.model.objects.get() except (self.model.DoesNotExist, self.model.MultipleObjectsReturned): kwargs.setdefault("extra_context", {}...
[ "def", "add_view", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "singleton", "=", "self", ".", "model", ".", "objects", ".", "get", "(", ")", "except", "(", "self", ".", "model", ".", "DoesNotExist", ",", "self", ...
Redirect to the change view if the singleton instance exists.
[ "Redirect", "to", "the", "change", "view", "if", "the", "singleton", "instance", "exists", "." ]
python
train
47.416667
linuxsoftware/ls.joyous
ls/joyous/models/events.py
https://github.com/linuxsoftware/ls.joyous/blob/316283140ca5171a68ad3170a5964fdc89be0b56/ls/joyous/models/events.py#L951-L958
def next_date(self): """ Date when this event is next scheduled to occur in the local time zone (Does not include postponements, but does exclude cancellations) """ nextDt = self.__localAfter(timezone.localtime(), dt.time.min) if nextDt is not None: return nex...
[ "def", "next_date", "(", "self", ")", ":", "nextDt", "=", "self", ".", "__localAfter", "(", "timezone", ".", "localtime", "(", ")", ",", "dt", ".", "time", ".", "min", ")", "if", "nextDt", "is", "not", "None", ":", "return", "nextDt", ".", "date", ...
Date when this event is next scheduled to occur in the local time zone (Does not include postponements, but does exclude cancellations)
[ "Date", "when", "this", "event", "is", "next", "scheduled", "to", "occur", "in", "the", "local", "time", "zone", "(", "Does", "not", "include", "postponements", "but", "does", "exclude", "cancellations", ")" ]
python
train
40.375
jcconnell/python-magicseaweed
magicseaweed/__init__.py
https://github.com/jcconnell/python-magicseaweed/blob/b22d5f22a134532ac6ab7fc274ee768e85f624a0/magicseaweed/__init__.py#L164-L169
def get_current(self): """Get current forecast.""" now = dt.now().timestamp() url = build_url(self.api_key, self.spot_id, self.fields, self.unit, now, now) return get_msw(url)
[ "def", "get_current", "(", "self", ")", ":", "now", "=", "dt", ".", "now", "(", ")", ".", "timestamp", "(", ")", "url", "=", "build_url", "(", "self", ".", "api_key", ",", "self", ".", "spot_id", ",", "self", ".", "fields", ",", "self", ".", "uni...
Get current forecast.
[ "Get", "current", "forecast", "." ]
python
train
37.666667
saltstack/salt
salt/fileclient.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/fileclient.py#L742-L792
def get_template( self, url, dest, template='jinja', makedirs=False, saltenv='base', cachedir=None, **kwargs): ''' Cache a file then process it as a template ''' if 'env' in kwargs: ...
[ "def", "get_template", "(", "self", ",", "url", ",", "dest", ",", "template", "=", "'jinja'", ",", "makedirs", "=", "False", ",", "saltenv", "=", "'base'", ",", "cachedir", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "'env'", "in", "kwargs"...
Cache a file then process it as a template
[ "Cache", "a", "file", "then", "process", "it", "as", "a", "template" ]
python
train
32.372549
takuti/flurs
flurs/utils/metric.py
https://github.com/takuti/flurs/blob/a998fc180b45db7eaf38dbbbf8125a93100b8a8c/flurs/utils/metric.py#L135-L156
def mpr(truth, recommend): """Mean Percentile Rank (MPR). Args: truth (numpy 1d array): Set of truth samples. recommend (numpy 1d array): Ordered set of recommended samples. Returns: float: MPR. """ if len(recommend) == 0 and len(truth) == 0: return 0. # best ...
[ "def", "mpr", "(", "truth", ",", "recommend", ")", ":", "if", "len", "(", "recommend", ")", "==", "0", "and", "len", "(", "truth", ")", "==", "0", ":", "return", "0.", "# best", "elif", "len", "(", "truth", ")", "==", "0", "or", "len", "(", "tr...
Mean Percentile Rank (MPR). Args: truth (numpy 1d array): Set of truth samples. recommend (numpy 1d array): Ordered set of recommended samples. Returns: float: MPR.
[ "Mean", "Percentile", "Rank", "(", "MPR", ")", "." ]
python
train
25.318182
industrial-optimization-group/DESDEO
desdeo/utils/tui.py
https://github.com/industrial-optimization-group/DESDEO/blob/c7aebe8adb20942d200b9a411d4cdec21f5f4bff/desdeo/utils/tui.py#L146-L166
def _prompt_wrapper(message, default=None, validator=None): """ Handle references piped from file """ class MockDocument: def __init__(self, text): self.text = text if HAS_INPUT: ret = prompt(message, default=default, validator=validator) else: ret = sys.stdin....
[ "def", "_prompt_wrapper", "(", "message", ",", "default", "=", "None", ",", "validator", "=", "None", ")", ":", "class", "MockDocument", ":", "def", "__init__", "(", "self", ",", "text", ")", ":", "self", ".", "text", "=", "text", "if", "HAS_INPUT", ":...
Handle references piped from file
[ "Handle", "references", "piped", "from", "file" ]
python
train
25.714286
deepmipt/DeepPavlov
deeppavlov/core/commands/train.py
https://github.com/deepmipt/DeepPavlov/blob/f3e4a69a3764d25d2f5bad4f1f1aebc872b00f9c/deeppavlov/core/commands/train.py#L61-L66
def get_iterator_from_config(config: dict, data: dict): """Create iterator (from config) for specified data.""" iterator_config = config['dataset_iterator'] iterator: Union[DataLearningIterator, DataFittingIterator] = from_params(iterator_config, ...
[ "def", "get_iterator_from_config", "(", "config", ":", "dict", ",", "data", ":", "dict", ")", ":", "iterator_config", "=", "config", "[", "'dataset_iterator'", "]", "iterator", ":", "Union", "[", "DataLearningIterator", ",", "DataFittingIterator", "]", "=", "fro...
Create iterator (from config) for specified data.
[ "Create", "iterator", "(", "from", "config", ")", "for", "specified", "data", "." ]
python
test
60.166667
kurtbrose/pyjks
jks/rfc7292.py
https://github.com/kurtbrose/pyjks/blob/1cbe7f060e2ad076b6462f3273f11d635771ea3d/jks/rfc7292.py#L69-L82
def _adjust(a, a_offset, b): """ a = bytearray a_offset = int b = bytearray """ x = (b[-1] & 0xFF) + (a[a_offset + len(b) - 1] & 0xFF) + 1 a[a_offset + len(b) - 1] = ctypes.c_ubyte(x).value x >>= 8 for i in range(len(b)-2, -1, -1): x += (b[i] & 0xFF) + (a[a_offset + i] & 0xF...
[ "def", "_adjust", "(", "a", ",", "a_offset", ",", "b", ")", ":", "x", "=", "(", "b", "[", "-", "1", "]", "&", "0xFF", ")", "+", "(", "a", "[", "a_offset", "+", "len", "(", "b", ")", "-", "1", "]", "&", "0xFF", ")", "+", "1", "a", "[", ...
a = bytearray a_offset = int b = bytearray
[ "a", "=", "bytearray", "a_offset", "=", "int", "b", "=", "bytearray" ]
python
train
26.785714
gpoulter/fablib
fablib.py
https://github.com/gpoulter/fablib/blob/5d14c4d998f79dd1aa3207063c3d06e30e3e2bf9/fablib.py#L67-L79
def cron(name, timespec, user, command, environ=None, disable=False): """Create entry in /etc/cron.d""" path = '/etc/cron.d/{}'.format(name) if disable: sudo('rm ' + path) return entry = '{}\t{}\t{}\n'.format(timespec, user, command) if environ: envstr = '\n'.join('{}={}'.for...
[ "def", "cron", "(", "name", ",", "timespec", ",", "user", ",", "command", ",", "environ", "=", "None", ",", "disable", "=", "False", ")", ":", "path", "=", "'/etc/cron.d/{}'", ".", "format", "(", "name", ")", "if", "disable", ":", "sudo", "(", "'rm '...
Create entry in /etc/cron.d
[ "Create", "entry", "in", "/", "etc", "/", "cron", ".", "d" ]
python
train
40.076923
Microsoft/azure-devops-python-api
azure-devops/azure/devops/v5_1/gallery/gallery_client.py
https://github.com/Microsoft/azure-devops-python-api/blob/4777ffda2f5052fabbaddb2abe9cb434e0cf1aa8/azure-devops/azure/devops/v5_1/gallery/gallery_client.py#L1103-L1119
def delete_publisher_asset(self, publisher_name, asset_type=None): """DeletePublisherAsset. [Preview API] Delete publisher asset like logo :param str publisher_name: Internal name of the publisher :param str asset_type: Type of asset. Default value is 'logo'. """ route_va...
[ "def", "delete_publisher_asset", "(", "self", ",", "publisher_name", ",", "asset_type", "=", "None", ")", ":", "route_values", "=", "{", "}", "if", "publisher_name", "is", "not", "None", ":", "route_values", "[", "'publisherName'", "]", "=", "self", ".", "_s...
DeletePublisherAsset. [Preview API] Delete publisher asset like logo :param str publisher_name: Internal name of the publisher :param str asset_type: Type of asset. Default value is 'logo'.
[ "DeletePublisherAsset", ".", "[", "Preview", "API", "]", "Delete", "publisher", "asset", "like", "logo", ":", "param", "str", "publisher_name", ":", "Internal", "name", "of", "the", "publisher", ":", "param", "str", "asset_type", ":", "Type", "of", "asset", ...
python
train
51.588235
wbond/asn1crypto
dev/deps.py
https://github.com/wbond/asn1crypto/blob/ecda20176f55d37021cbca1f6da9083a8e491197/dev/deps.py#L126-L157
def _archive_single_dir(archive): """ Check if all members of the archive are in a single top-level directory :param archive: An archive from _open_archive() :return: None if not a single top level directory in archive, otherwise a unicode string of the top level directory name...
[ "def", "_archive_single_dir", "(", "archive", ")", ":", "common_root", "=", "None", "for", "info", "in", "_list_archive_members", "(", "archive", ")", ":", "fn", "=", "_info_name", "(", "info", ")", "if", "fn", "in", "set", "(", "[", "'.'", ",", "'/'", ...
Check if all members of the archive are in a single top-level directory :param archive: An archive from _open_archive() :return: None if not a single top level directory in archive, otherwise a unicode string of the top level directory name
[ "Check", "if", "all", "members", "of", "the", "archive", "are", "in", "a", "single", "top", "-", "level", "directory" ]
python
train
26.375
edx/edx-enterprise
integrated_channels/xapi/management/commands/send_course_completions.py
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/xapi/management/commands/send_course_completions.py#L122-L147
def send_xapi_statements(self, lrs_configuration, days): """ Send xAPI analytics data of the enterprise learners to the given LRS. Arguments: lrs_configuration (XAPILRSConfiguration): Configuration object containing LRS configurations of the LRS where to send xAPI l...
[ "def", "send_xapi_statements", "(", "self", ",", "lrs_configuration", ",", "days", ")", ":", "persistent_course_grades", "=", "self", ".", "get_course_completions", "(", "lrs_configuration", ".", "enterprise_customer", ",", "days", ")", "users", "=", "self", ".", ...
Send xAPI analytics data of the enterprise learners to the given LRS. Arguments: lrs_configuration (XAPILRSConfiguration): Configuration object containing LRS configurations of the LRS where to send xAPI learner analytics. days (int): Include course enrollment of this n...
[ "Send", "xAPI", "analytics", "data", "of", "the", "enterprise", "learners", "to", "the", "given", "LRS", "." ]
python
valid
55.461538
PmagPy/PmagPy
pmagpy/ipmag.py
https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/ipmag.py#L4676-L5466
def specimens_results_magic(infile='pmag_specimens.txt', measfile='magic_measurements.txt', sampfile='er_samples.txt', sitefile='er_sites.txt', agefile='er_ages.txt', specout='er_specimens.txt', sampout='pmag_samples.txt', siteout='pmag_sites.txt', resout='pmag_results.txt', critout='pmag_criteria.txt', instout='magic_...
[ "def", "specimens_results_magic", "(", "infile", "=", "'pmag_specimens.txt'", ",", "measfile", "=", "'magic_measurements.txt'", ",", "sampfile", "=", "'er_samples.txt'", ",", "sitefile", "=", "'er_sites.txt'", ",", "agefile", "=", "'er_ages.txt'", ",", "specout", "=",...
Writes magic_instruments, er_specimens, pmag_samples, pmag_sites, pmag_criteria, and pmag_results. The data used to write this is obtained by reading a pmag_speciemns, a magic_measurements, a er_samples, a er_sites, a er_ages. @param -> infile: path from the WD to the pmag speciemns table @param -> measfile: pa...
[ "Writes", "magic_instruments", "er_specimens", "pmag_samples", "pmag_sites", "pmag_criteria", "and", "pmag_results", ".", "The", "data", "used", "to", "write", "this", "is", "obtained", "by", "reading", "a", "pmag_speciemns", "a", "magic_measurements", "a", "er_sample...
python
train
57.4311
arne-cl/discoursegraphs
src/discoursegraphs/readwrite/rst/rs3/rs3tree.py
https://github.com/arne-cl/discoursegraphs/blob/842f0068a3190be2c75905754521b176b25a54fb/src/discoursegraphs/readwrite/rst/rs3/rs3tree.py#L376-L387
def sort_subtrees(self, *subtrees): """sort the given subtrees (of type DGParentedTree) based on their linear position in this RSTTree. If two subtrees have the same linear position in the RSTTree (i.e. one is a child of the other), they are sorted by their height in reverse order (i.e. ...
[ "def", "sort_subtrees", "(", "self", ",", "*", "subtrees", ")", ":", "subtrees_desc_height", "=", "sorted", "(", "subtrees", ",", "key", "=", "methodcaller", "(", "'node_height'", ",", "self", ")", ",", "reverse", "=", "True", ")", "return", "sorted", "(",...
sort the given subtrees (of type DGParentedTree) based on their linear position in this RSTTree. If two subtrees have the same linear position in the RSTTree (i.e. one is a child of the other), they are sorted by their height in reverse order (i.e. the child appears before its parent).
[ "sort", "the", "given", "subtrees", "(", "of", "type", "DGParentedTree", ")", "based", "on", "their", "linear", "position", "in", "this", "RSTTree", ".", "If", "two", "subtrees", "have", "the", "same", "linear", "position", "in", "the", "RSTTree", "(", "i"...
python
train
54.083333
rosshamish/hexgrid
hexgrid.py
https://github.com/rosshamish/hexgrid/blob/16abb1822dc2789cb355f54fb06c7774eea1d9f2/hexgrid.py#L413-L422
def legal_node_coords(): """ Return all legal node coordinates on the grid """ nodes = set() for tile_id in legal_tile_ids(): for node in nodes_touching_tile(tile_id): nodes.add(node) logging.debug('Legal node coords({})={}'.format(len(nodes), nodes)) return nodes
[ "def", "legal_node_coords", "(", ")", ":", "nodes", "=", "set", "(", ")", "for", "tile_id", "in", "legal_tile_ids", "(", ")", ":", "for", "node", "in", "nodes_touching_tile", "(", "tile_id", ")", ":", "nodes", ".", "add", "(", "node", ")", "logging", "...
Return all legal node coordinates on the grid
[ "Return", "all", "legal", "node", "coordinates", "on", "the", "grid" ]
python
train
30.3