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
ensime/ensime-vim
ensime_shared/debugger.py
https://github.com/ensime/ensime-vim/blob/caa734e84f002b25446c615706283a74edd4ecfe/ensime_shared/debugger.py#L30-L40
def handle_debug_backtrace(self, call_id, payload): """Handle responses `DebugBacktrace`.""" frames = payload["frames"] fd, path = tempfile.mkstemp('.json', text=True, dir=self.tmp_diff_folder) tmpfile = os.fdopen(fd, 'w') tmpfile.write(json.dumps(frames, indent=2)) opts...
[ "def", "handle_debug_backtrace", "(", "self", ",", "call_id", ",", "payload", ")", ":", "frames", "=", "payload", "[", "\"frames\"", "]", "fd", ",", "path", "=", "tempfile", ".", "mkstemp", "(", "'.json'", ",", "text", "=", "True", ",", "dir", "=", "se...
Handle responses `DebugBacktrace`.
[ "Handle", "responses", "DebugBacktrace", "." ]
python
train
44.818182
Rapptz/discord.py
discord/guild.py
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/guild.py#L515-L527
def chunked(self): """Returns a boolean indicating if the guild is "chunked". A chunked guild means that :attr:`member_count` is equal to the number of members stored in the internal :attr:`members` cache. If this value returns ``False``, then you should request for offline mem...
[ "def", "chunked", "(", "self", ")", ":", "count", "=", "getattr", "(", "self", ",", "'_member_count'", ",", "None", ")", "if", "count", "is", "None", ":", "return", "False", "return", "count", "==", "len", "(", "self", ".", "_members", ")" ]
Returns a boolean indicating if the guild is "chunked". A chunked guild means that :attr:`member_count` is equal to the number of members stored in the internal :attr:`members` cache. If this value returns ``False``, then you should request for offline members.
[ "Returns", "a", "boolean", "indicating", "if", "the", "guild", "is", "chunked", "." ]
python
train
36.307692
aio-libs/aiohttp_admin
aiohttp_admin/contrib/admin.py
https://github.com/aio-libs/aiohttp_admin/blob/82e5032ef14ae8cc3c594fdd45d6c977aab1baad/aiohttp_admin/contrib/admin.py#L30-L52
def to_json(self): """ Prepare data for the initial state of the admin-on-rest """ endpoints = [] for endpoint in self.endpoints: list_fields = endpoint.fields resource_type = endpoint.Meta.resource_type table = endpoint.Meta.table ...
[ "def", "to_json", "(", "self", ")", ":", "endpoints", "=", "[", "]", "for", "endpoint", "in", "self", ".", "endpoints", ":", "list_fields", "=", "endpoint", ".", "fields", "resource_type", "=", "endpoint", ".", "Meta", ".", "resource_type", "table", "=", ...
Prepare data for the initial state of the admin-on-rest
[ "Prepare", "data", "for", "the", "initial", "state", "of", "the", "admin", "-", "on", "-", "rest" ]
python
train
28.304348
kata198/indexedredis
IndexedRedis/__init__.py
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/__init__.py#L1235-L1243
def _get_connection(self): ''' _get_connection - Maybe get a new connection, or reuse if passed in. Will share a connection with a model internal ''' if self._connection is None: self._connection = self._get_new_connection() return self._connection
[ "def", "_get_connection", "(", "self", ")", ":", "if", "self", ".", "_connection", "is", "None", ":", "self", ".", "_connection", "=", "self", ".", "_get_new_connection", "(", ")", "return", "self", ".", "_connection" ]
_get_connection - Maybe get a new connection, or reuse if passed in. Will share a connection with a model internal
[ "_get_connection", "-", "Maybe", "get", "a", "new", "connection", "or", "reuse", "if", "passed", "in", ".", "Will", "share", "a", "connection", "with", "a", "model", "internal" ]
python
valid
29.111111
saltstack/salt
salt/proxy/dummy.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/proxy/dummy.py#L164-L175
def package_install(name, **kwargs): ''' Install a "package" on the REST server ''' DETAILS = _load_state() if kwargs.get('version', False): version = kwargs['version'] else: version = '1.0' DETAILS['packages'][name] = version _save_state(DETAILS) return {name: versio...
[ "def", "package_install", "(", "name", ",", "*", "*", "kwargs", ")", ":", "DETAILS", "=", "_load_state", "(", ")", "if", "kwargs", ".", "get", "(", "'version'", ",", "False", ")", ":", "version", "=", "kwargs", "[", "'version'", "]", "else", ":", "ve...
Install a "package" on the REST server
[ "Install", "a", "package", "on", "the", "REST", "server" ]
python
train
25.916667
singularityhub/singularity-cli
spython/oci/__init__.py
https://github.com/singularityhub/singularity-cli/blob/cb36b4504812ca87e29c6a40b222a545d1865799/spython/oci/__init__.py#L100-L127
def _run_and_return(self, cmd, sudo=None): ''' Run a command, show the message to the user if quiet isn't set, and return the return code. This is a wrapper for the OCI client to run a command and easily return the return code value (what the user is ultimately interested in)...
[ "def", "_run_and_return", "(", "self", ",", "cmd", ",", "sudo", "=", "None", ")", ":", "sudo", "=", "self", ".", "_get_sudo", "(", "sudo", ")", "result", "=", "self", ".", "_run_command", "(", "cmd", ",", "sudo", "=", "sudo", ",", "quiet", "=", "Tr...
Run a command, show the message to the user if quiet isn't set, and return the return code. This is a wrapper for the OCI client to run a command and easily return the return code value (what the user is ultimately interested in). Parameters ========== ...
[ "Run", "a", "command", "show", "the", "message", "to", "the", "user", "if", "quiet", "isn", "t", "set", "and", "return", "the", "return", "code", ".", "This", "is", "a", "wrapper", "for", "the", "OCI", "client", "to", "run", "a", "command", "and", "e...
python
train
35.357143
pmacosta/ptrie
ptrie/ptrie.py
https://github.com/pmacosta/ptrie/blob/c176d3ee810b7b5243c7ff2bbf2f1af0b0fff2a8/ptrie/ptrie.py#L1011-L1028
def is_leaf(self, name): r""" Test if a node is a leaf node (node with no children). :param name: Node name :type name: :ref:`NodeName` :rtype: boolean :raises: * RuntimeError (Argument \`name\` is not valid) * RuntimeError (Node *[name]* not in tre...
[ "def", "is_leaf", "(", "self", ",", "name", ")", ":", "if", "self", ".", "_validate_node_name", "(", "name", ")", ":", "raise", "RuntimeError", "(", "\"Argument `name` is not valid\"", ")", "self", ".", "_node_in_tree", "(", "name", ")", "return", "not", "se...
r""" Test if a node is a leaf node (node with no children). :param name: Node name :type name: :ref:`NodeName` :rtype: boolean :raises: * RuntimeError (Argument \`name\` is not valid) * RuntimeError (Node *[name]* not in tree)
[ "r", "Test", "if", "a", "node", "is", "a", "leaf", "node", "(", "node", "with", "no", "children", ")", "." ]
python
train
27.888889
IBM/ibm-cos-sdk-python-s3transfer
ibm_s3transfer/aspera/manager.py
https://github.com/IBM/ibm-cos-sdk-python-s3transfer/blob/24ba53137213e26e6b8fc2c3ec1e8198d507d22b/ibm_s3transfer/aspera/manager.py#L636-L643
def wait(self): """ Wait until all in progress and queued items are processed """ self._wait_called = True while self.tracked_coordinator_count() > 0 or \ self.waiting_coordinator_count() > 0: time.sleep(1) super(AsperaTransferCoordinatorController, self)....
[ "def", "wait", "(", "self", ")", ":", "self", ".", "_wait_called", "=", "True", "while", "self", ".", "tracked_coordinator_count", "(", ")", ">", "0", "or", "self", ".", "waiting_coordinator_count", "(", ")", ">", "0", ":", "time", ".", "sleep", "(", "...
Wait until all in progress and queued items are processed
[ "Wait", "until", "all", "in", "progress", "and", "queued", "items", "are", "processed" ]
python
train
44.125
hydpy-dev/hydpy
hydpy/core/printtools.py
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/printtools.py#L139-L248
def progressbar(iterable, length=23): """Print a simple progress bar while processing the given iterable. Function |progressbar| does print the progress bar when option `printprogress` is activted: >>> from hydpy import pub >>> pub.options.printprogress = True You can pass an iterable object....
[ "def", "progressbar", "(", "iterable", ",", "length", "=", "23", ")", ":", "if", "hydpy", ".", "pub", ".", "options", ".", "printprogress", "and", "(", "len", "(", "iterable", ")", ">", "1", ")", ":", "temp_name", "=", "os", ".", "path", ".", "join...
Print a simple progress bar while processing the given iterable. Function |progressbar| does print the progress bar when option `printprogress` is activted: >>> from hydpy import pub >>> pub.options.printprogress = True You can pass an iterable object. Say you want to calculate the the sum o...
[ "Print", "a", "simple", "progress", "bar", "while", "processing", "the", "given", "iterable", "." ]
python
train
32.481818
rameshg87/pyremotevbox
pyremotevbox/ZSI/twisted/interfaces.py
https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/twisted/interfaces.py#L20-L33
def CheckInputArgs(*interfaces): """Must provide at least one interface, the last one may be repeated. """ l = len(interfaces) def wrapper(func): def check_args(self, *args, **kw): for i in range(len(args)): if (l > i and interfaces[i].providedBy(args[i])) or interfac...
[ "def", "CheckInputArgs", "(", "*", "interfaces", ")", ":", "l", "=", "len", "(", "interfaces", ")", "def", "wrapper", "(", "func", ")", ":", "def", "check_args", "(", "self", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "for", "i", "in", "ran...
Must provide at least one interface, the last one may be repeated.
[ "Must", "provide", "at", "least", "one", "interface", "the", "last", "one", "may", "be", "repeated", "." ]
python
train
45.357143
T-002/pycast
pycast/common/timeseries.py
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/timeseries.py#L573-L590
def apply(self, method): """Applies the given ForecastingAlgorithm or SmoothingMethod from the :py:mod:`pycast.methods` module to the TimeSeries. :param BaseMethod method: Method that should be used with the TimeSeries. For more information about the methods take a look into their c...
[ "def", "apply", "(", "self", ",", "method", ")", ":", "# check, if the methods requirements are fullfilled", "if", "method", ".", "has_to_be_normalized", "(", ")", "and", "not", "self", ".", "_normalized", ":", "raise", "StandardError", "(", "\"method requires a norma...
Applies the given ForecastingAlgorithm or SmoothingMethod from the :py:mod:`pycast.methods` module to the TimeSeries. :param BaseMethod method: Method that should be used with the TimeSeries. For more information about the methods take a look into their corresponding documentation. ...
[ "Applies", "the", "given", "ForecastingAlgorithm", "or", "SmoothingMethod", "from", "the", ":", "py", ":", "mod", ":", "pycast", ".", "methods", "module", "to", "the", "TimeSeries", "." ]
python
train
44.833333
NuGrid/NuGridPy
nugridpy/astronomy.py
https://github.com/NuGrid/NuGridPy/blob/eee8047446e398be77362d82c1d8b3310054fab0/nugridpy/astronomy.py#L265-L287
def am_orb(m1,m2,a,e): ''' orbital angular momentum. e.g Ge etal2010 Parameters ---------- m1, m2 : float Masses of both stars in Msun. A : float Separation in Rsun. e : float Eccentricity ''' a_cm = a * rsun_cm m1_g = m1 * msun_g ...
[ "def", "am_orb", "(", "m1", ",", "m2", ",", "a", ",", "e", ")", ":", "a_cm", "=", "a", "*", "rsun_cm", "m1_g", "=", "m1", "*", "msun_g", "m2_g", "=", "m2", "*", "msun_g", "J_orb", "=", "np", ".", "sqrt", "(", "grav_const", "*", "a_cm", "*", "...
orbital angular momentum. e.g Ge etal2010 Parameters ---------- m1, m2 : float Masses of both stars in Msun. A : float Separation in Rsun. e : float Eccentricity
[ "orbital", "angular", "momentum", "." ]
python
train
18.304348
hazelcast/hazelcast-python-client
hazelcast/cluster.py
https://github.com/hazelcast/hazelcast-python-client/blob/3f6639443c23d6d036aa343f8e094f052250d2c1/hazelcast/cluster.py#L84-L95
def remove_listener(self, registration_id): """ Removes the specified membership listener. :param registration_id: (str), registration id of the listener to be deleted. :return: (bool), if the registration is removed, ``false`` otherwise. """ try: self.listen...
[ "def", "remove_listener", "(", "self", ",", "registration_id", ")", ":", "try", ":", "self", ".", "listeners", ".", "pop", "(", "registration_id", ")", "return", "True", "except", "KeyError", ":", "return", "False" ]
Removes the specified membership listener. :param registration_id: (str), registration id of the listener to be deleted. :return: (bool), if the registration is removed, ``false`` otherwise.
[ "Removes", "the", "specified", "membership", "listener", "." ]
python
train
33.916667
hyperledger/indy-plenum
plenum/server/node.py
https://github.com/hyperledger/indy-plenum/blob/dcd144e238af7f17a869ffc9412f13dc488b7020/plenum/server/node.py#L663-L674
def init_state_from_ledger(self, state: State, ledger: Ledger, reqHandler): """ If the trie is empty then initialize it by applying txns from ledger. """ if state.isEmpty: logger.info('{} found state to be empty, recreating from ' 'ledger'.form...
[ "def", "init_state_from_ledger", "(", "self", ",", "state", ":", "State", ",", "ledger", ":", "Ledger", ",", "reqHandler", ")", ":", "if", "state", ".", "isEmpty", ":", "logger", ".", "info", "(", "'{} found state to be empty, recreating from '", "'ledger'", "."...
If the trie is empty then initialize it by applying txns from ledger.
[ "If", "the", "trie", "is", "empty", "then", "initialize", "it", "by", "applying", "txns", "from", "ledger", "." ]
python
train
45.666667
vtkiorg/vtki
vtki/container.py
https://github.com/vtkiorg/vtki/blob/5ccad7ae6d64a03e9594c9c7474c8aab3eb22dd1/vtki/container.py#L69-L83
def combine(self, merge_points=False): """Appends all blocks into a single unstructured grid. Parameters ---------- merge_points : bool, optional Merge coincidental points. """ alg = vtk.vtkAppendFilter() for block in self: alg.AddInputDa...
[ "def", "combine", "(", "self", ",", "merge_points", "=", "False", ")", ":", "alg", "=", "vtk", ".", "vtkAppendFilter", "(", ")", "for", "block", "in", "self", ":", "alg", ".", "AddInputData", "(", "block", ")", "alg", ".", "SetMergePoints", "(", "merge...
Appends all blocks into a single unstructured grid. Parameters ---------- merge_points : bool, optional Merge coincidental points.
[ "Appends", "all", "blocks", "into", "a", "single", "unstructured", "grid", "." ]
python
train
28.333333
datacamp/antlr-ast
antlr_ast/ast.py
https://github.com/datacamp/antlr-ast/blob/d08d5eb2e663bd40501d0eeddc8a731ac7e96b11/antlr_ast/ast.py#L143-L148
def get_info(node_cfg): """Return a tuple with the verbal name of a node, and a dict of field names.""" node_cfg = node_cfg if isinstance(node_cfg, dict) else {"name": node_cfg} return node_cfg.get("name"), node_cfg.get("fields", {})
[ "def", "get_info", "(", "node_cfg", ")", ":", "node_cfg", "=", "node_cfg", "if", "isinstance", "(", "node_cfg", ",", "dict", ")", "else", "{", "\"name\"", ":", "node_cfg", "}", "return", "node_cfg", ".", "get", "(", "\"name\"", ")", ",", "node_cfg", ".",...
Return a tuple with the verbal name of a node, and a dict of field names.
[ "Return", "a", "tuple", "with", "the", "verbal", "name", "of", "a", "node", "and", "a", "dict", "of", "field", "names", "." ]
python
train
42.333333
quantmind/ccy
ccy/dates/converters.py
https://github.com/quantmind/ccy/blob/068cf6887489087cd26657a937a932e82106b47f/ccy/dates/converters.py#L53-L59
def timestamp2date(tstamp): "Converts a unix timestamp to a Python datetime object" dt = datetime.fromtimestamp(tstamp) if not dt.hour+dt.minute+dt.second+dt.microsecond: return dt.date() else: return dt
[ "def", "timestamp2date", "(", "tstamp", ")", ":", "dt", "=", "datetime", ".", "fromtimestamp", "(", "tstamp", ")", "if", "not", "dt", ".", "hour", "+", "dt", ".", "minute", "+", "dt", ".", "second", "+", "dt", ".", "microsecond", ":", "return", "dt",...
Converts a unix timestamp to a Python datetime object
[ "Converts", "a", "unix", "timestamp", "to", "a", "Python", "datetime", "object" ]
python
train
32.714286
hubo1016/aiogrpc
aiogrpc/channel.py
https://github.com/hubo1016/aiogrpc/blob/5bc98bfbe9f2e11dd0eab8e93b8aeefbcc2ccd4b/aiogrpc/channel.py#L208-L237
def future(self, request_iterator, timeout=None, metadata=None, credentials=None): """Asynchronously invokes the underlying RPC on the client. Args: request_iterator: An ASYNC iterator that yields request values for the RPC. timeout: A...
[ "def", "future", "(", "self", ",", "request_iterator", ",", "timeout", "=", "None", ",", "metadata", "=", "None", ",", "credentials", "=", "None", ")", ":", "return", "_utils", ".", "wrap_future_call", "(", "self", ".", "_inner", ".", "future", "(", "_ut...
Asynchronously invokes the underlying RPC on the client. Args: request_iterator: An ASYNC iterator that yields request values for the RPC. timeout: An optional duration of time in seconds to allow for the RPC. If None, the timeout is considered infinite. metadata: Optional :term:`m...
[ "Asynchronously", "invokes", "the", "underlying", "RPC", "on", "the", "client", "." ]
python
train
42
evhub/coconut
coconut/compiler/grammar.py
https://github.com/evhub/coconut/blob/ff97177344e7604e89a0a98a977a87ed2a56fc6d/coconut/compiler/grammar.py#L384-L398
def none_coalesce_handle(tokens): """Process the None-coalescing operator.""" if len(tokens) == 1: return tokens[0] elif tokens[0].isalnum(): return "({b} if {a} is None else {a})".format( a=tokens[0], b=none_coalesce_handle(tokens[1:]), ) else: re...
[ "def", "none_coalesce_handle", "(", "tokens", ")", ":", "if", "len", "(", "tokens", ")", "==", "1", ":", "return", "tokens", "[", "0", "]", "elif", "tokens", "[", "0", "]", ".", "isalnum", "(", ")", ":", "return", "\"({b} if {a} is None else {a})\"", "."...
Process the None-coalescing operator.
[ "Process", "the", "None", "-", "coalescing", "operator", "." ]
python
train
32.2
chrisspen/burlap
burlap/rpi.py
https://github.com/chrisspen/burlap/blob/a92b0a8e5206850bb777c74af8421ea8b33779bd/burlap/rpi.py#L439-L514
def configure_camera(self): """ Enables access to the camera. http://raspberrypi.stackexchange.com/questions/14229/how-can-i-enable-the-camera-without-using-raspi-config https://mike632t.wordpress.com/2014/06/26/raspberry-pi-camera-setup/ Afterwards, test with: ...
[ "def", "configure_camera", "(", "self", ")", ":", "#TODO:check per OS? Works on Raspbian Jessie", "r", "=", "self", ".", "local_renderer", "if", "self", ".", "env", ".", "camera_enabled", ":", "r", ".", "pc", "(", "'Enabling camera.'", ")", "#TODO:fix, doesn't work ...
Enables access to the camera. http://raspberrypi.stackexchange.com/questions/14229/how-can-i-enable-the-camera-without-using-raspi-config https://mike632t.wordpress.com/2014/06/26/raspberry-pi-camera-setup/ Afterwards, test with: /opt/vc/bin/raspistill --nopreview --output...
[ "Enables", "access", "to", "the", "camera", "." ]
python
valid
37.394737
wangwenpei/cliez
cliez/components/check.py
https://github.com/wangwenpei/cliez/blob/d6fe775544cd380735c56c8a4a79bc2ad22cb6c4/cliez/components/check.py#L22-L64
def run(self, options): """ .. todo:: check network connection :param Namespace options: parse result from argparse :return: """ self.logger.debug("debug enabled...") depends = ['git'] nil_tools = [] self.logger.info("depends list: ...
[ "def", "run", "(", "self", ",", "options", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"debug enabled...\"", ")", "depends", "=", "[", "'git'", "]", "nil_tools", "=", "[", "]", "self", ".", "logger", ".", "info", "(", "\"depends list: %s\"", ...
.. todo:: check network connection :param Namespace options: parse result from argparse :return:
[ "..", "todo", "::" ]
python
valid
30.325581
manns/pyspread
pyspread/src/lib/vlc.py
https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/lib/vlc.py#L3919-L3929
def libvlc_event_detach(p_event_manager, i_event_type, f_callback, p_user_data): '''Unregister an event notification. @param p_event_manager: the event manager. @param i_event_type: the desired event to which we want to unregister. @param f_callback: the function to call when i_event_type occurs. @p...
[ "def", "libvlc_event_detach", "(", "p_event_manager", ",", "i_event_type", ",", "f_callback", ",", "p_user_data", ")", ":", "f", "=", "_Cfunctions", ".", "get", "(", "'libvlc_event_detach'", ",", "None", ")", "or", "_Cfunction", "(", "'libvlc_event_detach'", ",", ...
Unregister an event notification. @param p_event_manager: the event manager. @param i_event_type: the desired event to which we want to unregister. @param f_callback: the function to call when i_event_type occurs. @param p_user_data: user provided data to carry with the event.
[ "Unregister", "an", "event", "notification", "." ]
python
train
60.272727
photo/openphoto-python
trovebox/api/api_album.py
https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_album.py#L54-L64
def delete(self, album, **kwds): """ Endpoint: /album/<id>/delete.json Deletes an album. Returns True if successful. Raises a TroveboxError if not. """ return self._client.post("/album/%s/delete.json" % self._extract_id(album), ...
[ "def", "delete", "(", "self", ",", "album", ",", "*", "*", "kwds", ")", ":", "return", "self", ".", "_client", ".", "post", "(", "\"/album/%s/delete.json\"", "%", "self", ".", "_extract_id", "(", "album", ")", ",", "*", "*", "kwds", ")", "[", "\"resu...
Endpoint: /album/<id>/delete.json Deletes an album. Returns True if successful. Raises a TroveboxError if not.
[ "Endpoint", ":", "/", "album", "/", "<id", ">", "/", "delete", ".", "json" ]
python
train
32.545455
materialsproject/pymatgen
pymatgen/core/structure.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/core/structure.py#L134-L139
def group_by_types(self): """Iterate over species grouped by type""" for t in self.types_of_specie: for site in self: if site.specie == t: yield site
[ "def", "group_by_types", "(", "self", ")", ":", "for", "t", "in", "self", ".", "types_of_specie", ":", "for", "site", "in", "self", ":", "if", "site", ".", "specie", "==", "t", ":", "yield", "site" ]
Iterate over species grouped by type
[ "Iterate", "over", "species", "grouped", "by", "type" ]
python
train
34.666667
googleapis/google-auth-library-python
google/auth/compute_engine/_metadata.py
https://github.com/googleapis/google-auth-library-python/blob/2c6ad78917e936f38f87c946209c8031166dc96e/google/auth/compute_engine/_metadata.py#L92-L140
def get(request, path, root=_METADATA_ROOT, recursive=False): """Fetch a resource from the metadata server. Args: request (google.auth.transport.Request): A callable used to make HTTP requests. path (str): The resource to retrieve. For example, ``'instance/service-accoun...
[ "def", "get", "(", "request", ",", "path", ",", "root", "=", "_METADATA_ROOT", ",", "recursive", "=", "False", ")", ":", "base_url", "=", "urlparse", ".", "urljoin", "(", "root", ",", "path", ")", "query_params", "=", "{", "}", "if", "recursive", ":", ...
Fetch a resource from the metadata server. Args: request (google.auth.transport.Request): A callable used to make HTTP requests. path (str): The resource to retrieve. For example, ``'instance/service-accounts/default'``. root (str): The full path to the metadata serv...
[ "Fetch", "a", "resource", "from", "the", "metadata", "server", "." ]
python
train
39.061224
tuxu/python-samplerate
samplerate/converters.py
https://github.com/tuxu/python-samplerate/blob/ed73d7a39e61bfb34b03dade14ffab59aa27922a/samplerate/converters.py#L31-L90
def resample(input_data, ratio, converter_type='sinc_best', verbose=False): """Resample the signal in `input_data` at once. Parameters ---------- input_data : ndarray Input data. A single channel is provided as a 1D array of `num_frames` length. Input data with several channels is repre...
[ "def", "resample", "(", "input_data", ",", "ratio", ",", "converter_type", "=", "'sinc_best'", ",", "verbose", "=", "False", ")", ":", "from", "samplerate", ".", "lowlevel", "import", "src_simple", "from", "samplerate", ".", "exceptions", "import", "ResamplingEr...
Resample the signal in `input_data` at once. Parameters ---------- input_data : ndarray Input data. A single channel is provided as a 1D array of `num_frames` length. Input data with several channels is represented as a 2D array of shape (`num_frames`, `num_channels`). For use with ...
[ "Resample", "the", "signal", "in", "input_data", "at", "once", "." ]
python
train
35.7
glut23/webvtt-py
webvtt/webvtt.py
https://github.com/glut23/webvtt-py/blob/7b4da0123c2e2afaf31402107528721eb1d3d481/webvtt/webvtt.py#L58-L61
def read(cls, file): """Reads a WebVTT captions file.""" parser = WebVTTParser().read(file) return cls(file=file, captions=parser.captions, styles=parser.styles)
[ "def", "read", "(", "cls", ",", "file", ")", ":", "parser", "=", "WebVTTParser", "(", ")", ".", "read", "(", "file", ")", "return", "cls", "(", "file", "=", "file", ",", "captions", "=", "parser", ".", "captions", ",", "styles", "=", "parser", ".",...
Reads a WebVTT captions file.
[ "Reads", "a", "WebVTT", "captions", "file", "." ]
python
train
45.5
brocade/pynos
pynos/versions/base/interface.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/interface.py#L2708-L2727
def get_interface_detail_request(last_interface_name, last_interface_type): """ Creates a new Netconf request based on the last received interface name and type when the hasMore flag is true """ request_interface = ET.Element( 'get-interf...
[ "def", "get_interface_detail_request", "(", "last_interface_name", ",", "last_interface_type", ")", ":", "request_interface", "=", "ET", ".", "Element", "(", "'get-interface-detail'", ",", "xmlns", "=", "\"urn:brocade.com:mgmt:brocade-interface-ext\"", ")", "if", "last_inte...
Creates a new Netconf request based on the last received interface name and type when the hasMore flag is true
[ "Creates", "a", "new", "Netconf", "request", "based", "on", "the", "last", "received", "interface", "name", "and", "type", "when", "the", "hasMore", "flag", "is", "true" ]
python
train
47.85
TissueMAPS/TmClient
src/python/tmclient/api.py
https://github.com/TissueMAPS/TmClient/blob/6fb40622af19142cb5169a64b8c2965993a25ab1/src/python/tmclient/api.py#L2203-L2253
def download_feature_values_and_metadata_files(self, mapobject_type_name, directory, parallel=1): '''Downloads all feature values for the given object type and stores the data as *CSV* files on disk. Parameters ---------- mapobj...
[ "def", "download_feature_values_and_metadata_files", "(", "self", ",", "mapobject_type_name", ",", "directory", ",", "parallel", "=", "1", ")", ":", "def", "download_per_well", "(", "well", ")", ":", "logger", ".", "info", "(", "'download feature data at well: plate=%...
Downloads all feature values for the given object type and stores the data as *CSV* files on disk. Parameters ---------- mapobject_type_name: str type of the segmented objects directory: str absolute path to the directory on disk where the file should be ...
[ "Downloads", "all", "feature", "values", "for", "the", "given", "object", "type", "and", "stores", "the", "data", "as", "*", "CSV", "*", "files", "on", "disk", "." ]
python
train
41.509804
saltstack/salt
salt/states/ipmi.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/ipmi.py#L260-L297
def user_absent(name, channel=14, **kwargs): ''' Remove user Delete all user (uid) records having the matching name. name string name of user to delete channel channel to remove user access from defaults to 14 for auto. kwargs - api_host=localhost - api_user=ad...
[ "def", "user_absent", "(", "name", ",", "channel", "=", "14", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'result'", ":", "False", ",", "'comment'", ":", "''", ",", "'changes'", ":", "{", "}", "}", "user_id_list...
Remove user Delete all user (uid) records having the matching name. name string name of user to delete channel channel to remove user access from defaults to 14 for auto. kwargs - api_host=localhost - api_user=admin - api_pass= - api_port=623 - ...
[ "Remove", "user", "Delete", "all", "user", "(", "uid", ")", "records", "having", "the", "matching", "name", "." ]
python
train
26.394737
marshmallow-code/marshmallow
src/marshmallow/schema.py
https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/schema.py#L491-L559
def dump(self, obj, many=None): """Serialize an object to native Python data types according to this Schema's fields. :param obj: The object to serialize. :param bool many: Whether to serialize `obj` as a collection. If `None`, the value for `self.many` is used. :ret...
[ "def", "dump", "(", "self", ",", "obj", ",", "many", "=", "None", ")", ":", "error_store", "=", "ErrorStore", "(", ")", "errors", "=", "{", "}", "many", "=", "self", ".", "many", "if", "many", "is", "None", "else", "bool", "(", "many", ")", "if",...
Serialize an object to native Python data types according to this Schema's fields. :param obj: The object to serialize. :param bool many: Whether to serialize `obj` as a collection. If `None`, the value for `self.many` is used. :return: A dict of serialized data :rty...
[ "Serialize", "an", "object", "to", "native", "Python", "data", "types", "according", "to", "this", "Schema", "s", "fields", "." ]
python
train
32.637681
mitsei/dlkit
dlkit/json_/cataloging/managers.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/managers.py#L384-L401
def get_catalog_hierarchy_design_session(self, proxy): """Gets the catalog hierarchy design session. arg: proxy (osid.proxy.Proxy): proxy return: (osid.cataloging.CatalogHierarchyDesignSession) - a ``CatalogHierarchyDesignSession`` raise: NullArgument - ``proxy`` is ...
[ "def", "get_catalog_hierarchy_design_session", "(", "self", ",", "proxy", ")", ":", "if", "not", "self", ".", "supports_catalog_hierarchy_design", "(", ")", ":", "raise", "errors", ".", "Unimplemented", "(", ")", "# pylint: disable=no-member", "return", "sessions", ...
Gets the catalog hierarchy design session. arg: proxy (osid.proxy.Proxy): proxy return: (osid.cataloging.CatalogHierarchyDesignSession) - a ``CatalogHierarchyDesignSession`` raise: NullArgument - ``proxy`` is null raise: OperationFailed - unable to complete request ...
[ "Gets", "the", "catalog", "hierarchy", "design", "session", "." ]
python
train
46.444444
adamcharnock/swiftwind
swiftwind/dashboard/views.py
https://github.com/adamcharnock/swiftwind/blob/72c715800841c3b2feabded3f3b65b76388b4cea/swiftwind/dashboard/views.py#L15-L22
def get_balance_context(self): """Get the high level balances""" bank_account = Account.objects.get(name='Bank') return dict( bank=bank_account, retained_earnings_accounts=Account.objects.filter(parent__name='Retained Earnings'), )
[ "def", "get_balance_context", "(", "self", ")", ":", "bank_account", "=", "Account", ".", "objects", ".", "get", "(", "name", "=", "'Bank'", ")", "return", "dict", "(", "bank", "=", "bank_account", ",", "retained_earnings_accounts", "=", "Account", ".", "obj...
Get the high level balances
[ "Get", "the", "high", "level", "balances" ]
python
train
35.125
romana/vpc-router
vpcrouter/watcher/plugins/configfile.py
https://github.com/romana/vpc-router/blob/d696c2e023f1111ceb61f9c6fbabfafed8e14040/vpcrouter/watcher/plugins/configfile.py#L187-L195
def add_arguments(cls, parser, sys_arg_list=None): """ Arguments for the configfile mode. """ parser.add_argument('-f', '--file', dest='file', required=True, help="config file for routing groups " "(only in configfile mode)") ...
[ "def", "add_arguments", "(", "cls", ",", "parser", ",", "sys_arg_list", "=", "None", ")", ":", "parser", ".", "add_argument", "(", "'-f'", ",", "'--file'", ",", "dest", "=", "'file'", ",", "required", "=", "True", ",", "help", "=", "\"config file for routi...
Arguments for the configfile mode.
[ "Arguments", "for", "the", "configfile", "mode", "." ]
python
train
37.222222
sunt05/SuPy
src/supy/supy_save.py
https://github.com/sunt05/SuPy/blob/47178bd5aee50a059414e3e504940662fbfae0dc/src/supy/supy_save.py#L12-L40
def gen_df_save(df_grid_group: pd.DataFrame)->pd.DataFrame: '''generate a dataframe for saving Parameters ---------- df_output_grid_group : pd.DataFrame an output dataframe of a single group and grid Returns ------- pd.DataFrame a dataframe with date time info prepended for...
[ "def", "gen_df_save", "(", "df_grid_group", ":", "pd", ".", "DataFrame", ")", "->", "pd", ".", "DataFrame", ":", "# generate df_datetime for prepending", "idx_dt", "=", "df_grid_group", ".", "index", "ser_year", "=", "pd", ".", "Series", "(", "idx_dt", ".", "y...
generate a dataframe for saving Parameters ---------- df_output_grid_group : pd.DataFrame an output dataframe of a single group and grid Returns ------- pd.DataFrame a dataframe with date time info prepended for saving
[ "generate", "a", "dataframe", "for", "saving" ]
python
train
32.517241
TaurusOlson/fntools
fntools/fntools.py
https://github.com/TaurusOlson/fntools/blob/316080c7b5bfdd88c9f3fac4a67deb5be3c319e5/fntools/fntools.py#L446-L456
def duplicates(coll): """Return the duplicated items in the given collection :param coll: a collection :returns: a list of the duplicated items in the collection >>> duplicates([1, 1, 2, 3, 3, 4, 1, 1]) [1, 3] """ return list(set(x for x in coll if coll.count(x) > 1))
[ "def", "duplicates", "(", "coll", ")", ":", "return", "list", "(", "set", "(", "x", "for", "x", "in", "coll", "if", "coll", ".", "count", "(", "x", ")", ">", "1", ")", ")" ]
Return the duplicated items in the given collection :param coll: a collection :returns: a list of the duplicated items in the collection >>> duplicates([1, 1, 2, 3, 3, 4, 1, 1]) [1, 3]
[ "Return", "the", "duplicated", "items", "in", "the", "given", "collection" ]
python
train
26.272727
cbclab/MOT
mot/cl_routines/numerical_differentiation.py
https://github.com/cbclab/MOT/blob/fb3243b65025705842e82704705c00902f9a35af/mot/cl_routines/numerical_differentiation.py#L15-L135
def estimate_hessian(objective_func, parameters, lower_bounds=None, upper_bounds=None, step_ratio=2, nmr_steps=5, max_step_sizes=None, data=None, cl_runtime_info=None): """Estimate and return the upper triangular elements of the Hes...
[ "def", "estimate_hessian", "(", "objective_func", ",", "parameters", ",", "lower_bounds", "=", "None", ",", "upper_bounds", "=", "None", ",", "step_ratio", "=", "2", ",", "nmr_steps", "=", "5", ",", "max_step_sizes", "=", "None", ",", "data", "=", "None", ...
Estimate and return the upper triangular elements of the Hessian of the given function at the given parameters. This calculates the Hessian using central difference (using a 2nd order Taylor expansion) with a Richardson extrapolation over the proposed sequence of steps. If enough steps are given, we apply a Wy...
[ "Estimate", "and", "return", "the", "upper", "triangular", "elements", "of", "the", "Hessian", "of", "the", "given", "function", "at", "the", "given", "parameters", "." ]
python
train
50.438017
h2oai/h2o-3
h2o-py/h2o/utils/shared_utils.py
https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/utils/shared_utils.py#L282-L328
def get_human_readable_time(time_ms): """ Convert given duration in milliseconds into a human-readable representation, i.e. hours, minutes, seconds, etc. More specifically, the returned string may look like following: 1 day 3 hours 12 mins 3 days 0 hours 0 mins 8 hours 12 mins ...
[ "def", "get_human_readable_time", "(", "time_ms", ")", ":", "millis", "=", "time_ms", "%", "1000", "secs", "=", "(", "time_ms", "//", "1000", ")", "%", "60", "mins", "=", "(", "time_ms", "//", "60000", ")", "%", "60", "hours", "=", "(", "time_ms", "/...
Convert given duration in milliseconds into a human-readable representation, i.e. hours, minutes, seconds, etc. More specifically, the returned string may look like following: 1 day 3 hours 12 mins 3 days 0 hours 0 mins 8 hours 12 mins 34 mins 02 secs 13 secs 541 ms ...
[ "Convert", "given", "duration", "in", "milliseconds", "into", "a", "human", "-", "readable", "representation", "i", ".", "e", ".", "hours", "minutes", "seconds", "etc", ".", "More", "specifically", "the", "returned", "string", "may", "look", "like", "following...
python
test
32.361702
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/parallel/apps/ipengineapp.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/parallel/apps/ipengineapp.py#L203-L231
def load_connector_file(self): """load config from a JSON connector file, at a *lower* priority than command-line/config files. """ self.log.info("Loading url_file %r", self.url_file) config = self.config with open(self.url_file) as f: d = js...
[ "def", "load_connector_file", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "\"Loading url_file %r\"", ",", "self", ".", "url_file", ")", "config", "=", "self", ".", "config", "with", "open", "(", "self", ".", "url_file", ")", "as", "f", ...
load config from a JSON connector file, at a *lower* priority than command-line/config files.
[ "load", "config", "from", "a", "JSON", "connector", "file", "at", "a", "*", "lower", "*", "priority", "than", "command", "-", "line", "/", "config", "files", "." ]
python
test
31.862069
quantopian/zipline
zipline/extensions.py
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/extensions.py#L110-L124
def load(self, name): """Construct an object from a registered factory. Parameters ---------- name : str Name with which the factory was registered. """ try: return self._factories[name]() except KeyError: raise ValueError( ...
[ "def", "load", "(", "self", ",", "name", ")", ":", "try", ":", "return", "self", ".", "_factories", "[", "name", "]", "(", ")", "except", "KeyError", ":", "raise", "ValueError", "(", "\"no %s factory registered under name %r, options are: %r\"", "%", "(", "sel...
Construct an object from a registered factory. Parameters ---------- name : str Name with which the factory was registered.
[ "Construct", "an", "object", "from", "a", "registered", "factory", "." ]
python
train
31.066667
sebp/scikit-survival
sksurv/preprocessing.py
https://github.com/sebp/scikit-survival/blob/cfc99fd20454cdd6f4f20fe331b39f2191ccaabc/sksurv/preprocessing.py#L102-L123
def transform(self, X): """Convert categorical columns to numeric values. Parameters ---------- X : pandas.DataFrame Data to encode. Returns ------- Xt : pandas.DataFrame Encoded data. """ check_is_fitted(self, "encoded_co...
[ "def", "transform", "(", "self", ",", "X", ")", ":", "check_is_fitted", "(", "self", ",", "\"encoded_columns_\"", ")", "check_columns_exist", "(", "X", ".", "columns", ",", "self", ".", "feature_names_", ")", "Xt", "=", "X", ".", "copy", "(", ")", "for",...
Convert categorical columns to numeric values. Parameters ---------- X : pandas.DataFrame Data to encode. Returns ------- Xt : pandas.DataFrame Encoded data.
[ "Convert", "categorical", "columns", "to", "numeric", "values", "." ]
python
train
27.727273
dropbox/pyannotate
pyannotate_tools/annotations/infer.py
https://github.com/dropbox/pyannotate/blob/d128c76b8a86f208e5c78716f2a917003650cebc/pyannotate_tools/annotations/infer.py#L166-L191
def is_redundant_union_item(first, other): # type: (AbstractType, AbstractType) -> bool """If union has both items, is the first one redundant? For example, if first is 'str' and the other is 'Text', return True. If items are equal, return False. """ if isinstance(first, ClassType) and isinsta...
[ "def", "is_redundant_union_item", "(", "first", ",", "other", ")", ":", "# type: (AbstractType, AbstractType) -> bool", "if", "isinstance", "(", "first", ",", "ClassType", ")", "and", "isinstance", "(", "other", ",", "ClassType", ")", ":", "if", "first", ".", "n...
If union has both items, is the first one redundant? For example, if first is 'str' and the other is 'Text', return True. If items are equal, return False.
[ "If", "union", "has", "both", "items", "is", "the", "first", "one", "redundant?" ]
python
train
40.346154
reorx/torext
examples/formal_project/manage.py
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/examples/formal_project/manage.py#L20-L27
def run(**kwargs): """Command to run server, pass `--PORT 9000`, `--TEMPLATE_PATH templates` as arguments to affect on global settings object. """ from sampleproject.app import app app.update_settings(**kwargs) app.run()
[ "def", "run", "(", "*", "*", "kwargs", ")", ":", "from", "sampleproject", ".", "app", "import", "app", "app", ".", "update_settings", "(", "*", "*", "kwargs", ")", "app", ".", "run", "(", ")" ]
Command to run server, pass `--PORT 9000`, `--TEMPLATE_PATH templates` as arguments to affect on global settings object.
[ "Command", "to", "run", "server", "pass", "--", "PORT", "9000", "--", "TEMPLATE_PATH", "templates", "as", "arguments", "to", "affect", "on", "global", "settings", "object", "." ]
python
train
29.75
saltstack/salt
salt/states/vagrant.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/vagrant.py#L77-L127
def _vagrant_call(node, function, section, comment, status_when_done=None, **kwargs): ''' Helper to call the vagrant functions. Wildcards supported. :param node: The Salt-id or wildcard :param function: the vagrant submodule to call :param section: the name for the state call. :param comment: w...
[ "def", "_vagrant_call", "(", "node", ",", "function", ",", "section", ",", "comment", ",", "status_when_done", "=", "None", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "'name'", ":", "node", ",", "'changes'", ":", "{", "}", ",", "'result'", "...
Helper to call the vagrant functions. Wildcards supported. :param node: The Salt-id or wildcard :param function: the vagrant submodule to call :param section: the name for the state call. :param comment: what the state reply should say :param status_when_done: the Vagrant status expected for this s...
[ "Helper", "to", "call", "the", "vagrant", "functions", ".", "Wildcards", "supported", "." ]
python
train
40.117647
swharden/SWHLab
doc/oldcode/swhlab/core/abf.py
https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/abf.py#L432-L467
def average_data(self,ranges=[[None,None]],percentile=None): """ given a list of ranges, return single point averages for every sweep. Units are in seconds. Expects something like: ranges=[[1,2],[4,5],[7,7.5]] None values will be replaced with maximum/minimum bounds. ...
[ "def", "average_data", "(", "self", ",", "ranges", "=", "[", "[", "None", ",", "None", "]", "]", ",", "percentile", "=", "None", ")", ":", "ranges", "=", "copy", ".", "deepcopy", "(", "ranges", ")", "#TODO: make this cleaner. Why needed?", "# clean up ranges...
given a list of ranges, return single point averages for every sweep. Units are in seconds. Expects something like: ranges=[[1,2],[4,5],[7,7.5]] None values will be replaced with maximum/minimum bounds. For baseline subtraction, make a range baseline then sub it youtself. ...
[ "given", "a", "list", "of", "ranges", "return", "single", "point", "averages", "for", "every", "sweep", ".", "Units", "are", "in", "seconds", ".", "Expects", "something", "like", ":", "ranges", "=", "[[", "1", "2", "]", "[", "4", "5", "]", "[", "7", ...
python
valid
45.111111
explosion/spaCy
spacy/pipeline/functions.py
https://github.com/explosion/spaCy/blob/8ee4100f8ffb336886208a1ea827bf4c745e2709/spacy/pipeline/functions.py#L24-L36
def merge_entities(doc): """Merge entities into a single token. doc (Doc): The Doc object. RETURNS (Doc): The Doc object with merged entities. DOCS: https://spacy.io/api/pipeline-functions#merge_entities """ with doc.retokenize() as retokenizer: for ent in doc.ents: attrs =...
[ "def", "merge_entities", "(", "doc", ")", ":", "with", "doc", ".", "retokenize", "(", ")", "as", "retokenizer", ":", "for", "ent", "in", "doc", ".", "ents", ":", "attrs", "=", "{", "\"tag\"", ":", "ent", ".", "root", ".", "tag", ",", "\"dep\"", ":"...
Merge entities into a single token. doc (Doc): The Doc object. RETURNS (Doc): The Doc object with merged entities. DOCS: https://spacy.io/api/pipeline-functions#merge_entities
[ "Merge", "entities", "into", "a", "single", "token", "." ]
python
train
33.615385
kankiri/pabiana
demos/collection/timer.py
https://github.com/kankiri/pabiana/blob/74acfdd81e2a1cc411c37b9ee3d6905ce4b1a39b/demos/collection/timer.py#L18-L28
def place(slot_name, dttime): """ Set a timer to be published at the specified minute. """ dttime = datetime.strptime(dttime, '%Y-%m-%d %H:%M:%S') dttime = dttime.replace(second=0, microsecond=0) try: area.context['timers'][dttime].add(slot_name) except KeyError: area.context['timers'][dttime] = {slot_name} ...
[ "def", "place", "(", "slot_name", ",", "dttime", ")", ":", "dttime", "=", "datetime", ".", "strptime", "(", "dttime", ",", "'%Y-%m-%d %H:%M:%S'", ")", "dttime", "=", "dttime", ".", "replace", "(", "second", "=", "0", ",", "microsecond", "=", "0", ")", ...
Set a timer to be published at the specified minute.
[ "Set", "a", "timer", "to", "be", "published", "at", "the", "specified", "minute", "." ]
python
train
32.818182
snbuback/django_services
django_services/service/core.py
https://github.com/snbuback/django_services/blob/58cbdea878bb11197add0ed1008a9206e4d92671/django_services/service/core.py#L151-L155
def filter_objects(self, objects, perm=None): """ Return only objects with specified permission in objects list. If perm not specified, 'view' perm will be used. """ if perm is None: perm = build_permission_name(self.model_class, 'view') return filter(lambda o: self.user.has_perm(per...
[ "def", "filter_objects", "(", "self", ",", "objects", ",", "perm", "=", "None", ")", ":", "if", "perm", "is", "None", ":", "perm", "=", "build_permission_name", "(", "self", ".", "model_class", ",", "'view'", ")", "return", "filter", "(", "lambda", "o", ...
Return only objects with specified permission in objects list. If perm not specified, 'view' perm will be used.
[ "Return", "only", "objects", "with", "specified", "permission", "in", "objects", "list", ".", "If", "perm", "not", "specified", "view", "perm", "will", "be", "used", "." ]
python
train
67
kislyuk/aegea
aegea/packages/github3/issues/issue.py
https://github.com/kislyuk/aegea/blob/94957e9dba036eae3052e2662c208b259c08399a/aegea/packages/github3/issues/issue.py#L175-L203
def edit(self, title=None, body=None, assignee=None, state=None, milestone=None, labels=None): """Edit this issue. :param str title: Title of the issue :param str body: markdown formatted body (description) of the issue :param str assignee: login name of user the issue shou...
[ "def", "edit", "(", "self", ",", "title", "=", "None", ",", "body", "=", "None", ",", "assignee", "=", "None", ",", "state", "=", "None", ",", "milestone", "=", "None", ",", "labels", "=", "None", ")", ":", "json", "=", "None", "data", "=", "{", ...
Edit this issue. :param str title: Title of the issue :param str body: markdown formatted body (description) of the issue :param str assignee: login name of user the issue should be assigned to :param str state: accepted values: ('open', 'closed') :param int mileston...
[ "Edit", "this", "issue", "." ]
python
train
42.310345
nesaro/pydsl
pydsl/lex.py
https://github.com/nesaro/pydsl/blob/00b4fffd72036b80335e1a44a888fac57917ab41/pydsl/lex.py#L141-L143
def is_subset(a, b): """Excluding same size""" return b.left <= a.left and b.right > a.right or b.left < a.left and b.right >= a.right
[ "def", "is_subset", "(", "a", ",", "b", ")", ":", "return", "b", ".", "left", "<=", "a", ".", "left", "and", "b", ".", "right", ">", "a", ".", "right", "or", "b", ".", "left", "<", "a", ".", "left", "and", "b", ".", "right", ">=", "a", ".",...
Excluding same size
[ "Excluding", "same", "size" ]
python
train
46.666667
juanifioren/django-oidc-provider
oidc_provider/lib/utils/token.py
https://github.com/juanifioren/django-oidc-provider/blob/f0daed07b2ac7608565b80d4c80ccf04d8c416a8/oidc_provider/lib/utils/token.py#L22-L69
def create_id_token(token, user, aud, nonce='', at_hash='', request=None, scope=None): """ Creates the id_token dictionary. See: http://openid.net/specs/openid-connect-core-1_0.html#IDToken Return a dic. """ if scope is None: scope = [] sub = settings.get('OIDC_IDTOKEN_SUB_GENERATOR'...
[ "def", "create_id_token", "(", "token", ",", "user", ",", "aud", ",", "nonce", "=", "''", ",", "at_hash", "=", "''", ",", "request", "=", "None", ",", "scope", "=", "None", ")", ":", "if", "scope", "is", "None", ":", "scope", "=", "[", "]", "sub"...
Creates the id_token dictionary. See: http://openid.net/specs/openid-connect-core-1_0.html#IDToken Return a dic.
[ "Creates", "the", "id_token", "dictionary", ".", "See", ":", "http", ":", "//", "openid", ".", "net", "/", "specs", "/", "openid", "-", "connect", "-", "core", "-", "1_0", ".", "html#IDToken", "Return", "a", "dic", "." ]
python
train
30.291667
scott-griffiths/bitstring
bitstring.py
https://github.com/scott-griffiths/bitstring/blob/ab40ae7f0b43fe223a39b63cbc0529b09f3ef653/bitstring.py#L157-L160
def getbyteslice(self, start, end): """Direct access to byte data.""" c = self._rawarray[start:end] return c
[ "def", "getbyteslice", "(", "self", ",", "start", ",", "end", ")", ":", "c", "=", "self", ".", "_rawarray", "[", "start", ":", "end", "]", "return", "c" ]
Direct access to byte data.
[ "Direct", "access", "to", "byte", "data", "." ]
python
train
32.25
gmr/rejected
rejected/consumer.py
https://github.com/gmr/rejected/blob/610a3e1401122ecb98d891b6795cca0255e5b044/rejected/consumer.py#L1207-L1223
def _validate_message_type(self): """Check to see if the current message's AMQP type property is supported and if not, raise either a :exc:`DropMessage` or :exc:`MessageException`. :raises: DropMessage :raises: MessageException """ if self._unsupported_message_t...
[ "def", "_validate_message_type", "(", "self", ")", ":", "if", "self", ".", "_unsupported_message_type", "(", ")", ":", "self", ".", "logger", ".", "warning", "(", "'Received unsupported message type: %s'", ",", "self", ".", "message_type", ")", "if", "self", "."...
Check to see if the current message's AMQP type property is supported and if not, raise either a :exc:`DropMessage` or :exc:`MessageException`. :raises: DropMessage :raises: MessageException
[ "Check", "to", "see", "if", "the", "current", "message", "s", "AMQP", "type", "property", "is", "supported", "and", "if", "not", "raise", "either", "a", ":", "exc", ":", "DropMessage", "or", ":", "exc", ":", "MessageException", "." ]
python
train
37.117647
pipermerriam/ethereum-client-utils
eth_client_utils/client.py
https://github.com/pipermerriam/ethereum-client-utils/blob/34d0976305a262200a1159b2f336b69ce4f02d70/eth_client_utils/client.py#L72-L85
def default_from_address(self): """ Cache the coinbase address so that we don't make two requests for every single transaction. """ if self._coinbase_cache_til is not None: if time.time - self._coinbase_cache_til > 30: self._coinbase_cache_til = None ...
[ "def", "default_from_address", "(", "self", ")", ":", "if", "self", ".", "_coinbase_cache_til", "is", "not", "None", ":", "if", "time", ".", "time", "-", "self", ".", "_coinbase_cache_til", ">", "30", ":", "self", ".", "_coinbase_cache_til", "=", "None", "...
Cache the coinbase address so that we don't make two requests for every single transaction.
[ "Cache", "the", "coinbase", "address", "so", "that", "we", "don", "t", "make", "two", "requests", "for", "every", "single", "transaction", "." ]
python
train
34.5
wuher/devil
devil/mappers/xmlmapper.py
https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/devil/mappers/xmlmapper.py#L78-L91
def _format_data(self, data, charset): """ Format data into XML. """ if data is None or data == '': return u'' stream = StringIO.StringIO() xml = SimplerXMLGenerator(stream, charset) xml.startDocument() xml.startElement(self._root_element_name(), {}) ...
[ "def", "_format_data", "(", "self", ",", "data", ",", "charset", ")", ":", "if", "data", "is", "None", "or", "data", "==", "''", ":", "return", "u''", "stream", "=", "StringIO", ".", "StringIO", "(", ")", "xml", "=", "SimplerXMLGenerator", "(", "stream...
Format data into XML.
[ "Format", "data", "into", "XML", "." ]
python
train
31.428571
python/performance
performance/benchmarks/bm_regex_effbot.py
https://github.com/python/performance/blob/2a9524c0a5714e85106671bc61d750e800fe17db/performance/benchmarks/bm_regex_effbot.py#L60-L94
def gen_string_table(n): """Generates the list of strings that will be used in the benchmarks. All strings have repeated prefixes and suffices, and n specifies the number of repetitions. """ strings = [] def append(s): if USE_BYTES_IN_PY3K: strings.append(s.encode('latin1')...
[ "def", "gen_string_table", "(", "n", ")", ":", "strings", "=", "[", "]", "def", "append", "(", "s", ")", ":", "if", "USE_BYTES_IN_PY3K", ":", "strings", ".", "append", "(", "s", ".", "encode", "(", "'latin1'", ")", ")", "else", ":", "strings", ".", ...
Generates the list of strings that will be used in the benchmarks. All strings have repeated prefixes and suffices, and n specifies the number of repetitions.
[ "Generates", "the", "list", "of", "strings", "that", "will", "be", "used", "in", "the", "benchmarks", "." ]
python
test
34.828571
bokeh/bokeh
_setup_support.py
https://github.com/bokeh/bokeh/blob/dc8cf49e4e4302fd38537ad089ece81fbcca4737/_setup_support.py#L203-L223
def get_cmdclass(): ''' A ``cmdclass`` that works around a setuptools deficiency. There is no need to build wheels when installing a package, however some versions of setuptools seem to mandate this. This is a hacky workaround that modifies the ``cmdclass`` returned by versioneer so that not having ...
[ "def", "get_cmdclass", "(", ")", ":", "cmdclass", "=", "versioneer", ".", "get_cmdclass", "(", ")", "try", ":", "from", "wheel", ".", "bdist_wheel", "import", "bdist_wheel", "except", "ImportError", ":", "# pip is not claiming for bdist_wheel when wheel is not installed...
A ``cmdclass`` that works around a setuptools deficiency. There is no need to build wheels when installing a package, however some versions of setuptools seem to mandate this. This is a hacky workaround that modifies the ``cmdclass`` returned by versioneer so that not having wheel installed is not a fa...
[ "A", "cmdclass", "that", "works", "around", "a", "setuptools", "deficiency", "." ]
python
train
32.047619
awacha/sastool
sastool/misc/easylsq.py
https://github.com/awacha/sastool/blob/deaddfa3002f3f6818697e36139633b7e30427a3/sastool/misc/easylsq.py#L217-L319
def nlsq_fit(x, y, dy, func, params_init, verbose=False, **kwargs): """Perform a non-linear least squares fit Inputs: x: one-dimensional numpy array of the independent variable y: one-dimensional numpy array of the dependent variable dy: absolute error (square root of the variance) of t...
[ "def", "nlsq_fit", "(", "x", ",", "y", ",", "dy", ",", "func", ",", "params_init", ",", "verbose", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "verbose", ":", "t0", "=", "time", ".", "monotonic", "(", ")", "print", "(", "\"nlsq_fit start...
Perform a non-linear least squares fit Inputs: x: one-dimensional numpy array of the independent variable y: one-dimensional numpy array of the dependent variable dy: absolute error (square root of the variance) of the dependent variable. Either a one-dimensional numpy array or ...
[ "Perform", "a", "non", "-", "linear", "least", "squares", "fit" ]
python
train
45
pallets/werkzeug
src/werkzeug/formparser.py
https://github.com/pallets/werkzeug/blob/a220671d66755a94630a212378754bb432811158/src/werkzeug/formparser.py#L197-L206
def parse_from_environ(self, environ): """Parses the information from the environment as form data. :param environ: the WSGI environment to be used for parsing. :return: A tuple in the form ``(stream, form, files)``. """ content_type = environ.get("CONTENT_TYPE", "") con...
[ "def", "parse_from_environ", "(", "self", ",", "environ", ")", ":", "content_type", "=", "environ", ".", "get", "(", "\"CONTENT_TYPE\"", ",", "\"\"", ")", "content_length", "=", "get_content_length", "(", "environ", ")", "mimetype", ",", "options", "=", "parse...
Parses the information from the environment as form data. :param environ: the WSGI environment to be used for parsing. :return: A tuple in the form ``(stream, form, files)``.
[ "Parses", "the", "information", "from", "the", "environment", "as", "form", "data", "." ]
python
train
50.3
OSSOS/MOP
src/ossos/core/ossos/downloads/cutouts/source.py
https://github.com/OSSOS/MOP/blob/94f91d32ad5ec081d5a1ebd67604a838003465af/src/ossos/core/ossos/downloads/cutouts/source.py#L425-L454
def retrieve_comparison_image(self): """ Search the DB for a comparison image for this cutout. """ # selecting comparator when on a comparator should load a new one. collectionID = self.comparison_image_list[self.comparison_image_index]['EXPNUM'] ref_ra = self.reading.ra ...
[ "def", "retrieve_comparison_image", "(", "self", ")", ":", "# selecting comparator when on a comparator should load a new one.", "collectionID", "=", "self", ".", "comparison_image_list", "[", "self", ".", "comparison_image_index", "]", "[", "'EXPNUM'", "]", "ref_ra", "=", ...
Search the DB for a comparison image for this cutout.
[ "Search", "the", "DB", "for", "a", "comparison", "image", "for", "this", "cutout", "." ]
python
train
54.8
peterwittek/somoclu
src/Python/somoclu/train.py
https://github.com/peterwittek/somoclu/blob/b31dfbeba6765e64aedddcf8259626d6684f5349/src/Python/somoclu/train.py#L168-L181
def load_codebook(self, filename): """Load the codebook from a file to the Somoclu object. :param filename: The name of the file. :type filename: str. """ self.codebook = np.loadtxt(filename, comments='%') if self.n_dim == 0: self.n_dim = self.codebook.shape[...
[ "def", "load_codebook", "(", "self", ",", "filename", ")", ":", "self", ".", "codebook", "=", "np", ".", "loadtxt", "(", "filename", ",", "comments", "=", "'%'", ")", "if", "self", ".", "n_dim", "==", "0", ":", "self", ".", "n_dim", "=", "self", "....
Load the codebook from a file to the Somoclu object. :param filename: The name of the file. :type filename: str.
[ "Load", "the", "codebook", "from", "a", "file", "to", "the", "Somoclu", "object", "." ]
python
train
44.285714
scikit-learn-contrib/hdbscan
hdbscan/prediction.py
https://github.com/scikit-learn-contrib/hdbscan/blob/e40ccef139e56e38adf7bd6912cd63efd97598f9/hdbscan/prediction.py#L198-L255
def _extend_condensed_tree(tree, neighbor_indices, neighbor_distances, core_distances, min_samples): """ Create a new condensed tree with an additional point added, allowing for computations as if this point had been part of the original tree. Note that this makes as little ch...
[ "def", "_extend_condensed_tree", "(", "tree", ",", "neighbor_indices", ",", "neighbor_distances", ",", "core_distances", ",", "min_samples", ")", ":", "tree_root", "=", "tree", "[", "'parent'", "]", ".", "min", "(", ")", "nearest_neighbor", ",", "lambda_", "=", ...
Create a new condensed tree with an additional point added, allowing for computations as if this point had been part of the original tree. Note that this makes as little change to the tree as possible, with no re-optimizing/re-condensing so that the selected clusters remain effectively unchanged. P...
[ "Create", "a", "new", "condensed", "tree", "with", "an", "additional", "point", "added", "allowing", "for", "computations", "as", "if", "this", "point", "had", "been", "part", "of", "the", "original", "tree", ".", "Note", "that", "this", "makes", "as", "li...
python
train
39.87931
Kane610/deconz
pydeconz/group.py
https://github.com/Kane610/deconz/blob/8a9498dbbc8c168d4a081173ad6c3b1e17fffdf6/pydeconz/group.py#L175-L178
async def async_set_state(self, data): """Recall scene to group.""" field = self._deconz_id + '/recall' await self._async_set_state_callback(field, data)
[ "async", "def", "async_set_state", "(", "self", ",", "data", ")", ":", "field", "=", "self", ".", "_deconz_id", "+", "'/recall'", "await", "self", ".", "_async_set_state_callback", "(", "field", ",", "data", ")" ]
Recall scene to group.
[ "Recall", "scene", "to", "group", "." ]
python
train
43.5
CGATOxford/UMI-tools
umi_tools/network.py
https://github.com/CGATOxford/UMI-tools/blob/c4b5d84aac391d59916d294f8f4f8f5378abcfbe/umi_tools/network.py#L56-L65
def remove_umis(adj_list, cluster, nodes): '''removes the specified nodes from the cluster and returns the remaining nodes ''' # list incomprehension: for x in nodes: for node in adj_list[x]: yield node nodes_to_remove = set([node for x in nodes for...
[ "def", "remove_umis", "(", "adj_list", ",", "cluster", ",", "nodes", ")", ":", "# list incomprehension: for x in nodes: for node in adj_list[x]: yield node", "nodes_to_remove", "=", "set", "(", "[", "node", "for", "x", "in", "nodes", "for", "node", "in", "adj_list", ...
removes the specified nodes from the cluster and returns the remaining nodes
[ "removes", "the", "specified", "nodes", "from", "the", "cluster", "and", "returns", "the", "remaining", "nodes" ]
python
train
37.9
networks-lab/metaknowledge
metaknowledge/WOS/tagProcessing/helpFuncs.py
https://github.com/networks-lab/metaknowledge/blob/8162bf95e66bb6f9916081338e6e2a6132faff75/metaknowledge/WOS/tagProcessing/helpFuncs.py#L4-L25
def getMonth(s): """ Known formats: Month ("%b") Month Day ("%b %d") Month-Month ("%b-%b") --- this gets coerced to the first %b, dropping the month range Season ("%s") --- this gets coerced to use the first month of the given season Month Day Year ("%b %d %Y") Month Year ("%b %Y") Y...
[ "def", "getMonth", "(", "s", ")", ":", "monthOrSeason", "=", "s", ".", "split", "(", "'-'", ")", "[", "0", "]", ".", "upper", "(", ")", "if", "monthOrSeason", "in", "monthDict", ":", "return", "monthDict", "[", "monthOrSeason", "]", "else", ":", "mon...
Known formats: Month ("%b") Month Day ("%b %d") Month-Month ("%b-%b") --- this gets coerced to the first %b, dropping the month range Season ("%s") --- this gets coerced to use the first month of the given season Month Day Year ("%b %d %Y") Month Year ("%b %Y") Year Month Day ("%Y %m %d")
[ "Known", "formats", ":", "Month", "(", "%b", ")", "Month", "Day", "(", "%b", "%d", ")", "Month", "-", "Month", "(", "%b", "-", "%b", ")", "---", "this", "gets", "coerced", "to", "the", "first", "%b", "dropping", "the", "month", "range", "Season", "...
python
train
31.636364
TheOneHyer/arandomness
build/lib.linux-x86_64-3.6/arandomness/trees/omnitree.py
https://github.com/TheOneHyer/arandomness/blob/ae9f630e9a1d67b0eb6d61644a49756de8a5268c/build/lib.linux-x86_64-3.6/arandomness/trees/omnitree.py#L66-L73
def add_parents(self, parents): """Adds new parent nodes after filtering for duplicates Args: parents (list): list of OmniTree nodes to add as parents """ self._parents += [p for p in parents if p not in self._parents]
[ "def", "add_parents", "(", "self", ",", "parents", ")", ":", "self", ".", "_parents", "+=", "[", "p", "for", "p", "in", "parents", "if", "p", "not", "in", "self", ".", "_parents", "]" ]
Adds new parent nodes after filtering for duplicates Args: parents (list): list of OmniTree nodes to add as parents
[ "Adds", "new", "parent", "nodes", "after", "filtering", "for", "duplicates" ]
python
train
32.125
cyberdelia/metrology
metrology/reporter/statsd.py
https://github.com/cyberdelia/metrology/blob/7599bea7de1fd59374c06e2f8041a217e3cf9c01/metrology/reporter/statsd.py#L170-L176
def serialize_metric(self, metric, m_name, keys, m_type): """Serialize and send available measures of a metric.""" return [ self.format_metric_string(m_name, getattr(metric, key), m_type) for key in keys ]
[ "def", "serialize_metric", "(", "self", ",", "metric", ",", "m_name", ",", "keys", ",", "m_type", ")", ":", "return", "[", "self", ".", "format_metric_string", "(", "m_name", ",", "getattr", "(", "metric", ",", "key", ")", ",", "m_type", ")", "for", "k...
Serialize and send available measures of a metric.
[ "Serialize", "and", "send", "available", "measures", "of", "a", "metric", "." ]
python
test
35.428571
numenta/nupic
src/nupic/math/stats.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/math/stats.py#L156-L183
def Distribution(pos, size, counts, dtype): """ Returns an array of length size and type dtype that is everywhere 0, except in the indices listed in sequence pos. The non-zero indices contain a normalized distribution based on the counts. :param pos: A single integer or sequence of integers that specify...
[ "def", "Distribution", "(", "pos", ",", "size", ",", "counts", ",", "dtype", ")", ":", "x", "=", "numpy", ".", "zeros", "(", "size", ",", "dtype", "=", "dtype", ")", "if", "hasattr", "(", "pos", ",", "'__iter__'", ")", ":", "# calculate normalization c...
Returns an array of length size and type dtype that is everywhere 0, except in the indices listed in sequence pos. The non-zero indices contain a normalized distribution based on the counts. :param pos: A single integer or sequence of integers that specify the position of ones to be set. :param ...
[ "Returns", "an", "array", "of", "length", "size", "and", "type", "dtype", "that", "is", "everywhere", "0", "except", "in", "the", "indices", "listed", "in", "sequence", "pos", ".", "The", "non", "-", "zero", "indices", "contain", "a", "normalized", "distri...
python
valid
36.714286
astrocatalogs/astrocats
astrocats/catalog/entry.py
https://github.com/astrocatalogs/astrocats/blob/11abc3131c6366ecd23964369e55ff264add7805/astrocats/catalog/entry.py#L803-L831
def add_spectrum(self, compare_to_existing=True, **kwargs): """Add a `Spectrum` instance to this entry.""" spec_key = self._KEYS.SPECTRA # Make sure that a source is given, and is valid (nor erroneous) source = self._check_cat_dict_source(Spectrum, spec_key, **kwargs) if source i...
[ "def", "add_spectrum", "(", "self", ",", "compare_to_existing", "=", "True", ",", "*", "*", "kwargs", ")", ":", "spec_key", "=", "self", ".", "_KEYS", ".", "SPECTRA", "# Make sure that a source is given, and is valid (nor erroneous)", "source", "=", "self", ".", "...
Add a `Spectrum` instance to this entry.
[ "Add", "a", "Spectrum", "instance", "to", "this", "entry", "." ]
python
train
42.137931
tknapen/FIRDeconvolution
src/FIRDeconvolution.py
https://github.com/tknapen/FIRDeconvolution/blob/6263496a356c449062fe4c216fef56541f6dc151/src/FIRDeconvolution.py#L241-L260
def ridge_regress(self, cv = 20, alphas = None ): """perform k-folds cross-validated ridge regression on the design_matrix. To be used when the design matrix contains very collinear regressors. For cross-validation and ridge fitting, we use sklearn's RidgeCV functionality. Note: intercept is not fit, and data a...
[ "def", "ridge_regress", "(", "self", ",", "cv", "=", "20", ",", "alphas", "=", "None", ")", ":", "if", "alphas", "is", "None", ":", "alphas", "=", "np", ".", "logspace", "(", "7", ",", "0", ",", "20", ")", "self", ".", "rcv", "=", "linear_model",...
perform k-folds cross-validated ridge regression on the design_matrix. To be used when the design matrix contains very collinear regressors. For cross-validation and ridge fitting, we use sklearn's RidgeCV functionality. Note: intercept is not fit, and data are not prenormalized. :param cv: cross-validate...
[ "perform", "k", "-", "folds", "cross", "-", "validated", "ridge", "regression", "on", "the", "design_matrix", ".", "To", "be", "used", "when", "the", "design", "matrix", "contains", "very", "collinear", "regressors", ".", "For", "cross", "-", "validation", "...
python
train
72.2
astroswego/plotypus
src/plotypus/lightcurve.py
https://github.com/astroswego/plotypus/blob/b1162194ca1d4f6c00e79afe3e6fb40f0eaffcb9/src/plotypus/lightcurve.py#L310-L341
def get_lightcurve_from_file(file, *args, use_cols=None, skiprows=0, verbosity=None, **kwargs): """get_lightcurve_from_file(file, *args, use_cols=None, skiprows=0, **kwargs) Fits a light curve to the data contained in *file* using :func:`get_lightcu...
[ "def", "get_lightcurve_from_file", "(", "file", ",", "*", "args", ",", "use_cols", "=", "None", ",", "skiprows", "=", "0", ",", "verbosity", "=", "None", ",", "*", "*", "kwargs", ")", ":", "data", "=", "numpy", ".", "loadtxt", "(", "file", ",", "skip...
get_lightcurve_from_file(file, *args, use_cols=None, skiprows=0, **kwargs) Fits a light curve to the data contained in *file* using :func:`get_lightcurve`. **Parameters** file : str or file File or filename to load data from. use_cols : iterable or None, optional Iterable of colum...
[ "get_lightcurve_from_file", "(", "file", "*", "args", "use_cols", "=", "None", "skiprows", "=", "0", "**", "kwargs", ")" ]
python
train
35.5625
elifesciences/elife-tools
elifetools/utils.py
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/utils.py#L134-L143
def date_struct_nn(year, month, day, tz="UTC"): """ Assemble a date object but if day or month is none set them to 1 to make it easier to deal with partial dates """ if not day: day = 1 if not month: month = 1 return date_struct(year, month, day, tz)
[ "def", "date_struct_nn", "(", "year", ",", "month", ",", "day", ",", "tz", "=", "\"UTC\"", ")", ":", "if", "not", "day", ":", "day", "=", "1", "if", "not", "month", ":", "month", "=", "1", "return", "date_struct", "(", "year", ",", "month", ",", ...
Assemble a date object but if day or month is none set them to 1 to make it easier to deal with partial dates
[ "Assemble", "a", "date", "object", "but", "if", "day", "or", "month", "is", "none", "set", "them", "to", "1", "to", "make", "it", "easier", "to", "deal", "with", "partial", "dates" ]
python
train
28.5
jssimporter/python-jss
jss/distribution_point.py
https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/distribution_point.py#L650-L660
def copy_pkg(self, filename, id_=-1): """Copy a package to the distribution server. Bundle-style packages must be zipped prior to copying. Args: filename: Full path to file to upload. id_: ID of Package object to associate with, or -1 for new packages (d...
[ "def", "copy_pkg", "(", "self", ",", "filename", ",", "id_", "=", "-", "1", ")", ":", "self", ".", "_copy", "(", "filename", ",", "id_", "=", "id_", ",", "file_type", "=", "PKG_FILE_TYPE", ")" ]
Copy a package to the distribution server. Bundle-style packages must be zipped prior to copying. Args: filename: Full path to file to upload. id_: ID of Package object to associate with, or -1 for new packages (default).
[ "Copy", "a", "package", "to", "the", "distribution", "server", "." ]
python
train
35.727273
flaviogrossi/sockjs-cyclone
sockjs/cyclone/session.py
https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/session.py#L397-L402
def start_heartbeat(self): """ Reset hearbeat timer """ self.stop_heartbeat() self._heartbeat_timer = task.LoopingCall(self._heartbeat) self._heartbeat_timer.start(self._heartbeat_interval, False)
[ "def", "start_heartbeat", "(", "self", ")", ":", "self", ".", "stop_heartbeat", "(", ")", "self", ".", "_heartbeat_timer", "=", "task", ".", "LoopingCall", "(", "self", ".", "_heartbeat", ")", "self", ".", "_heartbeat_timer", ".", "start", "(", "self", "."...
Reset hearbeat timer
[ "Reset", "hearbeat", "timer" ]
python
train
37.333333
callowayproject/Calloway
calloway/apps/django_ext/templatetags/listutil.py
https://github.com/callowayproject/Calloway/blob/d22e98d41fbd298ab6393ba7bd84a75528be9f81/calloway/apps/django_ext/templatetags/listutil.py#L21-L47
def partition(thelist, n): """ Break a list into ``n`` pieces. The last list may be larger than the rest if the list doesn't break cleanly. That is:: >>> l = range(10) >>> partition(l, 2) [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]] >>> partition(l, 3) [[0, 1, 2], [3, 4, ...
[ "def", "partition", "(", "thelist", ",", "n", ")", ":", "try", ":", "n", "=", "int", "(", "n", ")", "thelist", "=", "list", "(", "thelist", ")", "except", "(", "ValueError", ",", "TypeError", ")", ":", "return", "[", "thelist", "]", "p", "=", "le...
Break a list into ``n`` pieces. The last list may be larger than the rest if the list doesn't break cleanly. That is:: >>> l = range(10) >>> partition(l, 2) [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]] >>> partition(l, 3) [[0, 1, 2], [3, 4, 5], [6, 7, 8, 9]] >>> partiti...
[ "Break", "a", "list", "into", "n", "pieces", ".", "The", "last", "list", "may", "be", "larger", "than", "the", "rest", "if", "the", "list", "doesn", "t", "break", "cleanly", ".", "That", "is", "::", ">>>", "l", "=", "range", "(", "10", ")", ">>>", ...
python
train
25.962963
oceanprotocol/squid-py
squid_py/keeper/event_listener.py
https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/keeper/event_listener.py#L31-L41
def make_event_filter(self): """Create a new event filter.""" event_filter = EventFilter( self.event_name, self.event, self.filters, from_block=self.from_block, to_block=self.to_block ) event_filter.set_poll_interval(0.5) ...
[ "def", "make_event_filter", "(", "self", ")", ":", "event_filter", "=", "EventFilter", "(", "self", ".", "event_name", ",", "self", ".", "event", ",", "self", ".", "filters", ",", "from_block", "=", "self", ".", "from_block", ",", "to_block", "=", "self", ...
Create a new event filter.
[ "Create", "a", "new", "event", "filter", "." ]
python
train
30.090909
ThreatConnect-Inc/tcex
tcex/tcex_auth.py
https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_auth.py#L74-L120
def _renew_token(self, retry=True): """Renew expired ThreatConnect Token.""" self.renewing = True self.log.info('Renewing ThreatConnect Token') self.log.info('Current Token Expiration: {}'.format(self._token_expiration)) try: params = {'expiredToken': self._token} ...
[ "def", "_renew_token", "(", "self", ",", "retry", "=", "True", ")", ":", "self", ".", "renewing", "=", "True", "self", ".", "log", ".", "info", "(", "'Renewing ThreatConnect Token'", ")", "self", ".", "log", ".", "info", "(", "'Current Token Expiration: {}'"...
Renew expired ThreatConnect Token.
[ "Renew", "expired", "ThreatConnect", "Token", "." ]
python
train
54.744681
amzn/ion-python
amazon/ion/symbols.py
https://github.com/amzn/ion-python/blob/0b21fa3ba7755f55f745e4aa970d86343b82449d/amazon/ion/symbols.py#L418-L443
def placeholder_symbol_table(name, version, max_id): """Constructs a shared symbol table that consists symbols that all have no known text. This is generally used for cases where a shared symbol table is not available by the application. Args: name (unicode): The name of the shared symbol tabl...
[ "def", "placeholder_symbol_table", "(", "name", ",", "version", ",", "max_id", ")", ":", "if", "version", "<=", "0", ":", "raise", "ValueError", "(", "'Version must be grater than or equal to 1: %s'", "%", "version", ")", "if", "max_id", "<", "0", ":", "raise", ...
Constructs a shared symbol table that consists symbols that all have no known text. This is generally used for cases where a shared symbol table is not available by the application. Args: name (unicode): The name of the shared symbol table. version (int): The version of the shared symbol t...
[ "Constructs", "a", "shared", "symbol", "table", "that", "consists", "symbols", "that", "all", "have", "no", "known", "text", "." ]
python
train
34.115385
pip-services3-python/pip-services3-commons-python
pip_services3_commons/commands/CommandSet.py
https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/commands/CommandSet.py#L111-L120
def _build_command_chain(self, command): """ Builds execution chain including all intercepters and the specified command. :param command: the command to build a chain. """ next = command for intercepter in reversed(self._intercepters): next = InterceptedComma...
[ "def", "_build_command_chain", "(", "self", ",", "command", ")", ":", "next", "=", "command", "for", "intercepter", "in", "reversed", "(", "self", ".", "_intercepters", ")", ":", "next", "=", "InterceptedCommand", "(", "intercepter", ",", "next", ")", "self"...
Builds execution chain including all intercepters and the specified command. :param command: the command to build a chain.
[ "Builds", "execution", "chain", "including", "all", "intercepters", "and", "the", "specified", "command", "." ]
python
train
38.7
closeio/tasktiger
tasktiger/_internal.py
https://github.com/closeio/tasktiger/blob/59f893152d6eb4b7f1f62fc4b35aeeca7f26c07a/tasktiger/_internal.py#L56-L65
def gen_unique_id(serialized_name, args, kwargs): """ Generates and returns a hex-encoded 256-bit ID for the given task name and args. Used to generate IDs for unique tasks or for task locks. """ return hashlib.sha256(json.dumps({ 'func': serialized_name, 'args': args, 'kwarg...
[ "def", "gen_unique_id", "(", "serialized_name", ",", "args", ",", "kwargs", ")", ":", "return", "hashlib", ".", "sha256", "(", "json", ".", "dumps", "(", "{", "'func'", ":", "serialized_name", ",", "'args'", ":", "args", ",", "'kwargs'", ":", "kwargs", "...
Generates and returns a hex-encoded 256-bit ID for the given task name and args. Used to generate IDs for unique tasks or for task locks.
[ "Generates", "and", "returns", "a", "hex", "-", "encoded", "256", "-", "bit", "ID", "for", "the", "given", "task", "name", "and", "args", ".", "Used", "to", "generate", "IDs", "for", "unique", "tasks", "or", "for", "task", "locks", "." ]
python
train
37.3
atlassian-api/atlassian-python-api
atlassian/confluence.py
https://github.com/atlassian-api/atlassian-python-api/blob/540d269905c3e7547b666fe30c647b2d512cf358/atlassian/confluence.py#L205-L216
def get_all_draft_pages_from_space(self, space, start=0, limit=500, status='draft'): """ Get list of draft pages from space Use case is cleanup old drafts from Confluence :param space: :param start: OPTIONAL: The start point of the collection to return. Default: None (0). ...
[ "def", "get_all_draft_pages_from_space", "(", "self", ",", "space", ",", "start", "=", "0", ",", "limit", "=", "500", ",", "status", "=", "'draft'", ")", ":", "return", "self", ".", "get_all_pages_from_space", "(", "space", ",", "start", ",", "limit", ",",...
Get list of draft pages from space Use case is cleanup old drafts from Confluence :param space: :param start: OPTIONAL: The start point of the collection to return. Default: None (0). :param limit: OPTIONAL: The limit of the number of pages to return, this may be restricted by ...
[ "Get", "list", "of", "draft", "pages", "from", "space", "Use", "case", "is", "cleanup", "old", "drafts", "from", "Confluence", ":", "param", "space", ":", ":", "param", "start", ":", "OPTIONAL", ":", "The", "start", "point", "of", "the", "collection", "t...
python
train
49.25
jameshilliard/hlk-sw16
hlk_sw16/protocol.py
https://github.com/jameshilliard/hlk-sw16/blob/4f0c5a7b76b42167f4dc9d2aa6312c7518a8cd56/hlk_sw16/protocol.py#L292-L305
async def create_hlk_sw16_connection(port=None, host=None, disconnect_callback=None, reconnect_callback=None, loop=None, logger=None, timeout=None, reconnect_interval=None)...
[ "async", "def", "create_hlk_sw16_connection", "(", "port", "=", "None", ",", "host", "=", "None", ",", "disconnect_callback", "=", "None", ",", "reconnect_callback", "=", "None", ",", "loop", "=", "None", ",", "logger", "=", "None", ",", "timeout", "=", "N...
Create HLK-SW16 Client class.
[ "Create", "HLK", "-", "SW16", "Client", "class", "." ]
python
train
49.357143
RudolfCardinal/pythonlib
cardinal_pythonlib/interval.py
https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/interval.py#L433-L438
def component_on_date(self, date: datetime.date) -> Optional["Interval"]: """ Returns the part of this interval that falls on the date given, or ``None`` if the interval doesn't have any part during that date. """ return self.intersection(Interval.wholeday(date))
[ "def", "component_on_date", "(", "self", ",", "date", ":", "datetime", ".", "date", ")", "->", "Optional", "[", "\"Interval\"", "]", ":", "return", "self", ".", "intersection", "(", "Interval", ".", "wholeday", "(", "date", ")", ")" ]
Returns the part of this interval that falls on the date given, or ``None`` if the interval doesn't have any part during that date.
[ "Returns", "the", "part", "of", "this", "interval", "that", "falls", "on", "the", "date", "given", "or", "None", "if", "the", "interval", "doesn", "t", "have", "any", "part", "during", "that", "date", "." ]
python
train
49.666667
ev3dev/ev3dev-lang-python
ev3dev2/motor.py
https://github.com/ev3dev/ev3dev-lang-python/blob/afc98d35004b533dc161a01f7c966e78607d7c1e/ev3dev2/motor.py#L510-L518
def polarity(self): """ Sets the polarity of the motor. With `normal` polarity, a positive duty cycle will cause the motor to rotate clockwise. With `inversed` polarity, a positive duty cycle will cause the motor to rotate counter-clockwise. Valid values are `normal` and `inverse...
[ "def", "polarity", "(", "self", ")", ":", "self", ".", "_polarity", ",", "value", "=", "self", ".", "get_attr_string", "(", "self", ".", "_polarity", ",", "'polarity'", ")", "return", "value" ]
Sets the polarity of the motor. With `normal` polarity, a positive duty cycle will cause the motor to rotate clockwise. With `inversed` polarity, a positive duty cycle will cause the motor to rotate counter-clockwise. Valid values are `normal` and `inversed`.
[ "Sets", "the", "polarity", "of", "the", "motor", ".", "With", "normal", "polarity", "a", "positive", "duty", "cycle", "will", "cause", "the", "motor", "to", "rotate", "clockwise", ".", "With", "inversed", "polarity", "a", "positive", "duty", "cycle", "will",...
python
train
47.666667
dims/etcd3-gateway
etcd3gw/client.py
https://github.com/dims/etcd3-gateway/blob/ad566c29cbde135aee20cfd32e0a4815ca3b5ee6/etcd3gw/client.py#L395-L399
def watch_prefix_once(self, key_prefix, timeout=None, **kwargs): """Watches a range of keys with a prefix, similar to watch_once""" kwargs['range_end'] = \ _increment_last_byte(key_prefix) return self.watch_once(key_prefix, timeout=timeout, **kwargs)
[ "def", "watch_prefix_once", "(", "self", ",", "key_prefix", ",", "timeout", "=", "None", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'range_end'", "]", "=", "_increment_last_byte", "(", "key_prefix", ")", "return", "self", ".", "watch_once", "(", "k...
Watches a range of keys with a prefix, similar to watch_once
[ "Watches", "a", "range", "of", "keys", "with", "a", "prefix", "similar", "to", "watch_once" ]
python
train
56.4
ofek/bit
bit/wallet.py
https://github.com/ofek/bit/blob/20fc0e7047946c1f28f868008d99d659905c1af6/bit/wallet.py#L89-L98
def verify(self, signature, data): """Verifies some data was signed by this private key. :param signature: The signature to verify. :type signature: ``bytes`` :param data: The data that was supposedly signed. :type data: ``bytes`` :rtype: ``bool`` """ ret...
[ "def", "verify", "(", "self", ",", "signature", ",", "data", ")", ":", "return", "self", ".", "_pk", ".", "public_key", ".", "verify", "(", "signature", ",", "data", ")" ]
Verifies some data was signed by this private key. :param signature: The signature to verify. :type signature: ``bytes`` :param data: The data that was supposedly signed. :type data: ``bytes`` :rtype: ``bool``
[ "Verifies", "some", "data", "was", "signed", "by", "this", "private", "key", "." ]
python
train
35.8
joytunes/JTLocalize
localization_flow/jtlocalize/core/localization_utils.py
https://github.com/joytunes/JTLocalize/blob/87864dc60114e0e61c768d057c6eddfadff3f40a/localization_flow/jtlocalize/core/localization_utils.py#L224-L238
def append_dictionary_to_file(localization_key_to_comment, file_path, section_name): """ Appends dictionary of localization keys and comments to a file Args: localization_key_to_comment (dict): A mapping between localization keys and comments. file_path (str): The path of the file to append to....
[ "def", "append_dictionary_to_file", "(", "localization_key_to_comment", ",", "file_path", ",", "section_name", ")", ":", "output_file", "=", "open_strings_file", "(", "file_path", ",", "\"a\"", ")", "write_section_header_to_file", "(", "output_file", ",", "section_name", ...
Appends dictionary of localization keys and comments to a file Args: localization_key_to_comment (dict): A mapping between localization keys and comments. file_path (str): The path of the file to append to. section_name (str): The name of the section.
[ "Appends", "dictionary", "of", "localization", "keys", "and", "comments", "to", "a", "file" ]
python
train
47.8
programa-stic/barf-project
barf/analysis/gadgets/finder.py
https://github.com/programa-stic/barf-project/blob/18ed9e5eace55f7bf6015ec57f037c364099021c/barf/analysis/gadgets/finder.py#L307-L325
def _build_gadgets_rec(self, gadget_tree_root): """Build a gadgets from a gadgets tree. """ root = gadget_tree_root.get_root() children = gadget_tree_root.get_children() node_list = [] root_gadget_ins = root if not children: node_list += [[root_gadg...
[ "def", "_build_gadgets_rec", "(", "self", ",", "gadget_tree_root", ")", ":", "root", "=", "gadget_tree_root", ".", "get_root", "(", ")", "children", "=", "gadget_tree_root", ".", "get_children", "(", ")", "node_list", "=", "[", "]", "root_gadget_ins", "=", "ro...
Build a gadgets from a gadgets tree.
[ "Build", "a", "gadgets", "from", "a", "gadgets", "tree", "." ]
python
train
27.631579
T-002/pycast
pycast/common/matrix.py
https://github.com/T-002/pycast/blob/8a53505c6d8367e0ea572e8af768e80b29e1cc41/pycast/common/matrix.py#L940-L961
def pseudoinverse(self): """Return the pseudoinverse (Moore-Penrose-Inverse). The singular value decomposition is used to calculate the pseudoinverse. """ transform = False if self.get_width() > self.get_height(): transform = True u, sigma, v = self.trans...
[ "def", "pseudoinverse", "(", "self", ")", ":", "transform", "=", "False", "if", "self", ".", "get_width", "(", ")", ">", "self", ".", "get_height", "(", ")", ":", "transform", "=", "True", "u", ",", "sigma", ",", "v", "=", "self", ".", "transform", ...
Return the pseudoinverse (Moore-Penrose-Inverse). The singular value decomposition is used to calculate the pseudoinverse.
[ "Return", "the", "pseudoinverse", "(", "Moore", "-", "Penrose", "-", "Inverse", ")", "." ]
python
train
38.318182
twitterdev/tweet_parser
tweet_parser/getter_methods/tweet_text.py
https://github.com/twitterdev/tweet_parser/blob/3435de8367d36b483a6cfd8d46cc28694ee8a42e/tweet_parser/getter_methods/tweet_text.py#L6-L66
def get_full_text(tweet): """ Get the full text of a tweet dict. Includes @-mention replies and long links. Args: tweet (Tweet or dict): A Tweet object or dictionary Returns: str: the untruncated text of a Tweet (finds extended text if available) Example: >>> f...
[ "def", "get_full_text", "(", "tweet", ")", ":", "if", "is_original_format", "(", "tweet", ")", ":", "if", "tweet", "[", "\"truncated\"", "]", ":", "return", "tweet", "[", "\"extended_tweet\"", "]", "[", "\"full_text\"", "]", "else", ":", "return", "tweet", ...
Get the full text of a tweet dict. Includes @-mention replies and long links. Args: tweet (Tweet or dict): A Tweet object or dictionary Returns: str: the untruncated text of a Tweet (finds extended text if available) Example: >>> from tweet_parser.getter_methods.tweet_...
[ "Get", "the", "full", "text", "of", "a", "tweet", "dict", ".", "Includes", "@", "-", "mention", "replies", "and", "long", "links", "." ]
python
train
37.868852
bcbio/bcbio-nextgen
bcbio/bam/__init__.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/bam/__init__.py#L109-L121
def idxstats(in_bam, data): """Return BAM index stats for the given file, using samtools idxstats. """ index(in_bam, data["config"], check_timestamp=False) AlignInfo = collections.namedtuple("AlignInfo", ["contig", "length", "aligned", "unaligned"]) samtools = config_utils.get_program("samtools", da...
[ "def", "idxstats", "(", "in_bam", ",", "data", ")", ":", "index", "(", "in_bam", ",", "data", "[", "\"config\"", "]", ",", "check_timestamp", "=", "False", ")", "AlignInfo", "=", "collections", ".", "namedtuple", "(", "\"AlignInfo\"", ",", "[", "\"contig\"...
Return BAM index stats for the given file, using samtools idxstats.
[ "Return", "BAM", "index", "stats", "for", "the", "given", "file", "using", "samtools", "idxstats", "." ]
python
train
50.076923
Jammy2211/PyAutoLens
autolens/model/galaxy/galaxy.py
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/model/galaxy/galaxy.py#L281-L291
def einstein_radius_in_units(self, unit_length='arcsec', kpc_per_arcsec=None): """The Einstein Radius of this galaxy, which is the sum of Einstein Radii of its mass profiles. If the galaxy is composed of multiple ellipitcal profiles with different axis-ratios, this Einstein Radius \ may be inac...
[ "def", "einstein_radius_in_units", "(", "self", ",", "unit_length", "=", "'arcsec'", ",", "kpc_per_arcsec", "=", "None", ")", ":", "if", "self", ".", "has_mass_profile", ":", "return", "sum", "(", "map", "(", "lambda", "p", ":", "p", ".", "einstein_radius_in...
The Einstein Radius of this galaxy, which is the sum of Einstein Radii of its mass profiles. If the galaxy is composed of multiple ellipitcal profiles with different axis-ratios, this Einstein Radius \ may be inaccurate. This is because the differently oriented ellipses of each mass profile
[ "The", "Einstein", "Radius", "of", "this", "galaxy", "which", "is", "the", "sum", "of", "Einstein", "Radii", "of", "its", "mass", "profiles", "." ]
python
valid
57.636364
quantopian/zipline
zipline/pipeline/graph.py
https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/graph.py#L165-L182
def _decref_dependencies_recursive(self, term, refcounts, garbage): """ Decrement terms recursively. Notes ----- This should only be used to build the initial workspace, after that we should use: :meth:`~zipline.pipeline.graph.TermGraph.decref_dependencies` ...
[ "def", "_decref_dependencies_recursive", "(", "self", ",", "term", ",", "refcounts", ",", "garbage", ")", ":", "# Edges are tuple of (from, to).", "for", "parent", ",", "_", "in", "self", ".", "graph", ".", "in_edges", "(", "[", "term", "]", ")", ":", "refco...
Decrement terms recursively. Notes ----- This should only be used to build the initial workspace, after that we should use: :meth:`~zipline.pipeline.graph.TermGraph.decref_dependencies`
[ "Decrement", "terms", "recursively", "." ]
python
train
39.166667
PGower/PyCanvas
pycanvas/apis/files.py
https://github.com/PGower/PyCanvas/blob/68520005382b440a1e462f9df369f54d364e21e8/pycanvas/apis/files.py#L1089-L1110
def delete_folder(self, id, force=None): """ Delete folder. Remove the specified folder. You can only delete empty folders unless you set the 'force' flag """ path = {} data = {} params = {} # REQUIRED - PATH - id """ID""" ...
[ "def", "delete_folder", "(", "self", ",", "id", ",", "force", "=", "None", ")", ":", "path", "=", "{", "}", "data", "=", "{", "}", "params", "=", "{", "}", "# REQUIRED - PATH - id\r", "\"\"\"ID\"\"\"", "path", "[", "\"id\"", "]", "=", "id", "# OPTIONAL...
Delete folder. Remove the specified folder. You can only delete empty folders unless you set the 'force' flag
[ "Delete", "folder", ".", "Remove", "the", "specified", "folder", ".", "You", "can", "only", "delete", "empty", "folders", "unless", "you", "set", "the", "force", "flag" ]
python
train
34.590909
sublee/zeronimo
zeronimo/core.py
https://github.com/sublee/zeronimo/blob/b216638232932718d2cbc5eabd870c8f5b5e83fb/zeronimo/core.py#L133-L142
def default_malformed_message_handler(worker, exc_info, message_parts): """The default malformed message handler for :class:`Worker`. It warns as a :exc:`MalformedMessage`. """ exc_type, exc, tb = exc_info exc_strs = traceback.format_exception_only(exc_type, exc) exc_str = exc_strs[0].strip() ...
[ "def", "default_malformed_message_handler", "(", "worker", ",", "exc_info", ",", "message_parts", ")", ":", "exc_type", ",", "exc", ",", "tb", "=", "exc_info", "exc_strs", "=", "traceback", ".", "format_exception_only", "(", "exc_type", ",", "exc", ")", "exc_str...
The default malformed message handler for :class:`Worker`. It warns as a :exc:`MalformedMessage`.
[ "The", "default", "malformed", "message", "handler", "for", ":", "class", ":", "Worker", ".", "It", "warns", "as", "a", ":", "exc", ":", "MalformedMessage", "." ]
python
test
43.7
sibirrer/lenstronomy
lenstronomy/Util/kernel_util.py
https://github.com/sibirrer/lenstronomy/blob/4edb100a4f3f4fdc4fac9b0032d2b0283d0aa1d6/lenstronomy/Util/kernel_util.py#L241-L271
def split_kernel(kernel, kernel_subgrid, subsampling_size, subgrid_res): """ pixel kernel and subsampling kernel such that the convolution of both applied on an image can be performed, i.e. smaller subsampling PSF and hole in larger PSF :param kernel: PSF kernel of the size of the pixel :param kern...
[ "def", "split_kernel", "(", "kernel", ",", "kernel_subgrid", ",", "subsampling_size", ",", "subgrid_res", ")", ":", "n", "=", "len", "(", "kernel", ")", "n_sub", "=", "len", "(", "kernel_subgrid", ")", "if", "subsampling_size", "%", "2", "==", "0", ":", ...
pixel kernel and subsampling kernel such that the convolution of both applied on an image can be performed, i.e. smaller subsampling PSF and hole in larger PSF :param kernel: PSF kernel of the size of the pixel :param kernel_subgrid: subsampled kernel :param subsampling_size: size of subsampling PSF in...
[ "pixel", "kernel", "and", "subsampling", "kernel", "such", "that", "the", "convolution", "of", "both", "applied", "on", "an", "image", "can", "be", "performed", "i", ".", "e", ".", "smaller", "subsampling", "PSF", "and", "hole", "in", "larger", "PSF" ]
python
train
43.258065
cloud9ers/gurumate
environment/lib/python2.7/site-packages/IPython/parallel/controller/dependency.py
https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/parallel/controller/dependency.py#L192-L199
def as_dict(self): """Represent this dependency as a dict. For json compatibility.""" return dict( dependencies=list(self), all=self.all, success=self.success, failure=self.failure )
[ "def", "as_dict", "(", "self", ")", ":", "return", "dict", "(", "dependencies", "=", "list", "(", "self", ")", ",", "all", "=", "self", ".", "all", ",", "success", "=", "self", ".", "success", ",", "failure", "=", "self", ".", "failure", ")" ]
Represent this dependency as a dict. For json compatibility.
[ "Represent", "this", "dependency", "as", "a", "dict", ".", "For", "json", "compatibility", "." ]
python
test
30.875
awslabs/aws-sam-cli
samcli/commands/local/cli_common/invoke_context.py
https://github.com/awslabs/aws-sam-cli/blob/c05af5e7378c6f05f7d82ad3f0bca17204177db6/samcli/commands/local/cli_common/invoke_context.py#L217-L227
def stderr(self): """ Returns stream writer for stderr to output Lambda function errors to Returns ------- samcli.lib.utils.stream_writer.StreamWriter Stream writer for stderr """ stream = self._log_file_handle if self._log_file_handle else osutils.st...
[ "def", "stderr", "(", "self", ")", ":", "stream", "=", "self", ".", "_log_file_handle", "if", "self", ".", "_log_file_handle", "else", "osutils", ".", "stderr", "(", ")", "return", "StreamWriter", "(", "stream", ",", "self", ".", "_is_debugging", ")" ]
Returns stream writer for stderr to output Lambda function errors to Returns ------- samcli.lib.utils.stream_writer.StreamWriter Stream writer for stderr
[ "Returns", "stream", "writer", "for", "stderr", "to", "output", "Lambda", "function", "errors", "to" ]
python
train
33.818182
sorgerlab/indra
rest_api/api.py
https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/rest_api/api.py#L104-L113
def reach_process_text(): """Process text with REACH and return INDRA Statements.""" if request.method == 'OPTIONS': return {} response = request.body.read().decode('utf-8') body = json.loads(response) text = body.get('text') offline = True if body.get('offline') else False rp = reac...
[ "def", "reach_process_text", "(", ")", ":", "if", "request", ".", "method", "==", "'OPTIONS'", ":", "return", "{", "}", "response", "=", "request", ".", "body", ".", "read", "(", ")", ".", "decode", "(", "'utf-8'", ")", "body", "=", "json", ".", "loa...
Process text with REACH and return INDRA Statements.
[ "Process", "text", "with", "REACH", "and", "return", "INDRA", "Statements", "." ]
python
train
38
senaite/senaite.core
bika/lims/upgrade/v01_03_000.py
https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/upgrade/v01_03_000.py#L1383-L1403
def remove_bika_listing_resources(portal): """Remove all bika_listing resources """ logger.info("Removing bika_listing resouces") REMOVE_JS = [ "++resource++bika.lims.js/bika.lims.bikalisting.js", "++resource++bika.lims.js/bika.lims.bikalistingfilterbar.js", ] REMOVE_CSS = [ ...
[ "def", "remove_bika_listing_resources", "(", "portal", ")", ":", "logger", ".", "info", "(", "\"Removing bika_listing resouces\"", ")", "REMOVE_JS", "=", "[", "\"++resource++bika.lims.js/bika.lims.bikalisting.js\"", ",", "\"++resource++bika.lims.js/bika.lims.bikalistingfilterbar.js...
Remove all bika_listing resources
[ "Remove", "all", "bika_listing", "resources" ]
python
train
29.142857