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
Azure/azure-sdk-for-python
azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py
https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicemanagement-legacy/azure/servicemanagement/_http/winhttp.py#L265-L277
def open(self, method, url): ''' Opens the request. method: the request VERB 'GET', 'POST', etc. url: the url to connect ''' flag = VARIANT.create_bool_false() _method = BSTR(method) _url = BSTR(url) _WinHttpRequest._Open(s...
[ "def", "open", "(", "self", ",", "method", ",", "url", ")", ":", "flag", "=", "VARIANT", ".", "create_bool_false", "(", ")", "_method", "=", "BSTR", "(", "method", ")", "_url", "=", "BSTR", "(", "url", ")", "_WinHttpRequest", ".", "_Open", "(", "self...
Opens the request. method: the request VERB 'GET', 'POST', etc. url: the url to connect
[ "Opens", "the", "request", "." ]
python
test
25.615385
lmjohns3/theanets
theanets/trainer.py
https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/trainer.py#L28-L64
def itertrain(self, train, valid=None, **kwargs): '''Train a model using a training and validation set. This method yields a series of monitor values to the caller. After every iteration, a pair of monitor dictionaries is generated: one evaluated on the training dataset, and another eva...
[ "def", "itertrain", "(", "self", ",", "train", ",", "valid", "=", "None", ",", "*", "*", "kwargs", ")", ":", "for", "monitors", "in", "downhill", ".", "build", "(", "algo", "=", "self", ".", "algo", ",", "loss", "=", "self", ".", "network", ".", ...
Train a model using a training and validation set. This method yields a series of monitor values to the caller. After every iteration, a pair of monitor dictionaries is generated: one evaluated on the training dataset, and another evaluated on the validation dataset. The validation moni...
[ "Train", "a", "model", "using", "a", "training", "and", "validation", "set", "." ]
python
test
44.918919
BerkeleyAutomation/autolab_core
autolab_core/transformations.py
https://github.com/BerkeleyAutomation/autolab_core/blob/8f3813f6401972868cc5e3981ba1b4382d4418d5/autolab_core/transformations.py#L359-L393
def scale_matrix(factor, origin=None, direction=None): """Return matrix to scale by factor around origin in direction. Use factor -1 for point symmetry. >>> v = (numpy.random.rand(4, 5) - 0.5) * 20.0 >>> v[3] = 1.0 >>> S = scale_matrix(-1.234) >>> numpy.allclose(numpy.dot(S, v)[:3], -1.234*v[:...
[ "def", "scale_matrix", "(", "factor", ",", "origin", "=", "None", ",", "direction", "=", "None", ")", ":", "if", "direction", "is", "None", ":", "# uniform scaling", "M", "=", "numpy", ".", "array", "(", "(", "(", "factor", ",", "0.0", ",", "0.0", ",...
Return matrix to scale by factor around origin in direction. Use factor -1 for point symmetry. >>> v = (numpy.random.rand(4, 5) - 0.5) * 20.0 >>> v[3] = 1.0 >>> S = scale_matrix(-1.234) >>> numpy.allclose(numpy.dot(S, v)[:3], -1.234*v[:3]) True >>> factor = random.random() * 10 - 5 >>>...
[ "Return", "matrix", "to", "scale", "by", "factor", "around", "origin", "in", "direction", "." ]
python
train
36.114286
SpotlightData/preprocessing
preprocessing/text.py
https://github.com/SpotlightData/preprocessing/blob/180c6472bc2642afbd7a1ece08d0b0d14968a708/preprocessing/text.py#L332-L349
def remove_whitespace(text_string): ''' Removes all whitespace found within text_string and returns new string as type str. Keyword argument: - text_string: string instance Exceptions raised: - InputError: occurs should a string or NoneType not be passed as an argument ''' if text_st...
[ "def", "remove_whitespace", "(", "text_string", ")", ":", "if", "text_string", "is", "None", "or", "text_string", "==", "\"\"", ":", "return", "\"\"", "elif", "isinstance", "(", "text_string", ",", "str", ")", ":", "return", "\" \"", ".", "join", "(", "tex...
Removes all whitespace found within text_string and returns new string as type str. Keyword argument: - text_string: string instance Exceptions raised: - InputError: occurs should a string or NoneType not be passed as an argument
[ "Removes", "all", "whitespace", "found", "within", "text_string", "and", "returns", "new", "string", "as", "type", "str", "." ]
python
train
29.055556
sdispater/orator
orator/schema/mysql_builder.py
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/schema/mysql_builder.py#L22-L43
def get_column_listing(self, table): """ Get the column listing for a given table. :param table: The table :type table: str :rtype: list """ sql = self._grammar.compile_column_exists() database = self._connection.get_database_name() table = self....
[ "def", "get_column_listing", "(", "self", ",", "table", ")", ":", "sql", "=", "self", ".", "_grammar", ".", "compile_column_exists", "(", ")", "database", "=", "self", ".", "_connection", ".", "get_database_name", "(", ")", "table", "=", "self", ".", "_con...
Get the column listing for a given table. :param table: The table :type table: str :rtype: list
[ "Get", "the", "column", "listing", "for", "a", "given", "table", "." ]
python
train
30.818182
choderalab/pymbar
pymbar/mbar.py
https://github.com/choderalab/pymbar/blob/69d1f0ff680e9ac1c6a51a5a207ea28f3ed86740/pymbar/mbar.py#L1523-L1544
def _ErrorOfDifferences(self, cov, warning_cutoff=1.0e-10): """ inputs: cov is the covariance matrix of A returns the statistical error matrix of A_i - A_j """ diag = np.matrix(cov.diagonal()) d2 = diag + diag.transpose() - 2 * cov # Cast warning_cutoff...
[ "def", "_ErrorOfDifferences", "(", "self", ",", "cov", ",", "warning_cutoff", "=", "1.0e-10", ")", ":", "diag", "=", "np", ".", "matrix", "(", "cov", ".", "diagonal", "(", ")", ")", "d2", "=", "diag", "+", "diag", ".", "transpose", "(", ")", "-", "...
inputs: cov is the covariance matrix of A returns the statistical error matrix of A_i - A_j
[ "inputs", ":", "cov", "is", "the", "covariance", "matrix", "of", "A" ]
python
train
33.5
pydata/xarray
xarray/core/dataset.py
https://github.com/pydata/xarray/blob/6d93a95d05bdbfc33fff24064f67d29dd891ab58/xarray/core/dataset.py#L3784-L3849
def roll(self, shifts=None, roll_coords=None, **shifts_kwargs): """Roll this dataset by an offset along one or more dimensions. Unlike shift, roll may rotate all variables, including coordinates if specified. The direction of rotation is consistent with :py:func:`numpy.roll`. P...
[ "def", "roll", "(", "self", ",", "shifts", "=", "None", ",", "roll_coords", "=", "None", ",", "*", "*", "shifts_kwargs", ")", ":", "shifts", "=", "either_dict_or_kwargs", "(", "shifts", ",", "shifts_kwargs", ",", "'roll'", ")", "invalid", "=", "[", "k", ...
Roll this dataset by an offset along one or more dimensions. Unlike shift, roll may rotate all variables, including coordinates if specified. The direction of rotation is consistent with :py:func:`numpy.roll`. Parameters ---------- shifts : dict, optional A...
[ "Roll", "this", "dataset", "by", "an", "offset", "along", "one", "or", "more", "dimensions", "." ]
python
train
36.893939
shoebot/shoebot
shoebot/grammar/grammar.py
https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/grammar.py#L85-L97
def _frame_limit(self, start_time): """ Limit to framerate, should be called after rendering has completed :param start_time: When execution started """ if self._speed: completion_time = time() exc_time = completion_time - start_time s...
[ "def", "_frame_limit", "(", "self", ",", "start_time", ")", ":", "if", "self", ".", "_speed", ":", "completion_time", "=", "time", "(", ")", "exc_time", "=", "completion_time", "-", "start_time", "sleep_for", "=", "(", "1.0", "/", "abs", "(", "self", "."...
Limit to framerate, should be called after rendering has completed :param start_time: When execution started
[ "Limit", "to", "framerate", "should", "be", "called", "after", "rendering", "has", "completed" ]
python
valid
32.076923
saltstack/salt
salt/modules/hg.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/hg.py#L204-L236
def update(cwd, rev, force=False, user=None): ''' Update to a given revision cwd The path to the Mercurial repository rev The revision to update to force : False Force an update user : None Run hg as a user other than what the minion runs as CLI Example: ...
[ "def", "update", "(", "cwd", ",", "rev", ",", "force", "=", "False", ",", "user", "=", "None", ")", ":", "cmd", "=", "[", "'hg'", ",", "'update'", ",", "'{0}'", ".", "format", "(", "rev", ")", "]", "if", "force", ":", "cmd", ".", "append", "(",...
Update to a given revision cwd The path to the Mercurial repository rev The revision to update to force : False Force an update user : None Run hg as a user other than what the minion runs as CLI Example: .. code-block:: bash salt devserver1 hg.upda...
[ "Update", "to", "a", "given", "revision" ]
python
train
22
stoneworksolutions/stoneredis
stoneredis/client.py
https://github.com/stoneworksolutions/stoneredis/blob/46018b81317c152bd47c0764c3f1293379618af4/stoneredis/client.py#L130-L142
def multi_rpush(self, queue, values, bulk_size=0, transaction=False): ''' Pushes multiple elements to a list If bulk_size is set it will execute the pipeline every bulk_size elements This operation will be atomic if transaction=True is passed ''' # Check that what we...
[ "def", "multi_rpush", "(", "self", ",", "queue", ",", "values", ",", "bulk_size", "=", "0", ",", "transaction", "=", "False", ")", ":", "# Check that what we receive is iterable\r", "if", "hasattr", "(", "values", ",", "'__iter__'", ")", ":", "pipe", "=", "s...
Pushes multiple elements to a list If bulk_size is set it will execute the pipeline every bulk_size elements This operation will be atomic if transaction=True is passed
[ "Pushes", "multiple", "elements", "to", "a", "list", "If", "bulk_size", "is", "set", "it", "will", "execute", "the", "pipeline", "every", "bulk_size", "elements", "This", "operation", "will", "be", "atomic", "if", "transaction", "=", "True", "is", "passed" ]
python
train
47.923077
Gandi/gandi.cli
gandi/cli/commands/vm.py
https://github.com/Gandi/gandi.cli/blob/6ee5b8fc8ec44b0a6c232043ca610606ad8f693d/gandi/cli/commands/vm.py#L525-L544
def migrate(gandi, resource, force, background, finalize): """ Migrate a virtual machine to another datacenter. """ if not gandi.iaas.check_can_migrate(resource): return if not force: proceed = click.confirm('Are you sure you want to migrate VM %s ?' % resour...
[ "def", "migrate", "(", "gandi", ",", "resource", ",", "force", ",", "background", ",", "finalize", ")", ":", "if", "not", "gandi", ".", "iaas", ".", "check_can_migrate", "(", "resource", ")", ":", "return", "if", "not", "force", ":", "proceed", "=", "c...
Migrate a virtual machine to another datacenter.
[ "Migrate", "a", "virtual", "machine", "to", "another", "datacenter", "." ]
python
train
30.3
p3trus/slave
slave/lakeshore/ls340.py
https://github.com/p3trus/slave/blob/bdc74e73bd0f47b74a090c43aa2283c469cde3be/slave/lakeshore/ls340.py#L419-L426
def line(self, idx): """Return the i'th program line. :param i: The i'th program line. """ # TODO: We should parse the response properly. return self._query(('PGM?', [Integer, Integer], String), self.idx, idx)
[ "def", "line", "(", "self", ",", "idx", ")", ":", "# TODO: We should parse the response properly.", "return", "self", ".", "_query", "(", "(", "'PGM?'", ",", "[", "Integer", ",", "Integer", "]", ",", "String", ")", ",", "self", ".", "idx", ",", "idx", ")...
Return the i'th program line. :param i: The i'th program line.
[ "Return", "the", "i", "th", "program", "line", "." ]
python
train
30.5
ValvePython/vpk
vpk/__init__.py
https://github.com/ValvePython/vpk/blob/cc522fc7febbf53efa5d58fcd1ad2103dae37ac8/vpk/__init__.py#L43-L76
def read_dir(self, path): """ Reads the given path into the tree """ self.tree = {} self.file_count = 0 self.path = path for root, _, filelist in os.walk(path): rel = root[len(path):].lstrip('/\\') # empty rel, means file is in root dir ...
[ "def", "read_dir", "(", "self", ",", "path", ")", ":", "self", ".", "tree", "=", "{", "}", "self", ".", "file_count", "=", "0", "self", ".", "path", "=", "path", "for", "root", ",", "_", ",", "filelist", "in", "os", ".", "walk", "(", "path", ")...
Reads the given path into the tree
[ "Reads", "the", "given", "path", "into", "the", "tree" ]
python
train
32.176471
pywbem/pywbem
try/run_central_instances.py
https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/try/run_central_instances.py#L488-L505
def get_associated_profiles(profile_path, result_role, server): """ Get the associated CIM_ReferencedProfile (i.e. the Reference) for the profile defined by profile_path. This allows the ResultRolefor the association to be set as part of the call to either "Dependent" or "Antecedent". """ a...
[ "def", "get_associated_profiles", "(", "profile_path", ",", "result_role", ",", "server", ")", ":", "associated_profiles", "=", "server", ".", "conn", ".", "Associators", "(", "ObjectName", "=", "profile_path", ",", "AssocClass", "=", "\"CIM_ReferencedProfile\"", ",...
Get the associated CIM_ReferencedProfile (i.e. the Reference) for the profile defined by profile_path. This allows the ResultRolefor the association to be set as part of the call to either "Dependent" or "Antecedent".
[ "Get", "the", "associated", "CIM_ReferencedProfile", "(", "i", ".", "e", ".", "the", "Reference", ")", "for", "the", "profile", "defined", "by", "profile_path", ".", "This", "allows", "the", "ResultRolefor", "the", "association", "to", "be", "set", "as", "pa...
python
train
44.555556
atztogo/phonopy
phonopy/phonon/group_velocity.py
https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/phonon/group_velocity.py#L44-L64
def get_group_velocity(q, # q-point dynamical_matrix, q_length=None, # finite distance in q symmetry=None, frequency_factor_to_THz=VaspToTHz): """ If frequencies and eigenvectors are supplied they are used instead ...
[ "def", "get_group_velocity", "(", "q", ",", "# q-point", "dynamical_matrix", ",", "q_length", "=", "None", ",", "# finite distance in q", "symmetry", "=", "None", ",", "frequency_factor_to_THz", "=", "VaspToTHz", ")", ":", "gv", "=", "GroupVelocity", "(", "dynamic...
If frequencies and eigenvectors are supplied they are used instead of calculating them at q-point (but not at q+dq and q-dq). reciprocal lattice has to be given as [[a_x, b_x, c_x], [a_y, b_y, c_y], [a_z, b_z, c_z]]
[ "If", "frequencies", "and", "eigenvectors", "are", "supplied", "they", "are", "used", "instead", "of", "calculating", "them", "at", "q", "-", "point", "(", "but", "not", "at", "q", "+", "dq", "and", "q", "-", "dq", ")", "." ]
python
train
35.047619
pandas-dev/pandas
pandas/core/frame.py
https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/frame.py#L5410-L5558
def update(self, other, join='left', overwrite=True, filter_func=None, errors='ignore'): """ Modify in place using non-NA values from another DataFrame. Aligns on indices. There is no return value. Parameters ---------- other : DataFrame, or object coerci...
[ "def", "update", "(", "self", ",", "other", ",", "join", "=", "'left'", ",", "overwrite", "=", "True", ",", "filter_func", "=", "None", ",", "errors", "=", "'ignore'", ")", ":", "import", "pandas", ".", "core", ".", "computation", ".", "expressions", "...
Modify in place using non-NA values from another DataFrame. Aligns on indices. There is no return value. Parameters ---------- other : DataFrame, or object coercible into a DataFrame Should have at least one matching index/column label with the original DataFram...
[ "Modify", "in", "place", "using", "non", "-", "NA", "values", "from", "another", "DataFrame", "." ]
python
train
33.791946
j3ffhubb/pymarshal
pymarshal/api_docs/routes.py
https://github.com/j3ffhubb/pymarshal/blob/42cd1cccfabfdce5af633358a641fcd5183ee192/pymarshal/api_docs/routes.py#L178-L229
def factory( method, description="", request_example=None, request_ctor=None, responses=None, method_choices=HTTP_METHODS, ): """ desc: Describes a single HTTP method of a URI args: - name: method type: str ...
[ "def", "factory", "(", "method", ",", "description", "=", "\"\"", ",", "request_example", "=", "None", ",", "request_ctor", "=", "None", ",", "responses", "=", "None", ",", "method_choices", "=", "HTTP_METHODS", ",", ")", ":", "return", "RouteMethod", "(", ...
desc: Describes a single HTTP method of a URI args: - name: method type: str desc: The HTTP request method to use - name: description type: str desc: The description of what this call does required: false...
[ "desc", ":", "Describes", "a", "single", "HTTP", "method", "of", "a", "URI", "args", ":", "-", "name", ":", "method", "type", ":", "str", "desc", ":", "The", "HTTP", "request", "method", "to", "use", "-", "name", ":", "description", "type", ":", "str...
python
train
33.423077
ARMmbed/mbed-cloud-sdk-python
src/mbed_cloud/pagination.py
https://github.com/ARMmbed/mbed-cloud-sdk-python/blob/c0af86fb2cdd4dc7ed26f236139241067d293509/src/mbed_cloud/pagination.py#L137-L146
def first(self): """Returns the first item from the query, or None if there are no results""" if self._results_cache: return self._results_cache[0] query = PaginatedResponse(func=self._func, lwrap_type=self._lwrap_type, **self._kwargs) try: return next(query) ...
[ "def", "first", "(", "self", ")", ":", "if", "self", ".", "_results_cache", ":", "return", "self", ".", "_results_cache", "[", "0", "]", "query", "=", "PaginatedResponse", "(", "func", "=", "self", ".", "_func", ",", "lwrap_type", "=", "self", ".", "_l...
Returns the first item from the query, or None if there are no results
[ "Returns", "the", "first", "item", "from", "the", "query", "or", "None", "if", "there", "are", "no", "results" ]
python
train
36.1
aio-libs/aioredis
examples/scan.py
https://github.com/aio-libs/aioredis/blob/e8c33e39558d4cc91cf70dde490d8b330c97dc2e/examples/scan.py#L5-L17
async def main(): """Scan command example.""" redis = await aioredis.create_redis( 'redis://localhost') await redis.mset('key:1', 'value1', 'key:2', 'value2') cur = b'0' # set initial cursor to 0 while cur: cur, keys = await redis.scan(cur, match='key:*') print("Iteration r...
[ "async", "def", "main", "(", ")", ":", "redis", "=", "await", "aioredis", ".", "create_redis", "(", "'redis://localhost'", ")", "await", "redis", ".", "mset", "(", "'key:1'", ",", "'value1'", ",", "'key:2'", ",", "'value2'", ")", "cur", "=", "b'0'", "# s...
Scan command example.
[ "Scan", "command", "example", "." ]
python
train
28.615385
Karaage-Cluster/karaage
karaage/common/trace.py
https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/common/trace.py#L470-L673
def trace(_name): """Function decorator that logs function entry and exit details. \var{_name} a string, an instance of logging.Logger or a function. Construct a function or method proxy to generate call traces. """ def decorator(_func): """This is the actual decorator function that wraps ...
[ "def", "trace", "(", "_name", ")", ":", "def", "decorator", "(", "_func", ")", ":", "\"\"\"This is the actual decorator function that wraps the\n \\var{_func} function for detailed logging.\n \"\"\"", "def", "positional", "(", "name", ",", "value", ")", ":", "...
Function decorator that logs function entry and exit details. \var{_name} a string, an instance of logging.Logger or a function. Construct a function or method proxy to generate call traces.
[ "Function", "decorator", "that", "logs", "function", "entry", "and", "exit", "details", "." ]
python
train
33.642157
Parsl/parsl
parsl/monitoring/db_manager.py
https://github.com/Parsl/parsl/blob/d7afb3bc37f50dcf224ae78637944172edb35dac/parsl/monitoring/db_manager.py#L405-L412
def dbm_starter(priority_msgs, resource_msgs, *args, **kwargs): """Start the database manager process The DFK should start this function. The args, kwargs match that of the monitoring config """ dbm = DatabaseManager(*args, **kwargs) dbm.start(priority_msgs, resource_msgs)
[ "def", "dbm_starter", "(", "priority_msgs", ",", "resource_msgs", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "dbm", "=", "DatabaseManager", "(", "*", "args", ",", "*", "*", "kwargs", ")", "dbm", ".", "start", "(", "priority_msgs", ",", "resou...
Start the database manager process The DFK should start this function. The args, kwargs match that of the monitoring config
[ "Start", "the", "database", "manager", "process" ]
python
valid
36
spyder-ide/spyder
spyder/config/utils.py
https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/config/utils.py#L176-L189
def is_gtk_desktop(): """Detect if we are running in a Gtk-based desktop""" if sys.platform.startswith('linux'): xdg_desktop = os.environ.get('XDG_CURRENT_DESKTOP', '') if xdg_desktop: gtk_desktops = ['Unity', 'GNOME', 'XFCE'] if any([xdg_desktop.startswith(d) for d in gt...
[ "def", "is_gtk_desktop", "(", ")", ":", "if", "sys", ".", "platform", ".", "startswith", "(", "'linux'", ")", ":", "xdg_desktop", "=", "os", ".", "environ", ".", "get", "(", "'XDG_CURRENT_DESKTOP'", ",", "''", ")", "if", "xdg_desktop", ":", "gtk_desktops",...
Detect if we are running in a Gtk-based desktop
[ "Detect", "if", "we", "are", "running", "in", "a", "Gtk", "-", "based", "desktop" ]
python
train
33.214286
apache/incubator-mxnet
example/speech_recognition/stt_datagenerator.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/speech_recognition/stt_datagenerator.py#L172-L216
def prepare_minibatch(self, audio_paths, texts, overwrite=False, is_bi_graphemes=False, seq_length=-1, save_feature_as_csvfile=False): """ Featurize a minibatch of audio, zero pad them and return a dictionary Params: audio_paths (list(str)): List of paths to audio f...
[ "def", "prepare_minibatch", "(", "self", ",", "audio_paths", ",", "texts", ",", "overwrite", "=", "False", ",", "is_bi_graphemes", "=", "False", ",", "seq_length", "=", "-", "1", ",", "save_feature_as_csvfile", "=", "False", ")", ":", "assert", "len", "(", ...
Featurize a minibatch of audio, zero pad them and return a dictionary Params: audio_paths (list(str)): List of paths to audio files texts (list(str)): List of texts corresponding to the audio files Returns: dict: See below for contents
[ "Featurize", "a", "minibatch", "of", "audio", "zero", "pad", "them", "and", "return", "a", "dictionary", "Params", ":", "audio_paths", "(", "list", "(", "str", "))", ":", "List", "of", "paths", "to", "audio", "files", "texts", "(", "list", "(", "str", ...
python
train
51.022222
tensorflow/tensorboard
tensorboard/plugins/distribution/compressor.py
https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/plugins/distribution/compressor.py#L141-L143
def _lerp(x, x0, x1, y0, y1): """Affinely map from [x0, x1] onto [y0, y1].""" return y0 + (x - x0) * float(y1 - y0) / (x1 - x0)
[ "def", "_lerp", "(", "x", ",", "x0", ",", "x1", ",", "y0", ",", "y1", ")", ":", "return", "y0", "+", "(", "x", "-", "x0", ")", "*", "float", "(", "y1", "-", "y0", ")", "/", "(", "x1", "-", "x0", ")" ]
Affinely map from [x0, x1] onto [y0, y1].
[ "Affinely", "map", "from", "[", "x0", "x1", "]", "onto", "[", "y0", "y1", "]", "." ]
python
train
43
santosjorge/cufflinks
cufflinks/datagen.py
https://github.com/santosjorge/cufflinks/blob/ca1cbf93998dc793d0b1f8ac30fe1f2bd105f63a/cufflinks/datagen.py#L131-L155
def scatter(n_categories=5,n=10,prefix='category',mode=None): """ Returns a DataFrame with the required format for a scatter plot Parameters: ----------- n_categories : int Number of categories n : int Number of points for each category prefix : string Name for each category mode : string Fo...
[ "def", "scatter", "(", "n_categories", "=", "5", ",", "n", "=", "10", ",", "prefix", "=", "'category'", ",", "mode", "=", "None", ")", ":", "categories", "=", "[", "]", "for", "i", "in", "range", "(", "n_categories", ")", ":", "categories", ".", "e...
Returns a DataFrame with the required format for a scatter plot Parameters: ----------- n_categories : int Number of categories n : int Number of points for each category prefix : string Name for each category mode : string Format for each item 'abc' for alphabet columns 'stocks' for r...
[ "Returns", "a", "DataFrame", "with", "the", "required", "format", "for", "a", "scatter", "plot" ]
python
train
26.36
salsita/flask-raml
setup.py
https://github.com/salsita/flask-raml/blob/9876f19d49401fa32f7d852239aa295a78149ab2/setup.py#L86-L141
def init( dist='dist', minver=None, maxver=None, use_markdown_readme=True, use_stdeb=False, use_distribute=False, ): """Imports and returns a setup function. If use_markdown_readme is set, then README.md is added to setuptools READMES list. If use_stdeb is set on a Debian b...
[ "def", "init", "(", "dist", "=", "'dist'", ",", "minver", "=", "None", ",", "maxver", "=", "None", ",", "use_markdown_readme", "=", "True", ",", "use_stdeb", "=", "False", ",", "use_distribute", "=", "False", ",", ")", ":", "if", "not", "minver", "==",...
Imports and returns a setup function. If use_markdown_readme is set, then README.md is added to setuptools READMES list. If use_stdeb is set on a Debian based system, then module stdeb is imported. Stdeb supports building deb packages on Debian based systems. The package should only be install...
[ "Imports", "and", "returns", "a", "setup", "function", "." ]
python
test
29.892857
Unity-Technologies/ml-agents
ml-agents/mlagents/trainers/barracuda.py
https://github.com/Unity-Technologies/ml-agents/blob/37d139af636e4a2351751fbf0f2fca5a9ed7457f/ml-agents/mlagents/trainers/barracuda.py#L320-L345
def gru(name, input, state, kernel_r, kernel_u, kernel_c, bias_r, bias_u, bias_c, new_state, number_of_gates = 2): ''' - zt = f(Xt*Wz + Ht_1*Rz + Wbz + Rbz) - rt = f(Xt*Wr + Ht_1*Rr + Wbr + Rbr) - ht = g(Xt*Wh + (rt . Ht_1)*Rh + Rbh + Wbh) - Ht = (1-zt).ht + zt.Ht_1 ''' ...
[ "def", "gru", "(", "name", ",", "input", ",", "state", ",", "kernel_r", ",", "kernel_u", ",", "kernel_c", ",", "bias_r", ",", "bias_u", ",", "bias_c", ",", "new_state", ",", "number_of_gates", "=", "2", ")", ":", "nn", "=", "Build", "(", "name", ")",...
- zt = f(Xt*Wz + Ht_1*Rz + Wbz + Rbz) - rt = f(Xt*Wr + Ht_1*Rr + Wbr + Rbr) - ht = g(Xt*Wh + (rt . Ht_1)*Rh + Rbh + Wbh) - Ht = (1-zt).ht + zt.Ht_1
[ "-", "zt", "=", "f", "(", "Xt", "*", "Wz", "+", "Ht_1", "*", "Rz", "+", "Wbz", "+", "Rbz", ")", "-", "rt", "=", "f", "(", "Xt", "*", "Wr", "+", "Ht_1", "*", "Rr", "+", "Wbr", "+", "Rbr", ")", "-", "ht", "=", "g", "(", "Xt", "*", "Wh",...
python
train
31.115385
saltstack/salt
salt/cloud/clouds/azurearm.py
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/azurearm.py#L701-L733
def _get_network_interface(name, resource_group): ''' Get a network interface. ''' public_ips = [] private_ips = [] netapi_versions = get_api_versions(kwargs={ 'resource_provider': 'Microsoft.Network', 'resource_type': 'publicIPAddresses' } ) netapi_version = neta...
[ "def", "_get_network_interface", "(", "name", ",", "resource_group", ")", ":", "public_ips", "=", "[", "]", "private_ips", "=", "[", "]", "netapi_versions", "=", "get_api_versions", "(", "kwargs", "=", "{", "'resource_provider'", ":", "'Microsoft.Network'", ",", ...
Get a network interface.
[ "Get", "a", "network", "interface", "." ]
python
train
36.757576
Capitains/Nautilus
capitains_nautilus/flask_ext.py
https://github.com/Capitains/Nautilus/blob/6be453fe0cc0e2c1b89ff06e5af1409165fc1411/capitains_nautilus/flask_ext.py#L185-L212
def view(self, function_name, extension_name): """ Builds response according to a function name :param function_name: Route name / function name :param extension_name: Name of the extension holding the function :return: Function """ if isinstance(self.Access_Control_Allo...
[ "def", "view", "(", "self", ",", "function_name", ",", "extension_name", ")", ":", "if", "isinstance", "(", "self", ".", "Access_Control_Allow_Origin", ",", "dict", ")", ":", "d", "=", "{", "\"Access-Control-Allow-Origin\"", ":", "self", ".", "Access_Control_All...
Builds response according to a function name :param function_name: Route name / function name :param extension_name: Name of the extension holding the function :return: Function
[ "Builds", "response", "according", "to", "a", "function", "name" ]
python
train
39.571429
xzased/lvm2py
lvm2py/vg.py
https://github.com/xzased/lvm2py/blob/34ce69304531a474c2fe4a4009ca445a8c103cd6/lvm2py/vg.py#L177-L184
def max_lv_count(self): """ Returns the maximum allowed logical volume count. """ self.open() count = lvm_vg_get_max_lv(self.handle) self.close() return count
[ "def", "max_lv_count", "(", "self", ")", ":", "self", ".", "open", "(", ")", "count", "=", "lvm_vg_get_max_lv", "(", "self", ".", "handle", ")", "self", ".", "close", "(", ")", "return", "count" ]
Returns the maximum allowed logical volume count.
[ "Returns", "the", "maximum", "allowed", "logical", "volume", "count", "." ]
python
train
25.875
minhhoit/yacms
yacms/utils/urls.py
https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/urls.py#L125-L136
def path_to_slug(path): """ Removes everything from the given URL path, including language code and ``PAGES_SLUG`` if any is set, returning a slug that would match a ``Page`` instance's slug. """ from yacms.urls import PAGES_SLUG lang_code = translation.get_language_from_path(path) for p...
[ "def", "path_to_slug", "(", "path", ")", ":", "from", "yacms", ".", "urls", "import", "PAGES_SLUG", "lang_code", "=", "translation", ".", "get_language_from_path", "(", "path", ")", "for", "prefix", "in", "(", "lang_code", ",", "settings", ".", "SITE_PREFIX", ...
Removes everything from the given URL path, including language code and ``PAGES_SLUG`` if any is set, returning a slug that would match a ``Page`` instance's slug.
[ "Removes", "everything", "from", "the", "given", "URL", "path", "including", "language", "code", "and", "PAGES_SLUG", "if", "any", "is", "set", "returning", "a", "slug", "that", "would", "match", "a", "Page", "instance", "s", "slug", "." ]
python
train
39
aichaos/rivescript-python
rivescript/rivescript.py
https://github.com/aichaos/rivescript-python/blob/b55c820cf02a194605fd66af1f070e239f84ed31/rivescript/rivescript.py#L561-L593
def set_handler(self, language, obj): """Define a custom language handler for RiveScript objects. Pass in a ``None`` value for the object to delete an existing handler (for example, to prevent Python code from being able to be run by default). Look in the ``eg`` folder of the rivescrip...
[ "def", "set_handler", "(", "self", ",", "language", ",", "obj", ")", ":", "# Allow them to delete a handler too.", "if", "obj", "is", "None", ":", "if", "language", "in", "self", ".", "_handlers", ":", "del", "self", ".", "_handlers", "[", "language", "]", ...
Define a custom language handler for RiveScript objects. Pass in a ``None`` value for the object to delete an existing handler (for example, to prevent Python code from being able to be run by default). Look in the ``eg`` folder of the rivescript-python distribution for an example scri...
[ "Define", "a", "custom", "language", "handler", "for", "RiveScript", "objects", "." ]
python
train
44.878788
TeamHG-Memex/eli5
eli5/formatters/as_dataframe.py
https://github.com/TeamHG-Memex/eli5/blob/371b402a0676295c05e582a2dd591f7af476b86b/eli5/formatters/as_dataframe.py#L72-L89
def format_as_dataframes(explanation): # type: (Explanation) -> Dict[str, pd.DataFrame] """ Export an explanation to a dictionary with ``pandas.DataFrame`` values and string keys that correspond to explanation attributes. Use this method if several dataframes can be exported from a single explanatio...
[ "def", "format_as_dataframes", "(", "explanation", ")", ":", "# type: (Explanation) -> Dict[str, pd.DataFrame]", "result", "=", "{", "}", "for", "attr", "in", "_EXPORTED_ATTRIBUTES", ":", "value", "=", "getattr", "(", "explanation", ",", "attr", ")", "if", "value", ...
Export an explanation to a dictionary with ``pandas.DataFrame`` values and string keys that correspond to explanation attributes. Use this method if several dataframes can be exported from a single explanation (e.g. for CRF explanation with has both feature weights and transition matrix). Note that ...
[ "Export", "an", "explanation", "to", "a", "dictionary", "with", "pandas", ".", "DataFrame", "values", "and", "string", "keys", "that", "correspond", "to", "explanation", "attributes", ".", "Use", "this", "method", "if", "several", "dataframes", "can", "be", "e...
python
train
43.833333
Shapeways/coyote_framework
coyote_framework/util/apps/polling/polling.py
https://github.com/Shapeways/coyote_framework/blob/cb29899b984a21d56bf65d0b1d907073948fe16c/coyote_framework/util/apps/polling/polling.py#L6-L50
def poll(function, step=0.5, timeout=3, ignore_exceptions=(), exception_message='', message_builder=None, args=(), kwargs=None, ontimeout=()): """Calls the function until bool(return value) is truthy @param step: Wait time between each function call @param timeout: Max amount of time that will ela...
[ "def", "poll", "(", "function", ",", "step", "=", "0.5", ",", "timeout", "=", "3", ",", "ignore_exceptions", "=", "(", ")", ",", "exception_message", "=", "''", ",", "message_builder", "=", "None", ",", "args", "=", "(", ")", ",", "kwargs", "=", "Non...
Calls the function until bool(return value) is truthy @param step: Wait time between each function call @param timeout: Max amount of time that will elapse. If the function is in progress when timeout has passed, the function will be allowed to complete. @type ignore_exceptions: tuple @param ignore...
[ "Calls", "the", "function", "until", "bool", "(", "return", "value", ")", "is", "truthy" ]
python
train
33.644444
vmware/pyvmomi
pyVmomi/Differ.py
https://github.com/vmware/pyvmomi/blob/3ffcb23bf77d757175c0d5216ba9a25345d824cd/pyVmomi/Differ.py#L113-L123
def DiffAnyArrays(self, oldObj, newObj, isElementLinks): """Diff two arrays which contain Any objects""" if len(oldObj) != len(newObj): __Log__.debug('DiffAnyArrays: Array lengths do not match. %d != %d' % (len(oldObj), len(newObj))) return False for i, j in zip(oldObj, n...
[ "def", "DiffAnyArrays", "(", "self", ",", "oldObj", ",", "newObj", ",", "isElementLinks", ")", ":", "if", "len", "(", "oldObj", ")", "!=", "len", "(", "newObj", ")", ":", "__Log__", ".", "debug", "(", "'DiffAnyArrays: Array lengths do not match. %d != %d'", "%...
Diff two arrays which contain Any objects
[ "Diff", "two", "arrays", "which", "contain", "Any", "objects" ]
python
train
45.181818
google/grumpy
third_party/stdlib/_abcoll.py
https://github.com/google/grumpy/blob/3ec87959189cfcdeae82eb68a47648ac25ceb10b/third_party/stdlib/_abcoll.py#L249-L279
def _hash(self): """Compute the hash value of a set. Note that we don't define __hash__: not all sets are hashable. But if you define a hashable set type, its __hash__ should call this function. This must be compatible __eq__. All sets ought to compare equal if they co...
[ "def", "_hash", "(", "self", ")", ":", "MAX", "=", "sys", ".", "maxint", "MASK", "=", "2", "*", "MAX", "+", "1", "n", "=", "len", "(", "self", ")", "h", "=", "1927868237", "*", "(", "n", "+", "1", ")", "h", "&=", "MASK", "for", "x", "in", ...
Compute the hash value of a set. Note that we don't define __hash__: not all sets are hashable. But if you define a hashable set type, its __hash__ should call this function. This must be compatible __eq__. All sets ought to compare equal if they contain the same eleme...
[ "Compute", "the", "hash", "value", "of", "a", "set", "." ]
python
valid
31.354839
pybel/pybel
src/pybel/struct/mutation/induction/random_subgraph.py
https://github.com/pybel/pybel/blob/c8a7a1bdae4c475fa2a8c77f3a9a5f6d79556ca0/src/pybel/struct/mutation/induction/random_subgraph.py#L168-L216
def get_random_subgraph(graph, number_edges=None, number_seed_edges=None, seed=None, invert_degrees=None): """Generate a random subgraph based on weighted random walks from random seed edges. :type graph: pybel.BELGraph graph :param Optional[int] number_edges: Maximum number of edges. Defaults to :dat...
[ "def", "get_random_subgraph", "(", "graph", ",", "number_edges", "=", "None", ",", "number_seed_edges", "=", "None", ",", "seed", "=", "None", ",", "invert_degrees", "=", "None", ")", ":", "if", "number_edges", "is", "None", ":", "number_edges", "=", "SAMPLE...
Generate a random subgraph based on weighted random walks from random seed edges. :type graph: pybel.BELGraph graph :param Optional[int] number_edges: Maximum number of edges. Defaults to :data:`pybel_tools.constants.SAMPLE_RANDOM_EDGE_COUNT` (250). :param Optional[int] number_seed_edges: Number of no...
[ "Generate", "a", "random", "subgraph", "based", "on", "weighted", "random", "walks", "from", "random", "seed", "edges", "." ]
python
train
38.346939
Metatab/metatab
metatab/parser.py
https://github.com/Metatab/metatab/blob/8336ec3e4bd8da84a9a5cb86de1c1086e14b8b22/metatab/parser.py#L302-L410
def generate_terms(self, ref, root, file_type=None): """An generator that yields term objects, handling includes and argument children. :param file_type: :param doc: :param root: :param ref: """ last_section = root t = None if isinstance...
[ "def", "generate_terms", "(", "self", ",", "ref", ",", "root", ",", "file_type", "=", "None", ")", ":", "last_section", "=", "root", "t", "=", "None", "if", "isinstance", "(", "ref", ",", "Source", ")", ":", "row_gen", "=", "ref", "ref_path", "=", "r...
An generator that yields term objects, handling includes and argument children. :param file_type: :param doc: :param root: :param ref:
[ "An", "generator", "that", "yields", "term", "objects", "handling", "includes", "and", "argument", "children", ".", ":", "param", "file_type", ":", ":", "param", "doc", ":", ":", "param", "root", ":", ":", "param", "ref", ":" ]
python
train
37.59633
secdev/scapy
scapy/layers/dot11.py
https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/dot11.py#L619-L670
def network_stats(self): """Return a dictionary containing a summary of the Dot11 elements fields """ summary = {} crypto = set() akmsuite_types = { 0x00: "Reserved", 0x01: "802.1X", 0x02: "PSK" } p = self.payload ...
[ "def", "network_stats", "(", "self", ")", ":", "summary", "=", "{", "}", "crypto", "=", "set", "(", ")", "akmsuite_types", "=", "{", "0x00", ":", "\"Reserved\"", ",", "0x01", ":", "\"802.1X\"", ",", "0x02", ":", "\"PSK\"", "}", "p", "=", "self", ".",...
Return a dictionary containing a summary of the Dot11 elements fields
[ "Return", "a", "dictionary", "containing", "a", "summary", "of", "the", "Dot11", "elements", "fields" ]
python
train
36.326923
limpyd/redis-limpyd
limpyd/fields.py
https://github.com/limpyd/redis-limpyd/blob/3c745dde1390a0bd09690b77a089dcc08c6c7e43/limpyd/fields.py#L726-L733
def _rem(self, command, *args, **kwargs): """ Shortcut for commands that only remove values from the field. Removed values will be deindexed. """ if self.indexable: self.deindex(args) return self._traverse_command(command, *args, **kwargs)
[ "def", "_rem", "(", "self", ",", "command", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "indexable", ":", "self", ".", "deindex", "(", "args", ")", "return", "self", ".", "_traverse_command", "(", "command", ",", "*", "a...
Shortcut for commands that only remove values from the field. Removed values will be deindexed.
[ "Shortcut", "for", "commands", "that", "only", "remove", "values", "from", "the", "field", ".", "Removed", "values", "will", "be", "deindexed", "." ]
python
train
36.5
pymc-devs/pymc
pymc/distributions.py
https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L1241-L1261
def exponweib_like(x, alpha, k, loc=0, scale=1): R""" Exponentiated Weibull log-likelihood. The exponentiated Weibull distribution is a generalization of the Weibull family. Its value lies in being able to model monotone and non-monotone failure rates. .. math:: f(x \mid \alpha,k,loc,s...
[ "def", "exponweib_like", "(", "x", ",", "alpha", ",", "k", ",", "loc", "=", "0", ",", "scale", "=", "1", ")", ":", "return", "flib", ".", "exponweib", "(", "x", ",", "alpha", ",", "k", ",", "loc", ",", "scale", ")" ]
R""" Exponentiated Weibull log-likelihood. The exponentiated Weibull distribution is a generalization of the Weibull family. Its value lies in being able to model monotone and non-monotone failure rates. .. math:: f(x \mid \alpha,k,loc,scale) & = \frac{\alpha k}{scale} (1-e^{-z^k})^{\alph...
[ "R", "Exponentiated", "Weibull", "log", "-", "likelihood", "." ]
python
train
30.714286
bitesofcode/projexui
projexui/widgets/xchart/axes/xdatetimeaxis.py
https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xchart/axes/xdatetimeaxis.py#L59-L85
def percentAt(self, value): """ Returns the percentage the value represents between the minimum and maximum for this axis. :param value | <int> || <float> :return <float> """ min_val = self.minimum() max_val = self.maxi...
[ "def", "percentAt", "(", "self", ",", "value", ")", ":", "min_val", "=", "self", ".", "minimum", "(", ")", "max_val", "=", "self", ".", "maximum", "(", ")", "# round the max value to sync with the values in the grid\r", "total_seconds", "=", "(", "max_val", "-",...
Returns the percentage the value represents between the minimum and maximum for this axis. :param value | <int> || <float> :return <float>
[ "Returns", "the", "percentage", "the", "value", "represents", "between", "the", "minimum", "and", "maximum", "for", "this", "axis", ".", ":", "param", "value", "|", "<int", ">", "||", "<float", ">", ":", "return", "<float", ">" ]
python
train
29.074074
gsamokovarov/frames.py
frames/__init__.py
https://github.com/gsamokovarov/frames.py/blob/ba43782d043691fb5a388a1e749e0f0edb68a3d7/frames/__init__.py#L73-L119
def locate(callback, root_frame=None, include_root=False, raw=False): ''' Locates a frame by criteria. :param callback: One argument function to check the frame against. The frame we are curretly on, is given as that argument. :param root_frame: The r...
[ "def", "locate", "(", "callback", ",", "root_frame", "=", "None", ",", "include_root", "=", "False", ",", "raw", "=", "False", ")", ":", "def", "get_from", "(", "maybe_callable", ")", ":", "if", "callable", "(", "maybe_callable", ")", ":", "return", "may...
Locates a frame by criteria. :param callback: One argument function to check the frame against. The frame we are curretly on, is given as that argument. :param root_frame: The root frame to start the search from. Can be a callback taking no arguments. ...
[ "Locates", "a", "frame", "by", "criteria", "." ]
python
train
34.021277
KenjiTakahashi/td
td/model.py
https://github.com/KenjiTakahashi/td/blob/7311eabc63efe6fe6600687c3026f0837454c2e4/td/model.py#L281-L346
def _modifyInternal(self, *, sort=None, purge=False, done=None): """Creates a whole new database from existing one, based on given modifiers. :sort: pattern should look like this: ([(<index>, True|False)], {<level_index>: [(<index>, True|False)]}), where True|False indicate whet...
[ "def", "_modifyInternal", "(", "self", ",", "*", ",", "sort", "=", "None", ",", "purge", "=", "False", ",", "done", "=", "None", ")", ":", "sortAll", ",", "sortLevels", "=", "sort", "is", "not", "None", "and", "sort", "or", "(", "[", "]", ",", "{...
Creates a whole new database from existing one, based on given modifiers. :sort: pattern should look like this: ([(<index>, True|False)], {<level_index>: [(<index>, True|False)]}), where True|False indicate whether to reverse or not, <index> are one of Model.indexes and <level_i...
[ "Creates", "a", "whole", "new", "database", "from", "existing", "one", "based", "on", "given", "modifiers", "." ]
python
train
39.772727
DataDog/integrations-core
haproxy/datadog_checks/haproxy/haproxy.py
https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/haproxy/datadog_checks/haproxy/haproxy.py#L163-L191
def _fetch_url_data(self, url, username, password, verify, custom_headers): ''' Hit a given http url and return the stats lines ''' # Try to fetch data from the stats URL auth = (username, password) url = "%s%s" % (url, STATS_URL) custom_headers.update(headers(self.agentConfig))...
[ "def", "_fetch_url_data", "(", "self", ",", "url", ",", "username", ",", "password", ",", "verify", ",", "custom_headers", ")", ":", "# Try to fetch data from the stats URL", "auth", "=", "(", "username", ",", "password", ")", "url", "=", "\"%s%s\"", "%", "(",...
Hit a given http url and return the stats lines
[ "Hit", "a", "given", "http", "url", "and", "return", "the", "stats", "lines" ]
python
train
38.103448
chaoss/grimoirelab-perceval
perceval/backends/core/git.py
https://github.com/chaoss/grimoirelab-perceval/blob/41c908605e88b7ebc3a536c643fa0f212eaf9e0e/perceval/backends/core/git.py#L831-L859
def count_objects(self): """Count the objects of a repository. The method returns the total number of objects (packed and unpacked) available on the repository. :raises RepositoryError: when an error occurs counting the objects of a repository """ cmd_count ...
[ "def", "count_objects", "(", "self", ")", ":", "cmd_count", "=", "[", "'git'", ",", "'count-objects'", ",", "'-v'", "]", "outs", "=", "self", ".", "_exec", "(", "cmd_count", ",", "cwd", "=", "self", ".", "dirpath", ",", "env", "=", "self", ".", "gite...
Count the objects of a repository. The method returns the total number of objects (packed and unpacked) available on the repository. :raises RepositoryError: when an error occurs counting the objects of a repository
[ "Count", "the", "objects", "of", "a", "repository", "." ]
python
test
38.241379
theislab/scanpy
scanpy/datasets/__init__.py
https://github.com/theislab/scanpy/blob/9e4e5ee02e04cf618872d9b098e24f0542e8b227/scanpy/datasets/__init__.py#L177-L192
def toggleswitch() -> AnnData: """Simulated toggleswitch. Data obtained simulating a simple toggleswitch `Gardner *et al.*, Nature (2000) <https://doi.org/10.1038/35002131>`__. Simulate via :func:`~scanpy.api.sim`. Returns ------- Annotated data matrix. """ filename = os.path.dirn...
[ "def", "toggleswitch", "(", ")", "->", "AnnData", ":", "filename", "=", "os", ".", "path", ".", "dirname", "(", "__file__", ")", "+", "'/toggleswitch.txt'", "adata", "=", "sc", ".", "read", "(", "filename", ",", "first_column_names", "=", "True", ")", "a...
Simulated toggleswitch. Data obtained simulating a simple toggleswitch `Gardner *et al.*, Nature (2000) <https://doi.org/10.1038/35002131>`__. Simulate via :func:`~scanpy.api.sim`. Returns ------- Annotated data matrix.
[ "Simulated", "toggleswitch", "." ]
python
train
27.4375
pkgw/pwkit
pwkit/synphot.py
https://github.com/pkgw/pwkit/blob/d40957a1c3d2ea34e7ceac2267ee9635135f2793/pwkit/synphot.py#L333-L344
def mag_to_fnu(self, mag): """Convert a magnitude in this band to a f_ν flux density. It is assumed that the magnitude has been computed in the appropriate photometric system. The definition of "appropriate" will vary from case to case. """ if self.native_flux_kind == '...
[ "def", "mag_to_fnu", "(", "self", ",", "mag", ")", ":", "if", "self", ".", "native_flux_kind", "==", "'flam'", ":", "return", "flam_ang_to_fnu_cgs", "(", "self", ".", "mag_to_flam", "(", "mag", ")", ",", "self", ".", "pivot_wavelength", "(", ")", ")", "r...
Convert a magnitude in this band to a f_ν flux density. It is assumed that the magnitude has been computed in the appropriate photometric system. The definition of "appropriate" will vary from case to case.
[ "Convert", "a", "magnitude", "in", "this", "band", "to", "a", "f_ν", "flux", "density", "." ]
python
train
44.333333
hhromic/python-oslom-runner
oslom/runner.py
https://github.com/hhromic/python-oslom-runner/blob/f5991bd5014c65d0a9852641d51cbc344407d6a2/oslom/runner.py#L100-L115
def run(self, oslom_exec, oslom_args, log_filename): """Run OSLOM and wait for the process to finish.""" args = [oslom_exec, "-f", self.get_path(OslomRunner.TMP_EDGES_FILE)] args.extend(oslom_args) with open(log_filename, "w") as logwriter: start_time = time.time() ...
[ "def", "run", "(", "self", ",", "oslom_exec", ",", "oslom_args", ",", "log_filename", ")", ":", "args", "=", "[", "oslom_exec", ",", "\"-f\"", ",", "self", ".", "get_path", "(", "OslomRunner", ".", "TMP_EDGES_FILE", ")", "]", "args", ".", "extend", "(", ...
Run OSLOM and wait for the process to finish.
[ "Run", "OSLOM", "and", "wait", "for", "the", "process", "to", "finish", "." ]
python
train
45.875
phoebe-project/phoebe2
phoebe/frontend/bundle.py
https://github.com/phoebe-project/phoebe2/blob/e64b8be683977064e2d55dd1b3ac400f64c3e379/phoebe/frontend/bundle.py#L1849-L1919
def add_component(self, kind, **kwargs): """ Add a new component (star or orbit) to the system. If not provided, 'component' (the name of the new star or orbit) will be created for you and can be accessed by the 'component' attribute of the returned ParameterSet. >>> b....
[ "def", "add_component", "(", "self", ",", "kind", ",", "*", "*", "kwargs", ")", ":", "func", "=", "_get_add_func", "(", "component", ",", "kind", ")", "if", "kwargs", ".", "get", "(", "'component'", ",", "False", ")", "is", "None", ":", "# then we want...
Add a new component (star or orbit) to the system. If not provided, 'component' (the name of the new star or orbit) will be created for you and can be accessed by the 'component' attribute of the returned ParameterSet. >>> b.add_component(component.star) or >>> b.add_...
[ "Add", "a", "new", "component", "(", "star", "or", "orbit", ")", "to", "the", "system", ".", "If", "not", "provided", "component", "(", "the", "name", "of", "the", "new", "star", "or", "orbit", ")", "will", "be", "created", "for", "you", "and", "can"...
python
train
38.577465
kivy/python-for-android
pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py
https://github.com/kivy/python-for-android/blob/8e0e8056bc22e4d5bd3398a6b0301f38ff167933/pythonforandroid/bootstraps/pygame/build/buildlib/jinja2.egg/jinja2/filters.py#L200-L219
def do_default(value, default_value=u'', boolean=False): """If the value is undefined it will return the passed default value, otherwise the value of the variable: .. sourcecode:: jinja {{ my_variable|default('my_variable is not defined') }} This will output the value of ``my_variable`` if th...
[ "def", "do_default", "(", "value", ",", "default_value", "=", "u''", ",", "boolean", "=", "False", ")", ":", "if", "(", "boolean", "and", "not", "value", ")", "or", "isinstance", "(", "value", ",", "Undefined", ")", ":", "return", "default_value", "retur...
If the value is undefined it will return the passed default value, otherwise the value of the variable: .. sourcecode:: jinja {{ my_variable|default('my_variable is not defined') }} This will output the value of ``my_variable`` if the variable was defined, otherwise ``'my_variable is not defi...
[ "If", "the", "value", "is", "undefined", "it", "will", "return", "the", "passed", "default", "value", "otherwise", "the", "value", "of", "the", "variable", ":" ]
python
train
34.7
clalancette/pycdlib
pycdlib/eltorito.py
https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/eltorito.py#L183-L216
def parse(self, valstr): # type: (bytes) -> None ''' A method to parse an El Torito Validation Entry out of a string. Parameters: valstr - The string to parse the El Torito Validation Entry out of. Returns: Nothing. ''' if self._initialized: ...
[ "def", "parse", "(", "self", ",", "valstr", ")", ":", "# type: (bytes) -> None", "if", "self", ".", "_initialized", ":", "raise", "pycdlibexception", ".", "PyCdlibInternalError", "(", "'El Torito Validation Entry already initialized'", ")", "(", "header_id", ",", "sel...
A method to parse an El Torito Validation Entry out of a string. Parameters: valstr - The string to parse the El Torito Validation Entry out of. Returns: Nothing.
[ "A", "method", "to", "parse", "an", "El", "Torito", "Validation", "Entry", "out", "of", "a", "string", "." ]
python
train
41.647059
mardiros/pyshop
pyshop/models.py
https://github.com/mardiros/pyshop/blob/b42510b9c3fa16e0e5710457401ac38fea5bf7a0/pyshop/models.py#L512-L519
def sorted_releases(self): """ Releases sorted by version. """ releases = [(parse_version(release.version), release) for release in self.releases] releases.sort(reverse=True) return [release[1] for release in releases]
[ "def", "sorted_releases", "(", "self", ")", ":", "releases", "=", "[", "(", "parse_version", "(", "release", ".", "version", ")", ",", "release", ")", "for", "release", "in", "self", ".", "releases", "]", "releases", ".", "sort", "(", "reverse", "=", "...
Releases sorted by version.
[ "Releases", "sorted", "by", "version", "." ]
python
train
34.875
occrp-attic/exactitude
exactitude/address.py
https://github.com/occrp-attic/exactitude/blob/9fe13aa70f1aac644dbc999e0b21683db507f02d/exactitude/address.py#L19-L24
def normalize(self, address, **kwargs): """Make the address more compareable.""" # TODO: normalize well-known parts like "Street", "Road", etc. # TODO: consider using https://github.com/openvenues/pypostal addresses = super(AddressType, self).normalize(address, **kwargs) return a...
[ "def", "normalize", "(", "self", ",", "address", ",", "*", "*", "kwargs", ")", ":", "# TODO: normalize well-known parts like \"Street\", \"Road\", etc.", "# TODO: consider using https://github.com/openvenues/pypostal", "addresses", "=", "super", "(", "AddressType", ",", "self...
Make the address more compareable.
[ "Make", "the", "address", "more", "compareable", "." ]
python
train
53.833333
3ll3d00d/vibe
backend/src/analyser/common/signal.py
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/signal.py#L179-L184
def lowPass(self, *args): """ Creates a copy of the signal with the low pass applied, args specifed are passed through to _butter. :return: """ return Signal(self._butter(self.samples, 'low', *args), fs=self.fs)
[ "def", "lowPass", "(", "self", ",", "*", "args", ")", ":", "return", "Signal", "(", "self", ".", "_butter", "(", "self", ".", "samples", ",", "'low'", ",", "*", "args", ")", ",", "fs", "=", "self", ".", "fs", ")" ]
Creates a copy of the signal with the low pass applied, args specifed are passed through to _butter. :return:
[ "Creates", "a", "copy", "of", "the", "signal", "with", "the", "low", "pass", "applied", "args", "specifed", "are", "passed", "through", "to", "_butter", ".", ":", "return", ":" ]
python
train
41.333333
calvinku96/labreporthelper
labreporthelper/table.py
https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/table.py#L7-L50
def make_tex_table(inputlist, outputfile, close=False, fmt=None, **kwargs): """ Parse table from inputlist Args: inputlist: list List to parse outputfile: file .tex file to write fmt: dictionary key: integer colu...
[ "def", "make_tex_table", "(", "inputlist", ",", "outputfile", ",", "close", "=", "False", ",", "fmt", "=", "None", ",", "*", "*", "kwargs", ")", ":", "output_str", "=", "\"\"", "if", "fmt", "is", "None", ":", "fmt", "=", "{", "}", "for", "row", "in...
Parse table from inputlist Args: inputlist: list List to parse outputfile: file .tex file to write fmt: dictionary key: integer column index starting with 0 values: string format string. eg "{:g}" **kwar...
[ "Parse", "table", "from", "inputlist" ]
python
train
29.386364
dereneaton/ipyrad
ipyrad/assemble/cluster_within.py
https://github.com/dereneaton/ipyrad/blob/5eeb8a178160f45faf71bf47cec4abe998a575d1/ipyrad/assemble/cluster_within.py#L1354-L1411
def derep_concat_split(data, sample, nthreads, force): """ Running on remote Engine. Refmaps, then merges, then dereplicates, then denovo clusters reads. """ ## report location for debugging LOGGER.info("INSIDE derep %s", sample.name) ## MERGED ASSEMBIES ONLY: ## concatenate edits file...
[ "def", "derep_concat_split", "(", "data", ",", "sample", ",", "nthreads", ",", "force", ")", ":", "## report location for debugging", "LOGGER", ".", "info", "(", "\"INSIDE derep %s\"", ",", "sample", ".", "name", ")", "## MERGED ASSEMBIES ONLY:", "## concatenate edits...
Running on remote Engine. Refmaps, then merges, then dereplicates, then denovo clusters reads.
[ "Running", "on", "remote", "Engine", ".", "Refmaps", "then", "merges", "then", "dereplicates", "then", "denovo", "clusters", "reads", "." ]
python
valid
41.706897
coleifer/walrus
walrus/containers.py
https://github.com/coleifer/walrus/blob/82bf15a6613487b5b5fefeb488f186d7e0106547/walrus/containers.py#L726-L735
def range_by_lex(self, low, high, start=None, num=None, reverse=False): """ Return a range of members in a sorted set, by lexicographical range. """ if reverse: fn = self.database.zrevrangebylex low, high = high, low else: fn = self.database.zr...
[ "def", "range_by_lex", "(", "self", ",", "low", ",", "high", ",", "start", "=", "None", ",", "num", "=", "None", ",", "reverse", "=", "False", ")", ":", "if", "reverse", ":", "fn", "=", "self", ".", "database", ".", "zrevrangebylex", "low", ",", "h...
Return a range of members in a sorted set, by lexicographical range.
[ "Return", "a", "range", "of", "members", "in", "a", "sorted", "set", "by", "lexicographical", "range", "." ]
python
train
37.1
webrecorder/pywb
pywb/warcserver/index/cdxops.py
https://github.com/webrecorder/pywb/blob/77f8bb647639dd66f6b92b7a9174c28810e4b1d9/pywb/warcserver/index/cdxops.py#L126-L132
def cdx_limit(cdx_iter, limit): """ limit cdx to at most `limit`. """ # for cdx, _ in itertools.izip(cdx_iter, xrange(limit)): # yield cdx return (cdx for cdx, _ in zip(cdx_iter, range(limit)))
[ "def", "cdx_limit", "(", "cdx_iter", ",", "limit", ")", ":", "# for cdx, _ in itertools.izip(cdx_iter, xrange(limit)):", "# yield cdx", "return", "(", "cdx", "for", "cdx", ",", "_", "in", "zip", "(", "cdx_iter", ",", "range", "(", "limit", ")", ")", ")...
limit cdx to at most `limit`.
[ "limit", "cdx", "to", "at", "most", "limit", "." ]
python
train
30.428571
quintusdias/glymur
glymur/jp2k.py
https://github.com/quintusdias/glymur/blob/8b8fb091130fff00f1028dc82219e69e3f9baf6d/glymur/jp2k.py#L652-L658
def _validate_image_rank(self, img_array): """ Images must be either 2D or 3D. """ if img_array.ndim == 1 or img_array.ndim > 3: msg = "{0}D imagery is not allowed.".format(img_array.ndim) raise IOError(msg)
[ "def", "_validate_image_rank", "(", "self", ",", "img_array", ")", ":", "if", "img_array", ".", "ndim", "==", "1", "or", "img_array", ".", "ndim", ">", "3", ":", "msg", "=", "\"{0}D imagery is not allowed.\"", ".", "format", "(", "img_array", ".", "ndim", ...
Images must be either 2D or 3D.
[ "Images", "must", "be", "either", "2D", "or", "3D", "." ]
python
train
36.714286
numenta/nupic
src/nupic/algorithms/spatial_pooler.py
https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/algorithms/spatial_pooler.py#L1036-L1059
def _updateInhibitionRadius(self): """ Update the inhibition radius. The inhibition radius is a measure of the square (or hypersquare) of columns that each a column is "connected to" on average. Since columns are are not connected to each other directly, we determine this quantity by first figuring ...
[ "def", "_updateInhibitionRadius", "(", "self", ")", ":", "if", "self", ".", "_globalInhibition", ":", "self", ".", "_inhibitionRadius", "=", "int", "(", "self", ".", "_columnDimensions", ".", "max", "(", ")", ")", "return", "avgConnectedSpan", "=", "numpy", ...
Update the inhibition radius. The inhibition radius is a measure of the square (or hypersquare) of columns that each a column is "connected to" on average. Since columns are are not connected to each other directly, we determine this quantity by first figuring out how many *inputs* a column is connected...
[ "Update", "the", "inhibition", "radius", ".", "The", "inhibition", "radius", "is", "a", "measure", "of", "the", "square", "(", "or", "hypersquare", ")", "of", "columns", "that", "each", "a", "column", "is", "connected", "to", "on", "average", ".", "Since",...
python
valid
47.041667
ANTsX/ANTsPy
ants/segmentation/anti_alias.py
https://github.com/ANTsX/ANTsPy/blob/638020af2cdfc5ff4bdb9809ffe67aa505727a3b/ants/segmentation/anti_alias.py#L12-L44
def anti_alias(image): """ Apply Anti-Alias filter to a binary image ANTsR function: N/A Arguments --------- image : ANTsImage binary image to which anti-aliasing will be applied Returns ------- ANTsImage Example ------- >>> import ants >>> img = ants....
[ "def", "anti_alias", "(", "image", ")", ":", "if", "image", ".", "pixeltype", "!=", "'unsigned char'", ":", "if", "image", ".", "max", "(", ")", ">", "255.", ":", "image", "=", "(", "image", "-", "image", ".", "max", "(", ")", ")", "/", "(", "ima...
Apply Anti-Alias filter to a binary image ANTsR function: N/A Arguments --------- image : ANTsImage binary image to which anti-aliasing will be applied Returns ------- ANTsImage Example ------- >>> import ants >>> img = ants.image_read(ants.get_data('r16')) ...
[ "Apply", "Anti", "-", "Alias", "filter", "to", "a", "binary", "image", "ANTsR", "function", ":", "N", "/", "A" ]
python
train
26.848485
tensorflow/tensorboard
tensorboard/backend/event_processing/event_accumulator.py
https://github.com/tensorflow/tensorboard/blob/8e5f497b48e40f2a774f85416b8a35ac0693c35e/tensorboard/backend/event_processing/event_accumulator.py#L647-L654
def _ProcessImage(self, tag, wall_time, step, image): """Processes an image by adding it to accumulated state.""" event = ImageEvent(wall_time=wall_time, step=step, encoded_image_string=image.encoded_image_string, width=image.width, ...
[ "def", "_ProcessImage", "(", "self", ",", "tag", ",", "wall_time", ",", "step", ",", "image", ")", ":", "event", "=", "ImageEvent", "(", "wall_time", "=", "wall_time", ",", "step", "=", "step", ",", "encoded_image_string", "=", "image", ".", "encoded_image...
Processes an image by adding it to accumulated state.
[ "Processes", "an", "image", "by", "adding", "it", "to", "accumulated", "state", "." ]
python
train
47.75
emlazzarin/acrylic
acrylic/datatable.py
https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/datatable.py#L706-L731
def sample(self, num): """ Returns a new table with rows randomly sampled. We create a mask with `num` True bools, and fill it with False bools until it is the length of the table. We shuffle it, and apply that mask to the table. """ if num > len(self): ...
[ "def", "sample", "(", "self", ",", "num", ")", ":", "if", "num", ">", "len", "(", "self", ")", ":", "return", "self", ".", "copy", "(", ")", "elif", "num", "<", "0", ":", "raise", "IndexError", "(", "\"Cannot sample a negative number of rows \"", "\"from...
Returns a new table with rows randomly sampled. We create a mask with `num` True bools, and fill it with False bools until it is the length of the table. We shuffle it, and apply that mask to the table.
[ "Returns", "a", "new", "table", "with", "rows", "randomly", "sampled", "." ]
python
train
39.769231
contraslash/django-crud-generator
django_crud_generator/django_crud_generator.py
https://github.com/contraslash/django-crud-generator/blob/9080a227291a36cf0d93b49d20601e55a616da1e/django_crud_generator/django_crud_generator.py#L77-L100
def generic_insert_module(module_name, args, **kwargs): """ In general we have a initial template and then insert new data, so we dont repeat the schema for each module :param module_name: String with module name :paran **kwargs: Args to be rendered in template """ file = create_or_open( ...
[ "def", "generic_insert_module", "(", "module_name", ",", "args", ",", "*", "*", "kwargs", ")", ":", "file", "=", "create_or_open", "(", "'{}.py'", ".", "format", "(", "module_name", ")", ",", "os", ".", "path", ".", "join", "(", "BASE_TEMPLATES_DIR", ",", ...
In general we have a initial template and then insert new data, so we dont repeat the schema for each module :param module_name: String with module name :paran **kwargs: Args to be rendered in template
[ "In", "general", "we", "have", "a", "initial", "template", "and", "then", "insert", "new", "data", "so", "we", "dont", "repeat", "the", "schema", "for", "each", "module", ":", "param", "module_name", ":", "String", "with", "module", "name", ":", "paran", ...
python
train
28.541667
ctuning/ck
ck/kernel.py
https://github.com/ctuning/ck/blob/7e009814e975f8742790d3106340088a46223714/ck/kernel.py#L6749-L6925
def cp(i): """ Input: { (repo_uoa) - repo UOA module_uoa - module UOA data_uoa - data UOA xcids[0] - {'repo_uoa', 'module_uoa', 'data_uoa'} - new CID or (new_repo_uoa) - new repo UOA ...
[ "def", "cp", "(", "i", ")", ":", "move", "=", "i", ".", "get", "(", "'move'", ",", "''", ")", "# Check if global writing is allowed", "r", "=", "check_writing", "(", "{", "}", ")", "if", "r", "[", "'return'", "]", ">", "0", ":", "return", "r", "imp...
Input: { (repo_uoa) - repo UOA module_uoa - module UOA data_uoa - data UOA xcids[0] - {'repo_uoa', 'module_uoa', 'data_uoa'} - new CID or (new_repo_uoa) - new repo UOA (new_module_uoa) - ...
[ "Input", ":", "{", "(", "repo_uoa", ")", "-", "repo", "UOA", "module_uoa", "-", "module", "UOA", "data_uoa", "-", "data", "UOA" ]
python
train
25.384181
iotile/coretools
iotilegateway/iotilegateway/supervisor/client.py
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/supervisor/client.py#L165-L189
async def sync_services(self): """Poll the current state of all services. Returns: dict: A dictionary mapping service name to service status """ services = {} servs = await self.list_services() for i, serv in enumerate(servs): info = await self....
[ "async", "def", "sync_services", "(", "self", ")", ":", "services", "=", "{", "}", "servs", "=", "await", "self", ".", "list_services", "(", ")", "for", "i", ",", "serv", "in", "enumerate", "(", "servs", ")", ":", "info", "=", "await", "self", ".", ...
Poll the current state of all services. Returns: dict: A dictionary mapping service name to service status
[ "Poll", "the", "current", "state", "of", "all", "services", "." ]
python
train
38.08
MisterWil/abodepy
abodepy/devices/camera.py
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/camera.py#L91-L108
def image_to_file(self, path, get_image=True): """Write the image to a file.""" if not self.image_url or get_image: if not self.refresh_image(): return False response = requests.get(self.image_url, stream=True) if response.status_code != 200: _LO...
[ "def", "image_to_file", "(", "self", ",", "path", ",", "get_image", "=", "True", ")", ":", "if", "not", "self", ".", "image_url", "or", "get_image", ":", "if", "not", "self", ".", "refresh_image", "(", ")", ":", "return", "False", "response", "=", "req...
Write the image to a file.
[ "Write", "the", "image", "to", "a", "file", "." ]
python
train
34.777778
apache/incubator-mxnet
example/reinforcement-learning/dqn/utils.py
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/reinforcement-learning/dqn/utils.py#L179-L203
def sample_mog(prob, mean, var, rng): """Sample from independent mixture of gaussian (MoG) distributions Each batch is an independent MoG distribution. Parameters ---------- prob : numpy.ndarray mixture probability of each gaussian. Shape --> (batch_num, center_num) mean : numpy.ndarray ...
[ "def", "sample_mog", "(", "prob", ",", "mean", ",", "var", ",", "rng", ")", ":", "gaussian_inds", "=", "sample_categorical", "(", "prob", ",", "rng", ")", ".", "astype", "(", "numpy", ".", "int32", ")", "mean", "=", "mean", "[", "numpy", ".", "arange...
Sample from independent mixture of gaussian (MoG) distributions Each batch is an independent MoG distribution. Parameters ---------- prob : numpy.ndarray mixture probability of each gaussian. Shape --> (batch_num, center_num) mean : numpy.ndarray mean of each gaussian. Shape --> (batch...
[ "Sample", "from", "independent", "mixture", "of", "gaussian", "(", "MoG", ")", "distributions" ]
python
train
35.36
edx/edx-enterprise
enterprise/management/commands/assign_enterprise_user_roles.py
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/management/commands/assign_enterprise_user_roles.py#L113-L118
def _get_enterprise_enrollment_api_admin_users_batch(self, start, end): # pylint: disable=invalid-name """ Returns a batched queryset of User objects. """ LOGGER.info('Fetching new batch of enterprise enrollment admin users from indexes: %s to %s', start, end) return User.obj...
[ "def", "_get_enterprise_enrollment_api_admin_users_batch", "(", "self", ",", "start", ",", "end", ")", ":", "# pylint: disable=invalid-name", "LOGGER", ".", "info", "(", "'Fetching new batch of enterprise enrollment admin users from indexes: %s to %s'", ",", "start", ",", "end"...
Returns a batched queryset of User objects.
[ "Returns", "a", "batched", "queryset", "of", "User", "objects", "." ]
python
valid
67.666667
nwilming/ocupy
ocupy/utils.py
https://github.com/nwilming/ocupy/blob/a0bd64f822576feaa502939d6bafd1183b237d16/ocupy/utils.py#L63-L70
def randsample(vec, nr_samples, with_replacement = False): """ Draws nr_samples random samples from vec. """ if not with_replacement: return np.random.permutation(vec)[0:nr_samples] else: return np.asarray(vec)[np.random.randint(0, len(vec), nr_samples)]
[ "def", "randsample", "(", "vec", ",", "nr_samples", ",", "with_replacement", "=", "False", ")", ":", "if", "not", "with_replacement", ":", "return", "np", ".", "random", ".", "permutation", "(", "vec", ")", "[", "0", ":", "nr_samples", "]", "else", ":", ...
Draws nr_samples random samples from vec.
[ "Draws", "nr_samples", "random", "samples", "from", "vec", "." ]
python
train
35.375
Jammy2211/PyAutoLens
autolens/data/array/grids.py
https://github.com/Jammy2211/PyAutoLens/blob/91e50369c7a9c048c83d217625578b72423cd5a7/autolens/data/array/grids.py#L873-L892
def padded_grid_from_shape_psf_shape_and_pixel_scale(cls, shape, psf_shape, pixel_scale): """Setup a regular padded grid from a 2D array shape, psf-shape and pixel-scale. The center of every pixel is used to setup the grid's (y,x) arc-second coordinates, including padded pixels \ which are beyo...
[ "def", "padded_grid_from_shape_psf_shape_and_pixel_scale", "(", "cls", ",", "shape", ",", "psf_shape", ",", "pixel_scale", ")", ":", "padded_shape", "=", "(", "shape", "[", "0", "]", "+", "psf_shape", "[", "0", "]", "-", "1", ",", "shape", "[", "1", "]", ...
Setup a regular padded grid from a 2D array shape, psf-shape and pixel-scale. The center of every pixel is used to setup the grid's (y,x) arc-second coordinates, including padded pixels \ which are beyond the input shape but will blurred light into the 2D array's shape due to the psf. Paramete...
[ "Setup", "a", "regular", "padded", "grid", "from", "a", "2D", "array", "shape", "psf", "-", "shape", "and", "pixel", "-", "scale", "." ]
python
valid
61.05
chaoss/grimoirelab-sirmordred
sirmordred/task_enrich.py
https://github.com/chaoss/grimoirelab-sirmordred/blob/d6ac94d28d707fae23170064d078f1edf937d13e/sirmordred/task_enrich.py#L304-L347
def __studies(self, retention_time): """ Execute the studies configured for the current backend """ cfg = self.config.get_conf() if 'studies' not in cfg[self.backend_section] or not \ cfg[self.backend_section]['studies']: logger.debug('No studies for %s' % self.backend_se...
[ "def", "__studies", "(", "self", ",", "retention_time", ")", ":", "cfg", "=", "self", ".", "config", ".", "get_conf", "(", ")", "if", "'studies'", "not", "in", "cfg", "[", "self", ".", "backend_section", "]", "or", "not", "cfg", "[", "self", ".", "ba...
Execute the studies configured for the current backend
[ "Execute", "the", "studies", "configured", "for", "the", "current", "backend" ]
python
valid
45.454545
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_xstp_ext.py
https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_xstp_ext.py#L4657-L4672
def get_stp_mst_detail_output_msti_port_external_path_cost(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_stp_mst_detail = ET.Element("get_stp_mst_detail") config = get_stp_mst_detail output = ET.SubElement(get_stp_mst_detail, "output") ...
[ "def", "get_stp_mst_detail_output_msti_port_external_path_cost", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "get_stp_mst_detail", "=", "ET", ".", "Element", "(", "\"get_stp_mst_detail\"", ")", "conf...
Auto Generated Code
[ "Auto", "Generated", "Code" ]
python
train
45.9375
jakevdp/supersmoother
supersmoother/smoother.py
https://github.com/jakevdp/supersmoother/blob/0c96cf13dcd6f9006d3c0421f9cd6e18abe27a2f/supersmoother/smoother.py#L55-L58
def cv_residuals(self, cv=True): """Return the residuals of the cross-validation for the fit data""" vals = self.cv_values(cv) return (self.y - vals) / self.dy
[ "def", "cv_residuals", "(", "self", ",", "cv", "=", "True", ")", ":", "vals", "=", "self", ".", "cv_values", "(", "cv", ")", "return", "(", "self", ".", "y", "-", "vals", ")", "/", "self", ".", "dy" ]
Return the residuals of the cross-validation for the fit data
[ "Return", "the", "residuals", "of", "the", "cross", "-", "validation", "for", "the", "fit", "data" ]
python
train
45
odlgroup/odl
odl/operator/tensor_ops.py
https://github.com/odlgroup/odl/blob/b8443f6aca90e191ba36c91d32253c5a36249a6c/odl/operator/tensor_ops.py#L251-L265
def _call_vecfield_inf(self, vf, out): """Implement ``self(vf, out)`` for exponent ``inf``.""" vf[0].ufuncs.absolute(out=out) if self.is_weighted: out *= self.weights[0] if len(self.domain) == 1: return tmp = self.range.element() for vfi, wi in z...
[ "def", "_call_vecfield_inf", "(", "self", ",", "vf", ",", "out", ")", ":", "vf", "[", "0", "]", ".", "ufuncs", ".", "absolute", "(", "out", "=", "out", ")", "if", "self", ".", "is_weighted", ":", "out", "*=", "self", ".", "weights", "[", "0", "]"...
Implement ``self(vf, out)`` for exponent ``inf``.
[ "Implement", "self", "(", "vf", "out", ")", "for", "exponent", "inf", "." ]
python
train
32
chrisjrn/registrasion
registrasion/templatetags/registrasion_tags.py
https://github.com/chrisjrn/registrasion/blob/461d5846c6f9f3b7099322a94f5d9911564448e4/registrasion/templatetags/registrasion_tags.py#L124-L149
def sold_out_and_unregistered(context): ''' If the current user is unregistered, returns True if there are no products in the TICKET_PRODUCT_CATEGORY that are available to that user. If there *are* products available, the return False. If the current user *is* registered, then return None (it's not a ...
[ "def", "sold_out_and_unregistered", "(", "context", ")", ":", "user", "=", "user_for_context", "(", "context", ")", "if", "hasattr", "(", "user", ",", "\"attendee\"", ")", "and", "user", ".", "attendee", ".", "completed_registration", ":", "# This user has complet...
If the current user is unregistered, returns True if there are no products in the TICKET_PRODUCT_CATEGORY that are available to that user. If there *are* products available, the return False. If the current user *is* registered, then return None (it's not a pertinent question for people who already ha...
[ "If", "the", "current", "user", "is", "unregistered", "returns", "True", "if", "there", "are", "no", "products", "in", "the", "TICKET_PRODUCT_CATEGORY", "that", "are", "available", "to", "that", "user", "." ]
python
test
38.192308
BlueHack-Core/blueforge
blueforge/util/file.py
https://github.com/BlueHack-Core/blueforge/blob/ac40a888ee9c388638a8f312c51f7500b8891b6c/blueforge/util/file.py#L12-L24
def check_and_create_directories(paths): """ Check and create directories. If the directory is exist, It will remove it and create new folder. :type paths: Array of string or string :param paths: the location of directory """ for path in paths: if os.path.exists(pat...
[ "def", "check_and_create_directories", "(", "paths", ")", ":", "for", "path", "in", "paths", ":", "if", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "shutil", ".", "rmtree", "(", "path", ")", "os", ".", "mkdir", "(", "path", ")" ]
Check and create directories. If the directory is exist, It will remove it and create new folder. :type paths: Array of string or string :param paths: the location of directory
[ "Check", "and", "create", "directories", "." ]
python
train
28.153846
mitsei/dlkit
dlkit/json_/grading/objects.py
https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/grading/objects.py#L187-L198
def get_input_score_start_range_metadata(self): """Gets the metadata for the input score start range. return: (osid.Metadata) - metadata for the input score start range *compliance: mandatory -- This method must be implemented.* """ # Implemented from template f...
[ "def", "get_input_score_start_range_metadata", "(", "self", ")", ":", "# Implemented from template for osid.resource.ResourceForm.get_group_metadata_template", "metadata", "=", "dict", "(", "self", ".", "_mdata", "[", "'input_score_start_range'", "]", ")", "metadata", ".", "u...
Gets the metadata for the input score start range. return: (osid.Metadata) - metadata for the input score start range *compliance: mandatory -- This method must be implemented.*
[ "Gets", "the", "metadata", "for", "the", "input", "score", "start", "range", "." ]
python
train
46.416667
semiversus/python-broqer
broqer/hub/utils/datatype_check.py
https://github.com/semiversus/python-broqer/blob/8957110b034f982451392072d9fa16761adc9c9e/broqer/hub/utils/datatype_check.py#L10-L20
def resolve_meta_key(hub, key, meta): """ Resolve a value when it's a string and starts with '>' """ if key not in meta: return None value = meta[key] if isinstance(value, str) and value[0] == '>': topic = value[1:] if topic not in hub: raise KeyError('topic %s not fo...
[ "def", "resolve_meta_key", "(", "hub", ",", "key", ",", "meta", ")", ":", "if", "key", "not", "in", "meta", ":", "return", "None", "value", "=", "meta", "[", "key", "]", "if", "isinstance", "(", "value", ",", "str", ")", "and", "value", "[", "0", ...
Resolve a value when it's a string and starts with '>'
[ "Resolve", "a", "value", "when", "it", "s", "a", "string", "and", "starts", "with", ">" ]
python
train
34.454545
offu/WeRoBot
werobot/client.py
https://github.com/offu/WeRoBot/blob/fd42109105b03f9acf45ebd9dcabb9d5cff98f3c/werobot/client.py#L937-L966
def send_miniprogrampage_message( self, user_id, title, appid, pagepath, thumb_media_id, kf_account=None ): """ 发送小程序卡片(要求小程序与公众号已关联) :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source :param title: 小程序卡片的标题 :param appid: 小程序的 appid,要求小程序的 appid 需要与公众号有关联关系 :p...
[ "def", "send_miniprogrampage_message", "(", "self", ",", "user_id", ",", "title", ",", "appid", ",", "pagepath", ",", "thumb_media_id", ",", "kf_account", "=", "None", ")", ":", "data", "=", "{", "\"touser\"", ":", "user_id", ",", "\"msgtype\"", ":", "\"mini...
发送小程序卡片(要求小程序与公众号已关联) :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source :param title: 小程序卡片的标题 :param appid: 小程序的 appid,要求小程序的 appid 需要与公众号有关联关系 :param pagepath: 小程序的页面路径,跟 app.json 对齐,支持参数,比如 pages/index/index?foo=bar :param thumb_media_id: 小程序卡片图片的媒体 ID,小程序卡片图片建议大小为 520*416 ...
[ "发送小程序卡片(要求小程序与公众号已关联)" ]
python
train
34.866667
calmjs/calmjs
src/calmjs/toolchain.py
https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/toolchain.py#L1617-L1623
def transpile_modname_source_target(self, spec, modname, source, target): """ Calls the original version. """ return self.simple_transpile_modname_source_target( spec, modname, source, target)
[ "def", "transpile_modname_source_target", "(", "self", ",", "spec", ",", "modname", ",", "source", ",", "target", ")", ":", "return", "self", ".", "simple_transpile_modname_source_target", "(", "spec", ",", "modname", ",", "source", ",", "target", ")" ]
Calls the original version.
[ "Calls", "the", "original", "version", "." ]
python
train
33
Yelp/kafka-utils
kafka_utils/kafka_rolling_restart/main.py
https://github.com/Yelp/kafka-utils/blob/cdb4d64308f3079ee0873250bf7b34d0d94eca50/kafka_utils/kafka_rolling_restart/main.py#L198-L218
def generate_requests(hosts, jolokia_port, jolokia_prefix): """Return a generator of requests to fetch the under replicated partition number from the specified hosts. :param hosts: list of brokers ip addresses :type hosts: list of strings :param jolokia_port: HTTP port for Jolokia :type jolokia...
[ "def", "generate_requests", "(", "hosts", ",", "jolokia_port", ",", "jolokia_prefix", ")", ":", "session", "=", "FuturesSession", "(", ")", "for", "host", "in", "hosts", ":", "url", "=", "\"http://{host}:{port}/{prefix}/read/{key}\"", ".", "format", "(", "host", ...
Return a generator of requests to fetch the under replicated partition number from the specified hosts. :param hosts: list of brokers ip addresses :type hosts: list of strings :param jolokia_port: HTTP port for Jolokia :type jolokia_port: integer :param jolokia_prefix: HTTP prefix on the server...
[ "Return", "a", "generator", "of", "requests", "to", "fetch", "the", "under", "replicated", "partition", "number", "from", "the", "specified", "hosts", "." ]
python
train
35.952381
Iotic-Labs/py-IoticAgent
src/IoticAgent/IOT/Thing.py
https://github.com/Iotic-Labs/py-IoticAgent/blob/893e8582ad1dacfe32dfc0ee89452bbd6f57d28d/src/IoticAgent/IOT/Thing.py#L538-L555
def __sub_make_request(self, foc, gpid, callback): """Make right subscription request depending on whether local or global - used by __sub*""" # global if isinstance(gpid, string_types): gpid = uuid_to_hex(gpid) ref = (foc, gpid) with self.__sub_add_reference(...
[ "def", "__sub_make_request", "(", "self", ",", "foc", ",", "gpid", ",", "callback", ")", ":", "# global", "if", "isinstance", "(", "gpid", ",", "string_types", ")", ":", "gpid", "=", "uuid_to_hex", "(", "gpid", ")", "ref", "=", "(", "foc", ",", "gpid",...
Make right subscription request depending on whether local or global - used by __sub*
[ "Make", "right", "subscription", "request", "depending", "on", "whether", "local", "or", "global", "-", "used", "by", "__sub", "*" ]
python
train
46.611111
Diviyan-Kalainathan/CausalDiscoveryToolbox
cdt/causality/pairwise/model.py
https://github.com/Diviyan-Kalainathan/CausalDiscoveryToolbox/blob/be228b078ba9eb76c01b3ccba9a1c0ad9e9e5ed1/cdt/causality/pairwise/model.py#L116-L170
def orient_graph(self, df_data, graph, nb_runs=6, printout=None, **kwargs): """Orient an undirected graph using the pairwise method defined by the subclass. The pairwise method is ran on every undirected edge. Args: df_data (pandas.DataFrame): Data umg (networkx.Graph):...
[ "def", "orient_graph", "(", "self", ",", "df_data", ",", "graph", ",", "nb_runs", "=", "6", ",", "printout", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "type", "(", "graph", ")", "==", "nx", ".", "DiGraph", ":", "edges", "=", "[", "a",...
Orient an undirected graph using the pairwise method defined by the subclass. The pairwise method is ran on every undirected edge. Args: df_data (pandas.DataFrame): Data umg (networkx.Graph): Graph to orient nb_runs (int): number of times to rerun for each pair (boo...
[ "Orient", "an", "undirected", "graph", "using", "the", "pairwise", "method", "defined", "by", "the", "subclass", "." ]
python
valid
38.490909
skelsec/minidump
minidump/minidumpreader.py
https://github.com/skelsec/minidump/blob/0c4dcabe6f11d7a403440919ffa9e3c9889c5212/minidump/minidumpreader.py#L152-L161
def read_uint(self): """ Reads an integer. The size depends on the architecture. Reads a 4 byte small-endian unsinged int on 32 bit arch Reads an 8 byte small-endian unsinged int on 64 bit arch """ if self.reader.sysinfo.ProcessorArchitecture == PROCESSOR_ARCHITECTURE.AMD64: return int.from_bytes(self.r...
[ "def", "read_uint", "(", "self", ")", ":", "if", "self", ".", "reader", ".", "sysinfo", ".", "ProcessorArchitecture", "==", "PROCESSOR_ARCHITECTURE", ".", "AMD64", ":", "return", "int", ".", "from_bytes", "(", "self", ".", "read", "(", "8", ")", ",", "by...
Reads an integer. The size depends on the architecture. Reads a 4 byte small-endian unsinged int on 32 bit arch Reads an 8 byte small-endian unsinged int on 64 bit arch
[ "Reads", "an", "integer", ".", "The", "size", "depends", "on", "the", "architecture", ".", "Reads", "a", "4", "byte", "small", "-", "endian", "unsinged", "int", "on", "32", "bit", "arch", "Reads", "an", "8", "byte", "small", "-", "endian", "unsinged", ...
python
train
44.1
kennethreitz/clint
clint/utils.py
https://github.com/kennethreitz/clint/blob/9d3693d644b8587d985972b6075d970096f6439e/clint/utils.py#L62-L70
def tsplit(string, delimiters): """Behaves str.split but supports tuples of delimiters.""" delimiters = tuple(delimiters) if len(delimiters) < 1: return [string,] final_delimiter = delimiters[0] for i in delimiters[1:]: string = string.replace(i, final_delimiter) return string.sp...
[ "def", "tsplit", "(", "string", ",", "delimiters", ")", ":", "delimiters", "=", "tuple", "(", "delimiters", ")", "if", "len", "(", "delimiters", ")", "<", "1", ":", "return", "[", "string", ",", "]", "final_delimiter", "=", "delimiters", "[", "0", "]",...
Behaves str.split but supports tuples of delimiters.
[ "Behaves", "str", ".", "split", "but", "supports", "tuples", "of", "delimiters", "." ]
python
train
36.888889
bio2bel/bio2bel
src/bio2bel/manager/abstract_manager.py
https://github.com/bio2bel/bio2bel/blob/d80762d891fa18b248709ff0b0f97ebb65ec64c2/src/bio2bel/manager/abstract_manager.py#L325-L335
def add_cli_drop(main: click.Group) -> click.Group: # noqa: D202 """Add a ``drop`` command to main :mod:`click` function.""" @main.command() @click.confirmation_option(prompt='Are you sure you want to drop the db?') @click.pass_obj def drop(manager): """Drop the database.""" manage...
[ "def", "add_cli_drop", "(", "main", ":", "click", ".", "Group", ")", "->", "click", ".", "Group", ":", "# noqa: D202", "@", "main", ".", "command", "(", ")", "@", "click", ".", "confirmation_option", "(", "prompt", "=", "'Are you sure you want to drop the db?'...
Add a ``drop`` command to main :mod:`click` function.
[ "Add", "a", "drop", "command", "to", "main", ":", "mod", ":", "click", "function", "." ]
python
valid
30.818182
thomasdelaet/python-velbus
velbus/messages/cover_down.py
https://github.com/thomasdelaet/python-velbus/blob/af2f8af43f1a24bf854eff9f3126fd7b5c41b3dd/velbus/messages/cover_down.py#L75-L91
def populate(self, priority, address, rtr, data): """ :return: None """ assert isinstance(data, bytes) self.needs_high_priority(priority) self.needs_no_rtr(rtr) self.needs_data(data, 4) self.set_attributes(priority, address, rtr) # 00000011 = chann...
[ "def", "populate", "(", "self", ",", "priority", ",", "address", ",", "rtr", ",", "data", ")", ":", "assert", "isinstance", "(", "data", ",", "bytes", ")", "self", ".", "needs_high_priority", "(", "priority", ")", "self", ".", "needs_no_rtr", "(", "rtr",...
:return: None
[ ":", "return", ":", "None" ]
python
train
36.294118
evhub/coconut
coconut/compiler/compiler.py
https://github.com/evhub/coconut/blob/ff97177344e7604e89a0a98a977a87ed2a56fc6d/coconut/compiler/compiler.py#L942-L971
def ln_comment(self, ln): """Get an end line comment. CoconutInternalExceptions should always be caught and complained.""" if self.keep_lines: if not 1 <= ln <= len(self.original_lines) + 1: raise CoconutInternalException( "out of bounds line number", ln, ...
[ "def", "ln_comment", "(", "self", ",", "ln", ")", ":", "if", "self", ".", "keep_lines", ":", "if", "not", "1", "<=", "ln", "<=", "len", "(", "self", ".", "original_lines", ")", "+", "1", ":", "raise", "CoconutInternalException", "(", "\"out of bounds lin...
Get an end line comment. CoconutInternalExceptions should always be caught and complained.
[ "Get", "an", "end", "line", "comment", ".", "CoconutInternalExceptions", "should", "always", "be", "caught", "and", "complained", "." ]
python
train
40.366667
Azure/azure-cosmos-python
azure/cosmos/cosmos_client.py
https://github.com/Azure/azure-cosmos-python/blob/dd01b3c5d308c6da83cfcaa0ab7083351a476353/azure/cosmos/cosmos_client.py#L639-L662
def ReadPermission(self, permission_link, options=None): """Reads a permission. :param str permission_link: The link to the permission. :param dict options: The request options for the request. :return: The read permission. :rtype: ...
[ "def", "ReadPermission", "(", "self", ",", "permission_link", ",", "options", "=", "None", ")", ":", "if", "options", "is", "None", ":", "options", "=", "{", "}", "path", "=", "base", ".", "GetPathFromLink", "(", "permission_link", ")", "permission_id", "=...
Reads a permission. :param str permission_link: The link to the permission. :param dict options: The request options for the request. :return: The read permission. :rtype: dict
[ "Reads", "a", "permission", "." ]
python
train
28.333333
Esri/ArcREST
src/arcrest/manageorg/_community.py
https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_community.py#L1157-L1206
def search(self, q, start=1, num=10, sortField="username", sortOrder="asc"): """ The User Search operation searches for users in the portal. The search index is updated whenever users are created, updated, or ...
[ "def", "search", "(", "self", ",", "q", ",", "start", "=", "1", ",", "num", "=", "10", ",", "sortField", "=", "\"username\"", ",", "sortOrder", "=", "\"asc\"", ")", ":", "params", "=", "{", "\"f\"", ":", "\"json\"", ",", "\"q\"", ":", "q", ",", "...
The User Search operation searches for users in the portal. The search index is updated whenever users are created, updated, or deleted. There can be a lag between the time that the user is updated and the time when it's reflected in the search results. The results only contain users tha...
[ "The", "User", "Search", "operation", "searches", "for", "users", "in", "the", "portal", ".", "The", "search", "index", "is", "updated", "whenever", "users", "are", "created", "updated", "or", "deleted", ".", "There", "can", "be", "a", "lag", "between", "t...
python
train
43.96
mdsol/rwslib
rwslib/builders/metadata.py
https://github.com/mdsol/rwslib/blob/1a86bc072d408c009ed1de8bf6e98a1769f54d18/rwslib/builders/metadata.py#L1511-L1528
def build(self, builder): """Build XML by appending to builder""" params = dict(CodedValue=self.coded_value) if self.order_number is not None: params["mdsol:OrderNumber"] = str(self.order_number) if self.specify: params["mdsol:Specify"] = "Yes" builder.s...
[ "def", "build", "(", "self", ",", "builder", ")", ":", "params", "=", "dict", "(", "CodedValue", "=", "self", ".", "coded_value", ")", "if", "self", ".", "order_number", "is", "not", "None", ":", "params", "[", "\"mdsol:OrderNumber\"", "]", "=", "str", ...
Build XML by appending to builder
[ "Build", "XML", "by", "appending", "to", "builder" ]
python
train
28.5
rhgrant10/Groupy
groupy/api/attachments.py
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/attachments.py#L189-L197
def download_large(self, image, url_field='url'): """Downlaod the binary data of an image attachment at large size. :param str url_field: the field of the image with the right URL :return: binary image data :rtype: bytes """ return self.download(image, url_field=url_fie...
[ "def", "download_large", "(", "self", ",", "image", ",", "url_field", "=", "'url'", ")", ":", "return", "self", ".", "download", "(", "image", ",", "url_field", "=", "url_field", ",", "suffix", "=", "'large'", ")" ]
Downlaod the binary data of an image attachment at large size. :param str url_field: the field of the image with the right URL :return: binary image data :rtype: bytes
[ "Downlaod", "the", "binary", "data", "of", "an", "image", "attachment", "at", "large", "size", "." ]
python
train
36.777778
sernst/cauldron
cauldron/runner/markdown_file.py
https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/runner/markdown_file.py#L6-L32
def run( project: 'projects.Project', step: 'projects.ProjectStep' ) -> dict: """ Runs the markdown file and renders the contents to the notebook display :param project: :param step: :return: A run response dictionary containing """ with open(step.source_path, 'r') ...
[ "def", "run", "(", "project", ":", "'projects.Project'", ",", "step", ":", "'projects.ProjectStep'", ")", "->", "dict", ":", "with", "open", "(", "step", ".", "source_path", ",", "'r'", ")", "as", "f", ":", "code", "=", "f", ".", "read", "(", ")", "t...
Runs the markdown file and renders the contents to the notebook display :param project: :param step: :return: A run response dictionary containing
[ "Runs", "the", "markdown", "file", "and", "renders", "the", "contents", "to", "the", "notebook", "display" ]
python
train
24.259259
neithere/argh
argh/utils.py
https://github.com/neithere/argh/blob/dcd3253f2994400a6a58a700c118c53765bc50a4/argh/utils.py#L21-L43
def get_subparsers(parser, create=False): """ Returns the :class:`argparse._SubParsersAction` instance for given :class:`ArgumentParser` instance as would have been returned by :meth:`ArgumentParser.add_subparsers`. The problem with the latter is that it only works once and raises an exception on th...
[ "def", "get_subparsers", "(", "parser", ",", "create", "=", "False", ")", ":", "# note that ArgumentParser._subparsers is *not* what is returned by", "# ArgumentParser.add_subparsers().", "if", "parser", ".", "_subparsers", ":", "actions", "=", "[", "a", "for", "a", "in...
Returns the :class:`argparse._SubParsersAction` instance for given :class:`ArgumentParser` instance as would have been returned by :meth:`ArgumentParser.add_subparsers`. The problem with the latter is that it only works once and raises an exception on the second attempt, and the public API seems to lack...
[ "Returns", "the", ":", "class", ":", "argparse", ".", "_SubParsersAction", "instance", "for", "given", ":", "class", ":", "ArgumentParser", "instance", "as", "would", "have", "been", "returned", "by", ":", "meth", ":", "ArgumentParser", ".", "add_subparsers", ...
python
test
38.73913
jedie/DragonPy
dragonpy/utils/starter.py
https://github.com/jedie/DragonPy/blob/6659e5b5133aab26979a498ee7453495773a4f6c/dragonpy/utils/starter.py#L26-L44
def get_module_name(package): """ package must have these attributes: e.g.: package.DISTRIBUTION_NAME = "DragonPyEmulator" package.DIST_GROUP = "console_scripts" package.ENTRY_POINT = "DragonPy" :return: a string like: "dragonpy.core.cli" """ distribution = get_distribut...
[ "def", "get_module_name", "(", "package", ")", ":", "distribution", "=", "get_distribution", "(", "package", ".", "DISTRIBUTION_NAME", ")", "entry_info", "=", "distribution", ".", "get_entry_info", "(", "package", ".", "DIST_GROUP", ",", "package", ".", "ENTRY_POI...
package must have these attributes: e.g.: package.DISTRIBUTION_NAME = "DragonPyEmulator" package.DIST_GROUP = "console_scripts" package.ENTRY_POINT = "DragonPy" :return: a string like: "dragonpy.core.cli"
[ "package", "must", "have", "these", "attributes", ":", "e", ".", "g", ".", ":", "package", ".", "DISTRIBUTION_NAME", "=", "DragonPyEmulator", "package", ".", "DIST_GROUP", "=", "console_scripts", "package", ".", "ENTRY_POINT", "=", "DragonPy" ]
python
train
36.842105
hobson/aima
aima/logic.py
https://github.com/hobson/aima/blob/3572b2fb92039b4a1abe384be8545560fbd3d470/aima/logic.py#L650-L669
def dpll(clauses, symbols, model): "See if the clauses are true in a partial model." unknown_clauses = [] ## clauses with an unknown truth value for c in clauses: val = pl_true(c, model) if val == False: return False if val != True: unknown_clauses.append(c) ...
[ "def", "dpll", "(", "clauses", ",", "symbols", ",", "model", ")", ":", "unknown_clauses", "=", "[", "]", "## clauses with an unknown truth value", "for", "c", "in", "clauses", ":", "val", "=", "pl_true", "(", "c", ",", "model", ")", "if", "val", "==", "F...
See if the clauses are true in a partial model.
[ "See", "if", "the", "clauses", "are", "true", "in", "a", "partial", "model", "." ]
python
valid
39.65
NoviceLive/intellicoder
intellicoder/transformers.py
https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/transformers.py#L80-L91
def transform_sources(self, sources, with_string=False): """Get the defintions of needed strings and functions after replacement. """ modules = {} updater = partial( self.replace_source, modules=modules, prefix='string_') for filename in sources: u...
[ "def", "transform_sources", "(", "self", ",", "sources", ",", "with_string", "=", "False", ")", ":", "modules", "=", "{", "}", "updater", "=", "partial", "(", "self", ".", "replace_source", ",", "modules", "=", "modules", ",", "prefix", "=", "'string_'", ...
Get the defintions of needed strings and functions after replacement.
[ "Get", "the", "defintions", "of", "needed", "strings", "and", "functions", "after", "replacement", "." ]
python
train
42.916667
flo-compbio/genometools
genometools/ensembl/filter_fasta.py
https://github.com/flo-compbio/genometools/blob/dd962bb26d60a0f14ca14d8c9a4dd75768962c7d/genometools/ensembl/filter_fasta.py#L49-L84
def get_argument_parser(): """Returns an argument parser object for the script.""" desc = 'Filter FASTA file by chromosome names.' parser = cli.get_argument_parser(desc=desc) parser.add_argument( '-f', '--fasta-file', default='-', type=str, help=textwrap.dedent("""\ Path of the...
[ "def", "get_argument_parser", "(", ")", ":", "desc", "=", "'Filter FASTA file by chromosome names.'", "parser", "=", "cli", ".", "get_argument_parser", "(", "desc", "=", "desc", ")", "parser", ".", "add_argument", "(", "'-f'", ",", "'--fasta-file'", ",", "default"...
Returns an argument parser object for the script.
[ "Returns", "an", "argument", "parser", "object", "for", "the", "script", "." ]
python
train
36.777778