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
amcfague/webunit2
webunit2/response.py
https://github.com/amcfague/webunit2/blob/3157e5837aad0810800628c1383f1fe11ee3e513/webunit2/response.py#L97-L99
def assertNotCookie(self, name, value=None, attrs={}, *args, **kwargs): """ Negation of :meth:`assertCookie`. """ return not self.assertCookie(name, value, attrs)
[ "def", "assertNotCookie", "(", "self", ",", "name", ",", "value", "=", "None", ",", "attrs", "=", "{", "}", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "not", "self", ".", "assertCookie", "(", "name", ",", "value", ",", "attrs", ...
Negation of :meth:`assertCookie`.
[ "Negation", "of", ":", "meth", ":", "assertCookie", "." ]
python
train
58.666667
SUNCAT-Center/CatHub
cathub/make_folders_template.py
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/make_folders_template.py#L14-L225
def main( title, authors, year, email, journal='', volume='', number='', pages='', publisher='', doi='', tags=[], DFT_code='Quantum ESPRESSO', DFT_functionals=['BEEF-vdW'], reactions=[ {'reactants...
[ "def", "main", "(", "title", ",", "authors", ",", "year", ",", "email", ",", "journal", "=", "''", ",", "volume", "=", "''", ",", "number", "=", "''", ",", "pages", "=", "''", ",", "publisher", "=", "''", ",", "doi", "=", "''", ",", "tags", "="...
Automatically generate an organized folder structure for a DFT calculation. Start by copying the script to a folder in your username and assign the right information to the arguments in the function. You can change the parameters and run the script several times if you, for example, are using diff...
[ "Automatically", "generate", "an", "organized", "folder", "structure", "for", "a", "DFT", "calculation", "." ]
python
train
35.212264
The-Politico/politico-civic-demography
demography/management/commands/bootstrap/fetch/__init__.py
https://github.com/The-Politico/politico-civic-demography/blob/080bb964b64b06db7fd04386530e893ceed1cf98/demography/management/commands/bootstrap/fetch/__init__.py#L20-L55
def fetch_state_data(self, states): """ Fetch census estimates from table. """ print("Fetching census data") for table in CensusTable.objects.all(): api = self.get_series(table.series) for variable in table.variables.all(): estimate = "{}_{...
[ "def", "fetch_state_data", "(", "self", ",", "states", ")", ":", "print", "(", "\"Fetching census data\"", ")", "for", "table", "in", "CensusTable", ".", "objects", ".", "all", "(", ")", ":", "api", "=", "self", ".", "get_series", "(", "table", ".", "ser...
Fetch census estimates from table.
[ "Fetch", "census", "estimates", "from", "table", "." ]
python
train
37.527778
palantir/typedjsonrpc
typedjsonrpc/server.py
https://github.com/palantir/typedjsonrpc/blob/274218fcd236ff9643506caa629029c9ba25a0fb/typedjsonrpc/server.py#L114-L127
def run(self, host, port, **options): """For debugging purposes, you can run this as a standalone server. .. WARNING:: **Security vulnerability** This uses :class:`DebuggedJsonRpcApplication` to assist debugging. If you want to use this in production, you should run :class:`Ser...
[ "def", "run", "(", "self", ",", "host", ",", "port", ",", "*", "*", "options", ")", ":", "self", ".", "registry", ".", "debug", "=", "True", "debugged", "=", "DebuggedJsonRpcApplication", "(", "self", ",", "evalex", "=", "True", ")", "run_simple", "(",...
For debugging purposes, you can run this as a standalone server. .. WARNING:: **Security vulnerability** This uses :class:`DebuggedJsonRpcApplication` to assist debugging. If you want to use this in production, you should run :class:`Server` as a standard WSGI app with `uWS...
[ "For", "debugging", "purposes", "you", "can", "run", "this", "as", "a", "standalone", "server", "." ]
python
train
46.857143
ruipgil/changepy
changepy/costs.py
https://github.com/ruipgil/changepy/blob/95a903a24d532d658d4f1775d298c7fd51cdf47c/changepy/costs.py#L3-L41
def normal_mean(data, variance): """ Creates a segment cost function for a time series with a Normal distribution with changing mean Args: data (:obj:`list` of float): 1D time series data variance (float): variance Returns: function: Function with signature (int,...
[ "def", "normal_mean", "(", "data", ",", "variance", ")", ":", "if", "not", "isinstance", "(", "data", ",", "np", ".", "ndarray", ")", ":", "data", "=", "np", ".", "array", "(", "data", ")", "i_variance_2", "=", "1", "/", "(", "variance", "**", "2",...
Creates a segment cost function for a time series with a Normal distribution with changing mean Args: data (:obj:`list` of float): 1D time series data variance (float): variance Returns: function: Function with signature (int, int) -> float where the firs...
[ "Creates", "a", "segment", "cost", "function", "for", "a", "time", "series", "with", "a", "Normal", "distribution", "with", "changing", "mean" ]
python
train
28.871795
DistrictDataLabs/yellowbrick
yellowbrick/cluster/silhouette.py
https://github.com/DistrictDataLabs/yellowbrick/blob/59b67236a3862c73363e8edad7cd86da5b69e3b2/yellowbrick/cluster/silhouette.py#L184-L217
def finalize(self): """ Prepare the figure for rendering by setting the title and adjusting the limits on the axes, adding labels and a legend. """ # Set the title self.set_title(( "Silhouette Plot of {} Clustering for {} Samples in {} Centers" ).form...
[ "def", "finalize", "(", "self", ")", ":", "# Set the title", "self", ".", "set_title", "(", "(", "\"Silhouette Plot of {} Clustering for {} Samples in {} Centers\"", ")", ".", "format", "(", "self", ".", "name", ",", "self", ".", "n_samples_", ",", "self", ".", ...
Prepare the figure for rendering by setting the title and adjusting the limits on the axes, adding labels and a legend.
[ "Prepare", "the", "figure", "for", "rendering", "by", "setting", "the", "title", "and", "adjusting", "the", "limits", "on", "the", "axes", "adding", "labels", "and", "a", "legend", "." ]
python
train
42.323529
zeaphoo/budoc
budoc/pydoc.py
https://github.com/zeaphoo/budoc/blob/28f3aea4ad72ac90605ced012ed20e61af90c23a/budoc/pydoc.py#L663-L674
def methods(self): """ Returns all documented methods as `pydoc.Function` objects in the class, sorted alphabetically with `__init__` always coming first. Unfortunately, this also includes class methods. """ p = lambda o: (isinstance(o, Function) ...
[ "def", "methods", "(", "self", ")", ":", "p", "=", "lambda", "o", ":", "(", "isinstance", "(", "o", ",", "Function", ")", "and", "o", ".", "method", "and", "self", ".", "module", ".", "_docfilter", "(", "o", ")", ")", "return", "filter", "(", "p"...
Returns all documented methods as `pydoc.Function` objects in the class, sorted alphabetically with `__init__` always coming first. Unfortunately, this also includes class methods.
[ "Returns", "all", "documented", "methods", "as", "pydoc", ".", "Function", "objects", "in", "the", "class", "sorted", "alphabetically", "with", "__init__", "always", "coming", "first", "." ]
python
train
35.5
openego/eDisGo
edisgo/tools/tools.py
https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/tools/tools.py#L71-L135
def assign_load_feedin_case(network): """ For each time step evaluate whether it is a feed-in or a load case. Feed-in and load case are identified based on the generation and load time series and defined as follows: 1. Load case: positive (load - generation) at HV/MV substation 2. Feed-in case...
[ "def", "assign_load_feedin_case", "(", "network", ")", ":", "if", "network", ".", "pypsa", "is", "not", "None", ":", "residual_load", "=", "get_residual_load_from_pypsa_network", "(", "network", ".", "pypsa", ")", "*", "1e3", "else", ":", "grids", "=", "[", ...
For each time step evaluate whether it is a feed-in or a load case. Feed-in and load case are identified based on the generation and load time series and defined as follows: 1. Load case: positive (load - generation) at HV/MV substation 2. Feed-in case: negative (load - generation) at HV/MV substation...
[ "For", "each", "time", "step", "evaluate", "whether", "it", "is", "a", "feed", "-", "in", "or", "a", "load", "case", "." ]
python
train
35.892308
inspirehep/harvesting-kit
harvestingkit/utils.py
https://github.com/inspirehep/harvesting-kit/blob/33a7f8aa9dade1d863110c6d8b27dfd955cb471f/harvestingkit/utils.py#L343-L361
def punctuate_authorname(an): """Punctuate author names properly. Expects input in the form 'Bloggs, J K' and will return 'Bloggs, J. K.'. """ name = an.strip() parts = [x for x in name.split(',') if x != ''] ret_str = '' for idx, part in enumerate(parts): subparts = part.strip().sp...
[ "def", "punctuate_authorname", "(", "an", ")", ":", "name", "=", "an", ".", "strip", "(", ")", "parts", "=", "[", "x", "for", "x", "in", "name", ".", "split", "(", "','", ")", "if", "x", "!=", "''", "]", "ret_str", "=", "''", "for", "idx", ",",...
Punctuate author names properly. Expects input in the form 'Bloggs, J K' and will return 'Bloggs, J. K.'.
[ "Punctuate", "author", "names", "properly", "." ]
python
valid
32.473684
akfullfo/taskforce
taskforce/task.py
https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/task.py#L151-L369
def _exec_process(cmd_list, base_context, instance=0, log=None): """ Process execution tool. The forks and execs a process with args formatted according to a context. This is implemented as a module function to make it available to event_targets, legion and tasks. The args are: cmd_list ...
[ "def", "_exec_process", "(", "cmd_list", ",", "base_context", ",", "instance", "=", "0", ",", "log", "=", "None", ")", ":", "if", "not", "log", ":", "# pragma: no cover", "log", "=", "logging", ".", "getLogger", "(", "__name__", ")", "log", ".", "addHand...
Process execution tool. The forks and execs a process with args formatted according to a context. This is implemented as a module function to make it available to event_targets, legion and tasks. The args are: cmd_list - The path and arg vector context - Task's context instance ...
[ "Process", "execution", "tool", "." ]
python
train
37.794521
pjmark/NIMPA
niftypet/nimpa/prc/imio.py
https://github.com/pjmark/NIMPA/blob/3f4231fed2934a1d92e4cd8e9e153b0118e29d86/niftypet/nimpa/prc/imio.py#L220-L233
def nii_gzip(imfile, outpath=''): '''Compress *.gz file''' import gzip with open(imfile, 'rb') as f: d = f.read() # Now store the compressed data if outpath=='': fout = imfile+'.gz' else: fout = os.path.join(outpath, os.path.basename(imfile)+'.gz') # store compressed ...
[ "def", "nii_gzip", "(", "imfile", ",", "outpath", "=", "''", ")", ":", "import", "gzip", "with", "open", "(", "imfile", ",", "'rb'", ")", "as", "f", ":", "d", "=", "f", ".", "read", "(", ")", "# Now store the compressed data", "if", "outpath", "==", ...
Compress *.gz file
[ "Compress", "*", ".", "gz", "file" ]
python
train
29
Dentosal/python-sc2
sc2/bot_ai.py
https://github.com/Dentosal/python-sc2/blob/608bd25f04e89d39cef68b40101d8e9a8a7f1634/sc2/bot_ai.py#L366-L386
def already_pending_upgrade(self, upgrade_type: UpgradeId) -> Union[int, float]: """ Check if an upgrade is being researched Return values: 0: not started 0 < x < 1: researching 1: finished """ assert isinstance(upgrade_type, UpgradeId) if upgrade_type in ...
[ "def", "already_pending_upgrade", "(", "self", ",", "upgrade_type", ":", "UpgradeId", ")", "->", "Union", "[", "int", ",", "float", "]", ":", "assert", "isinstance", "(", "upgrade_type", ",", "UpgradeId", ")", "if", "upgrade_type", "in", "self", ".", "state"...
Check if an upgrade is being researched Return values: 0: not started 0 < x < 1: researching 1: finished
[ "Check", "if", "an", "upgrade", "is", "being", "researched", "Return", "values", ":", "0", ":", "not", "started", "0", "<", "x", "<", "1", ":", "researching", "1", ":", "finished" ]
python
train
40.809524
DataBiosphere/toil
attic/toil-sort-example.py
https://github.com/DataBiosphere/toil/blob/a8252277ff814e7bee0971139c2344f88e44b644/attic/toil-sort-example.py#L24-L60
def down(job, input_file_id, n, down_checkpoints): """Input is a file and a range into that file to sort and an output location in which to write the sorted file. If the range is larger than a threshold N the range is divided recursively and a follow on job is then created which merges back the results....
[ "def", "down", "(", "job", ",", "input_file_id", ",", "n", ",", "down_checkpoints", ")", ":", "# Read the file", "input_file", "=", "job", ".", "fileStore", ".", "readGlobalFile", "(", "input_file_id", ",", "cache", "=", "False", ")", "length", "=", "os", ...
Input is a file and a range into that file to sort and an output location in which to write the sorted file. If the range is larger than a threshold N the range is divided recursively and a follow on job is then created which merges back the results. Otherwise, the file is sorted and placed in the outpu...
[ "Input", "is", "a", "file", "and", "a", "range", "into", "that", "file", "to", "sort", "and", "an", "output", "location", "in", "which", "to", "write", "the", "sorted", "file", ".", "If", "the", "range", "is", "larger", "than", "a", "threshold", "N", ...
python
train
54.324324
uuazed/numerapi
numerapi/cli.py
https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/cli.py#L131-L133
def check_new_round(hours=24, tournament=1): """Check if a new round has started within the last `hours`.""" click.echo(int(napi.check_new_round(hours=hours, tournament=tournament)))
[ "def", "check_new_round", "(", "hours", "=", "24", ",", "tournament", "=", "1", ")", ":", "click", ".", "echo", "(", "int", "(", "napi", ".", "check_new_round", "(", "hours", "=", "hours", ",", "tournament", "=", "tournament", ")", ")", ")" ]
Check if a new round has started within the last `hours`.
[ "Check", "if", "a", "new", "round", "has", "started", "within", "the", "last", "hours", "." ]
python
train
62.666667
pyhys/minimalmodbus
dummy_serial.py
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/dummy_serial.py#L129-L138
def close(self): """Close a port on dummy_serial.""" if VERBOSE: _print_out('\nDummy_serial: Closing port\n') if not self._isOpen: raise IOError('Dummy_serial: The port is already closed') self._isOpen = False self.port = None
[ "def", "close", "(", "self", ")", ":", "if", "VERBOSE", ":", "_print_out", "(", "'\\nDummy_serial: Closing port\\n'", ")", "if", "not", "self", ".", "_isOpen", ":", "raise", "IOError", "(", "'Dummy_serial: The port is already closed'", ")", "self", ".", "_isOpen",...
Close a port on dummy_serial.
[ "Close", "a", "port", "on", "dummy_serial", "." ]
python
train
29.5
crackinglandia/pype32
pype32/utils.py
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/utils.py#L242-L251
def readQword(self): """ Reads a qword value from the L{ReadData} stream object. @rtype: int @return: The qword value read from the L{ReadData} stream. """ qword = unpack(self.endianness + ('Q' if not self.signed else 'b'), self.readAt(self.offset, 8))[0] ...
[ "def", "readQword", "(", "self", ")", ":", "qword", "=", "unpack", "(", "self", ".", "endianness", "+", "(", "'Q'", "if", "not", "self", ".", "signed", "else", "'b'", ")", ",", "self", ".", "readAt", "(", "self", ".", "offset", ",", "8", ")", ")"...
Reads a qword value from the L{ReadData} stream object. @rtype: int @return: The qword value read from the L{ReadData} stream.
[ "Reads", "a", "qword", "value", "from", "the", "L", "{", "ReadData", "}", "stream", "object", "." ]
python
train
35
saltstack/salt
salt/client/ssh/wrapper/state.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/client/ssh/wrapper/state.py#L1079-L1198
def single(fun, name, test=None, **kwargs): ''' .. versionadded:: 2015.5.0 Execute a single state function with the named kwargs, returns False if insufficient data is sent to the command By default, the values of the kwargs will be parsed as YAML. So, you can specify lists values, or lists of...
[ "def", "single", "(", "fun", ",", "name", ",", "test", "=", "None", ",", "*", "*", "kwargs", ")", ":", "st_kwargs", "=", "__salt__", ".", "kwargs", "__opts__", "[", "'grains'", "]", "=", "__grains__", "# state.fun -> [state, fun]", "comps", "=", "fun", "...
.. versionadded:: 2015.5.0 Execute a single state function with the named kwargs, returns False if insufficient data is sent to the command By default, the values of the kwargs will be parsed as YAML. So, you can specify lists values, or lists of single entry key-value maps, as you would in a YAML...
[ "..", "versionadded", "::", "2015", ".", "5", ".", "0" ]
python
train
29.341667
CodyKochmann/graphdb
graphdb/SQLiteGraphDB.py
https://github.com/CodyKochmann/graphdb/blob/8c18830db4beda30204f5fd4450bc96eb39b0feb/graphdb/SQLiteGraphDB.py#L212-L222
def delete_item(self, item): ''' removes an item from the db ''' for relation in self.relations_of(item): self.delete_relation(item, relation) for origin, relation in self.relations_to(item, True): self.delete_relation(origin, relation, item) with self._write_lock...
[ "def", "delete_item", "(", "self", ",", "item", ")", ":", "for", "relation", "in", "self", ".", "relations_of", "(", "item", ")", ":", "self", ".", "delete_relation", "(", "item", ",", "relation", ")", "for", "origin", ",", "relation", "in", "self", "....
removes an item from the db
[ "removes", "an", "item", "from", "the", "db" ]
python
train
42
CenturyLinkCloud/clc-python-sdk
src/clc/APIv2/anti_affinity.py
https://github.com/CenturyLinkCloud/clc-python-sdk/blob/f4dba40c627cb08dd4b7d0d277e8d67578010b05/src/clc/APIv2/anti_affinity.py#L28-L49
def GetAll(alias=None,location=None,session=None): """Gets a list of anti-affinity policies within a given account. https://t3n.zendesk.com/entries/44657214-Get-Anti-Affinity-Policies >>> clc.v2.AntiAffinity.GetAll() [<clc.APIv2.anti_affinity.AntiAffinity object at 0x10c65e910>, <clc.APIv2.anti_affinity.AntiA...
[ "def", "GetAll", "(", "alias", "=", "None", ",", "location", "=", "None", ",", "session", "=", "None", ")", ":", "if", "not", "alias", ":", "alias", "=", "clc", ".", "v2", ".", "Account", ".", "GetAlias", "(", "session", "=", "session", ")", "polic...
Gets a list of anti-affinity policies within a given account. https://t3n.zendesk.com/entries/44657214-Get-Anti-Affinity-Policies >>> clc.v2.AntiAffinity.GetAll() [<clc.APIv2.anti_affinity.AntiAffinity object at 0x10c65e910>, <clc.APIv2.anti_affinity.AntiAffinity object at 0x10c65ec90>]
[ "Gets", "a", "list", "of", "anti", "-", "affinity", "policies", "within", "a", "given", "account", "." ]
python
train
40.5
pvlib/pvlib-python
pvlib/irradiance.py
https://github.com/pvlib/pvlib-python/blob/2e844a595b820b43d1170269781fa66bd0ccc8a3/pvlib/irradiance.py#L1007-L1197
def perez(surface_tilt, surface_azimuth, dhi, dni, dni_extra, solar_zenith, solar_azimuth, airmass, model='allsitescomposite1990', return_components=False): ''' Determine diffuse irradiance from the sky on a tilted surface using one of the Perez models. Perez models determine the di...
[ "def", "perez", "(", "surface_tilt", ",", "surface_azimuth", ",", "dhi", ",", "dni", ",", "dni_extra", ",", "solar_zenith", ",", "solar_azimuth", ",", "airmass", ",", "model", "=", "'allsitescomposite1990'", ",", "return_components", "=", "False", ")", ":", "k...
Determine diffuse irradiance from the sky on a tilted surface using one of the Perez models. Perez models determine the diffuse irradiance from the sky (ground reflected irradiance is not included in this algorithm) on a tilted surface using the surface tilt angle, surface azimuth angle, diffuse ho...
[ "Determine", "diffuse", "irradiance", "from", "the", "sky", "on", "a", "tilted", "surface", "using", "one", "of", "the", "Perez", "models", "." ]
python
train
36.832461
openego/ding0
ding0/core/__init__.py
https://github.com/openego/ding0/blob/e2d6528f96255e4bb22ba15514a4f1883564ed5d/ding0/core/__init__.py#L106-L268
def run_ding0(self, session, mv_grid_districts_no=None, debug=False, export_figures=False): """ Let DING0 run by shouting at this method (or just call it from NetworkDing0 instance). This method is a wrapper for the main functionality of DING0. Parameters ---------- ...
[ "def", "run_ding0", "(", "self", ",", "session", ",", "mv_grid_districts_no", "=", "None", ",", "debug", "=", "False", ",", "export_figures", "=", "False", ")", ":", "if", "debug", ":", "start", "=", "time", ".", "time", "(", ")", "# STEP 1: Import MV Grid...
Let DING0 run by shouting at this method (or just call it from NetworkDing0 instance). This method is a wrapper for the main functionality of DING0. Parameters ---------- session : sqlalchemy.orm.session.Session Database session mv_grid_districts_no :...
[ "Let", "DING0", "run", "by", "shouting", "at", "this", "method", "(", "or", "just", "call", "it", "from", "NetworkDing0", "instance", ")", ".", "This", "method", "is", "a", "wrapper", "for", "the", "main", "functionality", "of", "DING0", "." ]
python
train
41.644172
Knoema/knoema-python-driver
knoema/data_reader.py
https://github.com/Knoema/knoema-python-driver/blob/e98b13db3e4df51c208c272e2977bfbe4c6e5532/knoema/data_reader.py#L465-L467
def get_pandas_series(self): """The function creates pandas series based on index and values""" return pandas.Series(self.values, self.index, name=self.name)
[ "def", "get_pandas_series", "(", "self", ")", ":", "return", "pandas", ".", "Series", "(", "self", ".", "values", ",", "self", ".", "index", ",", "name", "=", "self", ".", "name", ")" ]
The function creates pandas series based on index and values
[ "The", "function", "creates", "pandas", "series", "based", "on", "index", "and", "values" ]
python
train
57.666667
gamechanger/confluent_schema_registry_client
confluent_schema_registry_client/__init__.py
https://github.com/gamechanger/confluent_schema_registry_client/blob/ac9196e366724eeb2f19f1a169fd2f9a0c8d68ae/confluent_schema_registry_client/__init__.py#L60-L66
def get_subjects(self): """ Returns the list of subject names present in the schema registry. """ res = requests.get(self._url('/subjects')) raise_if_failed(res) return res.json()
[ "def", "get_subjects", "(", "self", ")", ":", "res", "=", "requests", ".", "get", "(", "self", ".", "_url", "(", "'/subjects'", ")", ")", "raise_if_failed", "(", "res", ")", "return", "res", ".", "json", "(", ")" ]
Returns the list of subject names present in the schema registry.
[ "Returns", "the", "list", "of", "subject", "names", "present", "in", "the", "schema", "registry", "." ]
python
train
31.571429
optimizely/python-sdk
optimizely/optimizely.py
https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/optimizely.py#L564-L581
def get_feature_variable_string(self, feature_key, variable_key, user_id, attributes=None): """ Returns value for a certain string variable attached to a feature. Args: feature_key: Key of the feature whose variable's value is being accessed. variable_key: Key of the variable whose value is to be a...
[ "def", "get_feature_variable_string", "(", "self", ",", "feature_key", ",", "variable_key", ",", "user_id", ",", "attributes", "=", "None", ")", ":", "variable_type", "=", "entities", ".", "Variable", ".", "Type", ".", "STRING", "return", "self", ".", "_get_fe...
Returns value for a certain string variable attached to a feature. Args: feature_key: Key of the feature whose variable's value is being accessed. variable_key: Key of the variable whose value is to be accessed. user_id: ID for user. attributes: Dict representing user attributes. Retur...
[ "Returns", "value", "for", "a", "certain", "string", "variable", "attached", "to", "a", "feature", "." ]
python
train
40.277778
vijayvarma392/surfinBH
surfinBH/_fit_evaluators/fit_3dq8.py
https://github.com/vijayvarma392/surfinBH/blob/9f2d25d00f894ee2ce9ffbb02f4e4a41fa7989eb/surfinBH/_fit_evaluators/fit_3dq8.py#L89-L94
def _load_fits(self, h5file): """ Loads fits from h5file and returns a dictionary of fits. """ fits = {} for key in ['mf', 'chifz', 'vfx', 'vfy']: fits[key] = self._load_scalar_fit(fit_key=key, h5file=h5file) return fits
[ "def", "_load_fits", "(", "self", ",", "h5file", ")", ":", "fits", "=", "{", "}", "for", "key", "in", "[", "'mf'", ",", "'chifz'", ",", "'vfx'", ",", "'vfy'", "]", ":", "fits", "[", "key", "]", "=", "self", ".", "_load_scalar_fit", "(", "fit_key", ...
Loads fits from h5file and returns a dictionary of fits.
[ "Loads", "fits", "from", "h5file", "and", "returns", "a", "dictionary", "of", "fits", "." ]
python
train
43.166667
ewels/MultiQC
multiqc/modules/qualimap/QM_BamQC.py
https://github.com/ewels/MultiQC/blob/2037d6322b2554146a74efbf869156ad20d4c4ec/multiqc/modules/qualimap/QM_BamQC.py#L158-L193
def parse_insert_size(self, f): """ Parse the contents of the Qualimap BamQC Insert Size Histogram file """ # Get the sample name from the parent parent directory # Typical path: <sample name>/raw_data_qualimapReport/insert_size_histogram.txt s_name = self.get_s_name(f) d = dict() zero_insertsi...
[ "def", "parse_insert_size", "(", "self", ",", "f", ")", ":", "# Get the sample name from the parent parent directory", "# Typical path: <sample name>/raw_data_qualimapReport/insert_size_histogram.txt", "s_name", "=", "self", ".", "get_s_name", "(", "f", ")", "d", "=", "dict",...
Parse the contents of the Qualimap BamQC Insert Size Histogram file
[ "Parse", "the", "contents", "of", "the", "Qualimap", "BamQC", "Insert", "Size", "Histogram", "file" ]
python
train
38.111111
sentinel-hub/eo-learn
mask/eolearn/mask/cloud_mask.py
https://github.com/sentinel-hub/eo-learn/blob/b8c390b9f553c561612fe9eb64e720611633a035/mask/eolearn/mask/cloud_mask.py#L93-L106
def _get_wcs_request(self, bbox, time_interval, size_x, size_y, maxcc, time_difference, custom_url_params): """ Returns WCS request. """ return WcsRequest(layer=self.data_feature, bbox=bbox, time=time_interval, ...
[ "def", "_get_wcs_request", "(", "self", ",", "bbox", ",", "time_interval", ",", "size_x", ",", "size_y", ",", "maxcc", ",", "time_difference", ",", "custom_url_params", ")", ":", "return", "WcsRequest", "(", "layer", "=", "self", ".", "data_feature", ",", "b...
Returns WCS request.
[ "Returns", "WCS", "request", "." ]
python
train
47.428571
davidmogar/cucco
cucco/cucco.py
https://github.com/davidmogar/cucco/blob/e2a0ff3342e4a9f25a65c486206a5a2ae1a4dbd4/cucco/cucco.py#L140-L159
def remove_accent_marks(text, excluded=None): """Remove accent marks from input text. This function removes accent marks in the text, but leaves unicode characters defined in the 'excluded' parameter. Args: text: The text to be processed. excluded: Set of unicod...
[ "def", "remove_accent_marks", "(", "text", ",", "excluded", "=", "None", ")", ":", "if", "excluded", "is", "None", ":", "excluded", "=", "set", "(", ")", "return", "unicodedata", ".", "normalize", "(", "'NFKC'", ",", "''", ".", "join", "(", "c", "for",...
Remove accent marks from input text. This function removes accent marks in the text, but leaves unicode characters defined in the 'excluded' parameter. Args: text: The text to be processed. excluded: Set of unicode characters to exclude. Returns: Th...
[ "Remove", "accent", "marks", "from", "input", "text", "." ]
python
train
33.1
bcbio/bcbio-nextgen
bcbio/variation/validate.py
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/validate.py#L671-L680
def _get_validate_plotdata_yaml(grading_file, data): """Retrieve validation plot data from grading YAML file (old style). """ with open(grading_file) as in_handle: grade_stats = yaml.safe_load(in_handle) for sample_stats in grade_stats: sample = sample_stats["sample"] for vtype, ...
[ "def", "_get_validate_plotdata_yaml", "(", "grading_file", ",", "data", ")", ":", "with", "open", "(", "grading_file", ")", "as", "in_handle", ":", "grade_stats", "=", "yaml", ".", "safe_load", "(", "in_handle", ")", "for", "sample_stats", "in", "grade_stats", ...
Retrieve validation plot data from grading YAML file (old style).
[ "Retrieve", "validation", "plot", "data", "from", "grading", "YAML", "file", "(", "old", "style", ")", "." ]
python
train
45.1
NiklasRosenstein-Python/nr-deprecated
nr/path.py
https://github.com/NiklasRosenstein-Python/nr-deprecated/blob/f9f8b89ea1b084841a8ab65784eaf68852686b2a/nr/path.py#L246-L254
def rmvsuffix(subject): """ Remove the suffix from *subject*. """ index = subject.rfind('.') if index > subject.replace('\\', '/').rfind('/'): subject = subject[:index] return subject
[ "def", "rmvsuffix", "(", "subject", ")", ":", "index", "=", "subject", ".", "rfind", "(", "'.'", ")", "if", "index", ">", "subject", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", ".", "rfind", "(", "'/'", ")", ":", "subject", "=", "subject", "[",...
Remove the suffix from *subject*.
[ "Remove", "the", "suffix", "from", "*", "subject", "*", "." ]
python
train
21.333333
akfullfo/taskforce
taskforce/watch_files.py
https://github.com/akfullfo/taskforce/blob/bc6dd744bd33546447d085dbd18a350532220193/taskforce/watch_files.py#L242-L252
def _close(self, fd): """ Close the descriptor used for a path regardless of mode. """ if self._mode == WF_INOTIFYX: try: pynotifyx.rm_watch(self._inx_fd, fd) except: pass else: try: os.close(fd) except: pass
[ "def", "_close", "(", "self", ",", "fd", ")", ":", "if", "self", ".", "_mode", "==", "WF_INOTIFYX", ":", "try", ":", "pynotifyx", ".", "rm_watch", "(", "self", ".", "_inx_fd", ",", "fd", ")", "except", ":", "pass", "else", ":", "try", ":", "os", ...
Close the descriptor used for a path regardless of mode.
[ "Close", "the", "descriptor", "used", "for", "a", "path", "regardless", "of", "mode", "." ]
python
train
26.363636
h2oai/h2o-3
h2o-py/h2o/model/metrics_base.py
https://github.com/h2oai/h2o-3/blob/dd62aaa1e7f680a8b16ee14bc66b0fb5195c2ad8/h2o-py/h2o/model/metrics_base.py#L501-L507
def mean_per_class_error(self, thresholds=None): """ :param thresholds: thresholds parameter must be a list (i.e. [0.01, 0.5, 0.99]). If None, then the thresholds in this set of metrics will be used. :returns: mean per class error. """ return [[x[0], 1 - x[1]] for x i...
[ "def", "mean_per_class_error", "(", "self", ",", "thresholds", "=", "None", ")", ":", "return", "[", "[", "x", "[", "0", "]", ",", "1", "-", "x", "[", "1", "]", "]", "for", "x", "in", "self", ".", "metric", "(", "\"mean_per_class_accuracy\"", ",", ...
:param thresholds: thresholds parameter must be a list (i.e. [0.01, 0.5, 0.99]). If None, then the thresholds in this set of metrics will be used. :returns: mean per class error.
[ ":", "param", "thresholds", ":", "thresholds", "parameter", "must", "be", "a", "list", "(", "i", ".", "e", ".", "[", "0", ".", "01", "0", ".", "5", "0", ".", "99", "]", ")", ".", "If", "None", "then", "the", "thresholds", "in", "this", "set", "...
python
test
54
apache/incubator-mxnet
python/mxnet/ndarray/utils.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/utils.py#L149-L182
def load(fname): """Loads an array from file. See more details in ``save``. Parameters ---------- fname : str The filename. Returns ------- list of NDArray, RowSparseNDArray or CSRNDArray, or \ dict of str to NDArray, RowSparseNDArray or CSRNDArray Loaded data. ...
[ "def", "load", "(", "fname", ")", ":", "if", "not", "isinstance", "(", "fname", ",", "string_types", ")", ":", "raise", "TypeError", "(", "'fname required to be a string'", ")", "out_size", "=", "mx_uint", "(", ")", "out_name_size", "=", "mx_uint", "(", ")",...
Loads an array from file. See more details in ``save``. Parameters ---------- fname : str The filename. Returns ------- list of NDArray, RowSparseNDArray or CSRNDArray, or \ dict of str to NDArray, RowSparseNDArray or CSRNDArray Loaded data.
[ "Loads", "an", "array", "from", "file", "." ]
python
train
33.588235
saulpw/visidata
visidata/vdtui.py
https://github.com/saulpw/visidata/blob/32771e0cea6c24fc7902683d14558391395c591f/visidata/vdtui.py#L644-L660
def toplevelTryFunc(func, *args, **kwargs): 'Thread entry-point for `func(*args, **kwargs)` with try/except wrapper' t = threading.current_thread() t.name = func.__name__ ret = None try: ret = func(*args, **kwargs) except EscapeException as e: # user aborted ...
[ "def", "toplevelTryFunc", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "t", "=", "threading", ".", "current_thread", "(", ")", "t", ".", "name", "=", "func", ".", "__name__", "ret", "=", "None", "try", ":", "ret", "=", "func", ...
Thread entry-point for `func(*args, **kwargs)` with try/except wrapper
[ "Thread", "entry", "-", "point", "for", "func", "(", "*", "args", "**", "kwargs", ")", "with", "try", "/", "except", "wrapper" ]
python
train
33.764706
google/grr
appveyor/windows_templates/build_windows_templates.py
https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/appveyor/windows_templates/build_windows_templates.py#L250-L282
def _RepackTemplates(self): """Repack templates with a dummy config.""" dummy_config = os.path.join( args.grr_src, "grr/test/grr_response_test/test_data/dummyconfig.yaml") if args.build_32: template_i386 = glob.glob(os.path.join(args.output_dir, "*_...
[ "def", "_RepackTemplates", "(", "self", ")", ":", "dummy_config", "=", "os", ".", "path", ".", "join", "(", "args", ".", "grr_src", ",", "\"grr/test/grr_response_test/test_data/dummyconfig.yaml\"", ")", "if", "args", ".", "build_32", ":", "template_i386", "=", "...
Repack templates with a dummy config.
[ "Repack", "templates", "with", "a", "dummy", "config", "." ]
python
train
45.848485
huge-success/sanic
sanic/blueprint_group.py
https://github.com/huge-success/sanic/blob/6a4a3f617fdbe1d3ee8bdc9d1b12ad2d0b34acdd/sanic/blueprint_group.py#L102-L120
def middleware(self, *args, **kwargs): """ A decorator that can be used to implement a Middleware plugin to all of the Blueprints that belongs to this specific Blueprint Group. In case of nested Blueprint Groups, the same middleware is applied across each of the Blueprints recur...
[ "def", "middleware", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "\"bp_group\"", "]", "=", "True", "def", "register_middleware_for_blueprints", "(", "fn", ")", ":", "for", "blueprint", "in", "self", ".", "blueprints", ...
A decorator that can be used to implement a Middleware plugin to all of the Blueprints that belongs to this specific Blueprint Group. In case of nested Blueprint Groups, the same middleware is applied across each of the Blueprints recursively. :param args: Optional positional Parameter...
[ "A", "decorator", "that", "can", "be", "used", "to", "implement", "a", "Middleware", "plugin", "to", "all", "of", "the", "Blueprints", "that", "belongs", "to", "this", "specific", "Blueprint", "Group", "." ]
python
train
40.105263
scanny/python-pptx
pptx/chart/xlsx.py
https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/chart/xlsx.py#L125-L135
def _populate_worksheet(self, workbook, worksheet): """ Write the chart data contents to *worksheet* in category chart layout. Write categories starting in the first column starting in the second row, and proceeding one column per category level (for charts having multi-level cat...
[ "def", "_populate_worksheet", "(", "self", ",", "workbook", ",", "worksheet", ")", ":", "self", ".", "_write_categories", "(", "workbook", ",", "worksheet", ")", "self", ".", "_write_series", "(", "workbook", ",", "worksheet", ")" ]
Write the chart data contents to *worksheet* in category chart layout. Write categories starting in the first column starting in the second row, and proceeding one column per category level (for charts having multi-level categories). Write series as columns starting in the next following...
[ "Write", "the", "chart", "data", "contents", "to", "*", "worksheet", "*", "in", "category", "chart", "layout", ".", "Write", "categories", "starting", "in", "the", "first", "column", "starting", "in", "the", "second", "row", "and", "proceeding", "one", "colu...
python
train
50.363636
trailofbits/manticore
manticore/core/smtlib/solver.py
https://github.com/trailofbits/manticore/blob/54c5a15b1119c523ae54c09972413e8b97f11629/manticore/core/smtlib/solver.py#L490-L543
def get_value(self, constraints, expression): """ Ask the solver for one possible result of given expression using given set of constraints. """ if not issymbolic(expression): return expression assert isinstance(expression, (Bool, BitVec, Array)) with constrai...
[ "def", "get_value", "(", "self", ",", "constraints", ",", "expression", ")", ":", "if", "not", "issymbolic", "(", "expression", ")", ":", "return", "expression", "assert", "isinstance", "(", "expression", ",", "(", "Bool", ",", "BitVec", ",", "Array", ")",...
Ask the solver for one possible result of given expression using given set of constraints.
[ "Ask", "the", "solver", "for", "one", "possible", "result", "of", "given", "expression", "using", "given", "set", "of", "constraints", "." ]
python
valid
41.407407
nephics/mat4py
mat4py/loadmat.py
https://github.com/nephics/mat4py/blob/6c1a2ad903937437cc5f24f3c3f5aa2c5a77a1c1/mat4py/loadmat.py#L146-L167
def read_element_tag(fd, endian): """Read data element tag: type and number of bytes. If tag is of the Small Data Element (SDE) type the element data is also returned. """ data = fd.read(8) mtpn = unpack(endian, 'I', data[:4]) # The most significant two bytes of mtpn will always be 0, # ...
[ "def", "read_element_tag", "(", "fd", ",", "endian", ")", ":", "data", "=", "fd", ".", "read", "(", "8", ")", "mtpn", "=", "unpack", "(", "endian", ",", "'I'", ",", "data", "[", ":", "4", "]", ")", "# The most significant two bytes of mtpn will always be 0...
Read data element tag: type and number of bytes. If tag is of the Small Data Element (SDE) type the element data is also returned.
[ "Read", "data", "element", "tag", ":", "type", "and", "number", "of", "bytes", ".", "If", "tag", "is", "of", "the", "Small", "Data", "Element", "(", "SDE", ")", "type", "the", "element", "data", "is", "also", "returned", "." ]
python
valid
35.227273
jkocherhans/alto
alto/urlviz.py
https://github.com/jkocherhans/alto/blob/79edc058022636fece7902b946ecac710713dfa4/alto/urlviz.py#L142-L160
def get_decorators(func): """ Return a list of decorator names for this function. """ decorators = [] # Parse the source code of the function with ast to find the names of # all of its decorators. tree = ast.parse(inspect.getsource(func)) for node in ast.iter_child_nodes(tree): f...
[ "def", "get_decorators", "(", "func", ")", ":", "decorators", "=", "[", "]", "# Parse the source code of the function with ast to find the names of", "# all of its decorators.", "tree", "=", "ast", ".", "parse", "(", "inspect", ".", "getsource", "(", "func", ")", ")",...
Return a list of decorator names for this function.
[ "Return", "a", "list", "of", "decorator", "names", "for", "this", "function", "." ]
python
train
40
vaexio/vaex
packages/vaex-core/vaex/utils.py
https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/utils.py#L588-L595
def write_to(f, mode): """Flexible writing, where f can be a filename or f object, if filename, closed after writing""" if hasattr(f, 'write'): yield f else: f = open(f, mode) yield f f.close()
[ "def", "write_to", "(", "f", ",", "mode", ")", ":", "if", "hasattr", "(", "f", ",", "'write'", ")", ":", "yield", "f", "else", ":", "f", "=", "open", "(", "f", ",", "mode", ")", "yield", "f", "f", ".", "close", "(", ")" ]
Flexible writing, where f can be a filename or f object, if filename, closed after writing
[ "Flexible", "writing", "where", "f", "can", "be", "a", "filename", "or", "f", "object", "if", "filename", "closed", "after", "writing" ]
python
test
28.75
Naresh1318/crystal
crystal/app.py
https://github.com/Naresh1318/crystal/blob/6bb43fd1128296cc59b8ed3bc03064cc61c6bd88/crystal/app.py#L104-L121
def get_projects(): """ Send a dictionary of projects that are available on the database. Usage description: This function is usually called to get and display the list of projects available in the database. :return: JSON, {<int_keys>: <project_name>} """ assert request.method == "GET", "G...
[ "def", "get_projects", "(", ")", ":", "assert", "request", ".", "method", "==", "\"GET\"", ",", "\"GET request expected received {}\"", ".", "format", "(", "request", ".", "method", ")", "try", ":", "if", "request", ".", "method", "==", "'GET'", ":", "projec...
Send a dictionary of projects that are available on the database. Usage description: This function is usually called to get and display the list of projects available in the database. :return: JSON, {<int_keys>: <project_name>}
[ "Send", "a", "dictionary", "of", "projects", "that", "are", "available", "on", "the", "database", "." ]
python
train
31.888889
materialsproject/pymatgen
pymatgen/io/abinit/flows.py
https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/abinit/flows.py#L473-L479
def errored_tasks(self): """List of errored tasks.""" etasks = [] for status in [self.S_ERROR, self.S_QCRITICAL, self.S_ABICRITICAL]: etasks.extend(list(self.iflat_tasks(status=status))) return set(etasks)
[ "def", "errored_tasks", "(", "self", ")", ":", "etasks", "=", "[", "]", "for", "status", "in", "[", "self", ".", "S_ERROR", ",", "self", ".", "S_QCRITICAL", ",", "self", ".", "S_ABICRITICAL", "]", ":", "etasks", ".", "extend", "(", "list", "(", "self...
List of errored tasks.
[ "List", "of", "errored", "tasks", "." ]
python
train
34.857143
saltstack/salt
salt/modules/azurearm_network.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/azurearm_network.py#L272-L406
def security_rule_create_or_update(name, access, direction, priority, protocol, security_group, resource_group, source_address_prefix=None, destination_address_prefix=None, source_port_range=None, destination_port_range=None, source_address_prefixes=...
[ "def", "security_rule_create_or_update", "(", "name", ",", "access", ",", "direction", ",", "priority", ",", "protocol", ",", "security_group", ",", "resource_group", ",", "source_address_prefix", "=", "None", ",", "destination_address_prefix", "=", "None", ",", "so...
.. versionadded:: 2019.2.0 Create or update a security rule within a specified network security group. :param name: The name of the security rule to create. :param access: 'allow' or 'deny' :param direction: 'inbound' or 'outbound' :param priority: Integer between 100 an...
[ "..", "versionadded", "::", "2019", ".", "2", ".", "0" ]
python
train
40.266667
ioos/compliance-checker
compliance_checker/cf/cf.py
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cf/cf.py#L1151-L1240
def check_standard_name(self, ds): ''' Check a variables's standard_name attribute to ensure that it meets CF compliance. CF §3.3 A standard name is associated with a variable via the attribute standard_name which takes a string value comprised of a standard name optiona...
[ "def", "check_standard_name", "(", "self", ",", "ds", ")", ":", "ret_val", "=", "[", "]", "coord_vars", "=", "self", ".", "_find_coord_vars", "(", "ds", ")", "aux_coord_vars", "=", "self", ".", "_find_aux_coord_vars", "(", "ds", ")", "axis_vars", "=", "cfu...
Check a variables's standard_name attribute to ensure that it meets CF compliance. CF §3.3 A standard name is associated with a variable via the attribute standard_name which takes a string value comprised of a standard name optionally followed by one or more blanks and a standard name ...
[ "Check", "a", "variables", "s", "standard_name", "attribute", "to", "ensure", "that", "it", "meets", "CF", "compliance", "." ]
python
train
50.822222
kkinder/NdbSearchableBase
NdbSearchableBase/SearchableModel.py
https://github.com/kkinder/NdbSearchableBase/blob/4f999336b464704a0929cec135c1f09fb1ddfb7c/NdbSearchableBase/SearchableModel.py#L159-L172
def from_urlsafe(cls, urlsafe): """ Returns an instance of the model from a urlsafe string. :param urlsafe: urlsafe key :return: Instance of cls """ try: key = ndb.Key(urlsafe=urlsafe) except: return None obj = key.get() if...
[ "def", "from_urlsafe", "(", "cls", ",", "urlsafe", ")", ":", "try", ":", "key", "=", "ndb", ".", "Key", "(", "urlsafe", "=", "urlsafe", ")", "except", ":", "return", "None", "obj", "=", "key", ".", "get", "(", ")", "if", "obj", "and", "isinstance",...
Returns an instance of the model from a urlsafe string. :param urlsafe: urlsafe key :return: Instance of cls
[ "Returns", "an", "instance", "of", "the", "model", "from", "a", "urlsafe", "string", "." ]
python
train
25.714286
secure-systems-lab/securesystemslib
securesystemslib/keys.py
https://github.com/secure-systems-lab/securesystemslib/blob/beb3109d5bb462e5a60eed88fb40ed1167bd354e/securesystemslib/keys.py#L744-L882
def verify_signature(key_dict, signature, data): """ <Purpose> Determine whether the private key belonging to 'key_dict' produced 'signature'. verify_signature() will use the public key found in 'key_dict', the 'sig' objects contained in 'signature', and 'data' to complete the verification. >>...
[ "def", "verify_signature", "(", "key_dict", ",", "signature", ",", "data", ")", ":", "# Does 'key_dict' have the correct format?", "# This check will ensure 'key_dict' has the appropriate number", "# of objects and object types, and that all dict keys are properly named.", "# Raise 'secure...
<Purpose> Determine whether the private key belonging to 'key_dict' produced 'signature'. verify_signature() will use the public key found in 'key_dict', the 'sig' objects contained in 'signature', and 'data' to complete the verification. >>> ed25519_key = generate_ed25519_key() >>> data = 'Th...
[ "<Purpose", ">", "Determine", "whether", "the", "private", "key", "belonging", "to", "key_dict", "produced", "signature", ".", "verify_signature", "()", "will", "use", "the", "public", "key", "found", "in", "key_dict", "the", "sig", "objects", "contained", "in",...
python
train
36.978417
saltstack/salt
salt/modules/zookeeper.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zookeeper.py#L234-L268
def exists(path, profile=None, hosts=None, scheme=None, username=None, password=None, default_acl=None): ''' Check if path exists path path to check profile Configured Zookeeper profile to authenticate with (Default: None) hosts Lists of Zookeeper Hosts (Default: '127.0.0....
[ "def", "exists", "(", "path", ",", "profile", "=", "None", ",", "hosts", "=", "None", ",", "scheme", "=", "None", ",", "username", "=", "None", ",", "password", "=", "None", ",", "default_acl", "=", "None", ")", ":", "conn", "=", "_get_zk_conn", "(",...
Check if path exists path path to check profile Configured Zookeeper profile to authenticate with (Default: None) hosts Lists of Zookeeper Hosts (Default: '127.0.0.1:2181) scheme Scheme to authenticate with (Default: 'digest') username Username to authent...
[ "Check", "if", "path", "exists" ]
python
train
25.657143
philgyford/django-spectator
spectator/events/migrations/0039_populate_exhibitions.py
https://github.com/philgyford/django-spectator/blob/f3c72004f9caa1fde0f5a3b2f0d2bf285fc01ada/spectator/events/migrations/0039_populate_exhibitions.py#L11-L24
def generate_slug(value): """ Generates a slug using a Hashid of `value`. COPIED from spectator.core.models.SluggedModelMixin() because migrations don't make this happen automatically and perhaps the least bad thing is to copy the method here, ugh. """ alphabet = app_settings.SLUG_ALPHABET ...
[ "def", "generate_slug", "(", "value", ")", ":", "alphabet", "=", "app_settings", ".", "SLUG_ALPHABET", "salt", "=", "app_settings", ".", "SLUG_SALT", "hashids", "=", "Hashids", "(", "alphabet", "=", "alphabet", ",", "salt", "=", "salt", ",", "min_length", "=...
Generates a slug using a Hashid of `value`. COPIED from spectator.core.models.SluggedModelMixin() because migrations don't make this happen automatically and perhaps the least bad thing is to copy the method here, ugh.
[ "Generates", "a", "slug", "using", "a", "Hashid", "of", "value", "." ]
python
train
31.5
rpcope1/PythonConfluenceAPI
PythonConfluenceAPI/api.py
https://github.com/rpcope1/PythonConfluenceAPI/blob/b7f0ca2a390f964715fdf3a60b5b0c5ef7116d40/PythonConfluenceAPI/api.py#L273-L294
def get_content_macro_by_macro_id(self, content_id, version, macro_id, callback=None): """ Returns the body of a macro (in storage format) with the given id. This resource is primarily used by connect applications that require the body of macro to perform their work. When content is cre...
[ "def", "get_content_macro_by_macro_id", "(", "self", ",", "content_id", ",", "version", ",", "macro_id", ",", "callback", "=", "None", ")", ":", "return", "self", ".", "_service_get_request", "(", "\"rest/api/content/{id}/history/{version}/macro/id/{macro_id}\"", "\"\"", ...
Returns the body of a macro (in storage format) with the given id. This resource is primarily used by connect applications that require the body of macro to perform their work. When content is created, if no macroId is specified, then Confluence will generate a random id. The id is persisted as...
[ "Returns", "the", "body", "of", "a", "macro", "(", "in", "storage", "format", ")", "with", "the", "given", "id", ".", "This", "resource", "is", "primarily", "used", "by", "connect", "applications", "that", "require", "the", "body", "of", "macro", "to", "...
python
train
73.636364
saltstack/salt
salt/cloud/clouds/msazure.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/msazure.py#L1498-L1522
def list_disks(kwargs=None, conn=None, call=None): ''' .. versionadded:: 2015.8.0 List disks associated with the account CLI Example: .. code-block:: bash salt-cloud -f list_disks my-azure ''' if call != 'function': raise SaltCloudSystemExit( 'The list_disks f...
[ "def", "list_disks", "(", "kwargs", "=", "None", ",", "conn", "=", "None", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "'function'", ":", "raise", "SaltCloudSystemExit", "(", "'The list_disks function must be called with -f or --function.'", ")", "if",...
.. versionadded:: 2015.8.0 List disks associated with the account CLI Example: .. code-block:: bash salt-cloud -f list_disks my-azure
[ "..", "versionadded", "::", "2015", ".", "8", ".", "0" ]
python
train
21.12
cjdrake/pyeda
pyeda/logic/aes.py
https://github.com/cjdrake/pyeda/blob/554ee53aa678f4b61bcd7e07ba2c74ddc749d665/pyeda/logic/aes.py#L202-L216
def add_round_key(state, rkey): """ Transformation in the Cipher and Inverse Cipher in which a Round Key is added to the State using an XOR operation. The length of a Round Key equals the size of the State (i.e., for Nb = 4, the Round Key length equals 128 bits/16 bytes). """ state = state.r...
[ "def", "add_round_key", "(", "state", ",", "rkey", ")", ":", "state", "=", "state", ".", "reshape", "(", "4", ",", "32", ")", "rkey", "=", "rkey", ".", "reshape", "(", "4", ",", "32", ")", "return", "fcat", "(", "state", "[", "0", "]", "^", "rk...
Transformation in the Cipher and Inverse Cipher in which a Round Key is added to the State using an XOR operation. The length of a Round Key equals the size of the State (i.e., for Nb = 4, the Round Key length equals 128 bits/16 bytes).
[ "Transformation", "in", "the", "Cipher", "and", "Inverse", "Cipher", "in", "which", "a", "Round", "Key", "is", "added", "to", "the", "State", "using", "an", "XOR", "operation", ".", "The", "length", "of", "a", "Round", "Key", "equals", "the", "size", "of...
python
train
32.333333
joequant/cryptoexchange
cryptoexchange/util/bitmex-generate-api-key.py
https://github.com/joequant/cryptoexchange/blob/6690fbd9a2ba00e40d7484425808c84d44233f0c/cryptoexchange/util/bitmex-generate-api-key.py#L110-L120
def disable_key(self): """Disable an existing API Key.""" print("This command will disable a enabled key.") apiKeyID = input("API Key ID: ") try: key = self._curl_bitmex("/apiKey/disable", postdict={"apiKeyID": apiKeyID}) print(...
[ "def", "disable_key", "(", "self", ")", ":", "print", "(", "\"This command will disable a enabled key.\"", ")", "apiKeyID", "=", "input", "(", "\"API Key ID: \"", ")", "try", ":", "key", "=", "self", ".", "_curl_bitmex", "(", "\"/apiKey/disable\"", ",", "postdict"...
Disable an existing API Key.
[ "Disable", "an", "existing", "API", "Key", "." ]
python
train
41.636364
zhmcclient/python-zhmcclient
zhmcclient_mock/_urihandler.py
https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient_mock/_urihandler.py#L207-L226
def check_required_fields(method, uri, body, field_names): """ Check required fields in the request body. Raises: BadRequestError with reason 3: Missing request body BadRequestError with reason 5: Missing required field in request body """ # Check presence of request body if body i...
[ "def", "check_required_fields", "(", "method", ",", "uri", ",", "body", ",", "field_names", ")", ":", "# Check presence of request body", "if", "body", "is", "None", ":", "raise", "BadRequestError", "(", "method", ",", "uri", ",", "reason", "=", "3", ",", "m...
Check required fields in the request body. Raises: BadRequestError with reason 3: Missing request body BadRequestError with reason 5: Missing required field in request body
[ "Check", "required", "fields", "in", "the", "request", "body", "." ]
python
train
36.45
Bystroushaak/pyDHTMLParser
src/dhtmlparser/__init__.py
https://github.com/Bystroushaak/pyDHTMLParser/blob/4756f93dd048500b038ece2323fe26e46b6bfdea/src/dhtmlparser/__init__.py#L43-L150
def _raw_split(itxt): """ Parse HTML from text into array filled with tags end text. Source code is little bit unintutive, because it is state machine parser. For better understanding, look at http://bit.ly/1rXRcJj Example:: >>> dhtmlparser._raw_split('<html><tag params="true"></html>') ...
[ "def", "_raw_split", "(", "itxt", ")", ":", "echr", "=", "\"\"", "buff", "=", "[", "\"\"", ",", "\"\"", ",", "\"\"", ",", "\"\"", "]", "content", "=", "\"\"", "array", "=", "[", "]", "next_state", "=", "0", "inside_tag", "=", "False", "escaped", "=...
Parse HTML from text into array filled with tags end text. Source code is little bit unintutive, because it is state machine parser. For better understanding, look at http://bit.ly/1rXRcJj Example:: >>> dhtmlparser._raw_split('<html><tag params="true"></html>') ['<html>', '<tag params="t...
[ "Parse", "HTML", "from", "text", "into", "array", "filled", "with", "tags", "end", "text", "." ]
python
train
26.342593
StackStorm/pybind
pybind/nos/v6_0_2f/snmp_server/__init__.py
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/snmp_server/__init__.py#L250-L271
def _set_host(self, v, load=False): """ Setter method for host, mapped from YANG variable /snmp_server/host (list) If this variable is read-only (config: false) in the source YANG file, then _set_host is considered as a private method. Backends looking to populate this variable should do so via ...
[ "def", "_set_host", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "base", ...
Setter method for host, mapped from YANG variable /snmp_server/host (list) If this variable is read-only (config: false) in the source YANG file, then _set_host is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_host() directly.
[ "Setter", "method", "for", "host", "mapped", "from", "YANG", "variable", "/", "snmp_server", "/", "host", "(", "list", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in", "the", "source", "YANG", "file", "t...
python
train
124.772727
monarch-initiative/dipper
dipper/sources/Coriell.py
https://github.com/monarch-initiative/dipper/blob/24cc80db355bbe15776edc5c7b41e0886959ba41/dipper/sources/Coriell.py#L150-L224
def fetch(self, is_dl_forced=False): """ Here we connect to the coriell sftp server using private connection details. They dump bi-weekly files with a timestamp in the filename. For each catalog, we ping the remote site and pull the most-recently updated file, renaming it to our...
[ "def", "fetch", "(", "self", ",", "is_dl_forced", "=", "False", ")", ":", "host", "=", "config", ".", "get_config", "(", ")", "[", "'dbauth'", "]", "[", "'coriell'", "]", "[", "'host'", "]", "key", "=", "config", ".", "get_config", "(", ")", "[", "...
Here we connect to the coriell sftp server using private connection details. They dump bi-weekly files with a timestamp in the filename. For each catalog, we ping the remote site and pull the most-recently updated file, renaming it to our local latest.csv. Be sure to have pg user/pass...
[ "Here", "we", "connect", "to", "the", "coriell", "sftp", "server", "using", "private", "connection", "details", ".", "They", "dump", "bi", "-", "weekly", "files", "with", "a", "timestamp", "in", "the", "filename", ".", "For", "each", "catalog", "we", "ping...
python
train
46
rackerlabs/rackspace-python-neutronclient
neutronclient/v2_0/client.py
https://github.com/rackerlabs/rackspace-python-neutronclient/blob/5a5009a8fe078e3aa1d582176669f1b28ab26bef/neutronclient/v2_0/client.py#L968-L971
def update_loadbalancer(self, lbaas_loadbalancer, body=None): """Updates a load balancer.""" return self.put(self.lbaas_loadbalancer_path % (lbaas_loadbalancer), body=body)
[ "def", "update_loadbalancer", "(", "self", ",", "lbaas_loadbalancer", ",", "body", "=", "None", ")", ":", "return", "self", ".", "put", "(", "self", ".", "lbaas_loadbalancer_path", "%", "(", "lbaas_loadbalancer", ")", ",", "body", "=", "body", ")" ]
Updates a load balancer.
[ "Updates", "a", "load", "balancer", "." ]
python
train
52.25
photo/openphoto-python
trovebox/api/api_photo.py
https://github.com/photo/openphoto-python/blob/209a1da27c8d8c88dbcf4ea6c6f57031ea1bc44b/trovebox/api/api_photo.py#L73-L83
def delete_source(self, photo, **kwds): """ Endpoint: /photo/<id>/source/delete.json Delete the source files of a photo. Returns True if successful. Raises a TroveboxError if not. """ return self._client.post("/photo/%s/source/delete.json" % ...
[ "def", "delete_source", "(", "self", ",", "photo", ",", "*", "*", "kwds", ")", ":", "return", "self", ".", "_client", ".", "post", "(", "\"/photo/%s/source/delete.json\"", "%", "self", ".", "_extract_id", "(", "photo", ")", ",", "*", "*", "kwds", ")", ...
Endpoint: /photo/<id>/source/delete.json Delete the source files of a photo. Returns True if successful. Raises a TroveboxError if not.
[ "Endpoint", ":", "/", "photo", "/", "<id", ">", "/", "source", "/", "delete", ".", "json" ]
python
train
36.090909
publysher/rdflib-django
src/rdflib_django/store.py
https://github.com/publysher/rdflib-django/blob/e26992af75f96ef27a6ceaf820574e3bca645953/src/rdflib_django/store.py#L41-L48
def _get_named_graph(context): """ Returns the named graph for this context. """ if context is None: return None return models.NamedGraph.objects.get_or_create(identifier=context.identifier)[0]
[ "def", "_get_named_graph", "(", "context", ")", ":", "if", "context", "is", "None", ":", "return", "None", "return", "models", ".", "NamedGraph", ".", "objects", ".", "get_or_create", "(", "identifier", "=", "context", ".", "identifier", ")", "[", "0", "]"...
Returns the named graph for this context.
[ "Returns", "the", "named", "graph", "for", "this", "context", "." ]
python
train
26.875
sethmlarson/virtualbox-python
virtualbox/library.py
https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L26448-L26459
def modify_log_flags(self, settings): """Modifies the debug or release logger flags. in settings of type str The flags settings string. See iprt/log.h for details. To target the release logger, prefix the string with "release:". """ if not isinstance(settings, b...
[ "def", "modify_log_flags", "(", "self", ",", "settings", ")", ":", "if", "not", "isinstance", "(", "settings", ",", "basestring", ")", ":", "raise", "TypeError", "(", "\"settings can only be an instance of type basestring\"", ")", "self", ".", "_call", "(", "\"mod...
Modifies the debug or release logger flags. in settings of type str The flags settings string. See iprt/log.h for details. To target the release logger, prefix the string with "release:".
[ "Modifies", "the", "debug", "or", "release", "logger", "flags", "." ]
python
train
39.833333
data-8/datascience
datascience/tables.py
https://github.com/data-8/datascience/blob/4cee38266903ca169cea4a53b8cc39502d85c464/datascience/tables.py#L1686-L1733
def relabeled(self, label, new_label): """Return a new table with ``label`` specifying column label(s) replaced by corresponding ``new_label``. Args: ``label`` -- (str or array of str) The label(s) of columns to be changed. ``new_label`` -- (str or array...
[ "def", "relabeled", "(", "self", ",", "label", ",", "new_label", ")", ":", "copy", "=", "self", ".", "copy", "(", ")", "copy", ".", "relabel", "(", "label", ",", "new_label", ")", "return", "copy" ]
Return a new table with ``label`` specifying column label(s) replaced by corresponding ``new_label``. Args: ``label`` -- (str or array of str) The label(s) of columns to be changed. ``new_label`` -- (str or array of str): The new label(s) of colu...
[ "Return", "a", "new", "table", "with", "label", "specifying", "column", "label", "(", "s", ")", "replaced", "by", "corresponding", "new_label", "." ]
python
train
34.854167
pyvisa/pyvisa
pyvisa/ctwrapper/functions.py
https://github.com/pyvisa/pyvisa/blob/b8b2d4371e1f00782856aa9176ff1ced6bcb3798/pyvisa/ctwrapper/functions.py#L1360-L1394
def parse_resource_extended(library, session, resource_name): """Parse a resource string to get extended interface information. Corresponds to viParseRsrcEx function of the VISA library. :param library: the visa library wrapped by ctypes. :param session: Resource Manager session (should always be the ...
[ "def", "parse_resource_extended", "(", "library", ",", "session", ",", "resource_name", ")", ":", "interface_type", "=", "ViUInt16", "(", ")", "interface_board_number", "=", "ViUInt16", "(", ")", "resource_class", "=", "create_string_buffer", "(", "constants", ".", ...
Parse a resource string to get extended interface information. Corresponds to viParseRsrcEx function of the VISA library. :param library: the visa library wrapped by ctypes. :param session: Resource Manager session (should always be the Default Resource Manager for VISA returned from o...
[ "Parse", "a", "resource", "string", "to", "get", "extended", "interface", "information", "." ]
python
train
47.685714
apache/incubator-mxnet
python/mxnet/image/detection.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/detection.py#L213-L217
def _calculate_areas(self, label): """Calculate areas for multiple labels""" heights = np.maximum(0, label[:, 3] - label[:, 1]) widths = np.maximum(0, label[:, 2] - label[:, 0]) return heights * widths
[ "def", "_calculate_areas", "(", "self", ",", "label", ")", ":", "heights", "=", "np", ".", "maximum", "(", "0", ",", "label", "[", ":", ",", "3", "]", "-", "label", "[", ":", ",", "1", "]", ")", "widths", "=", "np", ".", "maximum", "(", "0", ...
Calculate areas for multiple labels
[ "Calculate", "areas", "for", "multiple", "labels" ]
python
train
45.8
nugget/python-anthemav
anthemav/protocol.py
https://github.com/nugget/python-anthemav/blob/c3cee38f2d452c1ab1335d9885e0769ec24d5f90/anthemav/protocol.py#L852-L856
def dump_rawdata(self): """Return contents of transport object for debugging forensics.""" if hasattr(self, 'transport'): attrs = vars(self.transport) return ', '.join("%s: %s" % item for item in attrs.items())
[ "def", "dump_rawdata", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'transport'", ")", ":", "attrs", "=", "vars", "(", "self", ".", "transport", ")", "return", "', '", ".", "join", "(", "\"%s: %s\"", "%", "item", "for", "item", "in", "a...
Return contents of transport object for debugging forensics.
[ "Return", "contents", "of", "transport", "object", "for", "debugging", "forensics", "." ]
python
train
49.2
pandas-dev/pandas
pandas/core/indexes/base.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/base.py#L4440-L4450
def get_indexer_for(self, target, **kwargs): """ Guaranteed return of an indexer even when non-unique. This dispatches to get_indexer or get_indexer_nonunique as appropriate. """ if self.is_unique: return self.get_indexer(target, **kwargs) indexer, _ ...
[ "def", "get_indexer_for", "(", "self", ",", "target", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "is_unique", ":", "return", "self", ".", "get_indexer", "(", "target", ",", "*", "*", "kwargs", ")", "indexer", ",", "_", "=", "self", ".", ...
Guaranteed return of an indexer even when non-unique. This dispatches to get_indexer or get_indexer_nonunique as appropriate.
[ "Guaranteed", "return", "of", "an", "indexer", "even", "when", "non", "-", "unique", "." ]
python
train
34.545455
PonteIneptique/collatinus-python
pycollatinus/ch.py
https://github.com/PonteIneptique/collatinus-python/blob/fca37b0b77bc60f47d3c24ab42f6d0bdca6ba0f5/pycollatinus/ch.py#L20-L45
def listeI(l): """ Fonction importante permettant de renvoyer une liste d'entiers à partir d'une chaîne. La chaîne est une liste de sections séparées par des virgules. Une section peut être soit un entier, soit un intervalle d'entiers. On donne alors les l...
[ "def", "listeI", "(", "l", ")", ":", "result", "=", "[", "]", "lvirg", "=", "l", ".", "split", "(", "','", ")", "for", "virg", "in", "lvirg", ":", "if", "\"-\"", "in", "virg", ":", "deb", ",", "fin", "=", "tuple", "(", "virg", ".", "split", "...
Fonction importante permettant de renvoyer une liste d'entiers à partir d'une chaîne. La chaîne est une liste de sections séparées par des virgules. Une section peut être soit un entier, soit un intervalle d'entiers. On donne alors les limites inférieure et su...
[ "Fonction", "importante", "permettant", "de", "renvoyer", "une", "liste", "d", "entiers", "à", "partir", "d", "une", "chaîne", ".", "La", "chaîne", "est", "une", "liste", "de", "sections", "séparées", "par", "des", "virgules", ".", "Une", "section", "peut", ...
python
train
33.423077
googleapis/google-cloud-python
datastore/google/cloud/datastore/query.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/datastore/google/cloud/datastore/query.py#L184-L192
def ancestor(self, value): """Set the ancestor for the query :type value: :class:`~google.cloud.datastore.key.Key` :param value: the new ancestor key """ if not isinstance(value, Key): raise TypeError("Ancestor must be a Key") self._ancestor = value
[ "def", "ancestor", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "Key", ")", ":", "raise", "TypeError", "(", "\"Ancestor must be a Key\"", ")", "self", ".", "_ancestor", "=", "value" ]
Set the ancestor for the query :type value: :class:`~google.cloud.datastore.key.Key` :param value: the new ancestor key
[ "Set", "the", "ancestor", "for", "the", "query" ]
python
train
33.555556
googleapis/google-auth-library-python
google/auth/transport/urllib3.py
https://github.com/googleapis/google-auth-library-python/blob/2c6ad78917e936f38f87c946209c8031166dc96e/google/auth/transport/urllib3.py#L198-L246
def urlopen(self, method, url, body=None, headers=None, **kwargs): """Implementation of urllib3's urlopen.""" # pylint: disable=arguments-differ # We use kwargs to collect additional args that we don't need to # introspect here. However, we do explicitly collect the two # positio...
[ "def", "urlopen", "(", "self", ",", "method", ",", "url", ",", "body", "=", "None", ",", "headers", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable=arguments-differ", "# We use kwargs to collect additional args that we don't need to", "# introspect ...
Implementation of urllib3's urlopen.
[ "Implementation", "of", "urllib3", "s", "urlopen", "." ]
python
train
42.102041
thebigmunch/google-music
src/google_music/clients/mobileclient.py
https://github.com/thebigmunch/google-music/blob/d8a94dab462a1f063fbc1152187a73dc2f0e2a85/src/google_music/clients/mobileclient.py#L1840-L1864
def stations_iter(self, *, page_size=250): """Get a paged iterator of library stations. Parameters: page_size (int, Optional): The maximum number of results per returned page. Max allowed is ``49995``. Default: ``250`` Yields: list: Station dicts. """ start_token = None while True: resp...
[ "def", "stations_iter", "(", "self", ",", "*", ",", "page_size", "=", "250", ")", ":", "start_token", "=", "None", "while", "True", ":", "response", "=", "self", ".", "_call", "(", "mc_calls", ".", "RadioStation", ",", "max_results", "=", "page_size", ",...
Get a paged iterator of library stations. Parameters: page_size (int, Optional): The maximum number of results per returned page. Max allowed is ``49995``. Default: ``250`` Yields: list: Station dicts.
[ "Get", "a", "paged", "iterator", "of", "library", "stations", "." ]
python
train
21.88
genialis/resolwe
resolwe/flow/views/mixins.py
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/views/mixins.py#L30-L32
def define_contributor(self, request): """Define contributor by adding it to request.data.""" request.data['contributor'] = self.resolve_user(request.user).pk
[ "def", "define_contributor", "(", "self", ",", "request", ")", ":", "request", ".", "data", "[", "'contributor'", "]", "=", "self", ".", "resolve_user", "(", "request", ".", "user", ")", ".", "pk" ]
Define contributor by adding it to request.data.
[ "Define", "contributor", "by", "adding", "it", "to", "request", ".", "data", "." ]
python
train
57.333333
istresearch/scrapy-cluster
utils/scutils/zookeeper_watcher.py
https://github.com/istresearch/scrapy-cluster/blob/13aaed2349af5d792d6bcbfcadc5563158aeb599/utils/scutils/zookeeper_watcher.py#L237-L255
def update_pointed(self): ''' Grabs the latest file contents based on the pointer uri ''' # only grab file if our pointer is still good (not None) if not self.pointed_at_expired: try: conf_string, stat2 = self.zoo_client.get(self.point_path, ...
[ "def", "update_pointed", "(", "self", ")", ":", "# only grab file if our pointer is still good (not None)", "if", "not", "self", ".", "pointed_at_expired", ":", "try", ":", "conf_string", ",", "stat2", "=", "self", ".", "zoo_client", ".", "get", "(", "self", ".", ...
Grabs the latest file contents based on the pointer uri
[ "Grabs", "the", "latest", "file", "contents", "based", "on", "the", "pointer", "uri" ]
python
train
38.157895
rkcosmos/deepcut
deepcut/train.py
https://github.com/rkcosmos/deepcut/blob/9a2729071d01972af805acede85d7aa9e7a6da30/deepcut/train.py#L39-L62
def create_char_dataframe(words): """ Give list of input tokenized words, create dataframe of characters where first character of the word is tagged as 1, otherwise 0 Example ======= ['กิน', 'หมด'] to dataframe of [{'char': 'ก', 'type': ..., 'target': 1}, ..., {'char': 'ด', 'type':...
[ "def", "create_char_dataframe", "(", "words", ")", ":", "char_dict", "=", "[", "]", "for", "word", "in", "words", ":", "for", "i", ",", "char", "in", "enumerate", "(", "word", ")", ":", "if", "i", "==", "0", ":", "char_dict", ".", "append", "(", "{...
Give list of input tokenized words, create dataframe of characters where first character of the word is tagged as 1, otherwise 0 Example ======= ['กิน', 'หมด'] to dataframe of [{'char': 'ก', 'type': ..., 'target': 1}, ..., {'char': 'ด', 'type': ..., 'target': 0}]
[ "Give", "list", "of", "input", "tokenized", "words", "create", "dataframe", "of", "characters", "where", "first", "character", "of", "the", "word", "is", "tagged", "as", "1", "otherwise", "0" ]
python
valid
34.708333
sernst/cauldron
cauldron/environ/logger.py
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/environ/logger.py#L14-L27
def add_output_path(path: str = None) -> str: """ Adds the specified path to the output logging paths if it is not already in the listed paths. :param path: The path to add to the logging output paths. If the path is empty or no path is given, the current working directory will be used ...
[ "def", "add_output_path", "(", "path", ":", "str", "=", "None", ")", "->", "str", ":", "cleaned", "=", "paths", ".", "clean", "(", "path", "or", "os", ".", "getcwd", "(", ")", ")", "if", "cleaned", "not", "in", "_logging_paths", ":", "_logging_paths", ...
Adds the specified path to the output logging paths if it is not already in the listed paths. :param path: The path to add to the logging output paths. If the path is empty or no path is given, the current working directory will be used instead.
[ "Adds", "the", "specified", "path", "to", "the", "output", "logging", "paths", "if", "it", "is", "not", "already", "in", "the", "listed", "paths", "." ]
python
train
33.857143
odlgroup/odl
odl/discr/grid.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/discr/grid.py#L234-L241
def shape(self): """Number of grid points per axis.""" try: return self.__shape except AttributeError: shape = tuple(len(vec) for vec in self.coord_vectors) self.__shape = shape return shape
[ "def", "shape", "(", "self", ")", ":", "try", ":", "return", "self", ".", "__shape", "except", "AttributeError", ":", "shape", "=", "tuple", "(", "len", "(", "vec", ")", "for", "vec", "in", "self", ".", "coord_vectors", ")", "self", ".", "__shape", "...
Number of grid points per axis.
[ "Number", "of", "grid", "points", "per", "axis", "." ]
python
train
31.875
CitrineInformatics/pypif-sdk
pypif_sdk/interop/datacite.py
https://github.com/CitrineInformatics/pypif-sdk/blob/8b01d10d9a1426d5eef12e4b2f31c4657aa0fe59/pypif_sdk/interop/datacite.py#L42-L57
def datacite_to_pif_reference(dc): """ Parse a top-level datacite dictionary into a Reference :param dc: dictionary containing datacite metadata :return: Reference corresponding to that datacite entry """ ref = Reference() if dc.get('identifier', {}).get('identifierType') == "DOI": r...
[ "def", "datacite_to_pif_reference", "(", "dc", ")", ":", "ref", "=", "Reference", "(", ")", "if", "dc", ".", "get", "(", "'identifier'", ",", "{", "}", ")", ".", "get", "(", "'identifierType'", ")", "==", "\"DOI\"", ":", "ref", ".", "doi", "=", "dc",...
Parse a top-level datacite dictionary into a Reference :param dc: dictionary containing datacite metadata :return: Reference corresponding to that datacite entry
[ "Parse", "a", "top", "-", "level", "datacite", "dictionary", "into", "a", "Reference", ":", "param", "dc", ":", "dictionary", "containing", "datacite", "metadata", ":", "return", ":", "Reference", "corresponding", "to", "that", "datacite", "entry" ]
python
train
35.75
tensorflow/tensor2tensor
tensor2tensor/layers/common_attention.py
https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/layers/common_attention.py#L3554-L3558
def reshape_range(tensor, i, j, shape): """Reshapes a tensor between dimensions i and j.""" t_shape = common_layers.shape_list(tensor) target_shape = t_shape[:i] + shape + t_shape[j:] return tf.reshape(tensor, target_shape)
[ "def", "reshape_range", "(", "tensor", ",", "i", ",", "j", ",", "shape", ")", ":", "t_shape", "=", "common_layers", ".", "shape_list", "(", "tensor", ")", "target_shape", "=", "t_shape", "[", ":", "i", "]", "+", "shape", "+", "t_shape", "[", "j", ":"...
Reshapes a tensor between dimensions i and j.
[ "Reshapes", "a", "tensor", "between", "dimensions", "i", "and", "j", "." ]
python
train
45.4
bitesofcode/projexui
projexui/widgets/xchart/xchart.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchart/xchart.py#L353-L361
def pointAt(self, **axis_values): """ Returns the point on the chart where the inputed values are located. :return <QPointF> """ scene_point = self.renderer().pointAt(self.axes(), axis_values) chart_point = self.uiChartVIEW.mapFromScene(scene_point) ...
[ "def", "pointAt", "(", "self", ",", "*", "*", "axis_values", ")", ":", "scene_point", "=", "self", ".", "renderer", "(", ")", ".", "pointAt", "(", "self", ".", "axes", "(", ")", ",", "axis_values", ")", "chart_point", "=", "self", ".", "uiChartVIEW", ...
Returns the point on the chart where the inputed values are located. :return <QPointF>
[ "Returns", "the", "point", "on", "the", "chart", "where", "the", "inputed", "values", "are", "located", ".", ":", "return", "<QPointF", ">" ]
python
train
40.777778
edeposit/edeposit.amqp.ftp
src/edeposit/amqp/ftp/passwd_reader.py
https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/passwd_reader.py#L153-L167
def _encode_config(conf_dict): """Encode `conf_dict` to string.""" out = [] # get variables in order defined in settings._ALLOWED_MERGES for var in settings._ALLOWED_MERGES: out.append(conf_dict[var]) # convert bools to chars out = map( lambda x: "t" if x else "f", out ...
[ "def", "_encode_config", "(", "conf_dict", ")", ":", "out", "=", "[", "]", "# get variables in order defined in settings._ALLOWED_MERGES", "for", "var", "in", "settings", ".", "_ALLOWED_MERGES", ":", "out", ".", "append", "(", "conf_dict", "[", "var", "]", ")", ...
Encode `conf_dict` to string.
[ "Encode", "conf_dict", "to", "string", "." ]
python
train
22.4
maceoutliner/django-fiction-outlines
fiction_outlines/models.py
https://github.com/maceoutliner/django-fiction-outlines/blob/6c58e356af3fbe7b23557643ba27e46eaef9d4e3/fiction_outlines/models.py#L829-L878
def impact_rating(self): ''' Returns the impact rating for this node. Impact rating is a measure of how powerful this moment in the story is by evaluting how many simultaneous arc elements are associated with it. There is also a generational bleed element, where the impact score ...
[ "def", "impact_rating", "(", "self", ")", ":", "if", "self", ".", "depth", "==", "1", ":", "logger", ".", "debug", "(", "'Root node. Skipping.'", ")", "return", "0", "# pragma: no cover", "impact_bleed", "=", "{", "'mile'", ":", "0.5", ",", "# A milestone ex...
Returns the impact rating for this node. Impact rating is a measure of how powerful this moment in the story is by evaluting how many simultaneous arc elements are associated with it. There is also a generational bleed element, where the impact score creates shockwaves throughout their direct an...
[ "Returns", "the", "impact", "rating", "for", "this", "node", ".", "Impact", "rating", "is", "a", "measure", "of", "how", "powerful", "this", "moment", "in", "the", "story", "is", "by", "evaluting", "how", "many", "simultaneous", "arc", "elements", "are", "...
python
train
52.44
blackecho/Deep-Learning-TensorFlow
yadlt/models/boltzmann/deep_autoencoder.py
https://github.com/blackecho/Deep-Learning-TensorFlow/blob/ddeb1f2848da7b7bee166ad2152b4afc46bb2086/yadlt/models/boltzmann/deep_autoencoder.py#L237-L246
def _create_variables_pretrain(self): """Create model variables (previous unsupervised pretraining). :return: self """ for l, layer in enumerate(self.layers): self.encoding_w_[l] = tf.Variable( self.encoding_w_[l], name='enc-w-{}'.format(l)) self....
[ "def", "_create_variables_pretrain", "(", "self", ")", ":", "for", "l", ",", "layer", "in", "enumerate", "(", "self", ".", "layers", ")", ":", "self", ".", "encoding_w_", "[", "l", "]", "=", "tf", ".", "Variable", "(", "self", ".", "encoding_w_", "[", ...
Create model variables (previous unsupervised pretraining). :return: self
[ "Create", "model", "variables", "(", "previous", "unsupervised", "pretraining", ")", "." ]
python
train
40.4
ets-labs/python-dependency-injector
examples/providers/factory_delegation.py
https://github.com/ets-labs/python-dependency-injector/blob/d04fe41eb17f667da38b97525e2d16c8f2d272fe/examples/providers/factory_delegation.py#L20-L24
def main_photo(self): """Return user's main photo.""" if not self._main_photo: self._main_photo = self.photos_factory() return self._main_photo
[ "def", "main_photo", "(", "self", ")", ":", "if", "not", "self", ".", "_main_photo", ":", "self", ".", "_main_photo", "=", "self", ".", "photos_factory", "(", ")", "return", "self", ".", "_main_photo" ]
Return user's main photo.
[ "Return", "user", "s", "main", "photo", "." ]
python
train
35
spyder-ide/spyder
spyder/plugins/variableexplorer/widgets/collectionseditor.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/collectionseditor.py#L1311-L1314
def get_len(self, key): """Return sequence length""" data = self.model.get_data() return len(data[key])
[ "def", "get_len", "(", "self", ",", "key", ")", ":", "data", "=", "self", ".", "model", ".", "get_data", "(", ")", "return", "len", "(", "data", "[", "key", "]", ")" ]
Return sequence length
[ "Return", "sequence", "length" ]
python
train
31.75
sveetch/boussole
boussole/watcher.py
https://github.com/sveetch/boussole/blob/22cc644e9d633f41ebfc167d427a71c1726cee21/boussole/watcher.py#L265-L273
def compile_dependencies(self, sourcepath, include_self=True): """ Same as inherit method but the default value for keyword argument ``ìnclude_self`` is ``True``. """ return super(SassProjectEventHandler, self).compile_dependencies( sourcepath, include_sel...
[ "def", "compile_dependencies", "(", "self", ",", "sourcepath", ",", "include_self", "=", "True", ")", ":", "return", "super", "(", "SassProjectEventHandler", ",", "self", ")", ".", "compile_dependencies", "(", "sourcepath", ",", "include_self", "=", "include_self"...
Same as inherit method but the default value for keyword argument ``ìnclude_self`` is ``True``.
[ "Same", "as", "inherit", "method", "but", "the", "default", "value", "for", "keyword", "argument", "ìnclude_self", "is", "True", "." ]
python
train
37.333333
ReFirmLabs/binwalk
src/binwalk/core/module.py
https://github.com/ReFirmLabs/binwalk/blob/a0c5315fd2bae167e5c3d8469ce95d5defc743c2/src/binwalk/core/module.py#L528-L540
def header(self): ''' Displays the scan header, as defined by self.HEADER and self.HEADER_FORMAT. Returns None. ''' self.config.display.format_strings(self.HEADER_FORMAT, self.RESULT_FORMAT) self.config.display.add_custom_header(self.VERBOSE_FORMAT, self.VERBOSE) ...
[ "def", "header", "(", "self", ")", ":", "self", ".", "config", ".", "display", ".", "format_strings", "(", "self", ".", "HEADER_FORMAT", ",", "self", ".", "RESULT_FORMAT", ")", "self", ".", "config", ".", "display", ".", "add_custom_header", "(", "self", ...
Displays the scan header, as defined by self.HEADER and self.HEADER_FORMAT. Returns None.
[ "Displays", "the", "scan", "header", "as", "defined", "by", "self", ".", "HEADER", "and", "self", ".", "HEADER_FORMAT", "." ]
python
train
42.769231
offu/WeRoBot
werobot/client.py
https://github.com/offu/WeRoBot/blob/fd42109105b03f9acf45ebd9dcabb9d5cff98f3c/werobot/client.py#L97-L112
def get_access_token(self): """ 判断现有的token是否过期。 用户需要多进程或者多机部署可以手动重写这个函数 来自定义token的存储,刷新策略。 :return: 返回token """ if self._token: now = time.time() if self.token_expires_at - now > 60: return self._token json = self.g...
[ "def", "get_access_token", "(", "self", ")", ":", "if", "self", ".", "_token", ":", "now", "=", "time", ".", "time", "(", ")", "if", "self", ".", "token_expires_at", "-", "now", ">", "60", ":", "return", "self", ".", "_token", "json", "=", "self", ...
判断现有的token是否过期。 用户需要多进程或者多机部署可以手动重写这个函数 来自定义token的存储,刷新策略。 :return: 返回token
[ "判断现有的token是否过期。", "用户需要多进程或者多机部署可以手动重写这个函数", "来自定义token的存储,刷新策略。" ]
python
train
28.5625
evhub/coconut
coconut/compiler/compiler.py
https://github.com/evhub/coconut/blob/ff97177344e7604e89a0a98a977a87ed2a56fc6d/coconut/compiler/compiler.py#L392-L445
def bind(self): """Binds reference objects to the proper parse actions.""" self.endline <<= attach(self.endline_ref, self.endline_handle) self.moduledoc_item <<= trace(attach(self.moduledoc, self.set_docstring)) self.name <<= trace(attach(self.base_name, self.name_check)) # comm...
[ "def", "bind", "(", "self", ")", ":", "self", ".", "endline", "<<=", "attach", "(", "self", ".", "endline_ref", ",", "self", ".", "endline_handle", ")", "self", ".", "moduledoc_item", "<<=", "trace", "(", "attach", "(", "self", ".", "moduledoc", ",", "...
Binds reference objects to the proper parse actions.
[ "Binds", "reference", "objects", "to", "the", "proper", "parse", "actions", "." ]
python
train
75.277778
dims/etcd3-gateway
etcd3gw/client.py
https://github.com/dims/etcd3-gateway/blob/ad566c29cbde135aee20cfd32e0a4815ca3b5ee6/etcd3gw/client.py#L120-L127
def lock(self, id=str(uuid.uuid4()), ttl=DEFAULT_TIMEOUT): """Create a Lock object given an ID and timeout :param id: ID for the lock, creates a new uuid if not provided :param ttl: timeout :return: Lock object """ return Lock(id, ttl=ttl, client=self)
[ "def", "lock", "(", "self", ",", "id", "=", "str", "(", "uuid", ".", "uuid4", "(", ")", ")", ",", "ttl", "=", "DEFAULT_TIMEOUT", ")", ":", "return", "Lock", "(", "id", ",", "ttl", "=", "ttl", ",", "client", "=", "self", ")" ]
Create a Lock object given an ID and timeout :param id: ID for the lock, creates a new uuid if not provided :param ttl: timeout :return: Lock object
[ "Create", "a", "Lock", "object", "given", "an", "ID", "and", "timeout" ]
python
train
36.75
pydanny/simplicity
simplicity.py
https://github.com/pydanny/simplicity/blob/aef4ce39b0965b8d333c67c9d6ec5baecee9c617/simplicity.py#L24-L28
def text_cleanup(data, key, last_type): """ I strip extra whitespace off multi-line strings if they are ready to be stripped!""" if key in data and last_type == STRING_TYPE: data[key] = data[key].strip() return data
[ "def", "text_cleanup", "(", "data", ",", "key", ",", "last_type", ")", ":", "if", "key", "in", "data", "and", "last_type", "==", "STRING_TYPE", ":", "data", "[", "key", "]", "=", "data", "[", "key", "]", ".", "strip", "(", ")", "return", "data" ]
I strip extra whitespace off multi-line strings if they are ready to be stripped!
[ "I", "strip", "extra", "whitespace", "off", "multi", "-", "line", "strings", "if", "they", "are", "ready", "to", "be", "stripped!" ]
python
train
46.2
tensorpack/tensorpack
tensorpack/predict/concurrency.py
https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/tensorpack/predict/concurrency.py#L110-L129
def fetch_batch(self): """ Fetch a batch of data without waiting""" inp, f = self.queue.get() nr_input_var = len(inp) batched, futures = [[] for _ in range(nr_input_var)], [] for k in range(nr_input_var): batched[k].append(inp[k]) futures.append(f) whi...
[ "def", "fetch_batch", "(", "self", ")", ":", "inp", ",", "f", "=", "self", ".", "queue", ".", "get", "(", ")", "nr_input_var", "=", "len", "(", "inp", ")", "batched", ",", "futures", "=", "[", "[", "]", "for", "_", "in", "range", "(", "nr_input_v...
Fetch a batch of data without waiting
[ "Fetch", "a", "batch", "of", "data", "without", "waiting" ]
python
train
35.8
googleapis/google-cloud-python
spanner/google/cloud/spanner_v1/transaction.py
https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/spanner/google/cloud/spanner_v1/transaction.py#L134-L163
def _make_params_pb(params, param_types): """Helper for :meth:`execute_update`. :type params: dict, {str -> column value} :param params: values for parameter replacement. Keys must match the names used in ``dml``. :type param_types: dict[str -> Union[dict, .type...
[ "def", "_make_params_pb", "(", "params", ",", "param_types", ")", ":", "if", "params", "is", "not", "None", ":", "if", "param_types", "is", "None", ":", "raise", "ValueError", "(", "\"Specify 'param_types' when passing 'params'.\"", ")", "return", "Struct", "(", ...
Helper for :meth:`execute_update`. :type params: dict, {str -> column value} :param params: values for parameter replacement. Keys must match the names used in ``dml``. :type param_types: dict[str -> Union[dict, .types.Type]] :param param_types: (Opt...
[ "Helper", "for", ":", "meth", ":", "execute_update", "." ]
python
train
39.7
dusktreader/flask-praetorian
flask_praetorian/base.py
https://github.com/dusktreader/flask-praetorian/blob/d530cf3ffeffd61bfff1b8c79e8b45e9bfa0db0c/flask_praetorian/base.py#L140-L165
def _validate_user_class(cls, user_class): """ Validates the supplied user_class to make sure that it has the class methods necessary to function correctly. Requirements: - ``lookup`` method. Accepts a string parameter, returns instance - ``identify`` method. Accepts an...
[ "def", "_validate_user_class", "(", "cls", ",", "user_class", ")", ":", "PraetorianError", ".", "require_condition", "(", "getattr", "(", "user_class", ",", "'lookup'", ",", "None", ")", "is", "not", "None", ",", "textwrap", ".", "dedent", "(", "\"\"\"\n ...
Validates the supplied user_class to make sure that it has the class methods necessary to function correctly. Requirements: - ``lookup`` method. Accepts a string parameter, returns instance - ``identify`` method. Accepts an identity parameter, returns instance
[ "Validates", "the", "supplied", "user_class", "to", "make", "sure", "that", "it", "has", "the", "class", "methods", "necessary", "to", "function", "correctly", "." ]
python
train
39.346154
dslackw/sun
sun/utils.py
https://github.com/dslackw/sun/blob/ff3501757ce1cc2f0db195f7a6b1d23f601dce32/sun/utils.py#L38-L49
def urlopen(link): """Return urllib2 urlopen """ try: return urllib2.urlopen(link) except urllib2.URLError: pass except ValueError: return "" except KeyboardInterrupt: print("") raise SystemExit()
[ "def", "urlopen", "(", "link", ")", ":", "try", ":", "return", "urllib2", ".", "urlopen", "(", "link", ")", "except", "urllib2", ".", "URLError", ":", "pass", "except", "ValueError", ":", "return", "\"\"", "except", "KeyboardInterrupt", ":", "print", "(", ...
Return urllib2 urlopen
[ "Return", "urllib2", "urlopen" ]
python
train
20.75
zsimic/runez
src/runez/config.py
https://github.com/zsimic/runez/blob/14363b719a1aae1528859a501a22d075ce0abfcc/src/runez/config.py#L62-L67
def set_providers(self, *providers): """Replace current providers with given ones""" if self.providers: self.clear() for provider in providers: self.add(provider)
[ "def", "set_providers", "(", "self", ",", "*", "providers", ")", ":", "if", "self", ".", "providers", ":", "self", ".", "clear", "(", ")", "for", "provider", "in", "providers", ":", "self", ".", "add", "(", "provider", ")" ]
Replace current providers with given ones
[ "Replace", "current", "providers", "with", "given", "ones" ]
python
train
34.166667
PyCQA/pylint
pylint/checkers/utils.py
https://github.com/PyCQA/pylint/blob/2bf5c61a3ff6ae90613b81679de42c0f19aea600/pylint/checkers/utils.py#L538-L568
def collect_string_fields(format_string) -> Iterable[Optional[str]]: """ Given a format string, return an iterator of all the valid format fields. It handles nested fields as well. """ formatter = string.Formatter() try: parseiterator = formatter.parse(format_string) for result i...
[ "def", "collect_string_fields", "(", "format_string", ")", "->", "Iterable", "[", "Optional", "[", "str", "]", "]", ":", "formatter", "=", "string", ".", "Formatter", "(", ")", "try", ":", "parseiterator", "=", "formatter", ".", "parse", "(", "format_string"...
Given a format string, return an iterator of all the valid format fields. It handles nested fields as well.
[ "Given", "a", "format", "string", "return", "an", "iterator", "of", "all", "the", "valid", "format", "fields", ".", "It", "handles", "nested", "fields", "as", "well", "." ]
python
test
40.903226
adafruit/Adafruit_Python_BluefruitLE
Adafruit_BluefruitLE/corebluetooth/provider.py
https://github.com/adafruit/Adafruit_Python_BluefruitLE/blob/34fc6f596371b961628369d78ce836950514062f/Adafruit_BluefruitLE/corebluetooth/provider.py#L245-L270
def run_mainloop_with(self, target): """Start the OS's main loop to process asyncronous BLE events and then run the specified target function in a background thread. Target function should be a function that takes no parameters and optionally return an integer response code. When the t...
[ "def", "run_mainloop_with", "(", "self", ",", "target", ")", ":", "# Create background thread to run user code.", "self", ".", "_user_thread", "=", "threading", ".", "Thread", "(", "target", "=", "self", ".", "_user_thread_main", ",", "args", "=", "(", "target", ...
Start the OS's main loop to process asyncronous BLE events and then run the specified target function in a background thread. Target function should be a function that takes no parameters and optionally return an integer response code. When the target function stops executing or return...
[ "Start", "the", "OS", "s", "main", "loop", "to", "process", "asyncronous", "BLE", "events", "and", "then", "run", "the", "specified", "target", "function", "in", "a", "background", "thread", ".", "Target", "function", "should", "be", "a", "function", "that",...
python
valid
52.769231
bitesofcode/projexui
projexui/widgets/xdropzonewidget.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xdropzonewidget.py#L131-L142
def currentRegion(self): """ Returns the current region based on the current cursor position. :return <XDropZoneWidget> """ pos = QtGui.QCursor.pos() pos = self.mapFromGlobal(pos) for region in self.regions(): if region.testHovere...
[ "def", "currentRegion", "(", "self", ")", ":", "pos", "=", "QtGui", ".", "QCursor", ".", "pos", "(", ")", "pos", "=", "self", ".", "mapFromGlobal", "(", "pos", ")", "for", "region", "in", "self", ".", "regions", "(", ")", ":", "if", "region", ".", ...
Returns the current region based on the current cursor position. :return <XDropZoneWidget>
[ "Returns", "the", "current", "region", "based", "on", "the", "current", "cursor", "position", ".", ":", "return", "<XDropZoneWidget", ">" ]
python
train
30.666667
bcoe/secure-smtpd
secure_smtpd/smtp_channel.py
https://github.com/bcoe/secure-smtpd/blob/f3f76e72c7d610759097921405e88782a19129fe/secure_smtpd/smtp_channel.py#L13-L17
def decode_b64(data): '''Wrapper for b64decode, without having to struggle with bytestrings.''' byte_string = data.encode('utf-8') decoded = base64.b64decode(byte_string) return decoded.decode('utf-8')
[ "def", "decode_b64", "(", "data", ")", ":", "byte_string", "=", "data", ".", "encode", "(", "'utf-8'", ")", "decoded", "=", "base64", ".", "b64decode", "(", "byte_string", ")", "return", "decoded", ".", "decode", "(", "'utf-8'", ")" ]
Wrapper for b64decode, without having to struggle with bytestrings.
[ "Wrapper", "for", "b64decode", "without", "having", "to", "struggle", "with", "bytestrings", "." ]
python
train
42.6
UCL-INGI/INGInious
inginious/frontend/pages/course_admin/settings.py
https://github.com/UCL-INGI/INGInious/blob/cbda9a9c7f2b8e8eb1e6d7d51f0d18092086300c/inginious/frontend/pages/course_admin/settings.py#L22-L103
def POST_AUTH(self, courseid): # pylint: disable=arguments-differ """ POST request """ course, __ = self.get_course_and_check_rights(courseid, allow_all_staff=False) errors = [] course_content = {} try: data = web.input() course_content = self.course_fac...
[ "def", "POST_AUTH", "(", "self", ",", "courseid", ")", ":", "# pylint: disable=arguments-differ", "course", ",", "__", "=", "self", ".", "get_course_and_check_rights", "(", "courseid", ",", "allow_all_staff", "=", "False", ")", "errors", "=", "[", "]", "course_c...
POST request
[ "POST", "request" ]
python
train
51.426829
rosenbrockc/fortpy
fortpy/templates/genf90.py
https://github.com/rosenbrockc/fortpy/blob/1ed0757c52d549e41d9d44bdea68cb89529293a5/fortpy/templates/genf90.py#L366-L388
def fpy_interface(fpy, static, interface, typedict): """Splices the full list of subroutines and the module procedure list into the static.f90 file. :arg static: the string contents of the static.f90 file. :arg interface: the name of the interface *field* being replaced. :arg typedict: the dictiona...
[ "def", "fpy_interface", "(", "fpy", ",", "static", ",", "interface", ",", "typedict", ")", ":", "modprocs", "=", "[", "]", "subtext", "=", "[", "]", "for", "dtype", ",", "combos", "in", "list", "(", "typedict", ".", "items", "(", ")", ")", ":", "fo...
Splices the full list of subroutines and the module procedure list into the static.f90 file. :arg static: the string contents of the static.f90 file. :arg interface: the name of the interface *field* being replaced. :arg typedict: the dictionary of dtypes and their kind and suffix combos.
[ "Splices", "the", "full", "list", "of", "subroutines", "and", "the", "module", "procedure", "list", "into", "the", "static", ".", "f90", "file", "." ]
python
train
43.478261